@transferwise/components 46.130.2 → 46.130.3
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/dateInput/DateInput.js +12 -5
- package/build/dateInput/DateInput.js.map +1 -1
- package/build/dateInput/DateInput.mjs +11 -4
- package/build/dateInput/DateInput.mjs.map +1 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +16 -8
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +1 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +14 -6
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +1 -1
- package/build/index.js +12 -7
- package/build/index.js.map +1 -1
- package/build/index.mjs +9 -3
- package/build/index.mjs.map +1 -1
- package/build/inputs/{_BottomSheet.js → SelectInput/BottomSheet/SelectInputBottomSheet.js} +7 -7
- package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.js.map +1 -0
- package/build/inputs/{_BottomSheet.mjs → SelectInput/BottomSheet/SelectInputBottomSheet.mjs} +7 -7
- package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.mjs.map +1 -0
- package/build/inputs/{_ButtonInput.js → SelectInput/ButtonInput/SelectInputButtonInput.js} +5 -5
- package/build/inputs/SelectInput/ButtonInput/SelectInputButtonInput.js.map +1 -0
- package/build/inputs/{_ButtonInput.mjs → SelectInput/ButtonInput/SelectInputButtonInput.mjs} +5 -5
- package/build/inputs/SelectInput/ButtonInput/SelectInputButtonInput.mjs.map +1 -0
- package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.js +26 -0
- package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.js.map +1 -0
- package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.mjs +24 -0
- package/build/inputs/SelectInput/ClearButton/SelectInputClearButton.mjs.map +1 -0
- package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.js +59 -0
- package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.js.map +1 -0
- package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.mjs +56 -0
- package/build/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.mjs.map +1 -0
- package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.js +50 -0
- package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.js.map +1 -0
- package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.mjs +48 -0
- package/build/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.mjs.map +1 -0
- package/build/inputs/SelectInput/ItemView/SelectInputItemView.js +47 -0
- package/build/inputs/SelectInput/ItemView/SelectInputItemView.js.map +1 -0
- package/build/inputs/SelectInput/ItemView/SelectInputItemView.mjs +45 -0
- package/build/inputs/SelectInput/ItemView/SelectInputItemView.mjs.map +1 -0
- package/build/inputs/SelectInput/Option/SelectInputOption.js +42 -0
- package/build/inputs/SelectInput/Option/SelectInputOption.js.map +1 -0
- package/build/inputs/SelectInput/Option/SelectInputOption.mjs +40 -0
- package/build/inputs/SelectInput/Option/SelectInputOption.mjs.map +1 -0
- package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js +40 -0
- package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.js.map +1 -0
- package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs +38 -0
- package/build/inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs.map +1 -0
- package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js +48 -0
- package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.js.map +1 -0
- package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs +46 -0
- package/build/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.mjs.map +1 -0
- package/build/inputs/SelectInput/Options/SelectInputOptions.js +300 -0
- package/build/inputs/SelectInput/Options/SelectInputOptions.js.map +1 -0
- package/build/inputs/SelectInput/Options/SelectInputOptions.mjs +298 -0
- package/build/inputs/SelectInput/Options/SelectInputOptions.mjs.map +1 -0
- package/build/inputs/{_Popover.js → SelectInput/Popover/SelectInputPopover.js} +7 -7
- package/build/inputs/SelectInput/Popover/SelectInputPopover.js.map +1 -0
- package/build/inputs/{_Popover.mjs → SelectInput/Popover/SelectInputPopover.mjs} +7 -7
- package/build/inputs/SelectInput/Popover/SelectInputPopover.mjs.map +1 -0
- package/build/inputs/SelectInput/SelectInput.contexts.js +29 -0
- package/build/inputs/SelectInput/SelectInput.contexts.js.map +1 -0
- package/build/inputs/SelectInput/SelectInput.contexts.mjs +24 -0
- package/build/inputs/SelectInput/SelectInput.contexts.mjs.map +1 -0
- package/build/inputs/SelectInput/SelectInput.js +222 -0
- package/build/inputs/SelectInput/SelectInput.js.map +1 -0
- package/build/inputs/SelectInput/SelectInput.messages.js.map +1 -0
- package/build/inputs/SelectInput/SelectInput.messages.mjs.map +1 -0
- package/build/inputs/SelectInput/SelectInput.mjs +216 -0
- package/build/inputs/SelectInput/SelectInput.mjs.map +1 -0
- package/build/inputs/SelectInput/SelectInput.utils.js +164 -0
- package/build/inputs/SelectInput/SelectInput.utils.js.map +1 -0
- package/build/inputs/SelectInput/SelectInput.utils.mjs +154 -0
- package/build/inputs/SelectInput/SelectInput.utils.mjs.map +1 -0
- package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js +42 -0
- package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js.map +1 -0
- package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs +36 -0
- package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs.map +1 -0
- package/build/main.css +90 -90
- package/build/moneyInput/MoneyInput.js +9 -2
- package/build/moneyInput/MoneyInput.js.map +1 -1
- package/build/moneyInput/MoneyInput.mjs +8 -1
- package/build/moneyInput/MoneyInput.mjs.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.js +10 -3
- package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.mjs +9 -2
- package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
- package/build/styles/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.css +96 -0
- package/build/styles/inputs/SelectInput/ButtonInput/SelectInputButtonInput.css +16 -0
- package/build/styles/inputs/SelectInput/ClearButton/SelectInputClearButton.css +46 -0
- package/build/styles/inputs/SelectInput/ItemView/SelectInputItemView.css +16 -0
- package/build/styles/inputs/SelectInput/Option/SelectInputOption.css +33 -0
- package/build/styles/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +37 -0
- package/build/styles/inputs/SelectInput/Options/SelectInputOptions.css +81 -0
- package/build/styles/inputs/SelectInput/Popover/SelectInputPopover.css +46 -0
- package/build/styles/main.css +90 -90
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/{_BottomSheet.d.ts → SelectInput/BottomSheet/SelectInputBottomSheet.d.ts} +3 -3
- package/build/types/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/BottomSheet/index.d.ts +3 -0
- package/build/types/inputs/SelectInput/BottomSheet/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/ButtonInput/SelectInputButtonInput.d.ts +5 -0
- package/build/types/inputs/SelectInput/ButtonInput/SelectInputButtonInput.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/ButtonInput/index.d.ts +3 -0
- package/build/types/inputs/SelectInput/ButtonInput/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/ClearButton/SelectInputClearButton.d.ts +7 -0
- package/build/types/inputs/SelectInput/ClearButton/SelectInputClearButton.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/ClearButton/index.d.ts +3 -0
- package/build/types/inputs/SelectInput/ClearButton/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.d.ts +16 -0
- package/build/types/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/DefaultRenderTrigger/index.d.ts +2 -0
- package/build/types/inputs/SelectInput/DefaultRenderTrigger/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.d.ts +9 -0
- package/build/types/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/ItemView/GroupItemView/index.d.ts +3 -0
- package/build/types/inputs/SelectInput/ItemView/GroupItemView/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/ItemView/SelectInputItemView.d.ts +11 -0
- package/build/types/inputs/SelectInput/ItemView/SelectInputItemView.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/ItemView/index.d.ts +4 -0
- package/build/types/inputs/SelectInput/ItemView/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/Option/SelectInputOption.d.ts +11 -0
- package/build/types/inputs/SelectInput/Option/SelectInputOption.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/Option/index.d.ts +3 -0
- package/build/types/inputs/SelectInput/Option/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts +13 -0
- package/build/types/inputs/SelectInput/OptionContent/SelectInputOptionContent.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/OptionContent/index.d.ts +3 -0
- package/build/types/inputs/SelectInput/OptionContent/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts +9 -0
- package/build/types/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts +3 -0
- package/build/types/inputs/SelectInput/Options/OptionsContainer/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts +21 -0
- package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/Options/index.d.ts +4 -0
- package/build/types/inputs/SelectInput/Options/index.d.ts.map +1 -0
- package/build/types/inputs/{_Popover.d.ts → SelectInput/Popover/SelectInputPopover.d.ts} +3 -3
- package/build/types/inputs/SelectInput/Popover/SelectInputPopover.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/Popover/index.d.ts +3 -0
- package/build/types/inputs/SelectInput/Popover/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/SelectInput.contexts.d.ts +33 -0
- package/build/types/inputs/SelectInput/SelectInput.contexts.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/SelectInput.d.ts +10 -0
- package/build/types/inputs/SelectInput/SelectInput.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/SelectInput.messages.d.ts.map +1 -0
- package/build/types/inputs/{SelectInput.d.ts → SelectInput/SelectInput.types.d.ts} +12 -38
- package/build/types/inputs/SelectInput/SelectInput.types.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/SelectInput.utils.d.ts +60 -0
- package/build/types/inputs/SelectInput/SelectInput.utils.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts +12 -0
- package/build/types/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/TriggerButton/index.d.ts +3 -0
- package/build/types/inputs/SelectInput/TriggerButton/index.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/components.d.ts +10 -0
- package/build/types/inputs/SelectInput/components.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/index.d.ts +10 -0
- package/build/types/inputs/SelectInput/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +0 -1
- package/src/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.css +96 -0
- package/src/inputs/{_BottomSheet.tsx → SelectInput/BottomSheet/SelectInputBottomSheet.tsx} +7 -7
- package/src/inputs/SelectInput/BottomSheet/index.ts +2 -0
- package/src/inputs/SelectInput/ButtonInput/SelectInputButtonInput.css +16 -0
- package/src/inputs/{_ButtonInput.tsx → SelectInput/ButtonInput/SelectInputButtonInput.tsx} +5 -5
- package/src/inputs/SelectInput/ButtonInput/index.ts +2 -0
- package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.css +46 -0
- package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.less +39 -0
- package/src/inputs/SelectInput/ClearButton/SelectInputClearButton.tsx +27 -0
- package/src/inputs/SelectInput/ClearButton/index.ts +2 -0
- package/src/inputs/SelectInput/DefaultRenderTrigger/SelectInputDefaultRenderTrigger.tsx +74 -0
- package/src/inputs/SelectInput/DefaultRenderTrigger/index.ts +5 -0
- package/src/inputs/SelectInput/ItemView/GroupItemView/SelectInputGroupItemView.tsx +61 -0
- package/src/inputs/SelectInput/ItemView/GroupItemView/index.ts +2 -0
- package/src/inputs/SelectInput/ItemView/SelectInputItemView.css +16 -0
- package/src/inputs/SelectInput/ItemView/SelectInputItemView.less +17 -0
- package/src/inputs/SelectInput/ItemView/SelectInputItemView.tsx +48 -0
- package/src/inputs/SelectInput/ItemView/index.ts +3 -0
- package/src/inputs/SelectInput/Option/SelectInputOption.css +33 -0
- package/src/inputs/SelectInput/Option/SelectInputOption.less +32 -0
- package/src/inputs/SelectInput/Option/SelectInputOption.tsx +57 -0
- package/src/inputs/SelectInput/Option/index.ts +2 -0
- package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.css +37 -0
- package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.less +38 -0
- package/src/inputs/SelectInput/OptionContent/SelectInputOptionContent.tsx +72 -0
- package/src/inputs/SelectInput/OptionContent/index.ts +2 -0
- package/src/inputs/SelectInput/Options/OptionsContainer/SelectInputOptionsContainer.tsx +59 -0
- package/src/inputs/SelectInput/Options/OptionsContainer/index.ts +2 -0
- package/src/inputs/SelectInput/Options/SelectInputOptions.css +81 -0
- package/src/inputs/SelectInput/Options/SelectInputOptions.less +77 -0
- package/src/inputs/SelectInput/Options/SelectInputOptions.tsx +411 -0
- package/src/inputs/SelectInput/Options/index.ts +3 -0
- package/src/inputs/SelectInput/Popover/SelectInputPopover.css +46 -0
- package/src/inputs/{_Popover.tsx → SelectInput/Popover/SelectInputPopover.tsx} +7 -7
- package/src/inputs/SelectInput/Popover/index.ts +2 -0
- package/src/inputs/SelectInput/SelectInput.contexts.tsx +40 -0
- package/src/inputs/SelectInput/SelectInput.less +22 -0
- package/src/inputs/{SelectInput.test.tsx → SelectInput/SelectInput.test.tsx} +9 -11
- package/src/inputs/SelectInput/SelectInput.tsx +257 -0
- package/src/inputs/SelectInput/SelectInput.types.ts +113 -0
- package/src/inputs/SelectInput/SelectInput.utils.ts +205 -0
- package/src/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx +36 -0
- package/src/inputs/SelectInput/TriggerButton/index.ts +5 -0
- package/src/inputs/{SelectInput.docs.mdx → SelectInput/_stories/SelectInput.docs.mdx} +0 -1
- package/src/inputs/{SelectInput.story.tsx → SelectInput/_stories/SelectInput.story.tsx} +11 -8
- package/src/inputs/{SelectInput.test.story.tsx → SelectInput/_stories/SelectInput.test.story.tsx} +6 -10
- package/src/inputs/SelectInput/components.ts +10 -0
- package/src/inputs/SelectInput/index.ts +12 -0
- package/src/main.css +90 -90
- package/src/main.less +1 -1
- package/build/inputs/SelectInput.js +0 -890
- package/build/inputs/SelectInput.js.map +0 -1
- package/build/inputs/SelectInput.messages.js.map +0 -1
- package/build/inputs/SelectInput.messages.mjs.map +0 -1
- package/build/inputs/SelectInput.mjs +0 -881
- package/build/inputs/SelectInput.mjs.map +0 -1
- package/build/inputs/_BottomSheet.js.map +0 -1
- package/build/inputs/_BottomSheet.mjs.map +0 -1
- package/build/inputs/_ButtonInput.js.map +0 -1
- package/build/inputs/_ButtonInput.mjs.map +0 -1
- package/build/inputs/_Popover.js.map +0 -1
- package/build/inputs/_Popover.mjs.map +0 -1
- package/build/types/inputs/SelectInput.d.ts.map +0 -1
- package/build/types/inputs/SelectInput.messages.d.ts.map +0 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +0 -1
- package/build/types/inputs/_ButtonInput.d.ts +0 -5
- package/build/types/inputs/_ButtonInput.d.ts.map +0 -1
- package/build/types/inputs/_Popover.d.ts.map +0 -1
- package/src/inputs/SelectInput.less +0 -219
- package/src/inputs/SelectInput.tsx +0 -1269
- package/build/inputs/{SelectInput.messages.js → SelectInput/SelectInput.messages.js} +0 -0
- package/build/inputs/{SelectInput.messages.mjs → SelectInput/SelectInput.messages.mjs} +0 -0
- package/build/styles/inputs/{SelectInput.css → SelectInput/SelectInput.css} +90 -90
- package/build/types/inputs/{SelectInput.messages.d.ts → SelectInput/SelectInput.messages.d.ts} +0 -0
- package/src/inputs/{_BottomSheet.less → SelectInput/BottomSheet/SelectInputBottomSheet.less} +0 -0
- package/src/inputs/{_ButtonInput.less → SelectInput/ButtonInput/SelectInputButtonInput.less} +0 -0
- package/src/inputs/{_Popover.less → SelectInput/Popover/SelectInputPopover.less} +0 -0
- package/src/inputs/{SelectInput.css → SelectInput/SelectInput.css} +90 -90
- /package/src/inputs/{SelectInput.messages.ts → SelectInput/SelectInput.messages.ts} +0 -0
|
@@ -7,7 +7,16 @@ var React = require('react');
|
|
|
7
7
|
var reactIntl = require('react-intl');
|
|
8
8
|
var Body = require('../body/Body.js');
|
|
9
9
|
var Input = require('../inputs/Input.js');
|
|
10
|
-
var SelectInput = require('../inputs/SelectInput.js');
|
|
10
|
+
var SelectInput = require('../inputs/SelectInput/SelectInput.js');
|
|
11
|
+
require('@transferwise/icons');
|
|
12
|
+
require('../dateLookup/dateTrigger/DateTrigger.messages.js');
|
|
13
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
14
|
+
require('@headlessui/react');
|
|
15
|
+
var SelectInputOptionContent = require('../inputs/SelectInput/OptionContent/SelectInputOptionContent.js');
|
|
16
|
+
require('merge-props');
|
|
17
|
+
var contexts = require('../inputs/contexts.js');
|
|
18
|
+
require('../header/Header.js');
|
|
19
|
+
require('virtua');
|
|
11
20
|
require('../common/theme.js');
|
|
12
21
|
require('../common/direction.js');
|
|
13
22
|
require('../common/propsValues/control.js');
|
|
@@ -27,15 +36,13 @@ require('../common/propsValues/variant.js');
|
|
|
27
36
|
require('../common/propsValues/scroll.js');
|
|
28
37
|
require('../common/propsValues/markdownNodeType.js');
|
|
29
38
|
require('../common/fileType.js');
|
|
30
|
-
require('@transferwise/icons');
|
|
31
39
|
require('../common/closeButton/CloseButton.messages.js');
|
|
32
|
-
|
|
40
|
+
require('../inputs/SelectInput/SelectInput.messages.js');
|
|
33
41
|
require('@transferwise/formatting');
|
|
34
42
|
var getMonthNames = require('../common/dateUtils/getMonthNames/getMonthNames.js');
|
|
35
43
|
var isDateValid = require('../common/dateUtils/isDateValid/isDateValid.js');
|
|
36
44
|
var isMonthAndYearFormat = require('../common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.js');
|
|
37
45
|
var getFormatForLocale = require('../common/dateUtils/getFormatForLocale/getFormatForLocale.js');
|
|
38
|
-
var contexts = require('../inputs/contexts.js');
|
|
39
46
|
var DateInput_messages = require('./DateInput.messages.js');
|
|
40
47
|
var convertToLocalMidnight = require('./utils/convertToLocalMidnight/convertToLocalMidnight.js');
|
|
41
48
|
|
|
@@ -170,7 +177,7 @@ const DateInput = ({
|
|
|
170
177
|
})),
|
|
171
178
|
size: size$1,
|
|
172
179
|
value: month,
|
|
173
|
-
renderValue: selectedValue => /*#__PURE__*/jsxRuntime.jsx(
|
|
180
|
+
renderValue: selectedValue => /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContent.SelectInputOptionContent, {
|
|
174
181
|
title: monthNames[selectedValue]
|
|
175
182
|
}),
|
|
176
183
|
onChange: selectedValue => handleMonthChange(selectedValue),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","sources":["../../src/dateInput/DateInput.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef, useState } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport Body from '../body';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputOptionContent,\n type SelectInputProps,\n} from '../inputs/SelectInput';\nimport {\n DateMode,\n MonthFormat,\n Size,\n SizeLarge,\n SizeMedium,\n SizeSmall,\n Typography,\n} from '../common';\nimport { MDY, YMD, getMonthNames, isDateValid, isMonthAndYearFormat } from '../common/dateUtils';\nimport { useFieldLabelRef, useInputAttributes } from '../inputs/contexts';\nimport messages from './DateInput.messages';\nimport { convertToLocalMidnight } from './utils';\n\nexport interface DateInputProps {\n /** @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead. */\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /** @default false */\n disabled?: boolean;\n /** @default 'md' */\n size?: SizeSmall | SizeMedium | SizeLarge;\n value?: Date | string;\n onChange: (value: string | null) => void;\n onFocus?: React.FocusEventHandler<HTMLDivElement | HTMLFieldSetElement>;\n onBlur?: React.FocusEventHandler<HTMLDivElement | HTMLFieldSetElement>;\n dayLabel?: string;\n dayAutoComplete?: string;\n monthLabel?: string;\n yearLabel?: string;\n yearAutoComplete?: string;\n /** @default 'long' */\n monthFormat?: `${MonthFormat}`;\n /** @default 'day-month-year' */\n mode?: `${DateMode}`;\n placeholders?: {\n day?: string;\n month?: string;\n year?: string;\n };\n id?: string;\n /** @default {} */\n selectProps?: Partial<SelectInputProps<number | null>>;\n}\n\n/**\n * To be passed to SelectInput's parentId prop for correct blur handling.\n */\nconst DATE_INPUT_PARENT_ID = 'dateInput';\n\nconst DateInput = ({\n 'aria-labelledby': ariaLabelledByProp,\n 'aria-label': ariaLabel,\n disabled = false,\n size = Size.MEDIUM,\n value,\n dayLabel,\n dayAutoComplete,\n monthLabel,\n yearLabel,\n yearAutoComplete,\n monthFormat = MonthFormat.LONG,\n mode = DateMode.DAY_MONTH_YEAR,\n onChange,\n onFocus,\n onBlur,\n placeholders,\n id: idProp,\n selectProps = {},\n}: DateInputProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const fieldLabelRef = useFieldLabelRef();\n const dayRef = useRef<HTMLInputElement>(null);\n const monthRef = useRef<HTMLButtonElement>(null);\n const yearRef = useRef<HTMLInputElement>(null);\n const id = idProp ?? inputAttributes.id;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];\n\n const { locale, formatMessage } = useIntl();\n\n const getDateObject = (): Date | undefined => {\n if (value && isDateValid(value)) {\n return typeof value === 'string' ? convertToLocalMidnight(value) : value;\n }\n return undefined;\n };\n\n const getInitialDate = (unit: 'year' | 'month' | 'day'): number | null => {\n if (value && isDateValid(value)) {\n const dateObject = getDateObject();\n\n if (typeof value === 'string' && isMonthAndYearFormat(value) && unit === 'day') {\n return null;\n }\n\n if (dateObject !== undefined) {\n switch (unit) {\n case 'year':\n return dateObject.getFullYear();\n case 'month':\n return dateObject.getMonth();\n case 'day':\n return dateObject.getDate();\n default:\n return null;\n }\n }\n }\n return null;\n };\n\n const [day, setDay] = useState(() => getInitialDate('day'));\n const [displayDay, setDisplayDay] = useState(day?.toString());\n const [month, setMonth] = useState(() => getInitialDate('month'));\n const [year, setYear] = useState(() => getInitialDate('year'));\n const [displayYear, setDisplayYear] = useState(year?.toString());\n const [lastBroadcastedValue, setLastBroadcastedValue] = useState<Date | null | undefined>(\n getDateObject,\n );\n const monthNames = getMonthNames(locale, monthFormat);\n\n const monthYearOnly = mode === DateMode.MONTH_YEAR;\n const monthBeforeDay = MDY.has(locale);\n const yearFirst = YMD.has(locale);\n\n dayLabel ||= formatMessage(messages.dayLabel);\n monthLabel ||= formatMessage(messages.monthLabel);\n yearLabel ||= formatMessage(messages.yearLabel);\n placeholders = {\n day: placeholders?.day || formatMessage(messages.dayPlaceholder),\n month: placeholders?.month || formatMessage(messages.monthLabel),\n year: placeholders?.year || formatMessage(messages.yearPlaceholder),\n };\n\n useEffect(() => {\n const labelRef = fieldLabelRef?.current;\n\n if (labelRef) {\n const handleLabelClick = () => {\n // Not the best way to do this, but we're forced to recreate the native Label-click behavior\n if (monthYearOnly || monthBeforeDay) {\n monthRef.current?.click();\n } else if (yearFirst) {\n yearRef.current?.focus();\n } else {\n dayRef.current?.focus();\n }\n };\n\n labelRef.addEventListener('click', handleLabelClick);\n\n return () => {\n labelRef?.removeEventListener('click', handleLabelClick);\n };\n }\n }, [fieldLabelRef, id, monthBeforeDay, monthYearOnly, yearFirst]);\n\n const getDateAsString = (date: Date) => {\n if (!isDateValid(date)) {\n return '';\n }\n switch (mode) {\n case DateMode.MONTH_YEAR:\n return [date.getFullYear(), `0${date.getMonth() + 1}`.slice(-2)].join('-');\n case DateMode.DAY_MONTH_YEAR:\n default:\n return [\n date.getFullYear(),\n `0${date.getMonth() + 1}`.slice(-2),\n `0${date.getDate()}`.slice(-2),\n ].join('-');\n }\n };\n\n const getSelectElement = () => {\n return (\n <label className=\"d-flex flex-column\">\n <Body type={Typography.BODY_DEFAULT}>{monthLabel}</Body>\n <SelectInput\n triggerRef={monthRef}\n id={`${id}:month`}\n parentId={DATE_INPUT_PARENT_ID}\n name=\"month\"\n disabled={disabled}\n placeholder={placeholders?.month}\n items={Array.from({ length: 12 }, (_, index) => ({ type: 'option', value: index }))}\n size={size}\n value={month}\n renderValue={(selectedValue) => (\n <SelectInputOptionContent title={monthNames[selectedValue]} />\n )}\n onChange={(selectedValue) => handleMonthChange(selectedValue)}\n {...selectProps}\n />\n </label>\n );\n };\n\n const isDayValid = (newDay: number, newMonth: number, newYear: number) => {\n const maxDay = new Date(newYear, newMonth + 1, 0).getDate();\n return newDay <= maxDay;\n };\n\n const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {\n if (newDay == null || newDay === 0 || newMonth == null || newYear == null || newYear === 0) {\n broadcastNewValue(null);\n return;\n }\n if (!isDayValid(newDay, newMonth, newYear)) {\n broadcastNewValue(null);\n return;\n }\n\n const dateValue = new Date(newYear, newMonth, newDay);\n if (newYear < 100) {\n dateValue.setFullYear(newYear);\n }\n\n if (!isDateValid(dateValue)) {\n broadcastNewValue(null);\n return;\n }\n\n if (mode === DateMode.MONTH_YEAR) {\n if (newMonth !== month || newYear !== year) {\n broadcastNewValue(dateValue);\n }\n } else if (newDay !== day || newMonth !== month || newYear !== year) {\n broadcastNewValue(dateValue);\n }\n };\n\n const handleDayChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDayString = event.target.value.replace(/\\D/g, '');\n const newDayNumber = Number.parseInt(newDayString, 10);\n\n setDay(newDayNumber);\n setDisplayDay(newDayString);\n handleInternalValue(newDayNumber, month, year);\n };\n\n const handleMonthChange = (selectedMonth: number | null) => {\n if (selectedMonth === null) {\n setMonth(null);\n handleInternalValue(day, null, year);\n return;\n }\n setMonth(selectedMonth);\n handleInternalValue(day, selectedMonth, year);\n };\n\n const handleYearChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newYearString = event.target.value.replace(/\\D/g, '');\n const newYearNumber = Number.parseInt(newYearString, 10);\n\n if (newYearString.length >= 4 && newYearString.length <= 6) {\n setYear(newYearNumber);\n setDisplayYear(newYearString);\n handleInternalValue(day, month, newYearNumber);\n } else {\n setYear(null);\n setDisplayYear(newYearString);\n handleInternalValue(day, month, null);\n }\n };\n\n const broadcastNewValue = (newValue: Date | null) => {\n if (newValue !== lastBroadcastedValue) {\n setLastBroadcastedValue(newValue);\n onChange(newValue != null ? getDateAsString(newValue) : null);\n }\n };\n\n const monthWidth = clsx({\n 'col-sm-8 tw-date--month': monthYearOnly,\n 'col-sm-5 tw-date--month': !monthYearOnly,\n });\n\n const getMonth = () => {\n return <div className={monthWidth}>{getSelectElement()}</div>;\n };\n\n const getDay = () => {\n return (\n <div className=\"col-sm-3 tw-date--day\">\n <label>\n <Body type={Typography.BODY_DEFAULT}>{dayLabel}</Body>\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={dayRef}\n id={`${id}:day`}\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n name=\"day\"\n autoComplete={dayAutoComplete}\n value={displayDay || ''}\n placeholder={placeholders?.day}\n disabled={disabled}\n min={1}\n max={31}\n maxLength={2}\n onChange={(event) => handleDayChange(event)}\n />\n </div>\n </label>\n </div>\n );\n };\n\n const getYear = () => {\n return (\n <div className=\"col-sm-4 tw-date--year\">\n <label>\n <Body type={Typography.BODY_DEFAULT}>{yearLabel}</Body>\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={yearRef}\n id={`${id}:year`}\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n name=\"year\"\n autoComplete={yearAutoComplete}\n placeholder={placeholders?.year}\n value={displayYear || ''}\n disabled={disabled}\n min={0}\n max={9999}\n maxLength={6}\n onChange={(event) => handleYearChange(event)}\n />\n </div>\n </label>\n </div>\n );\n };\n\n return (\n <fieldset\n id={id}\n className=\"tw-date\"\n aria-describedby={inputAttributes['aria-describedby']}\n aria-invalid={inputAttributes['aria-invalid']}\n aria-labelledby={ariaLabelledBy}\n aria-label={ariaLabel}\n data-wds-dateinput=\"\"\n onFocus={(event) =>\n shouldPropagateOnFocus(event) ? onFocus?.(event) : event.stopPropagation()\n }\n onBlur={(event) => (shouldPropagateOnBlur(event) ? onBlur?.(event) : event.stopPropagation())}\n >\n <div className=\"row\">\n {(() => {\n if (monthYearOnly) {\n return (\n <>\n {!yearFirst && getMonth()}\n {getYear()}\n {yearFirst && getMonth()}\n </>\n );\n }\n if (monthBeforeDay) {\n return (\n <>\n {getMonth()}\n {getDay()}\n {getYear()}\n </>\n );\n }\n if (yearFirst) {\n return (\n <>\n {getYear()}\n {getMonth()}\n {getDay()}\n </>\n );\n }\n return (\n <>\n {getDay()}\n {getMonth()}\n {getYear()}\n </>\n );\n })()}\n </div>\n </fieldset>\n );\n};\n\n// Should only propagate if the relatedTarget is not part of this DateInput component.\nfunction shouldPropagateOnFocus({\n target,\n relatedTarget,\n}: Pick<React.FocusEvent, 'target' | 'relatedTarget'>) {\n const blurredElementParent = target.closest('[data-wds-dateinput]');\n const focusedElementParent = relatedTarget?.closest('[data-wds-dateinput]');\n return blurredElementParent !== focusedElementParent;\n}\n\n// Should only propagate if the focus-gaining element is not part\n// of this DateInput component or the (dropdown) of the month select.\nfunction shouldPropagateOnBlur({\n target,\n relatedTarget,\n}: Pick<React.FocusEvent, 'target' | 'relatedTarget'>) {\n const blurredElementParent = target.closest('[data-wds-dateinput]');\n const focusedElementParent = relatedTarget?.closest('[data-wds-dateinput]');\n\n return (\n blurredElementParent !== focusedElementParent &&\n !target?.closest(`[data-wds-parent=\"${DATE_INPUT_PARENT_ID}\"]`) &&\n !relatedTarget?.closest(`[data-wds-parent=\"${DATE_INPUT_PARENT_ID}\"]`)\n );\n}\n\nexport default DateInput;\n"],"names":["DATE_INPUT_PARENT_ID","DateInput","ariaLabelledByProp","ariaLabel","disabled","size","Size","MEDIUM","value","dayLabel","dayAutoComplete","monthLabel","yearLabel","yearAutoComplete","monthFormat","MonthFormat","LONG","mode","DateMode","DAY_MONTH_YEAR","onChange","onFocus","onBlur","placeholders","id","idProp","selectProps","inputAttributes","useInputAttributes","nonLabelable","fieldLabelRef","useFieldLabelRef","dayRef","useRef","monthRef","yearRef","ariaLabelledBy","locale","formatMessage","useIntl","getDateObject","isDateValid","convertToLocalMidnight","undefined","getInitialDate","unit","dateObject","isMonthAndYearFormat","getFullYear","getMonth","getDate","day","setDay","useState","displayDay","setDisplayDay","toString","month","setMonth","year","setYear","displayYear","setDisplayYear","lastBroadcastedValue","setLastBroadcastedValue","monthNames","getMonthNames","monthYearOnly","MONTH_YEAR","monthBeforeDay","MDY","has","yearFirst","YMD","messages","dayPlaceholder","yearPlaceholder","useEffect","labelRef","current","handleLabelClick","click","focus","addEventListener","removeEventListener","getDateAsString","date","slice","join","getSelectElement","_jsxs","className","children","_jsx","Body","type","Typography","BODY_DEFAULT","SelectInput","triggerRef","parentId","name","placeholder","items","Array","from","length","_","index","renderValue","selectedValue","SelectInputOptionContent","title","handleMonthChange","isDayValid","newDay","newMonth","newYear","maxDay","Date","handleInternalValue","broadcastNewValue","dateValue","setFullYear","handleDayChange","event","newDayString","target","replace","newDayNumber","Number","parseInt","selectedMonth","handleYearChange","newYearString","newYearNumber","newValue","monthWidth","clsx","getDay","Input","ref","inputMode","pattern","autoComplete","min","max","maxLength","getYear","shouldPropagateOnFocus","stopPropagation","shouldPropagateOnBlur","_Fragment","relatedTarget","blurredElementParent","closest","focusedElementParent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAMA,oBAAoB,GAAG,WAAW;AAExC,MAAMC,SAAS,GAAGA,CAAC;AACjB,EAAA,iBAAiB,EAAEC,kBAAkB;AACrC,EAAA,YAAY,EAAEC,SAAS;AACvBC,EAAAA,QAAQ,GAAG,KAAK;QAChBC,MAAI,GAAGC,SAAI,CAACC,MAAM;EAClBC,KAAK;EACLC,QAAQ;EACRC,eAAe;EACfC,UAAU;EACVC,SAAS;EACTC,gBAAgB;eAChBC,aAAW,GAAGC,uBAAW,CAACC,IAAI;EAC9BC,IAAI,GAAGC,iBAAQ,CAACC,cAAc;EAC9BC,QAAQ;EACRC,OAAO;EACPC,MAAM;EACNC,YAAY;AACZC,EAAAA,EAAE,EAAEC,MAAM;AACVC,EAAAA,WAAW,GAAG;AAAE,CACD,KAAI;EACnB,MAAMC,eAAe,GAAGC,2BAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAI,GAAE,CAAC;AAClE,EAAA,MAAMC,aAAa,GAAGC,yBAAgB,EAAE;AACxC,EAAA,MAAMC,MAAM,GAAGC,YAAM,CAAmB,IAAI,CAAC;AAC7C,EAAA,MAAMC,QAAQ,GAAGD,YAAM,CAAoB,IAAI,CAAC;AAChD,EAAA,MAAME,OAAO,GAAGF,YAAM,CAAmB,IAAI,CAAC;AAC9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B,GAAG3B,MAAM,CAAC4B,OAAO,CAAC,sBAAsB,CAAC;AACnE,EAAA,MAAMC,oBAAoB,GAAGH,aAAa,EAAEE,OAAO,CAAC,sBAAsB,CAAC;EAE3E,OACED,oBAAoB,KAAKE,oBAAoB,IAC7C,CAAC7B,MAAM,EAAE4B,OAAO,CAAC,CAAA,kBAAA,EAAqB3J,oBAAoB,IAAI,CAAC,IAC/D,CAACyJ,aAAa,EAAEE,OAAO,CAAC,CAAA,kBAAA,EAAqB3J,oBAAoB,CAAA,EAAA,CAAI,CAAC;AAE1E;;;;"}
|
|
1
|
+
{"version":3,"file":"DateInput.js","sources":["../../src/dateInput/DateInput.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef, useState } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport Body from '../body';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputOptionContent,\n type SelectInputProps,\n} from '../inputs/SelectInput';\nimport {\n DateMode,\n MonthFormat,\n Size,\n SizeLarge,\n SizeMedium,\n SizeSmall,\n Typography,\n} from '../common';\nimport { MDY, YMD, getMonthNames, isDateValid, isMonthAndYearFormat } from '../common/dateUtils';\nimport { useFieldLabelRef, useInputAttributes } from '../inputs/contexts';\nimport messages from './DateInput.messages';\nimport { convertToLocalMidnight } from './utils';\n\nexport interface DateInputProps {\n /** @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead. */\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /** @default false */\n disabled?: boolean;\n /** @default 'md' */\n size?: SizeSmall | SizeMedium | SizeLarge;\n value?: Date | string;\n onChange: (value: string | null) => void;\n onFocus?: React.FocusEventHandler<HTMLDivElement | HTMLFieldSetElement>;\n onBlur?: React.FocusEventHandler<HTMLDivElement | HTMLFieldSetElement>;\n dayLabel?: string;\n dayAutoComplete?: string;\n monthLabel?: string;\n yearLabel?: string;\n yearAutoComplete?: string;\n /** @default 'long' */\n monthFormat?: `${MonthFormat}`;\n /** @default 'day-month-year' */\n mode?: `${DateMode}`;\n placeholders?: {\n day?: string;\n month?: string;\n year?: string;\n };\n id?: string;\n /** @default {} */\n selectProps?: Partial<SelectInputProps<number | null>>;\n}\n\n/**\n * To be passed to SelectInput's parentId prop for correct blur handling.\n */\nconst DATE_INPUT_PARENT_ID = 'dateInput';\n\nconst DateInput = ({\n 'aria-labelledby': ariaLabelledByProp,\n 'aria-label': ariaLabel,\n disabled = false,\n size = Size.MEDIUM,\n value,\n dayLabel,\n dayAutoComplete,\n monthLabel,\n yearLabel,\n yearAutoComplete,\n monthFormat = MonthFormat.LONG,\n mode = DateMode.DAY_MONTH_YEAR,\n onChange,\n onFocus,\n onBlur,\n placeholders,\n id: idProp,\n selectProps = {},\n}: DateInputProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const fieldLabelRef = useFieldLabelRef();\n const dayRef = useRef<HTMLInputElement>(null);\n const monthRef = useRef<HTMLButtonElement>(null);\n const yearRef = useRef<HTMLInputElement>(null);\n const id = idProp ?? inputAttributes.id;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];\n\n const { locale, formatMessage } = useIntl();\n\n const getDateObject = (): Date | undefined => {\n if (value && isDateValid(value)) {\n return typeof value === 'string' ? convertToLocalMidnight(value) : value;\n }\n return undefined;\n };\n\n const getInitialDate = (unit: 'year' | 'month' | 'day'): number | null => {\n if (value && isDateValid(value)) {\n const dateObject = getDateObject();\n\n if (typeof value === 'string' && isMonthAndYearFormat(value) && unit === 'day') {\n return null;\n }\n\n if (dateObject !== undefined) {\n switch (unit) {\n case 'year':\n return dateObject.getFullYear();\n case 'month':\n return dateObject.getMonth();\n case 'day':\n return dateObject.getDate();\n default:\n return null;\n }\n }\n }\n return null;\n };\n\n const [day, setDay] = useState(() => getInitialDate('day'));\n const [displayDay, setDisplayDay] = useState(day?.toString());\n const [month, setMonth] = useState(() => getInitialDate('month'));\n const [year, setYear] = useState(() => getInitialDate('year'));\n const [displayYear, setDisplayYear] = useState(year?.toString());\n const [lastBroadcastedValue, setLastBroadcastedValue] = useState<Date | null | undefined>(\n getDateObject,\n );\n const monthNames = getMonthNames(locale, monthFormat);\n\n const monthYearOnly = mode === DateMode.MONTH_YEAR;\n const monthBeforeDay = MDY.has(locale);\n const yearFirst = YMD.has(locale);\n\n dayLabel ||= formatMessage(messages.dayLabel);\n monthLabel ||= formatMessage(messages.monthLabel);\n yearLabel ||= formatMessage(messages.yearLabel);\n placeholders = {\n day: placeholders?.day || formatMessage(messages.dayPlaceholder),\n month: placeholders?.month || formatMessage(messages.monthLabel),\n year: placeholders?.year || formatMessage(messages.yearPlaceholder),\n };\n\n useEffect(() => {\n const labelRef = fieldLabelRef?.current;\n\n if (labelRef) {\n const handleLabelClick = () => {\n // Not the best way to do this, but we're forced to recreate the native Label-click behavior\n if (monthYearOnly || monthBeforeDay) {\n monthRef.current?.click();\n } else if (yearFirst) {\n yearRef.current?.focus();\n } else {\n dayRef.current?.focus();\n }\n };\n\n labelRef.addEventListener('click', handleLabelClick);\n\n return () => {\n labelRef?.removeEventListener('click', handleLabelClick);\n };\n }\n }, [fieldLabelRef, id, monthBeforeDay, monthYearOnly, yearFirst]);\n\n const getDateAsString = (date: Date) => {\n if (!isDateValid(date)) {\n return '';\n }\n switch (mode) {\n case DateMode.MONTH_YEAR:\n return [date.getFullYear(), `0${date.getMonth() + 1}`.slice(-2)].join('-');\n case DateMode.DAY_MONTH_YEAR:\n default:\n return [\n date.getFullYear(),\n `0${date.getMonth() + 1}`.slice(-2),\n `0${date.getDate()}`.slice(-2),\n ].join('-');\n }\n };\n\n const getSelectElement = () => {\n return (\n <label className=\"d-flex flex-column\">\n <Body type={Typography.BODY_DEFAULT}>{monthLabel}</Body>\n <SelectInput\n triggerRef={monthRef}\n id={`${id}:month`}\n parentId={DATE_INPUT_PARENT_ID}\n name=\"month\"\n disabled={disabled}\n placeholder={placeholders?.month}\n items={Array.from({ length: 12 }, (_, index) => ({ type: 'option', value: index }))}\n size={size}\n value={month}\n renderValue={(selectedValue) => (\n <SelectInputOptionContent title={monthNames[selectedValue]} />\n )}\n onChange={(selectedValue) => handleMonthChange(selectedValue)}\n {...selectProps}\n />\n </label>\n );\n };\n\n const isDayValid = (newDay: number, newMonth: number, newYear: number) => {\n const maxDay = new Date(newYear, newMonth + 1, 0).getDate();\n return newDay <= maxDay;\n };\n\n const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {\n if (newDay == null || newDay === 0 || newMonth == null || newYear == null || newYear === 0) {\n broadcastNewValue(null);\n return;\n }\n if (!isDayValid(newDay, newMonth, newYear)) {\n broadcastNewValue(null);\n return;\n }\n\n const dateValue = new Date(newYear, newMonth, newDay);\n if (newYear < 100) {\n dateValue.setFullYear(newYear);\n }\n\n if (!isDateValid(dateValue)) {\n broadcastNewValue(null);\n return;\n }\n\n if (mode === DateMode.MONTH_YEAR) {\n if (newMonth !== month || newYear !== year) {\n broadcastNewValue(dateValue);\n }\n } else if (newDay !== day || newMonth !== month || newYear !== year) {\n broadcastNewValue(dateValue);\n }\n };\n\n const handleDayChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDayString = event.target.value.replace(/\\D/g, '');\n const newDayNumber = Number.parseInt(newDayString, 10);\n\n setDay(newDayNumber);\n setDisplayDay(newDayString);\n handleInternalValue(newDayNumber, month, year);\n };\n\n const handleMonthChange = (selectedMonth: number | null) => {\n if (selectedMonth === null) {\n setMonth(null);\n handleInternalValue(day, null, year);\n return;\n }\n setMonth(selectedMonth);\n handleInternalValue(day, selectedMonth, year);\n };\n\n const handleYearChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newYearString = event.target.value.replace(/\\D/g, '');\n const newYearNumber = Number.parseInt(newYearString, 10);\n\n if (newYearString.length >= 4 && newYearString.length <= 6) {\n setYear(newYearNumber);\n setDisplayYear(newYearString);\n handleInternalValue(day, month, newYearNumber);\n } else {\n setYear(null);\n setDisplayYear(newYearString);\n handleInternalValue(day, month, null);\n }\n };\n\n const broadcastNewValue = (newValue: Date | null) => {\n if (newValue !== lastBroadcastedValue) {\n setLastBroadcastedValue(newValue);\n onChange(newValue != null ? getDateAsString(newValue) : null);\n }\n };\n\n const monthWidth = clsx({\n 'col-sm-8 tw-date--month': monthYearOnly,\n 'col-sm-5 tw-date--month': !monthYearOnly,\n });\n\n const getMonth = () => {\n return <div className={monthWidth}>{getSelectElement()}</div>;\n };\n\n const getDay = () => {\n return (\n <div className=\"col-sm-3 tw-date--day\">\n <label>\n <Body type={Typography.BODY_DEFAULT}>{dayLabel}</Body>\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={dayRef}\n id={`${id}:day`}\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n name=\"day\"\n autoComplete={dayAutoComplete}\n value={displayDay || ''}\n placeholder={placeholders?.day}\n disabled={disabled}\n min={1}\n max={31}\n maxLength={2}\n onChange={(event) => handleDayChange(event)}\n />\n </div>\n </label>\n </div>\n );\n };\n\n const getYear = () => {\n return (\n <div className=\"col-sm-4 tw-date--year\">\n <label>\n <Body type={Typography.BODY_DEFAULT}>{yearLabel}</Body>\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={yearRef}\n id={`${id}:year`}\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n name=\"year\"\n autoComplete={yearAutoComplete}\n placeholder={placeholders?.year}\n value={displayYear || ''}\n disabled={disabled}\n min={0}\n max={9999}\n maxLength={6}\n onChange={(event) => handleYearChange(event)}\n />\n </div>\n </label>\n </div>\n );\n };\n\n return (\n <fieldset\n id={id}\n className=\"tw-date\"\n aria-describedby={inputAttributes['aria-describedby']}\n aria-invalid={inputAttributes['aria-invalid']}\n aria-labelledby={ariaLabelledBy}\n aria-label={ariaLabel}\n data-wds-dateinput=\"\"\n onFocus={(event) =>\n shouldPropagateOnFocus(event) ? onFocus?.(event) : event.stopPropagation()\n }\n onBlur={(event) => (shouldPropagateOnBlur(event) ? onBlur?.(event) : event.stopPropagation())}\n >\n <div className=\"row\">\n {(() => {\n if (monthYearOnly) {\n return (\n <>\n {!yearFirst && getMonth()}\n {getYear()}\n {yearFirst && getMonth()}\n </>\n );\n }\n if (monthBeforeDay) {\n return (\n <>\n {getMonth()}\n {getDay()}\n {getYear()}\n </>\n );\n }\n if (yearFirst) {\n return (\n <>\n {getYear()}\n {getMonth()}\n {getDay()}\n </>\n );\n }\n return (\n <>\n {getDay()}\n {getMonth()}\n {getYear()}\n </>\n );\n })()}\n </div>\n </fieldset>\n );\n};\n\n// Should only propagate if the relatedTarget is not part of this DateInput component.\nfunction shouldPropagateOnFocus({\n target,\n relatedTarget,\n}: Pick<React.FocusEvent, 'target' | 'relatedTarget'>) {\n const blurredElementParent = target.closest('[data-wds-dateinput]');\n const focusedElementParent = relatedTarget?.closest('[data-wds-dateinput]');\n return blurredElementParent !== focusedElementParent;\n}\n\n// Should only propagate if the focus-gaining element is not part\n// of this DateInput component or the (dropdown) of the month select.\nfunction shouldPropagateOnBlur({\n target,\n relatedTarget,\n}: Pick<React.FocusEvent, 'target' | 'relatedTarget'>) {\n const blurredElementParent = target.closest('[data-wds-dateinput]');\n const focusedElementParent = relatedTarget?.closest('[data-wds-dateinput]');\n\n return (\n blurredElementParent !== focusedElementParent &&\n !target?.closest(`[data-wds-parent=\"${DATE_INPUT_PARENT_ID}\"]`) &&\n !relatedTarget?.closest(`[data-wds-parent=\"${DATE_INPUT_PARENT_ID}\"]`)\n );\n}\n\nexport default DateInput;\n"],"names":["DATE_INPUT_PARENT_ID","DateInput","ariaLabelledByProp","ariaLabel","disabled","size","Size","MEDIUM","value","dayLabel","dayAutoComplete","monthLabel","yearLabel","yearAutoComplete","monthFormat","MonthFormat","LONG","mode","DateMode","DAY_MONTH_YEAR","onChange","onFocus","onBlur","placeholders","id","idProp","selectProps","inputAttributes","useInputAttributes","nonLabelable","fieldLabelRef","useFieldLabelRef","dayRef","useRef","monthRef","yearRef","ariaLabelledBy","locale","formatMessage","useIntl","getDateObject","isDateValid","convertToLocalMidnight","undefined","getInitialDate","unit","dateObject","isMonthAndYearFormat","getFullYear","getMonth","getDate","day","setDay","useState","displayDay","setDisplayDay","toString","month","setMonth","year","setYear","displayYear","setDisplayYear","lastBroadcastedValue","setLastBroadcastedValue","monthNames","getMonthNames","monthYearOnly","MONTH_YEAR","monthBeforeDay","MDY","has","yearFirst","YMD","messages","dayPlaceholder","yearPlaceholder","useEffect","labelRef","current","handleLabelClick","click","focus","addEventListener","removeEventListener","getDateAsString","date","slice","join","getSelectElement","_jsxs","className","children","_jsx","Body","type","Typography","BODY_DEFAULT","SelectInput","triggerRef","parentId","name","placeholder","items","Array","from","length","_","index","renderValue","selectedValue","SelectInputOptionContent","title","handleMonthChange","isDayValid","newDay","newMonth","newYear","maxDay","Date","handleInternalValue","broadcastNewValue","dateValue","setFullYear","handleDayChange","event","newDayString","target","replace","newDayNumber","Number","parseInt","selectedMonth","handleYearChange","newYearString","newYearNumber","newValue","monthWidth","clsx","getDay","Input","ref","inputMode","pattern","autoComplete","min","max","maxLength","getYear","shouldPropagateOnFocus","stopPropagation","shouldPropagateOnBlur","_Fragment","relatedTarget","blurredElementParent","closest","focusedElementParent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAMA,oBAAoB,GAAG,WAAW;AAExC,MAAMC,SAAS,GAAGA,CAAC;AACjB,EAAA,iBAAiB,EAAEC,kBAAkB;AACrC,EAAA,YAAY,EAAEC,SAAS;AACvBC,EAAAA,QAAQ,GAAG,KAAK;QAChBC,MAAI,GAAGC,SAAI,CAACC,MAAM;EAClBC,KAAK;EACLC,QAAQ;EACRC,eAAe;EACfC,UAAU;EACVC,SAAS;EACTC,gBAAgB;eAChBC,aAAW,GAAGC,uBAAW,CAACC,IAAI;EAC9BC,IAAI,GAAGC,iBAAQ,CAACC,cAAc;EAC9BC,QAAQ;EACRC,OAAO;EACPC,MAAM;EACNC,Y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Ef;AAEA;AACA,SAASC,sBAAsBA,CAAC;EAC9BtB,MAAM;AACN0B,EAAAA;AAAa,CACsC,EAAA;AACnD,EAAA,MAAMC,oBAAoB,GAAG3B,MAAM,CAAC4B,OAAO,CAAC,sBAAsB,CAAC;AACnE,EAAA,MAAMC,oBAAoB,GAAGH,aAAa,EAAEE,OAAO,CAAC,sBAAsB,CAAC;EAC3E,OAAOD,oBAAoB,KAAKE,oBAAoB;AACtD;AAEA;AACA;AACA,SAASL,qBAAqBA,CAAC;EAC7BxB,MAAM;AACN0B,EAAAA;AAAa,CACsC,EAAA;AACnD,EAAA,MAAMC,oBAAoB,GAAG3B,MAAM,CAAC4B,OAAO,CAAC,sBAAsB,CAAC;AACnE,EAAA,MAAMC,oBAAoB,GAAGH,aAAa,EAAEE,OAAO,CAAC,sBAAsB,CAAC;EAE3E,OACED,oBAAoB,KAAKE,oBAAoB,IAC7C,CAAC7B,MAAM,EAAE4B,OAAO,CAAC,CAAA,kBAAA,EAAqB3J,oBAAoB,IAAI,CAAC,IAC/D,CAACyJ,aAAa,EAAEE,OAAO,CAAC,CAAA,kBAAA,EAAqB3J,oBAAoB,CAAA,EAAA,CAAI,CAAC;AAE1E;;;;"}
|
|
@@ -3,7 +3,16 @@ import { useRef, useState, useEffect } from 'react';
|
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
4
|
import Body from '../body/Body.mjs';
|
|
5
5
|
import { Input } from '../inputs/Input.mjs';
|
|
6
|
-
import { SelectInput
|
|
6
|
+
import { SelectInput } from '../inputs/SelectInput/SelectInput.mjs';
|
|
7
|
+
import '@transferwise/icons';
|
|
8
|
+
import '../dateLookup/dateTrigger/DateTrigger.messages.mjs';
|
|
9
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
|
+
import '@headlessui/react';
|
|
11
|
+
import { SelectInputOptionContent } from '../inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs';
|
|
12
|
+
import 'merge-props';
|
|
13
|
+
import { useInputAttributes, useFieldLabelRef } from '../inputs/contexts.mjs';
|
|
14
|
+
import '../header/Header.mjs';
|
|
15
|
+
import 'virtua';
|
|
7
16
|
import '../common/theme.mjs';
|
|
8
17
|
import '../common/direction.mjs';
|
|
9
18
|
import '../common/propsValues/control.mjs';
|
|
@@ -23,15 +32,13 @@ import '../common/propsValues/variant.mjs';
|
|
|
23
32
|
import '../common/propsValues/scroll.mjs';
|
|
24
33
|
import '../common/propsValues/markdownNodeType.mjs';
|
|
25
34
|
import '../common/fileType.mjs';
|
|
26
|
-
import '@transferwise/icons';
|
|
27
35
|
import '../common/closeButton/CloseButton.messages.mjs';
|
|
28
|
-
import
|
|
36
|
+
import '../inputs/SelectInput/SelectInput.messages.mjs';
|
|
29
37
|
import '@transferwise/formatting';
|
|
30
38
|
import { getMonthNames } from '../common/dateUtils/getMonthNames/getMonthNames.mjs';
|
|
31
39
|
import { isDateValid } from '../common/dateUtils/isDateValid/isDateValid.mjs';
|
|
32
40
|
import { isMonthAndYearFormat } from '../common/dateUtils/isMonthAndYearFormat/isMonthAndYearFormat.mjs';
|
|
33
41
|
import { MDY, YMD } from '../common/dateUtils/getFormatForLocale/getFormatForLocale.mjs';
|
|
34
|
-
import { useInputAttributes, useFieldLabelRef } from '../inputs/contexts.mjs';
|
|
35
42
|
import messages from './DateInput.messages.mjs';
|
|
36
43
|
import { convertToLocalMidnight } from './utils/convertToLocalMidnight/convertToLocalMidnight.mjs';
|
|
37
44
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.mjs","sources":["../../src/dateInput/DateInput.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef, useState } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport Body from '../body';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputOptionContent,\n type SelectInputProps,\n} from '../inputs/SelectInput';\nimport {\n DateMode,\n MonthFormat,\n Size,\n SizeLarge,\n SizeMedium,\n SizeSmall,\n Typography,\n} from '../common';\nimport { MDY, YMD, getMonthNames, isDateValid, isMonthAndYearFormat } from '../common/dateUtils';\nimport { useFieldLabelRef, useInputAttributes } from '../inputs/contexts';\nimport messages from './DateInput.messages';\nimport { convertToLocalMidnight } from './utils';\n\nexport interface DateInputProps {\n /** @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead. */\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /** @default false */\n disabled?: boolean;\n /** @default 'md' */\n size?: SizeSmall | SizeMedium | SizeLarge;\n value?: Date | string;\n onChange: (value: string | null) => void;\n onFocus?: React.FocusEventHandler<HTMLDivElement | HTMLFieldSetElement>;\n onBlur?: React.FocusEventHandler<HTMLDivElement | HTMLFieldSetElement>;\n dayLabel?: string;\n dayAutoComplete?: string;\n monthLabel?: string;\n yearLabel?: string;\n yearAutoComplete?: string;\n /** @default 'long' */\n monthFormat?: `${MonthFormat}`;\n /** @default 'day-month-year' */\n mode?: `${DateMode}`;\n placeholders?: {\n day?: string;\n month?: string;\n year?: string;\n };\n id?: string;\n /** @default {} */\n selectProps?: Partial<SelectInputProps<number | null>>;\n}\n\n/**\n * To be passed to SelectInput's parentId prop for correct blur handling.\n */\nconst DATE_INPUT_PARENT_ID = 'dateInput';\n\nconst DateInput = ({\n 'aria-labelledby': ariaLabelledByProp,\n 'aria-label': ariaLabel,\n disabled = false,\n size = Size.MEDIUM,\n value,\n dayLabel,\n dayAutoComplete,\n monthLabel,\n yearLabel,\n yearAutoComplete,\n monthFormat = MonthFormat.LONG,\n mode = DateMode.DAY_MONTH_YEAR,\n onChange,\n onFocus,\n onBlur,\n placeholders,\n id: idProp,\n selectProps = {},\n}: DateInputProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const fieldLabelRef = useFieldLabelRef();\n const dayRef = useRef<HTMLInputElement>(null);\n const monthRef = useRef<HTMLButtonElement>(null);\n const yearRef = useRef<HTMLInputElement>(null);\n const id = idProp ?? inputAttributes.id;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];\n\n const { locale, formatMessage } = useIntl();\n\n const getDateObject = (): Date | undefined => {\n if (value && isDateValid(value)) {\n return typeof value === 'string' ? convertToLocalMidnight(value) : value;\n }\n return undefined;\n };\n\n const getInitialDate = (unit: 'year' | 'month' | 'day'): number | null => {\n if (value && isDateValid(value)) {\n const dateObject = getDateObject();\n\n if (typeof value === 'string' && isMonthAndYearFormat(value) && unit === 'day') {\n return null;\n }\n\n if (dateObject !== undefined) {\n switch (unit) {\n case 'year':\n return dateObject.getFullYear();\n case 'month':\n return dateObject.getMonth();\n case 'day':\n return dateObject.getDate();\n default:\n return null;\n }\n }\n }\n return null;\n };\n\n const [day, setDay] = useState(() => getInitialDate('day'));\n const [displayDay, setDisplayDay] = useState(day?.toString());\n const [month, setMonth] = useState(() => getInitialDate('month'));\n const [year, setYear] = useState(() => getInitialDate('year'));\n const [displayYear, setDisplayYear] = useState(year?.toString());\n const [lastBroadcastedValue, setLastBroadcastedValue] = useState<Date | null | undefined>(\n getDateObject,\n );\n const monthNames = getMonthNames(locale, monthFormat);\n\n const monthYearOnly = mode === DateMode.MONTH_YEAR;\n const monthBeforeDay = MDY.has(locale);\n const yearFirst = YMD.has(locale);\n\n dayLabel ||= formatMessage(messages.dayLabel);\n monthLabel ||= formatMessage(messages.monthLabel);\n yearLabel ||= formatMessage(messages.yearLabel);\n placeholders = {\n day: placeholders?.day || formatMessage(messages.dayPlaceholder),\n month: placeholders?.month || formatMessage(messages.monthLabel),\n year: placeholders?.year || formatMessage(messages.yearPlaceholder),\n };\n\n useEffect(() => {\n const labelRef = fieldLabelRef?.current;\n\n if (labelRef) {\n const handleLabelClick = () => {\n // Not the best way to do this, but we're forced to recreate the native Label-click behavior\n if (monthYearOnly || monthBeforeDay) {\n monthRef.current?.click();\n } else if (yearFirst) {\n yearRef.current?.focus();\n } else {\n dayRef.current?.focus();\n }\n };\n\n labelRef.addEventListener('click', handleLabelClick);\n\n return () => {\n labelRef?.removeEventListener('click', handleLabelClick);\n };\n }\n }, [fieldLabelRef, id, monthBeforeDay, monthYearOnly, yearFirst]);\n\n const getDateAsString = (date: Date) => {\n if (!isDateValid(date)) {\n return '';\n }\n switch (mode) {\n case DateMode.MONTH_YEAR:\n return [date.getFullYear(), `0${date.getMonth() + 1}`.slice(-2)].join('-');\n case DateMode.DAY_MONTH_YEAR:\n default:\n return [\n date.getFullYear(),\n `0${date.getMonth() + 1}`.slice(-2),\n `0${date.getDate()}`.slice(-2),\n ].join('-');\n }\n };\n\n const getSelectElement = () => {\n return (\n <label className=\"d-flex flex-column\">\n <Body type={Typography.BODY_DEFAULT}>{monthLabel}</Body>\n <SelectInput\n triggerRef={monthRef}\n id={`${id}:month`}\n parentId={DATE_INPUT_PARENT_ID}\n name=\"month\"\n disabled={disabled}\n placeholder={placeholders?.month}\n items={Array.from({ length: 12 }, (_, index) => ({ type: 'option', value: index }))}\n size={size}\n value={month}\n renderValue={(selectedValue) => (\n <SelectInputOptionContent title={monthNames[selectedValue]} />\n )}\n onChange={(selectedValue) => handleMonthChange(selectedValue)}\n {...selectProps}\n />\n </label>\n );\n };\n\n const isDayValid = (newDay: number, newMonth: number, newYear: number) => {\n const maxDay = new Date(newYear, newMonth + 1, 0).getDate();\n return newDay <= maxDay;\n };\n\n const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {\n if (newDay == null || newDay === 0 || newMonth == null || newYear == null || newYear === 0) {\n broadcastNewValue(null);\n return;\n }\n if (!isDayValid(newDay, newMonth, newYear)) {\n broadcastNewValue(null);\n return;\n }\n\n const dateValue = new Date(newYear, newMonth, newDay);\n if (newYear < 100) {\n dateValue.setFullYear(newYear);\n }\n\n if (!isDateValid(dateValue)) {\n broadcastNewValue(null);\n return;\n }\n\n if (mode === DateMode.MONTH_YEAR) {\n if (newMonth !== month || newYear !== year) {\n broadcastNewValue(dateValue);\n }\n } else if (newDay !== day || newMonth !== month || newYear !== year) {\n broadcastNewValue(dateValue);\n }\n };\n\n const handleDayChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDayString = event.target.value.replace(/\\D/g, '');\n const newDayNumber = Number.parseInt(newDayString, 10);\n\n setDay(newDayNumber);\n setDisplayDay(newDayString);\n handleInternalValue(newDayNumber, month, year);\n };\n\n const handleMonthChange = (selectedMonth: number | null) => {\n if (selectedMonth === null) {\n setMonth(null);\n handleInternalValue(day, null, year);\n return;\n }\n setMonth(selectedMonth);\n handleInternalValue(day, selectedMonth, year);\n };\n\n const handleYearChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newYearString = event.target.value.replace(/\\D/g, '');\n const newYearNumber = Number.parseInt(newYearString, 10);\n\n if (newYearString.length >= 4 && newYearString.length <= 6) {\n setYear(newYearNumber);\n setDisplayYear(newYearString);\n handleInternalValue(day, month, newYearNumber);\n } else {\n setYear(null);\n setDisplayYear(newYearString);\n handleInternalValue(day, month, null);\n }\n };\n\n const broadcastNewValue = (newValue: Date | null) => {\n if (newValue !== lastBroadcastedValue) {\n setLastBroadcastedValue(newValue);\n onChange(newValue != null ? getDateAsString(newValue) : null);\n }\n };\n\n const monthWidth = clsx({\n 'col-sm-8 tw-date--month': monthYearOnly,\n 'col-sm-5 tw-date--month': !monthYearOnly,\n });\n\n const getMonth = () => {\n return <div className={monthWidth}>{getSelectElement()}</div>;\n };\n\n const getDay = () => {\n return (\n <div className=\"col-sm-3 tw-date--day\">\n <label>\n <Body type={Typography.BODY_DEFAULT}>{dayLabel}</Body>\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={dayRef}\n id={`${id}:day`}\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n name=\"day\"\n autoComplete={dayAutoComplete}\n value={displayDay || ''}\n placeholder={placeholders?.day}\n disabled={disabled}\n min={1}\n max={31}\n maxLength={2}\n onChange={(event) => handleDayChange(event)}\n />\n </div>\n </label>\n </div>\n );\n };\n\n const getYear = () => {\n return (\n <div className=\"col-sm-4 tw-date--year\">\n <label>\n <Body type={Typography.BODY_DEFAULT}>{yearLabel}</Body>\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={yearRef}\n id={`${id}:year`}\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n name=\"year\"\n autoComplete={yearAutoComplete}\n placeholder={placeholders?.year}\n value={displayYear || ''}\n disabled={disabled}\n min={0}\n max={9999}\n maxLength={6}\n onChange={(event) => handleYearChange(event)}\n />\n </div>\n </label>\n </div>\n );\n };\n\n return (\n <fieldset\n id={id}\n className=\"tw-date\"\n aria-describedby={inputAttributes['aria-describedby']}\n aria-invalid={inputAttributes['aria-invalid']}\n aria-labelledby={ariaLabelledBy}\n aria-label={ariaLabel}\n data-wds-dateinput=\"\"\n onFocus={(event) =>\n shouldPropagateOnFocus(event) ? onFocus?.(event) : event.stopPropagation()\n }\n onBlur={(event) => (shouldPropagateOnBlur(event) ? onBlur?.(event) : event.stopPropagation())}\n >\n <div className=\"row\">\n {(() => {\n if (monthYearOnly) {\n return (\n <>\n {!yearFirst && getMonth()}\n {getYear()}\n {yearFirst && getMonth()}\n </>\n );\n }\n if (monthBeforeDay) {\n return (\n <>\n {getMonth()}\n {getDay()}\n {getYear()}\n </>\n );\n }\n if (yearFirst) {\n return (\n <>\n {getYear()}\n {getMonth()}\n {getDay()}\n </>\n );\n }\n return (\n <>\n {getDay()}\n {getMonth()}\n {getYear()}\n </>\n );\n })()}\n </div>\n </fieldset>\n );\n};\n\n// Should only propagate if the relatedTarget is not part of this DateInput component.\nfunction shouldPropagateOnFocus({\n target,\n relatedTarget,\n}: Pick<React.FocusEvent, 'target' | 'relatedTarget'>) {\n const blurredElementParent = target.closest('[data-wds-dateinput]');\n const focusedElementParent = relatedTarget?.closest('[data-wds-dateinput]');\n return blurredElementParent !== focusedElementParent;\n}\n\n// Should only propagate if the focus-gaining element is not part\n// of this DateInput component or the (dropdown) of the month select.\nfunction shouldPropagateOnBlur({\n target,\n relatedTarget,\n}: Pick<React.FocusEvent, 'target' | 'relatedTarget'>) {\n const blurredElementParent = target.closest('[data-wds-dateinput]');\n const focusedElementParent = relatedTarget?.closest('[data-wds-dateinput]');\n\n return (\n blurredElementParent !== focusedElementParent &&\n !target?.closest(`[data-wds-parent=\"${DATE_INPUT_PARENT_ID}\"]`) &&\n !relatedTarget?.closest(`[data-wds-parent=\"${DATE_INPUT_PARENT_ID}\"]`)\n );\n}\n\nexport default DateInput;\n"],"names":["DATE_INPUT_PARENT_ID","DateInput","ariaLabelledByProp","ariaLabel","disabled","size","Size","MEDIUM","value","dayLabel","dayAutoComplete","monthLabel","yearLabel","yearAutoComplete","monthFormat","MonthFormat","LONG","mode","DateMode","DAY_MONTH_YEAR","onChange","onFocus","onBlur","placeholders","id","idProp","selectProps","inputAttributes","useInputAttributes","nonLabelable","fieldLabelRef","useFieldLabelRef","dayRef","useRef","monthRef","yearRef","ariaLabelledBy","locale","formatMessage","useIntl","getDateObject","isDateValid","convertToLocalMidnight","undefined","getInitialDate","unit","dateObject","isMonthAndYearFormat","getFullYear","getMonth","getDate","day","setDay","useState","displayDay","setDisplayDay","toString","month","setMonth","year","setYear","displayYear","setDisplayYear","lastBroadcastedValue","setLastBroadcastedValue","monthNames","getMonthNames","monthYearOnly","MONTH_YEAR","monthBeforeDay","MDY","has","yearFirst","YMD","messages","dayPlaceholder","yearPlaceholder","useEffect","labelRef","current","handleLabelClick","click","focus","addEventListener","removeEventListener","getDateAsString","date","slice","join","getSelectElement","_jsxs","className","children","_jsx","Body","type","Typography","BODY_DEFAULT","SelectInput","triggerRef","parentId","name","placeholder","items","Array","from","length","_","index","renderValue","selectedValue","SelectInputOptionContent","title","handleMonthChange","isDayValid","newDay","newMonth","newYear","maxDay","Date","handleInternalValue","broadcastNewValue","dateValue","setFullYear","handleDayChange","event","newDayString","target","replace","newDayNumber","Number","parseInt","selectedMonth","handleYearChange","newYearString","newYearNumber","newValue","monthWidth","clsx","getDay","Input","ref","inputMode","pattern","autoComplete","min","max","maxLength","getYear","shouldPropagateOnFocus","stopPropagation","shouldPropagateOnBlur","_Fragment","relatedTarget","blurredElementParent","closest","focusedElementParent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAMA,oBAAoB,GAAG,WAAW;AAExC,MAAMC,SAAS,GAAGA,CAAC;AACjB,EAAA,iBAAiB,EAAEC,kBAAkB;AACrC,EAAA,YAAY,EAAEC,SAAS;AACvBC,EAAAA,QAAQ,GAAG,KAAK;EAChBC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,KAAK;EACLC,QAAQ;EACRC,eAAe;EACfC,UAAU;EACVC,SAAS;EACTC,gBAAgB;EAChBC,WAAW,GAAGC,WAAW,CAACC,IAAI;EAC9BC,IAAI,GAAGC,QAAQ,CAACC,cAAc;EAC9BC,QAAQ;EACRC,OAAO;EACPC,MAAM;EACNC,YAAY;AACZC,EAAAA,EAAE,EAAEC,MAAM;AACVC,EAAAA,WAAW,GAAG;AAAE,CACD,KAAI;EACnB,MAAMC,eAAe,GAAGC,kBAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAI,GAAE,CAAC;AAClE,EAAA,MAAMC,aAAa,GAAGC,gBAAgB,EAAE;AACxC,EAAA,MAAMC,MAAM,GAAGC,MAAM,CAAmB,IAAI,CAAC;AAC7C,EAAA,MAAMC,QAAQ,GAAGD,MAAM,CAAoB,IAAI,CAAC;AAChD,EAAA,MAAME,OAAO,GAAGF,MAAM,CAAmB,IAAI,CAAC;AAC9C,EAAA,MAAMT,EAAE,GAAGC,MAAM,IAAIE,eAAe,CAACH,EAAE;AACvC,EAAA,MAAMY,cAAc,GAAGlC,kBAAkB,IAAIyB,eAAe,CAAC,iBAAiB,CAAC;EAE/E,MAAM;IAAEU,MAAM;AAAEC,IAAAA;GAAe,GAAGC,OAAO,EAAE;EAE3C,MAAMC,aAAa,GAAGA,MAAuB;AAC3C,IAAA,IAAIhC,KAAK,IAAIiC,WAAW,CAACjC,K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CAAA,EAAA,CAAI,CAAC;AAE1E;;;;"}
|
|
1
|
+
{"version":3,"file":"DateInput.mjs","sources":["../../src/dateInput/DateInput.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef, useState } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport Body from '../body';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputOptionContent,\n type SelectInputProps,\n} from '../inputs/SelectInput';\nimport {\n DateMode,\n MonthFormat,\n Size,\n SizeLarge,\n SizeMedium,\n SizeSmall,\n Typography,\n} from '../common';\nimport { MDY, YMD, getMonthNames, isDateValid, isMonthAndYearFormat } from '../common/dateUtils';\nimport { useFieldLabelRef, useInputAttributes } from '../inputs/contexts';\nimport messages from './DateInput.messages';\nimport { convertToLocalMidnight } from './utils';\n\nexport interface DateInputProps {\n /** @deprecated Use `Field` wrapper or the `aria-labelledby` attribute instead. */\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /** @default false */\n disabled?: boolean;\n /** @default 'md' */\n size?: SizeSmall | SizeMedium | SizeLarge;\n value?: Date | string;\n onChange: (value: string | null) => void;\n onFocus?: React.FocusEventHandler<HTMLDivElement | HTMLFieldSetElement>;\n onBlur?: React.FocusEventHandler<HTMLDivElement | HTMLFieldSetElement>;\n dayLabel?: string;\n dayAutoComplete?: string;\n monthLabel?: string;\n yearLabel?: string;\n yearAutoComplete?: string;\n /** @default 'long' */\n monthFormat?: `${MonthFormat}`;\n /** @default 'day-month-year' */\n mode?: `${DateMode}`;\n placeholders?: {\n day?: string;\n month?: string;\n year?: string;\n };\n id?: string;\n /** @default {} */\n selectProps?: Partial<SelectInputProps<number | null>>;\n}\n\n/**\n * To be passed to SelectInput's parentId prop for correct blur handling.\n */\nconst DATE_INPUT_PARENT_ID = 'dateInput';\n\nconst DateInput = ({\n 'aria-labelledby': ariaLabelledByProp,\n 'aria-label': ariaLabel,\n disabled = false,\n size = Size.MEDIUM,\n value,\n dayLabel,\n dayAutoComplete,\n monthLabel,\n yearLabel,\n yearAutoComplete,\n monthFormat = MonthFormat.LONG,\n mode = DateMode.DAY_MONTH_YEAR,\n onChange,\n onFocus,\n onBlur,\n placeholders,\n id: idProp,\n selectProps = {},\n}: DateInputProps) => {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const fieldLabelRef = useFieldLabelRef();\n const dayRef = useRef<HTMLInputElement>(null);\n const monthRef = useRef<HTMLButtonElement>(null);\n const yearRef = useRef<HTMLInputElement>(null);\n const id = idProp ?? inputAttributes.id;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];\n\n const { locale, formatMessage } = useIntl();\n\n const getDateObject = (): Date | undefined => {\n if (value && isDateValid(value)) {\n return typeof value === 'string' ? convertToLocalMidnight(value) : value;\n }\n return undefined;\n };\n\n const getInitialDate = (unit: 'year' | 'month' | 'day'): number | null => {\n if (value && isDateValid(value)) {\n const dateObject = getDateObject();\n\n if (typeof value === 'string' && isMonthAndYearFormat(value) && unit === 'day') {\n return null;\n }\n\n if (dateObject !== undefined) {\n switch (unit) {\n case 'year':\n return dateObject.getFullYear();\n case 'month':\n return dateObject.getMonth();\n case 'day':\n return dateObject.getDate();\n default:\n return null;\n }\n }\n }\n return null;\n };\n\n const [day, setDay] = useState(() => getInitialDate('day'));\n const [displayDay, setDisplayDay] = useState(day?.toString());\n const [month, setMonth] = useState(() => getInitialDate('month'));\n const [year, setYear] = useState(() => getInitialDate('year'));\n const [displayYear, setDisplayYear] = useState(year?.toString());\n const [lastBroadcastedValue, setLastBroadcastedValue] = useState<Date | null | undefined>(\n getDateObject,\n );\n const monthNames = getMonthNames(locale, monthFormat);\n\n const monthYearOnly = mode === DateMode.MONTH_YEAR;\n const monthBeforeDay = MDY.has(locale);\n const yearFirst = YMD.has(locale);\n\n dayLabel ||= formatMessage(messages.dayLabel);\n monthLabel ||= formatMessage(messages.monthLabel);\n yearLabel ||= formatMessage(messages.yearLabel);\n placeholders = {\n day: placeholders?.day || formatMessage(messages.dayPlaceholder),\n month: placeholders?.month || formatMessage(messages.monthLabel),\n year: placeholders?.year || formatMessage(messages.yearPlaceholder),\n };\n\n useEffect(() => {\n const labelRef = fieldLabelRef?.current;\n\n if (labelRef) {\n const handleLabelClick = () => {\n // Not the best way to do this, but we're forced to recreate the native Label-click behavior\n if (monthYearOnly || monthBeforeDay) {\n monthRef.current?.click();\n } else if (yearFirst) {\n yearRef.current?.focus();\n } else {\n dayRef.current?.focus();\n }\n };\n\n labelRef.addEventListener('click', handleLabelClick);\n\n return () => {\n labelRef?.removeEventListener('click', handleLabelClick);\n };\n }\n }, [fieldLabelRef, id, monthBeforeDay, monthYearOnly, yearFirst]);\n\n const getDateAsString = (date: Date) => {\n if (!isDateValid(date)) {\n return '';\n }\n switch (mode) {\n case DateMode.MONTH_YEAR:\n return [date.getFullYear(), `0${date.getMonth() + 1}`.slice(-2)].join('-');\n case DateMode.DAY_MONTH_YEAR:\n default:\n return [\n date.getFullYear(),\n `0${date.getMonth() + 1}`.slice(-2),\n `0${date.getDate()}`.slice(-2),\n ].join('-');\n }\n };\n\n const getSelectElement = () => {\n return (\n <label className=\"d-flex flex-column\">\n <Body type={Typography.BODY_DEFAULT}>{monthLabel}</Body>\n <SelectInput\n triggerRef={monthRef}\n id={`${id}:month`}\n parentId={DATE_INPUT_PARENT_ID}\n name=\"month\"\n disabled={disabled}\n placeholder={placeholders?.month}\n items={Array.from({ length: 12 }, (_, index) => ({ type: 'option', value: index }))}\n size={size}\n value={month}\n renderValue={(selectedValue) => (\n <SelectInputOptionContent title={monthNames[selectedValue]} />\n )}\n onChange={(selectedValue) => handleMonthChange(selectedValue)}\n {...selectProps}\n />\n </label>\n );\n };\n\n const isDayValid = (newDay: number, newMonth: number, newYear: number) => {\n const maxDay = new Date(newYear, newMonth + 1, 0).getDate();\n return newDay <= maxDay;\n };\n\n const handleInternalValue = (newDay = day, newMonth = month, newYear = year) => {\n if (newDay == null || newDay === 0 || newMonth == null || newYear == null || newYear === 0) {\n broadcastNewValue(null);\n return;\n }\n if (!isDayValid(newDay, newMonth, newYear)) {\n broadcastNewValue(null);\n return;\n }\n\n const dateValue = new Date(newYear, newMonth, newDay);\n if (newYear < 100) {\n dateValue.setFullYear(newYear);\n }\n\n if (!isDateValid(dateValue)) {\n broadcastNewValue(null);\n return;\n }\n\n if (mode === DateMode.MONTH_YEAR) {\n if (newMonth !== month || newYear !== year) {\n broadcastNewValue(dateValue);\n }\n } else if (newDay !== day || newMonth !== month || newYear !== year) {\n broadcastNewValue(dateValue);\n }\n };\n\n const handleDayChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newDayString = event.target.value.replace(/\\D/g, '');\n const newDayNumber = Number.parseInt(newDayString, 10);\n\n setDay(newDayNumber);\n setDisplayDay(newDayString);\n handleInternalValue(newDayNumber, month, year);\n };\n\n const handleMonthChange = (selectedMonth: number | null) => {\n if (selectedMonth === null) {\n setMonth(null);\n handleInternalValue(day, null, year);\n return;\n }\n setMonth(selectedMonth);\n handleInternalValue(day, selectedMonth, year);\n };\n\n const handleYearChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newYearString = event.target.value.replace(/\\D/g, '');\n const newYearNumber = Number.parseInt(newYearString, 10);\n\n if (newYearString.length >= 4 && newYearString.length <= 6) {\n setYear(newYearNumber);\n setDisplayYear(newYearString);\n handleInternalValue(day, month, newYearNumber);\n } else {\n setYear(null);\n setDisplayYear(newYearString);\n handleInternalValue(day, month, null);\n }\n };\n\n const broadcastNewValue = (newValue: Date | null) => {\n if (newValue !== lastBroadcastedValue) {\n setLastBroadcastedValue(newValue);\n onChange(newValue != null ? getDateAsString(newValue) : null);\n }\n };\n\n const monthWidth = clsx({\n 'col-sm-8 tw-date--month': monthYearOnly,\n 'col-sm-5 tw-date--month': !monthYearOnly,\n });\n\n const getMonth = () => {\n return <div className={monthWidth}>{getSelectElement()}</div>;\n };\n\n const getDay = () => {\n return (\n <div className=\"col-sm-3 tw-date--day\">\n <label>\n <Body type={Typography.BODY_DEFAULT}>{dayLabel}</Body>\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={dayRef}\n id={`${id}:day`}\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n name=\"day\"\n autoComplete={dayAutoComplete}\n value={displayDay || ''}\n placeholder={placeholders?.day}\n disabled={disabled}\n min={1}\n max={31}\n maxLength={2}\n onChange={(event) => handleDayChange(event)}\n />\n </div>\n </label>\n </div>\n );\n };\n\n const getYear = () => {\n return (\n <div className=\"col-sm-4 tw-date--year\">\n <label>\n <Body type={Typography.BODY_DEFAULT}>{yearLabel}</Body>\n <div className={`input-group input-group-${size} ${disabled ? 'disabled' : ''}`}>\n <Input\n ref={yearRef}\n id={`${id}:year`}\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"[0-9]*\"\n name=\"year\"\n autoComplete={yearAutoComplete}\n placeholder={placeholders?.year}\n value={displayYear || ''}\n disabled={disabled}\n min={0}\n max={9999}\n maxLength={6}\n onChange={(event) => handleYearChange(event)}\n />\n </div>\n </label>\n </div>\n );\n };\n\n return (\n <fieldset\n id={id}\n className=\"tw-date\"\n aria-describedby={inputAttributes['aria-describedby']}\n aria-invalid={inputAttributes['aria-invalid']}\n aria-labelledby={ariaLabelledBy}\n aria-label={ariaLabel}\n data-wds-dateinput=\"\"\n onFocus={(event) =>\n shouldPropagateOnFocus(event) ? onFocus?.(event) : event.stopPropagation()\n }\n onBlur={(event) => (shouldPropagateOnBlur(event) ? onBlur?.(event) : event.stopPropagation())}\n >\n <div className=\"row\">\n {(() => {\n if (monthYearOnly) {\n return (\n <>\n {!yearFirst && getMonth()}\n {getYear()}\n {yearFirst && getMonth()}\n </>\n );\n }\n if (monthBeforeDay) {\n return (\n <>\n {getMonth()}\n {getDay()}\n {getYear()}\n </>\n );\n }\n if (yearFirst) {\n return (\n <>\n {getYear()}\n {getMonth()}\n {getDay()}\n </>\n );\n }\n return (\n <>\n {getDay()}\n {getMonth()}\n {getYear()}\n </>\n );\n })()}\n </div>\n </fieldset>\n );\n};\n\n// Should only propagate if the relatedTarget is not part of this DateInput component.\nfunction shouldPropagateOnFocus({\n target,\n relatedTarget,\n}: Pick<React.FocusEvent, 'target' | 'relatedTarget'>) {\n const blurredElementParent = target.closest('[data-wds-dateinput]');\n const focusedElementParent = relatedTarget?.closest('[data-wds-dateinput]');\n return blurredElementParent !== focusedElementParent;\n}\n\n// Should only propagate if the focus-gaining element is not part\n// of this DateInput component or the (dropdown) of the month select.\nfunction shouldPropagateOnBlur({\n target,\n relatedTarget,\n}: Pick<React.FocusEvent, 'target' | 'relatedTarget'>) {\n const blurredElementParent = target.closest('[data-wds-dateinput]');\n const focusedElementParent = relatedTarget?.closest('[data-wds-dateinput]');\n\n return (\n blurredElementParent !== focusedElementParent &&\n !target?.closest(`[data-wds-parent=\"${DATE_INPUT_PARENT_ID}\"]`) &&\n !relatedTarget?.closest(`[data-wds-parent=\"${DATE_INPUT_PARENT_ID}\"]`)\n );\n}\n\nexport default DateInput;\n"],"names":["DATE_INPUT_PARENT_ID","DateInput","ariaLabelledByProp","ariaLabel","disabled","size","Size","MEDIUM","value","dayLabel","dayAutoComplete","monthLabel","yearLabel","yearAutoComplete","monthFormat","MonthFormat","LONG","mode","DateMode","DAY_MONTH_YEAR","onChange","onFocus","onBlur","placeholders","id","idProp","selectProps","inputAttributes","useInputAttributes","nonLabelable","fieldLabelRef","useFieldLabelRef","dayRef","useRef","monthRef","yearRef","ariaLabelledBy","locale","formatMessage","useIntl","getDateObject","isDateValid","convertToLocalMidnight","undefined","getInitialDate","unit","dateObject","isMonthAndYearFormat","getFullYear","getMonth","getDate","day","setDay","useState","displayDay","setDisplayDay","toString","month","setMonth","year","setYear","displayYear","setDisplayYear","lastBroadcastedValue","setLastBroadcastedValue","monthNames","getMonthNames","monthYearOnly","MONTH_YEAR","monthBeforeDay","MDY","has","yearFirst","YMD","messages","dayPlaceholder","yearPlaceholder","useEffect","labelRef","current","handleLabelClick","click","focus","addEventListener","removeEventListener","getDateAsString","date","slice","join","getSelectElement","_jsxs","className","children","_jsx","Body","type","Typography","BODY_DEFAULT","SelectInput","triggerRef","parentId","name","placeholder","items","Array","from","length","_","index","renderValue","selectedValue","SelectInputOptionContent","title","handleMonthChange","isDayValid","newDay","newMonth","newYear","maxDay","Date","handleInternalValue","broadcastNewValue","dateValue","setFullYear","handleDayChange","event","newDayString","target","replace","newDayNumber","Number","parseInt","selectedMonth","handleYearChange","newYearString","newYearNumber","newValue","monthWidth","clsx","getDay","Input","ref","inputMode","pattern","autoComplete","min","max","maxLength","getYear","shouldPropagateOnFocus","stopPropagation","shouldPropagateOnBlur","_Fragment","relatedTarget","blurredElementParent","closest","focusedElementParent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAMA,oBAAoB,GAAG,WAAW;AAExC,MAAMC,SAAS,GAAGA,CAAC;AACjB,EAAA,iBAAiB,EAAEC,kBAAkB;AACrC,EAAA,YAAY,EAAEC,SAAS;AACvBC,EAAAA,QAAQ,GAAG,KAAK;EAChBC,IAAI,GAAGC,IAAI,CAACC,MAAM;EAClBC,KAAK;EACLC,QAAQ;EACRC,eAAe;EACfC,UAAU;EACVC,SAAS;EACTC,gBAAgB;EAChBC,WAAW,GAAGC,WAAW,CAACC,IAAI;EAC9BC,IAAI,GAAGC,QAAQ,CAACC,cAAc;EAC9BC,QAAQ;EACRC,OAAO;EACPC,MAAM;EACNC,YAAY;AACZC,EAAAA,EAAE,EAAEC,MAAM;AACVC,EAAAA,WAAW,GAAG;AAAE,CACD,KAAI;EACnB,MAAMC,eAAe,GAAGC,kBAAkB,CAAC;AAAEC,IAAAA,YAAY,EAAE;AAAI,GAAE,CAAC;AAClE,EAAA,MAAMC,aAAa,GAAGC,gBAAgB,EAAE;AACxC,EAAA,MAAMC,MAAM,GAAGC,MAAM,CAAmB,IAAI,CAAC;AAC7C,EAAA,MAAMC,QAAQ,GAAGD,MAAM,CAAoB,IAAI,C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sC,EAAA;AACnD,EAAA,MAAMC,oBAAoB,GAAG3B,MAAM,CAAC4B,OAAO,CAAC,sBAAsB,CAAC;AACnE,EAAA,MAAMC,oBAAoB,GAAGH,aAAa,EAAEE,OAAO,CAAC,sBAAsB,CAAC;EAE3E,OACED,oBAAoB,KAAKE,oBAAoB,IAC7C,CAAC7B,MAAM,EAAE4B,OAAO,CAAC,CAAA,kBAAA,EAAqB3J,oBAAoB,IAAI,CAAC,IAC/D,CAACyJ,aAAa,EAAEE,OAAO,CAAC,CAAA,kBAAA,EAAqB3J,oBAAoB,CAAA,EAAA,CAAI,CAAC;AAE1E;;;;"}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Button_resolver = require('../../button/Button.resolver.js');
|
|
4
|
-
var SelectInput = require('../../inputs/SelectInput.js');
|
|
4
|
+
var SelectInput = require('../../inputs/SelectInput/SelectInput.js');
|
|
5
5
|
var icons = require('@transferwise/icons');
|
|
6
|
-
|
|
7
|
-
var React = require('react');
|
|
6
|
+
require('clsx');
|
|
8
7
|
var reactIntl = require('react-intl');
|
|
9
|
-
|
|
8
|
+
require('../../dateLookup/dateTrigger/DateTrigger.messages.js');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
10
|
+
var React = require('react');
|
|
11
|
+
require('@headlessui/react');
|
|
12
|
+
var SelectInputOptionContent = require('../../inputs/SelectInput/OptionContent/SelectInputOptionContent.js');
|
|
13
|
+
var SelectInputTriggerButton = require('../../inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js');
|
|
14
|
+
require('../../inputs/contexts.js');
|
|
15
|
+
require('../../header/Header.js');
|
|
16
|
+
require('virtua');
|
|
10
17
|
require('../../common/theme.js');
|
|
11
18
|
require('../../common/direction.js');
|
|
12
19
|
require('../../common/propsValues/control.js');
|
|
@@ -27,9 +34,10 @@ require('../../common/propsValues/scroll.js');
|
|
|
27
34
|
require('../../common/propsValues/markdownNodeType.js');
|
|
28
35
|
require('../../common/fileType.js');
|
|
29
36
|
var index = require('../../common/locale/index.js');
|
|
30
|
-
require('clsx');
|
|
31
37
|
require('../../common/closeButton/CloseButton.messages.js');
|
|
32
|
-
|
|
38
|
+
require('../../inputs/SelectInput/SelectInput.messages.js');
|
|
39
|
+
var art = require('@wise/art');
|
|
40
|
+
var ExpressiveMoneyInput_messages = require('../ExpressiveMoneyInput.messages.js');
|
|
33
41
|
|
|
34
42
|
const CurrencySelector = ({
|
|
35
43
|
id,
|
|
@@ -75,7 +83,7 @@ const CurrencySelector = ({
|
|
|
75
83
|
code,
|
|
76
84
|
label
|
|
77
85
|
}) => {
|
|
78
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
86
|
+
return /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContent.SelectInputOptionContent, {
|
|
79
87
|
title: code,
|
|
80
88
|
note: label,
|
|
81
89
|
icon: /*#__PURE__*/jsxRuntime.jsx(art.Flag, {
|
|
@@ -84,7 +92,7 @@ const CurrencySelector = ({
|
|
|
84
92
|
})
|
|
85
93
|
});
|
|
86
94
|
},
|
|
87
|
-
renderTrigger: () => /*#__PURE__*/jsxRuntime.jsx(
|
|
95
|
+
renderTrigger: () => /*#__PURE__*/jsxRuntime.jsx(SelectInputTriggerButton.SelectInputTriggerButton, {
|
|
88
96
|
as: ButtonInput
|
|
89
97
|
// @ts-expect-error new (v2) ButtonProps
|
|
90
98
|
,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencySelector.js","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';\nimport { getLocaleCurrencyName } from '../../common';\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 ]\n .filter(Boolean)\n .filter((avatar) => !(avatar && Object.keys(avatar).length === 0)),\n }}\n addonEnd={disabled ? undefined : { type: 'icon', value: <ChevronDown /> }}\n onClick={(event) => handleTriggerClick(event)}\n >\n <>\n <span aria-hidden>{currency}</span>\n <span className=\"sr-only\">{getLocaleCurrencyName(intl, currency)}</span>\n </>\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","Boolean","avatar","Object","keys","addonEnd","ChevronDown","onClick","children","_jsxs","_Fragment","className","getLocaleCurrencyName","newValue","onFilterChange","queryNormalized","query","resultCount","forwardRef","rest","ref","Button","size","v2","priority","filterMatchers","keywords","section","flatMap","uniqueCurrencies","Map","forEach","currencyObj","set","Array","from","values","toLowerCase","includes","some","keyword","sort","a","b","aCode","bCode","localeCompare"],"mappings":";;;;;;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AOE,KAAK,CAACC,IAAI,CAACN,gBAAgB,CAACO,MAAM,EAAE,CAAC;AAC9C,CAAC;AAED,MAAMnE,+BAA+B,GAAGA,CACtCV,UAA4B,EAC5ByD,KAAa,KACO;AACpB,EAAA,OACEzD,UAAU,CACPyC,MAAM,CAAE3D,QAAQ,IAAI;IACnB,OACEA,QAAQ,CAACe,IAAI,CAACiF,WAAW,EAAE,CAACC,QAAQ,CAACtB,KAAK,CAAC,IAC3C,CAAC3E,QAAQ,CAAC6C,KAAK,IAAI,EAAE,EAAEmD,WAAW,EAAE,CAACC,QAAQ,CAACtB,KAAK,CAAC,IACpD3E,QAAQ,CAACqF,QAAQ,EAAEa,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACH,WAAW,EAAE,CAACC,QAAQ,CAACtB,KAAK,CAAC,CAAC;EAE/E,CAAC;AACD;AAAA,GACCyB,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAI;IACb,MAAMC,KAAK,GAAGF,CAAC,CAACtF,IAAI,CAACiF,WAAW,EAAE;IAClC,MAAMQ,KAAK,GAAGF,CAAC,CAACvF,IAAI,CAACiF,WAAW,EAAE;IAClC,IAAIO,KAAK,KAAK5B,KAAK,EAAE;AACnB,MAAA,OAAO,EAAE;AACX,IAAA;IACA,IAAI6B,KAAK,KAAK7B,KAAK,EAAE;AACnB,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,OAAO4B,KAAK,CAACE,aAAa,CAACD,KAAK,CAAC;AACnC,EAAA,CAAC,CAAC;AAER,CAAC;;;;;"}
|
|
1
|
+
{"version":3,"file":"CurrencySelector.js","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';\nimport { getLocaleCurrencyName } from '../../common';\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 ]\n .filter(Boolean)\n .filter((avatar) => !(avatar && Object.keys(avatar).length === 0)),\n }}\n addonEnd={disabled ? undefined : { type: 'icon', value: <ChevronDown /> }}\n onClick={(event) => handleTriggerClick(event)}\n >\n <>\n <span aria-hidden>{currency}</span>\n <span className=\"sr-only\">{getLocaleCurrencyName(intl, currency)}</span>\n </>\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","Boolean","avatar","Object","keys","addonEnd","ChevronDown","onClick","children","_jsxs","_Fragment","className","getLocaleCurrencyName","newValue","onFilterChange","queryNormalized","query","resultCount","forwardRef","rest","ref","Button","size","v2","priority","filterMatchers","keywords","section","flatMap","uniqueCurrencies","Map","forEach","currencyObj","set","Array","from","values","toLowerC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5E,IAAI,EAAE4E,WAAW,CAAC;AACrD,EAAA,CAAC,CAAC;EAEF,OAAOE,KAAK,CAACC,IAAI,CAACN,gBAAgB,CAACO,MAAM,EAAE,CAAC;AAC9C,CAAC;AAED,MAAMnE,+BAA+B,GAAGA,CACtCV,UAA4B,EAC5ByD,KAAa,KACO;AACpB,EAAA,OACEzD,UAAU,CACPyC,MAAM,CAAE3D,QAAQ,IAAI;IACnB,OACEA,QAAQ,CAACe,IAAI,CAACiF,WAAW,EAAE,CAACC,QAAQ,CAACtB,KAAK,CAAC,IAC3C,CAAC3E,QAAQ,CAAC6C,KAAK,IAAI,EAAE,EAAEmD,WAAW,EAAE,CAACC,QAAQ,CAACtB,KAAK,CAAC,IACpD3E,QAAQ,CAACqF,QAAQ,EAAEa,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACH,WAAW,EAAE,CAACC,QAAQ,CAACtB,KAAK,CAAC,CAAC;EAE/E,CAAC;AACD;AAAA,GACCyB,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAI;IACb,MAAMC,KAAK,GAAGF,CAAC,CAACtF,IAAI,CAACiF,WAAW,EAAE;IAClC,MAAMQ,KAAK,GAAGF,CAAC,CAACvF,IAAI,CAACiF,WAAW,EAAE;IAClC,IAAIO,KAAK,KAAK5B,KAAK,EAAE;AACnB,MAAA,OAAO,EAAE;AACX,IAAA;IACA,IAAI6B,KAAK,KAAK7B,KAAK,EAAE;AACnB,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,OAAO4B,KAAK,CAACE,aAAa,CAACD,KAAK,CAAC;AACnC,EAAA,CAAC,CAAC;AAER,CAAC;;;;;"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import Button from '../../button/Button.resolver.mjs';
|
|
2
|
-
import { SelectInput
|
|
2
|
+
import { SelectInput } from '../../inputs/SelectInput/SelectInput.mjs';
|
|
3
3
|
import { ChevronDown } from '@transferwise/icons';
|
|
4
|
-
import
|
|
5
|
-
import { useMemo, useState, forwardRef } from 'react';
|
|
4
|
+
import 'clsx';
|
|
6
5
|
import { useIntl } from 'react-intl';
|
|
7
|
-
import
|
|
6
|
+
import '../../dateLookup/dateTrigger/DateTrigger.messages.mjs';
|
|
7
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
+
import { useMemo, useState, forwardRef } from 'react';
|
|
9
|
+
import '@headlessui/react';
|
|
10
|
+
import { SelectInputOptionContent } from '../../inputs/SelectInput/OptionContent/SelectInputOptionContent.mjs';
|
|
11
|
+
import { SelectInputTriggerButton } from '../../inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs';
|
|
12
|
+
import '../../inputs/contexts.mjs';
|
|
13
|
+
import '../../header/Header.mjs';
|
|
14
|
+
import 'virtua';
|
|
8
15
|
import '../../common/theme.mjs';
|
|
9
16
|
import '../../common/direction.mjs';
|
|
10
17
|
import '../../common/propsValues/control.mjs';
|
|
@@ -25,9 +32,10 @@ import '../../common/propsValues/scroll.mjs';
|
|
|
25
32
|
import '../../common/propsValues/markdownNodeType.mjs';
|
|
26
33
|
import '../../common/fileType.mjs';
|
|
27
34
|
import { getLocaleCurrencyName } from '../../common/locale/index.mjs';
|
|
28
|
-
import 'clsx';
|
|
29
35
|
import '../../common/closeButton/CloseButton.messages.mjs';
|
|
30
|
-
import
|
|
36
|
+
import '../../inputs/SelectInput/SelectInput.messages.mjs';
|
|
37
|
+
import { Flag } from '@wise/art';
|
|
38
|
+
import messages from '../ExpressiveMoneyInput.messages.mjs';
|
|
31
39
|
|
|
32
40
|
const CurrencySelector = ({
|
|
33
41
|
id,
|
|
@@ -1 +1 @@
|
|
|
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';\nimport { getLocaleCurrencyName } from '../../common';\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 ]\n .filter(Boolean)\n .filter((avatar) => !(avatar && Object.keys(avatar).length === 0)),\n }}\n addonEnd={disabled ? undefined : { type: 'icon', value: <ChevronDown /> }}\n onClick={(event) => handleTriggerClick(event)}\n >\n <>\n <span aria-hidden>{currency}</span>\n <span className=\"sr-only\">{getLocaleCurrencyName(intl, currency)}</span>\n </>\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","Boolean","avatar","Object","keys","addonEnd","ChevronDown","onClick","children","_jsxs","_Fragment","className","getLocaleCurrencyName","newValue","onFilterChange","queryNormalized","query","resultCount","forwardRef","rest","ref","Button","size","v2","priority","filterMatchers","keywords","section","flatMap","uniqueCurrencies","Map","forEach","currencyObj","set","Array","from","values","toLowerCase","includes","some","keyword","sort","a","b","aCode","bCode","localeCompare"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CO,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,CAACb,QAAQ,IACTF,OAAO,CAACgB,MAAM,KAAK,CAAC,IACnBhB,OAAO,CAACgB,MAAM,KAAK,CAAC,IAAIhB,OAAO,CAAC,CAAC,CAAC,CAACiB,UAAU,CAACD,MAAM,IAAI,CAAE;EAE7D,MAAM,CAACE,WAAW,EAAEC,cAAc,CAAC,GAAGC,QAAQ,CAAS,EAAE,CAAC;EAE1D,MAAMC,kBAAkB,GAAuBC,KAAK,IAAI;AACtD,IAAA,MAAMC,SAAS,GAAGD,KAAK,CAACE,aAAa;IACrC,IAAID,SAAS,EAAEE,YAAY,CAAC,eAAe,CAAC,KAAK,OAAO,EAAE;AACxDrB,MAAAA,MAAM,IAAI;AACZ,IAAA;EACF,CAAC;EAED,MAAMsB,KAAK,GAAGR,WAAW,GACrBS,+BAA+B,CAACnB,kBAAkB,EAAEU,WAA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gB,CAACI,GAAG,CAACD,WAAW,CAAC5E,IAAI,EAAE4E,WAAW,CAAC;AACrD,EAAA,CAAC,CAAC;EAEF,OAAOE,KAAK,CAACC,IAAI,CAACN,gBAAgB,CAACO,MAAM,EAAE,CAAC;AAC9C,CAAC;AAED,MAAMnE,+BAA+B,GAAGA,CACtCV,UAA4B,EAC5ByD,KAAa,KACO;AACpB,EAAA,OACEzD,UAAU,CACPyC,MAAM,CAAE3D,QAAQ,IAAI;IACnB,OACEA,QAAQ,CAACe,IAAI,CAACiF,WAAW,EAAE,CAACC,QAAQ,CAACtB,KAAK,CAAC,IAC3C,CAAC3E,QAAQ,CAAC6C,KAAK,IAAI,EAAE,EAAEmD,WAAW,EAAE,CAACC,QAAQ,CAACtB,KAAK,CAAC,IACpD3E,QAAQ,CAACqF,QAAQ,EAAEa,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACH,WAAW,EAAE,CAACC,QAAQ,CAACtB,KAAK,CAAC,CAAC;EAE/E,CAAC;AACD;AAAA,GACCyB,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAI;IACb,MAAMC,KAAK,GAAGF,CAAC,CAACtF,IAAI,CAACiF,WAAW,EAAE;IAClC,MAAMQ,KAAK,GAAGF,CAAC,CAACvF,IAAI,CAACiF,WAAW,EAAE;IAClC,IAAIO,KAAK,KAAK5B,KAAK,EAAE;AACnB,MAAA,OAAO,EAAE;AACX,IAAA;IACA,IAAI6B,KAAK,KAAK7B,KAAK,EAAE;AACnB,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,OAAO4B,KAAK,CAACE,aAAa,CAACD,KAAK,CAAC;AACnC,EAAA,CAAC,CAAC;AAER,CAAC;;;;"}
|
|
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';\nimport { getLocaleCurrencyName } from '../../common';\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 ]\n .filter(Boolean)\n .filter((avatar) => !(avatar && Object.keys(avatar).length === 0)),\n }}\n addonEnd={disabled ? undefined : { type: 'icon', value: <ChevronDown /> }}\n onClick={(event) => handleTriggerClick(event)}\n >\n <>\n <span aria-hidden>{currency}</span>\n <span className=\"sr-only\">{getLocaleCurrencyName(intl, currency)}</span>\n </>\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","Boolean","avatar","Object","keys","addonEnd","ChevronDown","onClick","children","_jsxs","_Fragment","className","getLocaleCurrencyName","newValue","onFilterChange","queryNormalized","query","resultCount","forwardRef","rest","ref","Button","size","v2","priority","filterMatchers","keywords","section","flatMap","uniqueCurrencies","Map","forEach","currencyObj","set","Array","from","values","toLowerCase","includes","some","keyword","sort","a","b","aCode","bCode","localeCompare"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CO,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,CAACb,QAAQ,IACTF,OAAO,CAACgB,MAAM,KAAK,CAAC,IACnBhB,OAAO,CAACgB,MAAM,KAAK,CAAC,IAAIhB,OAAO,CAAC,CAAC,CAAC,CAACiB,UAAU,CAACD,MAAM,IAAI,CAAE;EAE7D,MAAM,CAACE,WAAW,EAAEC,cAAc,CAAC,GAAGC,QAAQ,CAAS,EAAE,CAAC;EAE1D,MAAMC,kBAAkB,GAAuBC,KAAK,IAAI;AACtD,IAAA,MAAMC,SAAS,GAAGD,KAAK,CAACE,aAAa;IACrC,IAAID,SAAS,EAAEE,YAAY,CAAC,eAAe,CAAC,KAAK,OAAO,EAAE;AACxDrB,MAAAA,MAAM,IAAI;AACZ,IAAA;EACF,CAAC;EAED,MAAMsB,KAAK,GAA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