@transferwise/components 46.140.1 → 46.142.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/avatarLayout/AvatarLayout.js +15 -1
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +15 -1
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/avatarView/AvatarView.js +6 -2
- package/build/avatarView/AvatarView.js.map +1 -1
- package/build/avatarView/AvatarView.mjs +6 -2
- package/build/avatarView/AvatarView.mjs.map +1 -1
- package/build/avatarView/Dot.js +8 -0
- package/build/avatarView/Dot.js.map +1 -1
- package/build/avatarView/Dot.mjs +8 -0
- package/build/avatarView/Dot.mjs.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.js +3 -4
- package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.mjs +4 -5
- package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
- package/build/button/LegacyButton.js.map +1 -1
- package/build/button/LegacyButton.mjs.map +1 -1
- package/build/common/circle/Circle.js +6 -2
- package/build/common/circle/Circle.js.map +1 -1
- package/build/common/circle/Circle.mjs +6 -2
- package/build/common/circle/Circle.mjs.map +1 -1
- package/build/common/hooks/useHasIntersected/useHasIntersected.js +6 -4
- package/build/common/hooks/useHasIntersected/useHasIntersected.js.map +1 -1
- package/build/common/hooks/useHasIntersected/useHasIntersected.mjs +6 -4
- package/build/common/hooks/useHasIntersected/useHasIntersected.mjs.map +1 -1
- package/build/common/liveRegion/LiveRegion.js +4 -1
- package/build/common/liveRegion/LiveRegion.js.map +1 -1
- package/build/common/liveRegion/LiveRegion.mjs +4 -1
- package/build/common/liveRegion/LiveRegion.mjs.map +1 -1
- package/build/dateInput/DateInput.js +10 -10
- package/build/dateInput/DateInput.js.map +1 -1
- package/build/dateInput/DateInput.mjs +10 -10
- package/build/dateInput/DateInput.mjs.map +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.js +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.js.map +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.mjs +1 -1
- package/build/dateLookup/monthCalendar/table/MonthCalendarTable.mjs.map +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.js +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.js.map +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.mjs +1 -1
- package/build/dateLookup/yearCalendar/table/YearCalendarTable.mjs.map +1 -1
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.js.map +1 -1
- package/build/expressiveMoneyInput/ExpressiveMoneyInput.mjs.map +1 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.js +18 -12
- package/build/expressiveMoneyInput/amountInput/AmountInput.js.map +1 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs +19 -13
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs.map +1 -1
- package/build/expressiveMoneyInput/hooks/useInputStyle.js +8 -6
- package/build/expressiveMoneyInput/hooks/useInputStyle.js.map +1 -1
- package/build/expressiveMoneyInput/hooks/useInputStyle.mjs +9 -7
- package/build/expressiveMoneyInput/hooks/useInputStyle.mjs.map +1 -1
- package/build/field/Field.js +63 -32
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.messages.js +14 -0
- package/build/field/Field.messages.js.map +1 -0
- package/build/field/Field.messages.mjs +10 -0
- package/build/field/Field.messages.mjs.map +1 -0
- package/build/field/Field.mjs +65 -34
- package/build/field/Field.mjs.map +1 -1
- package/build/header/Header.js +1 -1
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/header/Header.mjs.map +1 -1
- package/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.js.map +1 -1
- package/build/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.mjs.map +1 -1
- package/build/inputs/SelectInput/Options/SelectInputOptions.js +34 -22
- package/build/inputs/SelectInput/Options/SelectInputOptions.js.map +1 -1
- package/build/inputs/SelectInput/Options/SelectInputOptions.mjs +35 -23
- package/build/inputs/SelectInput/Options/SelectInputOptions.mjs.map +1 -1
- package/build/inputs/SelectInput/Popover/SelectInputPopover.js.map +1 -1
- package/build/inputs/SelectInput/Popover/SelectInputPopover.mjs.map +1 -1
- package/build/inputs/SelectInput/SelectInput.js +8 -6
- package/build/inputs/SelectInput/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput/SelectInput.mjs +9 -7
- package/build/inputs/SelectInput/SelectInput.mjs.map +1 -1
- package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.js.map +1 -1
- package/build/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.mjs.map +1 -1
- package/build/inputs/TextArea.js +5 -0
- package/build/inputs/TextArea.js.map +1 -1
- package/build/inputs/TextArea.mjs +6 -1
- package/build/inputs/TextArea.mjs.map +1 -1
- package/build/inputs/contexts.js +16 -0
- package/build/inputs/contexts.js.map +1 -1
- package/build/inputs/contexts.mjs +16 -2
- package/build/inputs/contexts.mjs.map +1 -1
- package/build/main.css +42 -8
- package/build/nudge/Nudge.js +31 -15
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs +32 -16
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.js +9 -12
- package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.mjs +9 -12
- package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
- package/build/promoCard/PromoCardGroup.js +34 -16
- package/build/promoCard/PromoCardGroup.js.map +1 -1
- package/build/promoCard/PromoCardGroup.mjs +35 -17
- package/build/promoCard/PromoCardGroup.mjs.map +1 -1
- package/build/segmentedControl/SegmentedControl.js +6 -1
- package/build/segmentedControl/SegmentedControl.js.map +1 -1
- package/build/segmentedControl/SegmentedControl.mjs +7 -2
- package/build/segmentedControl/SegmentedControl.mjs.map +1 -1
- package/build/styles/avatarView/AvatarView.css +4 -4
- package/build/styles/avatarView/Dot.css +4 -4
- package/build/styles/css/neptune.css +15 -1
- package/build/styles/expressiveMoneyInput/ExpressiveMoneyInput.css +2 -0
- package/build/styles/expressiveMoneyInput/amountInput/AmountInput.css +2 -0
- package/build/styles/field/Field.css +19 -3
- package/build/styles/main.css +42 -8
- package/build/styles/styles/less/neptune.css +15 -1
- package/build/tabs/Tabs.js +1 -1
- package/build/tabs/Tabs.js.map +1 -1
- package/build/tabs/Tabs.mjs +1 -1
- package/build/tabs/Tabs.mjs.map +1 -1
- package/build/tooltip/Tooltip.js +6 -3
- package/build/tooltip/Tooltip.js.map +1 -1
- package/build/tooltip/Tooltip.mjs +6 -3
- package/build/tooltip/Tooltip.mjs.map +1 -1
- package/build/types/avatarView/AvatarView.d.ts +1 -1
- package/build/types/avatarView/AvatarView.d.ts.map +1 -1
- package/build/types/avatarView/Dot.d.ts.map +1 -1
- package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
- package/build/types/common/circle/Circle.d.ts +1 -1
- package/build/types/common/circle/Circle.d.ts.map +1 -1
- package/build/types/common/hooks/useHasIntersected/useHasIntersected.d.ts.map +1 -1
- package/build/types/common/liveRegion/LiveRegion.d.ts.map +1 -1
- package/build/types/dateLookup/monthCalendar/table/MonthCalendarTable.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/ExpressiveMoneyInput.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/amountInput/AmountInput.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts +2 -2
- package/build/types/expressiveMoneyInput/hooks/useInputStyle.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/hooks/useSelectionRange.d.ts.map +1 -1
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/field/Field.messages.d.ts +8 -0
- package/build/types/field/Field.messages.d.ts.map +1 -0
- package/build/types/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.d.ts.map +1 -1
- package/build/types/inputs/SelectInput/Options/SelectInputOptions.d.ts.map +1 -1
- package/build/types/inputs/SelectInput/Popover/SelectInputPopover.d.ts.map +1 -1
- package/build/types/inputs/SelectInput/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/TextArea.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts +6 -0
- package/build/types/inputs/contexts.d.ts.map +1 -1
- package/build/types/nudge/Nudge.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/promoCard/PromoCardGroup.d.ts.map +1 -1
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +2 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/types/tooltip/Tooltip.d.ts.map +1 -1
- package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
- package/build/uploadInput/UploadInput.js +29 -25
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +29 -25
- package/build/uploadInput/UploadInput.mjs.map +1 -1
- package/package.json +3 -3
- package/src/avatarLayout/AvatarLayout.story.tsx +1 -1
- package/src/avatarLayout/AvatarLayout.tsx +4 -0
- package/src/avatarView/AvatarView.css +4 -4
- package/src/avatarView/AvatarView.story.tsx +17 -13
- package/src/avatarView/AvatarView.tsx +5 -1
- package/src/avatarView/Dot.css +4 -4
- package/src/avatarView/Dot.less +6 -6
- package/src/avatarView/Dot.tsx +2 -0
- package/src/avatarWrapper/AvatarWrapper.test.tsx +33 -3
- package/src/avatarWrapper/AvatarWrapper.tsx +5 -6
- package/src/button/LegacyButton.tsx +1 -1
- package/src/button/_stories/Button.test.story.tsx +3 -3
- package/src/common/circle/Circle.tsx +5 -1
- package/src/common/hooks/useContainerSize.test.tsx +1 -1
- package/src/common/hooks/useHasIntersected/useHasIntersected.ts +12 -4
- package/src/common/liveRegion/LiveRegion.tsx +5 -2
- package/src/dateInput/DateInput.tsx +10 -10
- package/src/dateLookup/monthCalendar/table/MonthCalendarTable.tsx +1 -5
- package/src/dateLookup/yearCalendar/table/YearCalendarTable.tsx +1 -1
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.css +2 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.test.story.tsx +43 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.tsx +1 -1
- package/src/expressiveMoneyInput/amountInput/AmountInput.css +2 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.less +2 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.tsx +23 -16
- package/src/expressiveMoneyInput/hooks/useInputStyle.ts +20 -8
- package/src/expressiveMoneyInput/hooks/useSelectionRange.ts +2 -0
- package/src/field/Field.css +19 -3
- package/src/field/Field.less +17 -3
- package/src/field/Field.messages.ts +8 -0
- package/src/field/Field.story.tsx +5 -1
- package/src/field/Field.test.tsx +90 -0
- package/src/field/Field.tsx +84 -37
- package/src/header/Header.tsx +2 -2
- package/src/i18n/en.json +1 -0
- package/src/inputs/SelectInput/BottomSheet/SelectInputBottomSheet.tsx +4 -0
- package/src/inputs/SelectInput/Options/SelectInputOptions.tsx +43 -27
- package/src/inputs/SelectInput/Popover/SelectInputPopover.tsx +4 -0
- package/src/inputs/SelectInput/SelectInput.tsx +21 -15
- package/src/inputs/SelectInput/TriggerButton/SelectInputTriggerButton.tsx +1 -1
- package/src/inputs/TextArea.story.tsx +97 -0
- package/src/inputs/TextArea.test.story.tsx +142 -0
- package/src/inputs/TextArea.tsx +7 -2
- package/src/inputs/contexts.tsx +18 -1
- package/src/main.css +42 -8
- package/src/nudge/Nudge.tsx +29 -20
- package/src/phoneNumberInput/PhoneNumberInput.test.tsx +16 -0
- package/src/phoneNumberInput/PhoneNumberInput.tsx +11 -13
- package/src/promoCard/PromoCard.story.tsx +3 -3
- package/src/promoCard/PromoCardGroup.tsx +39 -21
- package/src/segmentedControl/SegmentedControl.test.tsx +25 -0
- package/src/segmentedControl/SegmentedControl.tsx +7 -1
- package/src/select/Select.story.tsx +1 -1
- package/src/styles/less/core/_typography.less +28 -6
- package/src/styles/less/neptune.css +15 -1
- package/src/tabs/Tabs.tsx +1 -1
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +1 -0
- package/src/tooltip/Tooltip.tsx +3 -0
- package/src/uploadInput/UploadInput.test.tsx +19 -0
- package/src/uploadInput/UploadInput.tsx +28 -24
|
@@ -15,7 +15,9 @@ const MAP_ICON_SIZE = {
|
|
|
15
15
|
40: 20,
|
|
16
16
|
48: 24,
|
|
17
17
|
56: 28,
|
|
18
|
-
72: 36
|
|
18
|
+
72: 36,
|
|
19
|
+
88: 44,
|
|
20
|
+
96: 48
|
|
19
21
|
};
|
|
20
22
|
/**
|
|
21
23
|
* circle like components have custom typography styles for for default (Inter) font
|
|
@@ -29,7 +31,9 @@ const MAP_FONT_SIZE = {
|
|
|
29
31
|
40: 18,
|
|
30
32
|
48: 22,
|
|
31
33
|
56: 26,
|
|
32
|
-
72: 30
|
|
34
|
+
72: 30,
|
|
35
|
+
88: 36,
|
|
36
|
+
96: 40
|
|
33
37
|
};
|
|
34
38
|
const Circle = /*#__PURE__*/React.forwardRef(function Circle({
|
|
35
39
|
as: Element = 'div',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.js","sources":["../../../src/common/circle/Circle.tsx"],"sourcesContent":["import { HTMLAttributes, forwardRef } from 'react';\nimport { clsx } from 'clsx';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\n\nexport type ShapeSize = 16 | 24 | 32 | 40 | 48 | 56 | 72;\n\nexport type Props = {\n /**\n * Modify underlying element, `div` by default\n */\n as?: React.ElementType;\n /**\n * Set size of the circle in px, `48` by default\n */\n size?: ShapeSize;\n /**\n * When `true` will use the fixed size (`48px`) instead of the CSS spacing variable (`--size-*`)\n * as those can be dynamic a at certain viewport sizes\n */\n fixedSize?: boolean;\n enableBorder?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\n/**\n * circle like components has custom sizes for icons\n */\nconst MAP_ICON_SIZE = {\n 16: 12,\n 24: 16,\n 32: 18,\n 40: 20,\n 48: 24,\n 56: 28,\n 72: 36,\n};\n\n/**\n * circle like components have custom typography styles for for default (Inter) font\n *\n * circle size : font size (px)\n */\nconst MAP_FONT_SIZE = {\n 16: 8,\n 24: 12,\n 32: 14,\n 40: 18,\n 48: 22,\n 56: 26,\n 72: 30,\n};\n\nconst Circle = forwardRef(function Circle(\n {\n as: Element = 'div',\n children,\n size = 48,\n fixedSize = false,\n enableBorder = false,\n className,\n style,\n ...props\n }: Props,\n ref,\n) {\n const isTinyViewport = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n return (\n <Element\n {...props}\n ref={ref}\n style={{\n '--circle-size': fixedSize ? `${size}px` : `var(--size-${size})`,\n '--circle-icon-size':\n isTinyViewport && !fixedSize\n ? `${MAP_ICON_SIZE[size] / 2}px`\n : `${MAP_ICON_SIZE[size]}px`,\n '--circle-font-size': `${MAP_FONT_SIZE[size]}px`,\n ...style,\n }}\n className={clsx(\n 'np-circle',\n { 'np-circle-border': enableBorder },\n 'd-flex align-items-center justify-content-center',\n className,\n )}\n >\n {children}\n </Element>\n );\n});\n\nexport default Circle;\n"],"names":["MAP_ICON_SIZE","MAP_FONT_SIZE","Circle","forwardRef","as","Element","children","size","fixedSize","enableBorder","className","style","props","ref","isTinyViewport","useMedia","Breakpoint","ZOOM_400","_jsx","clsx"],"mappings":";;;;;;;;;;AA2BA,MAAMA,aAAa,GAAG;AACpB,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,E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EACX;AAAE,MAAA,kBAAkB,EAAEV;KAAc,EACpC,kDAAkD,EAClDC,SAAS,CACT;AAAAJ,IAAAA,QAAA,EAEDA;AAAQ,GACF,CAAC;AAEd,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Circle.js","sources":["../../../src/common/circle/Circle.tsx"],"sourcesContent":["import { HTMLAttributes, forwardRef } from 'react';\nimport { clsx } from 'clsx';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\n\nexport type ShapeSize = 16 | 24 | 32 | 40 | 48 | 56 | 72 | 88 | 96;\n\nexport type Props = {\n /**\n * Modify underlying element, `div` by default\n */\n as?: React.ElementType;\n /**\n * Set size of the circle in px, `48` by default\n */\n size?: ShapeSize;\n /**\n * When `true` will use the fixed size (`48px`) instead of the CSS spacing variable (`--size-*`)\n * as those can be dynamic a at certain viewport sizes\n */\n fixedSize?: boolean;\n enableBorder?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\n/**\n * circle like components has custom sizes for icons\n */\nconst MAP_ICON_SIZE = {\n 16: 12,\n 24: 16,\n 32: 18,\n 40: 20,\n 48: 24,\n 56: 28,\n 72: 36,\n 88: 44,\n 96: 48,\n};\n\n/**\n * circle like components have custom typography styles for for default (Inter) font\n *\n * circle size : font size (px)\n */\nconst MAP_FONT_SIZE = {\n 16: 8,\n 24: 12,\n 32: 14,\n 40: 18,\n 48: 22,\n 56: 26,\n 72: 30,\n 88: 36,\n 96: 40,\n};\n\nconst Circle = forwardRef(function Circle(\n {\n as: Element = 'div',\n children,\n size = 48,\n fixedSize = false,\n enableBorder = false,\n className,\n style,\n ...props\n }: Props,\n ref,\n) {\n const isTinyViewport = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n return (\n <Element\n {...props}\n ref={ref}\n style={{\n '--circle-size': fixedSize ? `${size}px` : `var(--size-${size})`,\n '--circle-icon-size':\n isTinyViewport && !fixedSize\n ? `${MAP_ICON_SIZE[size] / 2}px`\n : `${MAP_ICON_SIZE[size]}px`,\n '--circle-font-size': `${MAP_FONT_SIZE[size]}px`,\n ...style,\n }}\n className={clsx(\n 'np-circle',\n { 'np-circle-border': enableBorder },\n 'd-flex align-items-center justify-content-center',\n className,\n )}\n >\n {children}\n </Element>\n );\n});\n\nexport default Circle;\n"],"names":["MAP_ICON_SIZE","MAP_FONT_SIZE","Circle","forwardRef","as","Element","children","size","fixedSize","enableBorder","className","style","props","ref","isTinyViewport","useMedia","Breakpoint","ZOOM_400","_jsx","clsx"],"mappings":";;;;;;;;;;AA2BA,MAAMA,aAAa,GAAG;AACpB,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE;CACL;AAED;;;;AAIG;AACH,MAAMC,aAAa,GAAG;AACpB,EAAA,EAAE,EAAE,CAAC;AACL,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE;CACL;AAED,MAAMC,MAAM,gBAAGC,gBAAU,CAAC,SAASD,MAAMA,CACvC;EACEE,EAAE,EAAEC,OAAO,GAAG,KAAK;EACnBC,QAAQ;AACRC,EAAAA,IAAI,GAAG,EAAE;AACTC,EAAAA,SAAS,GAAG,KAAK;AACjBC,EAAAA,YAAY,GAAG,KAAK;EACpBC,SAAS;EACTC,KAAK;EACL,GAAGC;AAAK,CACF,EACRC,GAAG,EAAA;EAEH,MAAMC,cAAc,GAAGC,iBAAQ,CAAC,eAAeC,qBAAU,CAACC,QAAQ,CAAA,GAAA,CAAK,CAAC;EACxE,oBACEC,cAAA,CAACb,OAAO,EAAA;AAAA,IAAA,GACFO,KAAK;AACTC,IAAAA,GAAG,EAAEA,GAAI;AACTF,IAAAA,KAAK,EAAE;MACL,eAAe,EAAEH,SAAS,GAAG,CAAA,EAAGD,IAAI,CAAA,EAAA,CAAI,GAAG,CAAA,WAAA,EAAcA,IAAI,CAAA,CAAA,CAAG;MAChE,oBAAoB,EAClBO,cAAc,IAAI,CAACN,SAAS,GACxB,CAAA,EAAGR,aAAa,CAACO,IAAI,CAAC,GAAG,CAAC,IAAI,GAC9B,CAAA,EAAGP,aAAa,CAACO,IAAI,CAAC,CAAA,EAAA,CAAI;AAChC,MAAA,oBAAoB,EAAE,CAAA,EAAGN,aAAa,CAACM,IAAI,CAAC,CAAA,EAAA,CAAI;MAChD,GAAGI;KACH;AACFD,IAAAA,SAAS,EAAES,SAAI,CACb,WAAW,EACX;AAAE,MAAA,kBAAkB,EAAEV;KAAc,EACpC,kDAAkD,EAClDC,SAAS,CACT;AAAAJ,IAAAA,QAAA,EAEDA;AAAQ,GACF,CAAC;AAEd,CAAC;;;;"}
|
|
@@ -11,7 +11,9 @@ const MAP_ICON_SIZE = {
|
|
|
11
11
|
40: 20,
|
|
12
12
|
48: 24,
|
|
13
13
|
56: 28,
|
|
14
|
-
72: 36
|
|
14
|
+
72: 36,
|
|
15
|
+
88: 44,
|
|
16
|
+
96: 48
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* circle like components have custom typography styles for for default (Inter) font
|
|
@@ -25,7 +27,9 @@ const MAP_FONT_SIZE = {
|
|
|
25
27
|
40: 18,
|
|
26
28
|
48: 22,
|
|
27
29
|
56: 26,
|
|
28
|
-
72: 30
|
|
30
|
+
72: 30,
|
|
31
|
+
88: 36,
|
|
32
|
+
96: 40
|
|
29
33
|
};
|
|
30
34
|
const Circle = /*#__PURE__*/forwardRef(function Circle({
|
|
31
35
|
as: Element = 'div',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.mjs","sources":["../../../src/common/circle/Circle.tsx"],"sourcesContent":["import { HTMLAttributes, forwardRef } from 'react';\nimport { clsx } from 'clsx';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\n\nexport type ShapeSize = 16 | 24 | 32 | 40 | 48 | 56 | 72;\n\nexport type Props = {\n /**\n * Modify underlying element, `div` by default\n */\n as?: React.ElementType;\n /**\n * Set size of the circle in px, `48` by default\n */\n size?: ShapeSize;\n /**\n * When `true` will use the fixed size (`48px`) instead of the CSS spacing variable (`--size-*`)\n * as those can be dynamic a at certain viewport sizes\n */\n fixedSize?: boolean;\n enableBorder?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\n/**\n * circle like components has custom sizes for icons\n */\nconst MAP_ICON_SIZE = {\n 16: 12,\n 24: 16,\n 32: 18,\n 40: 20,\n 48: 24,\n 56: 28,\n 72: 36,\n};\n\n/**\n * circle like components have custom typography styles for for default (Inter) font\n *\n * circle size : font size (px)\n */\nconst MAP_FONT_SIZE = {\n 16: 8,\n 24: 12,\n 32: 14,\n 40: 18,\n 48: 22,\n 56: 26,\n 72: 30,\n};\n\nconst Circle = forwardRef(function Circle(\n {\n as: Element = 'div',\n children,\n size = 48,\n fixedSize = false,\n enableBorder = false,\n className,\n style,\n ...props\n }: Props,\n ref,\n) {\n const isTinyViewport = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n return (\n <Element\n {...props}\n ref={ref}\n style={{\n '--circle-size': fixedSize ? `${size}px` : `var(--size-${size})`,\n '--circle-icon-size':\n isTinyViewport && !fixedSize\n ? `${MAP_ICON_SIZE[size] / 2}px`\n : `${MAP_ICON_SIZE[size]}px`,\n '--circle-font-size': `${MAP_FONT_SIZE[size]}px`,\n ...style,\n }}\n className={clsx(\n 'np-circle',\n { 'np-circle-border': enableBorder },\n 'd-flex align-items-center justify-content-center',\n className,\n )}\n >\n {children}\n </Element>\n );\n});\n\nexport default Circle;\n"],"names":["MAP_ICON_SIZE","MAP_FONT_SIZE","Circle","forwardRef","as","Element","children","size","fixedSize","enableBorder","className","style","props","ref","isTinyViewport","useMedia","Breakpoint","ZOOM_400","_jsx","clsx"],"mappings":";;;;;;AA2BA,MAAMA,aAAa,GAAG;AACpB,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE;CACL;AAED;;;;AAIG;AACH,MAAMC,aAAa,GAAG;AACpB,EAAA,EAAE,EAAE,CAAC;AACL,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE;CACL;AAED,MAAMC,MAAM,gBAAGC,UAAU,CAAC,SAASD,MAAMA,CACvC;EACEE,EAAE,EAAEC,OAAO,GAAG,KAAK;EACnBC,QAAQ;AACRC,EAAAA,IAAI,GAAG,EAAE;AACTC,EAAAA,SAAS,GAAG,KAAK;AACjBC,EAAAA,YAAY,GAAG,KAAK;EACpBC,SAAS;EACTC,KAAK;EACL,GAAGC;AAAK,CACF,EACRC,GAAG,EAAA;EAEH,MAAMC,cAAc,GAAGC,QAAQ,CAAC,eAAeC,UAAU,CAACC,QAAQ,CAAA,GAAA,CAAK,CAAC;EACxE,oBACEC,GAAA,CAACb,OAAO,EAAA;AAAA,IAAA,GACFO,KAAK;AACTC,IAAAA,GAAG,EAAEA,GAAI;AACTF,IAAAA,KAAK,EAAE;MACL,eAAe,EAAEH,SAAS,GAAG,CAAA,EAAGD,IAAI,CAAA,EAAA,CAAI,GAAG,CAAA,WAAA,EAAcA,IAAI,CAAA,CAAA,CAAG;MAChE,oBAAoB,EAClBO,cAAc,IAAI,CAACN,SAAS,GACxB,CAAA,EAAGR,aAAa,CAACO,IAAI,CAAC,GAAG,CAAC,IAAI,GAC9B,CAAA,EAAGP,aAAa,CAACO,IAAI,CAAC,CAAA,EAAA,CAAI;AAChC,MAAA,oBAAoB,EAAE,CAAA,EAAGN,aAAa,CAACM,IAAI,CAAC,CAAA,EAAA,CAAI;MAChD,GAAGI;KACH;AACFD,IAAAA,SAAS,EAAES,IAAI,CACb,WAAW,EACX;AAAE,MAAA,kBAAkB,EAAEV;KAAc,EACpC,kDAAkD,EAClDC,SAAS,CACT;AAAAJ,IAAAA,QAAA,EAEDA;AAAQ,GACF,CAAC;AAEd,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Circle.mjs","sources":["../../../src/common/circle/Circle.tsx"],"sourcesContent":["import { HTMLAttributes, forwardRef } from 'react';\nimport { clsx } from 'clsx';\nimport { useMedia } from '../hooks/useMedia';\nimport { Breakpoint } from '../propsValues/breakpoint';\n\nexport type ShapeSize = 16 | 24 | 32 | 40 | 48 | 56 | 72 | 88 | 96;\n\nexport type Props = {\n /**\n * Modify underlying element, `div` by default\n */\n as?: React.ElementType;\n /**\n * Set size of the circle in px, `48` by default\n */\n size?: ShapeSize;\n /**\n * When `true` will use the fixed size (`48px`) instead of the CSS spacing variable (`--size-*`)\n * as those can be dynamic a at certain viewport sizes\n */\n fixedSize?: boolean;\n enableBorder?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\n/**\n * circle like components has custom sizes for icons\n */\nconst MAP_ICON_SIZE = {\n 16: 12,\n 24: 16,\n 32: 18,\n 40: 20,\n 48: 24,\n 56: 28,\n 72: 36,\n 88: 44,\n 96: 48,\n};\n\n/**\n * circle like components have custom typography styles for for default (Inter) font\n *\n * circle size : font size (px)\n */\nconst MAP_FONT_SIZE = {\n 16: 8,\n 24: 12,\n 32: 14,\n 40: 18,\n 48: 22,\n 56: 26,\n 72: 30,\n 88: 36,\n 96: 40,\n};\n\nconst Circle = forwardRef(function Circle(\n {\n as: Element = 'div',\n children,\n size = 48,\n fixedSize = false,\n enableBorder = false,\n className,\n style,\n ...props\n }: Props,\n ref,\n) {\n const isTinyViewport = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);\n return (\n <Element\n {...props}\n ref={ref}\n style={{\n '--circle-size': fixedSize ? `${size}px` : `var(--size-${size})`,\n '--circle-icon-size':\n isTinyViewport && !fixedSize\n ? `${MAP_ICON_SIZE[size] / 2}px`\n : `${MAP_ICON_SIZE[size]}px`,\n '--circle-font-size': `${MAP_FONT_SIZE[size]}px`,\n ...style,\n }}\n className={clsx(\n 'np-circle',\n { 'np-circle-border': enableBorder },\n 'd-flex align-items-center justify-content-center',\n className,\n )}\n >\n {children}\n </Element>\n );\n});\n\nexport default Circle;\n"],"names":["MAP_ICON_SIZE","MAP_FONT_SIZE","Circle","forwardRef","as","Element","children","size","fixedSize","enableBorder","className","style","props","ref","isTinyViewport","useMedia","Breakpoint","ZOOM_400","_jsx","clsx"],"mappings":";;;;;;AA2BA,MAAMA,aAAa,GAAG;AACpB,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE;CACL;AAED;;;;AAIG;AACH,MAAMC,aAAa,GAAG;AACpB,EAAA,EAAE,EAAE,CAAC;AACL,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE,EAAE;AACN,EAAA,EAAE,EAAE;CACL;AAED,MAAMC,MAAM,gBAAGC,UAAU,CAAC,SAASD,MAAMA,CACvC;EACEE,EAAE,EAAEC,OAAO,GAAG,KAAK;EACnBC,QAAQ;AACRC,EAAAA,IAAI,GAAG,EAAE;AACTC,EAAAA,SAAS,GAAG,KAAK;AACjBC,EAAAA,YAAY,GAAG,KAAK;EACpBC,SAAS;EACTC,KAAK;EACL,GAAGC;AAAK,CACF,EACRC,GAAG,EAAA;EAEH,MAAMC,cAAc,GAAGC,QAAQ,CAAC,eAAeC,UAAU,CAACC,QAAQ,CAAA,GAAA,CAAK,CAAC;EACxE,oBACEC,GAAA,CAACb,OAAO,EAAA;AAAA,IAAA,GACFO,KAAK;AACTC,IAAAA,GAAG,EAAEA,GAAI;AACTF,IAAAA,KAAK,EAAE;MACL,eAAe,EAAEH,SAAS,GAAG,CAAA,EAAGD,IAAI,CAAA,EAAA,CAAI,GAAG,CAAA,WAAA,EAAcA,IAAI,CAAA,CAAA,CAAG;MAChE,oBAAoB,EAClBO,cAAc,IAAI,CAACN,SAAS,GACxB,CAAA,EAAGR,aAAa,CAACO,IAAI,CAAC,GAAG,CAAC,IAAI,GAC9B,CAAA,EAAGP,aAAa,CAACO,IAAI,CAAC,CAAA,EAAA,CAAI;AAChC,MAAA,oBAAoB,EAAE,CAAA,EAAGN,aAAa,CAACM,IAAI,CAAC,CAAA,EAAA,CAAI;MAChD,GAAGI;KACH;AACFD,IAAAA,SAAS,EAAES,IAAI,CACb,WAAW,EACX;AAAE,MAAA,kBAAkB,EAAEV;KAAc,EACpC,kDAAkD,EAClDC,SAAS,CACT;AAAAJ,IAAAA,QAAA,EAEDA;AAAQ,GACF,CAAC;AAEd,CAAC;;;;"}
|
|
@@ -20,7 +20,11 @@ const useHasIntersected = ({
|
|
|
20
20
|
elRef,
|
|
21
21
|
loading = 'eager'
|
|
22
22
|
}) => {
|
|
23
|
-
|
|
23
|
+
// Initialize as true if IntersectionObserver is not supported
|
|
24
|
+
// Note: We can't check elRef.current here as it may not be set yet on first render
|
|
25
|
+
const [hasIntersected, setHasIntersected] = React.useState(() => {
|
|
26
|
+
return typeof window === 'undefined' || !window.IntersectionObserver;
|
|
27
|
+
});
|
|
24
28
|
const {
|
|
25
29
|
current
|
|
26
30
|
} = elRef || {};
|
|
@@ -41,9 +45,7 @@ const useHasIntersected = ({
|
|
|
41
45
|
let observer;
|
|
42
46
|
let didCancel = false;
|
|
43
47
|
// Check if window is defined for SSR and Old browsers fallback
|
|
44
|
-
if (typeof window
|
|
45
|
-
setHasIntersected(true);
|
|
46
|
-
} else if (current && !didCancel) {
|
|
48
|
+
if (typeof window !== 'undefined' && window.IntersectionObserver && isValidReference() && current && !didCancel) {
|
|
47
49
|
observer = new IntersectionObserver(handleOnIntersect, ObserverParams);
|
|
48
50
|
observer.observe(current);
|
|
49
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHasIntersected.js","sources":["../../../../src/common/hooks/useHasIntersected/useHasIntersected.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst ObserverParams: IntersectionObserverInit = {\n threshold: 0.1,\n};\n\n/**\n * useHasIntersected.\n * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.\n * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.\n *\n * @param {object} params\n * @param {object} [params.elRef] - node object that contains a react reference to the element that needs to be observed.\n * @param {string} [params.loading = 'eager'] - string that contains the type of loading.\n * @param elRef.loading\n * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`\n */\nexport const useHasIntersected = ({\n elRef,\n loading = 'eager',\n}: {\n elRef: React.RefObject<HTMLElement>;\n loading?: 'eager' | 'lazy';\n}) => {\n const [hasIntersected, setHasIntersected] = useState(
|
|
1
|
+
{"version":3,"file":"useHasIntersected.js","sources":["../../../../src/common/hooks/useHasIntersected/useHasIntersected.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst ObserverParams: IntersectionObserverInit = {\n threshold: 0.1,\n};\n\n/**\n * useHasIntersected.\n * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.\n * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.\n *\n * @param {object} params\n * @param {object} [params.elRef] - node object that contains a react reference to the element that needs to be observed.\n * @param {string} [params.loading = 'eager'] - string that contains the type of loading.\n * @param elRef.loading\n * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`\n */\nexport const useHasIntersected = ({\n elRef,\n loading = 'eager',\n}: {\n elRef: React.RefObject<HTMLElement>;\n loading?: 'eager' | 'lazy';\n}) => {\n // Initialize as true if IntersectionObserver is not supported\n // Note: We can't check elRef.current here as it may not be set yet on first render\n const [hasIntersected, setHasIntersected] = useState(() => {\n return typeof window === 'undefined' || !window.IntersectionObserver;\n });\n\n const { current } = elRef || {};\n\n const isValidReference = () => {\n return elRef && current;\n };\n\n const handleOnIntersect: IntersectionObserverCallback = (entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setHasIntersected(true);\n\n if (current) {\n observer.unobserve(current);\n }\n }\n });\n };\n\n useEffect(() => {\n let observer: IntersectionObserver | undefined;\n let didCancel = false;\n\n // Check if window is defined for SSR and Old browsers fallback\n if (\n typeof window !== 'undefined' &&\n window.IntersectionObserver &&\n isValidReference() &&\n current &&\n !didCancel\n ) {\n observer = new IntersectionObserver(handleOnIntersect, ObserverParams);\n observer.observe(current);\n }\n return () => {\n didCancel = true;\n if (observer && current) {\n observer.unobserve(current);\n }\n };\n }, [elRef]);\n\n if (loading === 'eager') {\n return [false];\n }\n\n return [hasIntersected];\n};\n"],"names":["ObserverParams","threshold","useHasIntersected","elRef","loading","hasIntersected","setHasIntersected","useState","window","IntersectionObserver","current","isValidReference","handleOnIntersect","entries","observer","forEach","entry","isIntersecting","unobserve","useEffect","didCancel","observe"],"mappings":";;;;AAEA,MAAMA,cAAc,GAA6B;AAC/CC,EAAAA,SAAS,EAAE;CACZ;AAED;;;;;;;;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Q,CAACI,SAAS,CAACR,OAAO,CAAC;AAC7B,MAAA;IACF,CAAC;AACH,EAAA,CAAC,EAAE,CAACP,KAAK,CAAC,CAAC;EAEX,IAAIC,OAAO,KAAK,OAAO,EAAE;IACvB,OAAO,CAAC,KAAK,CAAC;AAChB,EAAA;EAEA,OAAO,CAACC,cAAc,CAAC;AACzB;;;;"}
|
|
@@ -18,7 +18,11 @@ const useHasIntersected = ({
|
|
|
18
18
|
elRef,
|
|
19
19
|
loading = 'eager'
|
|
20
20
|
}) => {
|
|
21
|
-
|
|
21
|
+
// Initialize as true if IntersectionObserver is not supported
|
|
22
|
+
// Note: We can't check elRef.current here as it may not be set yet on first render
|
|
23
|
+
const [hasIntersected, setHasIntersected] = useState(() => {
|
|
24
|
+
return typeof window === 'undefined' || !window.IntersectionObserver;
|
|
25
|
+
});
|
|
22
26
|
const {
|
|
23
27
|
current
|
|
24
28
|
} = elRef || {};
|
|
@@ -39,9 +43,7 @@ const useHasIntersected = ({
|
|
|
39
43
|
let observer;
|
|
40
44
|
let didCancel = false;
|
|
41
45
|
// Check if window is defined for SSR and Old browsers fallback
|
|
42
|
-
if (typeof window
|
|
43
|
-
setHasIntersected(true);
|
|
44
|
-
} else if (current && !didCancel) {
|
|
46
|
+
if (typeof window !== 'undefined' && window.IntersectionObserver && isValidReference() && current && !didCancel) {
|
|
45
47
|
observer = new IntersectionObserver(handleOnIntersect, ObserverParams);
|
|
46
48
|
observer.observe(current);
|
|
47
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHasIntersected.mjs","sources":["../../../../src/common/hooks/useHasIntersected/useHasIntersected.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst ObserverParams: IntersectionObserverInit = {\n threshold: 0.1,\n};\n\n/**\n * useHasIntersected.\n * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.\n * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.\n *\n * @param {object} params\n * @param {object} [params.elRef] - node object that contains a react reference to the element that needs to be observed.\n * @param {string} [params.loading = 'eager'] - string that contains the type of loading.\n * @param elRef.loading\n * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`\n */\nexport const useHasIntersected = ({\n elRef,\n loading = 'eager',\n}: {\n elRef: React.RefObject<HTMLElement>;\n loading?: 'eager' | 'lazy';\n}) => {\n const [hasIntersected, setHasIntersected] = useState(
|
|
1
|
+
{"version":3,"file":"useHasIntersected.mjs","sources":["../../../../src/common/hooks/useHasIntersected/useHasIntersected.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst ObserverParams: IntersectionObserverInit = {\n threshold: 0.1,\n};\n\n/**\n * useHasIntersected.\n * Use this custom hook to detect when an element has became visible inside the viewport. This hook checks only if the intersection happend.\n * Once the intersection has happened the hook will not return false even if the element gets out of the viewport.\n *\n * @param {object} params\n * @param {object} [params.elRef] - node object that contains a react reference to the element that needs to be observed.\n * @param {string} [params.loading = 'eager'] - string that contains the type of loading.\n * @param elRef.loading\n * @usage `const [hasIntersected] = useHasIntersected({imageRef,loading});`\n */\nexport const useHasIntersected = ({\n elRef,\n loading = 'eager',\n}: {\n elRef: React.RefObject<HTMLElement>;\n loading?: 'eager' | 'lazy';\n}) => {\n // Initialize as true if IntersectionObserver is not supported\n // Note: We can't check elRef.current here as it may not be set yet on first render\n const [hasIntersected, setHasIntersected] = useState(() => {\n return typeof window === 'undefined' || !window.IntersectionObserver;\n });\n\n const { current } = elRef || {};\n\n const isValidReference = () => {\n return elRef && current;\n };\n\n const handleOnIntersect: IntersectionObserverCallback = (entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n setHasIntersected(true);\n\n if (current) {\n observer.unobserve(current);\n }\n }\n });\n };\n\n useEffect(() => {\n let observer: IntersectionObserver | undefined;\n let didCancel = false;\n\n // Check if window is defined for SSR and Old browsers fallback\n if (\n typeof window !== 'undefined' &&\n window.IntersectionObserver &&\n isValidReference() &&\n current &&\n !didCancel\n ) {\n observer = new IntersectionObserver(handleOnIntersect, ObserverParams);\n observer.observe(current);\n }\n return () => {\n didCancel = true;\n if (observer && current) {\n observer.unobserve(current);\n }\n };\n }, [elRef]);\n\n if (loading === 'eager') {\n return [false];\n }\n\n return [hasIntersected];\n};\n"],"names":["ObserverParams","threshold","useHasIntersected","elRef","loading","hasIntersected","setHasIntersected","useState","window","IntersectionObserver","current","isValidReference","handleOnIntersect","entries","observer","forEach","entry","isIntersecting","unobserve","useEffect","didCancel","observe"],"mappings":";;AAEA,MAAMA,cAAc,GAA6B;AAC/CC,EAAAA,SAAS,EAAE;CACZ;AAED;;;;;;;;;;AAUG;AACI,MAAMC,iBAAiB,GAAGA,CAAC;EAChCC,KAAK;AACLC,EAAAA,OAAO,GAAG;AAAO,CAIlB,KAAI;AACH;AACA;EACA,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGC,QAAQ,CAAC,MAAK;IACxD,OAAO,OAAOC,MAAM,KAAK,WAAW,IAAI,CAACA,MAAM,CAACC,oBAAoB;AACtE,EAAA,CAAC,CAAC;EAEF,MAAM;AAAEC,IAAAA;AAAO,GAAE,GAAGP,KAAK,IAAI,EAAE;EAE/B,MAAMQ,gBAAgB,GAAGA,MAAK;IAC5B,OAAOR,KAAK,IAAIO,OAAO;EACzB,CAAC;AAED,EAAA,MAAME,iBAAiB,GAAiCA,CAACC,OAAO,EAAEC,QAAQ,KAAI;AAC5ED,IAAAA,OAAO,CAACE,OAAO,CAAEC,KAAK,IAAI;MACxB,IAAIA,KAAK,CAACC,cAAc,EAAE;QACxBX,iBAAiB,CAAC,IAAI,CAAC;AAEvB,QAAA,IAAII,OAAO,EAAE;AACXI,UAAAA,QAAQ,CAACI,SAAS,CAACR,OAAO,CAAC;AAC7B,QAAA;AACF,MAAA;AACF,IAAA,CAAC,CAAC;EACJ,CAAC;AAEDS,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,IAAIL,QAA0C;IAC9C,IAAIM,SAAS,GAAG,KAAK;AAErB;AACA,IAAA,IACE,OAAOZ,MAAM,KAAK,WAAW,IAC7BA,MAAM,CAACC,oBAAoB,IAC3BE,gBAAgB,EAAE,IAClBD,OAAO,IACP,CAACU,SAAS,EACV;AACAN,MAAAA,QAAQ,GAAG,IAAIL,oBAAoB,CAACG,iBAAiB,EAAEZ,cAAc,CAAC;AACtEc,MAAAA,QAAQ,CAACO,OAAO,CAACX,OAAO,CAAC;AAC3B,IAAA;AACA,IAAA,OAAO,MAAK;AACVU,MAAAA,SAAS,GAAG,IAAI;MAChB,IAAIN,QAAQ,IAAIJ,OAAO,EAAE;AACvBI,QAAAA,QAAQ,CAACI,SAAS,CAACR,OAAO,CAAC;AAC7B,MAAA;IACF,CAAC;AACH,EAAA,CAAC,EAAE,CAACP,KAAK,CAAC,CAAC;EAEX,IAAIC,OAAO,KAAK,OAAO,EAAE;IACvB,OAAO,CAAC,KAAK,CAAC;AAChB,EAAA;EAEA,OAAO,CAACC,cAAc,CAAC;AACzB;;;;"}
|
|
@@ -52,10 +52,13 @@ const LiveRegion = ({
|
|
|
52
52
|
const [shouldAnnounce, setShouldAnnounce] = React.useState(false);
|
|
53
53
|
const announcementTrigger = announceOnChange ?? (typeof children === 'string' || typeof children === 'number' ? children : undefined);
|
|
54
54
|
React.useEffect(() => {
|
|
55
|
-
setShouldAnnounce(false);
|
|
56
55
|
if (ariaLive === 'off') {
|
|
57
56
|
return;
|
|
58
57
|
}
|
|
58
|
+
// Reset announcement state, then schedule new announcement
|
|
59
|
+
// This two-step process ensures screen readers re-announce the content
|
|
60
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- Deliberately resetting state to force re-announcement for screen readers
|
|
61
|
+
setShouldAnnounce(false);
|
|
59
62
|
const timeoutId = window.setTimeout(() => setShouldAnnounce(true), scheduleAnnouncement(ariaLive));
|
|
60
63
|
return () => window.clearTimeout(timeoutId);
|
|
61
64
|
}, [ariaLive, announcementTrigger]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveRegion.js","sources":["../../../src/common/liveRegion/LiveRegion.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport type { HTMLAttributes, ReactNode } from 'react';\n\nimport { WDS_LIVE_REGION_DELAY_MS } from '../constants';\n\nexport type AriaLive = 'off' | 'polite' | 'assertive';\n\ntype LivePoliteness = Exclude<AriaLive, 'off'>;\n\nconst LIVE_REGION_ROLE_BY_POLITENESS: Record<LivePoliteness, 'status' | 'alert'> = {\n assertive: 'alert',\n polite: 'status',\n};\n\nlet nextPoliteAnnouncementAt = 0;\nlet nextAssertiveAnnouncementAt = 0;\n\nconst getNextAnnouncementAt = (politeness: LivePoliteness): number => {\n if (politeness === 'polite') {\n return nextPoliteAnnouncementAt;\n }\n\n return nextAssertiveAnnouncementAt;\n};\n\nconst setNextAnnouncementAt = (politeness: LivePoliteness, value: number): void => {\n if (politeness === 'polite') {\n nextPoliteAnnouncementAt = value;\n return;\n }\n\n nextAssertiveAnnouncementAt = value;\n};\n\nexport const resetLiveRegionAnnouncementQueue = (): void => {\n nextPoliteAnnouncementAt = 0;\n nextAssertiveAnnouncementAt = 0;\n};\n\nconst calcAnnouncementDelayMs = (politeness: LivePoliteness, now: number): number => {\n return Math.max(now + WDS_LIVE_REGION_DELAY_MS, getNextAnnouncementAt(politeness)) - now;\n};\n\nconst scheduleAnnouncement = (politeness: LivePoliteness): number => {\n const now = Date.now();\n const delayMs = calcAnnouncementDelayMs(politeness, now);\n setNextAnnouncementAt(politeness, now + delayMs + WDS_LIVE_REGION_DELAY_MS);\n return delayMs;\n};\n\nexport interface LiveRegionProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'role' | 'aria-live' | 'aria-atomic'\n> {\n /**\n * Determines urgency: 'assertive' interrupts, 'polite' waits for idle, 'off' disables live region.\n */\n 'aria-live': AriaLive;\n /** Optional stable key that triggers a new announcement when it changes. */\n announceOnChange?: string | number;\n /** Test ID for testing tools */\n 'data-testid'?: string;\n children?: ReactNode;\n}\n\n/**\n * Renders an ARIA live region with the correct implicit role.\n *\n * - `aria-live=\"polite\"` → `role=\"status\"`\n * - `aria-live=\"assertive\"` → `role=\"alert\"`\n * - `aria-live=\"off\"` → no live region (renders children unwrapped)\n *\n * The `role` prop is intentionally excluded from the public API\n * to prevent mismatches between `aria-live` and `role`.\n */\nexport const LiveRegion = ({\n 'aria-live': ariaLive,\n announceOnChange,\n children,\n className,\n ...props\n}: LiveRegionProps) => {\n const [shouldAnnounce, setShouldAnnounce] = useState(false);\n const announcementTrigger =\n announceOnChange ??\n (typeof children === 'string' || typeof children === 'number' ? children : undefined);\n\n useEffect(() => {\n
|
|
1
|
+
{"version":3,"file":"LiveRegion.js","sources":["../../../src/common/liveRegion/LiveRegion.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport type { HTMLAttributes, ReactNode } from 'react';\n\nimport { WDS_LIVE_REGION_DELAY_MS } from '../constants';\n\nexport type AriaLive = 'off' | 'polite' | 'assertive';\n\ntype LivePoliteness = Exclude<AriaLive, 'off'>;\n\nconst LIVE_REGION_ROLE_BY_POLITENESS: Record<LivePoliteness, 'status' | 'alert'> = {\n assertive: 'alert',\n polite: 'status',\n};\n\nlet nextPoliteAnnouncementAt = 0;\nlet nextAssertiveAnnouncementAt = 0;\n\nconst getNextAnnouncementAt = (politeness: LivePoliteness): number => {\n if (politeness === 'polite') {\n return nextPoliteAnnouncementAt;\n }\n\n return nextAssertiveAnnouncementAt;\n};\n\nconst setNextAnnouncementAt = (politeness: LivePoliteness, value: number): void => {\n if (politeness === 'polite') {\n nextPoliteAnnouncementAt = value;\n return;\n }\n\n nextAssertiveAnnouncementAt = value;\n};\n\nexport const resetLiveRegionAnnouncementQueue = (): void => {\n nextPoliteAnnouncementAt = 0;\n nextAssertiveAnnouncementAt = 0;\n};\n\nconst calcAnnouncementDelayMs = (politeness: LivePoliteness, now: number): number => {\n return Math.max(now + WDS_LIVE_REGION_DELAY_MS, getNextAnnouncementAt(politeness)) - now;\n};\n\nconst scheduleAnnouncement = (politeness: LivePoliteness): number => {\n const now = Date.now();\n const delayMs = calcAnnouncementDelayMs(politeness, now);\n setNextAnnouncementAt(politeness, now + delayMs + WDS_LIVE_REGION_DELAY_MS);\n return delayMs;\n};\n\nexport interface LiveRegionProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'role' | 'aria-live' | 'aria-atomic'\n> {\n /**\n * Determines urgency: 'assertive' interrupts, 'polite' waits for idle, 'off' disables live region.\n */\n 'aria-live': AriaLive;\n /** Optional stable key that triggers a new announcement when it changes. */\n announceOnChange?: string | number;\n /** Test ID for testing tools */\n 'data-testid'?: string;\n children?: ReactNode;\n}\n\n/**\n * Renders an ARIA live region with the correct implicit role.\n *\n * - `aria-live=\"polite\"` → `role=\"status\"`\n * - `aria-live=\"assertive\"` → `role=\"alert\"`\n * - `aria-live=\"off\"` → no live region (renders children unwrapped)\n *\n * The `role` prop is intentionally excluded from the public API\n * to prevent mismatches between `aria-live` and `role`.\n */\nexport const LiveRegion = ({\n 'aria-live': ariaLive,\n announceOnChange,\n children,\n className,\n ...props\n}: LiveRegionProps) => {\n const [shouldAnnounce, setShouldAnnounce] = useState(false);\n const announcementTrigger =\n announceOnChange ??\n (typeof children === 'string' || typeof children === 'number' ? children : undefined);\n\n useEffect(() => {\n if (ariaLive === 'off') {\n return;\n }\n\n // Reset announcement state, then schedule new announcement\n // This two-step process ensures screen readers re-announce the content\n // eslint-disable-next-line react-hooks/set-state-in-effect -- Deliberately resetting state to force re-announcement for screen readers\n setShouldAnnounce(false);\n\n const timeoutId = window.setTimeout(\n () => setShouldAnnounce(true),\n scheduleAnnouncement(ariaLive),\n );\n\n return () => window.clearTimeout(timeoutId);\n }, [ariaLive, announcementTrigger]);\n\n if (ariaLive === 'off') {\n return <>{children}</>;\n }\n\n return (\n <div\n role={LIVE_REGION_ROLE_BY_POLITENESS[ariaLive]}\n aria-live={ariaLive}\n aria-atomic=\"true\"\n className={`wds-LiveRegion ${className ?? ''}`}\n {...props}\n >\n <div aria-hidden={shouldAnnounce ? undefined : 'true'}>{children}</div>\n </div>\n );\n};\n"],"names":["LIVE_REGION_ROLE_BY_POLITENESS","assertive","polite","nextPoliteAnnouncementAt","nextAssertiveAnnouncementAt","getNextAnnouncementAt","politeness","setNextAnnouncementAt","value","calcAnnouncementDelayMs","now","Math","max","WDS_LIVE_REGION_DELAY_MS","scheduleAnnouncement","Date","delayMs","LiveRegion","ariaLive","announceOnChange","children","className","props","shouldAnnounce","setShouldAnnounce","useState","announcementTrigger","undefined","useEffect","timeoutId","window","setTimeout","clearTimeout","_jsx","_Fragment","role"],"mappings":";;;;;;AASA,MAAMA,8BAA8B,GAA+C;AACjFC,EAAAA,SAAS,EAAE,OAAO;AAClBC,EAAAA,MAAM,EAAE;CACT;AAED,IAAIC,wBAAwB,GAAG,CAAC;AAChC,IAAIC,2BAA2B,GAAG,CAAC;AAEnC,MAAMC,qBAAqB,GAAIC,UAA0B,IAAY;EACnE,IAAIA,UAAU,KAAK,QAAQ,EAAE;AAC3B,IAAA,OAAOH,wBAAwB;AACjC,EAAA;AAEA,EAAA,OAAOC,2BAA2B;AACpC,CAAC;AAED,MAAMG,qBAAqB,GAAGA,CAACD,UAA0B,EAAEE,KAAa,KAAU;EAChF,IAAIF,UAAU,KAAK,QAAQ,EAAE;AAC3BH,IAAAA,wBAAwB,GAAGK,KAAK;AAChC,IAAA;AACF,EAAA;AAEAJ,EAAAA,2BAA2B,GAAGI,KAAK;AACrC,CAAC;AAOD,MAAMC,uBAAuB,GAAGA,CAACH,UAA0B,EAAEI,GAAW,KAAY;AAClF,EAAA,OAAOC,IAAI,CAACC,GAAG,CAACF,GAAG,GAAGG,kCAAwB,EAAER,qBAAqB,CAACC,UAAU,CAAC,CAAC,GAAGI,GAAG;AAC1F,CAAC;AAED,MAAMI,oBAAoB,GAAIR,UAA0B,IAAY;AAClE,EAAA,MAAMI,GAAG,GAAGK,IAAI,CAACL,GAAG,EAAE;AACtB,EAAA,MAAMM,OAAO,GAAGP,uBAAuB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,IAAAA,SAAS,EAAE,CAAA,eAAA,EAAkBA,SAAS,IAAI,EAAE,CAAA,CAAG;AAAA,IAAA,GAC3CC,KAAK;AAAAF,IAAAA,QAAA,eAETa,cAAA,CAAA,KAAA,EAAA;AAAK,MAAA,aAAA,EAAaV,cAAc,GAAGI,SAAS,GAAG,MAAO;AAAAP,MAAAA,QAAA,EAAEA;KAAc;AACxE,GAAK,CAAC;AAEV;;;;"}
|
|
@@ -50,10 +50,13 @@ const LiveRegion = ({
|
|
|
50
50
|
const [shouldAnnounce, setShouldAnnounce] = useState(false);
|
|
51
51
|
const announcementTrigger = announceOnChange ?? (typeof children === 'string' || typeof children === 'number' ? children : undefined);
|
|
52
52
|
useEffect(() => {
|
|
53
|
-
setShouldAnnounce(false);
|
|
54
53
|
if (ariaLive === 'off') {
|
|
55
54
|
return;
|
|
56
55
|
}
|
|
56
|
+
// Reset announcement state, then schedule new announcement
|
|
57
|
+
// This two-step process ensures screen readers re-announce the content
|
|
58
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- Deliberately resetting state to force re-announcement for screen readers
|
|
59
|
+
setShouldAnnounce(false);
|
|
57
60
|
const timeoutId = window.setTimeout(() => setShouldAnnounce(true), scheduleAnnouncement(ariaLive));
|
|
58
61
|
return () => window.clearTimeout(timeoutId);
|
|
59
62
|
}, [ariaLive, announcementTrigger]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveRegion.mjs","sources":["../../../src/common/liveRegion/LiveRegion.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport type { HTMLAttributes, ReactNode } from 'react';\n\nimport { WDS_LIVE_REGION_DELAY_MS } from '../constants';\n\nexport type AriaLive = 'off' | 'polite' | 'assertive';\n\ntype LivePoliteness = Exclude<AriaLive, 'off'>;\n\nconst LIVE_REGION_ROLE_BY_POLITENESS: Record<LivePoliteness, 'status' | 'alert'> = {\n assertive: 'alert',\n polite: 'status',\n};\n\nlet nextPoliteAnnouncementAt = 0;\nlet nextAssertiveAnnouncementAt = 0;\n\nconst getNextAnnouncementAt = (politeness: LivePoliteness): number => {\n if (politeness === 'polite') {\n return nextPoliteAnnouncementAt;\n }\n\n return nextAssertiveAnnouncementAt;\n};\n\nconst setNextAnnouncementAt = (politeness: LivePoliteness, value: number): void => {\n if (politeness === 'polite') {\n nextPoliteAnnouncementAt = value;\n return;\n }\n\n nextAssertiveAnnouncementAt = value;\n};\n\nexport const resetLiveRegionAnnouncementQueue = (): void => {\n nextPoliteAnnouncementAt = 0;\n nextAssertiveAnnouncementAt = 0;\n};\n\nconst calcAnnouncementDelayMs = (politeness: LivePoliteness, now: number): number => {\n return Math.max(now + WDS_LIVE_REGION_DELAY_MS, getNextAnnouncementAt(politeness)) - now;\n};\n\nconst scheduleAnnouncement = (politeness: LivePoliteness): number => {\n const now = Date.now();\n const delayMs = calcAnnouncementDelayMs(politeness, now);\n setNextAnnouncementAt(politeness, now + delayMs + WDS_LIVE_REGION_DELAY_MS);\n return delayMs;\n};\n\nexport interface LiveRegionProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'role' | 'aria-live' | 'aria-atomic'\n> {\n /**\n * Determines urgency: 'assertive' interrupts, 'polite' waits for idle, 'off' disables live region.\n */\n 'aria-live': AriaLive;\n /** Optional stable key that triggers a new announcement when it changes. */\n announceOnChange?: string | number;\n /** Test ID for testing tools */\n 'data-testid'?: string;\n children?: ReactNode;\n}\n\n/**\n * Renders an ARIA live region with the correct implicit role.\n *\n * - `aria-live=\"polite\"` → `role=\"status\"`\n * - `aria-live=\"assertive\"` → `role=\"alert\"`\n * - `aria-live=\"off\"` → no live region (renders children unwrapped)\n *\n * The `role` prop is intentionally excluded from the public API\n * to prevent mismatches between `aria-live` and `role`.\n */\nexport const LiveRegion = ({\n 'aria-live': ariaLive,\n announceOnChange,\n children,\n className,\n ...props\n}: LiveRegionProps) => {\n const [shouldAnnounce, setShouldAnnounce] = useState(false);\n const announcementTrigger =\n announceOnChange ??\n (typeof children === 'string' || typeof children === 'number' ? children : undefined);\n\n useEffect(() => {\n
|
|
1
|
+
{"version":3,"file":"LiveRegion.mjs","sources":["../../../src/common/liveRegion/LiveRegion.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport type { HTMLAttributes, ReactNode } from 'react';\n\nimport { WDS_LIVE_REGION_DELAY_MS } from '../constants';\n\nexport type AriaLive = 'off' | 'polite' | 'assertive';\n\ntype LivePoliteness = Exclude<AriaLive, 'off'>;\n\nconst LIVE_REGION_ROLE_BY_POLITENESS: Record<LivePoliteness, 'status' | 'alert'> = {\n assertive: 'alert',\n polite: 'status',\n};\n\nlet nextPoliteAnnouncementAt = 0;\nlet nextAssertiveAnnouncementAt = 0;\n\nconst getNextAnnouncementAt = (politeness: LivePoliteness): number => {\n if (politeness === 'polite') {\n return nextPoliteAnnouncementAt;\n }\n\n return nextAssertiveAnnouncementAt;\n};\n\nconst setNextAnnouncementAt = (politeness: LivePoliteness, value: number): void => {\n if (politeness === 'polite') {\n nextPoliteAnnouncementAt = value;\n return;\n }\n\n nextAssertiveAnnouncementAt = value;\n};\n\nexport const resetLiveRegionAnnouncementQueue = (): void => {\n nextPoliteAnnouncementAt = 0;\n nextAssertiveAnnouncementAt = 0;\n};\n\nconst calcAnnouncementDelayMs = (politeness: LivePoliteness, now: number): number => {\n return Math.max(now + WDS_LIVE_REGION_DELAY_MS, getNextAnnouncementAt(politeness)) - now;\n};\n\nconst scheduleAnnouncement = (politeness: LivePoliteness): number => {\n const now = Date.now();\n const delayMs = calcAnnouncementDelayMs(politeness, now);\n setNextAnnouncementAt(politeness, now + delayMs + WDS_LIVE_REGION_DELAY_MS);\n return delayMs;\n};\n\nexport interface LiveRegionProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'role' | 'aria-live' | 'aria-atomic'\n> {\n /**\n * Determines urgency: 'assertive' interrupts, 'polite' waits for idle, 'off' disables live region.\n */\n 'aria-live': AriaLive;\n /** Optional stable key that triggers a new announcement when it changes. */\n announceOnChange?: string | number;\n /** Test ID for testing tools */\n 'data-testid'?: string;\n children?: ReactNode;\n}\n\n/**\n * Renders an ARIA live region with the correct implicit role.\n *\n * - `aria-live=\"polite\"` → `role=\"status\"`\n * - `aria-live=\"assertive\"` → `role=\"alert\"`\n * - `aria-live=\"off\"` → no live region (renders children unwrapped)\n *\n * The `role` prop is intentionally excluded from the public API\n * to prevent mismatches between `aria-live` and `role`.\n */\nexport const LiveRegion = ({\n 'aria-live': ariaLive,\n announceOnChange,\n children,\n className,\n ...props\n}: LiveRegionProps) => {\n const [shouldAnnounce, setShouldAnnounce] = useState(false);\n const announcementTrigger =\n announceOnChange ??\n (typeof children === 'string' || typeof children === 'number' ? children : undefined);\n\n useEffect(() => {\n if (ariaLive === 'off') {\n return;\n }\n\n // Reset announcement state, then schedule new announcement\n // This two-step process ensures screen readers re-announce the content\n // eslint-disable-next-line react-hooks/set-state-in-effect -- Deliberately resetting state to force re-announcement for screen readers\n setShouldAnnounce(false);\n\n const timeoutId = window.setTimeout(\n () => setShouldAnnounce(true),\n scheduleAnnouncement(ariaLive),\n );\n\n return () => window.clearTimeout(timeoutId);\n }, [ariaLive, announcementTrigger]);\n\n if (ariaLive === 'off') {\n return <>{children}</>;\n }\n\n return (\n <div\n role={LIVE_REGION_ROLE_BY_POLITENESS[ariaLive]}\n aria-live={ariaLive}\n aria-atomic=\"true\"\n className={`wds-LiveRegion ${className ?? ''}`}\n {...props}\n >\n <div aria-hidden={shouldAnnounce ? undefined : 'true'}>{children}</div>\n </div>\n );\n};\n"],"names":["LIVE_REGION_ROLE_BY_POLITENESS","assertive","polite","nextPoliteAnnouncementAt","nextAssertiveAnnouncementAt","getNextAnnouncementAt","politeness","setNextAnnouncementAt","value","calcAnnouncementDelayMs","now","Math","max","WDS_LIVE_REGION_DELAY_MS","scheduleAnnouncement","Date","delayMs","LiveRegion","ariaLive","announceOnChange","children","className","props","shouldAnnounce","setShouldAnnounce","useState","announcementTrigger","undefined","useEffect","timeoutId","window","setTimeout","clearTime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ONTH_YEAR;
|
|
118
118
|
const monthBeforeDay = getFormatForLocale.MDY.has(locale);
|
|
119
119
|
const yearFirst = getFormatForLocale.YMD.has(locale);
|
|
120
|
-
dayLabel
|
|
121
|
-
monthLabel
|
|
122
|
-
yearLabel
|
|
123
|
-
|
|
120
|
+
const resolvedDayLabel = dayLabel || formatMessage(DateInput_messages.default.dayLabel);
|
|
121
|
+
const resolvedMonthLabel = monthLabel || formatMessage(DateInput_messages.default.monthLabel);
|
|
122
|
+
const resolvedYearLabel = yearLabel || formatMessage(DateInput_messages.default.yearLabel);
|
|
123
|
+
const resolvedPlaceholders = {
|
|
124
124
|
day: placeholders?.day || formatMessage(DateInput_messages.default.dayPlaceholder),
|
|
125
125
|
month: placeholders?.month || formatMessage(DateInput_messages.default.monthLabel),
|
|
126
126
|
year: placeholders?.year || formatMessage(DateInput_messages.default.yearPlaceholder)
|
|
@@ -161,14 +161,14 @@ const DateInput = ({
|
|
|
161
161
|
className: "d-flex flex-column",
|
|
162
162
|
children: [/*#__PURE__*/jsxRuntime.jsx(Body.default, {
|
|
163
163
|
type: typography.Typography.BODY_DEFAULT,
|
|
164
|
-
children:
|
|
164
|
+
children: resolvedMonthLabel
|
|
165
165
|
}), /*#__PURE__*/jsxRuntime.jsx(SelectInput.SelectInput, {
|
|
166
166
|
triggerRef: monthRef,
|
|
167
167
|
id: `${id}:month`,
|
|
168
168
|
parentId: DATE_INPUT_PARENT_ID,
|
|
169
169
|
name: "month",
|
|
170
170
|
disabled: disabled,
|
|
171
|
-
placeholder:
|
|
171
|
+
placeholder: resolvedPlaceholders.month,
|
|
172
172
|
items: Array.from({
|
|
173
173
|
length: 12
|
|
174
174
|
}, (_, index) => ({
|
|
@@ -265,7 +265,7 @@ const DateInput = ({
|
|
|
265
265
|
children: /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
266
266
|
children: [/*#__PURE__*/jsxRuntime.jsx(Body.default, {
|
|
267
267
|
type: typography.Typography.BODY_DEFAULT,
|
|
268
|
-
children:
|
|
268
|
+
children: resolvedDayLabel
|
|
269
269
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
270
270
|
className: `input-group input-group-${size$1} ${disabled ? 'disabled' : ''}`,
|
|
271
271
|
children: /*#__PURE__*/jsxRuntime.jsx(Input.Input, {
|
|
@@ -277,7 +277,7 @@ const DateInput = ({
|
|
|
277
277
|
name: "day",
|
|
278
278
|
autoComplete: dayAutoComplete,
|
|
279
279
|
value: displayDay || '',
|
|
280
|
-
placeholder:
|
|
280
|
+
placeholder: resolvedPlaceholders.day,
|
|
281
281
|
disabled: disabled,
|
|
282
282
|
min: 1,
|
|
283
283
|
max: 31,
|
|
@@ -294,7 +294,7 @@ const DateInput = ({
|
|
|
294
294
|
children: /*#__PURE__*/jsxRuntime.jsxs("label", {
|
|
295
295
|
children: [/*#__PURE__*/jsxRuntime.jsx(Body.default, {
|
|
296
296
|
type: typography.Typography.BODY_DEFAULT,
|
|
297
|
-
children:
|
|
297
|
+
children: resolvedYearLabel
|
|
298
298
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
299
299
|
className: `input-group input-group-${size$1} ${disabled ? 'disabled' : ''}`,
|
|
300
300
|
children: /*#__PURE__*/jsxRuntime.jsx(Input.Input, {
|
|
@@ -305,7 +305,7 @@ const DateInput = ({
|
|
|
305
305
|
pattern: "[0-9]*",
|
|
306
306
|
name: "year",
|
|
307
307
|
autoComplete: yearAutoComplete,
|
|
308
|
-
placeholder:
|
|
308
|
+
placeholder: resolvedPlaceholders.year,
|
|
309
309
|
value: displayYear || '',
|
|
310
310
|
disabled: disabled,
|
|
311
311
|
min: 0,
|
|
@@ -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;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;AAA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C,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 const resolvedDayLabel = dayLabel || formatMessage(messages.dayLabel);\n const resolvedMonthLabel = monthLabel || formatMessage(messages.monthLabel);\n const resolvedYearLabel = yearLabel || formatMessage(messages.yearLabel);\n const resolvedPlaceholders = {\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}>{resolvedMonthLabel}</Body>\n <SelectInput\n triggerRef={monthRef}\n id={`${id}:month`}\n parentId={DATE_INPUT_PARENT_ID}\n name=\"month\"\n disabled={disabled}\n placeholder={resolvedPlaceholders.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}>{resolvedDayLabel}</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={resolvedPlaceholders.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}>{resolvedYearLabel}</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={resolvedPlaceholders.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","resolvedDayLabel","messages","resolvedMonthLabel","resolvedYearLabel","resolvedPlaceholders","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;AACV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MAAA,CAAC;KACE;AACP,GAAU,CAAC;AAEf;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,EAAqB/J,oBAAoB,IAAI,CAAC,IAC/D,CAAC6J,aAAa,EAAEE,OAAO,CAAC,CAAA,kBAAA,EAAqB/J,oBAAoB,CAAA,EAAA,CAAI,CAAC;AAE1E;;;;"}
|
|
@@ -113,10 +113,10 @@ const DateInput = ({
|
|
|
113
113
|
const monthYearOnly = mode === DateMode.MONTH_YEAR;
|
|
114
114
|
const monthBeforeDay = MDY.has(locale);
|
|
115
115
|
const yearFirst = YMD.has(locale);
|
|
116
|
-
dayLabel
|
|
117
|
-
monthLabel
|
|
118
|
-
yearLabel
|
|
119
|
-
|
|
116
|
+
const resolvedDayLabel = dayLabel || formatMessage(messages.dayLabel);
|
|
117
|
+
const resolvedMonthLabel = monthLabel || formatMessage(messages.monthLabel);
|
|
118
|
+
const resolvedYearLabel = yearLabel || formatMessage(messages.yearLabel);
|
|
119
|
+
const resolvedPlaceholders = {
|
|
120
120
|
day: placeholders?.day || formatMessage(messages.dayPlaceholder),
|
|
121
121
|
month: placeholders?.month || formatMessage(messages.monthLabel),
|
|
122
122
|
year: placeholders?.year || formatMessage(messages.yearPlaceholder)
|
|
@@ -157,14 +157,14 @@ const DateInput = ({
|
|
|
157
157
|
className: "d-flex flex-column",
|
|
158
158
|
children: [/*#__PURE__*/jsx(Body, {
|
|
159
159
|
type: Typography.BODY_DEFAULT,
|
|
160
|
-
children:
|
|
160
|
+
children: resolvedMonthLabel
|
|
161
161
|
}), /*#__PURE__*/jsx(SelectInput, {
|
|
162
162
|
triggerRef: monthRef,
|
|
163
163
|
id: `${id}:month`,
|
|
164
164
|
parentId: DATE_INPUT_PARENT_ID,
|
|
165
165
|
name: "month",
|
|
166
166
|
disabled: disabled,
|
|
167
|
-
placeholder:
|
|
167
|
+
placeholder: resolvedPlaceholders.month,
|
|
168
168
|
items: Array.from({
|
|
169
169
|
length: 12
|
|
170
170
|
}, (_, index) => ({
|
|
@@ -261,7 +261,7 @@ const DateInput = ({
|
|
|
261
261
|
children: /*#__PURE__*/jsxs("label", {
|
|
262
262
|
children: [/*#__PURE__*/jsx(Body, {
|
|
263
263
|
type: Typography.BODY_DEFAULT,
|
|
264
|
-
children:
|
|
264
|
+
children: resolvedDayLabel
|
|
265
265
|
}), /*#__PURE__*/jsx("div", {
|
|
266
266
|
className: `input-group input-group-${size} ${disabled ? 'disabled' : ''}`,
|
|
267
267
|
children: /*#__PURE__*/jsx(Input, {
|
|
@@ -273,7 +273,7 @@ const DateInput = ({
|
|
|
273
273
|
name: "day",
|
|
274
274
|
autoComplete: dayAutoComplete,
|
|
275
275
|
value: displayDay || '',
|
|
276
|
-
placeholder:
|
|
276
|
+
placeholder: resolvedPlaceholders.day,
|
|
277
277
|
disabled: disabled,
|
|
278
278
|
min: 1,
|
|
279
279
|
max: 31,
|
|
@@ -290,7 +290,7 @@ const DateInput = ({
|
|
|
290
290
|
children: /*#__PURE__*/jsxs("label", {
|
|
291
291
|
children: [/*#__PURE__*/jsx(Body, {
|
|
292
292
|
type: Typography.BODY_DEFAULT,
|
|
293
|
-
children:
|
|
293
|
+
children: resolvedYearLabel
|
|
294
294
|
}), /*#__PURE__*/jsx("div", {
|
|
295
295
|
className: `input-group input-group-${size} ${disabled ? 'disabled' : ''}`,
|
|
296
296
|
children: /*#__PURE__*/jsx(Input, {
|
|
@@ -301,7 +301,7 @@ const DateInput = ({
|
|
|
301
301
|
pattern: "[0-9]*",
|
|
302
302
|
name: "year",
|
|
303
303
|
autoComplete: yearAutoComplete,
|
|
304
|
-
placeholder:
|
|
304
|
+
placeholder: resolvedPlaceholders.year,
|
|
305
305
|
value: displayYear || '',
|
|
306
306
|
disabled: disabled,
|
|
307
307
|
min: 0,
|