@transferwise/components 0.0.0-experimental-4ed3f9f → 0.0.0-experimental-643f4d2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/build/i18n/en.json +0 -2
  2. package/build/i18n/en.json.js +0 -2
  3. package/build/i18n/en.json.js.map +1 -1
  4. package/build/i18n/en.json.mjs +0 -2
  5. package/build/i18n/en.json.mjs.map +1 -1
  6. package/build/index.js +0 -2
  7. package/build/index.js.map +1 -1
  8. package/build/index.mjs +0 -1
  9. package/build/index.mjs.map +1 -1
  10. package/build/main.css +15 -65
  11. package/build/prompt/InlinePrompt/InlinePrompt.js +0 -7
  12. package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
  13. package/build/prompt/InlinePrompt/InlinePrompt.mjs +1 -8
  14. package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
  15. package/build/styles/main.css +15 -65
  16. package/build/styles/moneyInput/MoneyInput.css +8 -0
  17. package/build/styles/prompt/InlinePrompt/InlinePrompt.css +7 -7
  18. package/build/types/index.d.ts +0 -2
  19. package/build/types/index.d.ts.map +1 -1
  20. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +2 -3
  21. package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
  22. package/build/types/test-utils/index.d.ts +0 -4
  23. package/build/types/test-utils/index.d.ts.map +1 -1
  24. package/package.json +1 -1
  25. package/src/i18n/en.json +0 -2
  26. package/src/index.ts +0 -2
  27. package/src/main.css +15 -65
  28. package/src/main.less +0 -1
  29. package/src/moneyInput/MoneyInput.css +8 -0
  30. package/src/moneyInput/MoneyInput.less +5 -0
  31. package/src/prompt/InlinePrompt/InlinePrompt.css +7 -7
  32. package/src/prompt/InlinePrompt/InlinePrompt.less +7 -7
  33. package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +0 -6
  34. package/src/prompt/InlinePrompt/InlinePrompt.tsx +2 -12
  35. package/src/ssr.spec.tsx +0 -1
  36. package/build/expressiveMoneyInput/AmountInput.js +0 -281
  37. package/build/expressiveMoneyInput/AmountInput.js.map +0 -1
  38. package/build/expressiveMoneyInput/AmountInput.mjs +0 -279
  39. package/build/expressiveMoneyInput/AmountInput.mjs.map +0 -1
  40. package/build/expressiveMoneyInput/AnimatedNumber.js +0 -50
  41. package/build/expressiveMoneyInput/AnimatedNumber.js.map +0 -1
  42. package/build/expressiveMoneyInput/AnimatedNumber.mjs +0 -48
  43. package/build/expressiveMoneyInput/AnimatedNumber.mjs.map +0 -1
  44. package/build/expressiveMoneyInput/Chevron.js +0 -31
  45. package/build/expressiveMoneyInput/Chevron.js.map +0 -1
  46. package/build/expressiveMoneyInput/Chevron.mjs +0 -29
  47. package/build/expressiveMoneyInput/Chevron.mjs.map +0 -1
  48. package/build/expressiveMoneyInput/CurrencySelector.js +0 -160
  49. package/build/expressiveMoneyInput/CurrencySelector.js.map +0 -1
  50. package/build/expressiveMoneyInput/CurrencySelector.mjs +0 -157
  51. package/build/expressiveMoneyInput/CurrencySelector.mjs.map +0 -1
  52. package/build/expressiveMoneyInput/ExpressiveMoneyInput.js +0 -114
  53. package/build/expressiveMoneyInput/ExpressiveMoneyInput.js.map +0 -1
  54. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js +0 -17
  55. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.js.map +0 -1
  56. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs +0 -13
  57. package/build/expressiveMoneyInput/ExpressiveMoneyInput.messages.mjs.map +0 -1
  58. package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs +0 -110
  59. package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs.map +0 -1
  60. package/build/expressiveMoneyInput/useFocus.js +0 -37
  61. package/build/expressiveMoneyInput/useFocus.js.map +0 -1
  62. package/build/expressiveMoneyInput/useFocus.mjs +0 -35
  63. package/build/expressiveMoneyInput/useFocus.mjs.map +0 -1
  64. package/build/expressiveMoneyInput/useInputStyle.js +0 -71
  65. package/build/expressiveMoneyInput/useInputStyle.js.map +0 -1
  66. package/build/expressiveMoneyInput/useInputStyle.mjs +0 -69
  67. package/build/expressiveMoneyInput/useInputStyle.mjs.map +0 -1
  68. package/build/expressiveMoneyInput/utils.js +0 -87
  69. package/build/expressiveMoneyInput/utils.js.map +0 -1
  70. package/build/expressiveMoneyInput/utils.mjs +0 -78
  71. package/build/expressiveMoneyInput/utils.mjs.map +0 -1
  72. package/build/styles/expressiveMoneyInput/AmountInput.css +0 -32
  73. package/build/styles/expressiveMoneyInput/Chevron.css +0 -12
  74. package/build/styles/expressiveMoneyInput/CurrencySelector.css +0 -6
  75. package/build/styles/expressiveMoneyInput/ExpressiveMoneyInput.css +0 -58
  76. package/build/types/expressiveMoneyInput/AmountInput.d.ts +0 -13
  77. package/build/types/expressiveMoneyInput/AmountInput.d.ts.map +0 -1
  78. package/build/types/expressiveMoneyInput/AnimatedNumber.d.ts +0 -9
  79. package/build/types/expressiveMoneyInput/AnimatedNumber.d.ts.map +0 -1
  80. package/build/types/expressiveMoneyInput/Chevron.d.ts +0 -6
  81. package/build/types/expressiveMoneyInput/Chevron.d.ts.map +0 -1
  82. package/build/types/expressiveMoneyInput/CurrencySelector.d.ts +0 -30
  83. package/build/types/expressiveMoneyInput/CurrencySelector.d.ts.map +0 -1
  84. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts +0 -33
  85. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts.map +0 -1
  86. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts +0 -12
  87. package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.messages.d.ts.map +0 -1
  88. package/build/types/expressiveMoneyInput/index.d.ts +0 -3
  89. package/build/types/expressiveMoneyInput/index.d.ts.map +0 -1
  90. package/build/types/expressiveMoneyInput/useFocus.d.ts +0 -7
  91. package/build/types/expressiveMoneyInput/useFocus.d.ts.map +0 -1
  92. package/build/types/expressiveMoneyInput/useInputStyle.d.ts +0 -10
  93. package/build/types/expressiveMoneyInput/useInputStyle.d.ts.map +0 -1
  94. package/build/types/expressiveMoneyInput/useSelectionRange.d.ts +0 -10
  95. package/build/types/expressiveMoneyInput/useSelectionRange.d.ts.map +0 -1
  96. package/build/types/expressiveMoneyInput/utils.d.ts +0 -22
  97. package/build/types/expressiveMoneyInput/utils.d.ts.map +0 -1
  98. package/src/expressiveMoneyInput/AmountInput.css +0 -32
  99. package/src/expressiveMoneyInput/AmountInput.less +0 -43
  100. package/src/expressiveMoneyInput/AmountInput.tsx +0 -353
  101. package/src/expressiveMoneyInput/AnimatedNumber.tsx +0 -40
  102. package/src/expressiveMoneyInput/Chevron.css +0 -12
  103. package/src/expressiveMoneyInput/Chevron.less +0 -13
  104. package/src/expressiveMoneyInput/Chevron.tsx +0 -35
  105. package/src/expressiveMoneyInput/CurrencySelector.css +0 -6
  106. package/src/expressiveMoneyInput/CurrencySelector.less +0 -7
  107. package/src/expressiveMoneyInput/CurrencySelector.tsx +0 -218
  108. package/src/expressiveMoneyInput/ExpressiveMoneyInput.css +0 -58
  109. package/src/expressiveMoneyInput/ExpressiveMoneyInput.less +0 -13
  110. package/src/expressiveMoneyInput/ExpressiveMoneyInput.messages.ts +0 -13
  111. package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +0 -290
  112. package/src/expressiveMoneyInput/ExpressiveMoneyInput.tsx +0 -118
  113. package/src/expressiveMoneyInput/index.ts +0 -2
  114. package/src/expressiveMoneyInput/useFocus.ts +0 -35
  115. package/src/expressiveMoneyInput/useInputStyle.ts +0 -85
  116. package/src/expressiveMoneyInput/useSelectionRange.ts +0 -23
  117. package/src/expressiveMoneyInput/utils.spec.ts +0 -114
  118. package/src/expressiveMoneyInput/utils.ts +0 -116
  119. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +0 -57
