@commercetools/nimbus 0.0.0-canary-20251010175720 → 0.0.0-canary-20251013071647
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{localized-field-CV69UdIU.es.js → localized-field-COJ9aoma.es.js} +2 -2
- package/dist/chunks/{localized-field-CV69UdIU.es.js.map → localized-field-COJ9aoma.es.js.map} +1 -1
- package/dist/chunks/{localized-field-BqUMaU2Z.cjs.js → localized-field-DCgNEoJc.cjs.js} +2 -2
- package/dist/chunks/{localized-field-BqUMaU2Z.cjs.js.map → localized-field-DCgNEoJc.cjs.js.map} +1 -1
- package/dist/chunks/{money-input-BklJuHw0.cjs.js → money-input-CwrbJsn1.cjs.js} +2 -2
- package/dist/chunks/{money-input-BklJuHw0.cjs.js.map → money-input-CwrbJsn1.cjs.js.map} +1 -1
- package/dist/chunks/{money-input-CavdTx-o.es.js → money-input-DvR9Nnz5.es.js} +2 -2
- package/dist/chunks/{money-input-CavdTx-o.es.js.map → money-input-DvR9Nnz5.es.js.map} +1 -1
- package/dist/chunks/{pagination-CBrMi7gy.es.js → pagination-2Zl9bHfw.es.js} +2 -2
- package/dist/chunks/{pagination-CBrMi7gy.es.js.map → pagination-2Zl9bHfw.es.js.map} +1 -1
- package/dist/chunks/{pagination-DUCo0L7g.cjs.js → pagination-EVJ_rBrc.cjs.js} +2 -2
- package/dist/chunks/{pagination-DUCo0L7g.cjs.js.map → pagination-EVJ_rBrc.cjs.js.map} +1 -1
- package/dist/chunks/select-97-5UUPX.cjs.js +2 -0
- package/dist/chunks/{select-D_HPNSo0.cjs.js.map → select-97-5UUPX.cjs.js.map} +1 -1
- package/dist/chunks/select-D5QaNAMe.es.js +775 -0
- package/dist/chunks/{select-CWttUH5b.es.js.map → select-D5QaNAMe.es.js.map} +1 -1
- package/dist/components/localized-field.cjs +1 -1
- package/dist/components/localized-field.es.js +1 -1
- package/dist/components/money-input.cjs +1 -1
- package/dist/components/money-input.es.js +1 -1
- package/dist/components/pagination.cjs +1 -1
- package/dist/components/pagination.es.js +1 -1
- package/dist/components/scoped-search-input.cjs +1 -1
- package/dist/components/scoped-search-input.es.js +1 -1
- package/dist/components/select.cjs +1 -1
- package/dist/components/select.es.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.es.js +4 -4
- package/dist/select.d.ts +110 -7
- package/package.json +5 -5
- package/dist/chunks/select-CWttUH5b.es.js +0 -690
- package/dist/chunks/select-D_HPNSo0.cjs.js +0 -2
|
@@ -7,7 +7,7 @@ import { WarningAmber as ne, HelpOutline as Ie, Payments as $e, Language as Me,
|
|
|
7
7
|
import { P as Ce } from "./popover-yeZXM_2G.es.js";
|
|
8
8
|
import { createSlotRecipeContext as je } from "@chakra-ui/react/styled-system";
|
|
9
9
|
import { l as Ee } from "./index-DthLdwMN.es.js";
|
|
10
|
-
import { M as k } from "./money-input-
|
|
10
|
+
import { M as k } from "./money-input-DvR9Nnz5.es.js";
|
|
11
11
|
import { F as I } from "./form-field-BrU_qJq3.es.js";
|
|
12
12
|
import { R as Se } from "./rich-text-input-CUAI0VeV.es.js";
|
|
13
13
|
import { M as ze } from "./multiline-text-input-BrE5zqv5.es.js";
|
|
@@ -468,4 +468,4 @@ const it = (e, t) => Object.values(e).map((o) => k.convertToMoneyValue(o, t)), o
|
|
|
468
468
|
export {
|
|
469
469
|
kt as L
|
|
470
470
|
};
|
|
471
|
-
//# sourceMappingURL=localized-field-
|
|
471
|
+
//# sourceMappingURL=localized-field-COJ9aoma.es.js.map
|
package/dist/chunks/{localized-field-CV69UdIU.es.js.map → localized-field-COJ9aoma.es.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localized-field-CV69UdIU.es.js","sources":["../../src/components/localized-field/localized-field.i18n.ts","../../src/components/localized-field/localized-field.slots.tsx","../../src/components/localized-field/utils/localized-field.utils.tsx","../../src/components/localized-field/components/localized-field.locale-field.tsx","../../src/components/localized-field/components/localized-field.root.tsx","../../src/components/localized-field/localized-field.tsx"],"sourcesContent":["import { defineMessages } from \"react-intl\";\n\nexport default defineMessages({\n missingRequiredField: {\n id: \"Nimbus.LocalizedField.missingRequiredField\",\n description: \"Error message for missing required value\",\n defaultMessage: \"This field is required. Provide at least one value.\",\n },\n infoBoxTriggerAriaLabel: {\n id: \"Nimbus.LocalizedField.infoBoxTriggerAriaLabel\",\n description: \"aria label for button that triggers more info dialog\",\n defaultMessage: \"more info\",\n },\n showLanguages: {\n id: \"Nimbus.LocalizedField.showLanguages\",\n description:\n \"Label for showing all language inputs when toggle button is pressed\",\n defaultMessage: \"Show all languages\",\n },\n hideLanguages: {\n id: \"Nimbus.LocalizedField.hideLanguages\",\n description:\n \"Label for hiding all language inputs when toggle button is pressed\",\n defaultMessage: \"Hide all languages\",\n },\n showCurrencies: {\n id: \"Nimbus.LocalizedField.showCurrencies\",\n description:\n \"Label for showing all currency inputs when toggle button is pressed\",\n defaultMessage: \"Show all currencies\",\n },\n hideCurrencies: {\n id: \"Nimbus.LocalizedField.hideCurrencies\",\n description:\n \"Label for hiding all currency inputs when toggle button is pressed\",\n defaultMessage: \"Hide all currencies\",\n },\n});\n","/* eslint-disable @typescript-eslint/no-empty-object-type */\nimport {\n type HTMLChakraProps,\n type RecipeVariantProps,\n createSlotRecipeContext,\n} from \"@chakra-ui/react/styled-system\";\nimport { localizedFieldSlotRecipe } from \"./localized-field.recipe\";\n\nconst { withProvider, withContext } = createSlotRecipeContext({\n recipe: localizedFieldSlotRecipe,\n});\n\n// Root Slot\nexport interface LocalizedFieldRootSlotProps\n extends HTMLChakraProps<\n \"fieldset\",\n RecipeVariantProps<typeof localizedFieldSlotRecipe>\n > {}\nexport const LocalizedFieldRootSlot = withProvider<\n HTMLFieldSetElement,\n LocalizedFieldRootSlotProps\n>(\"fieldset\", \"root\");\n\n// Label Slot\nexport interface LocalizedFieldLabelSlotProps\n extends HTMLChakraProps<\"label\"> {}\nexport const LocalizedFieldLabelSlot = withContext<\n HTMLLabelElement,\n LocalizedFieldLabelSlotProps\n>(\"legend\", \"label\");\n\n// InfoDialog Slot\nexport interface LocalizedFieldInfoDialogSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldInfoDialogSlot = withContext<\n HTMLDivElement,\n LocalizedFieldInfoDialogSlotProps\n>(\"div\", \"infoDialog\");\n\n// FieldsContainer Slot\nexport interface LocalizedFieldFieldsContainerSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldFieldsContainerSlot = withContext<\n HTMLDivElement,\n LocalizedFieldFieldsContainerSlotProps\n>(\"div\", \"fieldsContainer\");\n\n// Description Slot\nexport interface LocalizedFieldDescriptionSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldDescriptionSlot = withContext<\n HTMLDivElement,\n LocalizedFieldDescriptionSlotProps\n>(\"div\", \"description\");\n\n// Error Slot\nexport interface LocalizedFieldErrorSlotProps extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldErrorSlot = withContext<\n HTMLDivElement,\n LocalizedFieldErrorSlotProps\n>(\"div\", \"error\");\n\n// ToggleButtonContainer Slot\nexport interface LocalizedFieldToggleButtonContainerSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldToggleButtonContainerSlot = withContext<\n HTMLDivElement,\n LocalizedFieldToggleButtonContainerSlotProps\n>(\"div\", \"toggleButtonContainer\");\n\n// LocaleFieldRoot Slot\n\nexport interface LocalizedFieldLocaleFieldRootSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldRootSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldRootSlotProps\n>(\"div\", \"localeFieldRoot\");\n\n// FieldLabel Slot\nexport interface LocalizedFieldLocaleFieldLabelSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldLabelSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldLabelSlotProps\n>(\"div\", \"localeFieldLabel\");\n\n// FieldInput Slot\nexport interface LocalizedFieldLocaleFieldInputSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldInputSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldInputSlotProps\n>(\"div\", \"localeFieldInput\");\n","import { FormattedMessage } from \"react-intl\";\nimport {\n FormField,\n type TCurrencyCode,\n type TValue,\n type TMoneyValue,\n type TFieldErrors,\n MoneyInput,\n} from \"@/components\";\nimport messages from \"../localized-field.i18n\";\nimport type { LocalizedString } from \"../localized-field.types\";\n\ntype LanguagesSplitByDefaultLocale = {\n related: string[];\n unrelated: string[];\n};\n\ntype TouchedLocalizedString = { [locale: string]: boolean };\n\ntype CustomFormikErrors<Values> = {\n [K in keyof Values]?: TFieldErrors;\n};\n\nexport const RequiredValueErrorMessage = () => (\n <FormField.Error>\n <FormattedMessage {...messages.missingRequiredField} />\n </FormField.Error>\n);\n\nexport const getLocaleFieldAttribute = (\n fieldGroupAttr?: string,\n locale?: string\n): string | undefined =>\n fieldGroupAttr && locale ? `${fieldGroupAttr}.${locale}` : undefined;\n\n// gets the language tag of a given locale, e.g. `de` in `de-DE`\nexport const getLanguageForLocale = (locale: string): string =>\n locale.split(\"-\")[0];\n\n// splits the locales into two groups:\n// - the 'related' array contains locales with the same language tag as the default locale,\n// e.g. if the default locale is de-DE, related would be ['de-DE', 'de-CH']\n// - the 'unrelated' array contains locales with a different different language tag from the default locale\n//. e.g. if the default locale is de-DE, unrelated would be ['pt-BR', 'en-GB', 'zh-Hans']\nexport const splitLanguages = (\n defaultLocale: string,\n locales: string[]\n): LanguagesSplitByDefaultLocale => {\n const defaultLanguage = getLanguageForLocale(defaultLocale);\n const related = locales.filter(\n (locale) => getLanguageForLocale(locale) === defaultLanguage\n );\n const unrelated = locales.filter(\n (locale) => getLanguageForLocale(locale) !== defaultLanguage\n );\n return {\n unrelated,\n related,\n };\n};\n\n// sorts locales with the following priority:\n// - The selected locale is placed first (e.g pt-BR)\n// - All locales using the same language tag as the selected language\n// follow (e.g. pt, pt-PT). They are sorted alphabetically.\n// - All other locales follow, sorted alphabetically as well\nexport const sortLocalesByDefaultLocaleLanguage = (\n defaultLocale: string,\n allLocales: string[]\n): string[] => {\n const { related, unrelated } = splitLanguages(\n defaultLocale,\n allLocales.filter((locale: string) => locale !== defaultLocale)\n );\n\n return [defaultLocale, ...related.sort(), ...unrelated.sort()];\n};\n\nexport const sortCurrencies = (\n defaultCurrency: TCurrencyCode,\n allCurrencies: TCurrencyCode[]\n) => {\n const remainingCurrencies = allCurrencies.filter(\n (currency) => currency !== defaultCurrency\n );\n return [defaultCurrency, ...remainingCurrencies.sort()];\n};\n\nexport const getHasInvalidLocalizedFields = <TErrors extends object>(\n errors?: TErrors,\n defaultLocaleOrCurrency?: string\n): boolean => {\n if (errors && Object.keys(errors).length > 0 && defaultLocaleOrCurrency) {\n return Object.keys(errors).some(\n (localeOrCurrency) => localeOrCurrency !== defaultLocaleOrCurrency\n );\n }\n return false;\n};\n\nexport const createLocalizedString = (\n locales: string[],\n existingLocalizedString: LocalizedString\n): LocalizedString => {\n const localesInLocalizedString = Array.from(\n new Set([...locales, ...Object.keys(existingLocalizedString)])\n );\n\n return localesInLocalizedString.reduce<LocalizedString>(\n (localizedString, locale) => ({\n ...localizedString,\n [locale]: existingLocalizedString?.[locale] || \"\",\n }),\n {}\n );\n};\n\n// Note: I prefer `isLocalizedStringEmpty`, but keeping this as `isEmpty` for api consistency with UI Kit\nexport const isEmpty = (localizedString?: LocalizedString): boolean => {\n if (!localizedString) return true;\n return Object.values(localizedString).every(\n (value?: string) => !value || value?.trim().length === 0\n );\n};\n\nexport const omitEmptyTranslations = <Translations extends LocalizedString>(\n localizedString: Translations\n): LocalizedString => {\n // TODO: is it necessary to create a util that enforces a consistent warning/error format, e.g.\n // `<COMPONENT_NAME> - Warning: <WARNING_MESSAGE>`\n if (typeof localizedString !== \"object\") {\n console.warn(\n \"Nimbus Localized Field - Warning: omitEmptyTranslations must be called with an object\"\n );\n }\n\n return Object.entries(localizedString).reduce<LocalizedString>(\n (localizedStringWithoutEmptyTranslations, [locale, value]) => {\n if (value && value.trim().length > 0) {\n return {\n ...localizedStringWithoutEmptyTranslations,\n [locale]: value,\n };\n }\n return localizedStringWithoutEmptyTranslations;\n },\n {}\n );\n};\n\nexport const isTouched = (touched?: TouchedLocalizedString): boolean => {\n if (touched) {\n return Object.values(touched).some(Boolean);\n }\n return false;\n};\n\n/**\n * Use this function to convert the Formik `errors` object type to\n * our custom field errors type.\n * This is primarly useful when using TypeScript.\n */\nexport function toFieldErrors<FormValues>(\n errors: unknown\n): CustomFormikErrors<FormValues> {\n return errors as CustomFormikErrors<FormValues>;\n}\n\nexport const convertToMoneyValues = (\n values: TValue[],\n currency: string\n): Array<TMoneyValue | null> =>\n Object.values(values).map<TMoneyValue | null>((value) => {\n return MoneyInput.convertToMoneyValue(value, currency);\n });\n\nexport const parseMoneyValues = (\n moneyValues: TMoneyValue[] = [],\n locale: string\n): Record<TCurrencyCode, TValue> =>\n moneyValues.reduce<Record<TCurrencyCode, TValue>>(\n (allValues, moneyValue) => {\n const value = MoneyInput.parseMoneyValue(moneyValue, locale);\n return {\n ...allValues,\n [value.currencyCode]: value,\n };\n },\n {} as Record<TCurrencyCode, TValue>\n );\n\nexport const getHighPrecisionCurrencies = (\n values: Record<TCurrencyCode, TValue>,\n locale: string\n): TCurrencyCode[] => {\n const typedCurrencyCodes = Object.keys(values) as TCurrencyCode[];\n return typedCurrencyCodes.filter((currencyCode) =>\n MoneyInput.isHighPrecision(values[currencyCode], locale)\n );\n};\n\nexport const getEmptyCurrencies = (\n values: Record<TCurrencyCode, TValue>\n): TCurrencyCode[] => {\n const typedCurrencyCodes = Object.keys(values) as TCurrencyCode[];\n return typedCurrencyCodes.filter((currencyCode) =>\n MoneyInput.isEmpty(values[currencyCode])\n );\n};\n","import { useCallback } from \"react\";\nimport {\n FormField,\n Icon,\n TextInput,\n MoneyInput,\n type TCustomEvent,\n MultilineTextInput,\n RichTextInput,\n type TValue,\n type TCurrencyCode,\n} from \"@/components\";\nimport { WarningAmber } from \"@commercetools/nimbus-icons\";\nimport {\n LocalizedFieldLocaleFieldRootSlot,\n LocalizedFieldLocaleFieldInputSlot,\n LocalizedFieldLocaleFieldLabelSlot,\n} from \"../localized-field.slots\";\nimport type { LocalizedFieldLocaleFieldProps } from \"../localized-field.types\";\n\nexport const LocalizedFieldLocaleField = ({\n type,\n size,\n localeOrCurrency,\n id,\n name,\n inputValue: inputValueFromProps,\n description,\n warning,\n error,\n onChange,\n onBlur,\n onFocus,\n isRequired,\n isReadOnly,\n isDisabled,\n isInvalid,\n touched,\n ...otherProps\n}: LocalizedFieldLocaleFieldProps) => {\n let InputComponent:\n | typeof TextInput\n | typeof MultilineTextInput\n | typeof MoneyInput\n | typeof RichTextInput;\n switch (type) {\n case \"text\":\n default:\n InputComponent = TextInput;\n break;\n case \"multiLine\":\n InputComponent = MultilineTextInput;\n break;\n case \"money\":\n InputComponent = MoneyInput;\n break;\n case \"richText\":\n InputComponent = RichTextInput;\n break;\n }\n\n const getInputValue = () => {\n if (type === \"money\") {\n return inputValueFromProps\n ? (inputValueFromProps as TValue)\n : ({ amount: \"\", currencyCode: localeOrCurrency } as TValue);\n }\n return inputValueFromProps ? inputValueFromProps : \"\";\n };\n\n const inputValue = getInputValue();\n\n const handleChange = useCallback(\n (value: string | TCustomEvent | undefined) => {\n // The `MoneyInput` onChange event value is a custom value,\n // and the `MoneyInput` modifies the input id and name since it is in a `group`,\n // so we need to build a separate return object for the MoneInput to return\n // the expected values\n const isMoneyInputEvent = typeof value === \"object\";\n const changeValue = {\n target: isMoneyInputEvent\n ? {\n id: value.target.id,\n name: value.target.name,\n locale: undefined,\n currency: localeOrCurrency as TCurrencyCode,\n value: value.target.value,\n }\n : { id, name, locale: localeOrCurrency, currency: undefined, value },\n };\n onChange(changeValue);\n },\n [id, name, localeOrCurrency, onChange]\n );\n\n return (\n <LocalizedFieldLocaleFieldRootSlot asChild>\n <FormField.Root\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isInvalid={(isInvalid || !!error) && touched}\n direction=\"row\"\n size={size}\n id={id}\n >\n <LocalizedFieldLocaleFieldLabelSlot\n display={type === \"money\" ? \"none\" : undefined}\n {...(isDisabled && { \"data-disabled\": isDisabled })}\n asChild\n >\n <FormField.Label>\n {localeOrCurrency.toLocaleUpperCase()}\n </FormField.Label>\n </LocalizedFieldLocaleFieldLabelSlot>\n <FormField.Input>\n <LocalizedFieldLocaleFieldInputSlot\n aria-required={isRequired}\n asChild\n >\n <InputComponent\n {...otherProps}\n size={size}\n value={inputValue as string & TValue}\n onChange={handleChange}\n onBlur={(e: React.FocusEvent | TCustomEvent) =>\n onBlur?.(e, localeOrCurrency)\n }\n onFocus={(e: React.FocusEvent | TCustomEvent) =>\n onFocus?.(e, localeOrCurrency)\n }\n isRequired={isRequired}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isInvalid={(isInvalid || !!error) && touched}\n />\n </LocalizedFieldLocaleFieldInputSlot>\n </FormField.Input>\n {(description || (warning && touched)) && (\n <FormField.Description\n role={warning && touched ? \"status\" : undefined}\n color={warning && touched ? \"warning.11\" : undefined}\n display=\"flex\"\n gap=\"100\"\n alignItems=\"center\"\n >\n {warning && touched ? (\n <>\n <Icon colorPalette=\"warning\">\n <WarningAmber />\n </Icon>\n {warning}\n </>\n ) : (\n description\n )}\n </FormField.Description>\n )}\n {error && touched && <FormField.Error>{error}</FormField.Error>}\n </FormField.Root>\n </LocalizedFieldLocaleFieldRootSlot>\n );\n};\n","import { useState, useMemo } from \"react\";\nimport { useIntl } from \"react-intl\";\nimport {\n Collection as RaCollection,\n Dialog as RaDialog,\n DialogTrigger as RaDialogTrigger,\n} from \"react-aria-components\";\nimport { useField, useId } from \"react-aria\";\nimport {\n ErrorOutline,\n HelpOutline,\n Language,\n Payments,\n WarningAmber,\n} from \"@commercetools/nimbus-icons\";\nimport {\n Box,\n Button,\n FieldErrors,\n Icon,\n IconButton,\n Stack,\n type TCurrencyCode,\n} from \"@/components\";\nimport { Popover } from \"../../popover\";\nimport messages from \"../localized-field.i18n\";\nimport {\n LocalizedFieldRootSlot,\n LocalizedFieldLabelSlot,\n LocalizedFieldInfoDialogSlot,\n LocalizedFieldFieldsContainerSlot,\n LocalizedFieldDescriptionSlot,\n LocalizedFieldErrorSlot,\n LocalizedFieldToggleButtonContainerSlot,\n} from \"../localized-field.slots\";\nimport type {\n LocalizedFieldProps,\n MergedLocaleFieldData,\n LocalizedCurrency,\n} from \"../localized-field.types\";\n\nimport {\n getHasInvalidLocalizedFields,\n getLocaleFieldAttribute,\n sortCurrencies,\n sortLocalesByDefaultLocaleLanguage,\n} from \"../utils/localized-field.utils\";\nimport { LocalizedFieldLocaleField } from \"./localized-field.locale-field\";\n\nexport const LocalizedField = ({\n type = \"text\",\n id,\n name,\n defaultLocaleOrCurrency,\n valuesByLocaleOrCurrency,\n placeholdersByLocaleOrCurrency,\n descriptionsByLocaleOrCurrency,\n warningsByLocaleOrCurrency,\n errorsByLocaleOrCurrency,\n label,\n hint,\n description,\n warning,\n warnings,\n renderWarning,\n error,\n errors,\n renderError,\n touched,\n isRequired,\n isDisabled,\n isReadOnly,\n onChange,\n onBlur,\n onFocus,\n defaultExpanded = false,\n displayAllLocalesOrCurrencies = false,\n size,\n autoFocus,\n [\"data-track-component\"]: dataTrackComponent,\n [\"data-testid\"]: dataTestId,\n [\"data-test\"]: dataTest,\n // DOM & Style props for wrapper container\n ...rest\n}: LocalizedFieldProps) => {\n const [expanded, setExpanded] = useState(\n displayAllLocalesOrCurrencies || defaultExpanded\n );\n\n const { formatMessage } = useIntl();\n\n // Used to associate more info dialog with fieldset via `aria-controls`\n const localeFieldsContainerId = useId();\n // Used to associate more info dialog with fieldset via `aria-details`\n const moreDetailsButtonId = useId();\n\n // Either `error` exists, or there are `true` fields in the UI Kit compat `errors` object\n const hasError: boolean = Boolean(\n error || (errors && Object.values(errors).some((error) => error === true))\n );\n\n // Either `warning` exists, or there are `true` fields in the UI Kit compat `warnings` object\n const hasWarning: boolean = Boolean(\n warning || (warnings && Object.values(warnings).some(Boolean))\n );\n\n // FieldGroup is invalid if a non-field-specific error is passed and the group has been touched\n // When FieldGroup is invalid, all fields will display error styling without displaying a field-specific error message\n const isInvalid: boolean = !!(hasError && touched);\n\n const { labelProps, fieldProps, descriptionProps, errorMessageProps } =\n useField({\n id,\n label,\n description,\n errorMessage: error,\n isInvalid,\n });\n\n // Array of locales/currencies to display as input fields\n const localizationKeys: string[] | TCurrencyCode[] = Object.keys(\n valuesByLocaleOrCurrency\n );\n\n // Merge all -ByLocaleOrCurrencies data for each field\n const allDataForFields = useMemo(() => {\n const sortedFieldData =\n type === \"money\"\n ? sortCurrencies(\n defaultLocaleOrCurrency as TCurrencyCode,\n localizationKeys as TCurrencyCode[]\n )\n : sortLocalesByDefaultLocaleLanguage(\n defaultLocaleOrCurrency,\n localizationKeys\n );\n\n return sortedFieldData.reduce(\n (allFieldData: MergedLocaleFieldData[], localizationKey) => {\n const allDataForLocale = {\n localeOrCurrency: localizationKey,\n inputValue:\n type === \"money\"\n ? (valuesByLocaleOrCurrency as LocalizedCurrency)[localizationKey]\n : (valuesByLocaleOrCurrency[localizationKey] as string),\n placeholder: placeholdersByLocaleOrCurrency?.[localizationKey],\n description: descriptionsByLocaleOrCurrency?.[localizationKey],\n warning: warningsByLocaleOrCurrency?.[localizationKey],\n error: errorsByLocaleOrCurrency?.[localizationKey],\n // autoFocus default/first locale field\n ...(localizationKey === defaultLocaleOrCurrency && autoFocus\n ? { autoFocus }\n : {}),\n isInvalid,\n isRequired,\n isDisabled,\n isReadOnly,\n };\n if (\n expanded ||\n // Only display defaultLocaleOrInput field if fieldGroup is not expanded\n (!expanded && localizationKey === defaultLocaleOrCurrency)\n ) {\n return [...allFieldData, allDataForLocale];\n }\n return allFieldData;\n },\n []\n );\n }, [\n valuesByLocaleOrCurrency,\n placeholdersByLocaleOrCurrency,\n descriptionsByLocaleOrCurrency,\n warningsByLocaleOrCurrency,\n errorsByLocaleOrCurrency,\n defaultLocaleOrCurrency,\n expanded,\n isInvalid,\n isRequired,\n isDisabled,\n isReadOnly,\n ]);\n\n const groupHasInvalidLocalizedFields = getHasInvalidLocalizedFields(\n errorsByLocaleOrCurrency,\n defaultLocaleOrCurrency\n );\n\n const shouldExpandInvalidFields =\n (groupHasInvalidLocalizedFields || hasError) && touched;\n // If there are fields that are invalid, ensure that field group\n // shows all fields so that invalid field is visible\n if (shouldExpandInvalidFields && !expanded) {\n setExpanded(true);\n }\n\n return (\n <LocalizedFieldRootSlot\n {...rest}\n {...fieldProps}\n aria-details={hint ? moreDetailsButtonId : undefined}\n type={type}\n size={size}\n name={name}\n >\n {label && (\n <Stack direction=\"row\" gap=\"0\">\n <LocalizedFieldLabelSlot {...labelProps}>\n {label}\n {isRequired && <sup aria-hidden=\"true\">*</sup>}\n </LocalizedFieldLabelSlot>\n {hint && (\n <RaDialogTrigger>\n <IconButton\n id={moreDetailsButtonId}\n aria-label={formatMessage(messages.infoBoxTriggerAriaLabel)}\n size=\"2xs\"\n tone=\"info\"\n variant=\"link\"\n >\n <HelpOutline />\n </IconButton>\n\n <Popover padding={0}>\n <LocalizedFieldInfoDialogSlot asChild>\n <RaDialog>\n <Box p=\"300\">{hint}</Box>\n </RaDialog>\n </LocalizedFieldInfoDialogSlot>\n </Popover>\n </RaDialogTrigger>\n )}\n </Stack>\n )}\n <LocalizedFieldFieldsContainerSlot\n id={localeFieldsContainerId}\n data-expanded={expanded}\n >\n <RaCollection items={allDataForFields}>\n {(item) => {\n return (\n <LocalizedFieldLocaleField\n {...item}\n size={size}\n type={type}\n onChange={onChange}\n onBlur={onBlur}\n onFocus={onFocus}\n touched={touched}\n // Format field attributes to match uikit pattern\n id={getLocaleFieldAttribute(\n fieldProps.id,\n item.localeOrCurrency\n )}\n name={getLocaleFieldAttribute(name, item.localeOrCurrency)}\n data-test={getLocaleFieldAttribute(\n dataTest,\n item.localeOrCurrency\n )}\n data-testid={getLocaleFieldAttribute(\n dataTestId,\n item.localeOrCurrency\n )}\n data-track-component={getLocaleFieldAttribute(\n dataTrackComponent,\n item.localeOrCurrency\n )}\n />\n );\n }}\n </RaCollection>\n </LocalizedFieldFieldsContainerSlot>\n\n {!displayAllLocalesOrCurrencies && localizationKeys.length > 1 && (\n <LocalizedFieldToggleButtonContainerSlot>\n <Button\n aria-controls={localeFieldsContainerId}\n aria-describedby={labelProps.id}\n aria-expanded={expanded}\n onPress={() => setExpanded(!expanded)}\n isDisabled={isDisabled || (shouldExpandInvalidFields && expanded)}\n variant=\"ghost\"\n size=\"2xs\"\n colorPalette=\"primary\"\n >\n <Box\n as={type === \"money\" ? Payments : Language}\n display=\"inline-flex\"\n boxSize=\"400\"\n verticalAlign=\"text-bottom\"\n mr=\"100\"\n />\n {type === \"money\"\n ? expanded\n ? formatMessage(messages.hideCurrencies)\n : formatMessage(messages.showCurrencies)\n : expanded\n ? formatMessage(messages.hideLanguages)\n : formatMessage(messages.showLanguages)}\n </Button>\n </LocalizedFieldToggleButtonContainerSlot>\n )}\n {(description || (hasWarning && touched)) && (\n <LocalizedFieldDescriptionSlot\n role={hasWarning && touched ? \"status\" : undefined}\n color={hasWarning && touched ? \"warning.11\" : undefined}\n // In order to associate the warnings from both the warning and legacy warnings props with the fieldset,\n // we must associate, them to this element with aria-labelledby\n aria-labelledby={`${descriptionProps.id}-warning`}\n {...descriptionProps}\n >\n {/** Warnings are for compat with UI Kit localized fields */}\n {hasWarning && touched ? (\n <>\n <Icon colorPalette=\"warning\">\n <WarningAmber />\n </Icon>\n <Stack gap=\"0\" id={`${descriptionProps.id}-warning`}>\n {warning}\n {warnings && hasWarning && (\n <FieldErrors\n errors={warnings}\n renderError={renderWarning}\n colorPalette=\"warning\"\n role={undefined}\n />\n )}\n </Stack>\n </>\n ) : (\n description\n )}\n </LocalizedFieldDescriptionSlot>\n )}\n {isInvalid && (\n <LocalizedFieldErrorSlot\n // In order to associate the errors from both the error and legacy errors props with the fieldset,\n // we must associate them to this element with aria-labelledby.\n aria-labelledby={`${errorMessageProps.id}-error`}\n role=\"alert\"\n {...errorMessageProps}\n >\n <Icon>\n <ErrorOutline />\n </Icon>\n <Stack gap=\"0\" id={`${errorMessageProps.id}-error`}>\n {error}\n {errors && hasError && (\n <FieldErrors\n errors={errors}\n renderError={renderError}\n role={undefined}\n />\n )}\n </Stack>\n </LocalizedFieldErrorSlot>\n )}\n </LocalizedFieldRootSlot>\n );\n};\n","import { LocalizedField as LocalizedFieldRoot } from \"./components/localized-field.root\";\nimport {\n getLocaleFieldAttribute,\n createLocalizedString,\n isEmpty,\n omitEmptyTranslations,\n isTouched,\n RequiredValueErrorMessage,\n toFieldErrors,\n convertToMoneyValues,\n parseMoneyValues,\n getHighPrecisionCurrencies,\n getEmptyCurrencies,\n} from \"./utils/localized-field.utils\";\n\nexport const LocalizedField = Object.assign(LocalizedFieldRoot, {\n // Add util methods here for compat with uikit - see https://github.com/commercetools/ui-kit/blob/e97e0c7e8f3e9393981bf1949573212d7c571c90/packages/components/inputs/localized-text-input/src/localized-text-input.tsx#L396\n getId: getLocaleFieldAttribute,\n getName: getLocaleFieldAttribute,\n isTouched,\n isEmpty,\n createLocalizedString,\n omitEmptyTranslations,\n RequiredValueErrorMessage,\n toFieldErrors,\n convertToMoneyValues,\n parseMoneyValues,\n getHighPrecisionCurrencies,\n getEmptyCurrencies,\n});\n"],"names":["messages","defineMessages","withProvider","withContext","createSlotRecipeContext","localizedFieldSlotRecipe","LocalizedFieldRootSlot","LocalizedFieldLabelSlot","LocalizedFieldInfoDialogSlot","LocalizedFieldFieldsContainerSlot","LocalizedFieldDescriptionSlot","LocalizedFieldErrorSlot","LocalizedFieldToggleButtonContainerSlot","LocalizedFieldLocaleFieldRootSlot","LocalizedFieldLocaleFieldLabelSlot","LocalizedFieldLocaleFieldInputSlot","RequiredValueErrorMessage","jsx","FormField","FormattedMessage","getLocaleFieldAttribute","fieldGroupAttr","locale","getLanguageForLocale","splitLanguages","defaultLocale","locales","defaultLanguage","related","sortLocalesByDefaultLocaleLanguage","allLocales","unrelated","sortCurrencies","defaultCurrency","allCurrencies","remainingCurrencies","currency","getHasInvalidLocalizedFields","errors","defaultLocaleOrCurrency","localeOrCurrency","createLocalizedString","existingLocalizedString","localizedString","isEmpty","value","omitEmptyTranslations","localizedStringWithoutEmptyTranslations","isTouched","touched","toFieldErrors","convertToMoneyValues","values","MoneyInput","parseMoneyValues","moneyValues","allValues","moneyValue","getHighPrecisionCurrencies","currencyCode","getEmptyCurrencies","LocalizedFieldLocaleField","type","size","id","name","inputValueFromProps","description","warning","error","onChange","onBlur","onFocus","isRequired","isReadOnly","isDisabled","isInvalid","otherProps","InputComponent","TextInput","MultilineTextInput","RichTextInput","inputValue","handleChange","useCallback","changeValue","jsxs","e","Fragment","Icon","WarningAmber","LocalizedField","valuesByLocaleOrCurrency","placeholdersByLocaleOrCurrency","descriptionsByLocaleOrCurrency","warningsByLocaleOrCurrency","errorsByLocaleOrCurrency","label","hint","warnings","renderWarning","renderError","defaultExpanded","displayAllLocalesOrCurrencies","autoFocus","dataTrackComponent","dataTestId","dataTest","rest","expanded","setExpanded","useState","formatMessage","useIntl","localeFieldsContainerId","useId","moreDetailsButtonId","hasError","hasWarning","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","localizationKeys","allDataForFields","useMemo","allFieldData","localizationKey","allDataForLocale","shouldExpandInvalidFields","Stack","RaDialogTrigger","IconButton","HelpOutline","Popover","RaDialog","Box","RaCollection","item","Button","Payments","Language","FieldErrors","ErrorOutline","LocalizedFieldRoot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,MAAAA,IAAe,gBAAAC,GAAe;AAAA,EAC5B,sBAAsB;AAAA,IACpB,IAAI;AAAA,IACJ,aAAa;AAAA,IACb,gBAAgB;AAAA,EAAA;AAAA,EAElB,yBAAyB;AAAA,IACvB,IAAI;AAAA,IACJ,aAAa;AAAA,IACb,gBAAgB;AAAA,EAAA;A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EACA,2BAAA9B;AAAA,EACA,eAAAkC;AAAA,EACA,sBAAAC;AAAA,EACA,kBAAAG;AAAA,EACA,4BAAAI;AAAA,EACA,oBAAAE;AACF,CAAC;"}
|
|
1
|
+
{"version":3,"file":"localized-field-COJ9aoma.es.js","sources":["../../src/components/localized-field/localized-field.i18n.ts","../../src/components/localized-field/localized-field.slots.tsx","../../src/components/localized-field/utils/localized-field.utils.tsx","../../src/components/localized-field/components/localized-field.locale-field.tsx","../../src/components/localized-field/components/localized-field.root.tsx","../../src/components/localized-field/localized-field.tsx"],"sourcesContent":["import { defineMessages } from \"react-intl\";\n\nexport default defineMessages({\n missingRequiredField: {\n id: \"Nimbus.LocalizedField.missingRequiredField\",\n description: \"Error message for missing required value\",\n defaultMessage: \"This field is required. Provide at least one value.\",\n },\n infoBoxTriggerAriaLabel: {\n id: \"Nimbus.LocalizedField.infoBoxTriggerAriaLabel\",\n description: \"aria label for button that triggers more info dialog\",\n defaultMessage: \"more info\",\n },\n showLanguages: {\n id: \"Nimbus.LocalizedField.showLanguages\",\n description:\n \"Label for showing all language inputs when toggle button is pressed\",\n defaultMessage: \"Show all languages\",\n },\n hideLanguages: {\n id: \"Nimbus.LocalizedField.hideLanguages\",\n description:\n \"Label for hiding all language inputs when toggle button is pressed\",\n defaultMessage: \"Hide all languages\",\n },\n showCurrencies: {\n id: \"Nimbus.LocalizedField.showCurrencies\",\n description:\n \"Label for showing all currency inputs when toggle button is pressed\",\n defaultMessage: \"Show all currencies\",\n },\n hideCurrencies: {\n id: \"Nimbus.LocalizedField.hideCurrencies\",\n description:\n \"Label for hiding all currency inputs when toggle button is pressed\",\n defaultMessage: \"Hide all currencies\",\n },\n});\n","/* eslint-disable @typescript-eslint/no-empty-object-type */\nimport {\n type HTMLChakraProps,\n type RecipeVariantProps,\n createSlotRecipeContext,\n} from \"@chakra-ui/react/styled-system\";\nimport { localizedFieldSlotRecipe } from \"./localized-field.recipe\";\n\nconst { withProvider, withContext } = createSlotRecipeContext({\n recipe: localizedFieldSlotRecipe,\n});\n\n// Root Slot\nexport interface LocalizedFieldRootSlotProps\n extends HTMLChakraProps<\n \"fieldset\",\n RecipeVariantProps<typeof localizedFieldSlotRecipe>\n > {}\nexport const LocalizedFieldRootSlot = withProvider<\n HTMLFieldSetElement,\n LocalizedFieldRootSlotProps\n>(\"fieldset\", \"root\");\n\n// Label Slot\nexport interface LocalizedFieldLabelSlotProps\n extends HTMLChakraProps<\"label\"> {}\nexport const LocalizedFieldLabelSlot = withContext<\n HTMLLabelElement,\n LocalizedFieldLabelSlotProps\n>(\"legend\", \"label\");\n\n// InfoDialog Slot\nexport interface LocalizedFieldInfoDialogSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldInfoDialogSlot = withContext<\n HTMLDivElement,\n LocalizedFieldInfoDialogSlotProps\n>(\"div\", \"infoDialog\");\n\n// FieldsContainer Slot\nexport interface LocalizedFieldFieldsContainerSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldFieldsContainerSlot = withContext<\n HTMLDivElement,\n LocalizedFieldFieldsContainerSlotProps\n>(\"div\", \"fieldsContainer\");\n\n// Description Slot\nexport interface LocalizedFieldDescriptionSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldDescriptionSlot = withContext<\n HTMLDivElement,\n LocalizedFieldDescriptionSlotProps\n>(\"div\", \"description\");\n\n// Error Slot\nexport interface LocalizedFieldErrorSlotProps extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldErrorSlot = withContext<\n HTMLDivElement,\n LocalizedFieldErrorSlotProps\n>(\"div\", \"error\");\n\n// ToggleButtonContainer Slot\nexport interface LocalizedFieldToggleButtonContainerSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldToggleButtonContainerSlot = withContext<\n HTMLDivElement,\n LocalizedFieldToggleButtonContainerSlotProps\n>(\"div\", \"toggleButtonContainer\");\n\n// LocaleFieldRoot Slot\n\nexport interface LocalizedFieldLocaleFieldRootSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldRootSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldRootSlotProps\n>(\"div\", \"localeFieldRoot\");\n\n// FieldLabel Slot\nexport interface LocalizedFieldLocaleFieldLabelSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldLabelSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldLabelSlotProps\n>(\"div\", \"localeFieldLabel\");\n\n// FieldInput Slot\nexport interface LocalizedFieldLocaleFieldInputSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldInputSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldInputSlotProps\n>(\"div\", \"localeFieldInput\");\n","import { FormattedMessage } from \"react-intl\";\nimport {\n FormField,\n type TCurrencyCode,\n type TValue,\n type TMoneyValue,\n type TFieldErrors,\n MoneyInput,\n} from \"@/components\";\nimport messages from \"../localized-field.i18n\";\nimport type { LocalizedString } from \"../localized-field.types\";\n\ntype LanguagesSplitByDefaultLocale = {\n related: string[];\n unrelated: string[];\n};\n\ntype TouchedLocalizedString = { [locale: string]: boolean };\n\ntype CustomFormikErrors<Values> = {\n [K in keyof Values]?: TFieldErrors;\n};\n\nexport const RequiredValueErrorMessage = () => (\n <FormField.Error>\n <FormattedMessage {...messages.missingRequiredField} />\n </FormField.Error>\n);\n\nexport const getLocaleFieldAttribute = (\n fieldGroupAttr?: string,\n locale?: string\n): string | undefined =>\n fieldGroupAttr && locale ? `${fieldGroupAttr}.${locale}` : undefined;\n\n// gets the language tag of a given locale, e.g. `de` in `de-DE`\nexport const getLanguageForLocale = (locale: string): string =>\n locale.split(\"-\")[0];\n\n// splits the locales into two groups:\n// - the 'related' array contains locales with the same language tag as the default locale,\n// e.g. if the default locale is de-DE, related would be ['de-DE', 'de-CH']\n// - the 'unrelated' array contains locales with a different different language tag from the default locale\n//. e.g. if the default locale is de-DE, unrelated would be ['pt-BR', 'en-GB', 'zh-Hans']\nexport const splitLanguages = (\n defaultLocale: string,\n locales: string[]\n): LanguagesSplitByDefaultLocale => {\n const defaultLanguage = getLanguageForLocale(defaultLocale);\n const related = locales.filter(\n (locale) => getLanguageForLocale(locale) === defaultLanguage\n );\n const unrelated = locales.filter(\n (locale) => getLanguageForLocale(locale) !== defaultLanguage\n );\n return {\n unrelated,\n related,\n };\n};\n\n// sorts locales with the following priority:\n// - The selected locale is placed first (e.g pt-BR)\n// - All locales using the same language tag as the selected language\n// follow (e.g. pt, pt-PT). They are sorted alphabetically.\n// - All other locales follow, sorted alphabetically as well\nexport const sortLocalesByDefaultLocaleLanguage = (\n defaultLocale: string,\n allLocales: string[]\n): string[] => {\n const { related, unrelated } = splitLanguages(\n defaultLocale,\n allLocales.filter((locale: string) => locale !== defaultLocale)\n );\n\n return [defaultLocale, ...related.sort(), ...unrelated.sort()];\n};\n\nexport const sortCurrencies = (\n defaultCurrency: TCurrencyCode,\n allCurrencies: TCurrencyCode[]\n) => {\n const remainingCurrencies = allCurrencies.filter(\n (currency) => currency !== defaultCurrency\n );\n return [defaultCurrency, ...remainingCurrencies.sort()];\n};\n\nexport const getHasInvalidLocalizedFields = <TErrors extends object>(\n errors?: TErrors,\n defaultLocaleOrCurrency?: string\n): boolean => {\n if (errors && Object.keys(errors).length > 0 && defaultLocaleOrCurrency) {\n return Object.keys(errors).some(\n (localeOrCurrency) => localeOrCurrency !== defaultLocaleOrCurrency\n );\n }\n return false;\n};\n\nexport const createLocalizedString = (\n locales: string[],\n existingLocalizedString: LocalizedString\n): LocalizedString => {\n const localesInLocalizedString = Array.from(\n new Set([...locales, ...Object.keys(existingLocalizedString)])\n );\n\n return localesInLocalizedString.reduce<LocalizedString>(\n (localizedString, locale) => ({\n ...localizedString,\n [locale]: existingLocalizedString?.[locale] || \"\",\n }),\n {}\n );\n};\n\n// Note: I prefer `isLocalizedStringEmpty`, but keeping this as `isEmpty` for api consistency with UI Kit\nexport const isEmpty = (localizedString?: LocalizedString): boolean => {\n if (!localizedString) return true;\n return Object.values(localizedString).every(\n (value?: string) => !value || value?.trim().length === 0\n );\n};\n\nexport const omitEmptyTranslations = <Translations extends LocalizedString>(\n localizedString: Translations\n): LocalizedString => {\n // TODO: is it necessary to create a util that enforces a consistent warning/error format, e.g.\n // `<COMPONENT_NAME> - Warning: <WARNING_MESSAGE>`\n if (typeof localizedString !== \"object\") {\n console.warn(\n \"Nimbus Localized Field - Warning: omitEmptyTranslations must be called with an object\"\n );\n }\n\n return Object.entries(localizedString).reduce<LocalizedString>(\n (localizedStringWithoutEmptyTranslations, [locale, value]) => {\n if (value && value.trim().length > 0) {\n return {\n ...localizedStringWithoutEmptyTranslations,\n [locale]: value,\n };\n }\n return localizedStringWithoutEmptyTranslations;\n },\n {}\n );\n};\n\nexport const isTouched = (touched?: TouchedLocalizedString): boolean => {\n if (touched) {\n return Object.values(touched).some(Boolean);\n }\n return false;\n};\n\n/**\n * Use this function to convert the Formik `errors` object type to\n * our custom field errors type.\n * This is primarly useful when using TypeScript.\n */\nexport function toFieldErrors<FormValues>(\n errors: unknown\n): CustomFormikErrors<FormValues> {\n return errors as CustomFormikErrors<FormValues>;\n}\n\nexport const convertToMoneyValues = (\n values: TValue[],\n currency: string\n): Array<TMoneyValue | null> =>\n Object.values(values).map<TMoneyValue | null>((value) => {\n return MoneyInput.convertToMoneyValue(value, currency);\n });\n\nexport const parseMoneyValues = (\n moneyValues: TMoneyValue[] = [],\n locale: string\n): Record<TCurrencyCode, TValue> =>\n moneyValues.reduce<Record<TCurrencyCode, TValue>>(\n (allValues, moneyValue) => {\n const value = MoneyInput.parseMoneyValue(moneyValue, locale);\n return {\n ...allValues,\n [value.currencyCode]: value,\n };\n },\n {} as Record<TCurrencyCode, TValue>\n );\n\nexport const getHighPrecisionCurrencies = (\n values: Record<TCurrencyCode, TValue>,\n locale: string\n): TCurrencyCode[] => {\n const typedCurrencyCodes = Object.keys(values) as TCurrencyCode[];\n return typedCurrencyCodes.filter((currencyCode) =>\n MoneyInput.isHighPrecision(values[currencyCode], locale)\n );\n};\n\nexport const getEmptyCurrencies = (\n values: Record<TCurrencyCode, TValue>\n): TCurrencyCode[] => {\n const typedCurrencyCodes = Object.keys(values) as TCurrencyCode[];\n return typedCurrencyCodes.filter((currencyCode) =>\n MoneyInput.isEmpty(values[currencyCode])\n );\n};\n","import { useCallback } from \"react\";\nimport {\n FormField,\n Icon,\n TextInput,\n MoneyInput,\n type TCustomEvent,\n MultilineTextInput,\n RichTextInput,\n type TValue,\n type TCurrencyCode,\n} from \"@/components\";\nimport { WarningAmber } from \"@commercetools/nimbus-icons\";\nimport {\n LocalizedFieldLocaleFieldRootSlot,\n LocalizedFieldLocaleFieldInputSlot,\n LocalizedFieldLocaleFieldLabelSlot,\n} from \"../localized-field.slots\";\nimport type { LocalizedFieldLocaleFieldProps } from \"../localized-field.types\";\n\nexport const LocalizedFieldLocaleField = ({\n type,\n size,\n localeOrCurrency,\n id,\n name,\n inputValue: inputValueFromProps,\n description,\n warning,\n error,\n onChange,\n onBlur,\n onFocus,\n isRequired,\n isReadOnly,\n isDisabled,\n isInvalid,\n touched,\n ...otherProps\n}: LocalizedFieldLocaleFieldProps) => {\n let InputComponent:\n | typeof TextInput\n | typeof MultilineTextInput\n | typeof MoneyInput\n | typeof RichTextInput;\n switch (type) {\n case \"text\":\n default:\n InputComponent = TextInput;\n break;\n case \"multiLine\":\n InputComponent = MultilineTextInput;\n break;\n case \"money\":\n InputComponent = MoneyInput;\n break;\n case \"richText\":\n InputComponent = RichTextInput;\n break;\n }\n\n const getInputValue = () => {\n if (type === \"money\") {\n return inputValueFromProps\n ? (inputValueFromProps as TValue)\n : ({ amount: \"\", currencyCode: localeOrCurrency } as TValue);\n }\n return inputValueFromProps ? inputValueFromProps : \"\";\n };\n\n const inputValue = getInputValue();\n\n const handleChange = useCallback(\n (value: string | TCustomEvent | undefined) => {\n // The `MoneyInput` onChange event value is a custom value,\n // and the `MoneyInput` modifies the input id and name since it is in a `group`,\n // so we need to build a separate return object for the MoneInput to return\n // the expected values\n const isMoneyInputEvent = typeof value === \"object\";\n const changeValue = {\n target: isMoneyInputEvent\n ? {\n id: value.target.id,\n name: value.target.name,\n locale: undefined,\n currency: localeOrCurrency as TCurrencyCode,\n value: value.target.value,\n }\n : { id, name, locale: localeOrCurrency, currency: undefined, value },\n };\n onChange(changeValue);\n },\n [id, name, localeOrCurrency, onChange]\n );\n\n return (\n <LocalizedFieldLocaleFieldRootSlot asChild>\n <FormField.Root\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isInvalid={(isInvalid || !!error) && touched}\n direction=\"row\"\n size={size}\n id={id}\n >\n <LocalizedFieldLocaleFieldLabelSlot\n display={type === \"money\" ? \"none\" : undefined}\n {...(isDisabled && { \"data-disabled\": isDisabled })}\n asChild\n >\n <FormField.Label>\n {localeOrCurrency.toLocaleUpperCase()}\n </FormField.Label>\n </LocalizedFieldLocaleFieldLabelSlot>\n <FormField.Input>\n <LocalizedFieldLocaleFieldInputSlot\n aria-required={isRequired}\n asChild\n >\n <InputComponent\n {...otherProps}\n size={size}\n value={inputValue as string & TValue}\n onChange={handleChange}\n onBlur={(e: React.FocusEvent | TCustomEvent) =>\n onBlur?.(e, localeOrCurrency)\n }\n onFocus={(e: React.FocusEvent | TCustomEvent) =>\n onFocus?.(e, localeOrCurrency)\n }\n isRequired={isRequired}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isInvalid={(isInvalid || !!error) && touched}\n />\n </LocalizedFieldLocaleFieldInputSlot>\n </FormField.Input>\n {(description || (warning && touched)) && (\n <FormField.Description\n role={warning && touched ? \"status\" : undefined}\n color={warning && touched ? \"warning.11\" : undefined}\n display=\"flex\"\n gap=\"100\"\n alignItems=\"center\"\n >\n {warning && touched ? (\n <>\n <Icon colorPalette=\"warning\">\n <WarningAmber />\n </Icon>\n {warning}\n </>\n ) : (\n description\n )}\n </FormField.Description>\n )}\n {error && touched && <FormField.Error>{error}</FormField.Error>}\n </FormField.Root>\n </LocalizedFieldLocaleFieldRootSlot>\n );\n};\n","import { useState, useMemo } from \"react\";\nimport { useIntl } from \"react-intl\";\nimport {\n Collection as RaCollection,\n Dialog as RaDialog,\n DialogTrigger as RaDialogTrigger,\n} from \"react-aria-components\";\nimport { useField, useId } from \"react-aria\";\nimport {\n ErrorOutline,\n HelpOutline,\n Language,\n Payments,\n WarningAmber,\n} from \"@commercetools/nimbus-icons\";\nimport {\n Box,\n Button,\n FieldErrors,\n Icon,\n IconButton,\n Stack,\n type TCurrencyCode,\n} from \"@/components\";\nimport { Popover } from \"../../popover\";\nimport messages from \"../localized-field.i18n\";\nimport {\n LocalizedFieldRootSlot,\n LocalizedFieldLabelSlot,\n LocalizedFieldInfoDialogSlot,\n LocalizedFieldFieldsContainerSlot,\n LocalizedFieldDescriptionSlot,\n LocalizedFieldErrorSlot,\n LocalizedFieldToggleButtonContainerSlot,\n} from \"../localized-field.slots\";\nimport type {\n LocalizedFieldProps,\n MergedLocaleFieldData,\n LocalizedCurrency,\n} from \"../localized-field.types\";\n\nimport {\n getHasInvalidLocalizedFields,\n getLocaleFieldAttribute,\n sortCurrencies,\n sortLocalesByDefaultLocaleLanguage,\n} from \"../utils/localized-field.utils\";\nimport { LocalizedFieldLocaleField } from \"./localized-field.locale-field\";\n\nexport const LocalizedField = ({\n type = \"text\",\n id,\n name,\n defaultLocaleOrCurrency,\n valuesByLocaleOrCurrency,\n placeholdersByLocaleOrCurrency,\n descriptionsByLocaleOrCurrency,\n warningsByLocaleOrCurrency,\n errorsByLocaleOrCurrency,\n label,\n hint,\n description,\n warning,\n warnings,\n renderWarning,\n error,\n errors,\n renderError,\n touched,\n isRequired,\n isDisabled,\n isReadOnly,\n onChange,\n onBlur,\n onFocus,\n defaultExpanded = false,\n displayAllLocalesOrCurrencies = false,\n size,\n autoFocus,\n [\"data-track-component\"]: dataTrackComponent,\n [\"data-testid\"]: dataTestId,\n [\"data-test\"]: dataTest,\n // DOM & Style props for wrapper container\n ...rest\n}: LocalizedFieldProps) => {\n const [expanded, setExpanded] = useState(\n displayAllLocalesOrCurrencies || defaultExpanded\n );\n\n const { formatMessage } = useIntl();\n\n // Used to associate more info dialog with fieldset via `aria-controls`\n const localeFieldsContainerId = useId();\n // Used to associate more info dialog with fieldset via `aria-details`\n const moreDetailsButtonId = useId();\n\n // Either `error` exists, or there are `true` fields in the UI Kit compat `errors` object\n const hasError: boolean = Boolean(\n error || (errors && Object.values(errors).some((error) => error === true))\n );\n\n // Either `warning` exists, or there are `true` fields in the UI Kit compat `warnings` object\n const hasWarning: boolean = Boolean(\n warning || (warnings && Object.values(warnings).some(Boolean))\n );\n\n // FieldGroup is invalid if a non-field-specific error is passed and the group has been touched\n // When FieldGroup is invalid, all fields will display error styling without displaying a field-specific error message\n const isInvalid: boolean = !!(hasError && touched);\n\n const { labelProps, fieldProps, descriptionProps, errorMessageProps } =\n useField({\n id,\n label,\n description,\n errorMessage: error,\n isInvalid,\n });\n\n // Array of locales/currencies to display as input fields\n const localizationKeys: string[] | TCurrencyCode[] = Object.keys(\n valuesByLocaleOrCurrency\n );\n\n // Merge all -ByLocaleOrCurrencies data for each field\n const allDataForFields = useMemo(() => {\n const sortedFieldData =\n type === \"money\"\n ? sortCurrencies(\n defaultLocaleOrCurrency as TCurrencyCode,\n localizationKeys as TCurrencyCode[]\n )\n : sortLocalesByDefaultLocaleLanguage(\n defaultLocaleOrCurrency,\n localizationKeys\n );\n\n return sortedFieldData.reduce(\n (allFieldData: MergedLocaleFieldData[], localizationKey) => {\n const allDataForLocale = {\n localeOrCurrency: localizationKey,\n inputValue:\n type === \"money\"\n ? (valuesByLocaleOrCurrency as LocalizedCurrency)[localizationKey]\n : (valuesByLocaleOrCurrency[localizationKey] as string),\n placeholder: placeholdersByLocaleOrCurrency?.[localizationKey],\n description: descriptionsByLocaleOrCurrency?.[localizationKey],\n warning: warningsByLocaleOrCurrency?.[localizationKey],\n error: errorsByLocaleOrCurrency?.[localizationKey],\n // autoFocus default/first locale field\n ...(localizationKey === defaultLocaleOrCurrency && autoFocus\n ? { autoFocus }\n : {}),\n isInvalid,\n isRequired,\n isDisabled,\n isReadOnly,\n };\n if (\n expanded ||\n // Only display defaultLocaleOrInput field if fieldGroup is not expanded\n (!expanded && localizationKey === defaultLocaleOrCurrency)\n ) {\n return [...allFieldData, allDataForLocale];\n }\n return allFieldData;\n },\n []\n );\n }, [\n valuesByLocaleOrCurrency,\n placeholdersByLocaleOrCurrency,\n descriptionsByLocaleOrCurrency,\n warningsByLocaleOrCurrency,\n errorsByLocaleOrCurrency,\n defaultLocaleOrCurrency,\n expanded,\n isInvalid,\n isRequired,\n isDisabled,\n isReadOnly,\n ]);\n\n const groupHasInvalidLocalizedFields = getHasInvalidLocalizedFields(\n errorsByLocaleOrCurrency,\n defaultLocaleOrCurrency\n );\n\n const shouldExpandInvalidFields =\n (groupHasInvalidLocalizedFields || hasError) && touched;\n // If there are fields that are invalid, ensure that field group\n // shows all fields so that invalid field is visible\n if (shouldExpandInvalidFields && !expanded) {\n setExpanded(true);\n }\n\n return (\n <LocalizedFieldRootSlot\n {...rest}\n {...fieldProps}\n aria-details={hint ? moreDetailsButtonId : undefined}\n type={type}\n size={size}\n name={name}\n >\n {label && (\n <Stack direction=\"row\" gap=\"0\">\n <LocalizedFieldLabelSlot {...labelProps}>\n {label}\n {isRequired && <sup aria-hidden=\"true\">*</sup>}\n </LocalizedFieldLabelSlot>\n {hint && (\n <RaDialogTrigger>\n <IconButton\n id={moreDetailsButtonId}\n aria-label={formatMessage(messages.infoBoxTriggerAriaLabel)}\n size=\"2xs\"\n tone=\"info\"\n variant=\"link\"\n >\n <HelpOutline />\n </IconButton>\n\n <Popover padding={0}>\n <LocalizedFieldInfoDialogSlot asChild>\n <RaDialog>\n <Box p=\"300\">{hint}</Box>\n </RaDialog>\n </LocalizedFieldInfoDialogSlot>\n </Popover>\n </RaDialogTrigger>\n )}\n </Stack>\n )}\n <LocalizedFieldFieldsContainerSlot\n id={localeFieldsContainerId}\n data-expanded={expanded}\n >\n <RaCollection items={allDataForFields}>\n {(item) => {\n return (\n <LocalizedFieldLocaleField\n {...item}\n size={size}\n type={type}\n onChange={onChange}\n onBlur={onBlur}\n onFocus={onFocus}\n touched={touched}\n // Format field attributes to match uikit pattern\n id={getLocaleFieldAttribute(\n fieldProps.id,\n item.localeOrCurrency\n )}\n name={getLocaleFieldAttribute(name, item.localeOrCurrency)}\n data-test={getLocaleFieldAttribute(\n dataTest,\n item.localeOrCurrency\n )}\n data-testid={getLocaleFieldAttribute(\n dataTestId,\n item.localeOrCurrency\n )}\n data-track-component={getLocaleFieldAttribute(\n dataTrackComponent,\n item.localeOrCurrency\n )}\n />\n );\n }}\n </RaCollection>\n </LocalizedFieldFieldsContainerSlot>\n\n {!displayAllLocalesOrCurrencies && localizationKeys.length > 1 && (\n <LocalizedFieldToggleButtonContainerSlot>\n <Button\n aria-controls={localeFieldsContainerId}\n aria-describedby={labelProps.id}\n aria-expanded={expanded}\n onPress={() => setExpanded(!expanded)}\n isDisabled={isDisabled || (shouldExpandInvalidFields && expanded)}\n variant=\"ghost\"\n size=\"2xs\"\n colorPalette=\"primary\"\n >\n <Box\n as={type === \"money\" ? Payments : Language}\n display=\"inline-flex\"\n boxSize=\"400\"\n verticalAlign=\"text-bottom\"\n mr=\"100\"\n />\n {type === \"money\"\n ? expanded\n ? formatMessage(messages.hideCurrencies)\n : formatMessage(messages.showCurrencies)\n : expanded\n ? formatMessage(messages.hideLanguages)\n : formatMessage(messages.showLanguages)}\n </Button>\n </LocalizedFieldToggleButtonContainerSlot>\n )}\n {(description || (hasWarning && touched)) && (\n <LocalizedFieldDescriptionSlot\n role={hasWarning && touched ? \"status\" : undefined}\n color={hasWarning && touched ? \"warning.11\" : undefined}\n // In order to associate the warnings from both the warning and legacy warnings props with the fieldset,\n // we must associate, them to this element with aria-labelledby\n aria-labelledby={`${descriptionProps.id}-warning`}\n {...descriptionProps}\n >\n {/** Warnings are for compat with UI Kit localized fields */}\n {hasWarning && touched ? (\n <>\n <Icon colorPalette=\"warning\">\n <WarningAmber />\n </Icon>\n <Stack gap=\"0\" id={`${descriptionProps.id}-warning`}>\n {warning}\n {warnings && hasWarning && (\n <FieldErrors\n errors={warnings}\n renderError={renderWarning}\n colorPalette=\"warning\"\n role={undefined}\n />\n )}\n </Stack>\n </>\n ) : (\n description\n )}\n </LocalizedFieldDescriptionSlot>\n )}\n {isInvalid && (\n <LocalizedFieldErrorSlot\n // In order to associate the errors from both the error and legacy errors props with the fieldset,\n // we must associate them to this element with aria-labelledby.\n aria-labelledby={`${errorMessageProps.id}-error`}\n role=\"alert\"\n {...errorMessageProps}\n >\n <Icon>\n <ErrorOutline />\n </Icon>\n <Stack gap=\"0\" id={`${errorMessageProps.id}-error`}>\n {error}\n {errors && hasError && (\n <FieldErrors\n errors={errors}\n renderError={renderError}\n role={undefined}\n />\n )}\n </Stack>\n </LocalizedFieldErrorSlot>\n )}\n </LocalizedFieldRootSlot>\n );\n};\n","import { LocalizedField as LocalizedFieldRoot } from \"./components/localized-field.root\";\nimport {\n getLocaleFieldAttribute,\n createLocalizedString,\n isEmpty,\n omitEmptyTranslations,\n isTouched,\n RequiredValueErrorMessage,\n toFieldErrors,\n convertToMoneyValues,\n parseMoneyValues,\n getHighPrecisionCurrencies,\n getEmptyCurrencies,\n} from \"./utils/localized-field.utils\";\n\nexport const LocalizedField = Object.assign(LocalizedFieldRoot, {\n // Add util methods here for compat with uikit - see https://github.com/commercetools/ui-kit/blob/e97e0c7e8f3e9393981bf1949573212d7c571c90/packages/components/inputs/localized-text-input/src/localized-text-input.tsx#L396\n getId: getLocaleFieldAttribute,\n getName: getLocaleFieldAttribute,\n isTouched,\n isEmpty,\n createLocalizedString,\n omitEmptyTranslations,\n RequiredValueErrorMessage,\n toFieldErrors,\n convertToMoneyValues,\n parseMoneyValues,\n getHighPrecisionCurrencies,\n getEmptyCurrencies,\n});\n"],"names":["messages","defineMessages","withProvider","withContext","createSlotRecipeContext","localizedFieldSlotRecipe","LocalizedFieldRootSlot","LocalizedFieldLabelSlot","LocalizedFieldInfoDialogSlot","LocalizedFieldFieldsContainerSlot","LocalizedFieldDescriptionSlot","LocalizedFieldErrorSlot","LocalizedFieldToggleButtonContainerSlot","LocalizedFieldLocaleFieldRootSlot","LocalizedFieldLocaleFieldLabelSlot","LocalizedFieldLocaleFieldInputSlot","RequiredValueErrorMessage","jsx","FormField","FormattedMessage","getLocaleFieldAttribute","fieldGroupAttr","locale","getLanguageForLocale","splitLanguages","defaultLocale","locales","defaultLanguage","related","sortLocalesByDefaultLocaleLanguage","allLocales","unrelated","sortCurrencies","defaultCurrency","allCurrencies","remainingCurrencies","currency","getHasInvalidLocalizedFields","errors","defaultLocaleOrCurrency","localeOrCurrency","createLocalizedString","existingLocalizedString","localizedString","isEmpty","value","omitEmptyTranslations","localizedStringWithoutEmptyTranslations","isTouched","touched","toFieldErrors","convertToMoneyValues","values","MoneyInput","parseMoneyValues","moneyValues","allValues","moneyValue","getHighPrecisionCurrencies","currencyCode","getEmptyCurrencies","LocalizedFieldLocaleField","type","size","id","name","inputValueFromProps","description","warning","error","onChange","onBlur","onFocus","isRequired","isReadOnly","isDisabled","isInvalid","otherProps","InputComponent","TextInput","MultilineTextInput","RichTextInput","inputValue","handleChange","useCallback","changeValue","jsxs","e","Fragment","Icon","WarningAmber","LocalizedField","valuesByLocaleOrCurrency","placeholdersByLocaleOrCurrency","descriptionsByLocaleOrCurrency","warningsByLocaleOrCurrency","errorsByLocaleOrCurrency","label","hint","warnings","renderWarning","renderError","defaultExpanded","displayAllLocalesOrCurrencies","autoFocus","dataTrackComponent","dataTestId","dataTest","rest","expanded","setExpanded","useState","formatMessage","useIntl","localeFieldsContainerId","useId","moreDetailsButtonId","hasError","hasWarning","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","localizationKeys","allDataForFields","useMemo","allFieldData","localizationKey","allDataForLocale","shouldExpandInvalidFields","Stack","RaDialogTrigger","IconButton","HelpOutline","Popover","RaDialog","Box","RaCollection","item","Button","Payments","Language","FieldErrors","ErrorOutline","LocalizedFieldRoot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,MAAAA,IAAe,gBAAAC,GAAe;AAAA,EAC5B,sBAAsB;AAAA,IACpB,IAAI;AAAA,IACJ,aAAa;AAAA,IACb,gBAAgB;AAAA,EAAA;AAAA,EAElB,yBAAyB;AAAA,IACvB,IAAI;AAAA,IACJ,aAAa;AAAA,IACb,gBAAgB;AAAA,EAAA;AAAA,EAElB,eAAe;AAAA,IACb,IAAI;AAAA,IACJ,aACE;AAAA,IACF,gBAAgB;AAAA,EAAA;AAAA,EAElB,eAAe;AAAA,IACb,IAAI;AAAA,IACJ,aACE;AAAA,IACF,gBAAgB;AAAA,EAAA;AAAA,EAElB,gBAAgB;AAAA,IACd,IAAI;AAAA,IACJ,aACE;AAAA,IACF,gBAAgB;AAAA,EAAA;AAAA,EAElB,gBAAgB;AAAA,IACd,IAAI;AAAA,IACJ,aACE;AAAA,IACF,gBAAgB;AAAA,EAAA;AAEpB,CAAC,GC7BK,EAAE,cAAAC,IAAc,aAAAC,EAAA,IAAgB,gBAAAC,GAAwB;AAAA,EAC5D,QAAQC;AACV,CAAC,GAQYC,KAAyB,gBAAAJ,GAGpC,YAAY,MAAM,GAKPK,KAA0B,gBAAAJ,EAGrC,UAAU,OAAO,GAKNK,KAA+B,gBAAAL,EAG1C,OAAO,YAAY,GAKRM,KAAoC,gBAAAN,EAG/C,OAAO,iBAAiB,GAKbO,KAAgC,gBAAAP,EAG3C,OAAO,aAAa,GAITQ,KAA0B,gBAAAR,EAGrC,OAAO,OAAO,GAKHS,KAA0C,gBAAAT,EAGrD,OAAO,uBAAuB,GAMnBU,KAAoC,gBAAAV,EAG/C,OAAO,iBAAiB,GAKbW,KAAqC,gBAAAX,EAGhD,OAAO,kBAAkB,GAKdY,KAAqC,gBAAAZ,EAGhD,OAAO,kBAAkB,GCtEda,KAA4B,MACvC,gBAAAC,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A,aAAA+D;AAAA,oBACA,MAAM;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACR,EAAA,CAEJ;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAIR,GCxVaV,KAAiB,uBAAO,OAAOsD,IAAoB;AAAA;AAAA,EAE9D,OAAO7H;AAAA,EACP,SAASA;AAAA,EACT,WAAA4B;AAAA,EACA,SAAAJ;AAAA,EACA,uBAAAH;AAAA,EACA,uBAAAK;AAAA,EACA,2BAAA9B;AAAA,EACA,eAAAkC;AAAA,EACA,sBAAAC;AAAA,EACA,kBAAAG;AAAA,EACA,4BAAAI;AAAA,EACA,oBAAAE;AACF,CAAC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),W=require("react"),J=require("react-intl"),ie=require("./Dialog-XGXh4NXU.cjs.js"),xe=require("./CollectionBuilder-BiEelELF.cjs.js"),L=require("@commercetools/nimbus-icons"),be=require("./popover-BJPogaez.cjs.js"),he=require("@chakra-ui/react/styled-system"),me=require("./index-Bx9ez6gh.cjs.js"),k=require("./money-input-
|
|
2
|
-
//# sourceMappingURL=localized-field-
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),W=require("react"),J=require("react-intl"),ie=require("./Dialog-XGXh4NXU.cjs.js"),xe=require("./CollectionBuilder-BiEelELF.cjs.js"),L=require("@commercetools/nimbus-icons"),be=require("./popover-BJPogaez.cjs.js"),he=require("@chakra-ui/react/styled-system"),me=require("./index-Bx9ez6gh.cjs.js"),k=require("./money-input-CwrbJsn1.cjs.js"),I=require("./form-field-2NMmaZgp.cjs.js"),Fe=require("./rich-text-input-BygekdK5.cjs.js"),je=require("./multiline-text-input-4kwHZ5HO.cjs.js"),U=require("./icon-BHx0r3NL.cjs.js"),fe=require("./text-input-DHyVy0pg.cjs.js"),se=require("./mergeProps-BA5Cwf5w.cjs.js"),Le=require("./useField-C_piDZ9g.cjs.js"),re=require("./field-errors-Dzmxsyfu.cjs.js"),A=require("./stack-CIN13EDn.cjs.js"),Ie=require("./icon-button-CkjZc6Br.cjs.js"),oe=require("./box-CWni3A32.cjs.js"),ve=require("./button-DTE97NpD.cjs.js"),v=J.defineMessages({missingRequiredField:{id:"Nimbus.LocalizedField.missingRequiredField",description:"Error message for missing required value",defaultMessage:"This field is required. Provide at least one value."},infoBoxTriggerAriaLabel:{id:"Nimbus.LocalizedField.infoBoxTriggerAriaLabel",description:"aria label for button that triggers more info dialog",defaultMessage:"more info"},showLanguages:{id:"Nimbus.LocalizedField.showLanguages",description:"Label for showing all language inputs when toggle button is pressed",defaultMessage:"Show all languages"},hideLanguages:{id:"Nimbus.LocalizedField.hideLanguages",description:"Label for hiding all language inputs when toggle button is pressed",defaultMessage:"Hide all languages"},showCurrencies:{id:"Nimbus.LocalizedField.showCurrencies",description:"Label for showing all currency inputs when toggle button is pressed",defaultMessage:"Show all currencies"},hideCurrencies:{id:"Nimbus.LocalizedField.hideCurrencies",description:"Label for hiding all currency inputs when toggle button is pressed",defaultMessage:"Hide all currencies"}}),{withProvider:qe,withContext:p}=he.createSlotRecipeContext({recipe:me.localizedFieldSlotRecipe}),Me=qe("fieldset","root"),$e=p("legend","label"),we=p("div","infoDialog"),Ce=p("div","fieldsContainer"),Ee=p("div","description"),Se=p("div","error"),ke=p("div","toggleButtonContainer"),ye=p("div","localeFieldRoot"),ze=p("div","localeFieldLabel"),Te=p("div","localeFieldInput"),Pe=()=>t.jsx(I.FormField.Error,{children:t.jsx(J.FormattedMessage,{...v.missingRequiredField})}),m=(e,n)=>e&&n?`${e}.${n}`:void 0,D=e=>e.split("-")[0],Be=(e,n)=>{const i=D(e),s=n.filter(l=>D(l)===i);return{unrelated:n.filter(l=>D(l)!==i),related:s}},He=(e,n)=>{const{related:i,unrelated:s}=Be(e,n.filter(r=>r!==e));return[e,...i.sort(),...s.sort()]},Ne=(e,n)=>{const i=n.filter(s=>s!==e);return[e,...i.sort()]},Re=(e,n)=>e&&Object.keys(e).length>0&&n?Object.keys(e).some(i=>i!==n):!1,Ve=(e,n)=>Array.from(new Set([...e,...Object.keys(n)])).reduce((s,r)=>({...s,[r]:n?.[r]||""}),{}),Ae=e=>e?Object.values(e).every(n=>!n||n?.trim().length===0):!0,De=e=>(typeof e!="object"&&console.warn("Nimbus Localized Field - Warning: omitEmptyTranslations must be called with an object"),Object.entries(e).reduce((n,[i,s])=>s&&s.trim().length>0?{...n,[i]:s}:n,{})),We=e=>e?Object.values(e).some(Boolean):!1;function Ue(e){return e}const Je=(e,n)=>Object.values(e).map(i=>k.MoneyInput.convertToMoneyValue(i,n)),Qe=(e=[],n)=>e.reduce((i,s)=>{const r=k.MoneyInput.parseMoneyValue(s,n);return{...i,[r.currencyCode]:r}},{}),Xe=(e,n)=>Object.keys(e).filter(s=>k.MoneyInput.isHighPrecision(e[s],n)),Ye=e=>Object.keys(e).filter(i=>k.MoneyInput.isEmpty(e[i])),Ze=({type:e,size:n,localeOrCurrency:i,id:s,name:r,inputValue:l,description:q,warning:x,error:b,onChange:F,onBlur:M,onFocus:$,isRequired:w,isReadOnly:h,isDisabled:j,isInvalid:f,touched:a,...P})=>{let o;switch(e){case"text":default:o=fe.TextInput;break;case"multiLine":o=je.MultilineTextInput;break;case"money":o=k.MoneyInput;break;case"richText":o=Fe.RichTextInput;break}const C=e==="money"?l||{amount:"",currencyCode:i}:l||"",z=W.useCallback(d=>{const B={target:typeof d=="object"?{id:d.target.id,name:d.target.name,locale:void 0,currency:i,value:d.target.value}:{id:s,name:r,locale:i,currency:void 0,value:d}};F(B)},[s,r,i,F]);return t.jsx(ye,{asChild:!0,children:t.jsxs(I.FormField.Root,{isDisabled:j,isReadOnly:h,isInvalid:(f||!!b)&&a,direction:"row",size:n,id:s,children:[t.jsx(ze,{display:e==="money"?"none":void 0,...j&&{"data-disabled":j},asChild:!0,children:t.jsx(I.FormField.Label,{children:i.toLocaleUpperCase()})}),t.jsx(I.FormField.Input,{children:t.jsx(Te,{"aria-required":w,asChild:!0,children:t.jsx(o,{...P,size:n,value:C,onChange:z,onBlur:d=>M?.(d,i),onFocus:d=>$?.(d,i),isRequired:w,isDisabled:j,isReadOnly:h,isInvalid:(f||!!b)&&a})})}),(q||x&&a)&&t.jsx(I.FormField.Description,{role:x&&a?"status":void 0,color:x&&a?"warning.11":void 0,display:"flex",gap:"100",alignItems:"center",children:x&&a?t.jsxs(t.Fragment,{children:[t.jsx(U.Icon,{colorPalette:"warning",children:t.jsx(L.WarningAmber,{})}),x]}):q}),b&&a&&t.jsx(I.FormField.Error,{children:b})]})})},_e=({type:e="text",id:n,name:i,defaultLocaleOrCurrency:s,valuesByLocaleOrCurrency:r,placeholdersByLocaleOrCurrency:l,descriptionsByLocaleOrCurrency:q,warningsByLocaleOrCurrency:x,errorsByLocaleOrCurrency:b,label:F,hint:M,description:$,warning:w,warnings:h,renderWarning:j,error:f,errors:a,renderError:P,touched:o,isRequired:y,isDisabled:C,isReadOnly:z,onChange:d,onBlur:Q,onFocus:B,defaultExpanded:ae=!1,displayAllLocalesOrCurrencies:X=!1,size:Y,autoFocus:Z,["data-track-component"]:le,["data-testid"]:de,["data-test"]:ce,...ue})=>{const[c,_]=W.useState(X||ae),{formatMessage:E}=J.useIntl(),G=se.$bdb11010cef70236$export$f680877a34711e37(),O=se.$bdb11010cef70236$export$f680877a34711e37(),H=!!(f||a&&Object.values(a).some(u=>u===!0)),S=!!(w||h&&Object.values(h).some(Boolean)),T=!!(H&&o),{labelProps:K,fieldProps:ee,descriptionProps:N,errorMessageProps:R}=Le.$2baaea4c71418dea$export$294aa081a6c6f55d({id:n,label:F,description:$,errorMessage:f,isInvalid:T}),V=Object.keys(r),ge=W.useMemo(()=>(e==="money"?Ne(s,V):He(s,V)).reduce((ne,g)=>{const pe={localeOrCurrency:g,inputValue:r[g],placeholder:l?.[g],description:q?.[g],warning:x?.[g],error:b?.[g],...g===s&&Z?{autoFocus:Z}:{},isInvalid:T,isRequired:y,isDisabled:C,isReadOnly:z};return c||!c&&g===s?[...ne,pe]:ne},[]),[r,l,q,x,b,s,c,T,y,C,z]),te=(Re(b,s)||H)&&o;return te&&!c&&_(!0),t.jsxs(Me,{...ue,...ee,"aria-details":M?O:void 0,type:e,size:Y,name:i,children:[F&&t.jsxs(A.Stack,{direction:"row",gap:"0",children:[t.jsxs($e,{...K,children:[F,y&&t.jsx("sup",{"aria-hidden":"true",children:"*"})]}),M&&t.jsxs(ie.$de32f1b87079253c$export$2e1e1122cf0cba88,{children:[t.jsx(Ie.IconButton,{id:O,"aria-label":E(v.infoBoxTriggerAriaLabel),size:"2xs",tone:"info",variant:"link",children:t.jsx(L.HelpOutline,{})}),t.jsx(be.Popover,{padding:0,children:t.jsx(we,{asChild:!0,children:t.jsx(ie.$de32f1b87079253c$export$3ddf2d174ce01153,{children:t.jsx(oe.Box,{p:"300",children:M})})})})]})]}),t.jsx(Ce,{id:G,"data-expanded":c,children:t.jsx(xe.$e1995378a142960e$export$fb8073518f34e6ec,{items:ge,children:u=>t.jsx(Ze,{...u,size:Y,type:e,onChange:d,onBlur:Q,onFocus:B,touched:o,id:m(ee.id,u.localeOrCurrency),name:m(i,u.localeOrCurrency),"data-test":m(ce,u.localeOrCurrency),"data-testid":m(de,u.localeOrCurrency),"data-track-component":m(le,u.localeOrCurrency)})})}),!X&&V.length>1&&t.jsx(ke,{children:t.jsxs(ve.Button,{"aria-controls":G,"aria-describedby":K.id,"aria-expanded":c,onPress:()=>_(!c),isDisabled:C||te&&c,variant:"ghost",size:"2xs",colorPalette:"primary",children:[t.jsx(oe.Box,{as:e==="money"?L.Payments:L.Language,display:"inline-flex",boxSize:"400",verticalAlign:"text-bottom",mr:"100"}),E(e==="money"?c?v.hideCurrencies:v.showCurrencies:c?v.hideLanguages:v.showLanguages)]})}),($||S&&o)&&t.jsx(Ee,{role:S&&o?"status":void 0,color:S&&o?"warning.11":void 0,"aria-labelledby":`${N.id}-warning`,...N,children:S&&o?t.jsxs(t.Fragment,{children:[t.jsx(U.Icon,{colorPalette:"warning",children:t.jsx(L.WarningAmber,{})}),t.jsxs(A.Stack,{gap:"0",id:`${N.id}-warning`,children:[w,h&&S&&t.jsx(re.FieldErrors,{errors:h,renderError:j,colorPalette:"warning",role:void 0})]})]}):$}),T&&t.jsxs(Se,{"aria-labelledby":`${R.id}-error`,role:"alert",...R,children:[t.jsx(U.Icon,{children:t.jsx(L.ErrorOutline,{})}),t.jsxs(A.Stack,{gap:"0",id:`${R.id}-error`,children:[f,a&&H&&t.jsx(re.FieldErrors,{errors:a,renderError:P,role:void 0})]})]})]})},Ge=Object.assign(_e,{getId:m,getName:m,isTouched:We,isEmpty:Ae,createLocalizedString:Ve,omitEmptyTranslations:De,RequiredValueErrorMessage:Pe,toFieldErrors:Ue,convertToMoneyValues:Je,parseMoneyValues:Qe,getHighPrecisionCurrencies:Xe,getEmptyCurrencies:Ye});exports.LocalizedField=Ge;
|
|
2
|
+
//# sourceMappingURL=localized-field-DCgNEoJc.cjs.js.map
|
package/dist/chunks/{localized-field-BqUMaU2Z.cjs.js.map → localized-field-DCgNEoJc.cjs.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localized-field-BqUMaU2Z.cjs.js","sources":["../../src/components/localized-field/localized-field.i18n.ts","../../src/components/localized-field/localized-field.slots.tsx","../../src/components/localized-field/utils/localized-field.utils.tsx","../../src/components/localized-field/components/localized-field.locale-field.tsx","../../src/components/localized-field/components/localized-field.root.tsx","../../src/components/localized-field/localized-field.tsx"],"sourcesContent":["import { defineMessages } from \"react-intl\";\n\nexport default defineMessages({\n missingRequiredField: {\n id: \"Nimbus.LocalizedField.missingRequiredField\",\n description: \"Error message for missing required value\",\n defaultMessage: \"This field is required. Provide at least one value.\",\n },\n infoBoxTriggerAriaLabel: {\n id: \"Nimbus.LocalizedField.infoBoxTriggerAriaLabel\",\n description: \"aria label for button that triggers more info dialog\",\n defaultMessage: \"more info\",\n },\n showLanguages: {\n id: \"Nimbus.LocalizedField.showLanguages\",\n description:\n \"Label for showing all language inputs when toggle button is pressed\",\n defaultMessage: \"Show all languages\",\n },\n hideLanguages: {\n id: \"Nimbus.LocalizedField.hideLanguages\",\n description:\n \"Label for hiding all language inputs when toggle button is pressed\",\n defaultMessage: \"Hide all languages\",\n },\n showCurrencies: {\n id: \"Nimbus.LocalizedField.showCurrencies\",\n description:\n \"Label for showing all currency inputs when toggle button is pressed\",\n defaultMessage: \"Show all currencies\",\n },\n hideCurrencies: {\n id: \"Nimbus.LocalizedField.hideCurrencies\",\n description:\n \"Label for hiding all currency inputs when toggle button is pressed\",\n defaultMessage: \"Hide all currencies\",\n },\n});\n","/* eslint-disable @typescript-eslint/no-empty-object-type */\nimport {\n type HTMLChakraProps,\n type RecipeVariantProps,\n createSlotRecipeContext,\n} from \"@chakra-ui/react/styled-system\";\nimport { localizedFieldSlotRecipe } from \"./localized-field.recipe\";\n\nconst { withProvider, withContext } = createSlotRecipeContext({\n recipe: localizedFieldSlotRecipe,\n});\n\n// Root Slot\nexport interface LocalizedFieldRootSlotProps\n extends HTMLChakraProps<\n \"fieldset\",\n RecipeVariantProps<typeof localizedFieldSlotRecipe>\n > {}\nexport const LocalizedFieldRootSlot = withProvider<\n HTMLFieldSetElement,\n LocalizedFieldRootSlotProps\n>(\"fieldset\", \"root\");\n\n// Label Slot\nexport interface LocalizedFieldLabelSlotProps\n extends HTMLChakraProps<\"label\"> {}\nexport const LocalizedFieldLabelSlot = withContext<\n HTMLLabelElement,\n LocalizedFieldLabelSlotProps\n>(\"legend\", \"label\");\n\n// InfoDialog Slot\nexport interface LocalizedFieldInfoDialogSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldInfoDialogSlot = withContext<\n HTMLDivElement,\n LocalizedFieldInfoDialogSlotProps\n>(\"div\", \"infoDialog\");\n\n// FieldsContainer Slot\nexport interface LocalizedFieldFieldsContainerSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldFieldsContainerSlot = withContext<\n HTMLDivElement,\n LocalizedFieldFieldsContainerSlotProps\n>(\"div\", \"fieldsContainer\");\n\n// Description Slot\nexport interface LocalizedFieldDescriptionSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldDescriptionSlot = withContext<\n HTMLDivElement,\n LocalizedFieldDescriptionSlotProps\n>(\"div\", \"description\");\n\n// Error Slot\nexport interface LocalizedFieldErrorSlotProps extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldErrorSlot = withContext<\n HTMLDivElement,\n LocalizedFieldErrorSlotProps\n>(\"div\", \"error\");\n\n// ToggleButtonContainer Slot\nexport interface LocalizedFieldToggleButtonContainerSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldToggleButtonContainerSlot = withContext<\n HTMLDivElement,\n LocalizedFieldToggleButtonContainerSlotProps\n>(\"div\", \"toggleButtonContainer\");\n\n// LocaleFieldRoot Slot\n\nexport interface LocalizedFieldLocaleFieldRootSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldRootSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldRootSlotProps\n>(\"div\", \"localeFieldRoot\");\n\n// FieldLabel Slot\nexport interface LocalizedFieldLocaleFieldLabelSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldLabelSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldLabelSlotProps\n>(\"div\", \"localeFieldLabel\");\n\n// FieldInput Slot\nexport interface LocalizedFieldLocaleFieldInputSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldInputSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldInputSlotProps\n>(\"div\", \"localeFieldInput\");\n","import { FormattedMessage } from \"react-intl\";\nimport {\n FormField,\n type TCurrencyCode,\n type TValue,\n type TMoneyValue,\n type TFieldErrors,\n MoneyInput,\n} from \"@/components\";\nimport messages from \"../localized-field.i18n\";\nimport type { LocalizedString } from \"../localized-field.types\";\n\ntype LanguagesSplitByDefaultLocale = {\n related: string[];\n unrelated: string[];\n};\n\ntype TouchedLocalizedString = { [locale: string]: boolean };\n\ntype CustomFormikErrors<Values> = {\n [K in keyof Values]?: TFieldErrors;\n};\n\nexport const RequiredValueErrorMessage = () => (\n <FormField.Error>\n <FormattedMessage {...messages.missingRequiredField} />\n </FormField.Error>\n);\n\nexport const getLocaleFieldAttribute = (\n fieldGroupAttr?: string,\n locale?: string\n): string | undefined =>\n fieldGroupAttr && locale ? `${fieldGroupAttr}.${locale}` : undefined;\n\n// gets the language tag of a given locale, e.g. `de` in `de-DE`\nexport const getLanguageForLocale = (locale: string): string =>\n locale.split(\"-\")[0];\n\n// splits the locales into two groups:\n// - the 'related' array contains locales with the same language tag as the default locale,\n// e.g. if the default locale is de-DE, related would be ['de-DE', 'de-CH']\n// - the 'unrelated' array contains locales with a different different language tag from the default locale\n//. e.g. if the default locale is de-DE, unrelated would be ['pt-BR', 'en-GB', 'zh-Hans']\nexport const splitLanguages = (\n defaultLocale: string,\n locales: string[]\n): LanguagesSplitByDefaultLocale => {\n const defaultLanguage = getLanguageForLocale(defaultLocale);\n const related = locales.filter(\n (locale) => getLanguageForLocale(locale) === defaultLanguage\n );\n const unrelated = locales.filter(\n (locale) => getLanguageForLocale(locale) !== defaultLanguage\n );\n return {\n unrelated,\n related,\n };\n};\n\n// sorts locales with the following priority:\n// - The selected locale is placed first (e.g pt-BR)\n// - All locales using the same language tag as the selected language\n// follow (e.g. pt, pt-PT). They are sorted alphabetically.\n// - All other locales follow, sorted alphabetically as well\nexport const sortLocalesByDefaultLocaleLanguage = (\n defaultLocale: string,\n allLocales: string[]\n): string[] => {\n const { related, unrelated } = splitLanguages(\n defaultLocale,\n allLocales.filter((locale: string) => locale !== defaultLocale)\n );\n\n return [defaultLocale, ...related.sort(), ...unrelated.sort()];\n};\n\nexport const sortCurrencies = (\n defaultCurrency: TCurrencyCode,\n allCurrencies: TCurrencyCode[]\n) => {\n const remainingCurrencies = allCurrencies.filter(\n (currency) => currency !== defaultCurrency\n );\n return [defaultCurrency, ...remainingCurrencies.sort()];\n};\n\nexport const getHasInvalidLocalizedFields = <TErrors extends object>(\n errors?: TErrors,\n defaultLocaleOrCurrency?: string\n): boolean => {\n if (errors && Object.keys(errors).length > 0 && defaultLocaleOrCurrency) {\n return Object.keys(errors).some(\n (localeOrCurrency) => localeOrCurrency !== defaultLocaleOrCurrency\n );\n }\n return false;\n};\n\nexport const createLocalizedString = (\n locales: string[],\n existingLocalizedString: LocalizedString\n): LocalizedString => {\n const localesInLocalizedString = Array.from(\n new Set([...locales, ...Object.keys(existingLocalizedString)])\n );\n\n return localesInLocalizedString.reduce<LocalizedString>(\n (localizedString, locale) => ({\n ...localizedString,\n [locale]: existingLocalizedString?.[locale] || \"\",\n }),\n {}\n );\n};\n\n// Note: I prefer `isLocalizedStringEmpty`, but keeping this as `isEmpty` for api consistency with UI Kit\nexport const isEmpty = (localizedString?: LocalizedString): boolean => {\n if (!localizedString) return true;\n return Object.values(localizedString).every(\n (value?: string) => !value || value?.trim().length === 0\n );\n};\n\nexport const omitEmptyTranslations = <Translations extends LocalizedString>(\n localizedString: Translations\n): LocalizedString => {\n // TODO: is it necessary to create a util that enforces a consistent warning/error format, e.g.\n // `<COMPONENT_NAME> - Warning: <WARNING_MESSAGE>`\n if (typeof localizedString !== \"object\") {\n console.warn(\n \"Nimbus Localized Field - Warning: omitEmptyTranslations must be called with an object\"\n );\n }\n\n return Object.entries(localizedString).reduce<LocalizedString>(\n (localizedStringWithoutEmptyTranslations, [locale, value]) => {\n if (value && value.trim().length > 0) {\n return {\n ...localizedStringWithoutEmptyTranslations,\n [locale]: value,\n };\n }\n return localizedStringWithoutEmptyTranslations;\n },\n {}\n );\n};\n\nexport const isTouched = (touched?: TouchedLocalizedString): boolean => {\n if (touched) {\n return Object.values(touched).some(Boolean);\n }\n return false;\n};\n\n/**\n * Use this function to convert the Formik `errors` object type to\n * our custom field errors type.\n * This is primarly useful when using TypeScript.\n */\nexport function toFieldErrors<FormValues>(\n errors: unknown\n): CustomFormikErrors<FormValues> {\n return errors as CustomFormikErrors<FormValues>;\n}\n\nexport const convertToMoneyValues = (\n values: TValue[],\n currency: string\n): Array<TMoneyValue | null> =>\n Object.values(values).map<TMoneyValue | null>((value) => {\n return MoneyInput.convertToMoneyValue(value, currency);\n });\n\nexport const parseMoneyValues = (\n moneyValues: TMoneyValue[] = [],\n locale: string\n): Record<TCurrencyCode, TValue> =>\n moneyValues.reduce<Record<TCurrencyCode, TValue>>(\n (allValues, moneyValue) => {\n const value = MoneyInput.parseMoneyValue(moneyValue, locale);\n return {\n ...allValues,\n [value.currencyCode]: value,\n };\n },\n {} as Record<TCurrencyCode, TValue>\n );\n\nexport const getHighPrecisionCurrencies = (\n values: Record<TCurrencyCode, TValue>,\n locale: string\n): TCurrencyCode[] => {\n const typedCurrencyCodes = Object.keys(values) as TCurrencyCode[];\n return typedCurrencyCodes.filter((currencyCode) =>\n MoneyInput.isHighPrecision(values[currencyCode], locale)\n );\n};\n\nexport const getEmptyCurrencies = (\n values: Record<TCurrencyCode, TValue>\n): TCurrencyCode[] => {\n const typedCurrencyCodes = Object.keys(values) as TCurrencyCode[];\n return typedCurrencyCodes.filter((currencyCode) =>\n MoneyInput.isEmpty(values[currencyCode])\n );\n};\n","import { useCallback } from \"react\";\nimport {\n FormField,\n Icon,\n TextInput,\n MoneyInput,\n type TCustomEvent,\n MultilineTextInput,\n RichTextInput,\n type TValue,\n type TCurrencyCode,\n} from \"@/components\";\nimport { WarningAmber } from \"@commercetools/nimbus-icons\";\nimport {\n LocalizedFieldLocaleFieldRootSlot,\n LocalizedFieldLocaleFieldInputSlot,\n LocalizedFieldLocaleFieldLabelSlot,\n} from \"../localized-field.slots\";\nimport type { LocalizedFieldLocaleFieldProps } from \"../localized-field.types\";\n\nexport const LocalizedFieldLocaleField = ({\n type,\n size,\n localeOrCurrency,\n id,\n name,\n inputValue: inputValueFromProps,\n description,\n warning,\n error,\n onChange,\n onBlur,\n onFocus,\n isRequired,\n isReadOnly,\n isDisabled,\n isInvalid,\n touched,\n ...otherProps\n}: LocalizedFieldLocaleFieldProps) => {\n let InputComponent:\n | typeof TextInput\n | typeof MultilineTextInput\n | typeof MoneyInput\n | typeof RichTextInput;\n switch (type) {\n case \"text\":\n default:\n InputComponent = TextInput;\n break;\n case \"multiLine\":\n InputComponent = MultilineTextInput;\n break;\n case \"money\":\n InputComponent = MoneyInput;\n break;\n case \"richText\":\n InputComponent = RichTextInput;\n break;\n }\n\n const getInputValue = () => {\n if (type === \"money\") {\n return inputValueFromProps\n ? (inputValueFromProps as TValue)\n : ({ amount: \"\", currencyCode: localeOrCurrency } as TValue);\n }\n return inputValueFromProps ? inputValueFromProps : \"\";\n };\n\n const inputValue = getInputValue();\n\n const handleChange = useCallback(\n (value: string | TCustomEvent | undefined) => {\n // The `MoneyInput` onChange event value is a custom value,\n // and the `MoneyInput` modifies the input id and name since it is in a `group`,\n // so we need to build a separate return object for the MoneInput to return\n // the expected values\n const isMoneyInputEvent = typeof value === \"object\";\n const changeValue = {\n target: isMoneyInputEvent\n ? {\n id: value.target.id,\n name: value.target.name,\n locale: undefined,\n currency: localeOrCurrency as TCurrencyCode,\n value: value.target.value,\n }\n : { id, name, locale: localeOrCurrency, currency: undefined, value },\n };\n onChange(changeValue);\n },\n [id, name, localeOrCurrency, onChange]\n );\n\n return (\n <LocalizedFieldLocaleFieldRootSlot asChild>\n <FormField.Root\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isInvalid={(isInvalid || !!error) && touched}\n direction=\"row\"\n size={size}\n id={id}\n >\n <LocalizedFieldLocaleFieldLabelSlot\n display={type === \"money\" ? \"none\" : undefined}\n {...(isDisabled && { \"data-disabled\": isDisabled })}\n asChild\n >\n <FormField.Label>\n {localeOrCurrency.toLocaleUpperCase()}\n </FormField.Label>\n </LocalizedFieldLocaleFieldLabelSlot>\n <FormField.Input>\n <LocalizedFieldLocaleFieldInputSlot\n aria-required={isRequired}\n asChild\n >\n <InputComponent\n {...otherProps}\n size={size}\n value={inputValue as string & TValue}\n onChange={handleChange}\n onBlur={(e: React.FocusEvent | TCustomEvent) =>\n onBlur?.(e, localeOrCurrency)\n }\n onFocus={(e: React.FocusEvent | TCustomEvent) =>\n onFocus?.(e, localeOrCurrency)\n }\n isRequired={isRequired}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isInvalid={(isInvalid || !!error) && touched}\n />\n </LocalizedFieldLocaleFieldInputSlot>\n </FormField.Input>\n {(description || (warning && touched)) && (\n <FormField.Description\n role={warning && touched ? \"status\" : undefined}\n color={warning && touched ? \"warning.11\" : undefined}\n display=\"flex\"\n gap=\"100\"\n alignItems=\"center\"\n >\n {warning && touched ? (\n <>\n <Icon colorPalette=\"warning\">\n <WarningAmber />\n </Icon>\n {warning}\n </>\n ) : (\n description\n )}\n </FormField.Description>\n )}\n {error && touched && <FormField.Error>{error}</FormField.Error>}\n </FormField.Root>\n </LocalizedFieldLocaleFieldRootSlot>\n );\n};\n","import { useState, useMemo } from \"react\";\nimport { useIntl } from \"react-intl\";\nimport {\n Collection as RaCollection,\n Dialog as RaDialog,\n DialogTrigger as RaDialogTrigger,\n} from \"react-aria-components\";\nimport { useField, useId } from \"react-aria\";\nimport {\n ErrorOutline,\n HelpOutline,\n Language,\n Payments,\n WarningAmber,\n} from \"@commercetools/nimbus-icons\";\nimport {\n Box,\n Button,\n FieldErrors,\n Icon,\n IconButton,\n Stack,\n type TCurrencyCode,\n} from \"@/components\";\nimport { Popover } from \"../../popover\";\nimport messages from \"../localized-field.i18n\";\nimport {\n LocalizedFieldRootSlot,\n LocalizedFieldLabelSlot,\n LocalizedFieldInfoDialogSlot,\n LocalizedFieldFieldsContainerSlot,\n LocalizedFieldDescriptionSlot,\n LocalizedFieldErrorSlot,\n LocalizedFieldToggleButtonContainerSlot,\n} from \"../localized-field.slots\";\nimport type {\n LocalizedFieldProps,\n MergedLocaleFieldData,\n LocalizedCurrency,\n} from \"../localized-field.types\";\n\nimport {\n getHasInvalidLocalizedFields,\n getLocaleFieldAttribute,\n sortCurrencies,\n sortLocalesByDefaultLocaleLanguage,\n} from \"../utils/localized-field.utils\";\nimport { LocalizedFieldLocaleField } from \"./localized-field.locale-field\";\n\nexport const LocalizedField = ({\n type = \"text\",\n id,\n name,\n defaultLocaleOrCurrency,\n valuesByLocaleOrCurrency,\n placeholdersByLocaleOrCurrency,\n descriptionsByLocaleOrCurrency,\n warningsByLocaleOrCurrency,\n errorsByLocaleOrCurrency,\n label,\n hint,\n description,\n warning,\n warnings,\n renderWarning,\n error,\n errors,\n renderError,\n touched,\n isRequired,\n isDisabled,\n isReadOnly,\n onChange,\n onBlur,\n onFocus,\n defaultExpanded = false,\n displayAllLocalesOrCurrencies = false,\n size,\n autoFocus,\n [\"data-track-component\"]: dataTrackComponent,\n [\"data-testid\"]: dataTestId,\n [\"data-test\"]: dataTest,\n // DOM & Style props for wrapper container\n ...rest\n}: LocalizedFieldProps) => {\n const [expanded, setExpanded] = useState(\n displayAllLocalesOrCurrencies || defaultExpanded\n );\n\n const { formatMessage } = useIntl();\n\n // Used to associate more info dialog with fieldset via `aria-controls`\n const localeFieldsContainerId = useId();\n // Used to associate more info dialog with fieldset via `aria-details`\n const moreDetailsButtonId = useId();\n\n // Either `error` exists, or there are `true` fields in the UI Kit compat `errors` object\n const hasError: boolean = Boolean(\n error || (errors && Object.values(errors).some((error) => error === true))\n );\n\n // Either `warning` exists, or there are `true` fields in the UI Kit compat `warnings` object\n const hasWarning: boolean = Boolean(\n warning || (warnings && Object.values(warnings).some(Boolean))\n );\n\n // FieldGroup is invalid if a non-field-specific error is passed and the group has been touched\n // When FieldGroup is invalid, all fields will display error styling without displaying a field-specific error message\n const isInvalid: boolean = !!(hasError && touched);\n\n const { labelProps, fieldProps, descriptionProps, errorMessageProps } =\n useField({\n id,\n label,\n description,\n errorMessage: error,\n isInvalid,\n });\n\n // Array of locales/currencies to display as input fields\n const localizationKeys: string[] | TCurrencyCode[] = Object.keys(\n valuesByLocaleOrCurrency\n );\n\n // Merge all -ByLocaleOrCurrencies data for each field\n const allDataForFields = useMemo(() => {\n const sortedFieldData =\n type === \"money\"\n ? sortCurrencies(\n defaultLocaleOrCurrency as TCurrencyCode,\n localizationKeys as TCurrencyCode[]\n )\n : sortLocalesByDefaultLocaleLanguage(\n defaultLocaleOrCurrency,\n localizationKeys\n );\n\n return sortedFieldData.reduce(\n (allFieldData: MergedLocaleFieldData[], localizationKey) => {\n const allDataForLocale = {\n localeOrCurrency: localizationKey,\n inputValue:\n type === \"money\"\n ? (valuesByLocaleOrCurrency as LocalizedCurrency)[localizationKey]\n : (valuesByLocaleOrCurrency[localizationKey] as string),\n placeholder: placeholdersByLocaleOrCurrency?.[localizationKey],\n description: descriptionsByLocaleOrCurrency?.[localizationKey],\n warning: warningsByLocaleOrCurrency?.[localizationKey],\n error: errorsByLocaleOrCurrency?.[localizationKey],\n // autoFocus default/first locale field\n ...(localizationKey === defaultLocaleOrCurrency && autoFocus\n ? { autoFocus }\n : {}),\n isInvalid,\n isRequired,\n isDisabled,\n isReadOnly,\n };\n if (\n expanded ||\n // Only display defaultLocaleOrInput field if fieldGroup is not expanded\n (!expanded && localizationKey === defaultLocaleOrCurrency)\n ) {\n return [...allFieldData, allDataForLocale];\n }\n return allFieldData;\n },\n []\n );\n }, [\n valuesByLocaleOrCurrency,\n placeholdersByLocaleOrCurrency,\n descriptionsByLocaleOrCurrency,\n warningsByLocaleOrCurrency,\n errorsByLocaleOrCurrency,\n defaultLocaleOrCurrency,\n expanded,\n isInvalid,\n isRequired,\n isDisabled,\n isReadOnly,\n ]);\n\n const groupHasInvalidLocalizedFields = getHasInvalidLocalizedFields(\n errorsByLocaleOrCurrency,\n defaultLocaleOrCurrency\n );\n\n const shouldExpandInvalidFields =\n (groupHasInvalidLocalizedFields || hasError) && touched;\n // If there are fields that are invalid, ensure that field group\n // shows all fields so that invalid field is visible\n if (shouldExpandInvalidFields && !expanded) {\n setExpanded(true);\n }\n\n return (\n <LocalizedFieldRootSlot\n {...rest}\n {...fieldProps}\n aria-details={hint ? moreDetailsButtonId : undefined}\n type={type}\n size={size}\n name={name}\n >\n {label && (\n <Stack direction=\"row\" gap=\"0\">\n <LocalizedFieldLabelSlot {...labelProps}>\n {label}\n {isRequired && <sup aria-hidden=\"true\">*</sup>}\n </LocalizedFieldLabelSlot>\n {hint && (\n <RaDialogTrigger>\n <IconButton\n id={moreDetailsButtonId}\n aria-label={formatMessage(messages.infoBoxTriggerAriaLabel)}\n size=\"2xs\"\n tone=\"info\"\n variant=\"link\"\n >\n <HelpOutline />\n </IconButton>\n\n <Popover padding={0}>\n <LocalizedFieldInfoDialogSlot asChild>\n <RaDialog>\n <Box p=\"300\">{hint}</Box>\n </RaDialog>\n </LocalizedFieldInfoDialogSlot>\n </Popover>\n </RaDialogTrigger>\n )}\n </Stack>\n )}\n <LocalizedFieldFieldsContainerSlot\n id={localeFieldsContainerId}\n data-expanded={expanded}\n >\n <RaCollection items={allDataForFields}>\n {(item) => {\n return (\n <LocalizedFieldLocaleField\n {...item}\n size={size}\n type={type}\n onChange={onChange}\n onBlur={onBlur}\n onFocus={onFocus}\n touched={touched}\n // Format field attributes to match uikit pattern\n id={getLocaleFieldAttribute(\n fieldProps.id,\n item.localeOrCurrency\n )}\n name={getLocaleFieldAttribute(name, item.localeOrCurrency)}\n data-test={getLocaleFieldAttribute(\n dataTest,\n item.localeOrCurrency\n )}\n data-testid={getLocaleFieldAttribute(\n dataTestId,\n item.localeOrCurrency\n )}\n data-track-component={getLocaleFieldAttribute(\n dataTrackComponent,\n item.localeOrCurrency\n )}\n />\n );\n }}\n </RaCollection>\n </LocalizedFieldFieldsContainerSlot>\n\n {!displayAllLocalesOrCurrencies && localizationKeys.length > 1 && (\n <LocalizedFieldToggleButtonContainerSlot>\n <Button\n aria-controls={localeFieldsContainerId}\n aria-describedby={labelProps.id}\n aria-expanded={expanded}\n onPress={() => setExpanded(!expanded)}\n isDisabled={isDisabled || (shouldExpandInvalidFields && expanded)}\n variant=\"ghost\"\n size=\"2xs\"\n colorPalette=\"primary\"\n >\n <Box\n as={type === \"money\" ? Payments : Language}\n display=\"inline-flex\"\n boxSize=\"400\"\n verticalAlign=\"text-bottom\"\n mr=\"100\"\n />\n {type === \"money\"\n ? expanded\n ? formatMessage(messages.hideCurrencies)\n : formatMessage(messages.showCurrencies)\n : expanded\n ? formatMessage(messages.hideLanguages)\n : formatMessage(messages.showLanguages)}\n </Button>\n </LocalizedFieldToggleButtonContainerSlot>\n )}\n {(description || (hasWarning && touched)) && (\n <LocalizedFieldDescriptionSlot\n role={hasWarning && touched ? \"status\" : undefined}\n color={hasWarning && touched ? \"warning.11\" : undefined}\n // In order to associate the warnings from both the warning and legacy warnings props with the fieldset,\n // we must associate, them to this element with aria-labelledby\n aria-labelledby={`${descriptionProps.id}-warning`}\n {...descriptionProps}\n >\n {/** Warnings are for compat with UI Kit localized fields */}\n {hasWarning && touched ? (\n <>\n <Icon colorPalette=\"warning\">\n <WarningAmber />\n </Icon>\n <Stack gap=\"0\" id={`${descriptionProps.id}-warning`}>\n {warning}\n {warnings && hasWarning && (\n <FieldErrors\n errors={warnings}\n renderError={renderWarning}\n colorPalette=\"warning\"\n role={undefined}\n />\n )}\n </Stack>\n </>\n ) : (\n description\n )}\n </LocalizedFieldDescriptionSlot>\n )}\n {isInvalid && (\n <LocalizedFieldErrorSlot\n // In order to associate the errors from both the error and legacy errors props with the fieldset,\n // we must associate them to this element with aria-labelledby.\n aria-labelledby={`${errorMessageProps.id}-error`}\n role=\"alert\"\n {...errorMessageProps}\n >\n <Icon>\n <ErrorOutline />\n </Icon>\n <Stack gap=\"0\" id={`${errorMessageProps.id}-error`}>\n {error}\n {errors && hasError && (\n <FieldErrors\n errors={errors}\n renderError={renderError}\n role={undefined}\n />\n )}\n </Stack>\n </LocalizedFieldErrorSlot>\n )}\n </LocalizedFieldRootSlot>\n );\n};\n","import { LocalizedField as LocalizedFieldRoot } from \"./components/localized-field.root\";\nimport {\n getLocaleFieldAttribute,\n createLocalizedString,\n isEmpty,\n omitEmptyTranslations,\n isTouched,\n RequiredValueErrorMessage,\n toFieldErrors,\n convertToMoneyValues,\n parseMoneyValues,\n getHighPrecisionCurrencies,\n getEmptyCurrencies,\n} from \"./utils/localized-field.utils\";\n\nexport const LocalizedField = Object.assign(LocalizedFieldRoot, {\n // Add util methods here for compat with uikit - see https://github.com/commercetools/ui-kit/blob/e97e0c7e8f3e9393981bf1949573212d7c571c90/packages/components/inputs/localized-text-input/src/localized-text-input.tsx#L396\n getId: getLocaleFieldAttribute,\n getName: getLocaleFieldAttribute,\n isTouched,\n isEmpty,\n createLocalizedString,\n omitEmptyTranslations,\n RequiredValueErrorMessage,\n toFieldErrors,\n convertToMoneyValues,\n parseMoneyValues,\n getHighPrecisionCurrencies,\n getEmptyCurrencies,\n});\n"],"names":["messages","defineMessages","withProvider","withContext","createSlotRecipeContext","localizedFieldSlotRecipe","LocalizedFieldRootSlot","LocalizedFieldLabelSlot","LocalizedFieldInfoDialogSlot","LocalizedFieldFieldsContainerSlot","LocalizedFieldDescriptionSlot","LocalizedFieldErrorSlot","LocalizedFieldToggleButtonContainerSlot","LocalizedFieldLocaleFieldRootSlot","LocalizedFieldLocaleFieldLabelSlot","LocalizedFieldLocaleFieldInputSlot","RequiredValueErrorMessage","jsx","FormField","FormattedMessage","getLocaleFieldAttribute","fieldGroupAttr","locale","getLanguageForLocale","splitLanguages","defaultLocale","locales","defaultLanguage","related","sortLocalesByDefaultLocaleLanguage","allLocales","unrelated","sortCurrencies","defaultCurrency","allCurrencies","remainingCurrencies","currency","getHasInvalidLocalizedFields","errors","defaultLocaleOrCurrency","localeOrCurrency","createLocalizedString","existingLocalizedString","localizedString","isEmpty","value","omitEmptyTranslations","localizedStringWithoutEmptyTranslations","isTouched","touched","toFieldErrors","convertToMoneyValues","values","MoneyInput","parseMoneyValues","moneyValues","allValues","moneyValue","getHighPrecisionCurrencies","currencyCode","getEmptyCurrencies","LocalizedFieldLocaleField","type","size","id","name","inputValueFromProps","description","warning","error","onChange","onBlur","onFocus","isRequired","isReadOnly","isDisabled","isInvalid","otherProps","InputComponent","TextInput","MultilineTextInput","RichTextInput","inputValue","handleChange","useCallback","changeValue","jsxs","e","Fragment","Icon","WarningAmber","LocalizedField","valuesByLocaleOrCurrency","placeholdersByLocaleOrCurrency","descriptionsByLocaleOrCurrency","warningsByLocaleOrCurrency","errorsByLocaleOrCurrency","label","hint","warnings","renderWarning","renderError","defaultExpanded","displayAllLocalesOrCurrencies","autoFocus","dataTrackComponent","dataTestId","dataTest","rest","expanded","setExpanded","useState","formatMessage","useIntl","localeFieldsContainerId","useId","moreDetailsButtonId","hasError","hasWarning","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","localizationKeys","allDataForFields","useMemo","allFieldData","localizationKey","allDataForLocale","shouldExpandInvalidFields","Stack","RaDialogTrigger","IconButton","HelpOutline","Popover","RaDialog","Box","RaCollection","item","Button","Payments","Language","FieldErrors","ErrorOutline","LocalizedFieldRoot"],"mappings":"g4BAEAA,EAAeC,iBAAe,CAC5B,qBAAsB,CACpB,GAAI,6CACJ,YAAa,2CACb,eAAgB,qDAAA,EAElB,wBAAyB,CACvB,GAAI,gDACJ,YAAa,uDACb,eAAgB,WAAA,EAElB,cAAe,CACb,GAAI,sCACJ,YACE,sEACF,eAAgB,oBAAA,EAElB,cAAe,CACb,GAAI,sCACJ,YACE,qEACF,eAAgB,oBAAA,EAElB,eAAgB,CACd,GAAI,uCACJ,YACE,sEACF,eAAgB,qBAAA,EAElB,eAAgB,CACd,GAAI,uCACJ,YACE,qEACF,eAAgB,qBAAA,CAEpB,CAAC,EC7BK,CAAE,aAAAC,GAAc,YAAAC,CAAA,EAAgBC,2BAAwB,CAC5D,OAAQC,GAAAA,wBACV,CAAC,EAQYC,GAAyBJ,GAGpC,WAAY,MAAM,EAKPK,GAA0BJ,EAGrC,SAAU,OAAO,EAKNK,GAA+BL,EAG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crE,EACbqC,EAAAA,KAAAE,EAAAA,SAAA,CACE,SAAA,CAAAvE,MAACwE,EAAAA,KAAA,CAAK,aAAa,UACjB,SAAAxE,MAACyE,EAAAA,eAAa,EAChB,EACAJ,EAAAA,KAAC6C,EAAAA,OAAM,IAAI,IAAI,GAAI,GAAGV,EAAiB,EAAE,WACtC,SAAA,CAAArD,EACA+B,GAAYmB,GACXrG,EAAAA,IAAC8H,GAAAA,YAAA,CACC,OAAQ5C,EACR,YAAaC,EACb,aAAa,UACb,KAAM,MAAA,CAAA,CACR,CAAA,CAEJ,CAAA,CAAA,CACF,EAEAjC,CAAA,CAAA,EAILS,GACCU,EAAAA,KAAC3E,GAAA,CAGC,kBAAiB,GAAG+G,EAAkB,EAAE,SACxC,KAAK,QACJ,GAAGA,EAEJ,SAAA,CAAAzG,EAAAA,IAACwE,EAAAA,KAAA,CACC,SAAAxE,EAAAA,IAAC+H,EAAAA,aAAA,CAAA,CAAa,EAChB,EACA1D,EAAAA,KAAC6C,EAAAA,OAAM,IAAI,IAAI,GAAI,GAAGT,EAAkB,EAAE,SACvC,SAAA,CAAArD,EACA/B,GAAU+E,GACTpG,EAAAA,IAAC8H,GAAAA,YAAA,CACC,OAAAzG,EACA,YAAA+D,EACA,KAAM,MAAA,CAAA,CACR,CAAA,CAEJ,CAAA,CAAA,CAAA,CACF,CAAA,CAAA,CAIR,ECxVaV,GAAiB,OAAO,OAAOsD,GAAoB,CAE9D,MAAO7H,EACP,QAASA,EACT,UAAA4B,GACA,QAAAJ,GACA,sBAAAH,GACA,sBAAAK,GACA,0BAAA9B,GACA,cAAAkC,GACA,qBAAAC,GACA,iBAAAG,GACA,2BAAAI,GACA,mBAAAE,EACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"localized-field-DCgNEoJc.cjs.js","sources":["../../src/components/localized-field/localized-field.i18n.ts","../../src/components/localized-field/localized-field.slots.tsx","../../src/components/localized-field/utils/localized-field.utils.tsx","../../src/components/localized-field/components/localized-field.locale-field.tsx","../../src/components/localized-field/components/localized-field.root.tsx","../../src/components/localized-field/localized-field.tsx"],"sourcesContent":["import { defineMessages } from \"react-intl\";\n\nexport default defineMessages({\n missingRequiredField: {\n id: \"Nimbus.LocalizedField.missingRequiredField\",\n description: \"Error message for missing required value\",\n defaultMessage: \"This field is required. Provide at least one value.\",\n },\n infoBoxTriggerAriaLabel: {\n id: \"Nimbus.LocalizedField.infoBoxTriggerAriaLabel\",\n description: \"aria label for button that triggers more info dialog\",\n defaultMessage: \"more info\",\n },\n showLanguages: {\n id: \"Nimbus.LocalizedField.showLanguages\",\n description:\n \"Label for showing all language inputs when toggle button is pressed\",\n defaultMessage: \"Show all languages\",\n },\n hideLanguages: {\n id: \"Nimbus.LocalizedField.hideLanguages\",\n description:\n \"Label for hiding all language inputs when toggle button is pressed\",\n defaultMessage: \"Hide all languages\",\n },\n showCurrencies: {\n id: \"Nimbus.LocalizedField.showCurrencies\",\n description:\n \"Label for showing all currency inputs when toggle button is pressed\",\n defaultMessage: \"Show all currencies\",\n },\n hideCurrencies: {\n id: \"Nimbus.LocalizedField.hideCurrencies\",\n description:\n \"Label for hiding all currency inputs when toggle button is pressed\",\n defaultMessage: \"Hide all currencies\",\n },\n});\n","/* eslint-disable @typescript-eslint/no-empty-object-type */\nimport {\n type HTMLChakraProps,\n type RecipeVariantProps,\n createSlotRecipeContext,\n} from \"@chakra-ui/react/styled-system\";\nimport { localizedFieldSlotRecipe } from \"./localized-field.recipe\";\n\nconst { withProvider, withContext } = createSlotRecipeContext({\n recipe: localizedFieldSlotRecipe,\n});\n\n// Root Slot\nexport interface LocalizedFieldRootSlotProps\n extends HTMLChakraProps<\n \"fieldset\",\n RecipeVariantProps<typeof localizedFieldSlotRecipe>\n > {}\nexport const LocalizedFieldRootSlot = withProvider<\n HTMLFieldSetElement,\n LocalizedFieldRootSlotProps\n>(\"fieldset\", \"root\");\n\n// Label Slot\nexport interface LocalizedFieldLabelSlotProps\n extends HTMLChakraProps<\"label\"> {}\nexport const LocalizedFieldLabelSlot = withContext<\n HTMLLabelElement,\n LocalizedFieldLabelSlotProps\n>(\"legend\", \"label\");\n\n// InfoDialog Slot\nexport interface LocalizedFieldInfoDialogSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldInfoDialogSlot = withContext<\n HTMLDivElement,\n LocalizedFieldInfoDialogSlotProps\n>(\"div\", \"infoDialog\");\n\n// FieldsContainer Slot\nexport interface LocalizedFieldFieldsContainerSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldFieldsContainerSlot = withContext<\n HTMLDivElement,\n LocalizedFieldFieldsContainerSlotProps\n>(\"div\", \"fieldsContainer\");\n\n// Description Slot\nexport interface LocalizedFieldDescriptionSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldDescriptionSlot = withContext<\n HTMLDivElement,\n LocalizedFieldDescriptionSlotProps\n>(\"div\", \"description\");\n\n// Error Slot\nexport interface LocalizedFieldErrorSlotProps extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldErrorSlot = withContext<\n HTMLDivElement,\n LocalizedFieldErrorSlotProps\n>(\"div\", \"error\");\n\n// ToggleButtonContainer Slot\nexport interface LocalizedFieldToggleButtonContainerSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldToggleButtonContainerSlot = withContext<\n HTMLDivElement,\n LocalizedFieldToggleButtonContainerSlotProps\n>(\"div\", \"toggleButtonContainer\");\n\n// LocaleFieldRoot Slot\n\nexport interface LocalizedFieldLocaleFieldRootSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldRootSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldRootSlotProps\n>(\"div\", \"localeFieldRoot\");\n\n// FieldLabel Slot\nexport interface LocalizedFieldLocaleFieldLabelSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldLabelSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldLabelSlotProps\n>(\"div\", \"localeFieldLabel\");\n\n// FieldInput Slot\nexport interface LocalizedFieldLocaleFieldInputSlotProps\n extends HTMLChakraProps<\"div\"> {}\nexport const LocalizedFieldLocaleFieldInputSlot = withContext<\n HTMLDivElement,\n LocalizedFieldLocaleFieldInputSlotProps\n>(\"div\", \"localeFieldInput\");\n","import { FormattedMessage } from \"react-intl\";\nimport {\n FormField,\n type TCurrencyCode,\n type TValue,\n type TMoneyValue,\n type TFieldErrors,\n MoneyInput,\n} from \"@/components\";\nimport messages from \"../localized-field.i18n\";\nimport type { LocalizedString } from \"../localized-field.types\";\n\ntype LanguagesSplitByDefaultLocale = {\n related: string[];\n unrelated: string[];\n};\n\ntype TouchedLocalizedString = { [locale: string]: boolean };\n\ntype CustomFormikErrors<Values> = {\n [K in keyof Values]?: TFieldErrors;\n};\n\nexport const RequiredValueErrorMessage = () => (\n <FormField.Error>\n <FormattedMessage {...messages.missingRequiredField} />\n </FormField.Error>\n);\n\nexport const getLocaleFieldAttribute = (\n fieldGroupAttr?: string,\n locale?: string\n): string | undefined =>\n fieldGroupAttr && locale ? `${fieldGroupAttr}.${locale}` : undefined;\n\n// gets the language tag of a given locale, e.g. `de` in `de-DE`\nexport const getLanguageForLocale = (locale: string): string =>\n locale.split(\"-\")[0];\n\n// splits the locales into two groups:\n// - the 'related' array contains locales with the same language tag as the default locale,\n// e.g. if the default locale is de-DE, related would be ['de-DE', 'de-CH']\n// - the 'unrelated' array contains locales with a different different language tag from the default locale\n//. e.g. if the default locale is de-DE, unrelated would be ['pt-BR', 'en-GB', 'zh-Hans']\nexport const splitLanguages = (\n defaultLocale: string,\n locales: string[]\n): LanguagesSplitByDefaultLocale => {\n const defaultLanguage = getLanguageForLocale(defaultLocale);\n const related = locales.filter(\n (locale) => getLanguageForLocale(locale) === defaultLanguage\n );\n const unrelated = locales.filter(\n (locale) => getLanguageForLocale(locale) !== defaultLanguage\n );\n return {\n unrelated,\n related,\n };\n};\n\n// sorts locales with the following priority:\n// - The selected locale is placed first (e.g pt-BR)\n// - All locales using the same language tag as the selected language\n// follow (e.g. pt, pt-PT). They are sorted alphabetically.\n// - All other locales follow, sorted alphabetically as well\nexport const sortLocalesByDefaultLocaleLanguage = (\n defaultLocale: string,\n allLocales: string[]\n): string[] => {\n const { related, unrelated } = splitLanguages(\n defaultLocale,\n allLocales.filter((locale: string) => locale !== defaultLocale)\n );\n\n return [defaultLocale, ...related.sort(), ...unrelated.sort()];\n};\n\nexport const sortCurrencies = (\n defaultCurrency: TCurrencyCode,\n allCurrencies: TCurrencyCode[]\n) => {\n const remainingCurrencies = allCurrencies.filter(\n (currency) => currency !== defaultCurrency\n );\n return [defaultCurrency, ...remainingCurrencies.sort()];\n};\n\nexport const getHasInvalidLocalizedFields = <TErrors extends object>(\n errors?: TErrors,\n defaultLocaleOrCurrency?: string\n): boolean => {\n if (errors && Object.keys(errors).length > 0 && defaultLocaleOrCurrency) {\n return Object.keys(errors).some(\n (localeOrCurrency) => localeOrCurrency !== defaultLocaleOrCurrency\n );\n }\n return false;\n};\n\nexport const createLocalizedString = (\n locales: string[],\n existingLocalizedString: LocalizedString\n): LocalizedString => {\n const localesInLocalizedString = Array.from(\n new Set([...locales, ...Object.keys(existingLocalizedString)])\n );\n\n return localesInLocalizedString.reduce<LocalizedString>(\n (localizedString, locale) => ({\n ...localizedString,\n [locale]: existingLocalizedString?.[locale] || \"\",\n }),\n {}\n );\n};\n\n// Note: I prefer `isLocalizedStringEmpty`, but keeping this as `isEmpty` for api consistency with UI Kit\nexport const isEmpty = (localizedString?: LocalizedString): boolean => {\n if (!localizedString) return true;\n return Object.values(localizedString).every(\n (value?: string) => !value || value?.trim().length === 0\n );\n};\n\nexport const omitEmptyTranslations = <Translations extends LocalizedString>(\n localizedString: Translations\n): LocalizedString => {\n // TODO: is it necessary to create a util that enforces a consistent warning/error format, e.g.\n // `<COMPONENT_NAME> - Warning: <WARNING_MESSAGE>`\n if (typeof localizedString !== \"object\") {\n console.warn(\n \"Nimbus Localized Field - Warning: omitEmptyTranslations must be called with an object\"\n );\n }\n\n return Object.entries(localizedString).reduce<LocalizedString>(\n (localizedStringWithoutEmptyTranslations, [locale, value]) => {\n if (value && value.trim().length > 0) {\n return {\n ...localizedStringWithoutEmptyTranslations,\n [locale]: value,\n };\n }\n return localizedStringWithoutEmptyTranslations;\n },\n {}\n );\n};\n\nexport const isTouched = (touched?: TouchedLocalizedString): boolean => {\n if (touched) {\n return Object.values(touched).some(Boolean);\n }\n return false;\n};\n\n/**\n * Use this function to convert the Formik `errors` object type to\n * our custom field errors type.\n * This is primarly useful when using TypeScript.\n */\nexport function toFieldErrors<FormValues>(\n errors: unknown\n): CustomFormikErrors<FormValues> {\n return errors as CustomFormikErrors<FormValues>;\n}\n\nexport const convertToMoneyValues = (\n values: TValue[],\n currency: string\n): Array<TMoneyValue | null> =>\n Object.values(values).map<TMoneyValue | null>((value) => {\n return MoneyInput.convertToMoneyValue(value, currency);\n });\n\nexport const parseMoneyValues = (\n moneyValues: TMoneyValue[] = [],\n locale: string\n): Record<TCurrencyCode, TValue> =>\n moneyValues.reduce<Record<TCurrencyCode, TValue>>(\n (allValues, moneyValue) => {\n const value = MoneyInput.parseMoneyValue(moneyValue, locale);\n return {\n ...allValues,\n [value.currencyCode]: value,\n };\n },\n {} as Record<TCurrencyCode, TValue>\n );\n\nexport const getHighPrecisionCurrencies = (\n values: Record<TCurrencyCode, TValue>,\n locale: string\n): TCurrencyCode[] => {\n const typedCurrencyCodes = Object.keys(values) as TCurrencyCode[];\n return typedCurrencyCodes.filter((currencyCode) =>\n MoneyInput.isHighPrecision(values[currencyCode], locale)\n );\n};\n\nexport const getEmptyCurrencies = (\n values: Record<TCurrencyCode, TValue>\n): TCurrencyCode[] => {\n const typedCurrencyCodes = Object.keys(values) as TCurrencyCode[];\n return typedCurrencyCodes.filter((currencyCode) =>\n MoneyInput.isEmpty(values[currencyCode])\n );\n};\n","import { useCallback } from \"react\";\nimport {\n FormField,\n Icon,\n TextInput,\n MoneyInput,\n type TCustomEvent,\n MultilineTextInput,\n RichTextInput,\n type TValue,\n type TCurrencyCode,\n} from \"@/components\";\nimport { WarningAmber } from \"@commercetools/nimbus-icons\";\nimport {\n LocalizedFieldLocaleFieldRootSlot,\n LocalizedFieldLocaleFieldInputSlot,\n LocalizedFieldLocaleFieldLabelSlot,\n} from \"../localized-field.slots\";\nimport type { LocalizedFieldLocaleFieldProps } from \"../localized-field.types\";\n\nexport const LocalizedFieldLocaleField = ({\n type,\n size,\n localeOrCurrency,\n id,\n name,\n inputValue: inputValueFromProps,\n description,\n warning,\n error,\n onChange,\n onBlur,\n onFocus,\n isRequired,\n isReadOnly,\n isDisabled,\n isInvalid,\n touched,\n ...otherProps\n}: LocalizedFieldLocaleFieldProps) => {\n let InputComponent:\n | typeof TextInput\n | typeof MultilineTextInput\n | typeof MoneyInput\n | typeof RichTextInput;\n switch (type) {\n case \"text\":\n default:\n InputComponent = TextInput;\n break;\n case \"multiLine\":\n InputComponent = MultilineTextInput;\n break;\n case \"money\":\n InputComponent = MoneyInput;\n break;\n case \"richText\":\n InputComponent = RichTextInput;\n break;\n }\n\n const getInputValue = () => {\n if (type === \"money\") {\n return inputValueFromProps\n ? (inputValueFromProps as TValue)\n : ({ amount: \"\", currencyCode: localeOrCurrency } as TValue);\n }\n return inputValueFromProps ? inputValueFromProps : \"\";\n };\n\n const inputValue = getInputValue();\n\n const handleChange = useCallback(\n (value: string | TCustomEvent | undefined) => {\n // The `MoneyInput` onChange event value is a custom value,\n // and the `MoneyInput` modifies the input id and name since it is in a `group`,\n // so we need to build a separate return object for the MoneInput to return\n // the expected values\n const isMoneyInputEvent = typeof value === \"object\";\n const changeValue = {\n target: isMoneyInputEvent\n ? {\n id: value.target.id,\n name: value.target.name,\n locale: undefined,\n currency: localeOrCurrency as TCurrencyCode,\n value: value.target.value,\n }\n : { id, name, locale: localeOrCurrency, currency: undefined, value },\n };\n onChange(changeValue);\n },\n [id, name, localeOrCurrency, onChange]\n );\n\n return (\n <LocalizedFieldLocaleFieldRootSlot asChild>\n <FormField.Root\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isInvalid={(isInvalid || !!error) && touched}\n direction=\"row\"\n size={size}\n id={id}\n >\n <LocalizedFieldLocaleFieldLabelSlot\n display={type === \"money\" ? \"none\" : undefined}\n {...(isDisabled && { \"data-disabled\": isDisabled })}\n asChild\n >\n <FormField.Label>\n {localeOrCurrency.toLocaleUpperCase()}\n </FormField.Label>\n </LocalizedFieldLocaleFieldLabelSlot>\n <FormField.Input>\n <LocalizedFieldLocaleFieldInputSlot\n aria-required={isRequired}\n asChild\n >\n <InputComponent\n {...otherProps}\n size={size}\n value={inputValue as string & TValue}\n onChange={handleChange}\n onBlur={(e: React.FocusEvent | TCustomEvent) =>\n onBlur?.(e, localeOrCurrency)\n }\n onFocus={(e: React.FocusEvent | TCustomEvent) =>\n onFocus?.(e, localeOrCurrency)\n }\n isRequired={isRequired}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n isInvalid={(isInvalid || !!error) && touched}\n />\n </LocalizedFieldLocaleFieldInputSlot>\n </FormField.Input>\n {(description || (warning && touched)) && (\n <FormField.Description\n role={warning && touched ? \"status\" : undefined}\n color={warning && touched ? \"warning.11\" : undefined}\n display=\"flex\"\n gap=\"100\"\n alignItems=\"center\"\n >\n {warning && touched ? (\n <>\n <Icon colorPalette=\"warning\">\n <WarningAmber />\n </Icon>\n {warning}\n </>\n ) : (\n description\n )}\n </FormField.Description>\n )}\n {error && touched && <FormField.Error>{error}</FormField.Error>}\n </FormField.Root>\n </LocalizedFieldLocaleFieldRootSlot>\n );\n};\n","import { useState, useMemo } from \"react\";\nimport { useIntl } from \"react-intl\";\nimport {\n Collection as RaCollection,\n Dialog as RaDialog,\n DialogTrigger as RaDialogTrigger,\n} from \"react-aria-components\";\nimport { useField, useId } from \"react-aria\";\nimport {\n ErrorOutline,\n HelpOutline,\n Language,\n Payments,\n WarningAmber,\n} from \"@commercetools/nimbus-icons\";\nimport {\n Box,\n Button,\n FieldErrors,\n Icon,\n IconButton,\n Stack,\n type TCurrencyCode,\n} from \"@/components\";\nimport { Popover } from \"../../popover\";\nimport messages from \"../localized-field.i18n\";\nimport {\n LocalizedFieldRootSlot,\n LocalizedFieldLabelSlot,\n LocalizedFieldInfoDialogSlot,\n LocalizedFieldFieldsContainerSlot,\n LocalizedFieldDescriptionSlot,\n LocalizedFieldErrorSlot,\n LocalizedFieldToggleButtonContainerSlot,\n} from \"../localized-field.slots\";\nimport type {\n LocalizedFieldProps,\n MergedLocaleFieldData,\n LocalizedCurrency,\n} from \"../localized-field.types\";\n\nimport {\n getHasInvalidLocalizedFields,\n getLocaleFieldAttribute,\n sortCurrencies,\n sortLocalesByDefaultLocaleLanguage,\n} from \"../utils/localized-field.utils\";\nimport { LocalizedFieldLocaleField } from \"./localized-field.locale-field\";\n\nexport const LocalizedField = ({\n type = \"text\",\n id,\n name,\n defaultLocaleOrCurrency,\n valuesByLocaleOrCurrency,\n placeholdersByLocaleOrCurrency,\n descriptionsByLocaleOrCurrency,\n warningsByLocaleOrCurrency,\n errorsByLocaleOrCurrency,\n label,\n hint,\n description,\n warning,\n warnings,\n renderWarning,\n error,\n errors,\n renderError,\n touched,\n isRequired,\n isDisabled,\n isReadOnly,\n onChange,\n onBlur,\n onFocus,\n defaultExpanded = false,\n displayAllLocalesOrCurrencies = false,\n size,\n autoFocus,\n [\"data-track-component\"]: dataTrackComponent,\n [\"data-testid\"]: dataTestId,\n [\"data-test\"]: dataTest,\n // DOM & Style props for wrapper container\n ...rest\n}: LocalizedFieldProps) => {\n const [expanded, setExpanded] = useState(\n displayAllLocalesOrCurrencies || defaultExpanded\n );\n\n const { formatMessage } = useIntl();\n\n // Used to associate more info dialog with fieldset via `aria-controls`\n const localeFieldsContainerId = useId();\n // Used to associate more info dialog with fieldset via `aria-details`\n const moreDetailsButtonId = useId();\n\n // Either `error` exists, or there are `true` fields in the UI Kit compat `errors` object\n const hasError: boolean = Boolean(\n error || (errors && Object.values(errors).some((error) => error === true))\n );\n\n // Either `warning` exists, or there are `true` fields in the UI Kit compat `warnings` object\n const hasWarning: boolean = Boolean(\n warning || (warnings && Object.values(warnings).some(Boolean))\n );\n\n // FieldGroup is invalid if a non-field-specific error is passed and the group has been touched\n // When FieldGroup is invalid, all fields will display error styling without displaying a field-specific error message\n const isInvalid: boolean = !!(hasError && touched);\n\n const { labelProps, fieldProps, descriptionProps, errorMessageProps } =\n useField({\n id,\n label,\n description,\n errorMessage: error,\n isInvalid,\n });\n\n // Array of locales/currencies to display as input fields\n const localizationKeys: string[] | TCurrencyCode[] = Object.keys(\n valuesByLocaleOrCurrency\n );\n\n // Merge all -ByLocaleOrCurrencies data for each field\n const allDataForFields = useMemo(() => {\n const sortedFieldData =\n type === \"money\"\n ? sortCurrencies(\n defaultLocaleOrCurrency as TCurrencyCode,\n localizationKeys as TCurrencyCode[]\n )\n : sortLocalesByDefaultLocaleLanguage(\n defaultLocaleOrCurrency,\n localizationKeys\n );\n\n return sortedFieldData.reduce(\n (allFieldData: MergedLocaleFieldData[], localizationKey) => {\n const allDataForLocale = {\n localeOrCurrency: localizationKey,\n inputValue:\n type === \"money\"\n ? (valuesByLocaleOrCurrency as LocalizedCurrency)[localizationKey]\n : (valuesByLocaleOrCurrency[localizationKey] as string),\n placeholder: placeholdersByLocaleOrCurrency?.[localizationKey],\n description: descriptionsByLocaleOrCurrency?.[localizationKey],\n warning: warningsByLocaleOrCurrency?.[localizationKey],\n error: errorsByLocaleOrCurrency?.[localizationKey],\n // autoFocus default/first locale field\n ...(localizationKey === defaultLocaleOrCurrency && autoFocus\n ? { autoFocus }\n : {}),\n isInvalid,\n isRequired,\n isDisabled,\n isReadOnly,\n };\n if (\n expanded ||\n // Only display defaultLocaleOrInput field if fieldGroup is not expanded\n (!expanded && localizationKey === defaultLocaleOrCurrency)\n ) {\n return [...allFieldData, allDataForLocale];\n }\n return allFieldData;\n },\n []\n );\n }, [\n valuesByLocaleOrCurrency,\n placeholdersByLocaleOrCurrency,\n descriptionsByLocaleOrCurrency,\n warningsByLocaleOrCurrency,\n errorsByLocaleOrCurrency,\n defaultLocaleOrCurrency,\n expanded,\n isInvalid,\n isRequired,\n isDisabled,\n isReadOnly,\n ]);\n\n const groupHasInvalidLocalizedFields = getHasInvalidLocalizedFields(\n errorsByLocaleOrCurrency,\n defaultLocaleOrCurrency\n );\n\n const shouldExpandInvalidFields =\n (groupHasInvalidLocalizedFields || hasError) && touched;\n // If there are fields that are invalid, ensure that field group\n // shows all fields so that invalid field is visible\n if (shouldExpandInvalidFields && !expanded) {\n setExpanded(true);\n }\n\n return (\n <LocalizedFieldRootSlot\n {...rest}\n {...fieldProps}\n aria-details={hint ? moreDetailsButtonId : undefined}\n type={type}\n size={size}\n name={name}\n >\n {label && (\n <Stack direction=\"row\" gap=\"0\">\n <LocalizedFieldLabelSlot {...labelProps}>\n {label}\n {isRequired && <sup aria-hidden=\"true\">*</sup>}\n </LocalizedFieldLabelSlot>\n {hint && (\n <RaDialogTrigger>\n <IconButton\n id={moreDetailsButtonId}\n aria-label={formatMessage(messages.infoBoxTriggerAriaLabel)}\n size=\"2xs\"\n tone=\"info\"\n variant=\"link\"\n >\n <HelpOutline />\n </IconButton>\n\n <Popover padding={0}>\n <LocalizedFieldInfoDialogSlot asChild>\n <RaDialog>\n <Box p=\"300\">{hint}</Box>\n </RaDialog>\n </LocalizedFieldInfoDialogSlot>\n </Popover>\n </RaDialogTrigger>\n )}\n </Stack>\n )}\n <LocalizedFieldFieldsContainerSlot\n id={localeFieldsContainerId}\n data-expanded={expanded}\n >\n <RaCollection items={allDataForFields}>\n {(item) => {\n return (\n <LocalizedFieldLocaleField\n {...item}\n size={size}\n type={type}\n onChange={onChange}\n onBlur={onBlur}\n onFocus={onFocus}\n touched={touched}\n // Format field attributes to match uikit pattern\n id={getLocaleFieldAttribute(\n fieldProps.id,\n item.localeOrCurrency\n )}\n name={getLocaleFieldAttribute(name, item.localeOrCurrency)}\n data-test={getLocaleFieldAttribute(\n dataTest,\n item.localeOrCurrency\n )}\n data-testid={getLocaleFieldAttribute(\n dataTestId,\n item.localeOrCurrency\n )}\n data-track-component={getLocaleFieldAttribute(\n dataTrackComponent,\n item.localeOrCurrency\n )}\n />\n );\n }}\n </RaCollection>\n </LocalizedFieldFieldsContainerSlot>\n\n {!displayAllLocalesOrCurrencies && localizationKeys.length > 1 && (\n <LocalizedFieldToggleButtonContainerSlot>\n <Button\n aria-controls={localeFieldsContainerId}\n aria-describedby={labelProps.id}\n aria-expanded={expanded}\n onPress={() => setExpanded(!expanded)}\n isDisabled={isDisabled || (shouldExpandInvalidFields && expanded)}\n variant=\"ghost\"\n size=\"2xs\"\n colorPalette=\"primary\"\n >\n <Box\n as={type === \"money\" ? Payments : Language}\n display=\"inline-flex\"\n boxSize=\"400\"\n verticalAlign=\"text-bottom\"\n mr=\"100\"\n />\n {type === \"money\"\n ? expanded\n ? formatMessage(messages.hideCurrencies)\n : formatMessage(messages.showCurrencies)\n : expanded\n ? formatMessage(messages.hideLanguages)\n : formatMessage(messages.showLanguages)}\n </Button>\n </LocalizedFieldToggleButtonContainerSlot>\n )}\n {(description || (hasWarning && touched)) && (\n <LocalizedFieldDescriptionSlot\n role={hasWarning && touched ? \"status\" : undefined}\n color={hasWarning && touched ? \"warning.11\" : undefined}\n // In order to associate the warnings from both the warning and legacy warnings props with the fieldset,\n // we must associate, them to this element with aria-labelledby\n aria-labelledby={`${descriptionProps.id}-warning`}\n {...descriptionProps}\n >\n {/** Warnings are for compat with UI Kit localized fields */}\n {hasWarning && touched ? (\n <>\n <Icon colorPalette=\"warning\">\n <WarningAmber />\n </Icon>\n <Stack gap=\"0\" id={`${descriptionProps.id}-warning`}>\n {warning}\n {warnings && hasWarning && (\n <FieldErrors\n errors={warnings}\n renderError={renderWarning}\n colorPalette=\"warning\"\n role={undefined}\n />\n )}\n </Stack>\n </>\n ) : (\n description\n )}\n </LocalizedFieldDescriptionSlot>\n )}\n {isInvalid && (\n <LocalizedFieldErrorSlot\n // In order to associate the errors from both the error and legacy errors props with the fieldset,\n // we must associate them to this element with aria-labelledby.\n aria-labelledby={`${errorMessageProps.id}-error`}\n role=\"alert\"\n {...errorMessageProps}\n >\n <Icon>\n <ErrorOutline />\n </Icon>\n <Stack gap=\"0\" id={`${errorMessageProps.id}-error`}>\n {error}\n {errors && hasError && (\n <FieldErrors\n errors={errors}\n renderError={renderError}\n role={undefined}\n />\n )}\n </Stack>\n </LocalizedFieldErrorSlot>\n )}\n </LocalizedFieldRootSlot>\n );\n};\n","import { LocalizedField as LocalizedFieldRoot } from \"./components/localized-field.root\";\nimport {\n getLocaleFieldAttribute,\n createLocalizedString,\n isEmpty,\n omitEmptyTranslations,\n isTouched,\n RequiredValueErrorMessage,\n toFieldErrors,\n convertToMoneyValues,\n parseMoneyValues,\n getHighPrecisionCurrencies,\n getEmptyCurrencies,\n} from \"./utils/localized-field.utils\";\n\nexport const LocalizedField = Object.assign(LocalizedFieldRoot, {\n // Add util methods here for compat with uikit - see https://github.com/commercetools/ui-kit/blob/e97e0c7e8f3e9393981bf1949573212d7c571c90/packages/components/inputs/localized-text-input/src/localized-text-input.tsx#L396\n getId: getLocaleFieldAttribute,\n getName: getLocaleFieldAttribute,\n isTouched,\n isEmpty,\n createLocalizedString,\n omitEmptyTranslations,\n RequiredValueErrorMessage,\n toFieldErrors,\n convertToMoneyValues,\n parseMoneyValues,\n getHighPrecisionCurrencies,\n getEmptyCurrencies,\n});\n"],"names":["messages","defineMessages","withProvider","withContext","createSlotRecipeContext","localizedFieldSlotRecipe","LocalizedFieldRootSlot","LocalizedFieldLabelSlot","LocalizedFieldInfoDialogSlot","LocalizedFieldFieldsContainerSlot","LocalizedFieldDescriptionSlot","LocalizedFieldErrorSlot","LocalizedFieldToggleButtonContainerSlot","LocalizedFieldLocaleFieldRootSlot","LocalizedFieldLocaleFieldLabelSlot","LocalizedFieldLocaleFieldInputSlot","RequiredValueErrorMessage","jsx","FormField","FormattedMessage","getLocaleFieldAttribute","fieldGroupAttr","locale","getLanguageForLocale","splitLanguages","defaultLocale","locales","defaultLanguage","related","sortLocalesByDefaultLocaleLanguage","allLocales","unrelated","sortCurrencies","defaultCurrency","allCurrencies","remainingCurrencies","currency","getHasInvalidLocalizedFields","errors","defaultLocaleOrCurrency","localeOrCurrency","createLocalizedString","existingLocalizedString","localizedString","isEmpty","value","omitEmptyTranslations","localizedStringWithoutEmptyTranslations","isTouched","touched","toFieldErrors","convertToMoneyValues","values","MoneyInput","parseMoneyValues","moneyValues","allValues","moneyValue","getHighPrecisionCurrencies","currencyCode","getEmptyCurrencies","LocalizedFieldLocaleField","type","size","id","name","inputValueFromProps","description","warning","error","onChange","onBlur","onFocus","isRequired","isReadOnly","isDisabled","isInvalid","otherProps","InputComponent","TextInput","MultilineTextInput","RichTextInput","inputValue","handleChange","useCallback","changeValue","jsxs","e","Fragment","Icon","WarningAmber","LocalizedField","valuesByLocaleOrCurrency","placeholdersByLocaleOrCurrency","descriptionsByLocaleOrCurrency","warningsByLocaleOrCurrency","errorsByLocaleOrCurrency","label","hint","warnings","renderWarning","renderError","defaultExpanded","displayAllLocalesOrCurrencies","autoFocus","dataTrackComponent","dataTestId","dataTest","rest","expanded","setExpanded","useState","formatMessage","useIntl","localeFieldsContainerId","useId","moreDetailsButtonId","hasError","hasWarning","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","localizationKeys","allDataForFields","useMemo","allFieldData","localizationKey","allDataForLocale","shouldExpandInvalidFields","Stack","RaDialogTrigger","IconButton","HelpOutline","Popover","RaDialog","Box","RaCollection","item","Button","Payments","Language","FieldErrors","ErrorOutline","LocalizedFieldRoot"],"mappings":"g4BAEAA,EAAeC,iBAAe,CAC5B,qBAAsB,CACpB,GAAI,6CACJ,YAAa,2CACb,eAAgB,qDAAA,EAElB,wBAAyB,CACvB,GAAI,gDACJ,YAAa,uDACb,eAAgB,WAAA,EAElB,cAAe,CACb,GAAI,sCACJ,YACE,sEACF,eAAgB,oBAAA,EAElB,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AAOsD,GAAoB,CAE9D,MAAO7H,EACP,QAASA,EACT,UAAA4B,GACA,QAAAJ,GACA,sBAAAH,GACA,sBAAAK,GACA,0BAAA9B,GACA,cAAAkC,GACA,qBAAAC,GACA,iBAAAG,GACA,2BAAAI,GACA,mBAAAE,EACF,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),s=require("react"),U=require("@chakra-ui/react/styled-system"),L=require("react-intl"),di=require("@commercetools/nimbus-icons"),mi=require("./extractStyleProps-G58aSXl8.cjs.js"),yi=require("@chakra-ui/react"),hi=require("./group-NazPMAWg.cjs.js"),x=require("./mergeProps-BA5Cwf5w.cjs.js"),bi=require("./context-OoV8SSWX.cjs.js"),A=require("./select-D_HPNSo0.cjs.js"),Si=require("./number-input-DA_yy5BZ.cjs.js"),Mi=require("./make-element-focusable-oedzOY_M.cjs.js"),X=require("./tooltip-CH2ASPPO.cjs.js"),Ci=require("./box-CWni3A32.cjs.js"),D={ADP:{fractionDigits:0},AED:{fractionDigits:2},AFA:{fractionDigits:2},AFN:{fractionDigits:2},ALL:{fractionDigits:2},AMD:{fractionDigits:2},ANG:{fractionDigits:2},AOA:{fractionDigits:2},ARS:{fractionDigits:2},ATS:{fractionDigits:2},AUD:{fractionDigits:2},AWG:{fractionDigits:2},AYM:{fractionDigits:2},AZM:{fractionDigits:2},AZN:{fractionDigits:2},BAM:{fractionDigits:2},BBD:{fractionDigits:2},BDT:{fractionDigits:2},BEF:{fractionDigits:0},BGL:{fractionDigits:2},BGN:{fractionDigits:2},BHD:{fractionDigits:3},BIF:{fractionDigits:0},BMD:{fractionDigits:2},BND:{fractionDigits:2},BOB:{fractionDigits:2},BOV:{fractionDigits:2},BRL:{fractionDigits:2},BSD:{fractionDigits:2},BTN:{fractionDigits:2},BWP:{fractionDigits:2},BYB:{fractionDigits:0},BYN:{fractionDigits:2},BYR:{fractionDigits:0},BZD:{fractionDigits:2},CAD:{fractionDigits:2},CDF:{fractionDigits:2},CHF:{fractionDigits:2},CLF:{fractionDigits:0},CLP:{fractionDigits:0},CNY:{fractionDigits:2},COP:{fractionDigits:2},CRC:{fractionDigits:2},CSD:{fractionDigits:2},CUC:{fractionDigits:2},CUP:{fractionDigits:2},CVE:{fractionDigits:2},CYP:{fractionDigits:2},CZK:{fractionDigits:2},DEM:{fractionDigits:2},DJF:{fractionDigits:0},DKK:{fractionDigits:2},DOP:{fractionDigits:2},DZD:{fractionDigits:2},EEK:{fractionDigits:2},EGP:{fractionDigits:2},ERN:{fractionDigits:2},ESP:{fractionDigits:0},ETB:{fractionDigits:2},EUR:{fractionDigits:2},FIM:{fractionDigits:2},FJD:{fractionDigits:2},FKP:{fractionDigits:2},FRF:{fractionDigits:2},GBP:{fractionDigits:2},GEL:{fractionDigits:2},GHC:{fractionDigits:2},GHS:{fractionDigits:2},GIP:{fractionDigits:2},GMD:{fractionDigits:2},GNF:{fractionDigits:0},GRD:{fractionDigits:0},GTQ:{fractionDigits:2},GWP:{fractionDigits:2},GYD:{fractionDigits:2},HKD:{fractionDigits:2},HNL:{fractionDigits:2},HRK:{fractionDigits:2},HTG:{fractionDigits:2},HUF:{fractionDigits:2},IDR:{fractionDigits:2},IEP:{fractionDigits:2},ILS:{fractionDigits:2},INR:{fractionDigits:2},IQD:{fractionDigits:3},IRR:{fractionDigits:2},ISK:{fractionDigits:0},ITL:{fractionDigits:0},JMD:{fractionDigits:2},JOD:{fractionDigits:3},JPY:{fractionDigits:0},KES:{fractionDigits:2},KGS:{fractionDigits:2},KHR:{fractionDigits:2},KMF:{fractionDigits:0},KPW:{fractionDigits:2},KRW:{fractionDigits:0},KWD:{fractionDigits:3},KYD:{fractionDigits:2},KZT:{fractionDigits:2},LAK:{fractionDigits:2},LBP:{fractionDigits:2},LKR:{fractionDigits:2},LRD:{fractionDigits:2},LSL:{fractionDigits:2},LTL:{fractionDigits:2},LUF:{fractionDigits:0},LVL:{fractionDigits:2},LYD:{fractionDigits:3},MAD:{fractionDigits:2},MDL:{fractionDigits:2},MGA:{fractionDigits:2},MGF:{fractionDigits:0},MKD:{fractionDigits:2},MMK:{fractionDigits:2},MNT:{fractionDigits:2},MOP:{fractionDigits:2},MRO:{fractionDigits:2},MTL:{fractionDigits:2},MUR:{fractionDigits:2},MVR:{fractionDigits:2},MWK:{fractionDigits:2},MXN:{fractionDigits:2},MXV:{fractionDigits:2},MYR:{fractionDigits:2},MZM:{fractionDigits:2},MZN:{fractionDigits:2},NAD:{fractionDigits:2},NGN:{fractionDigits:2},NIO:{fractionDigits:2},NLG:{fractionDigits:2},NOK:{fractionDigits:2},NPR:{fractionDigits:2},NZD:{fractionDigits:2},OMR:{fractionDigits:3},PAB:{fractionDigits:2},PEN:{fractionDigits:2},PGK:{fractionDigits:2},PHP:{fractionDigits:2},PKR:{fractionDigits:2},PLN:{fractionDigits:2},PTE:{fractionDigits:0},PYG:{fractionDigits:0},QAR:{fractionDigits:2},ROL:{fractionDigits:2},RON:{fractionDigits:2},RSD:{fractionDigits:2},RUB:{fractionDigits:2},RUR:{fractionDigits:2},RWF:{fractionDigits:0},SAR:{fractionDigits:2},SBD:{fractionDigits:2},SCR:{fractionDigits:2},SDD:{fractionDigits:2},SDG:{fractionDigits:2},SEK:{fractionDigits:2},SGD:{fractionDigits:2},SHP:{fractionDigits:2},SIT:{fractionDigits:2},SKK:{fractionDigits:2},SLL:{fractionDigits:2},SOS:{fractionDigits:2},SRD:{fractionDigits:2},SRG:{fractionDigits:2},SSP:{fractionDigits:2},STD:{fractionDigits:2},SVC:{fractionDigits:2},SYP:{fractionDigits:2},SZL:{fractionDigits:2},THB:{fractionDigits:2},TJS:{fractionDigits:2},TMM:{fractionDigits:2},TMT:{fractionDigits:2},TND:{fractionDigits:3},TOP:{fractionDigits:2},TPE:{fractionDigits:0},TRL:{fractionDigits:0},TRY:{fractionDigits:2},TTD:{fractionDigits:2},TWD:{fractionDigits:2},TZS:{fractionDigits:2},UAH:{fractionDigits:2},UGX:{fractionDigits:0},USD:{fractionDigits:2},USN:{fractionDigits:2},USS:{fractionDigits:2},UYU:{fractionDigits:2},UZS:{fractionDigits:2},VEB:{fractionDigits:2},VEF:{fractionDigits:2},VND:{fractionDigits:0},VUV:{fractionDigits:0},WST:{fractionDigits:2},XAF:{fractionDigits:0},XAG:{fractionDigits:-1},XAU:{fractionDigits:-1},XBA:{fractionDigits:-1},XBB:{fractionDigits:-1},XBC:{fractionDigits:-1},XBD:{fractionDigits:-1},XCD:{fractionDigits:2},XDR:{fractionDigits:-1},XFO:{fractionDigits:-1},XFU:{fractionDigits:-1},XOF:{fractionDigits:0},XPD:{fractionDigits:-1},XPF:{fractionDigits:0},XPT:{fractionDigits:-1},XSU:{fractionDigits:-1},XTS:{fractionDigits:-1},XUA:{fractionDigits:-1},XXX:{fractionDigits:-1},YER:{fractionDigits:2},YUM:{fractionDigits:2},ZAR:{fractionDigits:2},ZMK:{fractionDigits:2},ZMW:{fractionDigits:2},ZWD:{fractionDigits:2},ZWL:{fractionDigits:2},ZWN:{fractionDigits:2},ZWR:{fractionDigits:2}},H=yi.defineSlotRecipe({slots:["root","container","currencySelect","currencyLabel","amountInput","badge"],className:"nimbus-money-input",base:{root:{width:"full",position:"relative",fontFamily:"inherit","& .nimbus-select__trigger":{width:"2800",borderRightRadius:"0",boxShadow:"inset 0 1px 0 0 {colors.neutral.7}, inset 0 -1px 0 0 {colors.neutral.7}, inset 1px 0 0 0 {colors.neutral.7}"},"&:has(.nimbus-money-input__container:focus-within)":{"& .nimbus-money-input__currencyLabel":{outlineWidth:"var(--focus-ring-width)",outlineColor:"var(--focus-ring-color)",outlineStyle:"var(--focus-ring-style)",outlineOffset:"var(--focus-ring-offset)",clipPath:"inset(-4px -1px -4px -4px)"},"& .nimbus-money-input__amountInput":{clipPath:"inset(-4px -4px -4px -1px)"}}},container:{display:"inline-flex",alignItems:"stretch",position:"relative"},currencySelect:{_focusWithin:{zIndex:2}},currencyLabel:{color:"neutral.11",fontWeight:"500",display:"flex",height:"full",borderLeftRadius:"200",backgroundColor:"neutral.1",boxShadow:"inset 0 1px 0 0 {colors.neutral.7}, inset 0 -1px 0 0 {colors.neutral.7}, inset 1px 0 0 0 {colors.neutral.7}",paddingInline:"400",alignItems:"center","&[data-disabled='true']":{opacity:"0.5"}},amountInput:{borderLeftRadius:"0",_focusWithin:{zIndex:2}},badge:{position:"absolute",top:"0",right:"0",height:"full",display:"flex",alignItems:"center",justifyContent:"center",marginRight:"spacing.25"}},variants:{size:{sm:{root:{fontSize:"fontSize.20","& .nimbus-select__trigger":{width:"2600"}},currencySelect:{padding:"0 spacing.20"},amountInput:{paddingRight:"spacing.30"},currencyLabel:{fontSize:"300",lineHeight:"450"}},md:{root:{fontSize:"fontSize.30","& .nimbus-select__trigger":{width:"2800"}},currencySelect:{padding:"0 spacing.25"},amountInput:{paddingRight:"spacing.40"},currencyLabel:{fontSize:"350",lineHeight:"500"}}}},defaultVariants:{size:"md"}}),{withProvider:Ii,withContext:p}=U.createSlotRecipeContext({recipe:H}),Pi=Ii(hi.Group,"root"),Ri=p("div","container"),xi=p("div","currencySelect"),Ai=p("label","currencyLabel"),Li=p("input","amountInput"),Bi=p("div","badge"),Ni=(i,r,o)=>{if(!o)return null;const t=D[o];if(!t||i.length===0||i.trim()==="")return null;!r&&t.fractionDigits===0&&console.warn(`MoneyInput: A locale must be provided when currency has no fraction digits (${o})`);const c=parseFloat(i);if(isNaN(c))return null;const a=Math.trunc(Math.round(c*10**t.fractionDigits)),g=String(c).indexOf(".")===-1?0:String(c).length-String(c).indexOf(".")-1;return g>t.fractionDigits?{type:"highPrecision",currencyCode:o,centAmount:a,preciseAmount:parseInt(String(c).replace(".",""),10),fractionDigits:g}:{type:"centPrecision",currencyCode:o,centAmount:a,fractionDigits:t.fractionDigits}},Fi=i=>i.type==="highPrecision"?i.preciseAmount/10**i.fractionDigits:i.centAmount/10**D[i.currencyCode].fractionDigits,j=(i,r)=>Object.prototype.hasOwnProperty.call(i,r);function u(i,r){return i&&r?`${i}.${r}`:void 0}const W=(i,r)=>Ni(typeof i.amount=="string"?i.amount.trim():"",r,i.currencyCode),Ti=(i,r)=>{if(!i)return{currencyCode:"",amount:""};if(console.warn(typeof r=="string","MoneyInput.parseMoneyValue: A locale must be passed as the second argument"),console.warn(typeof i=="object","MoneyInput.parseMoneyValue: Value must be passed as an object or be undefined"),console.warn(typeof i.currencyCode=="string",'MoneyInput.parseMoneyValue: Value must contain "currencyCode"'),typeof i.currencyCode!="string")throw new Error('MoneyInput.parseMoneyValue: Value must contain "currencyCode"');if(console.warn(j(D,i.currencyCode),"MoneyInput.parseMoneyValue: Value must use known currency code"),!j(D,i.currencyCode))throw new Error("MoneyInput.parseMoneyValue: Value must use known currency code");console.warn(typeof i.centAmount=="number"||typeof i.preciseAmount=="number"&&typeof i.fractionDigits=="number",'MoneyInput.parseMoneyValue: Value must contain "amount"');const o=Fi(i),t=i.preciseAmount?i.fractionDigits:D[i.currencyCode].fractionDigits;return{amount:isNaN(o)?"":o.toLocaleString(r,{minimumFractionDigits:t}),currencyCode:i.currencyCode}},Z=i=>!i||i?.amount?.trim()===""||i?.currencyCode?.trim()==="",V=(i,r)=>Z(i)?!1:W(i,r)?.type==="highPrecision",C=L.defineMessages({currencySelectLabel:{id:"Nimbus.MoneyInput.currencySelectLabel",description:"aria-label for currency selection dropdown",defaultMessage:"Currency"},amountInputLabel:{id:"Nimbus.MoneyInput.amountInputLabel",description:"aria-label for amount input",defaultMessage:"Amount"},highPrecisionPrice:{id:"Nimbus.MoneyInput.highPrecisionPrice",description:"tooltip text for high precision price badge",defaultMessage:"High precision price"}}),Y=i=>{const{id:r,name:o,value:t,currencies:c=[],onChange:a,onValueChange:g,onAmountChange:B,onCurrencyChange:N,onFocus:d,onBlur:m,isDisabled:l,isReadOnly:F,isInvalid:q,isRequired:$,hasHighPrecisionBadge:T=!0,isCurrencyInputDisabled:_,placeholder:k="0.00",autoFocus:z,size:I,...J}=i,Q=x.$bdb11010cef70236$export$f680877a34711e37(),P=r??Q,{locale:G}=bi.$18f2051aff69b9bf$export$43bb16f9c6d9e3f7(),R=L.useIntl(),ii=t.amount?parseFloat(t.amount):void 0,ti=!c||c.length===0,v=V(t,G||"en"),ni=s.useMemo(()=>t.currencyCode?{minimumFractionDigits:D[t.currencyCode].fractionDigits,maximumFractionDigits:20,useGrouping:!0,style:"decimal"}:{},[t.currencyCode,G]),ri=U.useSlotRecipe({recipe:H}),[oi,ei]=ri.splitVariantProps({...J,size:I}),[ci,si]=mi.extractStyleProps(ei),y=u(P,"amount"),h=u(P,"currencyCode"),b=u(o,"amount"),S=u(o,"currencyCode"),ai=s.useCallback(n=>{const M=n.toString();a?.({target:{id:y,name:b,value:M}});const pi={...t,amount:M};g?.(pi),B?.(M)},[a,g,B,t,P,o]),gi=s.useCallback(()=>{const n={target:{id:y,name:b,value:t.amount}};d?.(n)},[d,t.amount,r,o]),fi=s.useCallback(()=>{const n={target:{id:y,name:b,value:t.amount}};m?.(n)},[m,t,r,o]),O=s.useCallback(n=>{a?.({target:{id:h,name:S,value:n}});const w={...t,currencyCode:n};g?.(w),N?.(n)},[a,g,N,t,r,o]),ui=s.useCallback(()=>{const n={target:{id:h,name:S,value:t.currencyCode}};d?.(n)},[d,t.currencyCode,r,o]),Di=s.useCallback(()=>{const n={target:{id:h,name:S,value:t.currencyCode}};m?.(n)},[m,t.currencyCode,r,o]),li=s.useCallback(n=>{n&&typeof n=="string"&&O(n)},[O]),K=x.$bdb11010cef70236$export$f680877a34711e37(),E=x.$bdb11010cef70236$export$f680877a34711e37();return e.jsxs(Pi,{...oi,...ci,...si,children:[e.jsxs(Ri,{children:[e.jsx(xi,{children:ti?e.jsx(Ai,{...l&&{"data-disabled":l},asChild:!0,children:e.jsx("label",{id:K,children:t.currencyCode})}):e.jsx(A.Select.Root,{id:h,name:S,selectedKey:t.currencyCode||null,onSelectionChange:li,onFocus:ui,onBlur:Di,isDisabled:_||l||F,isClearable:!1,placeholder:"","aria-label":R.formatMessage(C.currencySelectLabel),size:I,children:e.jsx(A.Select.Options,{children:c.map(n=>e.jsx(A.Select.Option,{id:n,children:n},n))})})}),e.jsx(Li,{"data-has-high-precision":T&&v,asChild:!0,children:e.jsx(Si.NumberInput,{id:y,name:b,value:ii,formatOptions:ni,onChange:ai,onFocus:gi,onBlur:fi,isDisabled:l,isReadOnly:F,isInvalid:q,isRequired:$,placeholder:k,autoFocus:z,size:I,"aria-label":R.formatMessage(C.amountInputLabel),"aria-labelledby":K,"aria-describedby":E,step:void 0})})]}),T&&v&&e.jsx(Bi,{children:e.jsxs(X.Tooltip.Root,{delay:0,closeDelay:0,children:[e.jsx(Mi.MakeElementFocusable,{children:e.jsx(Ci.Box,{as:di.HighPrecision,id:E,color:l?"neutral.8":"neutral.11","aria-label":R.formatMessage(C.highPrecisionPrice),transform:"translateX(-100px) translateY(2px)"})}),e.jsx(X.Tooltip.Content,{placement:"top",children:e.jsx(L.FormattedMessage,{...C.highPrecisionPrice})})]})})]})};Y.displayName="MoneyInput";const f=Y;f.getAmountInputId=i=>u(i,"amount");f.getCurrencyDropdownId=i=>u(i,"currencyCode");f.convertToMoneyValue=W;f.parseMoneyValue=Ti;f.isEmpty=Z;f.isHighPrecision=V;exports.MoneyInput=f;
|
|
2
|
-
//# sourceMappingURL=money-input-
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),s=require("react"),U=require("@chakra-ui/react/styled-system"),L=require("react-intl"),di=require("@commercetools/nimbus-icons"),mi=require("./extractStyleProps-G58aSXl8.cjs.js"),yi=require("@chakra-ui/react"),hi=require("./group-NazPMAWg.cjs.js"),x=require("./mergeProps-BA5Cwf5w.cjs.js"),bi=require("./context-OoV8SSWX.cjs.js"),A=require("./select-97-5UUPX.cjs.js"),Si=require("./number-input-DA_yy5BZ.cjs.js"),Mi=require("./make-element-focusable-oedzOY_M.cjs.js"),X=require("./tooltip-CH2ASPPO.cjs.js"),Ci=require("./box-CWni3A32.cjs.js"),D={ADP:{fractionDigits:0},AED:{fractionDigits:2},AFA:{fractionDigits:2},AFN:{fractionDigits:2},ALL:{fractionDigits:2},AMD:{fractionDigits:2},ANG:{fractionDigits:2},AOA:{fractionDigits:2},ARS:{fractionDigits:2},ATS:{fractionDigits:2},AUD:{fractionDigits:2},AWG:{fractionDigits:2},AYM:{fractionDigits:2},AZM:{fractionDigits:2},AZN:{fractionDigits:2},BAM:{fractionDigits:2},BBD:{fractionDigits:2},BDT:{fractionDigits:2},BEF:{fractionDigits:0},BGL:{fractionDigits:2},BGN:{fractionDigits:2},BHD:{fractionDigits:3},BIF:{fractionDigits:0},BMD:{fractionDigits:2},BND:{fractionDigits:2},BOB:{fractionDigits:2},BOV:{fractionDigits:2},BRL:{fractionDigits:2},BSD:{fractionDigits:2},BTN:{fractionDigits:2},BWP:{fractionDigits:2},BYB:{fractionDigits:0},BYN:{fractionDigits:2},BYR:{fractionDigits:0},BZD:{fractionDigits:2},CAD:{fractionDigits:2},CDF:{fractionDigits:2},CHF:{fractionDigits:2},CLF:{fractionDigits:0},CLP:{fractionDigits:0},CNY:{fractionDigits:2},COP:{fractionDigits:2},CRC:{fractionDigits:2},CSD:{fractionDigits:2},CUC:{fractionDigits:2},CUP:{fractionDigits:2},CVE:{fractionDigits:2},CYP:{fractionDigits:2},CZK:{fractionDigits:2},DEM:{fractionDigits:2},DJF:{fractionDigits:0},DKK:{fractionDigits:2},DOP:{fractionDigits:2},DZD:{fractionDigits:2},EEK:{fractionDigits:2},EGP:{fractionDigits:2},ERN:{fractionDigits:2},ESP:{fractionDigits:0},ETB:{fractionDigits:2},EUR:{fractionDigits:2},FIM:{fractionDigits:2},FJD:{fractionDigits:2},FKP:{fractionDigits:2},FRF:{fractionDigits:2},GBP:{fractionDigits:2},GEL:{fractionDigits:2},GHC:{fractionDigits:2},GHS:{fractionDigits:2},GIP:{fractionDigits:2},GMD:{fractionDigits:2},GNF:{fractionDigits:0},GRD:{fractionDigits:0},GTQ:{fractionDigits:2},GWP:{fractionDigits:2},GYD:{fractionDigits:2},HKD:{fractionDigits:2},HNL:{fractionDigits:2},HRK:{fractionDigits:2},HTG:{fractionDigits:2},HUF:{fractionDigits:2},IDR:{fractionDigits:2},IEP:{fractionDigits:2},ILS:{fractionDigits:2},INR:{fractionDigits:2},IQD:{fractionDigits:3},IRR:{fractionDigits:2},ISK:{fractionDigits:0},ITL:{fractionDigits:0},JMD:{fractionDigits:2},JOD:{fractionDigits:3},JPY:{fractionDigits:0},KES:{fractionDigits:2},KGS:{fractionDigits:2},KHR:{fractionDigits:2},KMF:{fractionDigits:0},KPW:{fractionDigits:2},KRW:{fractionDigits:0},KWD:{fractionDigits:3},KYD:{fractionDigits:2},KZT:{fractionDigits:2},LAK:{fractionDigits:2},LBP:{fractionDigits:2},LKR:{fractionDigits:2},LRD:{fractionDigits:2},LSL:{fractionDigits:2},LTL:{fractionDigits:2},LUF:{fractionDigits:0},LVL:{fractionDigits:2},LYD:{fractionDigits:3},MAD:{fractionDigits:2},MDL:{fractionDigits:2},MGA:{fractionDigits:2},MGF:{fractionDigits:0},MKD:{fractionDigits:2},MMK:{fractionDigits:2},MNT:{fractionDigits:2},MOP:{fractionDigits:2},MRO:{fractionDigits:2},MTL:{fractionDigits:2},MUR:{fractionDigits:2},MVR:{fractionDigits:2},MWK:{fractionDigits:2},MXN:{fractionDigits:2},MXV:{fractionDigits:2},MYR:{fractionDigits:2},MZM:{fractionDigits:2},MZN:{fractionDigits:2},NAD:{fractionDigits:2},NGN:{fractionDigits:2},NIO:{fractionDigits:2},NLG:{fractionDigits:2},NOK:{fractionDigits:2},NPR:{fractionDigits:2},NZD:{fractionDigits:2},OMR:{fractionDigits:3},PAB:{fractionDigits:2},PEN:{fractionDigits:2},PGK:{fractionDigits:2},PHP:{fractionDigits:2},PKR:{fractionDigits:2},PLN:{fractionDigits:2},PTE:{fractionDigits:0},PYG:{fractionDigits:0},QAR:{fractionDigits:2},ROL:{fractionDigits:2},RON:{fractionDigits:2},RSD:{fractionDigits:2},RUB:{fractionDigits:2},RUR:{fractionDigits:2},RWF:{fractionDigits:0},SAR:{fractionDigits:2},SBD:{fractionDigits:2},SCR:{fractionDigits:2},SDD:{fractionDigits:2},SDG:{fractionDigits:2},SEK:{fractionDigits:2},SGD:{fractionDigits:2},SHP:{fractionDigits:2},SIT:{fractionDigits:2},SKK:{fractionDigits:2},SLL:{fractionDigits:2},SOS:{fractionDigits:2},SRD:{fractionDigits:2},SRG:{fractionDigits:2},SSP:{fractionDigits:2},STD:{fractionDigits:2},SVC:{fractionDigits:2},SYP:{fractionDigits:2},SZL:{fractionDigits:2},THB:{fractionDigits:2},TJS:{fractionDigits:2},TMM:{fractionDigits:2},TMT:{fractionDigits:2},TND:{fractionDigits:3},TOP:{fractionDigits:2},TPE:{fractionDigits:0},TRL:{fractionDigits:0},TRY:{fractionDigits:2},TTD:{fractionDigits:2},TWD:{fractionDigits:2},TZS:{fractionDigits:2},UAH:{fractionDigits:2},UGX:{fractionDigits:0},USD:{fractionDigits:2},USN:{fractionDigits:2},USS:{fractionDigits:2},UYU:{fractionDigits:2},UZS:{fractionDigits:2},VEB:{fractionDigits:2},VEF:{fractionDigits:2},VND:{fractionDigits:0},VUV:{fractionDigits:0},WST:{fractionDigits:2},XAF:{fractionDigits:0},XAG:{fractionDigits:-1},XAU:{fractionDigits:-1},XBA:{fractionDigits:-1},XBB:{fractionDigits:-1},XBC:{fractionDigits:-1},XBD:{fractionDigits:-1},XCD:{fractionDigits:2},XDR:{fractionDigits:-1},XFO:{fractionDigits:-1},XFU:{fractionDigits:-1},XOF:{fractionDigits:0},XPD:{fractionDigits:-1},XPF:{fractionDigits:0},XPT:{fractionDigits:-1},XSU:{fractionDigits:-1},XTS:{fractionDigits:-1},XUA:{fractionDigits:-1},XXX:{fractionDigits:-1},YER:{fractionDigits:2},YUM:{fractionDigits:2},ZAR:{fractionDigits:2},ZMK:{fractionDigits:2},ZMW:{fractionDigits:2},ZWD:{fractionDigits:2},ZWL:{fractionDigits:2},ZWN:{fractionDigits:2},ZWR:{fractionDigits:2}},H=yi.defineSlotRecipe({slots:["root","container","currencySelect","currencyLabel","amountInput","badge"],className:"nimbus-money-input",base:{root:{width:"full",position:"relative",fontFamily:"inherit","& .nimbus-select__trigger":{width:"2800",borderRightRadius:"0",boxShadow:"inset 0 1px 0 0 {colors.neutral.7}, inset 0 -1px 0 0 {colors.neutral.7}, inset 1px 0 0 0 {colors.neutral.7}"},"&:has(.nimbus-money-input__container:focus-within)":{"& .nimbus-money-input__currencyLabel":{outlineWidth:"var(--focus-ring-width)",outlineColor:"var(--focus-ring-color)",outlineStyle:"var(--focus-ring-style)",outlineOffset:"var(--focus-ring-offset)",clipPath:"inset(-4px -1px -4px -4px)"},"& .nimbus-money-input__amountInput":{clipPath:"inset(-4px -4px -4px -1px)"}}},container:{display:"inline-flex",alignItems:"stretch",position:"relative"},currencySelect:{_focusWithin:{zIndex:2}},currencyLabel:{color:"neutral.11",fontWeight:"500",display:"flex",height:"full",borderLeftRadius:"200",backgroundColor:"neutral.1",boxShadow:"inset 0 1px 0 0 {colors.neutral.7}, inset 0 -1px 0 0 {colors.neutral.7}, inset 1px 0 0 0 {colors.neutral.7}",paddingInline:"400",alignItems:"center","&[data-disabled='true']":{opacity:"0.5"}},amountInput:{borderLeftRadius:"0",_focusWithin:{zIndex:2}},badge:{position:"absolute",top:"0",right:"0",height:"full",display:"flex",alignItems:"center",justifyContent:"center",marginRight:"spacing.25"}},variants:{size:{sm:{root:{fontSize:"fontSize.20","& .nimbus-select__trigger":{width:"2600"}},currencySelect:{padding:"0 spacing.20"},amountInput:{paddingRight:"spacing.30"},currencyLabel:{fontSize:"300",lineHeight:"450"}},md:{root:{fontSize:"fontSize.30","& .nimbus-select__trigger":{width:"2800"}},currencySelect:{padding:"0 spacing.25"},amountInput:{paddingRight:"spacing.40"},currencyLabel:{fontSize:"350",lineHeight:"500"}}}},defaultVariants:{size:"md"}}),{withProvider:Ii,withContext:p}=U.createSlotRecipeContext({recipe:H}),Pi=Ii(hi.Group,"root"),Ri=p("div","container"),xi=p("div","currencySelect"),Ai=p("label","currencyLabel"),Li=p("input","amountInput"),Bi=p("div","badge"),Ni=(i,r,o)=>{if(!o)return null;const t=D[o];if(!t||i.length===0||i.trim()==="")return null;!r&&t.fractionDigits===0&&console.warn(`MoneyInput: A locale must be provided when currency has no fraction digits (${o})`);const c=parseFloat(i);if(isNaN(c))return null;const a=Math.trunc(Math.round(c*10**t.fractionDigits)),g=String(c).indexOf(".")===-1?0:String(c).length-String(c).indexOf(".")-1;return g>t.fractionDigits?{type:"highPrecision",currencyCode:o,centAmount:a,preciseAmount:parseInt(String(c).replace(".",""),10),fractionDigits:g}:{type:"centPrecision",currencyCode:o,centAmount:a,fractionDigits:t.fractionDigits}},Fi=i=>i.type==="highPrecision"?i.preciseAmount/10**i.fractionDigits:i.centAmount/10**D[i.currencyCode].fractionDigits,j=(i,r)=>Object.prototype.hasOwnProperty.call(i,r);function u(i,r){return i&&r?`${i}.${r}`:void 0}const W=(i,r)=>Ni(typeof i.amount=="string"?i.amount.trim():"",r,i.currencyCode),Ti=(i,r)=>{if(!i)return{currencyCode:"",amount:""};if(console.warn(typeof r=="string","MoneyInput.parseMoneyValue: A locale must be passed as the second argument"),console.warn(typeof i=="object","MoneyInput.parseMoneyValue: Value must be passed as an object or be undefined"),console.warn(typeof i.currencyCode=="string",'MoneyInput.parseMoneyValue: Value must contain "currencyCode"'),typeof i.currencyCode!="string")throw new Error('MoneyInput.parseMoneyValue: Value must contain "currencyCode"');if(console.warn(j(D,i.currencyCode),"MoneyInput.parseMoneyValue: Value must use known currency code"),!j(D,i.currencyCode))throw new Error("MoneyInput.parseMoneyValue: Value must use known currency code");console.warn(typeof i.centAmount=="number"||typeof i.preciseAmount=="number"&&typeof i.fractionDigits=="number",'MoneyInput.parseMoneyValue: Value must contain "amount"');const o=Fi(i),t=i.preciseAmount?i.fractionDigits:D[i.currencyCode].fractionDigits;return{amount:isNaN(o)?"":o.toLocaleString(r,{minimumFractionDigits:t}),currencyCode:i.currencyCode}},Z=i=>!i||i?.amount?.trim()===""||i?.currencyCode?.trim()==="",V=(i,r)=>Z(i)?!1:W(i,r)?.type==="highPrecision",C=L.defineMessages({currencySelectLabel:{id:"Nimbus.MoneyInput.currencySelectLabel",description:"aria-label for currency selection dropdown",defaultMessage:"Currency"},amountInputLabel:{id:"Nimbus.MoneyInput.amountInputLabel",description:"aria-label for amount input",defaultMessage:"Amount"},highPrecisionPrice:{id:"Nimbus.MoneyInput.highPrecisionPrice",description:"tooltip text for high precision price badge",defaultMessage:"High precision price"}}),Y=i=>{const{id:r,name:o,value:t,currencies:c=[],onChange:a,onValueChange:g,onAmountChange:B,onCurrencyChange:N,onFocus:d,onBlur:m,isDisabled:l,isReadOnly:F,isInvalid:q,isRequired:$,hasHighPrecisionBadge:T=!0,isCurrencyInputDisabled:_,placeholder:k="0.00",autoFocus:z,size:I,...J}=i,Q=x.$bdb11010cef70236$export$f680877a34711e37(),P=r??Q,{locale:G}=bi.$18f2051aff69b9bf$export$43bb16f9c6d9e3f7(),R=L.useIntl(),ii=t.amount?parseFloat(t.amount):void 0,ti=!c||c.length===0,v=V(t,G||"en"),ni=s.useMemo(()=>t.currencyCode?{minimumFractionDigits:D[t.currencyCode].fractionDigits,maximumFractionDigits:20,useGrouping:!0,style:"decimal"}:{},[t.currencyCode,G]),ri=U.useSlotRecipe({recipe:H}),[oi,ei]=ri.splitVariantProps({...J,size:I}),[ci,si]=mi.extractStyleProps(ei),y=u(P,"amount"),h=u(P,"currencyCode"),b=u(o,"amount"),S=u(o,"currencyCode"),ai=s.useCallback(n=>{const M=n.toString();a?.({target:{id:y,name:b,value:M}});const pi={...t,amount:M};g?.(pi),B?.(M)},[a,g,B,t,P,o]),gi=s.useCallback(()=>{const n={target:{id:y,name:b,value:t.amount}};d?.(n)},[d,t.amount,r,o]),fi=s.useCallback(()=>{const n={target:{id:y,name:b,value:t.amount}};m?.(n)},[m,t,r,o]),O=s.useCallback(n=>{a?.({target:{id:h,name:S,value:n}});const w={...t,currencyCode:n};g?.(w),N?.(n)},[a,g,N,t,r,o]),ui=s.useCallback(()=>{const n={target:{id:h,name:S,value:t.currencyCode}};d?.(n)},[d,t.currencyCode,r,o]),Di=s.useCallback(()=>{const n={target:{id:h,name:S,value:t.currencyCode}};m?.(n)},[m,t.currencyCode,r,o]),li=s.useCallback(n=>{n&&typeof n=="string"&&O(n)},[O]),K=x.$bdb11010cef70236$export$f680877a34711e37(),E=x.$bdb11010cef70236$export$f680877a34711e37();return e.jsxs(Pi,{...oi,...ci,...si,children:[e.jsxs(Ri,{children:[e.jsx(xi,{children:ti?e.jsx(Ai,{...l&&{"data-disabled":l},asChild:!0,children:e.jsx("label",{id:K,children:t.currencyCode})}):e.jsx(A.Select.Root,{id:h,name:S,selectedKey:t.currencyCode||null,onSelectionChange:li,onFocus:ui,onBlur:Di,isDisabled:_||l||F,isClearable:!1,placeholder:"","aria-label":R.formatMessage(C.currencySelectLabel),size:I,children:e.jsx(A.Select.Options,{children:c.map(n=>e.jsx(A.Select.Option,{id:n,children:n},n))})})}),e.jsx(Li,{"data-has-high-precision":T&&v,asChild:!0,children:e.jsx(Si.NumberInput,{id:y,name:b,value:ii,formatOptions:ni,onChange:ai,onFocus:gi,onBlur:fi,isDisabled:l,isReadOnly:F,isInvalid:q,isRequired:$,placeholder:k,autoFocus:z,size:I,"aria-label":R.formatMessage(C.amountInputLabel),"aria-labelledby":K,"aria-describedby":E,step:void 0})})]}),T&&v&&e.jsx(Bi,{children:e.jsxs(X.Tooltip.Root,{delay:0,closeDelay:0,children:[e.jsx(Mi.MakeElementFocusable,{children:e.jsx(Ci.Box,{as:di.HighPrecision,id:E,color:l?"neutral.8":"neutral.11","aria-label":R.formatMessage(C.highPrecisionPrice),transform:"translateX(-100px) translateY(2px)"})}),e.jsx(X.Tooltip.Content,{placement:"top",children:e.jsx(L.FormattedMessage,{...C.highPrecisionPrice})})]})})]})};Y.displayName="MoneyInput";const f=Y;f.getAmountInputId=i=>u(i,"amount");f.getCurrencyDropdownId=i=>u(i,"currencyCode");f.convertToMoneyValue=W;f.parseMoneyValue=Ti;f.isEmpty=Z;f.isHighPrecision=V;exports.MoneyInput=f;
|
|
2
|
+
//# sourceMappingURL=money-input-CwrbJsn1.cjs.js.map
|