@transferwise/components 46.66.0 → 46.67.0
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/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/inputs/SelectInput.js +4 -0
- package/build/inputs/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput.mjs +4 -0
- package/build/inputs/SelectInput.mjs.map +1 -1
- package/build/main.css +0 -24
- package/build/moneyInput/MoneyInput.js +8 -1
- package/build/moneyInput/MoneyInput.js.map +1 -1
- package/build/moneyInput/MoneyInput.messages.js +3 -0
- package/build/moneyInput/MoneyInput.messages.js.map +1 -1
- package/build/moneyInput/MoneyInput.messages.mjs +3 -0
- package/build/moneyInput/MoneyInput.messages.mjs.map +1 -1
- package/build/moneyInput/MoneyInput.mjs +8 -1
- package/build/moneyInput/MoneyInput.mjs.map +1 -1
- package/build/stepper/Stepper.js +12 -1
- package/build/stepper/Stepper.js.map +1 -1
- package/build/stepper/Stepper.mjs +12 -1
- package/build/stepper/Stepper.mjs.map +1 -1
- package/build/styles/main.css +0 -24
- package/build/styles/stepper/Stepper.css +0 -24
- package/build/types/inputs/SelectInput.d.ts +3 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.messages.d.ts +5 -0
- package/build/types/moneyInput/MoneyInput.messages.d.ts.map +1 -1
- package/build/types/stepper/Stepper.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -2
- package/src/i18n/en.json +1 -0
- package/src/inputs/SelectInput.tsx +8 -3
- package/src/main.css +0 -24
- package/src/moneyInput/MoneyInput.docs.mdx +34 -0
- package/src/moneyInput/MoneyInput.messages.ts +5 -0
- package/src/moneyInput/MoneyInput.rtl.spec.tsx +47 -0
- package/src/moneyInput/MoneyInput.spec.js +0 -11
- package/src/moneyInput/MoneyInput.story.tsx +10 -7
- package/src/moneyInput/MoneyInput.tsx +8 -1
- package/src/stepper/Stepper.css +0 -24
- package/src/stepper/Stepper.less +0 -17
- package/src/stepper/Stepper.spec.js +11 -5
- package/src/stepper/Stepper.tsx +13 -2
- package/src/withId/withId.story.tsx +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyInput.mjs","sources":["../../src/moneyInput/MoneyInput.tsx"],"sourcesContent":["import { isEmpty, isNumber, isNull } from '@transferwise/neptune-validation';\nimport { Flag } from '@wise/art';\nimport { clsx } from 'clsx';\nimport { Component } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport { Typography, Size, SizeLarge, SizeMedium, SizeSmall } from '../common';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputItem,\n SelectInputOptionContent,\n SelectInputOptionItem,\n SelectInputProps,\n} from '../inputs/SelectInput';\nimport Title from '../title';\n\nimport messages from './MoneyInput.messages';\nimport { formatAmount, parseAmount } from './currencyFormatting';\nimport withId from '../withId';\n\nexport interface CurrencyOptionItem {\n header?: never;\n value: string;\n label: string;\n currency: string;\n note?: string;\n searchable?: string;\n}\n\nexport interface CurrencyHeaderItem {\n header: string;\n}\n\nexport type CurrencyItem = CurrencyOptionItem | CurrencyHeaderItem;\n\nconst isNumberOrNull = (v: unknown): v is number | null => isNumber(v) || isNull(v);\n\nconst formatAmountIfSet = ({\n amount,\n currency,\n locale,\n}: {\n amount: number | null | undefined;\n currency: string;\n locale: string;\n}) => {\n return typeof amount === 'number' ? formatAmount(amount, currency, locale) : '';\n};\n\nconst parseNumber = ({\n amount,\n currency,\n locale,\n}: {\n amount: string;\n currency: string;\n locale: string;\n}) => {\n return parseAmount(amount, currency, locale);\n};\n\nconst allowedInputKeys = new Set([\n 'Backspace',\n 'Delete',\n ',',\n '.',\n 'ArrowDown',\n 'ArrowUp',\n 'ArrowLeft',\n 'ArrowRight',\n 'Enter',\n 'Escape',\n 'Tab',\n]);\n\nexport interface MoneyInputProps extends WrappedComponentProps {\n id?: string;\n 'aria-labelledby'?: string;\n currencies: readonly CurrencyItem[];\n selectedCurrency: CurrencyOptionItem;\n onCurrencyChange?: (value: CurrencyOptionItem) => void;\n placeholder?: number;\n amount: number | null;\n size?: SizeSmall | SizeMedium | SizeLarge;\n onAmountChange?: (value: number | null) => void;\n addon?: React.ReactNode;\n searchPlaceholder?: string;\n /**\n * Allows the consumer to react to searching, while the search itself is handled internally.\n */\n onSearchChange?: (value: { searchQuery: string; filteredOptions: CurrencyItem[] }) => void;\n customActionLabel?: React.ReactNode;\n onCustomAction?: () => void;\n classNames?: Record<string, string>;\n selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;\n}\n\ntype MoneyInputPropsWithInputAttributes = MoneyInputProps & Partial<WithInputAttributesProps>;\n\ninterface MoneyInputState {\n searchQuery: string;\n formattedAmount: string;\n locale: string;\n}\n\nclass MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInputState> {\n declare props: MoneyInputPropsWithInputAttributes &\n Required<Pick<MoneyInputPropsWithInputAttributes, keyof typeof MoneyInput.defaultProps>>;\n\n static defaultProps = {\n size: Size.LARGE,\n classNames: {},\n selectProps: {},\n } satisfies Partial<MoneyInputPropsWithInputAttributes>;\n\n amountFocused = false;\n\n constructor(props: MoneyInputProps) {\n super(props);\n this.state = {\n searchQuery: '',\n formattedAmount: formatAmountIfSet({\n amount: props.amount,\n currency: props.selectedCurrency.currency,\n locale: props.intl.locale,\n }),\n locale: props.intl.locale,\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps: MoneyInputProps) {\n this.setState({ locale: nextProps.intl.locale });\n\n if (!this.amountFocused) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: nextProps.amount,\n currency: nextProps.selectedCurrency.currency,\n locale: nextProps.intl.locale,\n }),\n });\n }\n }\n\n isInputAllowedForKeyEvent = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const { metaKey, key, ctrlKey } = event;\n const isNumberKey = isNumber(Number.parseInt(key, 10));\n\n return isNumberKey || metaKey || ctrlKey || allowedInputKeys.has(key);\n };\n\n handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n if (!this.isInputAllowedForKeyEvent(event)) {\n event.preventDefault();\n }\n };\n\n handlePaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const paste = event.clipboardData.getData('text');\n const { locale } = this.state;\n const parsed = isEmpty(paste)\n ? null\n : parseNumber({\n amount: paste,\n currency: this.props.selectedCurrency.currency,\n locale,\n });\n\n if (isNumberOrNull(parsed)) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale,\n }),\n });\n this.props.onAmountChange?.(parsed);\n }\n\n event.preventDefault();\n };\n\n onAmountChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n this.setState({\n formattedAmount: value,\n });\n const parsed = isEmpty(value)\n ? null\n : parseNumber({\n amount: value,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n });\n if (isNumberOrNull(parsed)) {\n this.props.onAmountChange?.(parsed);\n }\n };\n\n onAmountBlur = () => {\n this.amountFocused = false;\n this.setAmount();\n };\n\n onAmountFocus = () => {\n this.amountFocused = true;\n };\n\n getSelectOptions() {\n const selectOptions = filterCurrenciesForQuery(this.props.currencies, this.state.searchQuery);\n\n const formattedOptions: SelectInputItem<CurrencyOptionItem>[] = [];\n let currentGroupOptions: SelectInputOptionItem<CurrencyOptionItem>[] | undefined;\n\n selectOptions.forEach((item) => {\n if (item.header != null) {\n currentGroupOptions = [];\n formattedOptions.push({\n type: 'group',\n label: item.header,\n options: currentGroupOptions,\n });\n } else {\n (currentGroupOptions ?? formattedOptions).push({\n type: 'option',\n value: item,\n filterMatchers: [item.value, item.label, item.note ?? '', item.searchable ?? ''],\n });\n }\n });\n\n return formattedOptions;\n }\n\n setAmount() {\n this.setState((previousState) => {\n const parsed = parseNumber({\n amount: previousState.formattedAmount,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n });\n if (!isNumberOrNull(parsed)) {\n return {\n formattedAmount: previousState.formattedAmount,\n };\n }\n return {\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n }),\n };\n });\n }\n\n handleSelectChange = (value: CurrencyOptionItem) => {\n this.handleSearchChange('');\n this.props.onCurrencyChange?.(value);\n };\n\n handleCustomAction = () => {\n this.handleSearchChange('');\n this.props.onCustomAction?.();\n };\n\n handleSearchChange = (searchQuery: string) => {\n this.setState({ searchQuery });\n this.props.onSearchChange?.({\n searchQuery,\n filteredOptions: filterCurrenciesForQuery(this.props.currencies, searchQuery),\n });\n };\n\n style = (className: string) => this.props.classNames[className] || className;\n\n render() {\n const {\n inputAttributes,\n id: amountInputId,\n 'aria-labelledby': ariaLabelledByProp,\n selectedCurrency,\n onCurrencyChange,\n size,\n addon,\n selectProps,\n } = this.props;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];\n const selectOptions = this.getSelectOptions();\n\n const hasSingleCurrency = () => {\n if (selectOptions.length !== 0) {\n const firstItem = selectOptions[0];\n\n if (selectOptions.length === 1) {\n if (firstItem.type === 'option') {\n return firstItem.value.currency === selectedCurrency.currency;\n }\n if (firstItem.type === 'group') {\n return (\n firstItem.options.length === 1 &&\n !(this.props.onCustomAction && this.props.customActionLabel)\n );\n }\n }\n } else if (selectedCurrency?.currency) {\n return true;\n }\n\n return false;\n };\n\n const isFixedCurrency = (!this.state.searchQuery && hasSingleCurrency()) || !onCurrencyChange;\n const disabled = !this.props.onAmountChange;\n const selectedCurrencyElementId = `${amountInputId}SelectedCurrency`;\n\n return (\n <div\n role=\"group\"\n {...inputAttributes}\n aria-labelledby={ariaLabelledBy}\n className={clsx(\n this.style('tw-money-input'),\n this.style('input-group'),\n this.style(`input-group-${size}`),\n )}\n >\n <Input\n id={amountInputId}\n value={this.state.formattedAmount}\n inputMode=\"decimal\"\n disabled={disabled}\n placeholder={formatAmountIfSet({\n amount: this.props.placeholder,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n })}\n autoComplete=\"off\"\n aria-describedby={selectedCurrencyElementId}\n onKeyDown={this.handleKeyDown}\n onChange={this.onAmountChange}\n onFocus={this.onAmountFocus}\n onBlur={this.onAmountBlur}\n onPaste={this.handlePaste}\n />\n {addon && (\n <span\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n disabled ? this.style('disabled') : '',\n )}\n >\n {addon}\n </span>\n )}\n {isFixedCurrency ? (\n <div\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n this.style('tw-money-input__fixed-currency'),\n disabled ? this.style('disabled') : '',\n )}\n id={selectedCurrencyElementId}\n >\n {(size === 'lg' || size === 'md') && (\n <span className={clsx(this.style('money-input-currency-flag'), this.style('m-r-2'))}>\n <Flag code={selectedCurrency.currency.toLowerCase()} intrinsicSize={24} />\n </span>\n )}\n <Title\n as=\"span\"\n type={Typography.TITLE_SUBSECTION}\n className={size === 'lg' ? this.style('m-r-1') : ''}\n >\n {selectedCurrency.currency.toUpperCase()}\n </Title>\n </div>\n ) : (\n <div\n className={clsx(\n this.style('input-group-btn'),\n this.style('amount-currency-select-btn'),\n )}\n >\n <SelectInput\n id={selectedCurrencyElementId}\n items={selectOptions}\n value={selectedCurrency}\n compareValues=\"currency\"\n renderValue={(currency, withinTrigger) => {\n return (\n <SelectInputOptionContent\n title={withinTrigger ? currency.currency.toUpperCase() : currency.label}\n note={withinTrigger ? undefined : currency.note}\n icon={<Flag code={currency.currency} intrinsicSize={24} />}\n />\n );\n }}\n renderFooter={\n this.props.onCustomAction\n ? () => (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div role=\"button\" tabIndex={0} onClick={this.handleCustomAction}>\n {this.props.customActionLabel}\n </div>\n )\n : undefined\n }\n placeholder={this.props.intl.formatMessage(messages.selectPlaceholder)}\n filterable\n filterPlaceholder={this.props.searchPlaceholder}\n disabled={disabled}\n size={size}\n onChange={this.handleSelectChange}\n onFilterChange={({ queryNormalized }) => {\n this.handleSearchChange(queryNormalized ?? '');\n }}\n {...selectProps}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nfunction filterCurrenciesForQuery(\n currencies: readonly CurrencyItem[],\n query: string,\n): CurrencyItem[] {\n if (!query) {\n return [...currencies];\n }\n\n const options = currencies.filter(\n (option): option is CurrencyOptionItem => option.header == null,\n );\n const filteredOptions = removeDuplicateValueOptions(options).filter((option) =>\n currencyOptionFitsQuery(option, query),\n );\n\n return sortOptionsLabelsToFirst(filteredOptions, query);\n}\n\nfunction removeDuplicateValueOptions(options: readonly CurrencyOptionItem[]) {\n const uniqueValues = new Set<string>();\n return options.filter((option) => {\n if (!uniqueValues.has(option.value)) {\n uniqueValues.add(option.value);\n return true;\n }\n return false;\n });\n}\n\nfunction currencyOptionFitsQuery(option: CurrencyOptionItem, query: string) {\n if (!option.value) {\n return false;\n }\n\n return (\n contains(option.label, query) ||\n contains(option.searchable, query) ||\n contains(option.note, query)\n );\n}\n\nfunction contains(property: string | undefined, query: string) {\n return property?.toLowerCase().includes(query.toLowerCase());\n}\n\nfunction sortOptionsLabelsToFirst(options: readonly CurrencyOptionItem[], query: string) {\n return [...options].sort((first, second) => {\n const firstContains = contains(first.label, query);\n const secondContains = contains(second.label, query);\n\n if (firstContains && secondContains) {\n return 0;\n }\n if (firstContains) {\n return -1;\n }\n if (secondContains) {\n return 1;\n }\n return 0;\n });\n}\n\nexport default injectIntl(withId(withInputAttributes(MoneyInput, { nonLabelable: true })));\n"],"names":["isNumberOrNull","v","isNumber","isNull","formatAmountIfSet","amount","currency","locale","formatAmount","parseNumber","parseAmount","allowedInputKeys","Set","MoneyInput","Component","defaultProps","size","Size","LARGE","classNames","selectProps","amountFocused","constructor","props","state","searchQuery","formattedAmount","selectedCurrency","intl","UNSAFE_componentWillReceiveProps","nextProps","setState","isInputAllowedForKeyEvent","event","metaKey","key","ctrlKey","isNumberKey","Number","parseInt","has","handleKeyDown","preventDefault","handlePaste","paste","clipboardData","getData","parsed","isEmpty","onAmountChange","value","target","onAmountBlur","setAmount","onAmountFocus","getSelectOptions","selectOptions","filterCurrenciesForQuery","currencies","formattedOptions","currentGroupOptions","forEach","item","header","push","type","label","options","filterMatchers","note","searchable","previousState","handleSelectChange","handleSearchChange","onCurrencyChange","handleCustomAction","onCustomAction","onSearchChange","filteredOptions","style","className","render","inputAttributes","id","amountInputId","ariaLabelledByProp","addon","ariaLabelledBy","hasSingleCurrency","length","firstItem","customActionLabel","isFixedCurrency","disabled","selectedCurrencyElementId","_jsxs","role","clsx","children","_jsx","Input","inputMode","placeholder","autoComplete","onKeyDown","onChange","onFocus","onBlur","onPaste","Flag","code","toLowerCase","intrinsicSize","Title","as","Typography","TITLE_SUBSECTION","toUpperCase","SelectInput","items","compareValues","renderValue","withinTrigger","SelectInputOptionContent","title","undefined","icon","renderFooter","tabIndex","onClick","formatMessage","messages","selectPlaceholder","filterable","filterPlaceholder","searchPlaceholder","onFilterChange","queryNormalized","query","filter","option","removeDuplicateValueOptions","currencyOptionFitsQuery","sortOptionsLabelsToFirst","uniqueValues","add","contains","property","includes","sort","first","second","firstContains","secondContains","injectIntl","withId","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;AAqCA,MAAMA,cAAc,GAAIC,CAAU,IAAyBC,QAAQ,CAACD,CAAC,CAAC,IAAIE,MAAM,CAACF,CAAC,CAAC,CAAA;AAEnF,MAAMG,iBAAiB,GAAGA,CAAC;EACzBC,MAAM;EACNC,QAAQ;AACRC,EAAAA,MAAAA;AAKD,CAAA,KAAI;AACH,EAAA,OAAO,OAAOF,MAAM,KAAK,QAAQ,GAAGG,YAAY,CAACH,MA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;IAEpD,IAAIc,aAAa,IAAIC,cAAc,EAAE;AACnC,MAAA,OAAO,CAAC,CAAA;AACV,KAAA;AACA,IAAA,IAAID,aAAa,EAAE;AACjB,MAAA,OAAO,CAAC,CAAC,CAAA;AACX,KAAA;AACA,IAAA,IAAIC,cAAc,EAAE;AAClB,MAAA,OAAO,CAAC,CAAA;AACV,KAAA;AACA,IAAA,OAAO,CAAC,CAAA;AACV,GAAC,CAAC,CAAA;AACJ,CAAA;AAEA,mBAAeC,UAAU,CAACC,MAAM,CAACC,mBAAmB,CAAC/I,UAAU,EAAE;AAAEgJ,EAAAA,YAAY,EAAE,IAAA;AAAI,CAAE,CAAC,CAAC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"MoneyInput.mjs","sources":["../../src/moneyInput/MoneyInput.tsx"],"sourcesContent":["import { isEmpty, isNumber, isNull } from '@transferwise/neptune-validation';\nimport { Flag } from '@wise/art';\nimport { clsx } from 'clsx';\nimport { Component } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport { Typography, Size, SizeLarge, SizeMedium, SizeSmall } from '../common';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputItem,\n SelectInputOptionContent,\n SelectInputOptionItem,\n SelectInputProps,\n} from '../inputs/SelectInput';\nimport Title from '../title';\n\nimport messages from './MoneyInput.messages';\nimport { formatAmount, parseAmount } from './currencyFormatting';\nimport withId from '../withId';\n\nexport interface CurrencyOptionItem {\n header?: never;\n value: string;\n label: string;\n currency: string;\n note?: string;\n searchable?: string;\n}\n\nexport interface CurrencyHeaderItem {\n header: string;\n}\n\nexport type CurrencyItem = CurrencyOptionItem | CurrencyHeaderItem;\n\nconst isNumberOrNull = (v: unknown): v is number | null => isNumber(v) || isNull(v);\n\nconst formatAmountIfSet = ({\n amount,\n currency,\n locale,\n}: {\n amount: number | null | undefined;\n currency: string;\n locale: string;\n}) => {\n return typeof amount === 'number' ? formatAmount(amount, currency, locale) : '';\n};\n\nconst parseNumber = ({\n amount,\n currency,\n locale,\n}: {\n amount: string;\n currency: string;\n locale: string;\n}) => {\n return parseAmount(amount, currency, locale);\n};\n\nconst allowedInputKeys = new Set([\n 'Backspace',\n 'Delete',\n ',',\n '.',\n 'ArrowDown',\n 'ArrowUp',\n 'ArrowLeft',\n 'ArrowRight',\n 'Enter',\n 'Escape',\n 'Tab',\n]);\n\nexport interface MoneyInputProps extends WrappedComponentProps {\n id?: string;\n 'aria-labelledby'?: string;\n currencies: readonly CurrencyItem[];\n selectedCurrency: CurrencyOptionItem;\n onCurrencyChange?: (value: CurrencyOptionItem) => void;\n placeholder?: number;\n amount: number | null;\n size?: SizeSmall | SizeMedium | SizeLarge;\n onAmountChange?: (value: number | null) => void;\n addon?: React.ReactNode;\n searchPlaceholder?: string;\n /**\n * Allows the consumer to react to searching, while the search itself is handled internally.\n */\n onSearchChange?: (value: { searchQuery: string; filteredOptions: CurrencyItem[] }) => void;\n customActionLabel?: React.ReactNode;\n onCustomAction?: () => void;\n classNames?: Record<string, string>;\n selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;\n}\n\ntype MoneyInputPropsWithInputAttributes = MoneyInputProps & Partial<WithInputAttributesProps>;\n\ninterface MoneyInputState {\n searchQuery: string;\n formattedAmount: string;\n locale: string;\n}\n\nclass MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInputState> {\n declare props: MoneyInputPropsWithInputAttributes &\n Required<Pick<MoneyInputPropsWithInputAttributes, keyof typeof MoneyInput.defaultProps>>;\n\n static defaultProps = {\n size: Size.LARGE,\n classNames: {},\n selectProps: {},\n } satisfies Partial<MoneyInputPropsWithInputAttributes>;\n\n amountFocused = false;\n\n constructor(props: MoneyInputProps) {\n super(props);\n this.state = {\n searchQuery: '',\n formattedAmount: formatAmountIfSet({\n amount: props.amount,\n currency: props.selectedCurrency.currency,\n locale: props.intl.locale,\n }),\n locale: props.intl.locale,\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps: MoneyInputProps) {\n this.setState({ locale: nextProps.intl.locale });\n\n if (!this.amountFocused) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: nextProps.amount,\n currency: nextProps.selectedCurrency.currency,\n locale: nextProps.intl.locale,\n }),\n });\n }\n }\n\n isInputAllowedForKeyEvent = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const { metaKey, key, ctrlKey } = event;\n const isNumberKey = isNumber(Number.parseInt(key, 10));\n\n return isNumberKey || metaKey || ctrlKey || allowedInputKeys.has(key);\n };\n\n handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n if (!this.isInputAllowedForKeyEvent(event)) {\n event.preventDefault();\n }\n };\n\n handlePaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const paste = event.clipboardData.getData('text');\n const { locale } = this.state;\n const parsed = isEmpty(paste)\n ? null\n : parseNumber({\n amount: paste,\n currency: this.props.selectedCurrency.currency,\n locale,\n });\n\n if (isNumberOrNull(parsed)) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale,\n }),\n });\n this.props.onAmountChange?.(parsed);\n }\n\n event.preventDefault();\n };\n\n onAmountChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n this.setState({\n formattedAmount: value,\n });\n const parsed = isEmpty(value)\n ? null\n : parseNumber({\n amount: value,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n });\n if (isNumberOrNull(parsed)) {\n this.props.onAmountChange?.(parsed);\n }\n };\n\n onAmountBlur = () => {\n this.amountFocused = false;\n this.setAmount();\n };\n\n onAmountFocus = () => {\n this.amountFocused = true;\n };\n\n getSelectOptions() {\n const selectOptions = filterCurrenciesForQuery(this.props.currencies, this.state.searchQuery);\n\n const formattedOptions: SelectInputItem<CurrencyOptionItem>[] = [];\n let currentGroupOptions: SelectInputOptionItem<CurrencyOptionItem>[] | undefined;\n\n selectOptions.forEach((item) => {\n if (item.header != null) {\n currentGroupOptions = [];\n formattedOptions.push({\n type: 'group',\n label: item.header,\n options: currentGroupOptions,\n });\n } else {\n (currentGroupOptions ?? formattedOptions).push({\n type: 'option',\n value: item,\n filterMatchers: [item.value, item.label, item.note ?? '', item.searchable ?? ''],\n });\n }\n });\n\n return formattedOptions;\n }\n\n setAmount() {\n this.setState((previousState) => {\n const parsed = parseNumber({\n amount: previousState.formattedAmount,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n });\n if (!isNumberOrNull(parsed)) {\n return {\n formattedAmount: previousState.formattedAmount,\n };\n }\n return {\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n }),\n };\n });\n }\n\n handleSelectChange = (value: CurrencyOptionItem) => {\n this.handleSearchChange('');\n this.props.onCurrencyChange?.(value);\n };\n\n handleCustomAction = () => {\n this.handleSearchChange('');\n this.props.onCustomAction?.();\n };\n\n handleSearchChange = (searchQuery: string) => {\n this.setState({ searchQuery });\n this.props.onSearchChange?.({\n searchQuery,\n filteredOptions: filterCurrenciesForQuery(this.props.currencies, searchQuery),\n });\n };\n\n style = (className: string) => this.props.classNames[className] || className;\n\n render() {\n const {\n inputAttributes,\n id: amountInputId,\n 'aria-labelledby': ariaLabelledByProp,\n selectedCurrency,\n onCurrencyChange,\n size,\n addon,\n selectProps,\n } = this.props;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];\n const selectOptions = this.getSelectOptions();\n\n const hasSingleCurrency = () => {\n if (selectOptions.length !== 0) {\n const firstItem = selectOptions[0];\n\n if (selectOptions.length === 1) {\n if (firstItem.type === 'option') {\n return firstItem.value.currency === selectedCurrency.currency;\n }\n if (firstItem.type === 'group') {\n return (\n firstItem.options.length === 1 &&\n !(this.props.onCustomAction && this.props.customActionLabel)\n );\n }\n }\n } else if (selectedCurrency?.currency) {\n return true;\n }\n\n return false;\n };\n\n const isFixedCurrency = (!this.state.searchQuery && hasSingleCurrency()) || !onCurrencyChange;\n const disabled = !this.props.onAmountChange;\n const selectedCurrencyElementId = `${inputAttributes?.id ?? amountInputId}SelectedCurrency`;\n\n return (\n <div\n role=\"group\"\n {...inputAttributes}\n aria-labelledby={ariaLabelledBy}\n className={clsx(\n this.style('tw-money-input'),\n this.style('input-group'),\n this.style(`input-group-${size}`),\n )}\n >\n <Input\n id={amountInputId}\n value={this.state.formattedAmount}\n inputMode=\"decimal\"\n disabled={disabled}\n placeholder={formatAmountIfSet({\n amount: this.props.placeholder,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n })}\n autoComplete=\"off\"\n aria-describedby={selectedCurrencyElementId}\n onKeyDown={this.handleKeyDown}\n onChange={this.onAmountChange}\n onFocus={this.onAmountFocus}\n onBlur={this.onAmountBlur}\n onPaste={this.handlePaste}\n />\n {addon && (\n <span\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n disabled ? this.style('disabled') : '',\n )}\n >\n {addon}\n </span>\n )}\n {isFixedCurrency ? (\n <div\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n this.style('tw-money-input__fixed-currency'),\n disabled ? this.style('disabled') : '',\n )}\n id={selectedCurrencyElementId}\n >\n {(size === 'lg' || size === 'md') && (\n <span className={clsx(this.style('money-input-currency-flag'), this.style('m-r-2'))}>\n <Flag code={selectedCurrency.currency.toLowerCase()} intrinsicSize={24} />\n </span>\n )}\n <Title\n as=\"span\"\n type={Typography.TITLE_SUBSECTION}\n className={size === 'lg' ? this.style('m-r-1') : ''}\n >\n {selectedCurrency.currency.toUpperCase()}\n </Title>\n </div>\n ) : (\n <div\n className={clsx(\n this.style('input-group-btn'),\n this.style('amount-currency-select-btn'),\n )}\n >\n <SelectInput\n UNSAFE_triggerButtonProps={{\n id: undefined,\n 'aria-labelledby': undefined,\n 'aria-describedby': undefined,\n 'aria-invalid': undefined,\n 'aria-label': this.props.intl.formatMessage(messages.selectCurrencyLabel),\n }}\n id={selectedCurrencyElementId}\n items={selectOptions}\n value={selectedCurrency}\n compareValues=\"currency\"\n renderValue={(currency, withinTrigger) => {\n return (\n <SelectInputOptionContent\n title={withinTrigger ? currency.currency.toUpperCase() : currency.label}\n note={withinTrigger ? undefined : currency.note}\n icon={<Flag code={currency.currency} intrinsicSize={24} />}\n />\n );\n }}\n renderFooter={\n this.props.onCustomAction\n ? () => (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div role=\"button\" tabIndex={0} onClick={this.handleCustomAction}>\n {this.props.customActionLabel}\n </div>\n )\n : undefined\n }\n placeholder={this.props.intl.formatMessage(messages.selectPlaceholder)}\n filterable\n filterPlaceholder={this.props.searchPlaceholder}\n disabled={disabled}\n size={size}\n onChange={this.handleSelectChange}\n onFilterChange={({ queryNormalized }) => {\n this.handleSearchChange(queryNormalized ?? '');\n }}\n {...selectProps}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nfunction filterCurrenciesForQuery(\n currencies: readonly CurrencyItem[],\n query: string,\n): CurrencyItem[] {\n if (!query) {\n return [...currencies];\n }\n\n const options = currencies.filter(\n (option): option is CurrencyOptionItem => option.header == null,\n );\n const filteredOptions = removeDuplicateValueOptions(options).filter((option) =>\n currencyOptionFitsQuery(option, query),\n );\n\n return sortOptionsLabelsToFirst(filteredOptions, query);\n}\n\nfunction removeDuplicateValueOptions(options: readonly CurrencyOptionItem[]) {\n const uniqueValues = new Set<string>();\n return options.filter((option) => {\n if (!uniqueValues.has(option.value)) {\n uniqueValues.add(option.value);\n return true;\n }\n return false;\n });\n}\n\nfunction currencyOptionFitsQuery(option: CurrencyOptionItem, query: string) {\n if (!option.value) {\n return false;\n }\n\n return (\n contains(option.label, query) ||\n contains(option.searchable, query) ||\n contains(option.note, query)\n );\n}\n\nfunction contains(property: string | undefined, query: string) {\n return property?.toLowerCase().includes(query.toLowerCase());\n}\n\nfunction sortOptionsLabelsToFirst(options: readonly CurrencyOptionItem[], query: string) {\n return [...options].sort((first, second) => {\n const firstContains = contains(first.label, query);\n const secondContains = contains(second.label, query);\n\n if (firstContains && secondContains) {\n return 0;\n }\n if (firstContains) {\n return -1;\n }\n if (secondContains) {\n return 1;\n }\n return 0;\n });\n}\n\nexport default injectIntl(withId(withInputAttributes(MoneyInput, { nonLabelable: true })));\n"],"names":["isNumberOrNull","v","isNumber","isNull","formatAmountIfSet","amount","currency","locale","formatAmount","parseNumber","parseAmount","allowedInputKeys","Set","MoneyInput","Component","defaultProps","size","Size","LARGE","classNames","selectProps","amountFocused","constructor","props","state","searchQuery","formattedAmount","selectedCurrency","intl","UNSAFE_componentWillReceiveProps","nextProps","setState","isInputAllowedForKeyEvent","event","metaKey","key","ctrlKey","isNumberKey","Number","parseInt","has","handleKeyDown","preventDefault","handlePaste","paste","clipboardData","getData","parsed","isEmpty","onAmountChange","value","target","onAmountBlur","setAmount","onAmountFocus","getSelectOptions","selectOptions","filterCurrenciesForQuery","currencies","formattedOptions","currentGroupOptions","forEach","item","header","push","type","label","options","filterMatchers","note","searchable","previousState","handleSelectChange","handleSearchChange","onCurrencyChange","handleCustomAction","onCustomAction","onSearchChange","filteredOptions","style","className","render","inputAttributes","id","amountInputId","ariaLabelledByProp","addon","ariaLabelledBy","hasSingleCurrency","length","firstItem","customActionLabel","isFixedCurrency","disabled","selectedCurrencyElementId","_jsxs","role","clsx","children","_jsx","Input","inputMode","placeholder","autoComplete","onKeyDown","onChange","onFocus","onBlur","onPaste","Flag","code","toLowerCase","intrinsicSize","Title","as","Typography","TITLE_SUBSECTION","toUpperCase","SelectInput","UNSAFE_triggerButtonProps","undefined","formatMessage","messages","selectCurrencyLabel","items","compareValues","renderValue","withinTrigger","SelectInputOptionContent","title","icon","renderFooter","tabIndex","onClick","selectPlaceholder","filterable","filterPlaceholder","searchPlaceholder","onFilterChange","queryNormalized","query","filter","option","removeDuplicateValueOptions","currencyOptionFitsQuery","sortOptionsLabelsToFirst","uniqueValues","add","contains","property","includes","sort","first","second","firstContains","secondContains","inj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QAAQ,CAACN,MAAM,CAACxE,UAAU,EAAEsE,KAAK,CAAC,IAClCQ,QAAQ,CAACN,MAAM,CAACzE,IAAI,EAAEuE,KAAK,CAAC,CAAA;AAEhC,CAAA;AAEA,SAASQ,QAAQA,CAACC,QAA4B,EAAET,KAAa,EAAA;AAC3D,EAAA,OAAOS,QAAQ,EAAEtC,WAAW,EAAE,CAACuC,QAAQ,CAACV,KAAK,CAAC7B,WAAW,EAAE,CAAC,CAAA;AAC9D,CAAA;AAEA,SAASkC,wBAAwBA,CAAC9E,OAAsC,EAAEyE,KAAa,EAAA;EACrF,OAAO,CAAC,GAAGzE,OAAO,CAAC,CAACoF,IAAI,CAAC,CAACC,KAAK,EAAEC,MAAM,KAAI;IACzC,MAAMC,aAAa,GAAGN,QAAQ,CAACI,KAAK,CAACtF,KAAK,EAAE0E,KAAK,CAAC,CAAA;IAClD,MAAMe,cAAc,GAAGP,QAAQ,CAACK,MAAM,CAACvF,KAAK,EAAE0E,KAAK,CAAC,CAAA;IAEpD,IAAIc,aAAa,IAAIC,cAAc,EAAE;AACnC,MAAA,OAAO,CAAC,CAAA;AACV,KAAA;AACA,IAAA,IAAID,aAAa,EAAE;AACjB,MAAA,OAAO,CAAC,CAAC,CAAA;AACX,KAAA;AACA,IAAA,IAAIC,cAAc,EAAE;AAClB,MAAA,OAAO,CAAC,CAAA;AACV,KAAA;AACA,IAAA,OAAO,CAAC,CAAA;AACV,GAAC,CAAC,CAAA;AACJ,CAAA;AAEA,mBAAeC,UAAU,CAACC,MAAM,CAACC,mBAAmB,CAACjJ,UAAU,EAAE;AAAEkJ,EAAAA,YAAY,EAAE,IAAA;AAAI,CAAE,CAAC,CAAC,CAAC;;;;"}
|
package/build/stepper/Stepper.js
CHANGED
|
@@ -29,6 +29,17 @@ const Stepper = ({
|
|
|
29
29
|
const activeStepIndex = clamp(0, steps.length - 1, activeStep);
|
|
30
30
|
const stepPercentage = 1 / (steps.length - 1);
|
|
31
31
|
const percentageCompleted = activeStepIndex / (steps.length - 1);
|
|
32
|
+
const getProgressWidth = () => {
|
|
33
|
+
if (percentageCompleted === 0) {
|
|
34
|
+
return '0px';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Progress bar starts with left/right (depends on rtl) shift `--progress-bar-start-shift` for hiding Progress bar's left and right borders
|
|
38
|
+
* which are used for progress vertical delimiter.
|
|
39
|
+
* When progress is completed, we need to add `--progress-bar-border-width` to the width to allow the right border be outside of the progress area.
|
|
40
|
+
*/
|
|
41
|
+
return `calc(${percentageCompleted * 100}% + var(--progress-bar-start-shift) + var(--progress-bar-border-width))`;
|
|
42
|
+
};
|
|
32
43
|
const renderStep = (step, index) => {
|
|
33
44
|
const active = index === activeStepIndex;
|
|
34
45
|
const clickable = step.onClick && !active;
|
|
@@ -65,7 +76,7 @@ const Stepper = ({
|
|
|
65
76
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
66
77
|
className: "progress-bar",
|
|
67
78
|
style: {
|
|
68
|
-
width:
|
|
79
|
+
width: getProgressWidth()
|
|
69
80
|
}
|
|
70
81
|
})
|
|
71
82
|
}), /*#__PURE__*/jsxRuntime.jsx("ol", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.js","sources":["../../src/stepper/Stepper.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport * as React from 'react';\n\nimport { Position } from '../common';\nimport { useDirection } from '../common/hooks';\nimport Tooltip from '../tooltip';\n\nimport { isTouchDevice } from './deviceDetection';\n\nfunction clamp(from: number, to: number, value: number) {\n return Math.max(Math.min(to, value), from);\n}\n\nexport interface Step {\n label: React.ReactNode;\n onClick?: () => void;\n hoverLabel?: React.ReactNode;\n}\n\nexport interface StepperProps {\n steps: readonly Step[];\n activeStep?: number;\n className?: string;\n}\n\n/**\n * This component is considered user-unfriendly and inaccessible on its own and will likely be made internal in the future. Please use `FlowNavigation` instead.\n * @see https://storybook.wise.design/?path=/story/navigation-flownavigation--variants\n */\nconst Stepper = ({ steps, activeStep = 0, className }: StepperProps) => {\n const { isRTL } = useDirection();\n\n if (steps.length === 0) {\n return null;\n }\n\n const activeStepIndex = clamp(0, steps.length - 1, activeStep);\n const stepPercentage = 1 / (steps.length - 1);\n const percentageCompleted = activeStepIndex / (steps.length - 1);\n\n const renderStep = (step: Step, index: number) => {\n const active = index === activeStepIndex;\n const clickable = step.onClick && !active;\n\n const labelButton = clickable ? (\n <button\n type=\"button\"\n className=\"btn-unstyled tw-stepper__step-label\"\n onClick={() => clickable && step.onClick?.()}\n >\n <small>{step.label}</small>\n </button>\n ) : (\n <span className=\"tw-stepper__step-label\">{step.label}</span>\n );\n\n return (\n <li\n key={index}\n className={clsx(\n 'hidden-xs',\n 'tw-stepper__step',\n active ? 'np-text-body-default-bold tw-stepper__step--active' : 'np-text-body-default',\n clickable && 'tw-stepper__step--clickable',\n step.hoverLabel && 'tw-stepper__step--has-tooltip',\n )}\n aria-current={active ? 'step' : false}\n style={\n isRTL\n ? { right: `${index * stepPercentage * 100}%` }\n : { left: `${index * stepPercentage * 100}%` }\n }\n >\n {step.hoverLabel && !isTouchDevice() ? (\n <Tooltip position={Position.BOTTOM} label={step.hoverLabel}>\n {labelButton}\n </Tooltip>\n ) : (\n labelButton\n )}\n </li>\n );\n };\n\n return (\n <div className={clsx('tw-stepper', className)}>\n <div className=\"progress\">\n <div className=\"progress-bar\" style={{ width:
|
|
1
|
+
{"version":3,"file":"Stepper.js","sources":["../../src/stepper/Stepper.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport * as React from 'react';\n\nimport { Position } from '../common';\nimport { useDirection } from '../common/hooks';\nimport Tooltip from '../tooltip';\n\nimport { isTouchDevice } from './deviceDetection';\n\nfunction clamp(from: number, to: number, value: number) {\n return Math.max(Math.min(to, value), from);\n}\n\nexport interface Step {\n label: React.ReactNode;\n onClick?: () => void;\n hoverLabel?: React.ReactNode;\n}\n\nexport interface StepperProps {\n steps: readonly Step[];\n activeStep?: number;\n className?: string;\n}\n\n/**\n * This component is considered user-unfriendly and inaccessible on its own and will likely be made internal in the future. Please use `FlowNavigation` instead.\n * @see https://storybook.wise.design/?path=/story/navigation-flownavigation--variants\n */\nconst Stepper = ({ steps, activeStep = 0, className }: StepperProps) => {\n const { isRTL } = useDirection();\n\n if (steps.length === 0) {\n return null;\n }\n\n const activeStepIndex = clamp(0, steps.length - 1, activeStep);\n const stepPercentage = 1 / (steps.length - 1);\n const percentageCompleted = activeStepIndex / (steps.length - 1);\n\n const getProgressWidth = (): string => {\n if (percentageCompleted === 0) {\n return '0px';\n }\n /**\n * Progress bar starts with left/right (depends on rtl) shift `--progress-bar-start-shift` for hiding Progress bar's left and right borders\n * which are used for progress vertical delimiter.\n * When progress is completed, we need to add `--progress-bar-border-width` to the width to allow the right border be outside of the progress area.\n */\n return `calc(${percentageCompleted * 100}% + var(--progress-bar-start-shift) + var(--progress-bar-border-width))`;\n };\n\n const renderStep = (step: Step, index: number) => {\n const active = index === activeStepIndex;\n const clickable = step.onClick && !active;\n\n const labelButton = clickable ? (\n <button\n type=\"button\"\n className=\"btn-unstyled tw-stepper__step-label\"\n onClick={() => clickable && step.onClick?.()}\n >\n <small>{step.label}</small>\n </button>\n ) : (\n <span className=\"tw-stepper__step-label\">{step.label}</span>\n );\n\n return (\n <li\n key={index}\n className={clsx(\n 'hidden-xs',\n 'tw-stepper__step',\n active ? 'np-text-body-default-bold tw-stepper__step--active' : 'np-text-body-default',\n clickable && 'tw-stepper__step--clickable',\n step.hoverLabel && 'tw-stepper__step--has-tooltip',\n )}\n aria-current={active ? 'step' : false}\n style={\n isRTL\n ? { right: `${index * stepPercentage * 100}%` }\n : { left: `${index * stepPercentage * 100}%` }\n }\n >\n {step.hoverLabel && !isTouchDevice() ? (\n <Tooltip position={Position.BOTTOM} label={step.hoverLabel}>\n {labelButton}\n </Tooltip>\n ) : (\n labelButton\n )}\n </li>\n );\n };\n\n return (\n <div className={clsx('tw-stepper', className)}>\n <div className=\"progress\">\n <div className=\"progress-bar\" style={{ width: getProgressWidth() }} />\n </div>\n <ol className=\"tw-stepper-steps p-t-1 m-b-0\">{steps.map(renderStep)}</ol>\n </div>\n );\n};\n\nexport default Stepper;\n"],"names":["clamp","from","to","value","Math","max","min","Stepper","steps","activeStep","className","isRTL","useDirection","length","activeStepIndex","stepPercentage","percentageCompleted","getProgressWidth","renderStep","step","index","active","clickable","onClick","labelButton","_jsx","type","children","label","clsx","hoverLabel","style","right","left","isTouchDevice","Tooltip","position","Position","BOTTOM","_jsxs","width","map"],"mappings":";;;;;;;;;;AASA,SAASA,KAAKA,CAACC,IAAY,EAAEC,EAAU,EAAEC,KAAa,EAAA;AACpD,EAAA,OAAOC,IAAI,CAACC,GAAG,CAACD,IAAI,CAACE,GAAG,CAACJ,EAAE,EAAEC,KAAK,CAAC,EAAEF,IAAI,CAAC,CAAA;AAC5C,CAAA;AAcA;;;AAGG;AACGM,MAAAA,OAAO,GAAGA,CAAC;EAAEC,KAAK;AAAEC,EAAAA,UAAU,GAAG,CAAC;AAAEC,EAAAA,SAAAA;AAAS,CAAgB,KAAI;EACrE,MAAM;AAAEC,IAAAA,KAAAA;GAAO,GAAGC,yBAAY,EAAE,CAAA;AAEhC,EAAA,IAAIJ,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;AACtB,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AAEA,EAAA,MAAMC,eAAe,GAAGd,KAAK,CAAC,CAAC,EAAEQ,KAAK,CAACK,MAAM,GAAG,CAAC,EAAEJ,UAAU,CAAC,CAAA;EAC9D,MAAMM,cAAc,GAAG,CAAC,IAAIP,KAAK,CAACK,MAAM,GAAG,CAAC,CAAC,CAAA;EAC7C,MAAMG,mBAAmB,GAAGF,eAAe,IAAIN,KAAK,CAACK,MAAM,GAAG,CAAC,CAAC,CAAA;EAEhE,MAAMI,gBAAgB,GAAGA,MAAa;IACpC,IAAID,mBAAmB,KAAK,CAAC,EAAE;AAC7B,MAAA,OAAO,KAAK,CAAA;AACd,KAAA;AAC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AAG,GAAG,CAAA,CAAA,CAAA;OAC5C;AAAAY,MAAAA,QAAA,EAEAR,IAAI,CAACW,UAAU,IAAI,CAACI,6BAAa,EAAE,gBAClCT,cAAA,CAACU,OAAO,EAAA;QAACC,QAAQ,EAAEC,iBAAQ,CAACC,MAAO;QAACV,KAAK,EAAET,IAAI,CAACW,UAAW;AAAAH,QAAAA,QAAA,EACxDH,WAAAA;AAAW,OACL,CAAC,GAEVA,WAAAA;AACD,KAAA,EArBIJ,KAsBH,CAAC,CAAA;GAER,CAAA;AAED,EAAA,oBACEmB,eAAA,CAAA,KAAA,EAAA;AAAK7B,IAAAA,SAAS,EAAEmB,SAAI,CAAC,YAAY,EAAEnB,SAAS,CAAE;AAAAiB,IAAAA,QAAA,gBAC5CF,cAAA,CAAA,KAAA,EAAA;AAAKf,MAAAA,SAAS,EAAC,UAAU;AAAAiB,MAAAA,QAAA,eACvBF,cAAA,CAAA,KAAA,EAAA;AAAKf,QAAAA,SAAS,EAAC,cAAc;AAACqB,QAAAA,KAAK,EAAE;UAAES,KAAK,EAAEvB,gBAAgB,EAAE;AAAA,SAAA;OAClE,CAAA;KAAK,CACL,eAAAQ,cAAA,CAAA,IAAA,EAAA;AAAIf,MAAAA,SAAS,EAAC,8BAA8B;AAAAiB,MAAAA,QAAA,EAAEnB,KAAK,CAACiC,GAAG,CAACvB,UAAU,CAAA;AAAC,KAAK,CAC1E,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV;;;;"}
|
|
@@ -27,6 +27,17 @@ const Stepper = ({
|
|
|
27
27
|
const activeStepIndex = clamp(0, steps.length - 1, activeStep);
|
|
28
28
|
const stepPercentage = 1 / (steps.length - 1);
|
|
29
29
|
const percentageCompleted = activeStepIndex / (steps.length - 1);
|
|
30
|
+
const getProgressWidth = () => {
|
|
31
|
+
if (percentageCompleted === 0) {
|
|
32
|
+
return '0px';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Progress bar starts with left/right (depends on rtl) shift `--progress-bar-start-shift` for hiding Progress bar's left and right borders
|
|
36
|
+
* which are used for progress vertical delimiter.
|
|
37
|
+
* When progress is completed, we need to add `--progress-bar-border-width` to the width to allow the right border be outside of the progress area.
|
|
38
|
+
*/
|
|
39
|
+
return `calc(${percentageCompleted * 100}% + var(--progress-bar-start-shift) + var(--progress-bar-border-width))`;
|
|
40
|
+
};
|
|
30
41
|
const renderStep = (step, index) => {
|
|
31
42
|
const active = index === activeStepIndex;
|
|
32
43
|
const clickable = step.onClick && !active;
|
|
@@ -63,7 +74,7 @@ const Stepper = ({
|
|
|
63
74
|
children: /*#__PURE__*/jsx("div", {
|
|
64
75
|
className: "progress-bar",
|
|
65
76
|
style: {
|
|
66
|
-
width:
|
|
77
|
+
width: getProgressWidth()
|
|
67
78
|
}
|
|
68
79
|
})
|
|
69
80
|
}), /*#__PURE__*/jsx("ol", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.mjs","sources":["../../src/stepper/Stepper.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport * as React from 'react';\n\nimport { Position } from '../common';\nimport { useDirection } from '../common/hooks';\nimport Tooltip from '../tooltip';\n\nimport { isTouchDevice } from './deviceDetection';\n\nfunction clamp(from: number, to: number, value: number) {\n return Math.max(Math.min(to, value), from);\n}\n\nexport interface Step {\n label: React.ReactNode;\n onClick?: () => void;\n hoverLabel?: React.ReactNode;\n}\n\nexport interface StepperProps {\n steps: readonly Step[];\n activeStep?: number;\n className?: string;\n}\n\n/**\n * This component is considered user-unfriendly and inaccessible on its own and will likely be made internal in the future. Please use `FlowNavigation` instead.\n * @see https://storybook.wise.design/?path=/story/navigation-flownavigation--variants\n */\nconst Stepper = ({ steps, activeStep = 0, className }: StepperProps) => {\n const { isRTL } = useDirection();\n\n if (steps.length === 0) {\n return null;\n }\n\n const activeStepIndex = clamp(0, steps.length - 1, activeStep);\n const stepPercentage = 1 / (steps.length - 1);\n const percentageCompleted = activeStepIndex / (steps.length - 1);\n\n const renderStep = (step: Step, index: number) => {\n const active = index === activeStepIndex;\n const clickable = step.onClick && !active;\n\n const labelButton = clickable ? (\n <button\n type=\"button\"\n className=\"btn-unstyled tw-stepper__step-label\"\n onClick={() => clickable && step.onClick?.()}\n >\n <small>{step.label}</small>\n </button>\n ) : (\n <span className=\"tw-stepper__step-label\">{step.label}</span>\n );\n\n return (\n <li\n key={index}\n className={clsx(\n 'hidden-xs',\n 'tw-stepper__step',\n active ? 'np-text-body-default-bold tw-stepper__step--active' : 'np-text-body-default',\n clickable && 'tw-stepper__step--clickable',\n step.hoverLabel && 'tw-stepper__step--has-tooltip',\n )}\n aria-current={active ? 'step' : false}\n style={\n isRTL\n ? { right: `${index * stepPercentage * 100}%` }\n : { left: `${index * stepPercentage * 100}%` }\n }\n >\n {step.hoverLabel && !isTouchDevice() ? (\n <Tooltip position={Position.BOTTOM} label={step.hoverLabel}>\n {labelButton}\n </Tooltip>\n ) : (\n labelButton\n )}\n </li>\n );\n };\n\n return (\n <div className={clsx('tw-stepper', className)}>\n <div className=\"progress\">\n <div className=\"progress-bar\" style={{ width:
|
|
1
|
+
{"version":3,"file":"Stepper.mjs","sources":["../../src/stepper/Stepper.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport * as React from 'react';\n\nimport { Position } from '../common';\nimport { useDirection } from '../common/hooks';\nimport Tooltip from '../tooltip';\n\nimport { isTouchDevice } from './deviceDetection';\n\nfunction clamp(from: number, to: number, value: number) {\n return Math.max(Math.min(to, value), from);\n}\n\nexport interface Step {\n label: React.ReactNode;\n onClick?: () => void;\n hoverLabel?: React.ReactNode;\n}\n\nexport interface StepperProps {\n steps: readonly Step[];\n activeStep?: number;\n className?: string;\n}\n\n/**\n * This component is considered user-unfriendly and inaccessible on its own and will likely be made internal in the future. Please use `FlowNavigation` instead.\n * @see https://storybook.wise.design/?path=/story/navigation-flownavigation--variants\n */\nconst Stepper = ({ steps, activeStep = 0, className }: StepperProps) => {\n const { isRTL } = useDirection();\n\n if (steps.length === 0) {\n return null;\n }\n\n const activeStepIndex = clamp(0, steps.length - 1, activeStep);\n const stepPercentage = 1 / (steps.length - 1);\n const percentageCompleted = activeStepIndex / (steps.length - 1);\n\n const getProgressWidth = (): string => {\n if (percentageCompleted === 0) {\n return '0px';\n }\n /**\n * Progress bar starts with left/right (depends on rtl) shift `--progress-bar-start-shift` for hiding Progress bar's left and right borders\n * which are used for progress vertical delimiter.\n * When progress is completed, we need to add `--progress-bar-border-width` to the width to allow the right border be outside of the progress area.\n */\n return `calc(${percentageCompleted * 100}% + var(--progress-bar-start-shift) + var(--progress-bar-border-width))`;\n };\n\n const renderStep = (step: Step, index: number) => {\n const active = index === activeStepIndex;\n const clickable = step.onClick && !active;\n\n const labelButton = clickable ? (\n <button\n type=\"button\"\n className=\"btn-unstyled tw-stepper__step-label\"\n onClick={() => clickable && step.onClick?.()}\n >\n <small>{step.label}</small>\n </button>\n ) : (\n <span className=\"tw-stepper__step-label\">{step.label}</span>\n );\n\n return (\n <li\n key={index}\n className={clsx(\n 'hidden-xs',\n 'tw-stepper__step',\n active ? 'np-text-body-default-bold tw-stepper__step--active' : 'np-text-body-default',\n clickable && 'tw-stepper__step--clickable',\n step.hoverLabel && 'tw-stepper__step--has-tooltip',\n )}\n aria-current={active ? 'step' : false}\n style={\n isRTL\n ? { right: `${index * stepPercentage * 100}%` }\n : { left: `${index * stepPercentage * 100}%` }\n }\n >\n {step.hoverLabel && !isTouchDevice() ? (\n <Tooltip position={Position.BOTTOM} label={step.hoverLabel}>\n {labelButton}\n </Tooltip>\n ) : (\n labelButton\n )}\n </li>\n );\n };\n\n return (\n <div className={clsx('tw-stepper', className)}>\n <div className=\"progress\">\n <div className=\"progress-bar\" style={{ width: getProgressWidth() }} />\n </div>\n <ol className=\"tw-stepper-steps p-t-1 m-b-0\">{steps.map(renderStep)}</ol>\n </div>\n );\n};\n\nexport default Stepper;\n"],"names":["clamp","from","to","value","Math","max","min","Stepper","steps","activeStep","className","isRTL","useDirection","length","activeStepIndex","stepPercentage","percentageCompleted","getProgressWidth","renderStep","step","index","active","clickable","onClick","labelButton","_jsx","type","children","label","clsx","hoverLabel","style","right","left","isTouchDevice","Tooltip","position","Position","BOTTOM","_jsxs","width","map"],"mappings":";;;;;;;;AASA,SAASA,KAAKA,CAACC,IAAY,EAAEC,EAAU,EAAEC,KAAa,EAAA;AACpD,EAAA,OAAOC,IAAI,CAACC,GAAG,CAACD,IAAI,CAACE,GAAG,CAACJ,EAAE,EAAEC,KAAK,CAAC,EAAEF,IAAI,CAAC,CAAA;AAC5C,CAAA;AAcA;;;AAGG;AACGM,MAAAA,OAAO,GAAGA,CAAC;EAAEC,KAAK;AAAEC,EAAAA,UAAU,GAAG,CAAC;AAAEC,EAAAA,SAAAA;AAAS,CAAgB,KAAI;EACrE,MAAM;AAAEC,IAAAA,KAAAA;GAAO,GAAGC,YAAY,EAAE,CAAA;AAEhC,EAAA,IAAIJ,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;AACtB,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AAEA,EAAA,MAAMC,eAAe,GAAGd,KAAK,CAAC,CAAC,EAAEQ,KAAK,CAACK,MAAM,GAAG,CAAC,EAAEJ,UAAU,CAAC,CAAA;EAC9D,MAAMM,cAAc,GAAG,CAAC,IAAIP,KAAK,CAACK,MAAM,GAAG,CAAC,CAAC,CAAA;EAC7C,MAAMG,mBAAmB,GAAGF,eAAe,IAAIN,KAAK,CAACK,MAAM,GAAG,CAAC,CAAC,CAAA;EAEhE,MAAMI,gBAAgB,GAAGA,MAAa;IACpC,IAAID,mBAAmB,KAAK,CAAC,EAAE;AAC7B,MAAA,OAAO,KAAK,CAAA;AACd,KAAA;AACA;;;;AAIG;AACH,IAAA,OAAO,CAAQA,KAAAA,EAAAA,mBAAmB,GAAG,GAAG,CAAyE,uEAAA,CAAA,CAAA;GAClH,CAAA;AAED,EAAA,MAAME,UAAU,GAAGA,CAACC,IAAU,EAAEC,KAAa,KAAI;AAC/C,IAAA,MA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AK,EAAET,IAAI,CAACW,UAAW;AAAAH,QAAAA,QAAA,EACxDH,WAAAA;AAAW,OACL,CAAC,GAEVA,WAAAA;AACD,KAAA,EArBIJ,KAsBH,CAAC,CAAA;GAER,CAAA;AAED,EAAA,oBACEmB,IAAA,CAAA,KAAA,EAAA;AAAK7B,IAAAA,SAAS,EAAEmB,IAAI,CAAC,YAAY,EAAEnB,SAAS,CAAE;AAAAiB,IAAAA,QAAA,gBAC5CF,GAAA,CAAA,KAAA,EAAA;AAAKf,MAAAA,SAAS,EAAC,UAAU;AAAAiB,MAAAA,QAAA,eACvBF,GAAA,CAAA,KAAA,EAAA;AAAKf,QAAAA,SAAS,EAAC,cAAc;AAACqB,QAAAA,KAAK,EAAE;UAAES,KAAK,EAAEvB,gBAAgB,EAAE;AAAA,SAAA;OAClE,CAAA;KAAK,CACL,eAAAQ,GAAA,CAAA,IAAA,EAAA;AAAIf,MAAAA,SAAS,EAAC,8BAA8B;AAAAiB,MAAAA,QAAA,EAAEnB,KAAK,CAACiC,GAAG,CAACvB,UAAU,CAAA;AAAC,KAAK,CAC1E,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV;;;;"}
|
package/build/styles/main.css
CHANGED
|
@@ -4368,35 +4368,11 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
4368
4368
|
padding: 0 ;
|
|
4369
4369
|
}
|
|
4370
4370
|
.progress-bar {
|
|
4371
|
-
float: left;
|
|
4372
4371
|
-webkit-backface-visibility: hidden;
|
|
4373
|
-
height: 100%;
|
|
4374
4372
|
background-color: var(--color-interactive-primary);
|
|
4375
|
-
border-top-left-radius: 1px;
|
|
4376
|
-
border-bottom-left-radius: 1px;
|
|
4377
4373
|
transition: width 0.6s ease-in-out;
|
|
4378
4374
|
will-change: width;
|
|
4379
4375
|
}
|
|
4380
|
-
[dir="rtl"] .progress-bar {
|
|
4381
|
-
float: right;
|
|
4382
|
-
}
|
|
4383
|
-
.progress-bar::after {
|
|
4384
|
-
float: right;
|
|
4385
|
-
width: 8px;
|
|
4386
|
-
height: 8px;
|
|
4387
|
-
margin-top: -3px;
|
|
4388
|
-
margin-right: -4px;
|
|
4389
|
-
content: "";
|
|
4390
|
-
border-radius: 4px;
|
|
4391
|
-
}
|
|
4392
|
-
[dir="rtl"] .progress-bar::after {
|
|
4393
|
-
float: left;
|
|
4394
|
-
}
|
|
4395
|
-
[dir="rtl"] .progress-bar::after {
|
|
4396
|
-
margin-left: -4px;
|
|
4397
|
-
margin-right: 0;
|
|
4398
|
-
margin-right: initial;
|
|
4399
|
-
}
|
|
4400
4376
|
.btn-unstyled {
|
|
4401
4377
|
background: none;
|
|
4402
4378
|
border: none;
|
|
@@ -70,35 +70,11 @@
|
|
|
70
70
|
padding: 0 ;
|
|
71
71
|
}
|
|
72
72
|
.progress-bar {
|
|
73
|
-
float: left;
|
|
74
73
|
-webkit-backface-visibility: hidden;
|
|
75
|
-
height: 100%;
|
|
76
74
|
background-color: var(--color-interactive-primary);
|
|
77
|
-
border-top-left-radius: 1px;
|
|
78
|
-
border-bottom-left-radius: 1px;
|
|
79
75
|
transition: width 0.6s ease-in-out;
|
|
80
76
|
will-change: width;
|
|
81
77
|
}
|
|
82
|
-
[dir="rtl"] .progress-bar {
|
|
83
|
-
float: right;
|
|
84
|
-
}
|
|
85
|
-
.progress-bar::after {
|
|
86
|
-
float: right;
|
|
87
|
-
width: 8px;
|
|
88
|
-
height: 8px;
|
|
89
|
-
margin-top: -3px;
|
|
90
|
-
margin-right: -4px;
|
|
91
|
-
content: "";
|
|
92
|
-
border-radius: 4px;
|
|
93
|
-
}
|
|
94
|
-
[dir="rtl"] .progress-bar::after {
|
|
95
|
-
float: left;
|
|
96
|
-
}
|
|
97
|
-
[dir="rtl"] .progress-bar::after {
|
|
98
|
-
margin-left: -4px;
|
|
99
|
-
margin-right: 0;
|
|
100
|
-
margin-right: initial;
|
|
101
|
-
}
|
|
102
78
|
.btn-unstyled {
|
|
103
79
|
background: none;
|
|
104
80
|
border: none;
|
|
@@ -42,7 +42,9 @@ export interface SelectInputProps<T = string, M extends boolean = false> {
|
|
|
42
42
|
disabled?: boolean;
|
|
43
43
|
size?: 'sm' | 'md' | 'lg';
|
|
44
44
|
className?: string;
|
|
45
|
-
UNSAFE_triggerButtonProps?: WithInputAttributesProps['inputAttributes']
|
|
45
|
+
UNSAFE_triggerButtonProps?: WithInputAttributesProps['inputAttributes'] & {
|
|
46
|
+
'aria-label'?: string;
|
|
47
|
+
};
|
|
46
48
|
onFilterChange?: (args: {
|
|
47
49
|
query: string;
|
|
48
50
|
queryNormalized: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectInput.d.ts","sourceRoot":"","sources":["../../../src/inputs/SelectInput.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAKjC,OAAO,EAAsB,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAyB1E,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,MAAM;IAC/C,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,CAAC,CAAC;IACT,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,MAAM;IAC9C,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC;CAC9C;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,MAAM,IAClC,qBAAqB,CAAC,CAAC,CAAC,GACxB,oBAAoB,CAAC,CAAC,CAAC,GACvB,wBAAwB,CAAC;AAiE7B,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,SAAS,OAAO,GAAG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EAAE,OAAO,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC;CAC7D;AAED,KAAK,kCAAkC,GAAG,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;;;;;;;;AAiZ9F,wBAA2F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyInput.messages.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/MoneyInput.messages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MoneyInput.messages.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/MoneyInput.messages.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,wBAUG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stepper.d.ts","sourceRoot":"","sources":["../../../src/stepper/Stepper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,QAAA,MAAM,OAAO,qCAA0C,YAAY,
|
|
1
|
+
{"version":3,"file":"Stepper.d.ts","sourceRoot":"","sources":["../../../src/stepper/Stepper.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,QAAA,MAAM,OAAO,qCAA0C,YAAY,6BA2ElE,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "46.
|
|
3
|
+
"version": "46.67.0",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"rollup-preserve-directives": "^1.1.1",
|
|
94
94
|
"storybook": "^8.2.2",
|
|
95
95
|
"@transferwise/less-config": "3.1.0",
|
|
96
|
-
"@transferwise/neptune-css": "14.
|
|
96
|
+
"@transferwise/neptune-css": "14.16.0",
|
|
97
97
|
"@wise/components-theming": "1.6.0"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
@@ -68,7 +68,6 @@ exports[`FlowNavigation on mobile renders as expected 1`] = `
|
|
|
68
68
|
>
|
|
69
69
|
<div
|
|
70
70
|
class="progress-bar"
|
|
71
|
-
style="width: 50%;"
|
|
72
71
|
/>
|
|
73
72
|
</div>
|
|
74
73
|
<ol
|
|
@@ -184,7 +183,7 @@ exports[`FlowNavigation renders as expected 1`] = `
|
|
|
184
183
|
>
|
|
185
184
|
<div
|
|
186
185
|
class="progress-bar"
|
|
187
|
-
style="width:
|
|
186
|
+
style="width: 0px;"
|
|
188
187
|
/>
|
|
189
188
|
</div>
|
|
190
189
|
<ol
|
package/src/i18n/en.json
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"neptune.Label.optional": "(Optional)",
|
|
22
22
|
"neptune.Link.opensInNewTab": "(opens in new tab)",
|
|
23
23
|
"neptune.MoneyInput.Select.placeholder": "Select an option...",
|
|
24
|
+
"neptune.MoneyInput.Select.selectCurrencyLabel": "Select currency",
|
|
24
25
|
"neptune.PhoneNumberInput.SelectInput.placeholder": "Select an option...",
|
|
25
26
|
"neptune.Select.searchPlaceholder": "Search...",
|
|
26
27
|
"neptune.SelectInput.noResultsFound": "No results found",
|
|
@@ -165,7 +165,9 @@ export interface SelectInputProps<T = string, M extends boolean = false> {
|
|
|
165
165
|
disabled?: boolean;
|
|
166
166
|
size?: 'sm' | 'md' | 'lg';
|
|
167
167
|
className?: string;
|
|
168
|
-
UNSAFE_triggerButtonProps?: WithInputAttributesProps['inputAttributes']
|
|
168
|
+
UNSAFE_triggerButtonProps?: WithInputAttributesProps['inputAttributes'] & {
|
|
169
|
+
'aria-label'?: string;
|
|
170
|
+
};
|
|
169
171
|
onFilterChange?: (args: { query: string; queryNormalized: string | null }) => void;
|
|
170
172
|
onChange?: (value: M extends true ? T[] : T) => void;
|
|
171
173
|
onClose?: () => void;
|
|
@@ -258,7 +260,6 @@ export function SelectInput<T = string, M extends boolean = false>({
|
|
|
258
260
|
}: SelectInputProps<T, M>) {
|
|
259
261
|
const inputAttributes = useInputAttributes();
|
|
260
262
|
const id = idProp ?? inputAttributes.id;
|
|
261
|
-
|
|
262
263
|
const [open, setOpen] = useState(false);
|
|
263
264
|
|
|
264
265
|
const initialized = useRef(false);
|
|
@@ -387,6 +388,7 @@ export function SelectInput<T = string, M extends boolean = false>({
|
|
|
387
388
|
}}
|
|
388
389
|
>
|
|
389
390
|
<SelectInputOptions
|
|
391
|
+
id={`${id}Search`}
|
|
390
392
|
items={items}
|
|
391
393
|
renderValue={renderValue}
|
|
392
394
|
renderFooter={renderFooter}
|
|
@@ -488,7 +490,7 @@ const SelectInputOptionsContainer = forwardRef(function SelectInputOptionsContai
|
|
|
488
490
|
interface SelectInputOptionsProps<T = string>
|
|
489
491
|
extends Pick<
|
|
490
492
|
SelectInputProps<T>,
|
|
491
|
-
'items' | 'renderValue' | 'renderFooter' | 'filterable' | 'filterPlaceholder'
|
|
493
|
+
'items' | 'renderValue' | 'renderFooter' | 'filterable' | 'filterPlaceholder' | 'id'
|
|
492
494
|
> {
|
|
493
495
|
searchInputRef: React.MutableRefObject<HTMLInputElement | null>;
|
|
494
496
|
listboxRef: React.MutableRefObject<HTMLDivElement | null>;
|
|
@@ -497,6 +499,7 @@ interface SelectInputOptionsProps<T = string>
|
|
|
497
499
|
}
|
|
498
500
|
|
|
499
501
|
function SelectInputOptions<T = string>({
|
|
502
|
+
id,
|
|
500
503
|
items,
|
|
501
504
|
renderValue = String,
|
|
502
505
|
renderFooter,
|
|
@@ -609,9 +612,11 @@ function SelectInputOptions<T = string>({
|
|
|
609
612
|
<div className="np-select-input-query-container">
|
|
610
613
|
<SearchInput
|
|
611
614
|
ref={searchInputRef}
|
|
615
|
+
id={id}
|
|
612
616
|
role="combobox"
|
|
613
617
|
shape="rectangle"
|
|
614
618
|
placeholder={filterPlaceholder}
|
|
619
|
+
aria-label={filterPlaceholder}
|
|
615
620
|
defaultValue={filterQuery}
|
|
616
621
|
aria-autocomplete="list"
|
|
617
622
|
aria-expanded
|
package/src/main.css
CHANGED
|
@@ -4368,35 +4368,11 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
4368
4368
|
padding: 0 ;
|
|
4369
4369
|
}
|
|
4370
4370
|
.progress-bar {
|
|
4371
|
-
float: left;
|
|
4372
4371
|
-webkit-backface-visibility: hidden;
|
|
4373
|
-
height: 100%;
|
|
4374
4372
|
background-color: var(--color-interactive-primary);
|
|
4375
|
-
border-top-left-radius: 1px;
|
|
4376
|
-
border-bottom-left-radius: 1px;
|
|
4377
4373
|
transition: width 0.6s ease-in-out;
|
|
4378
4374
|
will-change: width;
|
|
4379
4375
|
}
|
|
4380
|
-
[dir="rtl"] .progress-bar {
|
|
4381
|
-
float: right;
|
|
4382
|
-
}
|
|
4383
|
-
.progress-bar::after {
|
|
4384
|
-
float: right;
|
|
4385
|
-
width: 8px;
|
|
4386
|
-
height: 8px;
|
|
4387
|
-
margin-top: -3px;
|
|
4388
|
-
margin-right: -4px;
|
|
4389
|
-
content: "";
|
|
4390
|
-
border-radius: 4px;
|
|
4391
|
-
}
|
|
4392
|
-
[dir="rtl"] .progress-bar::after {
|
|
4393
|
-
float: left;
|
|
4394
|
-
}
|
|
4395
|
-
[dir="rtl"] .progress-bar::after {
|
|
4396
|
-
margin-left: -4px;
|
|
4397
|
-
margin-right: 0;
|
|
4398
|
-
margin-right: initial;
|
|
4399
|
-
}
|
|
4400
4376
|
.btn-unstyled {
|
|
4401
4377
|
background: none;
|
|
4402
4378
|
border: none;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Forms/MoneyInput/Known issues" />
|
|
4
|
+
|
|
5
|
+
# Known accessibility issues
|
|
6
|
+
|
|
7
|
+
There are few issues reported by Axe that are not fixable or safe to ignore at this point in time.
|
|
8
|
+
|
|
9
|
+
## Form elements should have a visible label / Form elements must have labels
|
|
10
|
+
|
|
11
|
+
While this requirement is normally considered as very serious, it's missing the fact that the input is wrapped by a labelled element with `role="group"`. We’ve tested it in NVDA on Windows and VoiceOver on MacOS, and discovered that if we were to satisfy Axe’s requirements, the screen reader would read out the label twice, something similar to `{Label Text} group, {Label Text} editable` (depending on the SR and the browser) which would result in an unnecessary noise. While the rule is valid, in this particular case the group label seems sufficient.
|
|
12
|
+
|
|
13
|
+
#### Further resources
|
|
14
|
+
|
|
15
|
+
- [Deque reference 1](https://dequeuniversity.com/rules/axe/4.9/label?application=axeAPI)
|
|
16
|
+
- [Deque reference 2](https://dequeuniversity.com/rules/axe/4.9/label-title-only?application=axeAPI)
|
|
17
|
+
- ['Group Labels Do Not Guarantee… Uniquity?' by Adrian Roselli](https://adrianroselli.com/2019/06/group-labels-do-not-guarantee-uniquity.html)
|
|
18
|
+
|
|
19
|
+
## Buttons must have discernible text
|
|
20
|
+
|
|
21
|
+
This affects HTML buttons with `role="combobox"` and deeply nested label text, not being discoverable by Axe. It is a known false-positive.
|
|
22
|
+
|
|
23
|
+
#### Further resources
|
|
24
|
+
|
|
25
|
+
- [Deque reference](https://dequeuniversity.com/rules/axe/4.9/button-name?application=axeAPI)
|
|
26
|
+
- [axe-core github issue](https://github.com/dequelabs/axe-core/issues/4472)
|
|
27
|
+
|
|
28
|
+
## ARIA hidden element must not be focusable or contain focusable elements
|
|
29
|
+
|
|
30
|
+
This is a genuine problem – according to the accessibility guidelines, no element with `aria-hidden="true"` should have any focusable children. This issue is caused by the `SelectInput`'s third party dependency (`Headless UI`) and, by extension, is visible in few other places. Work is planned to address it.
|
|
31
|
+
|
|
32
|
+
#### Further resources
|
|
33
|
+
|
|
34
|
+
- [Deque reference](https://dequeuniversity.com/rules/axe/4.9/aria-hidden-focus?application=axeAPI)
|
|
@@ -5,4 +5,9 @@ export default defineMessages({
|
|
|
5
5
|
id: 'neptune.MoneyInput.Select.placeholder',
|
|
6
6
|
defaultMessage: 'Select an option...',
|
|
7
7
|
},
|
|
8
|
+
selectCurrencyLabel: {
|
|
9
|
+
id: 'neptune.MoneyInput.Select.selectCurrencyLabel',
|
|
10
|
+
defaultMessage: 'Select currency',
|
|
11
|
+
description: 'Visually hidden label for the currency selector input.',
|
|
12
|
+
},
|
|
8
13
|
});
|