@@ -1,160 +0,0 @@
1
- 'use strict';
2
-
3
- var Button_resolver = require('../button/Button.resolver.js');
4
- var SelectInput = require('../inputs/SelectInput.js');
5
- var icons = require('@transferwise/icons');
6
- var art = require('@wise/art');
7
- var React = require('react');
8
- var reactIntl = require('react-intl');
9
- var ExpressiveMoneyInput_messages = require('./ExpressiveMoneyInput.messages.js');
10
- var jsxRuntime = require('react/jsx-runtime');
11
-
12
- const CurrencySelector = ({
13
- id,
14
- currency,
15
- options = [],
16
- labelId,
17
- onChange,
18
- addons,
19
- onOpen,
20
- onSearchChange
21
- }) => {
22
- const intl = reactIntl.useIntl();
23
- const allCurrencyOptions = React.useMemo(() => getUniqueCurrencies(options), [options]);
24
- const activeCurrencyOption = React.useMemo(() => {
25
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
26
- return allCurrencyOptions.find(option => option.code === currency);
27
- }, [currency, allCurrencyOptions]);
28
- const disabled = !onChange || options.length === 0 || options.length === 1 && options[0].currencies.length <= 1;
29
- const [searchQuery, setSearchQuery] = React.useState('');
30
- const handleTriggerClick = event => {
31
- const triggerEl = event.currentTarget;
32
- if (triggerEl?.getAttribute('aria-expanded') === 'false') {
33
- onOpen?.();
34
- }
35
- };
36
- const items = searchQuery ? filterAndSortCurrenciesForQuery(allCurrencyOptions, searchQuery).map(getCurrencySelectOption) : options.map(getCurrencyGroup);
37
- return /*#__PURE__*/jsxRuntime.jsx(SelectInput.SelectInput, {
38
- compareValues: "code",
39
- disabled: disabled,
40
- id: id,
41
- value: activeCurrencyOption,
42
- filterable: true,
43
- filterPlaceholder: intl.formatMessage(ExpressiveMoneyInput_messages.default.currencySelectorSearchPlaceholder),
44
- UNSAFE_triggerButtonProps: {
45
- id: undefined,
46
- 'aria-labelledby': undefined,
47
- 'aria-describedby': labelId,
48
- 'aria-invalid': undefined,
49
- 'aria-label': intl.formatMessage(ExpressiveMoneyInput_messages.default.currencySelectorSelectCurrency)
50
- },
51
- items: items,
52
- renderValue: ({
53
- code,
54
- label
55
- }) => {
56
- return /*#__PURE__*/jsxRuntime.jsx(SelectInput.SelectInputOptionContent, {
57
- title: code,
58
- note: label,
59
- icon: /*#__PURE__*/jsxRuntime.jsx(art.Flag, {
60
- code: code,
61
- intrinsicSize: 24
62
- })
63
- });
64
- },
65
- renderTrigger: () => /*#__PURE__*/jsxRuntime.jsx(SelectInput.SelectInputTriggerButton, {
66
- as: ButtonInput
67
- // @ts-expect-error new (v2) ButtonProps
68
- ,
69
- addonStart: {
70
- type: 'avatar',
71
- value: [addons ? addons[0] : null, {
72
- ...(addons && addons.length > 1 ? {
73
- ...addons[1]
74
- } : {
75
- asset: /*#__PURE__*/jsxRuntime.jsx(art.Flag, {
76
- code: currency
77
- })
78
- })
79
- }].filter(avatar => Boolean(avatar))
80
- },
81
- addonEnd: disabled ? undefined : {
82
- type: 'icon',
83
- value: /*#__PURE__*/jsxRuntime.jsx(icons.ChevronDown, {})
84
- },
85
- onClick: event => handleTriggerClick(event),
86
- children: currency
87
- }),
88
- onChange: newValue => {
89
- onChange?.(newValue.code);
90
- },
91
- onFilterChange: ({
92
- queryNormalized
93
- }) => {
94
- setSearchQuery(queryNormalized ?? '');
95
- if (queryNormalized) {
96
- onSearchChange?.({
97
- query: queryNormalized,
98
- resultCount: filterAndSortCurrenciesForQuery(allCurrencyOptions, queryNormalized).length
99
- });
100
- }
101
- }
102
- });
103
- };
104
- const ButtonInput = /*#__PURE__*/React.forwardRef(function ButtonInput({
105
- children,
106
- ...rest
107
- }, ref) {
108
- return /*#__PURE__*/jsxRuntime.jsx(Button_resolver.default, {
109
- ref: ref,
110
- size: "md",
111
- v2: true,
112
- className: "wds-currency-selector",
113
- priority: "secondary-neutral",
114
- ...rest,
115
- children: children
116
- });
117
- });
118
- const getCurrencySelectOption = currency => {
119
- return {
120
- type: 'option',
121
- value: currency,
122
- filterMatchers: currency.keywords
123
- };
124
- };
125
- const getCurrencyGroup = section => {
126
- return {
127
- type: 'group',
128
- label: section.title,
129
- options: section.currencies.map(getCurrencySelectOption)
130
- };
131
- };
132
- const getUniqueCurrencies = options => {
133
- const allCurrencyOptions = options.flatMap(section => section.currencies);
134
- const uniqueCurrencies = new Map();
135
- allCurrencyOptions.forEach(currencyObj => {
136
- uniqueCurrencies.set(currencyObj.code, currencyObj);
137
- });
138
- return Array.from(uniqueCurrencies.values());
139
- };
140
- const filterAndSortCurrenciesForQuery = (currencies, query) => {
141
- return currencies.filter(currency => {
142
- return currency.code.toLowerCase().includes(query) || (currency.label ?? '').toLowerCase().includes(query) || currency.keywords?.some(keyword => keyword.toLowerCase().includes(query));
143
- })
144
- // prefer exact matches, then sort alphabetically by code
145
- .sort((a, b) => {
146
- const aCode = a.code.toLowerCase();
147
- const bCode = b.code.toLowerCase();
148
- if (aCode === query) {
149
- return -1;
150
- }
151
- if (bCode === query) {
152
- return 1;
153
- }
154
- return aCode.localeCompare(bCode);
155
- });
156
- };
157
-
158
- exports.ButtonInput = ButtonInput;
159
- exports.CurrencySelector = CurrencySelector;
160
- //# sourceMappingURL=CurrencySelector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CurrencySelector.js","sources":["../../src/expressiveMoneyInput/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,iBAAO,EAAE;AAEtB,EAAA,MAAMC,kBAAkB,GAAGC,aAAO,CAAC,MAAMC,mBAAmB,CAACV,OAAO,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;AAEjF,EAAA,MAAMW,oBAAoB,GAAGF,aAAO,CAAC,MAAK;AACxC;IACA,OAAOD,kBAAkB,CAACI,IAAI,CAAEC,MAAM,IAAKA,MAAM,CAACC,IAAI,KAAKf,QAAQ,CAAE;AACvE,EAAA,CAA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K,CAAC;AACnC,EAAA,CAAC,CAAC;AAER,CAAC;;;;;"}
@@ -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.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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}
@@ -1,114 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var Body = require('../body/Body.js');
6
- var Label = require('../label/Label.js');
7
- var clsx = require('clsx');
8
- var framerMotion = require('framer-motion');
9
- var React = require('react');
10
- var CurrencySelector = require('./CurrencySelector.js');
11
- var AmountInput = require('./AmountInput.js');
12
- var Chevron = require('./Chevron.js');
13
- var InlinePrompt = require('../prompt/InlinePrompt/InlinePrompt.js');
14
- var jsxRuntime = require('react/jsx-runtime');
15
-
16
- function ExpressiveMoneyInput({
17
- label,
18
- currency,
19
- currencySelector = {
20
- options: []
21
- },
22
- amount,
23
- onAmountChange,
24
- className,
25
- inlinePrompt,
26
- showChevron,
27
- autoFocus,
28
- loading,
29
- onFocusChange
30
- }) {
31
- const inputId = React.useId();
32
- const labelId = React.useId();
33
- const customAlertId = React.useId();
34
- const currencyId = React.useId();
35
- const selector = currencySelector.customRender?.({
36
- id: currencyId,
37
- labelId
38
- }) ?? /*#__PURE__*/jsxRuntime.jsx(CurrencySelector.CurrencySelector, {
39
- id: currencyId,
40
- labelId: labelId,
41
- currency: currency,
42
- ...currencySelector
43
- });
44
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
45
- className: clsx.clsx('wds-expressive-money-input', className),
46
- children: [/*#__PURE__*/jsxRuntime.jsx(Label.Label, {
47
- id: labelId,
48
- htmlFor: inputId,
49
- className: clsx.clsx('m-b-1', 'font-weight-normal'),
50
- children: label
51
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
52
- className: clsx.clsx('d-flex'),
53
- role: "group",
54
- "aria-labelledby": labelId,
55
- ...(inlinePrompt ? {
56
- 'aria-describedby': customAlertId
57
- } : {}),
58
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
59
- className: "wds-expressive-money-input-currency-selector",
60
- children: selector
61
- }), /*#__PURE__*/jsxRuntime.jsx(AmountInput.AmountInput, {
62
- id: inputId,
63
- describedById: currencyId,
64
- amount: amount,
65
- currency: currency
66
- // eslint-disable-next-line jsx-a11y/no-autofocus
67
- ,
68
- autoFocus: autoFocus,
69
- loading: loading,
70
- onChange: onAmountChange,
71
- onFocusChange: onFocusChange
72
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
73
- className: clsx.clsx('d-flex align-items-center', 'wds-expressive-money-input-chevron'),
74
- children: /*#__PURE__*/jsxRuntime.jsx(Chevron.Chevron, {
75
- shouldShow: Boolean(showChevron)
76
- })
77
- })]
78
- }), /*#__PURE__*/jsxRuntime.jsx(framerMotion.AnimatePresence, {
79
- initial: false,
80
- children: inlinePrompt && /*#__PURE__*/jsxRuntime.jsx("div", {
81
- className: clsx.clsx('d-flex justify-content-end', inlinePrompt && 'm-t-1'),
82
- children: /*#__PURE__*/jsxRuntime.jsx(framerMotion.motion.div, {
83
- initial: {
84
- opacity: 0,
85
- height: 0
86
- },
87
- animate: {
88
- opacity: 1,
89
- height: 'auto',
90
- transition: {
91
- delay: 0.75,
92
- duration: 0.3
93
- }
94
- },
95
- exit: {
96
- opacity: 0,
97
- height: 0
98
- },
99
- children: inlinePrompt.sentiment ? /*#__PURE__*/jsxRuntime.jsx(InlinePrompt.InlinePrompt, {
100
- id: customAlertId,
101
- media: inlinePrompt.media,
102
- sentiment: inlinePrompt.sentiment,
103
- children: inlinePrompt.message
104
- }) : /*#__PURE__*/jsxRuntime.jsx(Body.default, {
105
- children: inlinePrompt.message
106
- })
107
- }, customAlertId)
108
- })
109
- })]
110
- });
111
- }
112
-
113
- exports.default = ExpressiveMoneyInput;
114
- //# sourceMappingURL=ExpressiveMoneyInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpressiveMoneyInput.js","sources":["../../src/expressiveMoneyInput/ExpressiveMoneyInput.tsx"],"sourcesContent":["import Body from '../body';\nimport { Label } from '../label/Label';\nimport { clsx } from 'clsx';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { useId, type ReactNode } from 'react';\n\nimport { type Props as CurrencySelectorProps, CurrencySelector } from './CurrencySelector';\nimport { CommonProps } from '../common';\nimport { AmountInput } from './AmountInput';\nimport { Chevron } from './Chevron';\nimport { InlinePrompt, type InlinePromptProps } from '../prompt/InlinePrompt';\n\ntype AmountType = number | null;\nexport type CurrencyType = string;\n\ntype DefaultCurrencySelectorInstanceType = Pick<\n CurrencySelectorProps,\n 'addons' | 'options' | 'onChange' | 'onOpen' | 'onSearchChange'\n>;\ntype CustomCurrencySelectorInstanceType = {\n customRender?: (props: { id: string; labelId: string }) => ReactNode;\n};\ntype CurrencySelectorType = DefaultCurrencySelectorInstanceType &\n CustomCurrencySelectorInstanceType;\n\nexport type Props = {\n label?: ReactNode;\n currencySelector?: CurrencySelectorType;\n amount?: AmountType;\n currency: CurrencyType;\n inlinePrompt?: {\n sentiment?: InlinePromptProps['sentiment'];\n message: InlinePromptProps['children'];\n media?: InlinePromptProps['media'];\n };\n showChevron?: boolean;\n autoFocus?: boolean;\n loading?: boolean;\n onAmountChange: (amount: AmountType) => void;\n onFocusChange?: (focused: boolean) => void;\n} & CommonProps;\n\nexport default function ExpressiveMoneyInput({\n label,\n currency,\n currencySelector = { options: [] } as DefaultCurrencySelectorInstanceType,\n amount,\n onAmountChange,\n className,\n inlinePrompt,\n showChevron,\n autoFocus,\n loading,\n onFocusChange,\n}: Props) {\n const inputId = useId();\n const labelId = useId();\n const customAlertId = useId();\n const currencyId = useId();\n\n const selector = currencySelector.customRender?.({ id: currencyId, labelId }) ?? (\n <CurrencySelector id={currencyId} labelId={labelId} currency={currency} {...currencySelector} />\n );\n\n return (\n <div className={clsx('wds-expressive-money-input', className)}>\n <Label id={labelId} htmlFor={inputId} className={clsx('m-b-1', 'font-weight-normal')}>\n {label}\n </Label>\n <div\n className={clsx('d-flex')}\n role=\"group\"\n aria-labelledby={labelId}\n {...(inlinePrompt ? { 'aria-describedby': customAlertId } : {})}\n >\n <div className=\"wds-expressive-money-input-currency-selector\">{selector}</div>\n <AmountInput\n id={inputId}\n describedById={currencyId}\n amount={amount}\n currency={currency}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n loading={loading}\n onChange={onAmountChange}\n onFocusChange={onFocusChange}\n />\n <div className={clsx('d-flex align-items-center', 'wds-expressive-money-input-chevron')}>\n <Chevron shouldShow={Boolean(showChevron)} />\n </div>\n </div>\n <AnimatePresence initial={false}>\n {inlinePrompt && (\n <div className={clsx('d-flex justify-content-end', inlinePrompt && 'm-t-1')}>\n <motion.div\n key={customAlertId}\n initial={{ opacity: 0, height: 0 }}\n animate={{\n opacity: 1,\n height: 'auto',\n transition: { delay: 0.75, duration: 0.3 },\n }}\n exit={{ opacity: 0, height: 0 }}\n >\n {inlinePrompt.sentiment ? (\n <InlinePrompt id={customAlertId} media={inlinePrompt.media} sentiment={inlinePrompt.sentiment}>\n {inlinePrompt.message}\n </InlinePrompt>\n ) : (\n <Body>{inlinePrompt.message}</Body>\n )}\n </motion.div>\n </div>\n )}\n </AnimatePresence>\n </div>\n );\n}\n"],"names":["ExpressiveMoneyInput","label","currency","currencySelector","options","amount","onAmountChange","className","inlinePrompt","showChevron","autoFocus","loading","onFocusChange","inputId","useId","labelId","customAlertId","currencyId","selector","customRender","id","_jsx","CurrencySelector","_jsxs","clsx","children","Label","htmlFor","role","AmountInput","describedById","onChange","Chevron","shouldShow","Boolean","AnimatePresence","initial","motion","div","opacity","height","animate","transition","delay","duration","exit","sentiment","InlinePrompt","media","message","Body"],"mappings":";;;;;;;;;;;;;;;AA0Cc,SAAUA,oBAAoBA,CAAC;EAC3CC,KAAK;EACLC,QAAQ;AACRC,EAAAA,gBAAgB,GAAG;AAAEC,IAAAA,OAAO,EAAE;GAA2C;EACzEC,MAAM;EACNC,cAAc;EACdC,SAAS;EACTC,YAAY;EACZC,WAAW;EACXC,SAAS;EACTC,OAAO;AACPC,EAAAA;AAAa,CACP,EAAA;AACN,EAAA,MAAMC,OAAO,GAAGC,WAAK,EAAE;AACvB,EAAA,MAAMC,OAAO,GAAGD,WAAK,EAAE;AACvB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EtC,YAAY,CAACsC,SAAU;YAAArB,QAAA,EAC3FjB,YAAY,CAACyC;AAAO,WACT,CAAC,gBAEf5B,cAAA,CAAC6B,YAAI,EAAA;YAAAzB,QAAA,EAAEjB,YAAY,CAACyC;WAAc;AACnC,SAAA,EAfIjC,aAgBK;OACT;AACN,KACc,CACnB;AAAA,GAAK,CAAC;AAEV;;;;"}
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var reactIntl = require('react-intl');
6
-
7
- var messages = reactIntl.defineMessages({
8
- currencySelectorSearchPlaceholder: {
9
- id: "neptune.ExpressiveMoneyInput.currency.search.placeholder"
10
- },
11
- currencySelectorSelectCurrency: {
12
- id: "neptune.ExpressiveMoneyInput.currency.select.currency"
13
- }
14
- });
15
-
16
- exports.default = messages;
17
- //# sourceMappingURL=ExpressiveMoneyInput.messages.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpressiveMoneyInput.messages.js","sources":["../../src/expressiveMoneyInput/ExpressiveMoneyInput.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n currencySelectorSearchPlaceholder: {\n id: 'neptune.ExpressiveMoneyInput.currency.search.placeholder',\n defaultMessage: 'Type a currency / country',\n },\n\n currencySelectorSelectCurrency: {\n id: 'neptune.ExpressiveMoneyInput.currency.select.currency',\n defaultMessage: 'Select currency',\n },\n});\n"],"names":["defineMessages","currencySelectorSearchPlaceholder","id","currencySelectorSelectCurrency"],"mappings":";;;;;;AAEA,eAAeA,wBAAc,CAAC;AAC5BC,EAAAA,iCAAiC,EAAE;IACjCC,EAAE,EAAA;GAEH;AAEDC,EAAAA,8BAA8B,EAAE;IAC9BD,EAAE,EAAA;AAEH;AACF,CAAA,CAAC;;;;"}
@@ -1,13 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- var messages = defineMessages({
4
- currencySelectorSearchPlaceholder: {
5
- id: "neptune.ExpressiveMoneyInput.currency.search.placeholder"
6
- },
7
- currencySelectorSelectCurrency: {
8
- id: "neptune.ExpressiveMoneyInput.currency.select.currency"
9
- }
10
- });
11
-
12
- export { messages as default };
13
- //# sourceMappingURL=ExpressiveMoneyInput.messages.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExpressiveMoneyInput.messages.mjs","sources":["../../src/expressiveMoneyInput/ExpressiveMoneyInput.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n currencySelectorSearchPlaceholder: {\n id: 'neptune.ExpressiveMoneyInput.currency.search.placeholder',\n defaultMessage: 'Type a currency / country',\n },\n\n currencySelectorSelectCurrency: {\n id: 'neptune.ExpressiveMoneyInput.currency.select.currency',\n defaultMessage: 'Select currency',\n },\n});\n"],"names":["defineMessages","currencySelectorSearchPlaceholder","id","currencySelectorSelectCurrency"],"mappings":";;AAEA,eAAeA,cAAc,CAAC;AAC5BC,EAAAA,iCAAiC,EAAE;IACjCC,EAAE,EAAA;GAEH;AAEDC,EAAAA,8BAA8B,EAAE;IAC9BD,EAAE,EAAA;AAEH;AACF,CAAA,CAAC;;;;"}
@@ -1,110 +0,0 @@
1
- import Body from '../body/Body.mjs';
2
- import { Label as LabelNamespace } from '../label/Label.mjs';
3
- import { clsx } from 'clsx';
4
- import { AnimatePresence, motion } from 'framer-motion';
5
- import { useId } from 'react';
6
- import { CurrencySelector } from './CurrencySelector.mjs';
7
- import { AmountInput } from './AmountInput.mjs';
8
- import { Chevron } from './Chevron.mjs';
9
- import { InlinePrompt } from '../prompt/InlinePrompt/InlinePrompt.mjs';
10
- import { jsx, jsxs } from 'react/jsx-runtime';
11
-
12
- function ExpressiveMoneyInput({
13
- label,
14
- currency,
15
- currencySelector = {
16
- options: []
17
- },
18
- amount,
19
- onAmountChange,
20
- className,
21
- inlinePrompt,
22
- showChevron,
23
- autoFocus,
24
- loading,
25
- onFocusChange
26
- }) {
27
- const inputId = useId();
28
- const labelId = useId();
29
- const customAlertId = useId();
30
- const currencyId = useId();
31
- const selector = currencySelector.customRender?.({
32
- id: currencyId,
33
- labelId
34
- }) ?? /*#__PURE__*/jsx(CurrencySelector, {
35
- id: currencyId,
36
- labelId: labelId,
37
- currency: currency,
38
- ...currencySelector
39
- });
40
- return /*#__PURE__*/jsxs("div", {
41
- className: clsx('wds-expressive-money-input', className),
42
- children: [/*#__PURE__*/jsx(LabelNamespace, {
43
- id: labelId,
44
- htmlFor: inputId,
45
- className: clsx('m-b-1', 'font-weight-normal'),
46
- children: label
47
- }), /*#__PURE__*/jsxs("div", {
48
- className: clsx('d-flex'),
49
- role: "group",
50
- "aria-labelledby": labelId,
51
- ...(inlinePrompt ? {
52
- 'aria-describedby': customAlertId
53
- } : {}),
54
- children: [/*#__PURE__*/jsx("div", {
55
- className: "wds-expressive-money-input-currency-selector",
56
- children: selector
57
- }), /*#__PURE__*/jsx(AmountInput, {
58
- id: inputId,
59
- describedById: currencyId,
60
- amount: amount,
61
- currency: currency
62
- // eslint-disable-next-line jsx-a11y/no-autofocus
63
- ,
64
- autoFocus: autoFocus,
65
- loading: loading,
66
- onChange: onAmountChange,
67
- onFocusChange: onFocusChange
68
- }), /*#__PURE__*/jsx("div", {
69
- className: clsx('d-flex align-items-center', 'wds-expressive-money-input-chevron'),
70
- children: /*#__PURE__*/jsx(Chevron, {
71
- shouldShow: Boolean(showChevron)
72
- })
73
- })]
74
- }), /*#__PURE__*/jsx(AnimatePresence, {
75
- initial: false,
76
- children: inlinePrompt && /*#__PURE__*/jsx("div", {
77
- className: clsx('d-flex justify-content-end', inlinePrompt && 'm-t-1'),
78
- children: /*#__PURE__*/jsx(motion.div, {
79
- initial: {
80
- opacity: 0,
81
- height: 0
82
- },
83
- animate: {
84
- opacity: 1,
85
- height: 'auto',
86
- transition: {
87
- delay: 0.75,
88
- duration: 0.3
89
- }
90
- },
91
- exit: {
92
- opacity: 0,
93
- height: 0
94
- },
95
- children: inlinePrompt.sentiment ? /*#__PURE__*/jsx(InlinePrompt, {
96
- id: customAlertId,
97
- media: inlinePrompt.media,
98
- sentiment: inlinePrompt.sentiment,
99
- children: inlinePrompt.message
100
- }) : /*#__PURE__*/jsx(Body, {
101
- children: inlinePrompt.message
102
- })
103
- }, customAlertId)
104
- })
105
- })]
106
- });
107
- }
108
-
109
- export { ExpressiveMoneyInput as default };
110
- //# sourceMappingURL=ExpressiveMoneyInput.mjs.map