@transferwise/components 46.160.4 → 46.160.6

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.
Files changed (106) hide show
  1. package/build/ExpressiveMoneyInput/AmountInput/AmountInput.js +2 -0
  2. package/build/ExpressiveMoneyInput/AmountInput/AmountInput.js.map +1 -1
  3. package/build/ExpressiveMoneyInput/AmountInput/AmountInput.mjs +2 -0
  4. package/build/ExpressiveMoneyInput/AmountInput/AmountInput.mjs.map +1 -1
  5. package/build/ExpressiveMoneyInput/hooks/useInputStyle.js +1 -1
  6. package/build/ExpressiveMoneyInput/hooks/useInputStyle.js.map +1 -1
  7. package/build/ExpressiveMoneyInput/hooks/useInputStyle.mjs +1 -1
  8. package/build/ExpressiveMoneyInput/hooks/useInputStyle.mjs.map +1 -1
  9. package/build/Inputs/Input/Input.js +1 -0
  10. package/build/Inputs/Input/Input.js.map +1 -1
  11. package/build/Inputs/Input/Input.mjs +1 -0
  12. package/build/Inputs/Input/Input.mjs.map +1 -1
  13. package/build/Inputs/TextArea/TextArea.js +1 -0
  14. package/build/Inputs/TextArea/TextArea.js.map +1 -1
  15. package/build/Inputs/TextArea/TextArea.mjs +1 -0
  16. package/build/Inputs/TextArea/TextArea.mjs.map +1 -1
  17. package/build/MoneyInput/MoneyInput.js +1 -0
  18. package/build/MoneyInput/MoneyInput.js.map +1 -1
  19. package/build/MoneyInput/MoneyInput.mjs +1 -0
  20. package/build/MoneyInput/MoneyInput.mjs.map +1 -1
  21. package/build/PhoneNumberInput/PhoneNumberInput.js +3 -2
  22. package/build/PhoneNumberInput/PhoneNumberInput.js.map +1 -1
  23. package/build/PhoneNumberInput/PhoneNumberInput.messages.js +3 -0
  24. package/build/PhoneNumberInput/PhoneNumberInput.messages.js.map +1 -1
  25. package/build/PhoneNumberInput/PhoneNumberInput.messages.mjs +3 -0
  26. package/build/PhoneNumberInput/PhoneNumberInput.messages.mjs.map +1 -1
  27. package/build/PhoneNumberInput/PhoneNumberInput.mjs +3 -2
  28. package/build/PhoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  29. package/build/Typeahead/TypeaheadInput/TypeaheadInput.js +50 -20
  30. package/build/Typeahead/TypeaheadInput/TypeaheadInput.js.map +1 -1
  31. package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs +50 -20
  32. package/build/Typeahead/TypeaheadInput/TypeaheadInput.mjs.map +1 -1
  33. package/build/i18n/en.json +1 -0
  34. package/build/i18n/en.json.js +1 -0
  35. package/build/i18n/en.json.js.map +1 -1
  36. package/build/i18n/en.json.mjs +1 -0
  37. package/build/i18n/en.json.mjs.map +1 -1
  38. package/build/main.css +69 -1
  39. package/build/styles/ExpressiveMoneyInput/AmountInput/AmountInput.css +6 -0
  40. package/build/styles/ExpressiveMoneyInput/ExpressiveMoneyInput.css +6 -0
  41. package/build/styles/Inputs/Input/Input.css +19 -0
  42. package/build/styles/Inputs/TextArea/TextArea.css +16 -1
  43. package/build/styles/MoneyInput/MoneyInput.css +3 -0
  44. package/build/styles/PhoneNumberInput/PhoneNumberInput.css +7 -0
  45. package/build/styles/PocketSurface/PocketSurface.css +1 -0
  46. package/build/styles/SentimentSurface/SentimentSurface.css +5 -0
  47. package/build/styles/css/neptune.css +11 -0
  48. package/build/styles/main.css +69 -1
  49. package/build/styles/styles/less/neptune.css +11 -0
  50. package/build/types/ExpressiveMoneyInput/AmountInput/AmountInput.d.ts.map +1 -1
  51. package/build/types/ExpressiveMoneyInput/hooks/useInputStyle.d.ts.map +1 -1
  52. package/build/types/Inputs/Input/Input.d.ts.map +1 -1
  53. package/build/types/Inputs/TextArea/TextArea.d.ts.map +1 -1
  54. package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
  55. package/build/types/PhoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  56. package/build/types/PhoneNumberInput/PhoneNumberInput.messages.d.ts +5 -0
  57. package/build/types/PhoneNumberInput/PhoneNumberInput.messages.d.ts.map +1 -1
  58. package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts +1 -1
  59. package/build/types/Typeahead/TypeaheadInput/TypeaheadInput.d.ts.map +1 -1
  60. package/build/types/test-utils/index.d.ts +2 -0
  61. package/build/types/test-utils/index.d.ts.map +1 -1
  62. package/package.json +14 -14
  63. package/src/ExpressiveMoneyInput/AmountInput/AmountInput.css +6 -0
  64. package/src/ExpressiveMoneyInput/AmountInput/AmountInput.less +7 -0
  65. package/src/ExpressiveMoneyInput/AmountInput/AmountInput.tsx +2 -1
  66. package/src/ExpressiveMoneyInput/ExpressiveMoneyInput.css +6 -0
  67. package/src/ExpressiveMoneyInput/hooks/useInputStyle.ts +1 -2
  68. package/src/Field/_stories/Field.test.story.tsx +27 -0
  69. package/src/Inputs/Input/Input.css +19 -0
  70. package/src/Inputs/Input/Input.less +16 -0
  71. package/src/Inputs/Input/Input.tsx +1 -0
  72. package/src/Inputs/{_stories → InputGroup/_stories}/InputGroup.story.tsx +9 -9
  73. package/src/Inputs/InputGroup/_stories/InputGroup.test.story.tsx +80 -0
  74. package/src/Inputs/{_stories → SearchInput/_stories}/SearchInput.story.tsx +4 -4
  75. package/src/Inputs/SearchInput/_stories/SearchInput.test.story.tsx +38 -0
  76. package/src/Inputs/SelectInput/_stories/SelectInput.rtl.test.story.tsx +31 -19
  77. package/src/Inputs/TextArea/TextArea.css +16 -1
  78. package/src/Inputs/TextArea/TextArea.less +6 -1
  79. package/src/Inputs/TextArea/TextArea.tsx +1 -0
  80. package/src/Inputs/{_stories → TextArea/_stories}/TextArea.story.tsx +4 -4
  81. package/src/Inputs/{_stories → TextArea/_stories}/TextArea.test.story.tsx +50 -26
  82. package/src/MoneyInput/MoneyInput.css +3 -0
  83. package/src/MoneyInput/MoneyInput.less +6 -0
  84. package/src/MoneyInput/MoneyInput.tsx +1 -0
  85. package/src/MoneyInput/_stories/MoneyInput.rtl.test.story.tsx +14 -10
  86. package/src/PhoneNumberInput/PhoneNumberInput.css +7 -0
  87. package/src/PhoneNumberInput/PhoneNumberInput.less +13 -0
  88. package/src/PhoneNumberInput/PhoneNumberInput.messages.ts +5 -0
  89. package/src/PhoneNumberInput/PhoneNumberInput.tsx +3 -2
  90. package/src/PhoneNumberInput/_stories/PhoneNumberInput.rtl.test.story.tsx +15 -7
  91. package/src/PocketSurface/PocketSurface.css +1 -0
  92. package/src/Prompt/ActionPrompt/_stories/ActionPrompt.story.tsx +5 -1
  93. package/src/Prompt/InfoPrompt/_stories/InfoPrompt.story.tsx +12 -9
  94. package/src/Prompt/InlinePrompt/_stories/InlinePrompt.story.tsx +5 -5
  95. package/src/Prompt/PrimitivePrompt/PrimitivePrompt.less +2 -1
  96. package/src/SentimentSurface/SentimentSurface.css +5 -0
  97. package/src/SentimentSurface/SentimentSurface.less +5 -0
  98. package/src/SentimentSurface/_stories/SentimentSurface.story.tsx +6 -2
  99. package/src/TextareaWithDisplayFormat/_stories/TextareaWithDisplayFormat.test.story.tsx +49 -34
  100. package/src/Typeahead/TypeaheadInput/TypeaheadInput.tsx +31 -20
  101. package/src/Typeahead/_stories/Typeahead.rtl.test.story.tsx +90 -57
  102. package/src/_deprecated/Select/_stories/Select.rtl.test.story.tsx +8 -1
  103. package/src/main.css +69 -1
  104. package/src/styles/less/neptune.css +11 -0
  105. package/src/Inputs/_stories/InputGroup.test.story.tsx +0 -69
  106. package/src/Inputs/_stories/SearchInput.test.story.tsx +0 -32
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNumberInput.mjs","sources":["../../src/PhoneNumberInput/PhoneNumberInput.tsx"],"sourcesContent":["import { useState, useEffect, useMemo, useRef } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport { Size, SizeLarge, SizeMedium, SizeSmall } from '../common';\nimport { useFieldLabelRef, useInputAttributes } from '../Inputs/contexts';\nimport { useInputPaddings } from '../Inputs/InputGroup/InputGroup';\nimport { SelectInput, SelectInputOptionContent, SelectInputProps } from '../Inputs/SelectInput';\nimport messages from './PhoneNumberInput.messages';\nimport countries from './Data/countries';\nimport {\n explodeNumberModel,\n isValidPhoneNumber,\n cleanNumber,\n setDefaultPrefix,\n sortArrayByProperty,\n groupCountriesByPrefix,\n excludeCountries,\n findCountryByPrefix,\n} from './utils';\nimport { PhoneNumber } from './utils/explodeNumberModel';\nimport { Input } from '../Inputs/Input/Input';\n\nconst ALLOWED_PHONE_CHARS = /^$|^[\\d-\\s]+$/;\n\nexport interface PhoneNumberInputProps {\n id?: string;\n 'aria-labelledby'?: string;\n required?: boolean;\n disabled?: boolean;\n initialValue?: string;\n onChange: (value: string | null, prefix: string) => void;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: () => void;\n countryCode?: string;\n /** @default 'Prefix' */\n searchPlaceholder?: string;\n /** @default 'md' */\n size?: SizeSmall | SizeMedium | SizeLarge;\n placeholder?: string;\n /** @default {} */\n selectProps?: Partial<SelectInputProps<string | null>>;\n /**\n * List of iso3 codes of countries to remove from the list\n * @default []\n */\n disabledCountries?: readonly string[];\n}\n\nconst defaultSelectProps = {} satisfies PhoneNumberInputProps['selectProps'];\nconst defaultDisabledCountries = [] satisfies PhoneNumberInputProps['disabledCountries'];\n\nconst PhoneNumberInput = ({\n id,\n 'aria-labelledby': ariaLabelledByProp,\n required,\n disabled,\n initialValue,\n onChange,\n onFocus,\n onBlur,\n countryCode,\n searchPlaceholder = 'Prefix',\n size = Size.MEDIUM,\n placeholder,\n selectProps = defaultSelectProps,\n disabledCountries = defaultDisabledCountries,\n}: PhoneNumberInputProps) => {\n const countryCodeSelectRef = useRef<HTMLButtonElement>(null);\n const phoneNumberInputRef = useRef<HTMLInputElement>(null);\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const { paddingInlineStart } = useInputPaddings();\n const hasInputGroupAddonStart = paddingInlineStart != null;\n const fieldLabelRef = useFieldLabelRef();\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];\n\n const { locale, formatMessage } = useIntl();\n\n const [randomId] = useState(() => Math.random().toString(36).slice(2, 8));\n\n const createId = (customID: string | undefined, backup: string): string => {\n if (customID) {\n return customID + (backup ? `-${backup}` : '');\n }\n return `${backup}-${randomId}`;\n };\n\n // Link the first non-disabled input to the the Field label, if present\n const ids = {\n countryCode: {\n label: createId(id, 'country-code-label'),\n select: createId(id, 'country-code-select'),\n },\n phoneNumber: {\n label: createId(id, 'phone-number-label'),\n input: createId(id, id ? '' : 'phone-number-input'),\n },\n };\n\n const [internalValue, setInternalValue] = useState<PhoneNumber>(() => {\n const cleanValue = initialValue ? cleanNumber(initialValue) : null;\n\n if (!cleanValue || !isValidPhoneNumber(cleanValue, 1)) {\n return {\n prefix: setDefaultPrefix(locale, countryCode),\n suffix: '',\n };\n }\n\n return explodeNumberModel(cleanValue);\n });\n const broadcastedValueRef = useRef<PhoneNumber>(internalValue);\n\n const [suffixDirty, setSuffixDirty] = useState(false);\n\n useEffect(() => {\n if (!suffixDirty && internalValue.suffix) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- Tracking when suffix becomes dirty\n setSuffixDirty(true);\n }\n }, [internalValue.suffix, suffixDirty]);\n\n const countriesByPrefix = useMemo(\n () =>\n groupCountriesByPrefix(\n sortArrayByProperty(excludeCountries(countries, disabledCountries), 'iso3'),\n ),\n [disabledCountries],\n );\n\n const onSuffixChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const suffix = event.target.value;\n if (ALLOWED_PHONE_CHARS.test(suffix)) {\n setInternalValue((prev) => ({ ...prev, suffix }));\n }\n };\n\n const onPaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n if (!event.nativeEvent.clipboardData) {\n return;\n }\n\n const pastedValue = (event.nativeEvent.clipboardData.getData('text/plain') || '').replace(\n /(\\s|-)+/g,\n '',\n );\n const pastedNumber = explodeNumberModel(pastedValue);\n\n if (\n pastedNumber.prefix != null &&\n countriesByPrefix.has(pastedNumber.prefix) &&\n ALLOWED_PHONE_CHARS.test(pastedNumber.suffix)\n ) {\n setInternalValue(pastedNumber);\n }\n };\n\n useEffect(() => {\n const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;\n const broadcastedPhoneNumber = `${broadcastedValueRef.current.prefix ?? ''}${broadcastedValueRef.current.suffix}`;\n\n if (internalPhoneNumber === broadcastedPhoneNumber) {\n return;\n }\n\n const newValue = isValidPhoneNumber(internalPhoneNumber)\n ? cleanNumber(internalPhoneNumber)\n : null;\n\n onChange(\n newValue,\n internalValue.prefix ?? '', // TODO: Allow `null` in public API\n );\n broadcastedValueRef.current = internalValue;\n }, [onChange, internalValue]);\n\n useEffect(() => {\n const labelRef = fieldLabelRef?.current;\n\n if (labelRef) {\n const handleLabelClick = () => {\n if (!selectProps.disabled) {\n countryCodeSelectRef.current?.click();\n } else {\n phoneNumberInputRef.current?.focus();\n }\n };\n\n labelRef.addEventListener('click', handleLabelClick);\n\n return () => {\n labelRef?.removeEventListener('click', handleLabelClick);\n };\n }\n }, [fieldLabelRef, selectProps.disabled]);\n\n return (\n <fieldset {...inputAttributes} aria-labelledby={ariaLabelledBy} className=\"tw-telephone\">\n <label className=\"sr-only\" id={ids.countryCode.label} htmlFor={ids.countryCode.select}>\n {formatMessage(messages.countryCodeLabel)}\n </label>\n <div\n className={`tw-telephone__country-select${\n hasInputGroupAddonStart\n ? ' tw-telephone__country-select--with-input-group-addon-start'\n : ''\n }`}\n >\n <SelectInput\n triggerRef={countryCodeSelectRef}\n placeholder={formatMessage(messages.selectInputPlaceholder)}\n items={[...countriesByPrefix].map(([prefix, countries]) => ({\n type: 'option',\n value: prefix,\n filterMatchers: [\n prefix,\n ...countries.map((country) => country.name),\n ...countries.map((country) => country.iso3),\n ],\n }))}\n value={internalValue.prefix}\n renderValue={(prefix, withinTrigger) => (\n <SelectInputOptionContent\n title={prefix}\n note={\n withinTrigger\n ? undefined\n : countriesByPrefix\n .get(prefix)\n ?.map((country) => country.iso3)\n .join(', ')\n }\n />\n )}\n filterable\n filterPlaceholder={searchPlaceholder}\n disabled={disabled}\n size={size}\n id={ids.countryCode.select}\n UNSAFE_triggerButtonProps={{\n id: ids.countryCode.select,\n 'aria-labelledby': ids.countryCode.label,\n 'aria-describedby': undefined,\n 'aria-invalid': undefined,\n }}\n onChange={(prefix) => {\n const country = prefix != null ? findCountryByPrefix(prefix) : null;\n setInternalValue((prev) => ({ ...prev, prefix, format: country?.phoneFormat }));\n }}\n onClose={() => {\n if (suffixDirty) {\n onBlur?.();\n }\n }}\n {...selectProps}\n />\n </div>\n <label className=\"sr-only\" id={ids.phoneNumber.label} htmlFor={ids.phoneNumber.input}>\n {formatMessage(messages.phoneNumberLabel)}\n </label>\n <div className=\"tw-telephone__number-input\">\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={phoneNumberInputRef}\n id={ids.phoneNumber.input}\n autoComplete=\"tel-national\"\n name=\"phoneNumber\"\n inputMode=\"numeric\"\n value={internalValue.suffix}\n disabled={disabled}\n required={required}\n placeholder={placeholder}\n aria-labelledby={ids.phoneNumber.label}\n onChange={onSuffixChange}\n onPaste={onPaste}\n onFocus={onFocus}\n onBlur={() => onBlur?.()}\n />\n </div>\n </div>\n </fieldset>\n );\n};\n\nexport default PhoneNumberInput;\n"],"names":["ALLOWED_PHONE_CHARS","defaultSelectProps","defaultDisabledCountries","PhoneNumberInput","id","ariaLabelledByProp","required","disabled","initialValue","onChange","onFocus","onBlur","countryCode","searchPlaceholder","size","Size","MEDIUM","placeholder","selectProps","disabledCountries","countryCodeSelectRef","useRef","phoneNumberInputRef","inputAttributes","useInputAttributes","nonLabelable","paddingInlineStart","useInputPaddings","hasInputGroupAddonStart","fieldLabelRef","useFieldLabelRef","ariaLabelledBy","locale","formatMessage","useIntl","randomId","useState","Math","random","toString","slice","createId","customID","backup","ids","label","select","phoneNumber","input","internalValue","setInternalValue","cleanValue","cleanNumber","isValidPhoneNumber","prefix","setDefaultPrefix","suffix","explodeNumberModel","broadcastedValueRef","suffixDirty","setSuffixDirty","useEffect","countriesByPrefix","useMemo","groupCountriesByPrefix","sortArrayByProperty","excludeCountries","countries","onSuffixChange","event","target","value","test","prev","onPaste","nativeEvent","clipboardData","pastedValue","getData","replace","pastedNumber","has","internalPhoneNumber","broadcastedPhoneNumber","current","newValue","labelRef","handleLabelClick","click","focus","addEventListener","removeEventListener","_jsxs","className","children","_jsx","htmlFor","messages","countryCodeLabel","SelectInput","triggerRef","selectInputPlaceholder","items","map","type","filterMatchers","country","name","iso3","renderValue","withinTrigger","SelectInputOptionContent","title","note","undefined","get","join","filterable","filterPlaceholder","UNSAFE_triggerButtonProps","findCountryByPrefix","format","phoneFormat","onClose","phoneNumberLabel","Input","ref","autoComplete","inputMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAMA,mBAAmB,GAAG,eAAe;AA0B3C,MAAMC,kBAAkB,GAAG,EAAiD;AAC5E,MAAMC,wBAAwB,GAAG,EAAuD;AAExF,MAAMC,gBAAgB,GAAGA,CAAC;EACxBC,EAAE;AACF,EAAA,iBAAiB,EAAEC,kBAAkB;EACrCC,QAAQ;EACRC,QAAQ;EACRC,YAAY;EACZC,QAAQ;EACRC,OAAO;EACPC,MAAM;EACNC,WAAW;AACXC,EAAAA,iBAAiB,GAAG,QAAQ;EAC5BC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,WAAW;AACXC,EAAAA,WAAW,GAAGjB,kBAAkB;AAChCkB,EAAAA,iBAAiB,GAAGjB;AAAwB,CACtB,KAAI;AAC1B,EAAA,MAAMkB,oBAAoB,GAAGC,MAAM,CAAoB,IAAI,CAAC;AAC5D,EAAA,MAAMC,mBAAmB,GAAGD,MAAM,CAAmB,IAAI,CAAC;EAC1D,MAAME,eAAe,GAAGC,kBAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAI,GAAE,CAAC;EAClE,MAAM;AAAEC,IAAAA;GAAoB,GAAGC,gBAAgB,EAAE;AACjD,EAAA,MAAMC,uBAAuB,GAAGF,kBAAkB,IAAI,IAAI;AAC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ACzBM,UAAAA,OAAO,EAAEA,OAAQ;AACjBhE,UAAAA,OAAO,EAAEA,OAAQ;AACjBC,UAAAA,MAAM,EAAEA,MAAMA,MAAM;SAAK;OAExB;AACP,KAAK,CACP;AAAA,GAAU,CAAC;AAEf;;;;"}
1
+ {"version":3,"file":"PhoneNumberInput.mjs","sources":["../../src/PhoneNumberInput/PhoneNumberInput.tsx"],"sourcesContent":["import { useState, useEffect, useMemo, useRef } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport { Size, SizeLarge, SizeMedium, SizeSmall } from '../common';\nimport { useFieldLabelRef, useInputAttributes } from '../Inputs/contexts';\nimport { useInputPaddings } from '../Inputs/InputGroup/InputGroup';\nimport { SelectInput, SelectInputOptionContent, SelectInputProps } from '../Inputs/SelectInput';\nimport messages from './PhoneNumberInput.messages';\nimport countries from './Data/countries';\nimport {\n explodeNumberModel,\n isValidPhoneNumber,\n cleanNumber,\n setDefaultPrefix,\n sortArrayByProperty,\n groupCountriesByPrefix,\n excludeCountries,\n findCountryByPrefix,\n} from './utils';\nimport { PhoneNumber } from './utils/explodeNumberModel';\nimport { Input } from '../Inputs/Input/Input';\n\nconst ALLOWED_PHONE_CHARS = /^$|^[\\d-\\s]+$/;\n\nexport interface PhoneNumberInputProps {\n id?: string;\n 'aria-labelledby'?: string;\n required?: boolean;\n disabled?: boolean;\n initialValue?: string;\n onChange: (value: string | null, prefix: string) => void;\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n onBlur?: () => void;\n countryCode?: string;\n /** @default 'Prefix' */\n searchPlaceholder?: string;\n /** @default 'md' */\n size?: SizeSmall | SizeMedium | SizeLarge;\n placeholder?: string;\n /** @default {} */\n selectProps?: Partial<SelectInputProps<string | null>>;\n /**\n * List of iso3 codes of countries to remove from the list\n * @default []\n */\n disabledCountries?: readonly string[];\n}\n\nconst defaultSelectProps = {} satisfies PhoneNumberInputProps['selectProps'];\nconst defaultDisabledCountries = [] satisfies PhoneNumberInputProps['disabledCountries'];\n\nconst PhoneNumberInput = ({\n id,\n 'aria-labelledby': ariaLabelledByProp,\n required,\n disabled,\n initialValue,\n onChange,\n onFocus,\n onBlur,\n countryCode,\n searchPlaceholder,\n size = Size.MEDIUM,\n placeholder,\n selectProps = defaultSelectProps,\n disabledCountries = defaultDisabledCountries,\n}: PhoneNumberInputProps) => {\n const countryCodeSelectRef = useRef<HTMLButtonElement>(null);\n const phoneNumberInputRef = useRef<HTMLInputElement>(null);\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const { paddingInlineStart } = useInputPaddings();\n const hasInputGroupAddonStart = paddingInlineStart != null;\n const fieldLabelRef = useFieldLabelRef();\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];\n\n const { locale, formatMessage } = useIntl();\n\n const [randomId] = useState(() => Math.random().toString(36).slice(2, 8));\n\n const createId = (customID: string | undefined, backup: string): string => {\n if (customID) {\n return customID + (backup ? `-${backup}` : '');\n }\n return `${backup}-${randomId}`;\n };\n\n // Link the first non-disabled input to the the Field label, if present\n const ids = {\n countryCode: {\n label: createId(id, 'country-code-label'),\n select: createId(id, 'country-code-select'),\n },\n phoneNumber: {\n label: createId(id, 'phone-number-label'),\n input: createId(id, id ? '' : 'phone-number-input'),\n },\n };\n\n const [internalValue, setInternalValue] = useState<PhoneNumber>(() => {\n const cleanValue = initialValue ? cleanNumber(initialValue) : null;\n\n if (!cleanValue || !isValidPhoneNumber(cleanValue, 1)) {\n return {\n prefix: setDefaultPrefix(locale, countryCode),\n suffix: '',\n };\n }\n\n return explodeNumberModel(cleanValue);\n });\n const broadcastedValueRef = useRef<PhoneNumber>(internalValue);\n\n const [suffixDirty, setSuffixDirty] = useState(false);\n\n useEffect(() => {\n if (!suffixDirty && internalValue.suffix) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- Tracking when suffix becomes dirty\n setSuffixDirty(true);\n }\n }, [internalValue.suffix, suffixDirty]);\n\n const countriesByPrefix = useMemo(\n () =>\n groupCountriesByPrefix(\n sortArrayByProperty(excludeCountries(countries, disabledCountries), 'iso3'),\n ),\n [disabledCountries],\n );\n\n const onSuffixChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const suffix = event.target.value;\n if (ALLOWED_PHONE_CHARS.test(suffix)) {\n setInternalValue((prev) => ({ ...prev, suffix }));\n }\n };\n\n const onPaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n if (!event.nativeEvent.clipboardData) {\n return;\n }\n\n const pastedValue = (event.nativeEvent.clipboardData.getData('text/plain') || '').replace(\n /(\\s|-)+/g,\n '',\n );\n const pastedNumber = explodeNumberModel(pastedValue);\n\n if (\n pastedNumber.prefix != null &&\n countriesByPrefix.has(pastedNumber.prefix) &&\n ALLOWED_PHONE_CHARS.test(pastedNumber.suffix)\n ) {\n setInternalValue(pastedNumber);\n }\n };\n\n useEffect(() => {\n const internalPhoneNumber = `${internalValue.prefix ?? ''}${internalValue.suffix}`;\n const broadcastedPhoneNumber = `${broadcastedValueRef.current.prefix ?? ''}${broadcastedValueRef.current.suffix}`;\n\n if (internalPhoneNumber === broadcastedPhoneNumber) {\n return;\n }\n\n const newValue = isValidPhoneNumber(internalPhoneNumber)\n ? cleanNumber(internalPhoneNumber)\n : null;\n\n onChange(\n newValue,\n internalValue.prefix ?? '', // TODO: Allow `null` in public API\n );\n broadcastedValueRef.current = internalValue;\n }, [onChange, internalValue]);\n\n useEffect(() => {\n const labelRef = fieldLabelRef?.current;\n\n if (labelRef) {\n const handleLabelClick = () => {\n if (!selectProps.disabled) {\n countryCodeSelectRef.current?.click();\n } else {\n phoneNumberInputRef.current?.focus();\n }\n };\n\n labelRef.addEventListener('click', handleLabelClick);\n\n return () => {\n labelRef?.removeEventListener('click', handleLabelClick);\n };\n }\n }, [fieldLabelRef, selectProps.disabled]);\n\n return (\n <fieldset {...inputAttributes} aria-labelledby={ariaLabelledBy} className=\"tw-telephone\">\n <label className=\"sr-only\" id={ids.countryCode.label} htmlFor={ids.countryCode.select}>\n {formatMessage(messages.countryCodeLabel)}\n </label>\n <div\n className={`tw-telephone__country-select${\n hasInputGroupAddonStart\n ? ' tw-telephone__country-select--with-input-group-addon-start'\n : ''\n }`}\n >\n <SelectInput\n triggerRef={countryCodeSelectRef}\n placeholder={formatMessage(messages.selectInputPlaceholder)}\n items={[...countriesByPrefix].map(([prefix, countries]) => ({\n type: 'option',\n value: prefix,\n filterMatchers: [\n prefix,\n ...countries.map((country) => country.name),\n ...countries.map((country) => country.iso3),\n ],\n }))}\n value={internalValue.prefix}\n renderValue={(prefix, withinTrigger) => (\n <SelectInputOptionContent\n title={prefix}\n note={\n withinTrigger\n ? undefined\n : countriesByPrefix\n .get(prefix)\n ?.map((country) => country.iso3)\n .join(', ')\n }\n />\n )}\n filterable\n filterPlaceholder={searchPlaceholder ?? formatMessage(messages.phoneNumberPrefix)}\n disabled={disabled}\n size={size}\n id={ids.countryCode.select}\n UNSAFE_triggerButtonProps={{\n id: ids.countryCode.select,\n 'aria-labelledby': ids.countryCode.label,\n 'aria-describedby': undefined,\n 'aria-invalid': undefined,\n }}\n onChange={(prefix) => {\n const country = prefix != null ? findCountryByPrefix(prefix) : null;\n setInternalValue((prev) => ({ ...prev, prefix, format: country?.phoneFormat }));\n }}\n onClose={() => {\n if (suffixDirty) {\n onBlur?.();\n }\n }}\n {...selectProps}\n />\n </div>\n <label className=\"sr-only\" id={ids.phoneNumber.label} htmlFor={ids.phoneNumber.input}>\n {formatMessage(messages.phoneNumberLabel)}\n </label>\n <div className=\"tw-telephone__number-input\">\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={phoneNumberInputRef}\n className=\"tw-telephone__number-input-field\"\n id={ids.phoneNumber.input}\n autoComplete=\"tel-national\"\n name=\"phoneNumber\"\n inputMode=\"numeric\"\n value={internalValue.suffix}\n disabled={disabled}\n required={required}\n placeholder={placeholder}\n aria-labelledby={ids.phoneNumber.label}\n onChange={onSuffixChange}\n onPaste={onPaste}\n onFocus={onFocus}\n onBlur={() => onBlur?.()}\n />\n </div>\n </div>\n </fieldset>\n );\n};\n\nexport default PhoneNumberInput;\n"],"names":["ALLOWED_PHONE_CHARS","defaultSelectProps","defaultDisabledCountries","PhoneNumberInput","id","ariaLabelledByProp","required","disabled","initialValue","onChange","onFocus","onBlur","countryCode","searchPlaceholder","size","Size","MEDIUM","placeholder","selectProps","disabledCountries","countryCodeSelectRef","useRef","phoneNumberInputRef","inputAttributes","useInputAttributes","nonLabelable","paddingInlineStart","useInputPaddings","hasInputGroupAddonStart","fieldLabelRef","useFieldLabelRef","ariaLabelledBy","locale","formatMessage","useIntl","randomId","useState","Math","random","toString","slice","createId","customID","backup","ids","label","select","phoneNumber","input","internalValue","setInternalValue","cleanValue","cleanNumber","isValidPhoneNumber","prefix","setDefaultPrefix","suffix","explodeNumberModel","broadcastedValueRef","suffixDirty","setSuffixDirty","useEffect","countriesByPrefix","useMemo","groupCountriesByPrefix","sortArrayByProperty","excludeCountries","countries","onSuffixChange","event","target","value","test","prev","onPaste","nativeEvent","clipboardData","pastedValue","getData","replace","pastedNumber","has","internalPhoneNumber","broadcastedPhoneNumber","current","newValue","labelRef","handleLabelClick","click","focus","addEventListener","removeEventListener","_jsxs","className","children","_jsx","htmlFor","messages","countryCodeLabel","SelectInput","triggerRef","selectInputPlaceholder","items","map","type","filterMatchers","country","name","iso3","renderValue","withinTrigger","SelectInputOptionContent","title","note","undefined","get","join","filterable","filterPlaceholder","phoneNumberPrefix","UNSAFE_triggerButtonProps","findCountryByPrefix","format","phoneFormat","onClose","phoneNumberLabel","Input","ref","autoComplete","inputMode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAMA,mBAAmB,GAAG,eAAe;AA0B3C,MAAMC,kBAAkB,GAAG,EAAiD;AAC5E,MAAMC,wBAAwB,GAAG,EAAuD;AAExF,MAAMC,gBAAgB,GAAGA,CAAC;EACxBC,EAAE;AACF,EAAA,iBAAiB,EAAEC,kBAAkB;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AA,KAAA,EAAA;QAAKF,SAAS,EAAE,2BAA2B/E,IAAI,CAAA,CAAA,EAAIP,QAAQ,GAAG,UAAU,GAAG,EAAE,CAAA,CAAG;QAAAuF,QAAA,eAC9EC,GAAA,CAAC+B,KAAK,EAAA;AACJC,UAAAA,GAAG,EAAEzG,mBAAoB;AACzBuE,UAAAA,SAAS,EAAC,kCAAkC;AAC5CzF,UAAAA,EAAE,EAAEwC,GAAG,CAACG,WAAW,CAACC,KAAM;AAC1BgF,UAAAA,YAAY,EAAC,cAAc;AAC3BrB,UAAAA,IAAI,EAAC,aAAa;AAClBsB,UAAAA,SAAS,EAAC,SAAS;UACnB1D,KAAK,EAAEtB,aAAa,CAACO,MAAO;AAC5BjD,UAAAA,QAAQ,EAAEA,QAAS;AACnBD,UAAAA,QAAQ,EAAEA,QAAS;AACnBW,UAAAA,WAAW,EAAEA,WAAY;AACzB,UAAA,iBAAA,EAAiB2B,GAAG,CAACG,WAAW,CAACF,KAAM;AACvCpC,UAAAA,QAAQ,EAAE2D,cAAe;AACzBM,UAAAA,OAAO,EAAEA,OAAQ;AACjBhE,UAAAA,OAAO,EAAEA,OAAQ;AACjBC,UAAAA,MAAM,EAAEA,MAAMA,MAAM;SAAK;OAExB;AACP,KAAK,CACP;AAAA,GAAU,CAAC;AAEf;;;;"}
@@ -5,7 +5,31 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var clsx = require('clsx');
6
6
  var React = require('react');
7
7
  var Input = require('../../Inputs/Input/Input.js');
8
+ require('../../common/theme.js');
9
+ var direction = require('../../common/direction.js');
10
+ require('@transferwise/neptune-tokens');
11
+ require('../../common/PropsValues/control.js');
12
+ require('../../common/PropsValues/size.js');
13
+ require('../../common/PropsValues/typography.js');
14
+ require('../../common/PropsValues/width.js');
15
+ require('../../common/PropsValues/type.js');
16
+ require('../../common/PropsValues/dateMode.js');
17
+ require('../../common/PropsValues/monthFormat.js');
18
+ require('../../common/PropsValues/position.js');
19
+ require('../../common/PropsValues/layouts.js');
20
+ require('../../common/PropsValues/status.js');
21
+ require('../../common/PropsValues/sentiment.js');
22
+ require('../../common/PropsValues/profileType.js');
23
+ require('../../common/PropsValues/variant.js');
24
+ require('../../common/PropsValues/scroll.js');
25
+ require('../../common/PropsValues/markdownNodeType.js');
26
+ require('../../common/fileType.js');
27
+ require('@transferwise/formatting');
28
+ require('@transferwise/icons');
29
+ require('react-intl');
30
+ require('../../common/CloseButton/CloseButton.messages.js');
8
31
  var jsxRuntime = require('react/jsx-runtime');
32
+ var DirectionProvider = require('../../Provider/Direction/DirectionProvider.js');
9
33
 
10
34
  /* eslint-disable jsx-a11y/no-autofocus */
11
35
  /* eslint-disable jsx-a11y/click-events-have-key-events */
@@ -44,7 +68,7 @@ class TypeaheadInput extends React.Component {
44
68
  });
