@flipdish/ui-library 0.72.0 → 0.73.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/dist/components/atoms/Avatar/components/AvatarBase.cjs +3 -1
- package/dist/components/atoms/Avatar/components/AvatarBase.cjs.map +1 -1
- package/dist/components/atoms/Avatar/components/AvatarBase.d.ts.map +1 -1
- package/dist/components/atoms/Avatar/components/AvatarBase.js +3 -1
- package/dist/components/atoms/Avatar/components/AvatarBase.js.map +1 -1
- package/dist/components/atoms/Badges/Badge/Badge.cjs +5 -2
- package/dist/components/atoms/Badges/Badge/Badge.cjs.map +1 -1
- package/dist/components/atoms/Badges/Badge/Badge.d.ts +4 -0
- package/dist/components/atoms/Badges/Badge/Badge.d.ts.map +1 -1
- package/dist/components/atoms/Badges/Badge/Badge.js +5 -2
- package/dist/components/atoms/Badges/Badge/Badge.js.map +1 -1
- package/dist/components/atoms/Inputs/Input/Input.cjs +1 -1
- package/dist/components/atoms/Inputs/Input/Input.cjs.map +1 -1
- package/dist/components/atoms/Inputs/Input/Input.js +1 -1
- package/dist/components/atoms/Inputs/Input/Input.js.map +1 -1
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.cjs +1 -1
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.cjs.map +1 -1
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.js +1 -1
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.js.map +1 -1
- package/dist/components/atoms/PhoneInput/index.cjs +1 -1
- package/dist/components/atoms/PhoneInput/index.cjs.map +1 -1
- package/dist/components/atoms/PhoneInput/index.js +1 -1
- package/dist/components/atoms/PhoneInput/index.js.map +1 -1
- package/dist/components/molecules/DetailList/detailList.types.d.ts +2 -0
- package/dist/components/molecules/DetailList/detailList.types.d.ts.map +1 -1
- package/dist/components/molecules/DetailList/index.cjs +10 -1
- package/dist/components/molecules/DetailList/index.cjs.map +1 -1
- package/dist/components/molecules/DetailList/index.d.ts.map +1 -1
- package/dist/components/molecules/DetailList/index.js +10 -1
- package/dist/components/molecules/DetailList/index.js.map +1 -1
- package/dist/components/molecules/DetailList/utilities/detailList.utils.cjs +17 -0
- package/dist/components/molecules/DetailList/utilities/detailList.utils.cjs.map +1 -0
- package/dist/components/molecules/DetailList/utilities/detailList.utils.d.ts +10 -0
- package/dist/components/molecules/DetailList/utilities/detailList.utils.d.ts.map +1 -0
- package/dist/components/molecules/DetailList/utilities/detailList.utils.js +15 -0
- package/dist/components/molecules/DetailList/utilities/detailList.utils.js.map +1 -0
- package/dist/components/molecules/EmptyState/index.cjs +8 -165
- package/dist/components/molecules/EmptyState/index.cjs.map +1 -1
- package/dist/components/molecules/EmptyState/index.d.ts +33 -105
- package/dist/components/molecules/EmptyState/index.d.ts.map +1 -1
- package/dist/components/molecules/EmptyState/index.js +8 -165
- package/dist/components/molecules/EmptyState/index.js.map +1 -1
- package/dist/components/molecules/EmptyStates/EmptyState/EmptyState.cjs +168 -0
- package/dist/components/molecules/EmptyStates/EmptyState/EmptyState.cjs.map +1 -0
- package/dist/components/molecules/EmptyStates/EmptyState/EmptyState.d.ts +98 -0
- package/dist/components/molecules/EmptyStates/EmptyState/EmptyState.d.ts.map +1 -0
- package/dist/components/molecules/EmptyStates/EmptyState/EmptyState.js +166 -0
- package/dist/components/molecules/EmptyStates/EmptyState/EmptyState.js.map +1 -0
- package/dist/components/molecules/EmptyStates/EmptyState/utilities/emptyState.utils.cjs.map +1 -0
- package/dist/components/molecules/EmptyStates/EmptyState/utilities/emptyState.utils.d.ts.map +1 -0
- package/dist/components/molecules/EmptyStates/EmptyState/utilities/emptyState.utils.js.map +1 -0
- package/dist/components/molecules/EmptyStates/LoadErrorState/LoadErrorState.cjs +22 -0
- package/dist/components/molecules/EmptyStates/LoadErrorState/LoadErrorState.cjs.map +1 -0
- package/dist/components/molecules/EmptyStates/LoadErrorState/LoadErrorState.d.ts +25 -0
- package/dist/components/molecules/EmptyStates/LoadErrorState/LoadErrorState.d.ts.map +1 -0
- package/dist/components/molecules/EmptyStates/LoadErrorState/LoadErrorState.js +20 -0
- package/dist/components/molecules/EmptyStates/LoadErrorState/LoadErrorState.js.map +1 -0
- package/dist/components/molecules/EmptyStates/NoResultsState/NoResultsState.cjs +22 -0
- package/dist/components/molecules/EmptyStates/NoResultsState/NoResultsState.cjs.map +1 -0
- package/dist/components/molecules/EmptyStates/NoResultsState/NoResultsState.d.ts +23 -0
- package/dist/components/molecules/EmptyStates/NoResultsState/NoResultsState.d.ts.map +1 -0
- package/dist/components/molecules/EmptyStates/NoResultsState/NoResultsState.js +20 -0
- package/dist/components/molecules/EmptyStates/NoResultsState/NoResultsState.js.map +1 -0
- package/dist/components/molecules/EmptyStates/PastLastPageState/PastLastPageState.cjs +24 -0
- package/dist/components/molecules/EmptyStates/PastLastPageState/PastLastPageState.cjs.map +1 -0
- package/dist/components/molecules/EmptyStates/PastLastPageState/PastLastPageState.d.ts +28 -0
- package/dist/components/molecules/EmptyStates/PastLastPageState/PastLastPageState.d.ts.map +1 -0
- package/dist/components/molecules/EmptyStates/PastLastPageState/PastLastPageState.js +22 -0
- package/dist/components/molecules/EmptyStates/PastLastPageState/PastLastPageState.js.map +1 -0
- package/dist/components/molecules/EmptyStates/components/EmptyStateReadyMade.cjs +12 -0
- package/dist/components/molecules/EmptyStates/components/EmptyStateReadyMade.cjs.map +1 -0
- package/dist/components/molecules/EmptyStates/components/EmptyStateReadyMade.d.ts +20 -0
- package/dist/components/molecules/EmptyStates/components/EmptyStateReadyMade.d.ts.map +1 -0
- package/dist/components/molecules/EmptyStates/components/EmptyStateReadyMade.js +10 -0
- package/dist/components/molecules/EmptyStates/components/EmptyStateReadyMade.js.map +1 -0
- package/dist/components/molecules/EmptyStates/index.cjs +14 -0
- package/dist/components/molecules/EmptyStates/index.cjs.map +1 -0
- package/dist/components/molecules/EmptyStates/index.d.ts +19 -0
- package/dist/components/molecules/EmptyStates/index.d.ts.map +1 -0
- package/dist/components/molecules/EmptyStates/index.js +5 -0
- package/dist/components/molecules/EmptyStates/index.js.map +1 -0
- package/dist/components/molecules/EmptyStates/utilities/emptyStates.utils.cjs +12 -0
- package/dist/components/molecules/EmptyStates/utilities/emptyStates.utils.cjs.map +1 -0
- package/dist/components/molecules/EmptyStates/utilities/emptyStates.utils.d.ts +8 -0
- package/dist/components/molecules/EmptyStates/utilities/emptyStates.utils.d.ts.map +1 -0
- package/dist/components/molecules/EmptyStates/utilities/emptyStates.utils.js +10 -0
- package/dist/components/molecules/EmptyStates/utilities/emptyStates.utils.js.map +1 -0
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.js +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/molecules/Tabs/index.cjs +31 -9
- package/dist/components/molecules/Tabs/index.cjs.map +1 -1
- package/dist/components/molecules/Tabs/index.d.ts +10 -6
- package/dist/components/molecules/Tabs/index.d.ts.map +1 -1
- package/dist/components/molecules/Tabs/index.js +33 -11
- package/dist/components/molecules/Tabs/index.js.map +1 -1
- package/dist/components/molecules/Tabs/utilities/tabs.utils.cjs +40 -0
- package/dist/components/molecules/Tabs/utilities/tabs.utils.cjs.map +1 -0
- package/dist/components/molecules/Tabs/utilities/tabs.utils.d.ts +23 -0
- package/dist/components/molecules/Tabs/utilities/tabs.utils.d.ts.map +1 -0
- package/dist/components/molecules/Tabs/utilities/tabs.utils.js +37 -0
- package/dist/components/molecules/Tabs/utilities/tabs.utils.js.map +1 -0
- package/dist/components/organisms/CommandMenu/components/CommandInput.cjs +1 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.js +1 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.js.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.cjs +4 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.js +6 -3
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs +32 -11
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.d.ts +5 -5
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js +35 -14
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.cjs +14 -3
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.d.ts +3 -8
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.js +14 -3
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.js.map +1 -1
- package/dist/components/organisms/DatePickers/datePickers.types.d.ts +17 -0
- package/dist/components/organisms/DatePickers/datePickers.types.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/hooks/useDateRangePresets.cjs +23 -0
- package/dist/components/organisms/DatePickers/hooks/useDateRangePresets.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/hooks/useDateRangePresets.d.ts +11 -0
- package/dist/components/organisms/DatePickers/hooks/useDateRangePresets.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/hooks/useDateRangePresets.js +21 -0
- package/dist/components/organisms/DatePickers/hooks/useDateRangePresets.js.map +1 -0
- package/dist/components/organisms/DatePickers/hooks/useToday.cjs +18 -0
- package/dist/components/organisms/DatePickers/hooks/useToday.cjs.map +1 -0
- package/dist/components/organisms/DatePickers/hooks/useToday.d.ts +9 -0
- package/dist/components/organisms/DatePickers/hooks/useToday.d.ts.map +1 -0
- package/dist/components/organisms/DatePickers/hooks/useToday.js +16 -0
- package/dist/components/organisms/DatePickers/hooks/useToday.js.map +1 -0
- package/dist/components/organisms/DatePickers/index.d.ts +1 -0
- package/dist/components/organisms/DatePickers/index.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/providers/CalendarSurface.context.cjs +1 -1
- package/dist/components/organisms/DatePickers/providers/CalendarSurface.context.d.ts +1 -1
- package/dist/components/organisms/DatePickers/providers/CalendarSurface.context.js +1 -1
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.cjs +84 -23
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.d.ts +70 -5
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.js +82 -24
- package/dist/components/organisms/DatePickers/utilities/dateRangePresets.utils.js.map +1 -1
- package/dist/components/organisms/HeaderNavigation/index.cjs +1 -1
- package/dist/components/organisms/HeaderNavigation/index.cjs.map +1 -1
- package/dist/components/organisms/HeaderNavigation/index.js +1 -1
- package/dist/components/organisms/HeaderNavigation/index.js.map +1 -1
- package/dist/hooks/useClipboard/clipboard.utils.cjs +33 -0
- package/dist/hooks/useClipboard/clipboard.utils.cjs.map +1 -0
- package/dist/hooks/useClipboard/clipboard.utils.d.ts +15 -0
- package/dist/hooks/useClipboard/clipboard.utils.d.ts.map +1 -0
- package/dist/hooks/useClipboard/clipboard.utils.js +31 -0
- package/dist/hooks/useClipboard/clipboard.utils.js.map +1 -0
- package/dist/hooks/useClipboard/index.cjs +17 -42
- package/dist/hooks/useClipboard/index.cjs.map +1 -1
- package/dist/hooks/useClipboard/index.d.ts.map +1 -1
- package/dist/hooks/useClipboard/index.js +17 -42
- package/dist/hooks/useClipboard/index.js.map +1 -1
- package/dist/native/components/atoms/Badges/Badge/Badge.d.ts +5 -1
- package/dist/native/components/atoms/Badges/Badge/Badge.d.ts.map +1 -1
- package/dist/native/components/atoms/Badges/Badge/Badge.js +5 -2
- package/dist/native/components/atoms/Badges/Badge/Badge.js.map +1 -1
- package/dist/native/components/molecules/EmptyStates/index.d.ts +12 -0
- package/dist/utilities/searchParamsUtils/index.cjs +40 -2
- package/dist/utilities/searchParamsUtils/index.cjs.map +1 -1
- package/dist/utilities/searchParamsUtils/index.d.ts +40 -2
- package/dist/utilities/searchParamsUtils/index.d.ts.map +1 -1
- package/dist/utilities/searchParamsUtils/index.js +39 -3
- package/dist/utilities/searchParamsUtils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.cjs.map +0 -1
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.d.ts.map +0 -1
- package/dist/components/molecules/EmptyState/utilities/emptyState.utils.js.map +0 -1
- /package/dist/components/molecules/{EmptyState → EmptyStates/EmptyState}/utilities/emptyState.utils.cjs +0 -0
- /package/dist/components/molecules/{EmptyState → EmptyStates/EmptyState}/utilities/emptyState.utils.d.ts +0 -0
- /package/dist/components/molecules/{EmptyState → EmptyStates/EmptyState}/utilities/emptyState.utils.js +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How far a horizontal scroller must move to bring an item it cuts off, or hides, to the middle of its view, so the
|
|
3
|
+
* neighbours on both sides show there is more to scroll to.
|
|
4
|
+
*
|
|
5
|
+
* @param view - The scroller's visible stretch, inside its padding.
|
|
6
|
+
* @param item - The item's stretch, measured at the same moment.
|
|
7
|
+
* @returns Pixels to scroll by: negative moves the view left, positive right, `0` when the whole item is already in view.
|
|
8
|
+
* The scroller stops at its ends, so an item near one stays short of the middle.
|
|
9
|
+
*/
|
|
10
|
+
const getRevealOffset = (view, item) => {
|
|
11
|
+
if (item.left >= view.left && item.right <= view.right)
|
|
12
|
+
return 0;
|
|
13
|
+
return (item.left + item.right - view.left - view.right) / 2;
|
|
14
|
+
};
|
|
15
|
+
const toPixels = (value) => Number.parseFloat(value) || 0;
|
|
16
|
+
/**
|
|
17
|
+
* Scrolls a horizontal tab list sideways, instantly, to bring a selected tab it cuts off or hides to the middle of its view.
|
|
18
|
+
* Only the list moves: unlike `scrollIntoView`, the page never scrolls, and focus stays where it is.
|
|
19
|
+
*
|
|
20
|
+
* @param list - The `role="tablist"` element, which scrolls its own tabs; one without a selected tab is left where it is.
|
|
21
|
+
*/
|
|
22
|
+
const revealSelectedTab = (list) => {
|
|
23
|
+
const tab = list.querySelector('[role="tab"][aria-selected="true"]');
|
|
24
|
+
if (!tab)
|
|
25
|
+
return;
|
|
26
|
+
const box = list.getBoundingClientRect();
|
|
27
|
+
const { paddingLeft, paddingRight } = getComputedStyle(list);
|
|
28
|
+
const left = box.left + list.clientLeft;
|
|
29
|
+
const view = { left: left + toPixels(paddingLeft), right: left + list.clientWidth - toPixels(paddingRight) };
|
|
30
|
+
const offset = getRevealOffset(view, tab.getBoundingClientRect());
|
|
31
|
+
// Instant, as `scroll-behavior: smooth` on a parent would otherwise animate a list that should open already in place.
|
|
32
|
+
if (offset !== 0)
|
|
33
|
+
list.scrollBy({ left: offset, behavior: 'instant' });
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { getRevealOffset, revealSelectedTab };
|
|
37
|
+
//# sourceMappingURL=tabs.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.utils.js","sources":["../../../../../src/components/molecules/Tabs/utilities/tabs.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AAMA;;;;;;;;AAQG;MACU,eAAe,GAAG,CAAC,IAAoB,EAAE,IAAoB,KAAY;AACpF,IAAA,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK;AAAE,QAAA,OAAO,CAAC;AAChE,IAAA,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC;AAC9D;AAEA,MAAM,QAAQ,GAAG,CAAC,KAAa,KAAa,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;AAEzE;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,IAAiB,KAAU;IAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,oCAAoC,CAAC;AACpE,IAAA,IAAI,CAAC,GAAG;QAAE;AACV,IAAA,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,EAAE;IACxC,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC;IAC5D,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU;IACvC,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC,EAAE;IAC5G,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,qBAAqB,EAAE,CAAC;;IAEjE,IAAI,MAAM,KAAK,CAAC;AAAE,QAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACxE;;"}
|
|
@@ -11,7 +11,7 @@ var CommandShortcut = require('./CommandShortcut.cjs');
|
|
|
11
11
|
|
|
12
12
|
const CommandInput = React.forwardRef(({ placeholder, shortcutHint, tooltip, className, ...props }, ref) => {
|
|
13
13
|
const overlayState = React.useContext(reactAriaComponents.OverlayTriggerStateContext);
|
|
14
|
-
return (jsxRuntime.jsxs(reactAriaComponents.Group, { className: ({ isFocusWithin }) => cx.cx('flex items-center gap-x-2 rounded-xl bg-primary p-4', isFocusWithin && 'outline-2 outline-focus-ring', className), children: [jsxRuntime.jsx("div", { className: "pointer-events-none absolute", children: jsxRuntime.jsx(uiIcons.SearchLg, { className: "size-5 text-fg-quaternary" }) }), jsxRuntime.jsx(reactAriaComponents.Input, { placeholder: placeholder, className: "m-0 w-full bg-transparent pl-7 text-md text-primary ring-0 outline-hidden placeholder:text-placeholder autofill:rounded-lg autofill:text-primary", ...props, ref: ref }), tooltip && (jsxRuntime.jsx(Tooltip.Tooltip, { title: tooltip, placement: "top", children: jsxRuntime.jsx(Tooltip.TooltipTrigger, { className: "cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover", children: jsxRuntime.jsx(uiIcons.HelpCircle, { className: "size-4 stroke-[2.25px]" }) }) })), shortcutHint && jsxRuntime.jsx(CommandShortcut.CommandShortcut, { keys: [shortcutHint], className: "max-md:hidden" }), overlayState && jsxRuntime.jsx(Buttons.CloseButton, { size: "sm", label: "Close command menu", onPress: overlayState.close, className: "-my-1.5 -mr-2 md:hidden" })] }));
|
|
14
|
+
return (jsxRuntime.jsxs(reactAriaComponents.Group, { className: ({ isFocusWithin }) => cx.cx('flex items-center gap-x-2 rounded-xl bg-primary p-4', isFocusWithin && 'outline-2 outline-focus-ring', className), children: [jsxRuntime.jsx("div", { className: "pointer-events-none absolute", children: jsxRuntime.jsx(uiIcons.SearchLg, { className: "size-5 text-fg-quaternary" }) }), jsxRuntime.jsx(reactAriaComponents.Input, { placeholder: placeholder, className: "m-0 w-full bg-transparent pl-7 text-md text-ellipsis text-primary ring-0 outline-hidden placeholder:text-placeholder autofill:rounded-lg autofill:text-primary", ...props, ref: ref }), tooltip && (jsxRuntime.jsx(Tooltip.Tooltip, { title: tooltip, placement: "top", children: jsxRuntime.jsx(Tooltip.TooltipTrigger, { className: "cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover", children: jsxRuntime.jsx(uiIcons.HelpCircle, { className: "size-4 stroke-[2.25px]" }) }) })), shortcutHint && jsxRuntime.jsx(CommandShortcut.CommandShortcut, { keys: [shortcutHint], className: "max-md:hidden" }), overlayState && jsxRuntime.jsx(Buttons.CloseButton, { size: "sm", label: "Close command menu", onPress: overlayState.close, className: "-my-1.5 -mr-2 md:hidden" })] }));
|
|
15
15
|
});
|
|
16
16
|
CommandInput.displayName = 'CommandInput';
|
|
17
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandInput.cjs","sources":["../../../../../src/components/organisms/CommandMenu/components/CommandInput.tsx"],"sourcesContent":[null],"names":["forwardRef","useContext","OverlayTriggerStateContext","_jsxs","AriaGroup","cx","_jsx","SearchLg","AriaInput","Tooltip","TooltipTrigger","HelpCircle","CommandShortcut","CloseButton"],"mappings":";;;;;;;;;;;MAoBa,YAAY,GAAGA,gBAAU,CAAsC,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;AAC/I,IAAA,MAAM,YAAY,GAAGC,gBAAU,CAACC,8CAA0B,CAAC;AAE3D,IAAA,QACEC,eAAA,CAACC,yBAAS,EAAA,EACR,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,KAC3BC,KAAE,CAAC,qDAAqD,EAAE,aAAa,IAAI,8BAA8B,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAGvHC,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,8BAA8B,YAC3CA,cAAA,CAACC,gBAAQ,EAAA,EAAC,SAAS,EAAC,2BAA2B,EAAA,CAAG,EAAA,CAC9C,EAEND,cAAA,CAACE,yBAAS,EAAA,EACR,WAAW,EAAE,WAAW,EACxB,SAAS,EAAC,
|
|
1
|
+
{"version":3,"file":"CommandInput.cjs","sources":["../../../../../src/components/organisms/CommandMenu/components/CommandInput.tsx"],"sourcesContent":[null],"names":["forwardRef","useContext","OverlayTriggerStateContext","_jsxs","AriaGroup","cx","_jsx","SearchLg","AriaInput","Tooltip","TooltipTrigger","HelpCircle","CommandShortcut","CloseButton"],"mappings":";;;;;;;;;;;MAoBa,YAAY,GAAGA,gBAAU,CAAsC,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;AAC/I,IAAA,MAAM,YAAY,GAAGC,gBAAU,CAACC,8CAA0B,CAAC;AAE3D,IAAA,QACEC,eAAA,CAACC,yBAAS,EAAA,EACR,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,KAC3BC,KAAE,CAAC,qDAAqD,EAAE,aAAa,IAAI,8BAA8B,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAGvHC,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,8BAA8B,YAC3CA,cAAA,CAACC,gBAAQ,EAAA,EAAC,SAAS,EAAC,2BAA2B,EAAA,CAAG,EAAA,CAC9C,EAEND,cAAA,CAACE,yBAAS,EAAA,EACR,WAAW,EAAE,WAAW,EACxB,SAAS,EAAC,gKAAgK,EAAA,GACtK,KAAK,EACT,GAAG,EAAE,GAAG,EAAA,CACR,EAED,OAAO,KACNF,cAAA,CAACG,eAAO,IAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAC,KAAK,EAAA,QAAA,EACtCH,cAAA,CAACI,sBAAc,EAAA,EAAC,SAAS,EAAC,yHAAyH,EAAA,QAAA,EACjJJ,cAAA,CAACK,kBAAU,EAAA,EAAC,SAAS,EAAC,wBAAwB,EAAA,CAAG,EAAA,CAClC,EAAA,CACT,CACX,EAEA,YAAY,IAAIL,cAAA,CAACM,+BAAe,EAAA,EAAC,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,SAAS,EAAC,eAAe,EAAA,CAAG,EAGnF,YAAY,IAAIN,cAAA,CAACO,mBAAW,EAAA,EAAC,IAAI,EAAC,IAAI,EAAC,KAAK,EAAC,oBAAoB,EAAC,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE,SAAS,EAAC,yBAAyB,EAAA,CAAG,CAAA,EAAA,CAC5H;AAEhB,CAAC;AACD,YAAY,CAAC,WAAW,GAAG,cAAc;;"}
|
|
@@ -9,7 +9,7 @@ import { CommandShortcut } from './CommandShortcut.js';
|
|
|
9
9
|
|
|
10
10
|
const CommandInput = forwardRef(({ placeholder, shortcutHint, tooltip, className, ...props }, ref) => {
|
|
11
11
|
const overlayState = useContext(OverlayTriggerStateContext);
|
|
12
|
-
return (jsxs(Group, { className: ({ isFocusWithin }) => cx('flex items-center gap-x-2 rounded-xl bg-primary p-4', isFocusWithin && 'outline-2 outline-focus-ring', className), children: [jsx("div", { className: "pointer-events-none absolute", children: jsx(SearchLg, { className: "size-5 text-fg-quaternary" }) }), jsx(Input, { placeholder: placeholder, className: "m-0 w-full bg-transparent pl-7 text-md text-primary ring-0 outline-hidden placeholder:text-placeholder autofill:rounded-lg autofill:text-primary", ...props, ref: ref }), tooltip && (jsx(Tooltip, { title: tooltip, placement: "top", children: jsx(TooltipTrigger, { className: "cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover", children: jsx(HelpCircle, { className: "size-4 stroke-[2.25px]" }) }) })), shortcutHint && jsx(CommandShortcut, { keys: [shortcutHint], className: "max-md:hidden" }), overlayState && jsx(CloseButton, { size: "sm", label: "Close command menu", onPress: overlayState.close, className: "-my-1.5 -mr-2 md:hidden" })] }));
|
|
12
|
+
return (jsxs(Group, { className: ({ isFocusWithin }) => cx('flex items-center gap-x-2 rounded-xl bg-primary p-4', isFocusWithin && 'outline-2 outline-focus-ring', className), children: [jsx("div", { className: "pointer-events-none absolute", children: jsx(SearchLg, { className: "size-5 text-fg-quaternary" }) }), jsx(Input, { placeholder: placeholder, className: "m-0 w-full bg-transparent pl-7 text-md text-ellipsis text-primary ring-0 outline-hidden placeholder:text-placeholder autofill:rounded-lg autofill:text-primary", ...props, ref: ref }), tooltip && (jsx(Tooltip, { title: tooltip, placement: "top", children: jsx(TooltipTrigger, { className: "cursor-pointer text-fg-quaternary transition duration-200 hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover", children: jsx(HelpCircle, { className: "size-4 stroke-[2.25px]" }) }) })), shortcutHint && jsx(CommandShortcut, { keys: [shortcutHint], className: "max-md:hidden" }), overlayState && jsx(CloseButton, { size: "sm", label: "Close command menu", onPress: overlayState.close, className: "-my-1.5 -mr-2 md:hidden" })] }));
|
|
13
13
|
});
|
|
14
14
|
CommandInput.displayName = 'CommandInput';
|
|
15
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandInput.js","sources":["../../../../../src/components/organisms/CommandMenu/components/CommandInput.tsx"],"sourcesContent":[null],"names":["_jsxs","AriaGroup","_jsx","AriaInput"],"mappings":";;;;;;;;;MAoBa,YAAY,GAAG,UAAU,CAAsC,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;AAC/I,IAAA,MAAM,YAAY,GAAG,UAAU,CAAC,0BAA0B,CAAC;AAE3D,IAAA,QACEA,IAAA,CAACC,KAAS,EAAA,EACR,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,KAC3B,EAAE,CAAC,qDAAqD,EAAE,aAAa,IAAI,8BAA8B,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAGvHC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,8BAA8B,YAC3CA,GAAA,CAAC,QAAQ,EAAA,EAAC,SAAS,EAAC,2BAA2B,EAAA,CAAG,EAAA,CAC9C,EAENA,GAAA,CAACC,KAAS,EAAA,EACR,WAAW,EAAE,WAAW,EACxB,SAAS,EAAC,
|
|
1
|
+
{"version":3,"file":"CommandInput.js","sources":["../../../../../src/components/organisms/CommandMenu/components/CommandInput.tsx"],"sourcesContent":[null],"names":["_jsxs","AriaGroup","_jsx","AriaInput"],"mappings":";;;;;;;;;MAoBa,YAAY,GAAG,UAAU,CAAsC,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;AAC/I,IAAA,MAAM,YAAY,GAAG,UAAU,CAAC,0BAA0B,CAAC;AAE3D,IAAA,QACEA,IAAA,CAACC,KAAS,EAAA,EACR,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,KAC3B,EAAE,CAAC,qDAAqD,EAAE,aAAa,IAAI,8BAA8B,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAGvHC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,8BAA8B,YAC3CA,GAAA,CAAC,QAAQ,EAAA,EAAC,SAAS,EAAC,2BAA2B,EAAA,CAAG,EAAA,CAC9C,EAENA,GAAA,CAACC,KAAS,EAAA,EACR,WAAW,EAAE,WAAW,EACxB,SAAS,EAAC,gKAAgK,EAAA,GACtK,KAAK,EACT,GAAG,EAAE,GAAG,EAAA,CACR,EAED,OAAO,KACND,GAAA,CAAC,OAAO,IAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAC,KAAK,EAAA,QAAA,EACtCA,GAAA,CAAC,cAAc,EAAA,EAAC,SAAS,EAAC,yHAAyH,EAAA,QAAA,EACjJA,GAAA,CAAC,UAAU,EAAA,EAAC,SAAS,EAAC,wBAAwB,EAAA,CAAG,EAAA,CAClC,EAAA,CACT,CACX,EAEA,YAAY,IAAIA,GAAA,CAAC,eAAe,EAAA,EAAC,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,SAAS,EAAC,eAAe,EAAA,CAAG,EAGnF,YAAY,IAAIA,GAAA,CAAC,WAAW,EAAA,EAAC,IAAI,EAAC,IAAI,EAAC,KAAK,EAAC,oBAAoB,EAAC,OAAO,EAAE,YAAY,CAAC,KAAK,EAAE,SAAS,EAAC,yBAAyB,EAAA,CAAG,CAAA,EAAA,CAC5H;AAEhB,CAAC;AACD,YAAY,CAAC,WAAW,GAAG,cAAc;;"}
|
|
@@ -13,9 +13,9 @@ var React = require('react');
|
|
|
13
13
|
var reactAriaComponents = require('react-aria-components');
|
|
14
14
|
var CalendarOverlay = require('../components/CalendarOverlay.cjs');
|
|
15
15
|
var useDatePickerDraft = require('../hooks/useDatePickerDraft.cjs');
|
|
16
|
+
var useToday = require('../hooks/useToday.cjs');
|
|
16
17
|
var Calendar = require('./components/Calendar.cjs');
|
|
17
18
|
|
|
18
|
-
const highlightedDates = [date.today(date.getLocalTimeZone())];
|
|
19
19
|
/**
|
|
20
20
|
* A trigger button paired with a popover calendar for selecting a single date, opening as a bottom
|
|
21
21
|
* sheet below the `md` breakpoint. Built on react-aria-components with Apply/Cancel actions in the footer.
|
|
@@ -36,6 +36,9 @@ const DatePicker = React.forwardRef(({ value: valueProp, defaultValue, onChange,
|
|
|
36
36
|
// Open state is owned here because react-aria reports no change when a controlled `isOpen` opens the calendar.
|
|
37
37
|
const [isOpen, setIsOpen] = utils.useControlledState(isOpenProp, defaultOpen ?? false, onOpenChange);
|
|
38
38
|
const { draftValue, setDraftValue } = useDatePickerDraft.useDatePickerDraft(value, isOpen);
|
|
39
|
+
// Read at every render, so a calendar rendered after midnight highlights the new day.
|
|
40
|
+
const now = useToday.useToday();
|
|
41
|
+
const highlightedDates = React.useMemo(() => [now], [now]);
|
|
39
42
|
const formattedDate = value ? formatter.format(value.toDate(date.getLocalTimeZone())) : placeholder;
|
|
40
43
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'date-picker', rootName: 'date-picker' });
|
|
41
44
|
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsx(reactAriaComponents.DatePicker
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.cjs","sources":["../../../../../src/components/organisms/DatePickers/DatePicker/DatePicker.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"DatePicker.cjs","sources":["../../../../../src/components/organisms/DatePickers/DatePicker/DatePicker.tsx"],"sourcesContent":[null],"names":["forwardRef","useDateFormatter","useControlledState","useDatePickerDraft","useToday","useMemo","getLocalTimeZone","useResolvedTestId","_jsx","TestIdProvider","AriaDatePicker","cx","_jsxs","_Fragment","Label","AriaGroup","Button","CalendarIcon","joinTestId","HintText","CalendarOverlay","Calendar"],"mappings":";;;;;;;;;;;;;;;;;;AAqCA;;;;;AAKG;AACI,MAAM,UAAU,GAAGA,gBAAU,CAClC,CACE,EACE,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,MAAM,EAAE,UAAU,EAClB,WAAW,EACX,YAAY,EACZ,IAAI,GAAG,IAAI,EACX,WAAW,GAAG,aAAa,EAC3B,KAAK,EACL,IAAI,EACJ,SAAS,EACT,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACT,EACD,GAAG,KACD;IACF,MAAM,SAAS,GAAGC,qBAAgB,CAAC;AACjC,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,GAAG,EAAE,SAAS;AACd,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA,CAAC;;;;;AAKF,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGC,wBAAkB,CAAC,SAAS,EAAE,YAAY,IAAI,IAAI,EAAE,QAAQ,CAAC;;AAEvF,IAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,wBAAkB,CAAC,UAAU,EAAE,WAAW,IAAI,KAAK,EAAE,YAAY,CAAC;AAC9F,IAAA,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAGC,qCAAkB,CAAC,KAAK,EAAE,MAAM,CAAC;;AAEvE,IAAA,MAAM,GAAG,GAAGC,iBAAQ,EAAE;AACtB,IAAA,MAAM,g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EAAA,OAAA,EAAA,CAGM,CAAA,EAAA,CACL,CAAA,EAAA,CACL,CACJ,EAAA,CACe,IACjB,CACJ,EAAA,CACc,EAAA,CACF;AAErB,CAAC;AAGH,UAAU,CAAC,WAAW,GAAG,YAAY;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/DatePickers/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAOzF,OAAO,EAAc,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/DatePickers/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAOzF,OAAO,EAAc,KAAK,SAAS,EAAW,MAAM,OAAO,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,IAAI,mBAAmB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAO/F,MAAM,WAAW,eAAgB,SAAQ,mBAAmB,CAAC,SAAS,CAAC;IACrE,+GAA+G;IAC/G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gHAAgH;IAChH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,CAAC;IAC5E,sHAAsH;IACtH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,4GA6HtB,CAAC"}
|
|
@@ -4,16 +4,16 @@ import { Button } from '@flipdish/ui-library/components/atoms/Buttons';
|
|
|
4
4
|
import { Label, HintText } from '@flipdish/ui-library/components/atoms/Inputs';
|
|
5
5
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
6
6
|
import { useResolvedTestId, TestIdProvider, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
7
|
-
import {
|
|
7
|
+
import { getLocalTimeZone } from '@internationalized/date';
|
|
8
8
|
import { useDateFormatter } from '@react-aria/i18n';
|
|
9
9
|
import { useControlledState } from '@react-stately/utils';
|
|
10
|
-
import { forwardRef } from 'react';
|
|
10
|
+
import { forwardRef, useMemo } from 'react';
|
|
11
11
|
import { DatePicker as DatePicker$1, Group } from 'react-aria-components';
|
|
12
12
|
import { CalendarOverlay } from '../components/CalendarOverlay.js';
|
|
13
13
|
import { useDatePickerDraft } from '../hooks/useDatePickerDraft.js';
|
|
14
|
+
import { useToday } from '../hooks/useToday.js';
|
|
14
15
|
import { Calendar as Calendar$1 } from './components/Calendar.js';
|
|
15
16
|
|
|
16
|
-
const highlightedDates = [today(getLocalTimeZone())];
|
|
17
17
|
/**
|
|
18
18
|
* A trigger button paired with a popover calendar for selecting a single date, opening as a bottom
|
|
19
19
|
* sheet below the `md` breakpoint. Built on react-aria-components with Apply/Cancel actions in the footer.
|
|
@@ -34,6 +34,9 @@ const DatePicker = forwardRef(({ value: valueProp, defaultValue, onChange, onApp
|
|
|
34
34
|
// Open state is owned here because react-aria reports no change when a controlled `isOpen` opens the calendar.
|
|
35
35
|
const [isOpen, setIsOpen] = useControlledState(isOpenProp, defaultOpen ?? false, onOpenChange);
|
|
36
36
|
const { draftValue, setDraftValue } = useDatePickerDraft(value, isOpen);
|
|
37
|
+
// Read at every render, so a calendar rendered after midnight highlights the new day.
|
|
38
|
+
const now = useToday();
|
|
39
|
+
const highlightedDates = useMemo(() => [now], [now]);
|
|
37
40
|
const formattedDate = value ? formatter.format(value.toDate(getLocalTimeZone())) : placeholder;
|
|
38
41
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'date-picker', rootName: 'date-picker' });
|
|
39
42
|
return (jsx(TestIdProvider, { value: rootTestId, children: jsx(DatePicker$1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sources":["../../../../../src/components/organisms/DatePickers/DatePicker/DatePicker.tsx"],"sourcesContent":[null],"names":["_jsx","AriaDatePicker","_jsxs","_Fragment","AriaGroup","CalendarIcon","Calendar"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sources":["../../../../../src/components/organisms/DatePickers/DatePicker/DatePicker.tsx"],"sourcesContent":[null],"names":["_jsx","AriaDatePicker","_jsxs","_Fragment","AriaGroup","CalendarIcon","Calendar"],"mappings":";;;;;;;;;;;;;;;;AAqCA;;;;;AAKG;AACI,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,MAAM,EAAE,UAAU,EAClB,WAAW,EACX,YAAY,EACZ,IAAI,GAAG,IAAI,EACX,WAAW,GAAG,aAAa,EAC3B,KAAK,EACL,IAAI,EACJ,SAAS,EACT,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACT,EACD,GAAG,KACD;IACF,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACjC,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,GAAG,EAAE,SAAS;AACd,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA,CAAC;;;;;AAKF,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,kBAAkB,CAAC,SAAS,EAAE,YAAY,IAAI,IAAI,EAAE,QAAQ,CAAC;;AAEvF,IAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,kBAAkB,CAAC,UAAU,E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A,aAAA,EACL,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,EAC5C,OAAO,EAAE,MAAK;gDACZ,QAAQ,CAAC,UAAU,CAAC;gDACpB,OAAO,IAAI;AACX,gDAAA,KAAK,EAAE;4CACT,CAAC,EAAA,QAAA,EAAA,OAAA,EAAA,CAGM,CAAA,EAAA,CACL,CAAA,EAAA,CACL,CACJ,EAAA,CACe,IACjB,CACJ,EAAA,CACc,EAAA,CACF;AAErB,CAAC;AAGH,UAAU,CAAC,WAAW,GAAG,YAAY;;"}
|
|
@@ -15,19 +15,31 @@ var controlFill_context = require('../../../__internal__/controlFill/controlFill
|
|
|
15
15
|
var SegmentedInputBase = require('../../../__internal__/segmentedInput/SegmentedInputBase.cjs');
|
|
16
16
|
var CalendarOverlay = require('../components/CalendarOverlay.cjs');
|
|
17
17
|
var useDatePickerDraft = require('../hooks/useDatePickerDraft.cjs');
|
|
18
|
+
var useDateRangePresets = require('../hooks/useDateRangePresets.cjs');
|
|
19
|
+
var useToday = require('../hooks/useToday.cjs');
|
|
18
20
|
var RangeCalendar = require('../RangeCalendar/RangeCalendar.cjs');
|
|
19
21
|
var dateRangePresets_utils = require('../utilities/dateRangePresets.utils.cjs');
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
+
// Complete literals so Tailwind sees them: the footer's inputs and equal-width actions switch at `lg` beside the sidebar's one month, at `md` without it.
|
|
24
|
+
const footerClasses = {
|
|
25
|
+
withSidebar: {
|
|
26
|
+
inputs: 'hidden items-center gap-2 lg:flex',
|
|
27
|
+
actions: 'flex w-full gap-3 max-md:flex-col-reverse lg:w-auto',
|
|
28
|
+
button: 'flex-1 lg:flex-none',
|
|
29
|
+
},
|
|
30
|
+
withoutSidebar: {
|
|
31
|
+
inputs: 'hidden items-center gap-2 md:flex',
|
|
32
|
+
actions: 'flex w-full gap-3 max-md:flex-col-reverse md:w-auto',
|
|
33
|
+
button: 'flex-1 md:flex-none',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
23
36
|
/**
|
|
24
|
-
* Trigger button with a
|
|
25
|
-
*
|
|
37
|
+
* Trigger button with a popover calendar for picking a start and end date, opening as a bottom sheet
|
|
38
|
+
* below the `md` breakpoint. Includes preset shortcuts and Apply and Cancel actions.
|
|
26
39
|
*
|
|
27
40
|
* @summary popover calendar for selecting a date range
|
|
28
41
|
*/
|
|
29
42
|
const DateRangePicker = React.forwardRef(({ value: valueProp, defaultValue, onChange, onApply, onCancel, isOpen: isOpenProp, defaultOpen, onOpenChange, size = 'sm', presets: presetsProp, placeholder = 'Select dates', label, hint, className, 'data-testid': dataTestId, ...props }, ref) => {
|
|
30
|
-
const { locale } = reactAriaComponents.useLocale();
|
|
31
43
|
const formatter = i18n.useDateFormatter({
|
|
32
44
|
month: 'short',
|
|
33
45
|
day: 'numeric',
|
|
@@ -40,34 +52,43 @@ const DateRangePicker = React.forwardRef(({ value: valueProp, defaultValue, onCh
|
|
|
40
52
|
const [value, setValue] = utils.useControlledState(valueProp, defaultValue || null, onChange);
|
|
41
53
|
// Open state is owned here because react-aria reports no change when a controlled `isOpen` opens the calendar.
|
|
42
54
|
const [isOpen, setIsOpen] = utils.useControlledState(isOpenProp, defaultOpen ?? false, onOpenChange);
|
|
55
|
+
// Read at every render, so the sidebar, the trigger's label and the highlight all count from the day it renders on.
|
|
56
|
+
const now = useToday.useToday();
|
|
57
|
+
const highlightedDates = React.useMemo(() => [now], [now]);
|
|
43
58
|
const { draftValue, setDraftValue } = useDatePickerDraft.useDatePickerDraft(value, isOpen);
|
|
44
59
|
// The calendar opens on the committed range's month, and a preset moves it to that preset's month.
|
|
45
60
|
// Always a date, today with no range: react-aria warns when a calendar's focused date goes from unset to set.
|
|
46
61
|
const { draftValue: focusedValue, setDraftValue: setFocusedValue } = useDatePickerDraft.useDatePickerDraft(value?.start ?? now, isOpen);
|
|
62
|
+
// One list for the sidebar, the sheet and the trigger's label, worked out from the day the picker renders on.
|
|
63
|
+
const presets = useDateRangePresets.useDateRangePresets(presetsProp ?? dateRangePresets_utils.DEFAULT_DATE_RANGE_PRESET_KEYS);
|
|
47
64
|
const formattedRange = value
|
|
48
65
|
? `${formatter.format(value.start.toDate(date.getLocalTimeZone()))} – ${formatter.format(value.end.toDate(date.getLocalTimeZone()))}`
|
|
49
66
|
: null;
|
|
50
|
-
|
|
51
|
-
const
|
|
67
|
+
// The applied range only, never the open calendar's draft: one on the same days as a preset is named by it, as "Last 7 days".
|
|
68
|
+
const matchingPresetLabel = dateRangePresets_utils.findMatchingDateRangePreset(presets, value)?.label;
|
|
69
|
+
const rangeText = matchingPresetLabel ?? formattedRange;
|
|
70
|
+
// A preset's label alone would hide its dates from a screen reader, so the trigger's name says both.
|
|
71
|
+
const rangeName = matchingPresetLabel && formattedRange ? `${matchingPresetLabel}, ${formattedRange}` : rangeText;
|
|
52
72
|
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'date-range-picker', rootName: 'date-range-picker' });
|
|
53
73
|
const triggerGroupRef = React.useRef(null);
|
|
54
74
|
// In a container that sizes its controls below `md`, the column stretches the trigger to the picker's box and the range truncates.
|
|
55
75
|
const isFilling = React.useContext(controlFill_context.ControlFillContext);
|
|
76
|
+
const footer = footerClasses[presets.length > 0 ? 'withSidebar' : 'withoutSidebar'];
|
|
56
77
|
// react-aria sends a label click to the first date field and skips the trigger, the only control a closed picker has.
|
|
57
78
|
const focusTrigger = () => triggerGroupRef.current?.querySelector('button')?.focus();
|
|
58
79
|
return (jsxRuntime.jsx(testIdUtils.TestIdProvider, { value: rootTestId, children: jsxRuntime.jsx(reactAriaComponents.DateRangePicker
|
|
59
80
|
// A visible label names the picker; without one this default does, unless `aria-label` is passed.
|
|
60
81
|
, { "aria-label": label ? undefined : 'Date range picker', ...props,
|
|
61
82
|
// Fixed after the spread: closing on select would discard the draft before Apply could commit it.
|
|
62
|
-
shouldCloseOnSelect: false, ref: ref, className: (state) => cx.cx('flex flex-col items-start gap-1.5', isFilling && 'max-md:items-stretch', typeof className === 'function' ? className(state) : className), value: draftValue, onChange: setDraftValue, isOpen: isOpen, onOpenChange: setIsOpen, "data-testid": rootTestId, children: ({ isInvalid, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Inputs.Label, { isRequired: isRequired, onClick: focusTrigger, children: label })), jsxRuntime.jsx(reactAriaComponents.Group, { ref: triggerGroupRef, children: jsxRuntime.jsx(Buttons.Button, { size: size, color: "secondary", iconLeading: uiIcons.Calendar, className: cx.cx(isFilling && 'max-md:w-full max-md:min-w-0 max-md:*:data-text:min-w-0 max-md:*:data-text:truncate', isInvalid && 'ring-error_subtle'), "aria-label": `Calendar, ${
|
|
83
|
+
shouldCloseOnSelect: false, ref: ref, className: (state) => cx.cx('flex flex-col items-start gap-1.5', isFilling && 'max-md:items-stretch', typeof className === 'function' ? className(state) : className), value: draftValue, onChange: setDraftValue, isOpen: isOpen, onOpenChange: setIsOpen, "data-testid": rootTestId, children: ({ isInvalid, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Inputs.Label, { isRequired: isRequired, onClick: focusTrigger, children: label })), jsxRuntime.jsx(reactAriaComponents.Group, { ref: triggerGroupRef, children: jsxRuntime.jsx(Buttons.Button, { size: size, color: "secondary", iconLeading: uiIcons.Calendar, className: cx.cx(isFilling && 'max-md:w-full max-md:min-w-0 max-md:*:data-text:min-w-0 max-md:*:data-text:truncate', isInvalid && 'ring-error_subtle'), "aria-label": `Calendar, ${rangeName ?? placeholder}`, "data-testid": testIdUtils.joinTestId(rootTestId, 'trigger'), children: rangeText ?? jsxRuntime.jsx("span", { className: "text-placeholder", children: placeholder }) }) }), hint && jsxRuntime.jsx(Inputs.HintText, { isInvalid: isInvalid, children: hint }), jsxRuntime.jsx(CalendarOverlay.CalendarOverlay, { "aria-label": props['aria-label'] ?? label ?? 'Date range picker', sheetTitle: label ?? 'Date range', "data-testid": testIdUtils.joinTestId(rootTestId, 'popover'),
|
|
63
84
|
// A row from `md`, the presets beside the calendar; the sheet below it stays a column.
|
|
64
|
-
className: "focus:outline-hidden md:flex-row", children: ({ close }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "scrollbar-visible hidden max-h-[inherit] w-38 flex-col gap-0.5 overflow-y-auto border-r border-solid border-secondary p-3
|
|
85
|
+
className: "focus:outline-hidden md:flex-row", children: ({ close }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [presets.length > 0 && (jsxRuntime.jsx("div", { className: "scrollbar-visible hidden max-h-[inherit] w-38 flex-col gap-0.5 overflow-y-auto border-r border-solid border-secondary p-3 md:flex", children: presets.map((preset) => (jsxRuntime.jsx(RangeCalendar.RangePresetButton, { value: preset.value, onClick: () => {
|
|
65
86
|
setDraftValue(preset.value);
|
|
66
87
|
setFocusedValue(preset.value.start);
|
|
67
|
-
}, children: preset.label }, preset.label))) }), jsxRuntime.jsxs("div", { className: "flex max-h-[inherit] min-h-0 flex-col max-md:w-full max-md:flex-1", children: [jsxRuntime.jsx(RangeCalendar.RangeCalendar, { focusedValue: focusedValue, onFocusChange: setFocusedValue, highlightedDates: highlightedDates, presets: presets }), jsxRuntime.jsxs("div", { className: "flex shrink-0 justify-between gap-3 border-t border-secondary bg-primary p-4 max-md:px-6", children: [jsxRuntime.jsxs("div", { className:
|
|
88
|
+
}, children: preset.label }, preset.label))) })), jsxRuntime.jsxs("div", { className: "flex max-h-[inherit] min-h-0 flex-col max-md:w-full max-md:flex-1", children: [jsxRuntime.jsx(RangeCalendar.RangeCalendar, { focusedValue: focusedValue, onFocusChange: setFocusedValue, highlightedDates: highlightedDates, presets: presets }), jsxRuntime.jsxs("div", { className: "flex shrink-0 justify-between gap-3 border-t border-secondary bg-primary p-4 max-md:px-6", children: [jsxRuntime.jsxs("div", { className: footer.inputs, children: [jsxRuntime.jsx(SegmentedInputBase.SegmentedInputBase, { slot: "start", size: "sm" }), jsxRuntime.jsx("div", { className: "text-md text-quaternary", children: "\u2013" }), jsxRuntime.jsx(SegmentedInputBase.SegmentedInputBase, { slot: "end", size: "sm" })] }), jsxRuntime.jsxs("div", { className: footer.actions, children: [jsxRuntime.jsx(Buttons.Button, { size: "sm", color: "secondary", className: footer.button, "data-testid": testIdUtils.joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
68
89
|
onCancel?.();
|
|
69
90
|
close();
|
|
70
|
-
}, children: "Cancel" }), jsxRuntime.jsx(Buttons.Button, { size: "sm", color: "primary", className:
|
|
91
|
+
}, children: "Cancel" }), jsxRuntime.jsx(Buttons.Button, { size: "sm", color: "primary", className: footer.button, "data-testid": testIdUtils.joinTestId(rootTestId, 'apply'), onClick: () => {
|
|
71
92
|
setValue(draftValue);
|
|
72
93
|
onApply?.();
|
|
73
94
|
close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.cjs","sources":["../../../../../src/components/organisms/DatePickers/DateRangePicker/DateRangePicker.tsx"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"DateRangePicker.cjs","sources":["../../../../../src/components/organisms/DatePickers/DateRangePicker/DateRangePicker.tsx"],"sourcesContent":[null],"names":["forwardRef","useDateFormatter","useControlledState","useToday","useMemo","useDatePickerDraft","useDateRangePresets","DEFAULT_DATE_RANGE_PRESET_KEYS","getLocalTimeZone","findMatchingDateRangePreset","useResolvedTestId","useRef","useContext","ControlFillContext","_jsx","TestIdProvider","AriaDateRangePicker","cx","_jsxs","_Fragment","Label","AriaGroup","Button","CalendarIcon","joinTestId","HintText","CalendarOverlay","RangePresetButton","RangeCalendar","SegmentedInputBase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4CA;AACA,MAAM,aAAa,GAAG;AACpB,IAAA,WAAW,EAAE;AACX,QAAA,MAAM,EAAE,mCAAmC;AAC3C,QAAA,OAAO,EAAE,qDAAqD;AAC9D,QAAA,MAAM,EAAE,qBAAqB;AAC9B,KAAA;AACD,IAAA,cAAc,EAAE;A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,EAAC,KAAK,EAAC,IAAI,EAAC,IAAI,EAAA,CAAG,CAAA,EAAA,CACvC,EAENX,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,MAAM,CAAC,OAAO,aAC5BJ,cAAA,CAACQ,cAAM,EAAA,EACL,IAAI,EAAC,IAAI,EACT,KAAK,EAAC,WAAW,EACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAA,aAAA,EACXE,sBAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC7C,OAAO,EAAE,MAAK;gEACZ,QAAQ,IAAI;AACZ,gEAAA,KAAK,EAAE;AACT,4DAAA,CAAC,EAAA,QAAA,EAAA,QAAA,EAAA,CAGM,EACTV,cAAA,CAACQ,cAAM,EAAA,EACL,IAAI,EAAC,IAAI,EACT,KAAK,EAAC,SAAS,EACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAA,aAAA,EACXE,sBAAU,CAAC,UAAU,EAAE,OAAO,CAAC,EAC5C,OAAO,EAAE,MAAK;gEACZ,QAAQ,CAAC,UAAU,CAAC;gEACpB,OAAO,IAAI;AACX,gEAAA,KAAK,EAAE;AACT,4DAAA,CAAC,EAAA,QAAA,EAAA,OAAA,EAAA,CAGM,CAAA,EAAA,CACL,CAAA,EAAA,CACF,CAAA,EAAA,CACF,CAAA,EAAA,CACL,CACJ,EAAA,CACe,CAAA,EAAA,CACjB,CACJ,EAAA,CACmB,EAAA,CACP;AAErB,CAAC;AAGH,eAAe,CAAC,WAAW,GAAG,iBAAiB;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ButtonProps } from '@flipdish/ui-library/components/atoms/Buttons';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
3
|
import type { DateRangePickerProps as AriaDateRangePickerProps, DateValue } from 'react-aria-components';
|
|
4
|
-
import {
|
|
4
|
+
import type { DateRangePresets } from '../datePickers.types';
|
|
5
5
|
export interface DateRangePickerProps extends AriaDateRangePickerProps<DateValue> {
|
|
6
6
|
/** Visible label above the trigger; it names the trigger and the calendar. When omitted, pass `aria-label`. */
|
|
7
7
|
label?: string;
|
|
@@ -9,8 +9,8 @@ export interface DateRangePickerProps extends AriaDateRangePickerProps<DateValue
|
|
|
9
9
|
hint?: ReactNode;
|
|
10
10
|
/** Size of the trigger button; the calendar's inputs and actions keep a fixed size. */
|
|
11
11
|
size?: ButtonProps['size'];
|
|
12
|
-
/**
|
|
13
|
-
presets?:
|
|
12
|
+
/** The shortcuts beside the calendar, in order: built-in keys such as `['today', 'last7Days']`, which may sit beside `{ label, value }` ranges of the page's own, or a record of such ranges; Today, Yesterday and the last 7, 14, 30, 90, 180 and 365 days when omitted. A label names the trigger while the applied range falls on the same days as its range, and derives its `--preset-<slug>` test id. */
|
|
13
|
+
presets?: DateRangePresets;
|
|
14
14
|
/** Trigger text while no range is applied. */
|
|
15
15
|
placeholder?: string;
|
|
16
16
|
/** Ignored: the calendar always stays open after a selection, so Apply can commit it. */
|
|
@@ -23,8 +23,8 @@ export interface DateRangePickerProps extends AriaDateRangePickerProps<DateValue
|
|
|
23
23
|
'data-testid'?: string;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Trigger button with a
|
|
27
|
-
*
|
|
26
|
+
* Trigger button with a popover calendar for picking a start and end date, opening as a bottom sheet
|
|
27
|
+
* below the `md` breakpoint. Includes preset shortcuts and Apply and Cancel actions.
|
|
28
28
|
*
|
|
29
29
|
* @summary popover calendar for selecting a date range
|
|
30
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/DatePickers/DateRangePicker/DateRangePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAOzF,OAAO,EAAc,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAChF,OAAO,KAAK,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"DateRangePicker.d.ts","sourceRoot":"","sources":["../../../../../src/components/organisms/DatePickers/DateRangePicker/DateRangePicker.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAOzF,OAAO,EAAc,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AAChF,OAAO,KAAK,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKzG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAO7D,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB,CAAC,SAAS,CAAC;IAC/E,+GAA+G;IAC/G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gHAAgH;IAChH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,uFAAuF;IACvF,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,+YAA+Y;IAC/Y,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,CAAC;IACjF,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,4HAA4H;IAC5H,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,iHA6L3B,CAAC"}
|
|
@@ -4,28 +4,40 @@ import { Button } from '@flipdish/ui-library/components/atoms/Buttons';
|
|
|
4
4
|
import { Label, HintText } from '@flipdish/ui-library/components/atoms/Inputs';
|
|
5
5
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
6
6
|
import { useResolvedTestId, TestIdProvider, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
7
|
-
import {
|
|
7
|
+
import { getLocalTimeZone } from '@internationalized/date';
|
|
8
8
|
import { useDateFormatter } from '@react-aria/i18n';
|
|
9
9
|
import { useControlledState } from '@react-stately/utils';
|
|
10
10
|
import { forwardRef, useMemo, useRef, useContext } from 'react';
|
|
11
|
-
import {
|
|
11
|
+
import { DateRangePicker as DateRangePicker$1, Group } from 'react-aria-components';
|
|
12
12
|
import { ControlFillContext } from '../../../__internal__/controlFill/controlFill.context.js';
|
|
13
13
|
import { SegmentedInputBase } from '../../../__internal__/segmentedInput/SegmentedInputBase.js';
|
|
14
14
|
import { CalendarOverlay } from '../components/CalendarOverlay.js';
|
|
15
15
|
import { useDatePickerDraft } from '../hooks/useDatePickerDraft.js';
|
|
16
|
+
import { useDateRangePresets } from '../hooks/useDateRangePresets.js';
|
|
17
|
+
import { useToday } from '../hooks/useToday.js';
|
|
16
18
|
import { RangePresetButton, RangeCalendar } from '../RangeCalendar/RangeCalendar.js';
|
|
17
|
-
import {
|
|
19
|
+
import { findMatchingDateRangePreset, DEFAULT_DATE_RANGE_PRESET_KEYS } from '../utilities/dateRangePresets.utils.js';
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
+
// Complete literals so Tailwind sees them: the footer's inputs and equal-width actions switch at `lg` beside the sidebar's one month, at `md` without it.
|
|
22
|
+
const footerClasses = {
|
|
23
|
+
withSidebar: {
|
|
24
|
+
inputs: 'hidden items-center gap-2 lg:flex',
|
|
25
|
+
actions: 'flex w-full gap-3 max-md:flex-col-reverse lg:w-auto',
|
|
26
|
+
button: 'flex-1 lg:flex-none',
|
|
27
|
+
},
|
|
28
|
+
withoutSidebar: {
|
|
29
|
+
inputs: 'hidden items-center gap-2 md:flex',
|
|
30
|
+
actions: 'flex w-full gap-3 max-md:flex-col-reverse md:w-auto',
|
|
31
|
+
button: 'flex-1 md:flex-none',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
21
34
|
/**
|
|
22
|
-
* Trigger button with a
|
|
23
|
-
*
|
|
35
|
+
* Trigger button with a popover calendar for picking a start and end date, opening as a bottom sheet
|
|
36
|
+
* below the `md` breakpoint. Includes preset shortcuts and Apply and Cancel actions.
|
|
24
37
|
*
|
|
25
38
|
* @summary popover calendar for selecting a date range
|
|
26
39
|
*/
|
|
27
40
|
const DateRangePicker = forwardRef(({ value: valueProp, defaultValue, onChange, onApply, onCancel, isOpen: isOpenProp, defaultOpen, onOpenChange, size = 'sm', presets: presetsProp, placeholder = 'Select dates', label, hint, className, 'data-testid': dataTestId, ...props }, ref) => {
|
|
28
|
-
const { locale } = useLocale();
|
|
29
41
|
const formatter = useDateFormatter({
|
|
30
42
|
month: 'short',
|
|
31
43
|
day: 'numeric',
|
|
@@ -38,34 +50,43 @@ const DateRangePicker = forwardRef(({ value: valueProp, defaultValue, onChange,
|
|
|
38
50
|
const [value, setValue] = useControlledState(valueProp, defaultValue || null, onChange);
|
|
39
51
|
// Open state is owned here because react-aria reports no change when a controlled `isOpen` opens the calendar.
|
|
40
52
|
const [isOpen, setIsOpen] = useControlledState(isOpenProp, defaultOpen ?? false, onOpenChange);
|
|
53
|
+
// Read at every render, so the sidebar, the trigger's label and the highlight all count from the day it renders on.
|
|
54
|
+
const now = useToday();
|
|
55
|
+
const highlightedDates = useMemo(() => [now], [now]);
|
|
41
56
|
const { draftValue, setDraftValue } = useDatePickerDraft(value, isOpen);
|
|
42
57
|
// The calendar opens on the committed range's month, and a preset moves it to that preset's month.
|
|
43
58
|
// Always a date, today with no range: react-aria warns when a calendar's focused date goes from unset to set.
|
|
44
59
|
const { draftValue: focusedValue, setDraftValue: setFocusedValue } = useDatePickerDraft(value?.start ?? now, isOpen);
|
|
60
|
+
// One list for the sidebar, the sheet and the trigger's label, worked out from the day the picker renders on.
|
|
61
|
+
const presets = useDateRangePresets(presetsProp ?? DEFAULT_DATE_RANGE_PRESET_KEYS);
|
|
45
62
|
const formattedRange = value
|
|
46
63
|
? `${formatter.format(value.start.toDate(getLocalTimeZone()))} – ${formatter.format(value.end.toDate(getLocalTimeZone()))}`
|
|
47
64
|
: null;
|
|
48
|
-
|
|
49
|
-
const
|
|
65
|
+
// The applied range only, never the open calendar's draft: one on the same days as a preset is named by it, as "Last 7 days".
|
|
66
|
+
const matchingPresetLabel = findMatchingDateRangePreset(presets, value)?.label;
|
|
67
|
+
const rangeText = matchingPresetLabel ?? formattedRange;
|
|
68
|
+
// A preset's label alone would hide its dates from a screen reader, so the trigger's name says both.
|
|
69
|
+
const rangeName = matchingPresetLabel && formattedRange ? `${matchingPresetLabel}, ${formattedRange}` : rangeText;
|
|
50
70
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'date-range-picker', rootName: 'date-range-picker' });
|
|
51
71
|
const triggerGroupRef = useRef(null);
|
|
52
72
|
// In a container that sizes its controls below `md`, the column stretches the trigger to the picker's box and the range truncates.
|
|
53
73
|
const isFilling = useContext(ControlFillContext);
|
|
74
|
+
const footer = footerClasses[presets.length > 0 ? 'withSidebar' : 'withoutSidebar'];
|
|
54
75
|
// react-aria sends a label click to the first date field and skips the trigger, the only control a closed picker has.
|
|
55
76
|
const focusTrigger = () => triggerGroupRef.current?.querySelector('button')?.focus();
|
|
56
77
|
return (jsx(TestIdProvider, { value: rootTestId, children: jsx(DateRangePicker$1
|
|
57
78
|
// A visible label names the picker; without one this default does, unless `aria-label` is passed.
|
|
58
79
|
, { "aria-label": label ? undefined : 'Date range picker', ...props,
|
|
59
80
|
// Fixed after the spread: closing on select would discard the draft before Apply could commit it.
|
|
60
|
-
shouldCloseOnSelect: false, ref: ref, className: (state) => cx('flex flex-col items-start gap-1.5', isFilling && 'max-md:items-stretch', typeof className === 'function' ? className(state) : className), value: draftValue, onChange: setDraftValue, isOpen: isOpen, onOpenChange: setIsOpen, "data-testid": rootTestId, children: ({ isInvalid, isRequired }) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: isRequired, onClick: focusTrigger, children: label })), jsx(Group, { ref: triggerGroupRef, children: jsx(Button, { size: size, color: "secondary", iconLeading: Calendar, className: cx(isFilling && 'max-md:w-full max-md:min-w-0 max-md:*:data-text:min-w-0 max-md:*:data-text:truncate', isInvalid && 'ring-error_subtle'), "aria-label": `Calendar, ${
|
|
81
|
+
shouldCloseOnSelect: false, ref: ref, className: (state) => cx('flex flex-col items-start gap-1.5', isFilling && 'max-md:items-stretch', typeof className === 'function' ? className(state) : className), value: draftValue, onChange: setDraftValue, isOpen: isOpen, onOpenChange: setIsOpen, "data-testid": rootTestId, children: ({ isInvalid, isRequired }) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: isRequired, onClick: focusTrigger, children: label })), jsx(Group, { ref: triggerGroupRef, children: jsx(Button, { size: size, color: "secondary", iconLeading: Calendar, className: cx(isFilling && 'max-md:w-full max-md:min-w-0 max-md:*:data-text:min-w-0 max-md:*:data-text:truncate', isInvalid && 'ring-error_subtle'), "aria-label": `Calendar, ${rangeName ?? placeholder}`, "data-testid": joinTestId(rootTestId, 'trigger'), children: rangeText ?? jsx("span", { className: "text-placeholder", children: placeholder }) }) }), hint && jsx(HintText, { isInvalid: isInvalid, children: hint }), jsx(CalendarOverlay, { "aria-label": props['aria-label'] ?? label ?? 'Date range picker', sheetTitle: label ?? 'Date range', "data-testid": joinTestId(rootTestId, 'popover'),
|
|
61
82
|
// A row from `md`, the presets beside the calendar; the sheet below it stays a column.
|
|
62
|
-
className: "focus:outline-hidden md:flex-row", children: ({ close }) => (jsxs(Fragment, { children: [jsx("div", { className: "scrollbar-visible hidden max-h-[inherit] w-38 flex-col gap-0.5 overflow-y-auto border-r border-solid border-secondary p-3
|
|
83
|
+
className: "focus:outline-hidden md:flex-row", children: ({ close }) => (jsxs(Fragment, { children: [presets.length > 0 && (jsx("div", { className: "scrollbar-visible hidden max-h-[inherit] w-38 flex-col gap-0.5 overflow-y-auto border-r border-solid border-secondary p-3 md:flex", children: presets.map((preset) => (jsx(RangePresetButton, { value: preset.value, onClick: () => {
|
|
63
84
|
setDraftValue(preset.value);
|
|
64
85
|
setFocusedValue(preset.value.start);
|
|
65
|
-
}, children: preset.label }, preset.label))) }), jsxs("div", { className: "flex max-h-[inherit] min-h-0 flex-col max-md:w-full max-md:flex-1", children: [jsx(RangeCalendar, { focusedValue: focusedValue, onFocusChange: setFocusedValue, highlightedDates: highlightedDates, presets: presets }), jsxs("div", { className: "flex shrink-0 justify-between gap-3 border-t border-secondary bg-primary p-4 max-md:px-6", children: [jsxs("div", { className:
|
|
86
|
+
}, children: preset.label }, preset.label))) })), jsxs("div", { className: "flex max-h-[inherit] min-h-0 flex-col max-md:w-full max-md:flex-1", children: [jsx(RangeCalendar, { focusedValue: focusedValue, onFocusChange: setFocusedValue, highlightedDates: highlightedDates, presets: presets }), jsxs("div", { className: "flex shrink-0 justify-between gap-3 border-t border-secondary bg-primary p-4 max-md:px-6", children: [jsxs("div", { className: footer.inputs, children: [jsx(SegmentedInputBase, { slot: "start", size: "sm" }), jsx("div", { className: "text-md text-quaternary", children: "\u2013" }), jsx(SegmentedInputBase, { slot: "end", size: "sm" })] }), jsxs("div", { className: footer.actions, children: [jsx(Button, { size: "sm", color: "secondary", className: footer.button, "data-testid": joinTestId(rootTestId, 'cancel'), onClick: () => {
|
|
66
87
|
onCancel?.();
|
|
67
88
|
close();
|
|
68
|
-
}, children: "Cancel" }), jsx(Button, { size: "sm", color: "primary", className:
|
|
89
|
+
}, children: "Cancel" }), jsx(Button, { size: "sm", color: "primary", className: footer.button, "data-testid": joinTestId(rootTestId, 'apply'), onClick: () => {
|
|
69
90
|
setValue(draftValue);
|
|
70
91
|
onApply?.();
|
|
71
92
|
close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.js","sources":["../../../../../src/components/organisms/DatePickers/DateRangePicker/DateRangePicker.tsx"],"sourcesContent":[null],"names":["_jsx","AriaDateRangePicker","_jsxs","_Fragment","AriaGroup","CalendarIcon"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateRangePicker.js","sources":["../../../../../src/components/organisms/DatePickers/DateRangePicker/DateRangePicker.tsx"],"sourcesContent":[null],"names":["_jsx","AriaDateRangePicker","_jsxs","_Fragment","AriaGroup","CalendarIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4CA;AACA,MAAM,aAAa,GAAG;AACpB,IAAA,WAAW,EAAE;AACX,QAAA,MAAM,EAAE,mCAAmC;AAC3C,QAAA,OAAO,EAAE,qDAAqD;AAC9D,QAAA,MAAM,EAAE,qBAAqB;AAC9B,KAAA;AACD,IAAA,cAAc,EAAE;AACd,QAAA,MAAM,EAAE,mCAAmC;AAC3C,QAAA,OAAO,EAAE,qDAAqD;AAC9D,QAAA,MAAM,EAAE,qBAAqB;AAC9B,KAAA;CACF;AAED;;;;;AAKG;AACI,MAAM,eAAe,GAAG,UAAU,CACvC,CACE,EACE,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,MAAM,EAAE,UAAU,EAClB,WAAW,EACX,YAAY,EACZ,IAAI,GAAG,IAAI,EACX,OAAO,EAAE,WAAW,EACpB,WAAW,GAAG,cAAc,EAC5B,KAAK,EACL,IAAI,EACJ,SAAS,EACT,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACT,EACD,GAAG,KACD;IACF,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACjC,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,GAAG,EAAE,SAAS;AACd,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA,CAAC;;;;;AAKF,IAAA,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,kBAAkB,CAAC,SAAS,EAAE,YAAY,IAAI,IAAI,EAAE,QAAQ,CAAC;;AAEvF,IAAA,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,kBAAkB,CAAC,UAAU,EAAE,WAAW,IAAI,KAAK,EAAE,YAAY,C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AAErB,CAAC;AAGH,eAAe,CAAC,WAAW,GAAG,iBAAiB;;"}
|
|
@@ -11,6 +11,7 @@ var React = require('react');
|
|
|
11
11
|
var reactAriaComponents = require('react-aria-components');
|
|
12
12
|
var SegmentedInputBase = require('../../../__internal__/segmentedInput/SegmentedInputBase.cjs');
|
|
13
13
|
var Cell = require('../components/Cell.cjs');
|
|
14
|
+
var useDateRangePresets = require('../hooks/useDateRangePresets.cjs');
|
|
14
15
|
var CalendarSurface_context = require('../providers/CalendarSurface.context.cjs');
|
|
15
16
|
|
|
16
17
|
const RangeCalendarTitle = ({ part }) => {
|
|
@@ -54,11 +55,17 @@ const MobilePresetButton = ({ value, children, ...props }) => {
|
|
|
54
55
|
*/
|
|
55
56
|
const RangeCalendar = ({ presets, visibleDuration, showOutOfRangeDates = false, showPresetsOnDesktop = false, 'data-testid': dataTestId, ...props }) => {
|
|
56
57
|
const isDesktop = useBreakpoints.useBreakpoints('md');
|
|
58
|
+
// The picker's sidebar from `md` leaves its right column room for one month until `lg`, so the second month and the footer inputs wait for it.
|
|
59
|
+
const isLarge = useBreakpoints.useBreakpoints('lg');
|
|
57
60
|
const surface = React.useContext(CalendarSurface_context.CalendarSurfaceContext);
|
|
58
61
|
const isInSheet = surface === 'sheet';
|
|
59
|
-
// The
|
|
62
|
+
// The date inputs above the month belong to a `DateRangePicker`, which holds the dates they edit; on its own the calendar has none to give them.
|
|
60
63
|
const isInPicker = React.useContext(reactAriaComponents.DateRangePickerStateContext) !== null;
|
|
61
|
-
|
|
64
|
+
// A picker hands down the list it already resolved, which passes through unchanged.
|
|
65
|
+
const resolvedPresets = useDateRangePresets.useDateRangePresets(presets);
|
|
66
|
+
const hasSidebar = isInPicker && resolvedPresets.length > 0;
|
|
67
|
+
const defaultMonths = isDesktop && (isLarge || !hasSidebar) ? 2 : 1;
|
|
68
|
+
const visibleDurationMonths = visibleDuration?.months || defaultMonths;
|
|
62
69
|
// Adopt the ambient prefix from an ancestor (e.g. `DateRangePicker`) unchanged so ids stay
|
|
63
70
|
// flat (`<root>--cell-…`); only fall back to the standalone default when there is none.
|
|
64
71
|
const ambientPrefix = testIdUtils.useTestIdPrefix();
|
|
@@ -69,7 +76,11 @@ const RangeCalendar = ({ presets, visibleDuration, showOutOfRangeDates = false,
|
|
|
69
76
|
// No sideways scroll: beside a scrollbar that takes width the 280px grid runs a little into the gutter instead.
|
|
70
77
|
surface && 'min-h-0 overflow-x-hidden overflow-y-auto', isInSheet && 'scrollbar-thin w-full', typeof props.className === 'function' ? props.className(state) : props.className), visibleDuration: {
|
|
71
78
|
months: visibleDurationMonths,
|
|
72
|
-
}, children: [jsxRuntime.jsxs("div", { className: cx.cx('flex min-w-0 flex-col gap-3 px-4 py-5 sm:px-6 md:gap-2', isInSheet && 'w-full px-6 pt-0'), children: [jsxRuntime.jsxs("div", { className: cx.cx('relative flex items-center', visibleDurationMonths > 1 ? 'justify-start' : 'justify-between'), children: [jsxRuntime.jsx(Buttons.Button, { slot: "previous", iconLeading: uiIcons.ChevronLeft, size: "sm", color: "tertiary", className: "size-8", "data-testid": testIdUtils.joinTestId(calendarTestId, 'prev') }), jsxRuntime.jsx("h2", { className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-sm font-semibold text-fg-secondary", children: jsxRuntime.jsx(RangeCalendarTitle, { part: "start" }) }), visibleDurationMonths === 1 && (jsxRuntime.jsx(Buttons.Button, { slot: "next", iconLeading: uiIcons.ChevronRight, size: "sm", color: "tertiary", className: "size-8", "data-testid": testIdUtils.joinTestId(calendarTestId, 'next') }))] }),
|
|
79
|
+
}, children: [jsxRuntime.jsxs("div", { className: cx.cx('flex min-w-0 flex-col gap-3 px-4 py-5 sm:px-6 md:gap-2', isInSheet && 'mx-auto w-full max-w-md px-6 pt-0'), children: [jsxRuntime.jsxs("div", { className: cx.cx('relative flex items-center', visibleDurationMonths > 1 ? 'justify-start' : 'justify-between'), children: [jsxRuntime.jsx(Buttons.Button, { slot: "previous", iconLeading: uiIcons.ChevronLeft, size: "sm", color: "tertiary", className: "size-8", "data-testid": testIdUtils.joinTestId(calendarTestId, 'prev') }), jsxRuntime.jsx("h2", { className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-sm font-semibold text-fg-secondary", children: jsxRuntime.jsx(RangeCalendarTitle, { part: "start" }) }), visibleDurationMonths === 1 && (jsxRuntime.jsx(Buttons.Button, { slot: "next", iconLeading: uiIcons.ChevronRight, size: "sm", color: "tertiary", className: "size-8", "data-testid": testIdUtils.joinTestId(calendarTestId, 'next') }))] }), isInPicker && (!isDesktop || (hasSidebar && !isLarge)) && (
|
|
80
|
+
// In the popover the row takes the grid's width rather than giving one: the empty inputs' natural width would widen the column.
|
|
81
|
+
jsxRuntime.jsxs("div", { className: cx.cx('flex items-center gap-2 max-sm:gap-1', hasSidebar ? 'lg:hidden' : 'md:hidden', surface === 'popover' && 'w-0 min-w-full'), children: [jsxRuntime.jsx(SegmentedInputBase.SegmentedInputBase, { slot: "start", size: "sm", wrapperClassName: "min-w-0 flex-1", className: "max-sm:px-2" }), jsxRuntime.jsx("div", { className: "text-md text-quaternary", children: "\u2013" }), jsxRuntime.jsx(SegmentedInputBase.SegmentedInputBase, { slot: "end", size: "sm", wrapperClassName: "min-w-0 flex-1", className: "max-sm:px-2" })] })), (showPresetsOnDesktop || !isDesktop) && resolvedPresets.length > 0 && (
|
|
82
|
+
// Three to a row in equal columns, a short last row centred; in the sheet the row reaches 8px from its edges, as designed.
|
|
83
|
+
jsxRuntime.jsx("div", { className: cx.cx('mt-1 flex flex-wrap justify-center gap-y-2', isInSheet && '-mx-4'), children: resolvedPresets.map((preset) => (jsxRuntime.jsx("div", { className: "flex min-w-0 basis-1/3 justify-center", children: jsxRuntime.jsx(MobilePresetButton, { value: preset.value, className: "max-w-full min-w-0 *:data-text:min-w-0 *:data-text:truncate", children: preset.label }) }, preset.label))) })), jsxRuntime.jsxs(reactAriaComponents.CalendarGrid, { weekdayStyle: "short", className: cx.cx('w-max', isInSheet && 'self-center'), children: [jsxRuntime.jsx(reactAriaComponents.CalendarGridHeader, { children: (day) => (jsxRuntime.jsx(reactAriaComponents.CalendarHeaderCell, { className: "border-b-4 border-transparent p-0", children: jsxRuntime.jsx("div", { className: "flex size-10 items-center justify-center text-sm font-medium text-secondary", children: day.slice(0, 2) }) })) }), jsxRuntime.jsx(reactAriaComponents.CalendarGridBody, { className: "[&_td]:p-0 [&_tr]:border-b-4 [&_tr]:border-transparent [&_tr:last-of-type]:border-none", children: (date) => jsxRuntime.jsx(Cell.CalendarCell, { date: date, showOutOfRangeDates: showOutOfRangeDates }) })] })] }), visibleDurationMonths > 1 && (jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 border-l border-secondary px-6 py-5", children: [jsxRuntime.jsxs("div", { className: "relative flex items-center justify-end", children: [jsxRuntime.jsx("h2", { className: "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 text-sm font-semibold text-fg-secondary", children: jsxRuntime.jsx(RangeCalendarTitle, { part: "end" }) }), jsxRuntime.jsx(Buttons.Button, { slot: "next", iconLeading: uiIcons.ChevronRight, size: "sm", color: "tertiary", className: "size-8", "data-testid": testIdUtils.joinTestId(calendarTestId, 'next') })] }), jsxRuntime.jsxs(reactAriaComponents.CalendarGrid, { weekdayStyle: "short", offset: { months: 1 }, className: "w-max", children: [jsxRuntime.jsx(reactAriaComponents.CalendarGridHeader, { children: (day) => (jsxRuntime.jsx(reactAriaComponents.CalendarHeaderCell, { className: "border-b-4 border-transparent p-0", children: jsxRuntime.jsx("div", { className: "flex size-10 items-center justify-center text-sm font-medium text-secondary", children: day.slice(0, 2) }) })) }), jsxRuntime.jsx(reactAriaComponents.CalendarGridBody, { className: "[&_td]:p-0 [&_tr]:border-b-4 [&_tr]:border-transparent [&_tr:last-of-type]:border-none", children: (date) => jsxRuntime.jsx(Cell.CalendarCell, { date: date, showOutOfRangeDates: showOutOfRangeDates }) })] })] }))] }) }));
|
|
73
84
|
};
|
|
74
85
|
|
|
75
86
|
exports.RangeCalendar = RangeCalendar;
|