All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.KeyValueInput-CoupoYmE.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"KeyValueInput-CoupoYmE.js","sources":["../../src/components/key-value-form/ValueSelect.tsx","../../src/components/key-value-form/KeyValueInput.tsx"],"sourcesContent":["import { KeycloakSelect } from \"@keycloak/keycloak-ui-shared\";\nimport { SelectOption, TextInput } from \"@patternfly/react-core\";\nimport { useMemo, useState } from \"react\";\nimport { UseControllerProps, useController } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { DefaultValue } from \"./KeyValueInput\";\n\ntype ValueSelectProps = UseControllerProps & {\n  selectItems: DefaultValue[];\n  keyValue: string;\n};\n\nexport const ValueSelect = ({\n  selectItems,\n  keyValue,\n  ...rest\n}: ValueSelectProps) => {\n  const { t } = useTranslation();\n  const { field } = useController(rest);\n  const [open, setOpen] = useState(false);\n\n  const defaultItem = useMemo(\n    () => selectItems.find((v) => v.key === keyValue),\n    [selectItems, keyValue],\n  );\n\n  return defaultItem?.values ? (\n     setOpen(isOpen)}\n      isOpen={open}\n      onSelect={(value) => {\n        field.onChange(value);\n        setOpen(false);\n      }}\n      selections={field.value ? [field.value] : t(\"choose\")}\n      placeholderText={t(\"valuePlaceholder\")}\n    >\n      {defaultItem.values.map((item) => (\n        \n          {item}\n        \n      ))}\n    \n  ) : (\n    \n  );\n};\n","import {\n  ActionList,\n  ActionListItem,\n  Button,\n  EmptyState,\n  EmptyStateBody,\n  EmptyStateFooter,\n  Grid,\n  GridItem,\n  HelperText,\n  HelperTextItem,\n  TextInput,\n} from \"@patternfly/react-core\";\nimport { MinusCircleIcon, PlusCircleIcon } from \"@patternfly/react-icons\";\nimport { Fragment } from \"react\";\nimport {\n  FieldValues,\n  useFieldArray,\n  useFormContext,\n  useWatch,\n} from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { KeySelect } from \"./KeySelect\";\nimport { ValueSelect } from \"./ValueSelect\";\n\nexport type DefaultValue = {\n  key: string;\n  values?: string[];\n  label: string;\n};\n\ntype KeyValueInputProps = {\n  name: string;\n  label?: string;\n  defaultKeyValue?: DefaultValue[];\n  isDisabled?: boolean;\n};\n\nexport const KeyValueInput = ({\n  name,\n  label = \"attributes\",\n  defaultKeyValue,\n  isDisabled = false,\n}: KeyValueInputProps) => {\n  const { t } = useTranslation();\n  const {\n    control,\n    register,\n    formState: { errors },\n  } = useFormContext();\n\n  const { fields, append, remove } = useFieldArray({\n    shouldUnregister: true,\n    control,\n    name,\n  });\n\n  const appendNew = () => append({ key: \"\", value: \"\" });\n\n  const values = useWatch({\n    name,\n    control,\n    defaultValue: [],\n  });\n\n  return fields.length > 0 ? (\n    <>\n      \n        \n          {t(\"key\")}\n        \n        \n          {t(\"value\")}\n        \n        {fields.map((attribute, index) => {\n          const error = (errors as any)[name]?.[index];\n          const keyError = !!error?.key;\n          const valueErrorPresent = !!error?.value || !!error?.message;\n          const valueError = error?.message || t(\"valueError\");\n          return (\n            \n              \n                {defaultKeyValue ? (\n                  \n                ) : (\n                  \n                )}\n                {keyError && (\n                  \n                    \n                      {t(\"keyError\")}\n                    \n                  \n                )}\n              \n              \n                {defaultKeyValue ? (\n                  \n                ) : (\n                  \n                )}\n                {valueErrorPresent && (\n                  \n                    \n                      {valueError}\n                    \n                  \n                )}\n              \n              \n                 remove(index)}\n                  data-testid={`${name}-remove`}\n                  isDisabled={isDisabled}\n                >\n                  \n                \n              \n            \n          );\n        })}\n      \n      \n        \n          }\n            onClick={appendNew}\n            isDisabled={isDisabled}\n          >\n            {t(\"addAttribute\", { label })}\n          \n        \n      \n    \n  ) : (\n    \n      {t(\"missingAttributes\", { label })}\n      \n        }\n          size=\"sm\"\n          onClick={appendNew}\n          isDisabled={isDisabled}\n        >\n          {t(\"addAttribute\", { label })}\n        \n      \n    \n  );\n};\n"],"names":["ValueSelect","selectItems","keyValue","rest","t","useTranslation","field","useController","open","setOpen","useState","defaultItem","useMemo","v","jsx","KeycloakSelect","isOpen","value","item","SelectOption","TextInput","KeyValueInput","name","label","defaultKeyValue","isDisabled","control","register","errors","useFormContext","fields","append","remove","useFieldArray","appendNew","values","useWatch","jsxs","Fragment","Grid","GridItem","attribute","index","error","keyError","valueErrorPresent","valueError","KeySelect","HelperText","HelperTextItem","Button","MinusCircleIcon","ActionList","ActionListItem","PlusCircleIcon","EmptyState","EmptyStateBody","EmptyStateFooter"],"mappings":"6YAYO,MAAMA,EAAc,CAAC,CAC1B,YAAAC,EACA,SAAAC,EACA,GAAGC,CACL,IAAwB,CAChB,KAAA,CAAE,EAAAC,GAAMC,IACR,CAAE,MAAAC,CAAA,EAAUC,EAAcJ,CAAI,EAC9B,CAACK,EAAMC,CAAO,EAAIC,EAAS,EAAK,EAEhCC,EAAcC,EAClB,IAAMX,EAAY,KAAMY,GAAMA,EAAE,MAAQX,CAAQ,EAChD,CAACD,EAAaC,CAAQ,CAAA,EAGxB,OAAOS,GAAa,OAClBG,EAACC,EAAA,CACC,SAAWC,GAAWP,EAAQO,CAAM,EACpC,OAAQR,EACR,SAAWS,GAAU,CACnBX,EAAM,SAASW,CAAK,EACpBR,EAAQ,EAAK,CACf,EACA,WAAYH,EAAM,MAAQ,CAACA,EAAM,KAAK,EAAIF,EAAE,QAAQ,EACpD,gBAAiBA,EAAE,kBAAkB,EAEpC,SAAAO,EAAY,OAAO,IAAKO,GACtBJ,EAAAK,EAAA,CAAwB,MAAOD,EAC7B,SADgBA,CAAA,EAAAA,CAEnB,CACD,CAAA,CAAA,EAGHJ,EAACM,EAAA,CACC,aAAYhB,EAAE,aAAa,EAC3B,cAAaD,EAAK,KACjB,GAAGG,CAAA,CAAA,CAGV,ECXae,EAAgB,CAAC,CAC5B,KAAAC,EACA,MAAAC,EAAQ,aACR,gBAAAC,EACA,WAAAC,EAAa,EACf,IAA0B,CAClB,KAAA,CAAE,EAAArB,GAAMC,IACR,CACJ,QAAAqB,EACA,SAAAC,EAC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