45
69
  });
46
70
  };
47
- renderInput = () => {
71
+ renderInput = isRTL => {
48
72
  const {
49
73
  typeaheadId,
50
74
  autoFocus,
@@ -67,6 +91,7 @@ class TypeaheadInput extends React.Component {
67
91
  const hasPlaceholder = !multiple || selected.length === 0;
68
92
  return /*#__PURE__*/jsxRuntime.jsx(Input.Input, {
69
93
  ref: this.inputRef,
94
+ dir: isRTL ? 'rtl' : 'auto',
70
95
  className: clsx.clsx(multiple && 'typeahead__input'),
71
96
  name: name,
72
97
  id: `input-${typeaheadId}`,
@@ -98,25 +123,30 @@ class TypeaheadInput extends React.Component {
98
123
  maxHeight,
99
124
  renderChip
100
125
  } = this.props;
101
- return multiple ? /*#__PURE__*/jsxRuntime.jsxs("div", {
102
- className: "form-control typeahead__input-container",
103
- style: {
104
- maxHeight
105
- },
106
- onClick: () => {
107
- this.inputRef.current?.focus();
108
- },
109
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
110
- className: "typeahead__input-wrapper",
111
- children: [selected && selected.map((chip, idx) => renderChip(chip, idx)), this.renderInput(), /*#__PURE__*/jsxRuntime.jsx("div", {
112
- className: "typeahead__input-aligner"
113
- })]
114
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
115
- ref: this.sizerRef,
116
- className: "sizer form-control typeahead__input",
117
- children: value
118
- })]
119
- }) : this.renderInput();
126
+ return /*#__PURE__*/jsxRuntime.jsx(DirectionProvider.DirectionContext.Consumer, {
127
+ children: direction$1 => {
128
+ const isRTL = direction$1 === direction.Direction.RTL;
129
+ return multiple ? /*#__PURE__*/jsxRuntime.jsxs("div", {
130
+ className: "form-control typeahead__input-container",
131
+ style: {
132
+ maxHeight
133
+ },
134
+ onClick: () => {
135
+ this.inputRef.current?.focus();
136
+ },
137
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
138
+ className: "typeahead__input-wrapper",
139
+ children: [selected && selected.map((chip, idx) => renderChip(chip, idx)), this.renderInput(isRTL), /*#__PURE__*/jsxRuntime.jsx("div", {
140
+ className: "typeahead__input-aligner"
141
+ })]
142
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
143
+ ref: this.sizerRef,
144
+ className: "sizer form-control typeahead__input",
145
+ children: value
146
+ })]
147
+ }) : this.renderInput(isRTL);
148
+ }
149
+ });
120
150
  }
