@once-ui-system/core 1.3.14 → 1.4.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/Accordion.d.ts +1 -0
- package/dist/components/Accordion.d.ts.map +1 -1
- package/dist/components/Accordion.js +18 -10
- package/dist/components/Accordion.js.map +1 -1
- package/dist/components/AccordionGroup.d.ts +1 -0
- package/dist/components/AccordionGroup.d.ts.map +1 -1
- package/dist/components/AccordionGroup.js +18 -3
- package/dist/components/AccordionGroup.js.map +1 -1
- package/dist/components/ArrowNavigationContext.d.ts +33 -0
- package/dist/components/ArrowNavigationContext.d.ts.map +1 -0
- package/dist/components/ArrowNavigationContext.js +60 -0
- package/dist/components/ArrowNavigationContext.js.map +1 -0
- package/dist/components/AutoScroll.js +1 -1
- package/dist/components/AutoScroll.js.map +1 -1
- package/dist/components/Button.d.ts +2 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +3 -3
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Button.module.scss +31 -8
- package/dist/components/Carousel.js +5 -5
- package/dist/components/Carousel.js.map +1 -1
- package/dist/components/ClientFlex.d.ts +7 -0
- package/dist/components/ClientFlex.d.ts.map +1 -0
- package/dist/components/ClientFlex.js +95 -0
- package/dist/components/ClientFlex.js.map +1 -0
- package/dist/components/ClientGrid.d.ts +7 -0
- package/dist/components/ClientGrid.d.ts.map +1 -0
- package/dist/components/ClientGrid.js +95 -0
- package/dist/components/ClientGrid.js.map +1 -0
- package/dist/components/Column.d.ts.map +1 -1
- package/dist/components/Column.js +1 -0
- package/dist/components/Column.js.map +1 -1
- package/dist/components/ContextMenu.d.ts.map +1 -1
- package/dist/components/ContextMenu.js +13 -1
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/CountFx.d.ts +14 -0
- package/dist/components/CountFx.d.ts.map +1 -0
- package/dist/components/CountFx.js +195 -0
- package/dist/components/CountFx.js.map +1 -0
- package/dist/components/Cursor.d.ts +8 -0
- package/dist/components/Cursor.d.ts.map +1 -0
- package/dist/components/Cursor.js +79 -0
- package/dist/components/Cursor.js.map +1 -0
- package/dist/components/CursorCard.js +1 -1
- package/dist/components/CursorCard.js.map +1 -1
- package/dist/components/DateInput.d.ts +2 -0
- package/dist/components/DateInput.d.ts.map +1 -1
- package/dist/components/DateInput.js +8 -7
- package/dist/components/DateInput.js.map +1 -1
- package/dist/components/DatePicker.d.ts +3 -0
- package/dist/components/DatePicker.d.ts.map +1 -1
- package/dist/components/DatePicker.js +297 -23
- package/dist/components/DatePicker.js.map +1 -1
- package/dist/components/DateRangeInput.d.ts.map +1 -1
- package/dist/components/DateRangeInput.js +6 -3
- package/dist/components/DateRangeInput.js.map +1 -1
- package/dist/components/Dialog.js +1 -1
- package/dist/components/Dialog.js.map +1 -1
- package/dist/components/Dropdown.d.ts.map +1 -1
- package/dist/components/Dropdown.js +3 -1
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/DropdownWrapper.d.ts +8 -0
- package/dist/components/DropdownWrapper.d.ts.map +1 -1
- package/dist/components/DropdownWrapper.js +237 -79
- package/dist/components/DropdownWrapper.js.map +1 -1
- package/dist/components/ElementType.js +1 -1
- package/dist/components/ElementType.js.map +1 -1
- package/dist/components/EmojiPicker.d.ts +2 -3
- package/dist/components/EmojiPicker.d.ts.map +1 -1
- package/dist/components/EmojiPicker.js.map +1 -1
- package/dist/components/EmojiPickerDropdown.d.ts +2 -2
- package/dist/components/EmojiPickerDropdown.d.ts.map +1 -1
- package/dist/components/Feedback.d.ts.map +1 -1
- package/dist/components/Feedback.js +1 -1
- package/dist/components/Feedback.js.map +1 -1
- package/dist/components/Flex.d.ts +4 -3
- package/dist/components/Flex.d.ts.map +1 -1
- package/dist/components/Flex.js +135 -94
- package/dist/components/Flex.js.map +1 -1
- package/dist/components/FocusTrap.d.ts +16 -0
- package/dist/components/FocusTrap.d.ts.map +1 -0
- package/dist/components/FocusTrap.js +82 -0
- package/dist/components/FocusTrap.js.map +1 -0
- package/dist/components/Grid.d.ts +3 -5
- package/dist/components/Grid.d.ts.map +1 -1
- package/dist/components/Grid.js +135 -62
- package/dist/components/Grid.js.map +1 -1
- package/dist/components/HoloFx.js +3 -3
- package/dist/components/HoloFx.js.map +1 -1
- package/dist/components/List.d.ts +11 -0
- package/dist/components/List.d.ts.map +1 -0
- package/dist/components/List.js +15 -0
- package/dist/components/List.js.map +1 -0
- package/dist/components/List.module.scss +30 -0
- package/dist/components/ListItem.d.ts +10 -0
- package/dist/components/ListItem.d.ts.map +1 -0
- package/dist/components/ListItem.js +12 -0
- package/dist/components/ListItem.js.map +1 -0
- package/dist/components/Media.d.ts +3 -1
- package/dist/components/Media.d.ts.map +1 -1
- package/dist/components/Media.js +18 -18
- package/dist/components/Media.js.map +1 -1
- package/dist/components/OgCard.d.ts +9 -10
- package/dist/components/OgCard.d.ts.map +1 -1
- package/dist/components/OgCard.js +43 -29
- package/dist/components/OgCard.js.map +1 -1
- package/dist/components/Option.d.ts +1 -0
- package/dist/components/Option.d.ts.map +1 -1
- package/dist/components/Option.js +52 -13
- package/dist/components/Option.js.map +1 -1
- package/dist/components/Option.module.scss +14 -3
- package/dist/components/ProgressBar.d.ts +15 -0
- package/dist/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/ProgressBar.js +12 -0
- package/dist/components/ProgressBar.js.map +1 -0
- package/dist/components/RevealFx.d.ts +1 -1
- package/dist/components/RevealFx.d.ts.map +1 -1
- package/dist/components/RevealFx.js +3 -0
- package/dist/components/RevealFx.js.map +1 -1
- package/dist/components/RevealFx.module.scss +1 -1
- package/dist/components/Row.d.ts.map +1 -1
- package/dist/components/Row.js +1 -0
- package/dist/components/Row.js.map +1 -1
- package/dist/components/Select.d.ts +3 -2
- package/dist/components/Select.d.ts.map +1 -1
- package/dist/components/Select.js +82 -178
- package/dist/components/Select.js.map +1 -1
- package/dist/components/ServerFlex.d.ts +6 -0
- package/dist/components/ServerFlex.d.ts.map +1 -0
- package/dist/components/ServerFlex.js +123 -0
- package/dist/components/ServerFlex.js.map +1 -0
- package/dist/components/ServerGrid.d.ts +7 -0
- package/dist/components/ServerGrid.d.ts.map +1 -0
- package/dist/components/ServerGrid.js +74 -0
- package/dist/components/ServerGrid.js.map +1 -0
- package/dist/components/StylePanel.js +10 -10
- package/dist/components/StylePanel.js.map +1 -1
- package/dist/components/Switch.js +1 -1
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/ToggleButton.d.ts +1 -1
- package/dist/components/ToggleButton.d.ts.map +1 -1
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +11 -0
- package/dist/components/index.js.map +1 -1
- package/dist/contexts/LayoutContext.d.ts +24 -0
- package/dist/contexts/LayoutContext.d.ts.map +1 -0
- package/dist/contexts/LayoutContext.js +72 -0
- package/dist/contexts/LayoutContext.js.map +1 -0
- package/dist/contexts/index.d.ts +1 -0
- package/dist/contexts/index.d.ts.map +1 -1
- package/dist/contexts/index.js +1 -0
- package/dist/contexts/index.js.map +1 -1
- package/dist/css/styles.css +1 -1
- package/dist/css/styles.css.map +1 -1
- package/dist/data/emoji-data.json +0 -10
- package/dist/hooks/useArrowNavigation.d.ts +23 -0
- package/dist/hooks/useArrowNavigation.d.ts.map +1 -0
- package/dist/hooks/useArrowNavigation.js +208 -0
- package/dist/hooks/useArrowNavigation.js.map +1 -0
- package/dist/hooks/useFetchOg.d.ts.map +1 -1
- package/dist/hooks/useFetchOg.js +8 -0
- package/dist/hooks/useFetchOg.js.map +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +3 -2
- package/dist/icons.js.map +1 -1
- package/dist/interfaces.d.ts +56 -16
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/modules/code/CodeBlock.d.ts.map +1 -1
- package/dist/modules/code/CodeBlock.js +4 -4
- package/dist/modules/code/CodeBlock.js.map +1 -1
- package/dist/modules/data/BarChart.d.ts.map +1 -1
- package/dist/modules/data/BarChart.js +2 -2
- package/dist/modules/data/BarChart.js.map +1 -1
- package/dist/modules/data/ChartHeader.js +1 -1
- package/dist/modules/data/ChartHeader.js.map +1 -1
- package/dist/modules/data/ChartStatus.d.ts +3 -1
- package/dist/modules/data/ChartStatus.d.ts.map +1 -1
- package/dist/modules/data/ChartStatus.js +3 -3
- package/dist/modules/data/ChartStatus.js.map +1 -1
- package/dist/modules/data/DataTooltip.d.ts.map +1 -1
- package/dist/modules/data/DataTooltip.js +2 -22
- package/dist/modules/data/DataTooltip.js.map +1 -1
- package/dist/modules/data/LineBarChart.d.ts.map +1 -1
- package/dist/modules/data/LineBarChart.js +2 -2
- package/dist/modules/data/LineBarChart.js.map +1 -1
- package/dist/modules/data/LineChart.d.ts.map +1 -1
- package/dist/modules/data/LineChart.js +2 -2
- package/dist/modules/data/LineChart.js.map +1 -1
- package/dist/modules/data/PieChart.d.ts.map +1 -1
- package/dist/modules/data/PieChart.js +2 -2
- package/dist/modules/data/PieChart.js.map +1 -1
- package/dist/modules/data/interfaces.d.ts +2 -0
- package/dist/modules/data/interfaces.d.ts.map +1 -1
- package/dist/modules/navigation/HeadingLink.js +1 -1
- package/dist/modules/navigation/HeadingLink.js.map +1 -1
- package/dist/modules/navigation/Kbar.d.ts +2 -0
- package/dist/modules/navigation/Kbar.d.ts.map +1 -1
- package/dist/modules/navigation/Kbar.js +8 -12
- package/dist/modules/navigation/Kbar.js.map +1 -1
- package/dist/modules/navigation/MobileMegaMenu.js +1 -1
- package/dist/modules/navigation/MobileMegaMenu.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/styles/border.scss +10 -0
- package/dist/styles/display.scss +116 -0
- package/dist/styles/flex.scss +305 -6
- package/dist/styles/global.scss +0 -33
- package/dist/styles/grid.scss +110 -24
- package/dist/styles/index.scss +13 -14
- package/dist/styles/position.scss +932 -0
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +102 -100
- package/dist/styles/layout.scss +0 -119
- package/next-env.d.ts +0 -5
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { Flex } from ".";
|
|
6
|
+
export const Cursor = ({ cursor, elementRef }) => {
|
|
7
|
+
const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });
|
|
8
|
+
const [isHovering, setIsHovering] = useState(false);
|
|
9
|
+
const [isTouchDevice, setIsTouchDevice] = useState(false);
|
|
10
|
+
// Detect touch device
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const checkTouchDevice = () => {
|
|
13
|
+
// Check for touch capability
|
|
14
|
+
const hasTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
|
15
|
+
// Check for pointer capability (some devices have both mouse and touch)
|
|
16
|
+
const hasPointer = window.matchMedia('(pointer: fine)').matches;
|
|
17
|
+
// Consider it a touch device if it has touch but no fine pointer (mouse)
|
|
18
|
+
setIsTouchDevice(hasTouch && !hasPointer);
|
|
19
|
+
};
|
|
20
|
+
checkTouchDevice();
|
|
21
|
+
// Listen for changes in pointer capability (e.g., when external mouse is connected)
|
|
22
|
+
const mediaQuery = window.matchMedia('(pointer: fine)');
|
|
23
|
+
const handlePointerChange = () => checkTouchDevice();
|
|
24
|
+
mediaQuery.addEventListener('change', handlePointerChange);
|
|
25
|
+
return () => {
|
|
26
|
+
mediaQuery.removeEventListener('change', handlePointerChange);
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
// Mouse tracking for custom cursor (only on non-touch devices)
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!cursor || !elementRef.current || isTouchDevice)
|
|
32
|
+
return;
|
|
33
|
+
let animationFrameId;
|
|
34
|
+
const handleMouseMove = (e) => {
|
|
35
|
+
// Cancel previous animation frame to prevent multiple updates
|
|
36
|
+
if (animationFrameId) {
|
|
37
|
+
cancelAnimationFrame(animationFrameId);
|
|
38
|
+
}
|
|
39
|
+
// Schedule the update for the next animation frame
|
|
40
|
+
animationFrameId = requestAnimationFrame(() => {
|
|
41
|
+
setMousePosition({ x: e.clientX, y: e.clientY });
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const handleMouseEnter = () => {
|
|
45
|
+
setIsHovering(true);
|
|
46
|
+
};
|
|
47
|
+
const handleMouseLeave = () => {
|
|
48
|
+
setIsHovering(false);
|
|
49
|
+
};
|
|
50
|
+
const element = elementRef.current;
|
|
51
|
+
if (element) {
|
|
52
|
+
element.addEventListener('mouseenter', handleMouseEnter);
|
|
53
|
+
element.addEventListener('mouseleave', handleMouseLeave);
|
|
54
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
55
|
+
}
|
|
56
|
+
return () => {
|
|
57
|
+
if (animationFrameId) {
|
|
58
|
+
cancelAnimationFrame(animationFrameId);
|
|
59
|
+
}
|
|
60
|
+
if (element) {
|
|
61
|
+
element.removeEventListener('mouseenter', handleMouseEnter);
|
|
62
|
+
element.removeEventListener('mouseleave', handleMouseLeave);
|
|
63
|
+
}
|
|
64
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
65
|
+
};
|
|
66
|
+
}, [cursor, elementRef, isTouchDevice]);
|
|
67
|
+
// Don't render custom cursor on touch devices
|
|
68
|
+
if (isTouchDevice || !isHovering)
|
|
69
|
+
return null;
|
|
70
|
+
return createPortal(_jsx(Flex, { position: "fixed", pointerEvents: "none", zIndex: 10, style: {
|
|
71
|
+
left: mousePosition.x,
|
|
72
|
+
top: mousePosition.y,
|
|
73
|
+
transform: 'translate(-50%, -50%)',
|
|
74
|
+
transition: 'none'
|
|
75
|
+
}, children: cursor }), document.body);
|
|
76
|
+
};
|
|
77
|
+
Cursor.displayName = "Cursor";
|
|
78
|
+
export default Cursor;
|
|
79
|
+
//# sourceMappingURL=Cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|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,CAAC,CAAC;YACzC,CAAC;YACD,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;gBAC5D,OAAO,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;YAC9D,CAAC;YACD,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QAC7D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAExC,8CAA8C;IAC9C,IAAI,aAAa,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAE9C,OAAO,YAAY,CACjB,KAAC,IAAI,IACH,QAAQ,EAAC,OAAO,EAChB,aAAa,EAAC,MAAM,EACpB,MAAM,EAAE,EAAE,EACV,KAAK,EAAE;YACL,IAAI,EAAE,aAAa,CAAC,CAAC;YACrB,GAAG,EAAE,aAAa,CAAC,CAAC;YACpB,SAAS,EAAE,uBAAuB;YAClC,UAAU,EAAE,MAAM;SACnB,YAEA,MAAM,GACF,EACP,QAAQ,CAAC,IAAI,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC;AAC9B,eAAe,MAAM,CAAC"}
|
|
@@ -13,7 +13,7 @@ const CursorCard = forwardRef(({ trigger, overlay, placement = "bottom-left", cl
|
|
|
13
13
|
useImperativeHandle(ref, () => cardRef.current);
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
const checkTouchDevice = () => {
|
|
16
|
-
return "ontouchstart" in window
|
|
16
|
+
return "ontouchstart" in window;
|
|
17
17
|
};
|
|
18
18
|
setIsTouchDevice(checkTouchDevice());
|
|
19
19
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorCard.js","sourceRoot":"","sources":["../../src/components/CursorCard.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;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SSProperties;
|
|
12
12
|
timePicker?: boolean;
|
|
13
|
+
minDate?: Date;
|
|
14
|
+
maxDate?: Date;
|
|
13
15
|
}
|
|
14
16
|
export declare const DateInput: React.FC<DateInputProps>;
|
|
15
17
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../src/components/DateInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"DateInput.d.ts","sourceRoot":"","sources":["../../src/components/DateInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,EAA+B,MAAM,GAAG,CAAC;AAEvD,UAAU,cAAe,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;IAC7F,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAiBD,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoF9C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useCallback, useEffect } from "react";
|
|
4
|
-
import { Input, DropdownWrapper,
|
|
4
|
+
import { Input, DropdownWrapper, DatePicker } from ".";
|
|
5
5
|
const formatDate = (date, timePicker) => {
|
|
6
6
|
const options = {
|
|
7
7
|
year: "numeric",
|
|
@@ -15,7 +15,7 @@ const formatDate = (date, timePicker) => {
|
|
|
15
15
|
};
|
|
16
16
|
return date.toLocaleString("en-US", options);
|
|
17
17
|
};
|
|
18
|
-
export const DateInput = ({ id, label, placeholder, value, onChange, error, minHeight, className, style, timePicker = false, ...rest }) => {
|
|
18
|
+
export const DateInput = ({ id, label, placeholder, value, onChange, error, minHeight, className, style, timePicker = false, minDate, maxDate, ...rest }) => {
|
|
19
19
|
const [isOpen, setIsOpen] = useState(false);
|
|
20
20
|
const [inputValue, setInputValue] = useState(value ? formatDate(value, timePicker) : "");
|
|
21
21
|
useEffect(() => {
|
|
@@ -33,10 +33,11 @@ export const DateInput = ({ id, label, placeholder, value, onChange, error, minH
|
|
|
33
33
|
const handleInputClick = useCallback(() => {
|
|
34
34
|
setIsOpen(true);
|
|
35
35
|
}, []);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const handleInputFocus = useCallback(() => {
|
|
37
|
+
setIsOpen(true);
|
|
38
|
+
}, []);
|
|
39
|
+
return (_jsx(DropdownWrapper, { trigger: _jsx(Input, { style: {
|
|
40
|
+
textOverflow: "ellipsis",
|
|
41
|
+
}, id: id, label: label, placeholder: placeholder, value: inputValue, error: error, readOnly: true, onFocus: handleInputFocus, ...rest }), dropdown: _jsx(DatePicker, { padding: "20", value: value, onChange: handleDateChange, timePicker: timePicker, minDate: minDate, maxDate: maxDate, autoFocus: true, isOpen: isOpen }, `datepicker-${isOpen ? 'open' : 'closed'}-${value?.getTime() || 0}`), fillWidth: true, minHeight: minHeight, isOpen: isOpen, onOpenChange: setIsOpen, className: className, closeAfterClick: !timePicker, disableTriggerClick: true, style: { ...style }, handleArrowNavigation: false }));
|
|
41
42
|
};
|
|
42
43
|
//# sourceMappingURL=DateInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../src/components/DateInput.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../src/components/DateInput.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AAgBvD,MAAM,UAAU,GAAG,CAAC,IAAU,EAAE,UAAmB,EAAE,EAAE;IACrD,MAAM,OAAO,GAA+B;QAC1C,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,OAAO;QACd,GAAG,EAAE,SAAS;QACd,GAAG,CAAC,UAAU,IAAI;YAChB,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,KAAK;SACd,CAAC;KACH,CAAC;IAEF,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAA6B,CAAC,EAClD,EAAE,EACF,KAAK,EACL,WAAW,EACX,KAAK,EACL,QAAQ,EACR,KAAK,EACL,SAAS,EACT,SAAS,EACT,KAAK,EACL,UAAU,GAAG,KAAK,EAClB,OAAO,EACP,OAAO,EACP,GAAG,IAAI,EACR,EAAE,EAAE;IACH,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,CAAC,UAAU,EA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,EAAE,KAAK,EACZ,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,IAAI,EACf,MAAM,EAAE,MAAM,IART,cAAc,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,IAAI,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,CASxE,EAEJ,SAAS,QACT,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,EACvB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,CAAC,UAAU,EAC5B,mBAAmB,EAAE,IAAI,EACzB,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,EACnB,qBAAqB,EAAE,KAAK,GAC5B,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -14,6 +14,7 @@ export interface DatePickerProps extends Omit<React.ComponentProps<typeof Flex>,
|
|
|
14
14
|
minutes: number;
|
|
15
15
|
};
|
|
16
16
|
size?: "s" | "m" | "l";
|
|
17
|
+
isNested?: boolean;
|
|
17
18
|
className?: string;
|
|
18
19
|
style?: React.CSSProperties;
|
|
19
20
|
currentMonth?: number;
|
|
@@ -24,6 +25,8 @@ export interface DatePickerProps extends Omit<React.ComponentProps<typeof Flex>,
|
|
|
24
25
|
endDate?: Date;
|
|
25
26
|
};
|
|
26
27
|
onHover?: (date: Date | null) => void;
|
|
28
|
+
autoFocus?: boolean;
|
|
29
|
+
isOpen?: boolean;
|
|
27
30
|
}
|
|
28
31
|
declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
29
32
|
export { DatePicker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../src/components/DatePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":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AC,EAAE,OAAO,CAAC;CAClB;AAED,QAAA,MAAM,UAAU,qGA40Bf,CAAC;AAGF,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,18 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useState, forwardRef, useEffect } from "react";
|
|
3
|
+
import { useState, forwardRef, useEffect, useCallback } from "react";
|
|
4
4
|
import classNames from "classnames";
|
|
5
|
-
import { Flex, Text, Button, Grid, SegmentedControl, IconButton, RevealFx, NumberInput } from ".";
|
|
5
|
+
import { Flex, Text, Button, Grid, SegmentedControl, IconButton, RevealFx, NumberInput, DropdownWrapper, Option, Column, Icon, Row, ArrowNavigation } from ".";
|
|
6
6
|
import styles from "./DatePicker.module.scss";
|
|
7
|
-
const DatePicker = forwardRef(({ value, onChange, timePicker = false, previousMonth = true, nextMonth = true, minDate, maxDate, defaultDate, defaultTime, size = "m", className, style, currentMonth: propCurrentMonth, currentYear: propCurrentYear, onMonthChange, range, onHover, ...rest }, ref) => {
|
|
7
|
+
const DatePicker = forwardRef(({ value, onChange, timePicker = false, previousMonth = true, nextMonth = true, minDate, maxDate, defaultDate, defaultTime, size = "m", isNested = false, className, style, currentMonth: propCurrentMonth, currentYear: propCurrentYear, onMonthChange, range, onHover, autoFocus = false, isOpen, ...rest }, ref) => {
|
|
8
8
|
const today = new Date();
|
|
9
9
|
const [selectedDate, setSelectedDate] = useState(value);
|
|
10
10
|
const [selectedTime, setSelectedTime] = useState(defaultTime);
|
|
11
11
|
const [isPM, setIsPM] = useState(defaultTime?.hours ? defaultTime.hours >= 12 : false);
|
|
12
12
|
const [isTimeSelector, setIsTimeSelector] = useState(false);
|
|
13
13
|
const [isTransitioning, setIsTransitioning] = useState(true);
|
|
14
|
+
const [isMonthOpen, setIsMonthOpen] = useState(false);
|
|
15
|
+
const [isYearOpen, setIsYearOpen] = useState(false);
|
|
16
|
+
const [isReady, setIsReady] = useState(false);
|
|
17
|
+
const [hoveredDate, setHoveredDate] = useState(null);
|
|
14
18
|
const [currentMonth, setCurrentMonth] = useState(value ? value.getMonth() : today.getMonth());
|
|
15
19
|
const [currentYear, setCurrentYear] = useState(value ? value.getFullYear() : today.getFullYear());
|
|
20
|
+
// Calculate the initial focused index based on the selected date
|
|
21
|
+
const calculateInitialFocusedIndex = useCallback(() => {
|
|
22
|
+
if (!selectedDate || isTimeSelector)
|
|
23
|
+
return 0;
|
|
24
|
+
// Find the exact button that matches the selected date
|
|
25
|
+
const container = document.querySelector('[data-role="dropdown-portal"]') ||
|
|
26
|
+
document.querySelector('[data-dropdown-id]') ||
|
|
27
|
+
document.activeElement?.closest('[data-role="dropdown-portal"]') ||
|
|
28
|
+
document.activeElement?.closest('[data-role="dropdown-wrapper"]') ||
|
|
29
|
+
document.body;
|
|
30
|
+
if (container) {
|
|
31
|
+
const enabledButtons = Array.from(container.querySelectorAll('button[data-value]:not([disabled])'));
|
|
32
|
+
const selectedButtonIndex = enabledButtons.findIndex(button => {
|
|
33
|
+
const buttonDate = new Date(button.getAttribute('data-value') || '');
|
|
34
|
+
return buttonDate.getTime() === selectedDate.getTime();
|
|
35
|
+
});
|
|
36
|
+
if (selectedButtonIndex !== -1) {
|
|
37
|
+
return selectedButtonIndex;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Fallback to day-based calculation
|
|
41
|
+
const selectedDay = selectedDate.getDate();
|
|
42
|
+
const firstDayOfWeek = new Date(currentYear, currentMonth, 1).getDay();
|
|
43
|
+
const offset = firstDayOfWeek;
|
|
44
|
+
const dayIndex = offset + selectedDay - 1;
|
|
45
|
+
return Math.max(0, dayIndex);
|
|
46
|
+
}, [selectedDate, isTimeSelector, currentMonth, currentYear]);
|
|
47
|
+
// Calculate the total number of days to display in the grid
|
|
48
|
+
const calculateTotalDays = () => {
|
|
49
|
+
const daysInMonth = new Date(currentYear, currentMonth + 1, 0).getDate();
|
|
50
|
+
// Since we're only selecting enabled buttons (current month days),
|
|
51
|
+
// the total is just the number of days in the current month
|
|
52
|
+
return daysInMonth;
|
|
53
|
+
};
|
|
16
54
|
useEffect(() => {
|
|
17
55
|
if (typeof propCurrentMonth === "number") {
|
|
18
56
|
setCurrentMonth(propCurrentMonth);
|
|
@@ -21,6 +59,33 @@ const DatePicker = forwardRef(({ value, onChange, timePicker = false, previousMo
|
|
|
21
59
|
setCurrentYear(propCurrentYear);
|
|
22
60
|
}
|
|
23
61
|
}, [propCurrentMonth, propCurrentYear]);
|
|
62
|
+
// Track if calendar is synced to selected value
|
|
63
|
+
const [isCalendarSynced, setIsCalendarSynced] = useState(false);
|
|
64
|
+
// Sync currentMonth/currentYear to value on mount and when value changes
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
// Reset calendar sync to ensure proper re-sync
|
|
67
|
+
setIsCalendarSynced(false);
|
|
68
|
+
if (value) {
|
|
69
|
+
setCurrentMonth(value.getMonth());
|
|
70
|
+
setCurrentYear(value.getFullYear());
|
|
71
|
+
// Small delay to ensure state updates are processed
|
|
72
|
+
const timer = setTimeout(() => {
|
|
73
|
+
setIsCalendarSynced(true);
|
|
74
|
+
}, 0);
|
|
75
|
+
return () => clearTimeout(timer);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
setIsCalendarSynced(true);
|
|
79
|
+
}
|
|
80
|
+
}, [value]);
|
|
81
|
+
// Additional sync effect that runs when the component becomes ready
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (isReady && value && !isCalendarSynced) {
|
|
84
|
+
setCurrentMonth(value.getMonth());
|
|
85
|
+
setCurrentYear(value.getFullYear());
|
|
86
|
+
setIsCalendarSynced(true);
|
|
87
|
+
}
|
|
88
|
+
}, [isReady, value, isCalendarSynced]);
|
|
24
89
|
useEffect(() => {
|
|
25
90
|
setSelectedDate(value);
|
|
26
91
|
if (value) {
|
|
@@ -29,14 +94,48 @@ const DatePicker = forwardRef(({ value, onChange, timePicker = false, previousMo
|
|
|
29
94
|
minutes: value.getMinutes(),
|
|
30
95
|
});
|
|
31
96
|
setIsPM(value.getHours() >= 12);
|
|
97
|
+
// Update current month/year to match the selected date
|
|
98
|
+
setCurrentMonth(value.getMonth());
|
|
99
|
+
setCurrentYear(value.getFullYear());
|
|
32
100
|
}
|
|
33
101
|
}, [value]);
|
|
34
102
|
useEffect(() => {
|
|
35
103
|
const timer = setTimeout(() => {
|
|
36
104
|
setIsTransitioning(true);
|
|
105
|
+
setIsReady(true);
|
|
37
106
|
}, 100);
|
|
38
107
|
return () => clearTimeout(timer);
|
|
39
108
|
}, []);
|
|
109
|
+
// Effect to ensure proper highlighting when component mounts or selected date changes
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (selectedDate && !isTimeSelector && isReady) {
|
|
112
|
+
// Only highlight if the current month/year matches the selected date's month/year
|
|
113
|
+
if (selectedDate.getMonth() === currentMonth && selectedDate.getFullYear() === currentYear) {
|
|
114
|
+
// Small delay to ensure the DOM is ready
|
|
115
|
+
const timer = setTimeout(() => {
|
|
116
|
+
const container = document.querySelector('[data-role="dropdown-portal"]') ||
|
|
117
|
+
document.querySelector('[data-dropdown-id]') ||
|
|
118
|
+
document.activeElement?.closest('[data-role="dropdown-portal"]') ||
|
|
119
|
+
document.activeElement?.closest('[data-role="dropdown-wrapper"]') ||
|
|
120
|
+
document.body; // Fallback for standalone DatePicker
|
|
121
|
+
if (container) {
|
|
122
|
+
// Find the selected date button and focus it
|
|
123
|
+
const enabledButtons = Array.from(container.querySelectorAll('button[data-value]:not([disabled])'));
|
|
124
|
+
// Find the button that matches the selected date
|
|
125
|
+
const selectedButton = enabledButtons.find(button => {
|
|
126
|
+
const buttonDate = new Date(button.getAttribute('data-value') || '');
|
|
127
|
+
return buttonDate.getTime() === selectedDate.getTime();
|
|
128
|
+
});
|
|
129
|
+
if (selectedButton) {
|
|
130
|
+
// Focus the button without scrolling
|
|
131
|
+
selectedButton.focus({ preventScroll: true });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, 50);
|
|
135
|
+
return () => clearTimeout(timer);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, [selectedDate, isTimeSelector, isReady, currentMonth, currentYear, isOpen]);
|
|
40
139
|
const monthNames = [
|
|
41
140
|
"January",
|
|
42
141
|
"February",
|
|
@@ -94,6 +193,35 @@ const DatePicker = forwardRef(({ value, onChange, timePicker = false, previousMo
|
|
|
94
193
|
}
|
|
95
194
|
}
|
|
96
195
|
};
|
|
196
|
+
const handleMonthSelect = (monthIndex) => {
|
|
197
|
+
setCurrentMonth(monthIndex);
|
|
198
|
+
};
|
|
199
|
+
const handleYearSelect = (year) => {
|
|
200
|
+
setCurrentYear(year);
|
|
201
|
+
};
|
|
202
|
+
const generateYearOptions = () => {
|
|
203
|
+
const currentYearNum = new Date().getFullYear();
|
|
204
|
+
const minYear = minDate ? minDate.getFullYear() : currentYearNum - 10;
|
|
205
|
+
const maxYear = maxDate ? maxDate.getFullYear() : currentYearNum + 10;
|
|
206
|
+
const years = [];
|
|
207
|
+
for (let i = minYear; i <= maxYear; i++) {
|
|
208
|
+
years.push(i);
|
|
209
|
+
}
|
|
210
|
+
return years;
|
|
211
|
+
};
|
|
212
|
+
const isMonthDisabled = (monthIndex, year) => {
|
|
213
|
+
if (!minDate && !maxDate)
|
|
214
|
+
return false;
|
|
215
|
+
const startOfMonth = new Date(year, monthIndex, 1);
|
|
216
|
+
const endOfMonth = new Date(year, monthIndex + 1, 0); // Last day of month
|
|
217
|
+
// If the entire month is before the minimum date
|
|
218
|
+
if (minDate && endOfMonth < minDate)
|
|
219
|
+
return true;
|
|
220
|
+
// If the entire month is after the maximum date
|
|
221
|
+
if (maxDate && startOfMonth > maxDate)
|
|
222
|
+
return true;
|
|
223
|
+
return false;
|
|
224
|
+
};
|
|
97
225
|
const convert24to12 = (hour24) => {
|
|
98
226
|
if (hour24 === 0)
|
|
99
227
|
return 12;
|
|
@@ -134,46 +262,175 @@ const DatePicker = forwardRef(({ value, onChange, timePicker = false, previousMo
|
|
|
134
262
|
// Previous month's days
|
|
135
263
|
for (let i = 0; i < firstDay; i++) {
|
|
136
264
|
const prevMonthDay = daysInPrevMonth - firstDay + i + 1;
|
|
137
|
-
days.push(_jsx(Flex, {
|
|
265
|
+
days.push(_jsx(Flex, { width: size === "s" ? "32" : size === "m" ? "40" : "48", height: size === "s" ? "32" : size === "m" ? "40" : "48", children: _jsx(Button, { fillWidth: true, weight: "default", variant: "tertiary", radius: firstDay === 1 ? undefined : i === 0 ? "left" : i === firstDay - 1 ? "right" : "none", size: size, type: "button", disabled: true, children: prevMonthDay }) }, `prev-${currentYear}-${currentMonth}-${i}`));
|
|
138
266
|
}
|
|
139
267
|
// Current month's days
|
|
140
268
|
for (let day = 1; day <= daysInMonth; day++) {
|
|
269
|
+
// Create date consistently - normalize to midnight in local timezone
|
|
141
270
|
const currentDate = new Date(currentYear, currentMonth, day);
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
selectedDate
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
range?.
|
|
271
|
+
const normalizedCurrentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
|
|
272
|
+
const isSelected = selectedDate ? ((selectedDate.getDate() === day &&
|
|
273
|
+
selectedDate.getMonth() === currentMonth &&
|
|
274
|
+
selectedDate.getFullYear() === currentYear) ||
|
|
275
|
+
(value instanceof Date && value.getTime() === normalizedCurrentDate.getTime()) ||
|
|
276
|
+
range?.startDate?.getTime() === normalizedCurrentDate.getTime() ||
|
|
277
|
+
range?.endDate?.getTime() === normalizedCurrentDate.getTime()) : false;
|
|
278
|
+
// Check if this date is being hovered
|
|
279
|
+
const isHovered = hoveredDate ? (hoveredDate.getDate() === day &&
|
|
280
|
+
hoveredDate.getMonth() === currentMonth &&
|
|
281
|
+
hoveredDate.getFullYear() === currentYear) : false;
|
|
148
282
|
const isFirstInRange = range?.startDate && currentDate.getTime() === range.startDate.getTime();
|
|
149
283
|
const isLastInRange = range?.endDate && currentDate.getTime() === range.endDate.getTime();
|
|
150
284
|
// Check if the current date is out of the minDate and maxDate range
|
|
151
285
|
const isDisabled = (minDate && currentDate < minDate) || (maxDate && currentDate > maxDate);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
286
|
+
// Calculate border radius for disabled days
|
|
287
|
+
let disabledRadius = undefined;
|
|
288
|
+
if (isDisabled) {
|
|
289
|
+
// Find consecutive disabled days
|
|
290
|
+
let consecutiveDisabledStart = day;
|
|
291
|
+
let consecutiveDisabledEnd = day;
|
|
292
|
+
// Look backwards for start of consecutive disabled days
|
|
293
|
+
while (consecutiveDisabledStart > 1) {
|
|
294
|
+
const prevDate = new Date(currentYear, currentMonth, consecutiveDisabledStart - 1);
|
|
295
|
+
const isPrevDisabled = (minDate && prevDate < minDate) || (maxDate && prevDate > maxDate);
|
|
296
|
+
if (isPrevDisabled) {
|
|
297
|
+
consecutiveDisabledStart--;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// Look forwards for end of consecutive disabled days
|
|
304
|
+
while (consecutiveDisabledEnd < daysInMonth) {
|
|
305
|
+
const nextDate = new Date(currentYear, currentMonth, consecutiveDisabledEnd + 1);
|
|
306
|
+
const isNextDisabled = (minDate && nextDate < minDate) || (maxDate && nextDate > maxDate);
|
|
307
|
+
if (isNextDisabled) {
|
|
308
|
+
consecutiveDisabledEnd++;
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const totalConsecutiveDisabled = consecutiveDisabledEnd - consecutiveDisabledStart + 1;
|
|
315
|
+
if (totalConsecutiveDisabled === 1) {
|
|
316
|
+
disabledRadius = undefined;
|
|
317
|
+
}
|
|
318
|
+
else if (day === consecutiveDisabledStart) {
|
|
319
|
+
disabledRadius = "left";
|
|
320
|
+
}
|
|
321
|
+
else if (day === consecutiveDisabledEnd) {
|
|
322
|
+
disabledRadius = "right";
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
disabledRadius = "none";
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
days.push(_jsx(Row, { width: size === "s" ? "32" : size === "m" ? "40" : "48", height: size === "s" ? "32" : size === "m" ? "40" : "48", background: isInRange(currentDate) ? "neutral-alpha-weak" : undefined, borderTop: isInRange(currentDate) ? "neutral-alpha-weak" : "transparent", borderBottom: isInRange(currentDate) ? "neutral-alpha-weak" : "transparent", leftRadius: isFirstInRange ? "m" : undefined, rightRadius: isLastInRange ? "m" : undefined, children: _jsx(Button, { fillWidth: true, weight: isSelected ? "strong" : "default", variant: isSelected ? "primary" : isHovered ? "secondary" : "tertiary", radius: disabledRadius, tabIndex: -1, size: size, "data-value": currentDate.toISOString(), onClick: (e) => {
|
|
329
|
+
if (!isDisabled) {
|
|
330
|
+
if (timePicker) {
|
|
331
|
+
// Stop propagation to prevent DropdownWrapper from closing
|
|
332
|
+
e.stopPropagation();
|
|
159
333
|
}
|
|
160
|
-
|
|
334
|
+
handleDateSelect(currentDate);
|
|
335
|
+
}
|
|
336
|
+
}, onMouseEnter: (e) => {
|
|
337
|
+
onHover?.(currentDate);
|
|
338
|
+
setHoveredDate(currentDate);
|
|
339
|
+
}, onMouseLeave: () => {
|
|
340
|
+
onHover?.(null);
|
|
341
|
+
setHoveredDate(null);
|
|
342
|
+
}, disabled: isDisabled, children: day }) }, `day-${currentYear}-${currentMonth}-${day}`));
|
|
161
343
|
}
|
|
162
344
|
const remainingDays = totalGridSpots - days.length;
|
|
163
345
|
for (let i = 1; i <= remainingDays; i++) {
|
|
164
|
-
days.push(_jsx(
|
|
346
|
+
days.push(_jsx(Row, { marginTop: "2", width: size === "s" ? "32" : size === "m" ? "40" : "48", height: size === "s" ? "32" : size === "m" ? "40" : "48", children: _jsx(Button, { fillWidth: true, weight: "default", variant: "tertiary", radius: remainingDays === 1 ? undefined : i === 1 ? "left" : i === remainingDays ? "right" : "none", size: size, type: "button", disabled: true, children: i }) }, `next-${currentYear}-${currentMonth}-${i}`));
|
|
165
347
|
}
|
|
166
348
|
return days;
|
|
167
349
|
};
|
|
168
|
-
return (_jsxs(
|
|
350
|
+
return (_jsxs(Column, { onClick: (event) => {
|
|
351
|
+
event.preventDefault();
|
|
352
|
+
event.stopPropagation();
|
|
353
|
+
// Close any open nested dropdowns when clicking on the DatePicker background
|
|
354
|
+
if (isMonthOpen) {
|
|
355
|
+
setIsMonthOpen(false);
|
|
356
|
+
}
|
|
357
|
+
if (isYearOpen) {
|
|
358
|
+
setIsYearOpen(false);
|
|
359
|
+
}
|
|
360
|
+
}, ref: ref, className: classNames(styles.calendar, className), style: style, fillWidth: true, horizontal: "center", gap: size, ...rest, children: [_jsx(Flex, { fillWidth: true, center: true, children: isTimeSelector ? (_jsxs(Column, { horizontal: "center", fillWidth: true, gap: "8", children: [_jsxs(Text, { variant: `label-default-${size}`, onBackground: "neutral-strong", children: [monthNames[currentMonth], " ", currentYear] }), _jsx(Row, { paddingX: "2", cursor: "interactive", textVariant: "label-default-s", radius: "m", onBackground: "brand-weak", tabIndex: 0, onClick: () => handleTimeToggle(false), onKeyDown: (e) => {
|
|
361
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
362
|
+
e.preventDefault();
|
|
363
|
+
handleTimeToggle(false);
|
|
364
|
+
}
|
|
365
|
+
}, role: "button", "aria-label": "Back to calendar", children: "Back to calendar" })] })) : (_jsxs(_Fragment, { children: [previousMonth && (_jsx(IconButton, { variant: "tertiary", size: size, icon: "chevronLeft", onClick: (event) => {
|
|
169
366
|
event.preventDefault();
|
|
170
367
|
event.stopPropagation();
|
|
171
368
|
handleMonthChange(-1);
|
|
172
|
-
} })), _jsxs(
|
|
369
|
+
} })), _jsxs(Column, { fillWidth: true, horizontal: "center", gap: "8", children: [_jsxs(Row, { gap: "4", horizontal: "center", children: [_jsx(DropdownWrapper, { isNested: isNested, placement: "bottom-start", isOpen: isMonthOpen, dropdownId: "month-dropdown", onOpenChange: (open) => {
|
|
370
|
+
setIsMonthOpen(open);
|
|
371
|
+
// Update global tracking for keyboard navigation
|
|
372
|
+
if (open) {
|
|
373
|
+
// Set this as the last opened dropdown
|
|
374
|
+
window.lastOpenedDropdown = 'month-dropdown';
|
|
375
|
+
}
|
|
376
|
+
else if (window.lastOpenedDropdown === 'month-dropdown') {
|
|
377
|
+
window.lastOpenedDropdown = null;
|
|
378
|
+
}
|
|
379
|
+
}, trigger: _jsx(Button, { onClick: (event) => {
|
|
380
|
+
event.preventDefault();
|
|
381
|
+
event.stopPropagation();
|
|
382
|
+
setIsMonthOpen(true);
|
|
383
|
+
// Update global tracking
|
|
384
|
+
window.lastOpenedDropdown = 'month-dropdown';
|
|
385
|
+
}, variant: "secondary", size: "s", children: _jsxs(Row, { vertical: "center", gap: "4", children: [monthNames[currentMonth], _jsx(Icon, { name: "chevronDown", onBackground: "neutral-weak", size: "xs" })] }) }), dropdown: _jsx(Column, { fillWidth: true, gap: "2", padding: "4", onClick: (event) => {
|
|
386
|
+
event.preventDefault();
|
|
387
|
+
event.stopPropagation();
|
|
388
|
+
}, children: monthNames.map((month, index) => {
|
|
389
|
+
const monthDisabled = isMonthDisabled(index, currentYear);
|
|
390
|
+
return (_jsx(Option, { value: index.toString(), disabled: monthDisabled, label: _jsx(Text, { color: monthDisabled ? "neutral-weak" : undefined, children: month }), selected: index === currentMonth, onClick: (value) => {
|
|
391
|
+
if (!monthDisabled) {
|
|
392
|
+
handleMonthSelect(index);
|
|
393
|
+
setIsMonthOpen(false);
|
|
394
|
+
// Clear global tracking
|
|
395
|
+
window.lastOpenedDropdown = null;
|
|
396
|
+
}
|
|
397
|
+
} }, month));
|
|
398
|
+
}) }), "data-dropdown-id": "month-dropdown" }), _jsx(DropdownWrapper, { navigationLayout: "grid", optionsCount: generateYearOptions().length, columns: generateYearOptions().length < 6 ? 1 : 6, isNested: isNested, isOpen: isYearOpen, dropdownId: "year-dropdown", onOpenChange: (open) => {
|
|
399
|
+
setIsYearOpen(open);
|
|
400
|
+
// Update global tracking for keyboard navigation
|
|
401
|
+
if (open) {
|
|
402
|
+
// Set this as the last opened dropdown
|
|
403
|
+
window.lastOpenedDropdown = 'year-dropdown';
|
|
404
|
+
}
|
|
405
|
+
else if (window.lastOpenedDropdown === 'year-dropdown') {
|
|
406
|
+
window.lastOpenedDropdown = null;
|
|
407
|
+
}
|
|
408
|
+
}, placement: "bottom-start", trigger: _jsx(Button, { variant: "secondary", size: "s", onClick: (event) => {
|
|
409
|
+
event.preventDefault();
|
|
410
|
+
event.stopPropagation();
|
|
411
|
+
setIsYearOpen(true);
|
|
412
|
+
// Update global tracking
|
|
413
|
+
window.lastOpenedDropdown = 'year-dropdown';
|
|
414
|
+
}, children: _jsxs(Row, { vertical: "center", gap: "4", children: [currentYear.toString(), _jsx(Icon, { name: "chevronDown", onBackground: "neutral-weak", size: "xs" })] }) }), dropdown: _jsx(Grid, { columns: generateYearOptions().length < 6 ? "1" : 6, gap: "2", padding: "4", onClick: (event) => {
|
|
415
|
+
event.preventDefault();
|
|
416
|
+
event.stopPropagation();
|
|
417
|
+
}, children: generateYearOptions().map((year) => {
|
|
418
|
+
// Check if all months in this year are disabled
|
|
419
|
+
const allMonthsDisabled = Array.from({ length: 12 }, (_, i) => i)
|
|
420
|
+
.every(month => isMonthDisabled(month, year));
|
|
421
|
+
return (_jsx(Option, { value: year.toString(), disabled: allMonthsDisabled, label: _jsx(Text, { color: allMonthsDisabled ? "neutral-weak" : undefined, children: year }), selected: year === currentYear, onClick: (value) => {
|
|
422
|
+
if (!allMonthsDisabled) {
|
|
423
|
+
handleYearSelect(year);
|
|
424
|
+
setIsYearOpen(false);
|
|
425
|
+
// Clear global tracking
|
|
426
|
+
window.lastOpenedDropdown = null;
|
|
427
|
+
}
|
|
428
|
+
} }, year));
|
|
429
|
+
}) }), "data-dropdown-id": "year-dropdown" })] }), timePicker && selectedTime && (_jsx(Text, { variant: "label-default-s", onBackground: "neutral-weak", children: `${selectedTime.hours.toString().padStart(2, "0")}:${selectedTime.minutes.toString().padStart(2, "0")} ${isPM ? "PM" : "AM"}` }))] }), nextMonth && (_jsx(IconButton, { variant: "tertiary", size: size, icon: "chevronRight", onClick: (event) => {
|
|
173
430
|
event.preventDefault();
|
|
174
431
|
event.stopPropagation();
|
|
175
432
|
handleMonthChange(1);
|
|
176
|
-
} }))] })) }), _jsx(RevealFx, { fillWidth: true,
|
|
433
|
+
} }))] })) }), _jsx(RevealFx, { fillWidth: true, center: true, trigger: isTransitioning, speed: 250, children: isTimeSelector ? (_jsxs(Column, { maxWidth: 24, center: true, padding: "32", gap: "32", children: [_jsx(SegmentedControl, { buttons: [
|
|
177
434
|
{
|
|
178
435
|
value: "AM",
|
|
179
436
|
label: "AM",
|
|
@@ -190,7 +447,24 @@ const DatePicker = forwardRef(({ value, onChange, timePicker = false, previousMo
|
|
|
190
447
|
if (value >= 0 && value <= 59) {
|
|
191
448
|
handleTimeChange(selectedTime?.hours ?? 0, value);
|
|
192
449
|
}
|
|
193
|
-
}, "aria-label": "Minutes" })] })] })) : (_jsxs(Grid, { fitWidth: true, columns: "7", children: [dayNames.map((day) => (_jsx(Text, { marginBottom: "16", variant: "label-default-m", onBackground: "neutral-medium", align: "center", children: day }, day))), renderCalendarGrid()] }))
|
|
450
|
+
}, "aria-label": "Minutes" })] })] })) : (isMonthOpen || isYearOpen ? (_jsxs(Grid, { fitWidth: true, columns: "7", children: [dayNames.map((day) => (_jsx(Text, { marginBottom: "16", variant: "label-default-m", onBackground: "neutral-medium", align: "center", children: day }, day))), renderCalendarGrid()] })) : (isCalendarSynced && (_jsx(ArrowNavigation, { layout: "grid", columns: 7, itemCount: calculateTotalDays(), initialFocusedIndex: isReady ? calculateInitialFocusedIndex() : 0, wrap: true, itemSelector: 'button[data-value]:not([disabled])', role: "grid", "aria-label": "Calendar", disableHighlighting: true, autoFocus: autoFocus, onSelect: (index) => {
|
|
451
|
+
// Find the actual button element at this index and click it
|
|
452
|
+
// Try multiple selectors for different scenarios (dropdown vs standalone)
|
|
453
|
+
const container = document.querySelector('[data-role="dropdown-portal"]') ||
|
|
454
|
+
document.querySelector('[data-dropdown-id]') ||
|
|
455
|
+
document.activeElement?.closest('[data-role="dropdown-portal"]') ||
|
|
456
|
+
document.activeElement?.closest('[data-role="dropdown-wrapper"]') ||
|
|
457
|
+
document.body; // Fallback for standalone DatePicker
|
|
458
|
+
if (container) {
|
|
459
|
+
const buttons = Array.from(container.querySelectorAll('button[data-value]:not([disabled])'));
|
|
460
|
+
if (buttons[index]) {
|
|
461
|
+
buttons[index].click();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}, onFocusChange: (index) => {
|
|
465
|
+
// Let React handle highlighting through props only
|
|
466
|
+
// No DOM manipulation needed
|
|
467
|
+
}, children: _jsxs(Grid, { fitWidth: true, columns: "7", children: [dayNames.map((day) => (_jsx(Text, { marginBottom: "16", variant: "label-default-m", onBackground: "neutral-medium", align: "center", children: day }, day))), renderCalendarGrid()] }) }, `calendar-${currentYear}-${currentMonth}-${selectedDate?.getTime() || 0}`)))) }, isTimeSelector ? "time" : "date")] }));
|
|
194
468
|
});
|
|
195
469
|
DatePicker.displayName = "DatePicker";
|
|
196
470
|
export { DatePicker };
|