@transferwise/components 0.0.0-experimental-83f1188 → 0.0.0-experimental-128143a
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 +0 -2
- package/build/i18n/en.json.js +0 -2
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -2
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +0 -2
- package/build/index.js.map +1 -1
- package/build/index.mjs +0 -1
- package/build/index.mjs.map +1 -1
- package/build/main.css +7 -65
- package/build/prompt/InlinePrompt/InlinePrompt.js +0 -7
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs +1 -8
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/styles/main.css +7 -65
- package/build/styles/prompt/InlinePrompt/InlinePrompt.css +7 -7
- package/build/types/index.d.ts +0 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +2 -3
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -4
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/i18n/en.json +0 -2
- package/src/index.ts +0 -2
- package/src/main.css +7 -65
- package/src/main.less +0 -1
- package/src/prompt/InlinePrompt/InlinePrompt.css +7 -7
- package/src/prompt/InlinePrompt/InlinePrompt.less +7 -7
- package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +0 -6
- package/src/prompt/InlinePrompt/InlinePrompt.tsx +2 -12
- package/src/ssr.spec.tsx +0 -1
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.js +0 -113
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.js.map +0 -1
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js +0 -17
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js.map +0 -1
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs +0 -13
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs.map +0 -1
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs +0 -109
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs.map +0 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.js +0 -281
- package/build/expressiveMoneyInput/amountInput/AmountInput.js.map +0 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs +0 -279
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs.map +0 -1
- package/build/expressiveMoneyInput/amountInput/utils.js +0 -87
- package/build/expressiveMoneyInput/amountInput/utils.js.map +0 -1
- package/build/expressiveMoneyInput/amountInput/utils.mjs +0 -78
- package/build/expressiveMoneyInput/amountInput/utils.mjs.map +0 -1
- package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.js +0 -50
- package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.js.map +0 -1
- package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.mjs +0 -48
- package/build/expressiveMoneyInput/animatedNumber/AnimatedNumber.mjs.map +0 -1
- package/build/expressiveMoneyInput/chevron/Chevron.js +0 -31
- package/build/expressiveMoneyInput/chevron/Chevron.js.map +0 -1
- package/build/expressiveMoneyInput/chevron/Chevron.mjs +0 -29
- package/build/expressiveMoneyInput/chevron/Chevron.mjs.map +0 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +0 -160
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +0 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +0 -157
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +0 -1
- package/build/expressiveMoneyInput/hooks/useFocus.js +0 -37
- package/build/expressiveMoneyInput/hooks/useFocus.js.map +0 -1
- package/build/expressiveMoneyInput/hooks/useFocus.mjs +0 -35
- package/build/expressiveMoneyInput/hooks/useFocus.mjs.map +0 -1
- package/build/expressiveMoneyInput/hooks/useInputStyle.js +0 -71
- package/build/expressiveMoneyInput/hooks/useInputStyle.js.map +0 -1
- package/build/expressiveMoneyInput/hooks/useInputStyle.mjs +0 -69
- package/build/expressiveMoneyInput/hooks/useInputStyle.mjs.map +0 -1
- package/build/styles/expressiveMoneyInput/ExpressiveMoneyInput.css +0 -58
- package/build/styles/expressiveMoneyInput/amountInput/AmountInput.css +0 -32
- package/build/styles/expressiveMoneyInput/chevron/Chevron.css +0 -12
- package/build/styles/expressiveMoneyInput/currencySelector/CurrencySelector.css +0 -6
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts +0 -33
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts +0 -12
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts +0 -13
- package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/amountInput/utils.d.ts +0 -22
- package/build/types/expressiveMoneyInput/amountInput/utils.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/animatedNumber/AnimatedNumber.d.ts +0 -9
- package/build/types/expressiveMoneyInput/animatedNumber/AnimatedNumber.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/chevron/Chevron.d.ts +0 -6
- package/build/types/expressiveMoneyInput/chevron/Chevron.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts +0 -30
- package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/hooks/useFocus.d.ts +0 -7
- package/build/types/expressiveMoneyInput/hooks/useFocus.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts +0 -10
- package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts +0 -10
- package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts.map +0 -1
- package/build/types/expressiveMoneyInput/index.d.ts +0 -3
- package/build/types/expressiveMoneyInput/index.d.ts.map +0 -1
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.css +0 -58
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.less +0 -13
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.messages.ts +0 -13
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +0 -287
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.tsx +0 -130
- package/src/expressiveMoneyInput/amountInput/AmountInput.css +0 -32
- package/src/expressiveMoneyInput/amountInput/AmountInput.less +0 -43
- package/src/expressiveMoneyInput/amountInput/AmountInput.tsx +0 -353
- package/src/expressiveMoneyInput/amountInput/utils.spec.ts +0 -114
- package/src/expressiveMoneyInput/amountInput/utils.ts +0 -116
- package/src/expressiveMoneyInput/animatedNumber/AnimatedNumber.tsx +0 -40
- package/src/expressiveMoneyInput/chevron/Chevron.css +0 -12
- package/src/expressiveMoneyInput/chevron/Chevron.less +0 -13
- package/src/expressiveMoneyInput/chevron/Chevron.tsx +0 -35
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.css +0 -6
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.less +0 -7
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.tsx +0 -218
- package/src/expressiveMoneyInput/hooks/useFocus.ts +0 -35
- package/src/expressiveMoneyInput/hooks/useInputStyle.ts +0 -85
- package/src/expressiveMoneyInput/hooks/useSelectionRange.ts +0 -23
- package/src/expressiveMoneyInput/index.ts +0 -2
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +0 -39
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import Button from '../../button/Button.resolver.mjs';
|
|
2
|
-
import { SelectInput, SelectInputTriggerButton, SelectInputOptionContent } from '../../inputs/SelectInput.mjs';
|
|
3
|
-
import { ChevronDown } from '@transferwise/icons';
|
|
4
|
-
import { Flag } from '@wise/art';
|
|
5
|
-
import { useMemo, useState, forwardRef } from 'react';
|
|
6
|
-
import { useIntl } from 'react-intl';
|
|
7
|
-
import messages from '../ExpressiveMoneyInput.messages.mjs';
|
|
8
|
-
import { jsx } from 'react/jsx-runtime';
|
|
9
|
-
|
|
10
|
-
const CurrencySelector = ({
|
|
11
|
-
id,
|
|
12
|
-
currency,
|
|
13
|
-
options = [],
|
|
14
|
-
labelId,
|
|
15
|
-
onChange,
|
|
16
|
-
addons,
|
|
17
|
-
onOpen,
|
|
18
|
-
onSearchChange
|
|
19
|
-
}) => {
|
|
20
|
-
const intl = useIntl();
|
|
21
|
-
const allCurrencyOptions = useMemo(() => getUniqueCurrencies(options), [options]);
|
|
22
|
-
const activeCurrencyOption = useMemo(() => {
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
24
|
-
return allCurrencyOptions.find(option => option.code === currency);
|
|
25
|
-
}, [currency, allCurrencyOptions]);
|
|
26
|
-
const disabled = !onChange || options.length === 0 || options.length === 1 && options[0].currencies.length <= 1;
|
|
27
|
-
const [searchQuery, setSearchQuery] = useState('');
|
|
28
|
-
const handleTriggerClick = event => {
|
|
29
|
-
const triggerEl = event.currentTarget;
|
|
30
|
-
if (triggerEl?.getAttribute('aria-expanded') === 'false') {
|
|
31
|
-
onOpen?.();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const items = searchQuery ? filterAndSortCurrenciesForQuery(allCurrencyOptions, searchQuery).map(getCurrencySelectOption) : options.map(getCurrencyGroup);
|
|
35
|
-
return /*#__PURE__*/jsx(SelectInput, {
|
|
36
|
-
compareValues: "code",
|
|
37
|
-
disabled: disabled,
|
|
38
|
-
id: id,
|
|
39
|
-
value: activeCurrencyOption,
|
|
40
|
-
filterable: true,
|
|
41
|
-
filterPlaceholder: intl.formatMessage(messages.currencySelectorSearchPlaceholder),
|
|
42
|
-
UNSAFE_triggerButtonProps: {
|
|
43
|
-
id: undefined,
|
|
44
|
-
'aria-labelledby': undefined,
|
|
45
|
-
'aria-describedby': labelId,
|
|
46
|
-
'aria-invalid': undefined,
|
|
47
|
-
'aria-label': intl.formatMessage(messages.currencySelectorSelectCurrency)
|
|
48
|
-
},
|
|
49
|
-
items: items,
|
|
50
|
-
renderValue: ({
|
|
51
|
-
code,
|
|
52
|
-
label
|
|
53
|
-
}) => {
|
|
54
|
-
return /*#__PURE__*/jsx(SelectInputOptionContent, {
|
|
55
|
-
title: code,
|
|
56
|
-
note: label,
|
|
57
|
-
icon: /*#__PURE__*/jsx(Flag, {
|
|
58
|
-
code: code,
|
|
59
|
-
intrinsicSize: 24
|
|
60
|
-
})
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
renderTrigger: () => /*#__PURE__*/jsx(SelectInputTriggerButton, {
|
|
64
|
-
as: ButtonInput
|
|
65
|
-
// @ts-expect-error new (v2) ButtonProps
|
|
66
|
-
,
|
|
67
|
-
addonStart: {
|
|
68
|
-
type: 'avatar',
|
|
69
|
-
value: [addons ? addons[0] : null, {
|
|
70
|
-
...(addons && addons.length > 1 ? {
|
|
71
|
-
...addons[1]
|
|
72
|
-
} : {
|
|
73
|
-
asset: /*#__PURE__*/jsx(Flag, {
|
|
74
|
-
code: currency
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
}].filter(avatar => Boolean(avatar))
|
|
78
|
-
},
|
|
79
|
-
addonEnd: disabled ? undefined : {
|
|
80
|
-
type: 'icon',
|
|
81
|
-
value: /*#__PURE__*/jsx(ChevronDown, {})
|
|
82
|
-
},
|
|
83
|
-
onClick: event => handleTriggerClick(event),
|
|
84
|
-
children: currency
|
|
85
|
-
}),
|
|
86
|
-
onChange: newValue => {
|
|
87
|
-
onChange?.(newValue.code);
|
|
88
|
-
},
|
|
89
|
-
onFilterChange: ({
|
|
90
|
-
queryNormalized
|
|
91
|
-
}) => {
|
|
92
|
-
setSearchQuery(queryNormalized ?? '');
|
|
93
|
-
if (queryNormalized) {
|
|
94
|
-
onSearchChange?.({
|
|
95
|
-
query: queryNormalized,
|
|
96
|
-
resultCount: filterAndSortCurrenciesForQuery(allCurrencyOptions, queryNormalized).length
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
const ButtonInput = /*#__PURE__*/forwardRef(function ButtonInput({
|
|
103
|
-
children,
|
|
104
|
-
...rest
|
|
105
|
-
}, ref) {
|
|
106
|
-
return /*#__PURE__*/jsx(Button, {
|
|
107
|
-
ref: ref,
|
|
108
|
-
size: "md",
|
|
109
|
-
v2: true,
|
|
110
|
-
className: "wds-currency-selector",
|
|
111
|
-
priority: "secondary-neutral",
|
|
112
|
-
...rest,
|
|
113
|
-
children: children
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
const getCurrencySelectOption = currency => {
|
|
117
|
-
return {
|
|
118
|
-
type: 'option',
|
|
119
|
-
value: currency,
|
|
120
|
-
filterMatchers: currency.keywords
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
const getCurrencyGroup = section => {
|
|
124
|
-
return {
|
|
125
|
-
type: 'group',
|
|
126
|
-
label: section.title,
|
|
127
|
-
options: section.currencies.map(getCurrencySelectOption)
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
const getUniqueCurrencies = options => {
|
|
131
|
-
const allCurrencyOptions = options.flatMap(section => section.currencies);
|
|
132
|
-
const uniqueCurrencies = new Map();
|
|
133
|
-
allCurrencyOptions.forEach(currencyObj => {
|
|
134
|
-
uniqueCurrencies.set(currencyObj.code, currencyObj);
|
|
135
|
-
});
|
|
136
|
-
return Array.from(uniqueCurrencies.values());
|
|
137
|
-
};
|
|
138
|
-
const filterAndSortCurrenciesForQuery = (currencies, query) => {
|
|
139
|
-
return currencies.filter(currency => {
|
|
140
|
-
return currency.code.toLowerCase().includes(query) || (currency.label ?? '').toLowerCase().includes(query) || currency.keywords?.some(keyword => keyword.toLowerCase().includes(query));
|
|
141
|
-
})
|
|
142
|
-
// prefer exact matches, then sort alphabetically by code
|
|
143
|
-
.sort((a, b) => {
|
|
144
|
-
const aCode = a.code.toLowerCase();
|
|
145
|
-
const bCode = b.code.toLowerCase();
|
|
146
|
-
if (aCode === query) {
|
|
147
|
-
return -1;
|
|
148
|
-
}
|
|
149
|
-
if (bCode === query) {
|
|
150
|
-
return 1;
|
|
151
|
-
}
|
|
152
|
-
return aCode.localeCompare(bCode);
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export { ButtonInput, CurrencySelector };
|
|
157
|
-
//# sourceMappingURL=CurrencySelector.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencySelector.mjs","sources":["../../../src/expressiveMoneyInput/currencySelector/CurrencySelector.tsx"],"sourcesContent":["import type { AvatarLayoutProps } from '../../avatarLayout';\nimport Button from '../../button';\nimport {\n SelectInput,\n SelectInputOptionContent,\n SelectInputTriggerButton,\n} from '../../inputs/SelectInput';\nimport { CurrencyType, Props as ExpressiveMoneyInputProps } from '../ExpressiveMoneyInput';\nimport { ChevronDown } from '@transferwise/icons';\nimport { Flag } from '@wise/art';\nimport {\n type ButtonHTMLAttributes,\n forwardRef,\n type MouseEventHandler,\n useMemo,\n useState,\n} from 'react';\nimport { useIntl } from 'react-intl';\n\nimport messages from '../ExpressiveMoneyInput.messages';\n\nexport interface CurrencyOption {\n label?: string;\n code: string;\n keywords: string[] | undefined;\n}\n\nexport interface CurrencySection {\n title: string;\n currencies: CurrencyOption[];\n}\n\nexport type CurrencyOptions = CurrencySection[];\n\nexport type Props = {\n id: string;\n labelId: string;\n options?: CurrencyOptions;\n onChange?: (currency: CurrencyType) => void;\n onOpen?: () => void;\n addons?: AvatarLayoutProps['avatars'];\n onSearchChange?: (payload: { query: string; resultCount: number }) => void;\n} & Pick<ExpressiveMoneyInputProps, 'currency'>;\n\nexport const CurrencySelector = ({\n id,\n currency,\n options = [],\n labelId,\n onChange,\n addons,\n onOpen,\n onSearchChange,\n}: Props) => {\n const intl = useIntl();\n\n const allCurrencyOptions = useMemo(() => getUniqueCurrencies(options), [options]);\n\n const activeCurrencyOption = useMemo(() => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return allCurrencyOptions.find((option) => option.code === currency)!;\n }, [currency, allCurrencyOptions]);\n\n const disabled =\n !onChange ||\n options.length === 0 ||\n (options.length === 1 && options[0].currencies.length <= 1);\n\n const [searchQuery, setSearchQuery] = useState<string>('');\n\n const handleTriggerClick: MouseEventHandler = (event) => {\n const triggerEl = event.currentTarget;\n if (triggerEl?.getAttribute('aria-expanded') === 'false') {\n onOpen?.();\n }\n };\n\n const items = searchQuery\n ? filterAndSortCurrenciesForQuery(allCurrencyOptions, searchQuery).map(getCurrencySelectOption)\n : options.map(getCurrencyGroup);\n\n return (\n <SelectInput\n compareValues=\"code\"\n disabled={disabled}\n id={id}\n value={activeCurrencyOption}\n filterable\n filterPlaceholder={intl.formatMessage(messages.currencySelectorSearchPlaceholder)}\n UNSAFE_triggerButtonProps={{\n id: undefined,\n 'aria-labelledby': undefined,\n 'aria-describedby': labelId,\n 'aria-invalid': undefined,\n 'aria-label': intl.formatMessage(messages.currencySelectorSelectCurrency),\n }}\n items={items}\n renderValue={({ code, label }) => {\n return (\n <SelectInputOptionContent\n title={code}\n note={label}\n icon={<Flag code={code} intrinsicSize={24} />}\n />\n );\n }}\n renderTrigger={() => (\n <SelectInputTriggerButton\n as={ButtonInput}\n // @ts-expect-error new (v2) ButtonProps\n addonStart={{\n type: 'avatar',\n value: [\n addons ? addons[0] : null,\n {\n ...(addons && addons.length > 1\n ? { ...addons[1] }\n : {\n asset: <Flag code={currency} />,\n }),\n },\n ].filter((avatar) => Boolean(avatar)),\n }}\n addonEnd={disabled ? undefined : { type: 'icon', value: <ChevronDown /> }}\n onClick={(event) => handleTriggerClick(event)}\n >\n {currency}\n </SelectInputTriggerButton>\n )}\n onChange={(newValue) => {\n onChange?.(newValue.code);\n }}\n onFilterChange={({ queryNormalized }) => {\n setSearchQuery(queryNormalized ?? '');\n if (queryNormalized) {\n onSearchChange?.({\n query: queryNormalized,\n resultCount: filterAndSortCurrenciesForQuery(allCurrencyOptions, queryNormalized)\n .length,\n });\n }\n }}\n />\n );\n};\n\nexport const ButtonInput = forwardRef(function ButtonInput(\n { children, ...rest }: React.PropsWithChildren<ButtonHTMLAttributes<HTMLButtonElement>>,\n ref: React.ForwardedRef<HTMLButtonElement | null>,\n) {\n return (\n <Button\n ref={ref}\n size=\"md\"\n v2\n className=\"wds-currency-selector\"\n priority=\"secondary-neutral\"\n {...rest}\n >\n {children}\n </Button>\n );\n});\n\nconst getCurrencySelectOption = (currency: CurrencyOption) => {\n return {\n type: 'option' as const,\n value: currency,\n filterMatchers: currency.keywords,\n };\n};\n\nconst getCurrencyGroup = (section: CurrencySection) => {\n return {\n type: 'group' as const,\n label: section.title,\n options: section.currencies.map(getCurrencySelectOption),\n };\n};\n\nconst getUniqueCurrencies = (options: CurrencyOptions) => {\n const allCurrencyOptions = options.flatMap((section) => section.currencies);\n const uniqueCurrencies = new Map<string, CurrencyOption>();\n\n allCurrencyOptions.forEach((currencyObj) => {\n uniqueCurrencies.set(currencyObj.code, currencyObj);\n });\n\n return Array.from(uniqueCurrencies.values());\n};\n\nconst filterAndSortCurrenciesForQuery = (\n currencies: CurrencyOption[],\n query: string,\n): CurrencyOption[] => {\n return (\n currencies\n .filter((currency) => {\n return (\n currency.code.toLowerCase().includes(query) ||\n (currency.label ?? '').toLowerCase().includes(query) ||\n currency.keywords?.some((keyword) => keyword.toLowerCase().includes(query))\n );\n })\n // prefer exact matches, then sort alphabetically by code\n .sort((a, b) => {\n const aCode = a.code.toLowerCase();\n const bCode = b.code.toLowerCase();\n if (aCode === query) {\n return -1;\n }\n if (bCode === query) {\n return 1;\n }\n return aCode.localeCompare(bCode);\n })\n );\n};\n"],"names":["CurrencySelector","id","currency","options","labelId","onChange","addons","onOpen","onSearchChange","intl","useIntl","allCurrencyOptions","useMemo","getUniqueCurrencies","activeCurrencyOption","find","option","code","disabled","length","currencies","searchQuery","setSearchQuery","useState","handleTriggerClick","event","triggerEl","currentTarget","getAttribute","items","filterAndSortCurrenciesForQuery","map","getCurrencySelectOption","getCurrencyGroup","_jsx","SelectInput","compareValues","value","filterable","filterPlaceholder","formatMessage","messages","currencySelectorSearchPlaceholder","UNSAFE_triggerButtonProps","undefined","currencySelectorSelectCurrency","renderValue","label","SelectInputOptionContent","title","note","icon","Flag","intrinsicSize","renderTrigger","SelectInputTriggerButton","as","ButtonInput","addonStart","type","asset","filter","avatar","Boolean","addonEnd","ChevronDown","onClick","children","newValue","onFilterChange","queryNormalized","query","resultCount","forwardRef","rest","ref","Button","size","v2","className","priority","filterMatchers","keywords","section","flatMap","uniqueCurrencies","Map","forEach","currencyObj","set","Array","from","values","toLowerCase","includes","some","keyword","sort","a","b","aCode","bCode","localeCompare"],"mappings":";;;;;;;;;AA4CO,MAAMA,gBAAgB,GAAGA,CAAC;EAC/BC,EAAE;EACFC,QAAQ;AACRC,EAAAA,OAAO,GAAG,EAAE;EACZC,OAAO;EACPC,QAAQ;EACRC,MAAM;EACNC,MAAM;AACNC,EAAAA;AAAc,CACR,KAAI;AACV,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE;AAEtB,EAAA,MAAMC,kBAAkB,GAAGC,OAAO,CAAC,MAAMC,mBAAmB,CAACV,OAAO,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;AAEjF,EAAA,MAAMW,oBAAoB,GAAGF,OAAO,CAAC,MAAK;AACxC;IACA,OAAOD,kBAAkB,CAACI,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACC,IAAI,KAAKf,QAAQ,CAAE;AACvE,EAAA,CAAC,EAAE,CAACA,QAAQ,EAAES,kBAAkB,CAAC,CAAC;EAElC,MAAMO,QAAQ,GACZ,CA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|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
|
|
5
|
-
const focusTimeout = 5 * 1000;
|
|
6
|
-
const useFocus = () => {
|
|
7
|
-
const [focus, setFocus] = React.useState(false);
|
|
8
|
-
const [visualFocus, setVisualFocus] = React.useState(false);
|
|
9
|
-
const [counter, setCounter] = React.useState(0);
|
|
10
|
-
React.useEffect(() => {
|
|
11
|
-
if (focus) {
|
|
12
|
-
const timeout = setTimeout(() => {
|
|
13
|
-
setVisualFocus(false);
|
|
14
|
-
}, focusTimeout);
|
|
15
|
-
return () => clearTimeout(timeout);
|
|
16
|
-
}
|
|
17
|
-
}, [focus, counter]);
|
|
18
|
-
return {
|
|
19
|
-
focus,
|
|
20
|
-
setFocus: value => {
|
|
21
|
-
setFocus(value);
|
|
22
|
-
if (value) {
|
|
23
|
-
setVisualFocus(true);
|
|
24
|
-
}
|
|
25
|
-
// any call to setFocus should reset the timeout, even if the input was already in focus
|
|
26
|
-
// updating the counter will trigger the useEffect to reset the timeout
|
|
27
|
-
setCounter(prev => prev + 1);
|
|
28
|
-
},
|
|
29
|
-
visualFocus,
|
|
30
|
-
setVisualFocus: value => {
|
|
31
|
-
setVisualFocus(value);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.useFocus = useFocus;
|
|
37
|
-
//# sourceMappingURL=useFocus.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFocus.js","sources":["../../../src/expressiveMoneyInput/hooks/useFocus.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst focusTimeout = 5 * 1000;\n\nexport const useFocus = () => {\n const [focus, setFocus] = useState(false);\n const [visualFocus, setVisualFocus] = useState(false);\n const [counter, setCounter] = useState(0);\n\n useEffect(() => {\n if (focus) {\n const timeout = setTimeout(() => {\n setVisualFocus(false);\n }, focusTimeout);\n return () => clearTimeout(timeout);\n }\n }, [focus, counter]);\n\n return {\n focus,\n setFocus: (value: boolean) => {\n setFocus(value);\n if (value) {\n setVisualFocus(true);\n }\n // any call to setFocus should reset the timeout, even if the input was already in focus\n // updating the counter will trigger the useEffect to reset the timeout\n setCounter((prev) => prev + 1);\n },\n visualFocus,\n setVisualFocus: (value: boolean) => {\n setVisualFocus(value);\n },\n };\n};\n"],"names":["focusTimeout","useFocus","focus","setFocus","useState","visualFocus","setVisualFocus","counter","setCounter","useEffect","timeout","setTimeout","clearTimeout","value","prev"],"mappings":";;;;AAEA,MAAMA,YAAY,GAAG,CAAC,GAAG,IAAI;AAEtB,MAAMC,QAAQ,GAAGA,MAAK;EAC3B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;EACzC,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGF,cAAQ,CAAC,KAAK,CAAC;EACrD,MAAM,CAACG,OAAO,EAAEC,UAAU,CAAC,GAAGJ,cAAQ,CAAC,CAAC,CAAC;AAEzCK,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,IAAIP,KAAK,EAAE;AACT,MAAA,MAAMQ,OAAO,GAAGC,UAAU,CAAC,MAAK;QAC9BL,cAAc,CAAC,KAAK,CAAC;MACvB,CAAC,EAAEN,YAAY,CAAC;AAChB,MAAA,OAAO,MAAMY,YAAY,CAACF,OAAO,CAAC;AACpC,IAAA;AACF,EAAA,CAAC,EAAE,CAACR,KAAK,EAAEK,OAAO,CAAC,CAAC;EAEpB,OAAO;IACLL,KAAK;IACLC,QAAQ,EAAGU,KAAc,IAAI;MAC3BV,QAAQ,CAACU,KAAK,CAAC;AACf,MAAA,IAAIA,KAAK,EAAE;QACTP,cAAc,CAAC,IAAI,CAAC;AACtB,MAAA;AACA;AACA;AACAE,MAAAA,UAAU,CAAEM,IAAI,IAAKA,IAAI,GAAG,CAAC,CAAC;IAChC,CAAC;IACDT,WAAW;IACXC,cAAc,EAAGO,KAAc,IAAI;MACjCP,cAAc,CAACO,KAAK,CAAC;AACvB,IAAA;GACD;AACH;;;;"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const focusTimeout = 5 * 1000;
|
|
4
|
-
const useFocus = () => {
|
|
5
|
-
const [focus, setFocus] = useState(false);
|
|
6
|
-
const [visualFocus, setVisualFocus] = useState(false);
|
|
7
|
-
const [counter, setCounter] = useState(0);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
if (focus) {
|
|
10
|
-
const timeout = setTimeout(() => {
|
|
11
|
-
setVisualFocus(false);
|
|
12
|
-
}, focusTimeout);
|
|
13
|
-
return () => clearTimeout(timeout);
|
|
14
|
-
}
|
|
15
|
-
}, [focus, counter]);
|
|
16
|
-
return {
|
|
17
|
-
focus,
|
|
18
|
-
setFocus: value => {
|
|
19
|
-
setFocus(value);
|
|
20
|
-
if (value) {
|
|
21
|
-
setVisualFocus(true);
|
|
22
|
-
}
|
|
23
|
-
// any call to setFocus should reset the timeout, even if the input was already in focus
|
|
24
|
-
// updating the counter will trigger the useEffect to reset the timeout
|
|
25
|
-
setCounter(prev => prev + 1);
|
|
26
|
-
},
|
|
27
|
-
visualFocus,
|
|
28
|
-
setVisualFocus: value => {
|
|
29
|
-
setVisualFocus(value);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export { useFocus };
|
|
35
|
-
//# sourceMappingURL=useFocus.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFocus.mjs","sources":["../../../src/expressiveMoneyInput/hooks/useFocus.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst focusTimeout = 5 * 1000;\n\nexport const useFocus = () => {\n const [focus, setFocus] = useState(false);\n const [visualFocus, setVisualFocus] = useState(false);\n const [counter, setCounter] = useState(0);\n\n useEffect(() => {\n if (focus) {\n const timeout = setTimeout(() => {\n setVisualFocus(false);\n }, focusTimeout);\n return () => clearTimeout(timeout);\n }\n }, [focus, counter]);\n\n return {\n focus,\n setFocus: (value: boolean) => {\n setFocus(value);\n if (value) {\n setVisualFocus(true);\n }\n // any call to setFocus should reset the timeout, even if the input was already in focus\n // updating the counter will trigger the useEffect to reset the timeout\n setCounter((prev) => prev + 1);\n },\n visualFocus,\n setVisualFocus: (value: boolean) => {\n setVisualFocus(value);\n },\n };\n};\n"],"names":["focusTimeout","useFocus","focus","setFocus","useState","visualFocus","setVisualFocus","counter","setCounter","useEffect","timeout","setTimeout","clearTimeout","value","prev"],"mappings":";;AAEA,MAAMA,YAAY,GAAG,CAAC,GAAG,IAAI;AAEtB,MAAMC,QAAQ,GAAGA,MAAK;EAC3B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAAC,KAAK,CAAC;EACzC,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGF,QAAQ,CAAC,KAAK,CAAC;EACrD,MAAM,CAACG,OAAO,EAAEC,UAAU,CAAC,GAAGJ,QAAQ,CAAC,CAAC,CAAC;AAEzCK,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,IAAIP,KAAK,EAAE;AACT,MAAA,MAAMQ,OAAO,GAAGC,UAAU,CAAC,MAAK;QAC9BL,cAAc,CAAC,KAAK,CAAC;MACvB,CAAC,EAAEN,YAAY,CAAC;AAChB,MAAA,OAAO,MAAMY,YAAY,CAACF,OAAO,CAAC;AACpC,IAAA;AACF,EAAA,CAAC,EAAE,CAACR,KAAK,EAAEK,OAAO,CAAC,CAAC;EAEpB,OAAO;IACLL,KAAK;IACLC,QAAQ,EAAGU,KAAc,IAAI;MAC3BV,QAAQ,CAACU,KAAK,CAAC;AACf,MAAA,IAAIA,KAAK,EAAE;QACTP,cAAc,CAAC,IAAI,CAAC;AACtB,MAAA;AACA;AACA;AACAE,MAAAA,UAAU,CAAEM,IAAI,IAAKA,IAAI,GAAG,CAAC,CAAC;IAChC,CAAC;IACDT,WAAW;IACXC,cAAc,EAAGO,KAAc,IAAI;MACjCP,cAAc,CAACO,KAAK,CAAC;AACvB,IAAA;GACD;AACH;;;;"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
|
|
5
|
-
const useInputStyle = ({
|
|
6
|
-
value,
|
|
7
|
-
focus,
|
|
8
|
-
inputElement,
|
|
9
|
-
loading
|
|
10
|
-
}) => {
|
|
11
|
-
const initialRender = !useTimeout(300);
|
|
12
|
-
const inputWidth = useFirstDefinedValue(inputElement?.clientWidth, [inputElement, value]);
|
|
13
|
-
const getStyle = () => {
|
|
14
|
-
const fontSize = getFontSize(value, focus, inputWidth);
|
|
15
|
-
return {
|
|
16
|
-
fontSize,
|
|
17
|
-
height: fontSize,
|
|
18
|
-
// aligns the top of the digit with the currency button
|
|
19
|
-
marginTop: fontSize * -0.19,
|
|
20
|
-
// if the input loads with a pre-filled value, we don't want to animate the font-size immediately
|
|
21
|
-
transition: initialRender ? 'none' : undefined,
|
|
22
|
-
color: loading ? 'var(--color-interactive-secondary)' : undefined
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const [style, setStyle] = React.useState(getStyle());
|
|
26
|
-
React.useLayoutEffect(() => {
|
|
27
|
-
setStyle(getStyle());
|
|
28
|
-
}, [value, focus, loading, inputWidth]);
|
|
29
|
-
return style;
|
|
30
|
-
};
|
|
31
|
-
function getFontSize(inputValue, isFocused, inputWidth) {
|
|
32
|
-
const defaultFontSize = 52;
|
|
33
|
-
const focusFontSize = 90;
|
|
34
|
-
const minimumFontSize = 34;
|
|
35
|
-
let fontSize = isFocused ? focusFontSize : defaultFontSize;
|
|
36
|
-
if (typeof inputWidth === 'undefined') {
|
|
37
|
-
return fontSize;
|
|
38
|
-
}
|
|
39
|
-
const textLength = inputValue.length;
|
|
40
|
-
const maxCharactersWithoutShrinking = Math.floor(inputWidth / 40);
|
|
41
|
-
if (textLength > maxCharactersWithoutShrinking) {
|
|
42
|
-
const adjustedSize = Math.round(inputWidth / textLength * 1.9);
|
|
43
|
-
fontSize = Math.min(fontSize, adjustedSize);
|
|
44
|
-
}
|
|
45
|
-
return Math.max(fontSize, minimumFontSize);
|
|
46
|
-
}
|
|
47
|
-
const useFirstDefinedValue = (newValue, dependencies) => {
|
|
48
|
-
const [value, setValue] = React.useState(newValue);
|
|
49
|
-
React.useLayoutEffect(() => {
|
|
50
|
-
if (typeof newValue !== 'undefined' && typeof value === 'undefined') {
|
|
51
|
-
setValue(newValue);
|
|
52
|
-
}
|
|
53
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
-
}, [...dependencies, value]);
|
|
55
|
-
return value;
|
|
56
|
-
};
|
|
57
|
-
const useTimeout = delay => {
|
|
58
|
-
const [ready, setReady] = React.useState(false);
|
|
59
|
-
React.useEffect(() => {
|
|
60
|
-
const timeout = setTimeout(() => {
|
|
61
|
-
setReady(true);
|
|
62
|
-
}, delay);
|
|
63
|
-
return () => {
|
|
64
|
-
clearTimeout(timeout);
|
|
65
|
-
};
|
|
66
|
-
}, [delay]);
|
|
67
|
-
return ready;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
exports.useInputStyle = useInputStyle;
|
|
71
|
-
//# sourceMappingURL=useInputStyle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInputStyle.js","sources":["../../../src/expressiveMoneyInput/hooks/useInputStyle.ts"],"sourcesContent":["import { type CSSProperties, useEffect, useLayoutEffect, useState } from 'react';\nimport { Props as ExpressiveMoneyInputProps } from '../ExpressiveMoneyInput';\n\ntype InputStyleObject = {\n value: string;\n focus: boolean;\n inputElement: HTMLInputElement | null;\n} & Pick<ExpressiveMoneyInputProps, 'loading'>;\n\nexport const useInputStyle = ({ value, focus, inputElement, loading }: InputStyleObject) => {\n const initialRender = !useTimeout(300);\n const inputWidth = useFirstDefinedValue(inputElement?.clientWidth, [inputElement, value]);\n\n const getStyle = (): CSSProperties => {\n const fontSize = getFontSize(value, focus, inputWidth);\n\n return {\n fontSize,\n height: fontSize,\n // aligns the top of the digit with the currency button\n marginTop: fontSize * -0.19,\n // if the input loads with a pre-filled value, we don't want to animate the font-size immediately\n transition: initialRender ? 'none' : undefined,\n color: loading ? 'var(--color-interactive-secondary)' : undefined,\n };\n };\n\n const [style, setStyle] = useState(getStyle());\n\n useLayoutEffect(() => {\n setStyle(getStyle());\n }, [value, focus, loading, inputWidth]);\n\n return style;\n};\n\nfunction getFontSize(inputValue: string, isFocused: boolean, inputWidth: number | undefined) {\n const defaultFontSize = 52;\n const focusFontSize = 90;\n const minimumFontSize = 34;\n\n let fontSize = isFocused ? focusFontSize : defaultFontSize;\n\n if (typeof inputWidth === 'undefined') {\n return fontSize;\n }\n const textLength = inputValue.length;\n const maxCharactersWithoutShrinking = Math.floor(inputWidth / 40);\n\n if (textLength > maxCharactersWithoutShrinking) {\n const adjustedSize = Math.round((inputWidth / textLength) * 1.9);\n fontSize = Math.min(fontSize, adjustedSize);\n }\n\n return Math.max(fontSize, minimumFontSize);\n}\n\nconst useFirstDefinedValue = (newValue: number | undefined, dependencies: unknown[]) => {\n const [value, setValue] = useState<number | undefined>(newValue);\n\n useLayoutEffect(() => {\n if (typeof newValue !== 'undefined' && typeof value === 'undefined') {\n setValue(newValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [...dependencies, value]);\n\n return value;\n};\n\nconst useTimeout = (delay: number) => {\n const [ready, setReady] = useState(false);\n\n useEffect(() => {\n const timeout = setTimeout(() => {\n setReady(true);\n }, delay);\n\n return () => {\n clearTimeout(timeout);\n };\n }, [delay]);\n\n return ready;\n};\n"],"names":["useInputStyle","value","focus","inputElement","loading","initialRender","useTimeout","inputWidth","useFirstDefinedValue","clientWidth","getStyle","fontSize","getFontSize","height","marginTop","transition","undefined","color","style","setStyle","useState","useLayoutEffect","inputValue","isFocused","defaultFontSize","focusFontSize","minimumFontSize","textLength","length","maxCharactersWithoutShrinking","Math","floor","adjustedSize","round","min","max","newValue","dependencies","setValue","delay","ready","setReady","useEffect","timeout","setTimeout","clearTimeout"],"mappings":";;;;AASO,MAAMA,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC,KAAK;EAAEC,YAAY;AAAEC,EAAAA;AAAO,CAAoB,KAAI;AACzF,EAAA,MAAMC,aAAa,GAAG,CAACC,UAAU,CAAC,GAAG,CAAC;AACtC,EAAA,MAAMC,UAAU,GAAGC,oBAAoB,CAACL,YAAY,EAAEM,WAAW,EAAE,CAACN,YAAY,EAAEF,KAAK,CAAC,CAAC;EAEzF,MAAMS,QAAQ,GAAGA,MAAoB;IACnC,MAAMC,QAAQ,GAAGC,WAAW,CAACX,KAAK,EAAEC,KAAK,EAAEK,UAAU,CAAC;IAEtD,OAAO;MACLI,QAAQ;AACRE,MAAAA,MAAM,EAAEF,QAAQ;AAChB;AACAG,MAAAA,SAAS,EAAEH,QAAQ,GAAG,KAAK;AAC3B;AACAI,MAAAA,UAAU,EAAEV,aAAa,GAAG,MAAM,GAAGW,SAAS;AAC9CC,MAAAA,KAAK,EAAEb,OAAO,GAAG,oCAAoC,GAAGY;KACzD;EACH,CAAC;EAED,MAAM,CAACE,KAAK,EAAEC,QAAQ,CAAC,GAAGC,cAAQ,CAACV,QAAQ,EAAE,CAAC;AAE9CW,EAAAA,qBAAe,CAAC,MAAK;AACnBF,IAAAA,QAAQ,CAACT,QAAQ,EAAE,CAAC;EACtB,CAAC,EAAE,CAACT,KAAK,EAAEC,KAAK,EAAEE,OAAO,EAAEG,UAAU,CAAC,CAAC;AAEvC,EAAA,OAAOW,KAAK;AACd;AAEA,SAASN,WAAWA,CAACU,UAAkB,EAAEC,SAAkB,EAAEhB,UAA8B,EAAA;EACzF,MAAMiB,eAAe,GAAG,EAAE;EAC1B,MAAMC,aAAa,GAAG,EAAE;EACxB,MAAMC,eAAe,GAAG,EAAE;AAE1B,EAAA,IAAIf,QAAQ,GAAGY,SAAS,GAAGE,aAAa,GAAGD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O,MAAK;MACVM,YAAY,CAACF,OAAO,CAAC;IACvB,CAAC;AACH,EAAA,CAAC,EAAE,CAACJ,KAAK,CAAC,CAAC;AAEX,EAAA,OAAOC,KAAK;AACd,CAAC;;;;"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { useState, useLayoutEffect, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const useInputStyle = ({
|
|
4
|
-
value,
|
|
5
|
-
focus,
|
|
6
|
-
inputElement,
|
|
7
|
-
loading
|
|
8
|
-
}) => {
|
|
9
|
-
const initialRender = !useTimeout(300);
|
|
10
|
-
const inputWidth = useFirstDefinedValue(inputElement?.clientWidth, [inputElement, value]);
|
|
11
|
-
const getStyle = () => {
|
|
12
|
-
const fontSize = getFontSize(value, focus, inputWidth);
|
|
13
|
-
return {
|
|
14
|
-
fontSize,
|
|
15
|
-
height: fontSize,
|
|
16
|
-
// aligns the top of the digit with the currency button
|
|
17
|
-
marginTop: fontSize * -0.19,
|
|
18
|
-
// if the input loads with a pre-filled value, we don't want to animate the font-size immediately
|
|
19
|
-
transition: initialRender ? 'none' : undefined,
|
|
20
|
-
color: loading ? 'var(--color-interactive-secondary)' : undefined
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
const [style, setStyle] = useState(getStyle());
|
|
24
|
-
useLayoutEffect(() => {
|
|
25
|
-
setStyle(getStyle());
|
|
26
|
-
}, [value, focus, loading, inputWidth]);
|
|
27
|
-
return style;
|
|
28
|
-
};
|
|
29
|
-
function getFontSize(inputValue, isFocused, inputWidth) {
|
|
30
|
-
const defaultFontSize = 52;
|
|
31
|
-
const focusFontSize = 90;
|
|
32
|
-
const minimumFontSize = 34;
|
|
33
|
-
let fontSize = isFocused ? focusFontSize : defaultFontSize;
|
|
34
|
-
if (typeof inputWidth === 'undefined') {
|
|
35
|
-
return fontSize;
|
|
36
|
-
}
|
|
37
|
-
const textLength = inputValue.length;
|
|
38
|
-
const maxCharactersWithoutShrinking = Math.floor(inputWidth / 40);
|
|
39
|
-
if (textLength > maxCharactersWithoutShrinking) {
|
|
40
|
-
const adjustedSize = Math.round(inputWidth / textLength * 1.9);
|
|
41
|
-
fontSize = Math.min(fontSize, adjustedSize);
|
|
42
|
-
}
|
|
43
|
-
return Math.max(fontSize, minimumFontSize);
|
|
44
|
-
}
|
|
45
|
-
const useFirstDefinedValue = (newValue, dependencies) => {
|
|
46
|
-
const [value, setValue] = useState(newValue);
|
|
47
|
-
useLayoutEffect(() => {
|
|
48
|
-
if (typeof newValue !== 'undefined' && typeof value === 'undefined') {
|
|
49
|
-
setValue(newValue);
|
|
50
|
-
}
|
|
51
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
|
-
}, [...dependencies, value]);
|
|
53
|
-
return value;
|
|
54
|
-
};
|
|
55
|
-
const useTimeout = delay => {
|
|
56
|
-
const [ready, setReady] = useState(false);
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
const timeout = setTimeout(() => {
|
|
59
|
-
setReady(true);
|
|
60
|
-
}, delay);
|
|
61
|
-
return () => {
|
|
62
|
-
clearTimeout(timeout);
|
|
63
|
-
};
|
|
64
|
-
}, [delay]);
|
|
65
|
-
return ready;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export { useInputStyle };
|
|
69
|
-
//# sourceMappingURL=useInputStyle.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useInputStyle.mjs","sources":["../../../src/expressiveMoneyInput/hooks/useInputStyle.ts"],"sourcesContent":["import { type CSSProperties, useEffect, useLayoutEffect, useState } from 'react';\nimport { Props as ExpressiveMoneyInputProps } from '../ExpressiveMoneyInput';\n\ntype InputStyleObject = {\n value: string;\n focus: boolean;\n inputElement: HTMLInputElement | null;\n} & Pick<ExpressiveMoneyInputProps, 'loading'>;\n\nexport const useInputStyle = ({ value, focus, inputElement, loading }: InputStyleObject) => {\n const initialRender = !useTimeout(300);\n const inputWidth = useFirstDefinedValue(inputElement?.clientWidth, [inputElement, value]);\n\n const getStyle = (): CSSProperties => {\n const fontSize = getFontSize(value, focus, inputWidth);\n\n return {\n fontSize,\n height: fontSize,\n // aligns the top of the digit with the currency button\n marginTop: fontSize * -0.19,\n // if the input loads with a pre-filled value, we don't want to animate the font-size immediately\n transition: initialRender ? 'none' : undefined,\n color: loading ? 'var(--color-interactive-secondary)' : undefined,\n };\n };\n\n const [style, setStyle] = useState(getStyle());\n\n useLayoutEffect(() => {\n setStyle(getStyle());\n }, [value, focus, loading, inputWidth]);\n\n return style;\n};\n\nfunction getFontSize(inputValue: string, isFocused: boolean, inputWidth: number | undefined) {\n const defaultFontSize = 52;\n const focusFontSize = 90;\n const minimumFontSize = 34;\n\n let fontSize = isFocused ? focusFontSize : defaultFontSize;\n\n if (typeof inputWidth === 'undefined') {\n return fontSize;\n }\n const textLength = inputValue.length;\n const maxCharactersWithoutShrinking = Math.floor(inputWidth / 40);\n\n if (textLength > maxCharactersWithoutShrinking) {\n const adjustedSize = Math.round((inputWidth / textLength) * 1.9);\n fontSize = Math.min(fontSize, adjustedSize);\n }\n\n return Math.max(fontSize, minimumFontSize);\n}\n\nconst useFirstDefinedValue = (newValue: number | undefined, dependencies: unknown[]) => {\n const [value, setValue] = useState<number | undefined>(newValue);\n\n useLayoutEffect(() => {\n if (typeof newValue !== 'undefined' && typeof value === 'undefined') {\n setValue(newValue);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [...dependencies, value]);\n\n return value;\n};\n\nconst useTimeout = (delay: number) => {\n const [ready, setReady] = useState(false);\n\n useEffect(() => {\n const timeout = setTimeout(() => {\n setReady(true);\n }, delay);\n\n return () => {\n clearTimeout(timeout);\n };\n }, [delay]);\n\n return ready;\n};\n"],"names":["useInputStyle","value","focus","inputElement","loading","initialRender","useTimeout","inputWidth","useFirstDefinedValue","clientWidth","getStyle","fontSize","getFontSize","height","marginTop","transition","undefined","color","style","setStyle","useState","useLayoutEffect","inputValue","isFocused","defaultFontSize","focusFontSize","minimumFontSize","textLength","length","maxCharactersWithoutShrinking","Math","floor","adjustedSize","round","min","max","newValue","dependencies","setValue","delay","ready","setReady","useEffect","timeout","setTimeout","clearTimeout"],"mappings":";;AASO,MAAMA,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC,KAAK;EAAEC,YAAY;AAAEC,EAAAA;AAAO,CAAoB,KAAI;AACzF,EAAA,MAAMC,aAAa,GAAG,CAACC,UAAU,CAAC,GAAG,CAAC;AACtC,EAAA,MAAMC,UAAU,GAAGC,oBAAoB,CAACL,YAAY,EAAEM,WAAW,EAAE,CAACN,YAAY,EAAEF,KAAK,CAAC,CAAC;EAEzF,MAAMS,QAAQ,GAAGA,MAAoB;IACnC,MAAMC,QAAQ,GAAGC,WAAW,CAACX,KAAK,EAAEC,KAAK,EAAEK,UAAU,CAAC;IAEtD,OAAO;MACLI,QAAQ;AACRE,MAAAA,MAAM,EAAEF,QAAQ;AAChB;AACAG,MAAAA,SAAS,EAAEH,QAAQ,GAAG,KAAK;AAC3B;AACAI,MAAAA,UAAU,EAAEV,aAAa,GAAG,MAAM,GAAGW,SAAS;AAC9CC,MAAAA,KAAK,EAAEb,OAAO,GAAG,oCAAoC,GAAGY;KACzD;EACH,CAAC;EAED,MAAM,CAACE,KAAK,EAAEC,QAAQ,CAAC,GAAGC,QAAQ,CAACV,QAAQ,EAAE,CAAC;AAE9CW,EAAAA,eAAe,CAAC,MAAK;AACnBF,IAAAA,QAAQ,CAACT,QAAQ,EAAE,CAAC;EACtB,CAAC,EAAE,CAACT,KAAK,EAAEC,KAAK,EAAEE,OAAO,EAAEG,UAAU,CAAC,CAAC;AAEvC,EAAA,OAAOW,KAAK;AACd;AAEA,SAASN,WAAWA,CAACU,UAAkB,EAAEC,SAAkB,EAAEhB,UAA8B,EAAA;EACzF,MAAMiB,eAAe,GAAG,EAAE;EAC1B,MAAMC,aAAa,GAAG,EAAE;EACxB,MAAMC,eAAe,GAAG,EAAE;AAE1B,EAAA,IAAIf,QAAQ,GAAGY,SAA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CAAC;AAET,IAAA,OAAO,MAAK;MACVM,YAAY,CAACF,OAAO,CAAC;IACvB,CAAC;AACH,EAAA,CAAC,EAAE,CAACJ,KAAK,CAAC,CAAC;AAEX,EAAA,OAAOC,KAAK;AACd,CAAC;;;;"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
.wds-amount-input-container {
|
|
2
|
-
width: 100%;
|
|
3
|
-
}
|
|
4
|
-
.wds-amount-input-input-container {
|
|
5
|
-
display: flex;
|
|
6
|
-
justify-content: right;
|
|
7
|
-
width: 100%;
|
|
8
|
-
transition: font-size 0.4s cubic-bezier(0.3, 0, 0.1, 1), height 0.4s cubic-bezier(0.3, 0, 0.1, 1), margin-top 0.4s cubic-bezier(0.3, 0, 0.1, 1), color 0.4s ease;
|
|
9
|
-
color: var(--color-interactive-primary);
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
margin-bottom: 0 !important;
|
|
12
|
-
}
|
|
13
|
-
@media (prefers-reduced-motion: reduce) {
|
|
14
|
-
.wds-amount-input-input-container {
|
|
15
|
-
transition: none;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
.wds-amount-input-input {
|
|
19
|
-
border: none;
|
|
20
|
-
outline: none;
|
|
21
|
-
flex-grow: 1;
|
|
22
|
-
text-align: right;
|
|
23
|
-
background-color: transparent;
|
|
24
|
-
}
|
|
25
|
-
.wds-amount-input-input:focus-visible {
|
|
26
|
-
outline: none;
|
|
27
|
-
}
|
|
28
|
-
.wds-amount-input-placeholder {
|
|
29
|
-
flex-grow: 0;
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
}
|
|
33
|
-
.wds-currency-selector:disabled {
|
|
34
|
-
opacity: 1 !important;
|
|
35
|
-
cursor: auto !important;
|
|
36
|
-
cursor: initial !important;
|
|
37
|
-
mix-blend-mode: initial !important;
|
|
38
|
-
}
|
|
39
|
-
.wds-chevron-container {
|
|
40
|
-
width: 32px;
|
|
41
|
-
width: var(--size-32);
|
|
42
|
-
overflow: hidden;
|
|
43
|
-
color: var(--color-interactive-primary);
|
|
44
|
-
margin-left: 8px;
|
|
45
|
-
margin-left: var(--size-8);
|
|
46
|
-
transition: width 0.3s ease;
|
|
47
|
-
}
|
|
48
|
-
.wds-chevron-hidden {
|
|
49
|
-
width: 0;
|
|
50
|
-
}
|
|
51
|
-
.wds-expressive-money-input-currency-selector {
|
|
52
|
-
flex-shrink: 0;
|
|
53
|
-
margin-right: 24px;
|
|
54
|
-
margin-right: var(--size-24);
|
|
55
|
-
}
|
|
56
|
-
.wds-expressive-money-input-chevron {
|
|
57
|
-
transform: translateY(-5%);
|
|
58
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
.wds-amount-input-container {
|
|
2
|
-
width: 100%;
|
|
3
|
-
}
|
|
4
|
-
.wds-amount-input-input-container {
|
|
5
|
-
display: flex;
|
|
6
|
-
justify-content: right;
|
|
7
|
-
width: 100%;
|
|
8
|
-
transition: font-size 0.4s cubic-bezier(0.3, 0, 0.1, 1), height 0.4s cubic-bezier(0.3, 0, 0.1, 1), margin-top 0.4s cubic-bezier(0.3, 0, 0.1, 1), color 0.4s ease;
|
|
9
|
-
color: var(--color-interactive-primary);
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
margin-bottom: 0 !important;
|
|
12
|
-
}
|
|
13
|
-
@media (prefers-reduced-motion: reduce) {
|
|
14
|
-
.wds-amount-input-input-container {
|
|
15
|
-
transition: none;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
.wds-amount-input-input {
|
|
19
|
-
border: none;
|
|
20
|
-
outline: none;
|
|
21
|
-
flex-grow: 1;
|
|
22
|
-
text-align: right;
|
|
23
|
-
background-color: transparent;
|
|
24
|
-
}
|
|
25
|
-
.wds-amount-input-input:focus-visible {
|
|
26
|
-
outline: none;
|
|
27
|
-
}
|
|
28
|
-
.wds-amount-input-placeholder {
|
|
29
|
-
flex-grow: 0;
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { type Props as CurrencySelectorProps } from './currencySelector/CurrencySelector';
|
|
3
|
-
import { CommonProps } from '../common';
|
|
4
|
-
import { type InlinePromptProps } from '../prompt/InlinePrompt';
|
|
5
|
-
type AmountType = number | null;
|
|
6
|
-
export type CurrencyType = string;
|
|
7
|
-
type DefaultCurrencySelectorInstanceType = Pick<CurrencySelectorProps, 'addons' | 'options' | 'onChange' | 'onOpen' | 'onSearchChange'>;
|
|
8
|
-
type CustomCurrencySelectorInstanceType = {
|
|
9
|
-
customRender?: (props: {
|
|
10
|
-
id: string;
|
|
11
|
-
labelId: string;
|
|
12
|
-
}) => ReactNode;
|
|
13
|
-
};
|
|
14
|
-
type CurrencySelectorType = DefaultCurrencySelectorInstanceType & CustomCurrencySelectorInstanceType;
|
|
15
|
-
export type Props = {
|
|
16
|
-
label?: ReactNode;
|
|
17
|
-
currencySelector?: CurrencySelectorType;
|
|
18
|
-
amount?: AmountType;
|
|
19
|
-
currency: CurrencyType;
|
|
20
|
-
inlinePrompt?: {
|
|
21
|
-
sentiment?: InlinePromptProps['sentiment'];
|
|
22
|
-
message: InlinePromptProps['children'];
|
|
23
|
-
media?: InlinePromptProps['media'];
|
|
24
|
-
};
|
|
25
|
-
showChevron?: boolean;
|
|
26
|
-
autoFocus?: boolean;
|
|
27
|
-
loading?: boolean;
|
|
28
|
-
onAmountChange: (amount: AmountType) => void;
|
|
29
|
-
onFocusChange?: (focused: boolean) => void;
|
|
30
|
-
} & CommonProps;
|
|
31
|
-
export default function ExpressiveMoneyInput({ label, currency, currencySelector, amount, onAmountChange, className, inlinePrompt, showChevron, autoFocus, loading, onFocusChange, }: Props): import("react").JSX.Element;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=ExpressiveMoneyInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Expressive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CAAC;IAClB,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IAC7C,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C,GAAG,WAAW,CAAC;AAEhB,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,KAAK,EACL,QAAQ,EACR,gBAAyE,EACzE,MAAM,EACN,cAAc,EACd,SAAS,EACT,YAAY,EACZ,WAAW,EACX,SAAS,EACT,OAAO,EACP,aAAa,GACd,EAAE,KAAK,+BAwEP"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
currencySelectorSearchPlaceholder: {
|
|
3
|
-
id: string;
|
|
4
|
-
defaultMessage: string;
|
|
5
|
-
};
|
|
6
|
-
currencySelectorSelectCurrency: {
|
|
7
|
-
id: string;
|
|
8
|
-
defaultMessage: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export default _default;
|
|
12
|
-
//# sourceMappingURL=ExpressiveMoneyInput.messages.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressiveMoneyInput.messages.d.ts","sourceRoot":"","sources":["../../../src/expressiveMoneyInput/ExpressiveMoneyInput.messages.ts"],"names":[],"mappings":";;;;;;;;;;AAEA,wBAUG"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Props as ExpressiveMoneyInputProps } from '../ExpressiveMoneyInput';
|
|
2
|
-
type Props = {
|
|
3
|
-
id: string;
|
|
4
|
-
describedById?: string;
|
|
5
|
-
amount?: number | null;
|
|
6
|
-
currency: string;
|
|
7
|
-
autoFocus?: boolean;
|
|
8
|
-
onChange: (amount: number | null) => void;
|
|
9
|
-
onFocusChange?: (focused: boolean) => void;
|
|
10
|
-
} & Pick<ExpressiveMoneyInputProps, 'loading'>;
|
|
11
|
-
export declare const AmountInput: ({ id, describedById, amount, currency, autoFocus, onChange, onFocusChange, loading, }: Props) => import("react").JSX.Element;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=AmountInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AmountInput.d.ts","sourceRoot":"","sources":["../../../../src/expressiveMoneyInput/amountInput/AmountInput.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,IAAI,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAe7E,KAAK,KAAK,GAAG;IACX,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C,GAAG,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;AAE/C,eAAO,MAAM,WAAW,GAAI,uFASzB,KAAK,gCA2SP,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { KeyboardEvent } from 'react';
|
|
2
|
-
export declare const getDecimalSeparator: (currency: string, locale: string) => string | null;
|
|
3
|
-
export declare const getGroupSeparator: (currency: string, locale: string) => string | null;
|
|
4
|
-
export declare const getDecimalCount: (currency: string, locale: string) => number;
|
|
5
|
-
export declare const getEnteredDecimalsCount: (value: string, decimalSeparator: string) => number;
|
|
6
|
-
export declare const getUnformattedNumber: ({ value: formattedValue, currency, locale, }: {
|
|
7
|
-
value: string;
|
|
8
|
-
currency: string;
|
|
9
|
-
locale: string;
|
|
10
|
-
}) => number | null;
|
|
11
|
-
export declare const getFormattedString: ({ value: unformattedValue, currency, locale, alwaysShowDecimals, }: {
|
|
12
|
-
value: number;
|
|
13
|
-
currency: string;
|
|
14
|
-
locale: string;
|
|
15
|
-
alwaysShowDecimals?: boolean;
|
|
16
|
-
}) => string;
|
|
17
|
-
export declare const isInputPossiblyOverflowing: ({ ref, value, }: {
|
|
18
|
-
ref: React.RefObject<HTMLInputElement>;
|
|
19
|
-
value: string;
|
|
20
|
-
}) => boolean | undefined;
|
|
21
|
-
export declare const isAllowedInputKey: (e: KeyboardEvent<HTMLInputElement>) => boolean;
|
|
22
|
-
//# sourceMappingURL=utils.d.ts.map
|