121
151
  }
122
152
 
@@ -1 +1 @@
1
- {"version":3,"file":"TypeaheadInput.js","sources":["../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport { clsx } from 'clsx';\nimport { Component, createRef, ReactNode } from 'react';\n\nimport { Input } from '../../Inputs/Input/Input';\nimport { TypeaheadOption, TypeaheadProps } from '../Typeahead';\n\nconst DEFAULT_INPUT_MIN_WIDTH = 10;\n\nexport type TypeaheadInputProps<T> = {\n typeaheadId: string;\n value: string;\n selected: readonly TypeaheadOption<T>[];\n dropdownOpen?: boolean;\n autoComplete: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;\n onFocus: () => void;\n onPaste: React.ClipboardEventHandler<HTMLInputElement>;\n renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;\n ariaActivedescendant?: string;\n} & Pick<TypeaheadProps<T>, 'id' | 'name' | 'autoFocus' | 'multiple' | 'placeholder' | 'maxHeight'>;\n\ntype TypeaheadInputState = {\n inputWidth: number;\n keyboardFocusedOptionIndex: number | null;\n};\n\nexport default class TypeaheadInput<T> extends Component<\n TypeaheadInputProps<T>,\n TypeaheadInputState\n> {\n inputRef = createRef<HTMLInputElement>();\n sizerRef = createRef<HTMLDivElement>();\n\n constructor(props: TypeaheadInputProps<T>) {\n super(props);\n this.state = {\n inputWidth: DEFAULT_INPUT_MIN_WIDTH,\n keyboardFocusedOptionIndex: null,\n };\n }\n\n componentDidMount() {\n const { autoFocus } = this.props;\n if (autoFocus) {\n // Autofocus after context code executions (e.g open Modal) is completed\n setTimeout(() => {\n this.inputRef.current?.focus();\n });\n }\n }\n\n componentDidUpdate(previousProps: TypeaheadInputProps<T>) {\n if (previousProps.value !== this.props.value && this.props.multiple) {\n this.recalculateWidth();\n }\n }\n\n recalculateWidth = () => {\n requestAnimationFrame(() => {\n this.setState({\n inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.current?.scrollWidth ?? 0 + 10),\n });\n });\n };\n\n renderInput = () => {\n const {\n typeaheadId,\n autoFocus,\n multiple,\n name,\n dropdownOpen,\n placeholder,\n selected,\n value,\n onChange,\n onKeyDown,\n onFocus,\n onPaste,\n autoComplete,\n ariaActivedescendant,\n } = this.props;\n const { inputWidth } = this.state;\n\n const hasPlaceholder = !multiple || selected.length === 0;\n return (\n <Input\n ref={this.inputRef}\n className={clsx(multiple && 'typeahead__input')}\n name={name}\n id={`input-${typeaheadId}`}\n aria-activedescendant={ariaActivedescendant}\n autoFocus={autoFocus}\n placeholder={hasPlaceholder ? placeholder : ''}\n aria-autocomplete=\"list\"\n aria-expanded={dropdownOpen}\n aria-haspopup=\"listbox\"\n aria-controls={dropdownOpen ? `menu-${typeaheadId}` : undefined}\n autoComplete={autoComplete}\n role=\"combobox\"\n value={value}\n style={multiple && selected.length > 0 ? { width: inputWidth } : {}}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onClick={onFocus}\n onFocus={onFocus}\n onPaste={onPaste}\n />\n );\n };\n\n render() {\n const { multiple, selected, value, maxHeight, renderChip } = this.props;\n\n return multiple ? (\n <div\n className=\"form-control typeahead__input-container\"\n style={{ maxHeight }}\n onClick={() => {\n this.inputRef.current?.focus();\n }}\n >\n <div className=\"typeahead__input-wrapper\">\n {selected && selected.map((chip, idx) => renderChip(chip, idx))}\n\n {this.renderInput()}\n <div className=\"typeahead__input-aligner\" />\n </div>\n <div ref={this.sizerRef} className=\"sizer form-control typeahead__input\">\n {value}\n </div>\n </div>\n ) : (\n this.renderInput()\n );\n }\n}\n"],"names":["DEFAULT_INPUT_MIN_WIDTH","TypeaheadInput","Component","inputRef","createRef","sizerRef","constructor","props","state","inputWidth","keyboardFocusedOptionIndex","componentDidMount","autoFocus","setTimeout","current","focus","componentDidUpdate","previousProps","value","multiple","recalculateWidth","requestAnimationFrame","setState","Math","max","scrollWidth","renderInput","typeaheadId","name","dropdownOpen","placeholder","selected","onChange","onKeyDown","onFocus","onPaste","autoComplete","ariaActivedescendant","hasPlaceholder","length","_jsx","Input","ref","className","clsx","id","undefined","role","style","width","onClick","render","maxHeight","renderChip","_jsxs","children","map","chip","idx"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AAOA,MAAMA,uBAAuB,GAAG,EAAE;AAqBpB,MAAOC,cAAkB,SAAQC,eAG9C,CAAA;EACCC,QAAQ,gBAAGC,eAAS,EAAoB;EACxCC,QAAQ,gBAAGD,eAAS,EAAkB;EAEtCE,WAAAA,CAAYC,KAA6B,EAAA;IACvC,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;AACXC,MAAAA,UAAU,EAAET,uBAAuB;AACnCU,MAAAA,0BAA0B,EAAE;KAC7B;AACH,EAAA;AAEA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C,KAAK,EAAE;MAChC,CAAE;AAAAwC,MAAAA,QAAA,gBAEFD,eAAA,CAAA,KAAA,EAAA;AAAKX,QAAAA,SAAS,EAAC,0BAA0B;QAAAY,QAAA,EAAA,CACtCxB,QAAQ,IAAIA,QAAQ,CAACyB,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,KAAKL,UAAU,CAACI,IAAI,EAAEC,GAAG,CAAC,CAAC,EAE9D,IAAI,CAAChC,WAAW,EAAE,eACnBc,cAAA,CAAA,KAAA,EAAA;AAAKG,UAAAA,SAAS,EAAC;AAA0B,SAAA,CAC3C;OAAK,CACL,eAAAH,cAAA,CAAA,KAAA,EAAA;QAAKE,GAAG,EAAE,IAAI,CAACrC,QAAS;AAACsC,QAAAA,SAAS,EAAC,qCAAqC;AAAAY,QAAAA,QAAA,EACrErC;AAAK,OACH,CACP;AAAA,KAAK,CAAC,GAEN,IAAI,CAACQ,WAAW,EACjB;AACH,EAAA;AACD;;;;"}
1
+ {"version":3,"file":"TypeaheadInput.js","sources":["../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport { clsx } from 'clsx';\nimport { Component, createRef, ReactNode } from 'react';\n\nimport { Input } from '../../Inputs/Input/Input';\nimport { TypeaheadOption, TypeaheadProps } from '../Typeahead';\nimport { Direction } from '../../common';\nimport { DirectionContext } from '../../Provider/Direction';\n\nconst DEFAULT_INPUT_MIN_WIDTH = 10;\n\nexport type TypeaheadInputProps<T> = {\n typeaheadId: string;\n value: string;\n selected: readonly TypeaheadOption<T>[];\n dropdownOpen?: boolean;\n autoComplete: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;\n onFocus: () => void;\n onPaste: React.ClipboardEventHandler<HTMLInputElement>;\n renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;\n ariaActivedescendant?: string;\n} & Pick<TypeaheadProps<T>, 'id' | 'name' | 'autoFocus' | 'multiple' | 'placeholder' | 'maxHeight'>;\n\ntype TypeaheadInputState = {\n inputWidth: number;\n keyboardFocusedOptionIndex: number | null;\n};\n\nexport default class TypeaheadInput<T> extends Component<\n TypeaheadInputProps<T>,\n TypeaheadInputState\n> {\n inputRef = createRef<HTMLInputElement>();\n sizerRef = createRef<HTMLDivElement>();\n\n constructor(props: TypeaheadInputProps<T>) {\n super(props);\n this.state = {\n inputWidth: DEFAULT_INPUT_MIN_WIDTH,\n keyboardFocusedOptionIndex: null,\n };\n }\n\n componentDidMount() {\n const { autoFocus } = this.props;\n if (autoFocus) {\n // Autofocus after context code executions (e.g open Modal) is completed\n setTimeout(() => {\n this.inputRef.current?.focus();\n });\n }\n }\n\n componentDidUpdate(previousProps: TypeaheadInputProps<T>) {\n if (previousProps.value !== this.props.value && this.props.multiple) {\n this.recalculateWidth();\n }\n }\n\n recalculateWidth = () => {\n requestAnimationFrame(() => {\n this.setState({\n inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.current?.scrollWidth ?? 0 + 10),\n });\n });\n };\n\n renderInput = (isRTL: boolean) => {\n const {\n typeaheadId,\n autoFocus,\n multiple,\n name,\n dropdownOpen,\n placeholder,\n selected,\n value,\n onChange,\n onKeyDown,\n onFocus,\n onPaste,\n autoComplete,\n ariaActivedescendant,\n } = this.props;\n const { inputWidth } = this.state;\n\n const hasPlaceholder = !multiple || selected.length === 0;\n return (\n <Input\n ref={this.inputRef}\n dir={isRTL ? 'rtl' : 'auto'}\n className={clsx(multiple && 'typeahead__input')}\n name={name}\n id={`input-${typeaheadId}`}\n aria-activedescendant={ariaActivedescendant}\n autoFocus={autoFocus}\n placeholder={hasPlaceholder ? placeholder : ''}\n aria-autocomplete=\"list\"\n aria-expanded={dropdownOpen}\n aria-haspopup=\"listbox\"\n aria-controls={dropdownOpen ? `menu-${typeaheadId}` : undefined}\n autoComplete={autoComplete}\n role=\"combobox\"\n value={value}\n style={multiple && selected.length > 0 ? { width: inputWidth } : {}}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onClick={onFocus}\n onFocus={onFocus}\n onPaste={onPaste}\n />\n );\n };\n\n render() {\n const { multiple, selected, value, maxHeight, renderChip } = this.props;\n\n return (\n <DirectionContext.Consumer>\n {(direction) => {\n const isRTL = direction === Direction.RTL;\n\n return multiple ? (\n <div\n className=\"form-control typeahead__input-container\"\n style={{ maxHeight }}\n onClick={() => {\n this.inputRef.current?.focus();\n }}\n >\n <div className=\"typeahead__input-wrapper\">\n {selected && selected.map((chip, idx) => renderChip(chip, idx))}\n\n {this.renderInput(isRTL)}\n <div className=\"typeahead__input-aligner\" />\n </div>\n <div ref={this.sizerRef} className=\"sizer form-control typeahead__input\">\n {value}\n </div>\n </div>\n ) : (\n this.renderInput(isRTL)\n );\n }}\n </DirectionContext.Consumer>\n );\n }\n}\n"],"names":["DEFAULT_INPUT_MIN_WIDTH","TypeaheadInput","Component","inputRef","createRef","sizerRef","constructor","props","state","inputWidth","keyboardFocusedOptionIndex","componentDidMount","autoFocus","setTimeout","current","focus","componentDidUpdate","previousProps","value","multiple","recalculateWidth","requestAnimationFrame","setState","Math","max","scrollWidth","renderInput","isRTL","typeaheadId","name","dropdownOpen","placeholder","selected","onChange","onKeyDown","onFocus","onPaste","autoComplete","ariaActivedescendant","hasPlaceholder","length","_jsx","Input","ref","dir","className","clsx","id","undefined","role","style","width","onClick","render","maxHeight","renderChip","DirectionContext","Consumer","children","direction","Direction","RTL","_jsxs","map","chip","idx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AASA,MAAMA,uBAAuB,GAAG,EAAE;AAqBpB,MAAOC,cAAkB,SAAQC,eAG9C,CAAA;EACCC,QAAQ,gBAAGC,eAAS,EAAoB;EACxCC,QAAQ,gBAAGD,eAAS,EAAkB;EAEtCE,WAAAA,CAAYC,KA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CAAChD,KAAK;AAEvE,IAAA,oBACEkC,cAAA,CAACe,kCAAgB,CAACC,QAAQ,EAAA;MAAAC,QAAA,EACtBC,WAAS,IAAI;AACb,QAAA,MAAMhC,KAAK,GAAGgC,WAAS,KAAKC,mBAAS,CAACC,GAAG;QAEzC,OAAO1C,QAAQ,gBACb2C,eAAA,CAAA,KAAA,EAAA;AACEjB,UAAAA,SAAS,EAAC,yCAAyC;AACnDK,UAAAA,KAAK,EAAE;AAAEI,YAAAA;WAAY;UACrBF,OAAO,EAAEA,MAAK;AACZ,YAAA,IAAI,CAACjD,QAAQ,CAACW,OAAO,EAAEC,KAAK,EAAE;UAChC,CAAE;AAAA2C,UAAAA,QAAA,gBAEFI,eAAA,CAAA,KAAA,EAAA;AAAKjB,YAAAA,SAAS,EAAC,0BAA0B;YAAAa,QAAA,EAAA,CACtC1B,QAAQ,IAAIA,QAAQ,CAAC+B,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,KAAKV,UAAU,CAACS,IAAI,EAAEC,GAAG,CAAC,CAAC,EAE9D,IAAI,CAACvC,WAAW,CAACC,KAAK,CAAC,eACxBc,cAAA,CAAA,KAAA,EAAA;AAAKI,cAAAA,SAAS,EAAC;AAA0B,aAAA,CAC3C;WAAK,CACL,eAAAJ,cAAA,CAAA,KAAA,EAAA;YAAKE,GAAG,EAAE,IAAI,CAACtC,QAAS;AAACwC,YAAAA,SAAS,EAAC,qCAAqC;AAAAa,YAAAA,QAAA,EACrExC;AAAK,WACH,CACP;AAAA,SAAK,CAAC,GAEN,IAAI,CAACQ,WAAW,CAACC,KAAK,CACvB;AACH,MAAA;AAAC,KACwB,CAAC;AAEhC,EAAA;AACD;;;;"}
@@ -1,7 +1,31 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { Component, createRef } from 'react';
3
3
  import { Input } from '../../Inputs/Input/Input.mjs';
4
+ import '../../common/theme.mjs';
5
+ import { Direction } from '../../common/direction.mjs';
6
+ import '@transferwise/neptune-tokens';
7
+ import '../../common/PropsValues/control.mjs';
8
+ import '../../common/PropsValues/size.mjs';
9
+ import '../../common/PropsValues/typography.mjs';
10
+ import '../../common/PropsValues/width.mjs';
11
+ import '../../common/PropsValues/type.mjs';
12
+ import '../../common/PropsValues/dateMode.mjs';
13
+ import '../../common/PropsValues/monthFormat.mjs';
14
+ import '../../common/PropsValues/position.mjs';
15
+ import '../../common/PropsValues/layouts.mjs';
16
+ import '../../common/PropsValues/status.mjs';
17
+ import '../../common/PropsValues/sentiment.mjs';
18
+ import '../../common/PropsValues/profileType.mjs';
19
+ import '../../common/PropsValues/variant.mjs';
20
+ import '../../common/PropsValues/scroll.mjs';
21
+ import '../../common/PropsValues/markdownNodeType.mjs';
22
+ import '../../common/fileType.mjs';
23
+ import '@transferwise/formatting';
24
+ import '@transferwise/icons';
25
+ import 'react-intl';
26
+ import '../../common/CloseButton/CloseButton.messages.mjs';
4
27
  import { jsx, jsxs } from 'react/jsx-runtime';
28
+ import { DirectionContext } from '../../Provider/Direction/DirectionProvider.mjs';
5
29
 
6
30
  /* eslint-disable jsx-a11y/no-autofocus */
7
31
  /* eslint-disable jsx-a11y/click-events-have-key-events */
@@ -40,7 +64,7 @@ class TypeaheadInput extends Component {
40
64
  });
41
65
  });
42
66
  };
43
- renderInput = () => {
67
+ renderInput = isRTL => {
44
68
  const {
45
69
  typeaheadId,
46
70
  autoFocus,
@@ -63,6 +87,7 @@ class TypeaheadInput extends Component {
63
87
  const hasPlaceholder = !multiple || selected.length === 0;
64
88
  return /*#__PURE__*/jsx(Input, {
65
89
  ref: this.inputRef,
90
+ dir: isRTL ? 'rtl' : 'auto',
66
91
  className: clsx(multiple && 'typeahead__input'),
67
92
  name: name,
68
93
  id: `input-${typeaheadId}`,
@@ -94,25 +119,30 @@ class TypeaheadInput extends Component {
94
119
  maxHeight,
95
120
  renderChip
96
121
  } = this.props;
97
- return multiple ? /*#__PURE__*/jsxs("div", {
98
- className: "form-control typeahead__input-container",
99
- style: {
100
- maxHeight
101
- },
102
- onClick: () => {
103
- this.inputRef.current?.focus();
104
- },
105
- children: [/*#__PURE__*/jsxs("div", {
106
- className: "typeahead__input-wrapper",
107
- children: [selected && selected.map((chip, idx) => renderChip(chip, idx)), this.renderInput(), /*#__PURE__*/jsx("div", {
108
- className: "typeahead__input-aligner"
109
- })]
110
- }), /*#__PURE__*/jsx("div", {
111
- ref: this.sizerRef,
112
- className: "sizer form-control typeahead__input",
113
- children: value
114
- })]
115
- }) : this.renderInput();
122
+ return /*#__PURE__*/jsx(DirectionContext.Consumer, {
123
+ children: direction => {
124
+ const isRTL = direction === Direction.RTL;
125
+ return multiple ? /*#__PURE__*/jsxs("div", {
126
+ className: "form-control typeahead__input-container",
127
+ style: {
128
+ maxHeight
129
+ },
130
+ onClick: () => {
131
+ this.inputRef.current?.focus();
132
+ },
133
+ children: [/*#__PURE__*/jsxs("div", {
134
+ className: "typeahead__input-wrapper",
135
+ children: [selected && selected.map((chip, idx) => renderChip(chip, idx)), this.renderInput(isRTL), /*#__PURE__*/jsx("div", {
136
+ className: "typeahead__input-aligner"
137
+ })]
138
+ }), /*#__PURE__*/jsx("div", {
139
+ ref: this.sizerRef,
140
+ className: "sizer form-control typeahead__input",
141
+ children: value
142
+ })]
143
+ }) : this.renderInput(isRTL);
144
+ }
145
+ });
116
146
  }
117
147
  }
118
148
 
@@ -1 +1 @@
1
- {"version":3,"file":"TypeaheadInput.mjs","sources":["../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport { clsx } from 'clsx';\nimport { Component, createRef, ReactNode } from 'react';\n\nimport { Input } from '../../Inputs/Input/Input';\nimport { TypeaheadOption, TypeaheadProps } from '../Typeahead';\n\nconst DEFAULT_INPUT_MIN_WIDTH = 10;\n\nexport type TypeaheadInputProps<T> = {\n typeaheadId: string;\n value: string;\n selected: readonly TypeaheadOption<T>[];\n dropdownOpen?: boolean;\n autoComplete: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;\n onFocus: () => void;\n onPaste: React.ClipboardEventHandler<HTMLInputElement>;\n renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;\n ariaActivedescendant?: string;\n} & Pick<TypeaheadProps<T>, 'id' | 'name' | 'autoFocus' | 'multiple' | 'placeholder' | 'maxHeight'>;\n\ntype TypeaheadInputState = {\n inputWidth: number;\n keyboardFocusedOptionIndex: number | null;\n};\n\nexport default class TypeaheadInput<T> extends Component<\n TypeaheadInputProps<T>,\n TypeaheadInputState\n> {\n inputRef = createRef<HTMLInputElement>();\n sizerRef = createRef<HTMLDivElement>();\n\n constructor(props: TypeaheadInputProps<T>) {\n super(props);\n this.state = {\n inputWidth: DEFAULT_INPUT_MIN_WIDTH,\n keyboardFocusedOptionIndex: null,\n };\n }\n\n componentDidMount() {\n const { autoFocus } = this.props;\n if (autoFocus) {\n // Autofocus after context code executions (e.g open Modal) is completed\n setTimeout(() => {\n this.inputRef.current?.focus();\n });\n }\n }\n\n componentDidUpdate(previousProps: TypeaheadInputProps<T>) {\n if (previousProps.value !== this.props.value && this.props.multiple) {\n this.recalculateWidth();\n }\n }\n\n recalculateWidth = () => {\n requestAnimationFrame(() => {\n this.setState({\n inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.current?.scrollWidth ?? 0 + 10),\n });\n });\n };\n\n renderInput = () => {\n const {\n typeaheadId,\n autoFocus,\n multiple,\n name,\n dropdownOpen,\n placeholder,\n selected,\n value,\n onChange,\n onKeyDown,\n onFocus,\n onPaste,\n autoComplete,\n ariaActivedescendant,\n } = this.props;\n const { inputWidth } = this.state;\n\n const hasPlaceholder = !multiple || selected.length === 0;\n return (\n <Input\n ref={this.inputRef}\n className={clsx(multiple && 'typeahead__input')}\n name={name}\n id={`input-${typeaheadId}`}\n aria-activedescendant={ariaActivedescendant}\n autoFocus={autoFocus}\n placeholder={hasPlaceholder ? placeholder : ''}\n aria-autocomplete=\"list\"\n aria-expanded={dropdownOpen}\n aria-haspopup=\"listbox\"\n aria-controls={dropdownOpen ? `menu-${typeaheadId}` : undefined}\n autoComplete={autoComplete}\n role=\"combobox\"\n value={value}\n style={multiple && selected.length > 0 ? { width: inputWidth } : {}}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onClick={onFocus}\n onFocus={onFocus}\n onPaste={onPaste}\n />\n );\n };\n\n render() {\n const { multiple, selected, value, maxHeight, renderChip } = this.props;\n\n return multiple ? (\n <div\n className=\"form-control typeahead__input-container\"\n style={{ maxHeight }}\n onClick={() => {\n this.inputRef.current?.focus();\n }}\n >\n <div className=\"typeahead__input-wrapper\">\n {selected && selected.map((chip, idx) => renderChip(chip, idx))}\n\n {this.renderInput()}\n <div className=\"typeahead__input-aligner\" />\n </div>\n <div ref={this.sizerRef} className=\"sizer form-control typeahead__input\">\n {value}\n </div>\n </div>\n ) : (\n this.renderInput()\n );\n }\n}\n"],"names":["DEFAULT_INPUT_MIN_WIDTH","TypeaheadInput","Component","inputRef","createRef","sizerRef","constructor","props","state","inputWidth","keyboardFocusedOptionIndex","componentDidMount","autoFocus","setTimeout","current","focus","componentDidUpdate","previousProps","value","multiple","recalculateWidth","requestAnimationFrame","setState","Math","max","scrollWidth","renderInput","typeaheadId","name","dropdownOpen","placeholder","selected","onChange","onKeyDown","onFocus","onPaste","autoComplete","ariaActivedescendant","hasPlaceholder","length","_jsx","Input","ref","className","clsx","id","undefined","role","style","width","onClick","render","maxHeight","renderChip","_jsxs","children","map","chip","idx"],"mappings":";;;;;AAAA;AACA;AACA;AAOA,MAAMA,uBAAuB,GAAG,EAAE;AAqBpB,MAAOC,cAAkB,SAAQC,SAG9C,CAAA;EACCC,QAAQ,gBAAGC,SAAS,EAAoB;EACxCC,QAAQ,gBAAGD,SAAS,EAAkB;EAEtCE,WAAAA,CAAYC,KAA6B,EAAA;IACvC,K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EAAC,yCAAyC;AACnDK,MAAAA,KAAK,EAAE;AAAEI,QAAAA;OAAY;MACrBF,OAAO,EAAEA,MAAK;AACZ,QAAA,IAAI,CAAC/C,QAAQ,CAACW,OAAO,EAAEC,KAAK,EAAE;MAChC,CAAE;AAAAwC,MAAAA,QAAA,gBAEFD,IAAA,CAAA,KAAA,EAAA;AAAKX,QAAAA,SAAS,EAAC,0BAA0B;QAAAY,QAAA,EAAA,CACtCxB,QAAQ,IAAIA,QAAQ,CAACyB,GAAG,CAAC,CAACC,IAAI,EAAEC,GAAG,KAAKL,UAAU,CAACI,IAAI,EAAEC,GAAG,CAAC,CAAC,EAE9D,IAAI,CAAChC,WAAW,EAAE,eACnBc,GAAA,CAAA,KAAA,EAAA;AAAKG,UAAAA,SAAS,EAAC;AAA0B,SAAA,CAC3C;OAAK,CACL,eAAAH,GAAA,CAAA,KAAA,EAAA;QAAKE,GAAG,EAAE,IAAI,CAACrC,QAAS;AAACsC,QAAAA,SAAS,EAAC,qCAAqC;AAAAY,QAAAA,QAAA,EACrErC;AAAK,OACH,CACP;AAAA,KAAK,CAAC,GAEN,IAAI,CAACQ,WAAW,EACjB;AACH,EAAA;AACD;;;;"}
1
+ {"version":3,"file":"TypeaheadInput.mjs","sources":["../../../src/Typeahead/TypeaheadInput/TypeaheadInput.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-autofocus */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n/* eslint-disable jsx-a11y/no-static-element-interactions */\nimport { clsx } from 'clsx';\nimport { Component, createRef, ReactNode } from 'react';\n\nimport { Input } from '../../Inputs/Input/Input';\nimport { TypeaheadOption, TypeaheadProps } from '../Typeahead';\nimport { Direction } from '../../common';\nimport { DirectionContext } from '../../Provider/Direction';\n\nconst DEFAULT_INPUT_MIN_WIDTH = 10;\n\nexport type TypeaheadInputProps<T> = {\n typeaheadId: string;\n value: string;\n selected: readonly TypeaheadOption<T>[];\n dropdownOpen?: boolean;\n autoComplete: string;\n onChange: React.ChangeEventHandler<HTMLInputElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLInputElement>;\n onFocus: () => void;\n onPaste: React.ClipboardEventHandler<HTMLInputElement>;\n renderChip: (chip: TypeaheadOption<T>, index: number) => ReactNode;\n ariaActivedescendant?: string;\n} & Pick<TypeaheadProps<T>, 'id' | 'name' | 'autoFocus' | 'multiple' | 'placeholder' | 'maxHeight'>;\n\ntype TypeaheadInputState = {\n inputWidth: number;\n keyboardFocusedOptionIndex: number | null;\n};\n\nexport default class TypeaheadInput<T> extends Component<\n TypeaheadInputProps<T>,\n TypeaheadInputState\n> {\n inputRef = createRef<HTMLInputElement>();\n sizerRef = createRef<HTMLDivElement>();\n\n constructor(props: TypeaheadInputProps<T>) {\n super(props);\n this.state = {\n inputWidth: DEFAULT_INPUT_MIN_WIDTH,\n keyboardFocusedOptionIndex: null,\n };\n }\n\n componentDidMount() {\n const { autoFocus } = this.props;\n if (autoFocus) {\n // Autofocus after context code executions (e.g open Modal) is completed\n setTimeout(() => {\n this.inputRef.current?.focus();\n });\n }\n }\n\n componentDidUpdate(previousProps: TypeaheadInputProps<T>) {\n if (previousProps.value !== this.props.value && this.props.multiple) {\n this.recalculateWidth();\n }\n }\n\n recalculateWidth = () => {\n requestAnimationFrame(() => {\n this.setState({\n inputWidth: Math.max(DEFAULT_INPUT_MIN_WIDTH, this.sizerRef.current?.scrollWidth ?? 0 + 10),\n });\n });\n };\n\n renderInput = (isRTL: boolean) => {\n const {\n typeaheadId,\n autoFocus,\n multiple,\n name,\n dropdownOpen,\n placeholder,\n selected,\n value,\n onChange,\n onKeyDown,\n onFocus,\n onPaste,\n autoComplete,\n ariaActivedescendant,\n } = this.props;\n const { inputWidth } = this.state;\n\n const hasPlaceholder = !multiple || selected.length === 0;\n return (\n <Input\n ref={this.inputRef}\n dir={isRTL ? 'rtl' : 'auto'}\n className={clsx(multiple && 'typeahead__input')}\n name={name}\n id={`input-${typeaheadId}`}\n aria-activedescendant={ariaActivedescendant}\n autoFocus={autoFocus}\n placeholder={hasPlaceholder ? placeholder : ''}\n aria-autocomplete=\"list\"\n aria-expanded={dropdownOpen}\n aria-haspopup=\"listbox\"\n aria-controls={dropdownOpen ? `menu-${typeaheadId}` : undefined}\n autoComplete={autoComplete}\n role=\"combobox\"\n value={value}\n style={multiple && selected.length > 0 ? { width: inputWidth } : {}}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onClick={onFocus}\n onFocus={onFocus}\n onPaste={onPaste}\n />\n );\n };\n\n render() {\n const { multiple, selected, value, maxHeight, renderChip } = this.props;\n\n return (\n <DirectionContext.Consumer>\n {(direction) => {\n const isRTL = direction === Direction.RTL;\n\n return multiple ? (\n <div\n className=\"form-control typeahead__input-container\"\n style={{ maxHeight }}\n onClick={() => {\n this.inputRef.current?.focus();\n }}\n >\n <div className=\"typeahead__input-wrapper\">\n {selected && selected.map((chip, idx) => renderChip(chip, idx))}\n\n {this.renderInput(isRTL)}\n <div className=\"typeahead__input-aligner\" />\n </div>\n <div ref={this.sizerRef} className=\"sizer form-control typeahead__input\">\n {value}\n </div>\n </div>\n ) : (\n this.renderInput(isRTL)\n );\n }}\n </DirectionContext.Consumer>\n );\n }\n}\n"],"names":["DEFAULT_INPUT_MIN_WIDTH","TypeaheadInput","Component","inputRef","createRef","sizerRef","constructor","props","state","inputWidth","keyboardFocusedOptionIndex","componentDidMount","autoFocus","setTimeout","current","focus","componentDidUpdate","previousProps","value","multiple","recalculateWidth","requestAnimationFrame","setState","Math","max","scrollWidth","renderInput","isRTL","typeaheadId","name","dropdownOpen","placeholder","selected","onChange","onKeyDown","onFocus","onPaste","autoComplete","ariaActivedescendant","hasPlaceholder","length","_jsx","Input","ref","dir","className","clsx","id","undefined","role","style","width","onClick","render","maxHeight","renderChip","DirectionContext","Consumer","children","direction","Direction","RTL","_jsxs","map","chip","idx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AASA,MAAMA,uBAAuB,GAAG,EAAE;AAq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placeholder": "Select an option...",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "Country code",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "Phone number",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Prefix",
38
39
  "neptune.Select.searchPlaceholder": "Search...",
39
40
  "neptune.SelectInput.noResultsFound": "No results found",
40
41
  "neptune.StatusIcon.iconLabel.error": "Error:",
@@ -39,6 +39,7 @@ var en = {
39
39
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Select an option...",
40
40
  "neptune.PhoneNumberInput.countryCodeLabel": "Country code",
41
41
  "neptune.PhoneNumberInput.phoneNumberLabel": "Phone number",
42
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Prefix",
42
43
  "neptune.Select.searchPlaceholder": "Search...",
43
44
  "neptune.SelectInput.noResultsFound": "No results found",
44
45
  "neptune.StatusIcon.iconLabel.error": "Error:",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -35,6 +35,7 @@ var en = {
35
35
  "neptune.PhoneNumberInput.SelectInput.placeholder": "Select an option...",
36
36
  "neptune.PhoneNumberInput.countryCodeLabel": "Country code",
37
37
  "neptune.PhoneNumberInput.phoneNumberLabel": "Phone number",
38
+ "neptune.PhoneNumberInput.phoneNumberPrefix": "Prefix",
38
39
  "neptune.Select.searchPlaceholder": "Search...",
39
40
  "neptune.SelectInput.noResultsFound": "No results found",
40
41
  "neptune.StatusIcon.iconLabel.error": "Error:",
@@ -1 +1 @@
1
- {"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}