tekivex-ui 2.5.15 → 2.6.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/charts.cjs +1 -1
- package/dist/charts.js +22 -553
- package/dist/chunk-B3ph66Zb.js +1 -0
- package/dist/chunk-Bc16rJT-.js +1 -0
- package/dist/chunk-Dike2DLU.js +3 -0
- package/dist/chunk-DjxOP8W4.js +1 -0
- package/dist/chunk-DkoFTL1O.js +1 -0
- package/dist/chunk-DmRB1Blb.js +1 -0
- package/dist/chunk-DnCXUUx5.js +1 -0
- package/dist/chunk-LWkKqC8d.js +1 -0
- package/dist/chunk-PJ50l0JC.js +1 -0
- package/dist/headless.cjs +1 -1
- package/dist/headless.js +1 -442
- package/dist/i18n.cjs +1 -1
- package/dist/i18n.js +1 -733
- package/dist/index.cjs +1 -152
- package/dist/index.d.ts +4 -2
- package/dist/index.js +429 -16786
- package/dist/quantum.cjs +1 -89
- package/dist/quantum.js +74 -2551
- package/dist/realtime.cjs +1 -23
- package/dist/realtime.js +1 -804
- package/dist/src/a11y/index.d.ts +0 -1
- package/dist/src/charts/TkxAreaChart.d.ts +0 -5
- package/dist/src/charts/TkxBarChart.d.ts +0 -3
- package/dist/src/charts/TkxDonutChart.d.ts +0 -5
- package/dist/src/charts/TkxLineChart.d.ts +0 -1
- package/dist/src/charts/TkxPieChart.d.ts +0 -3
- package/dist/src/charts/TkxRadarChart.d.ts +0 -3
- package/dist/src/charts/TkxScatterChart.d.ts +0 -2
- package/dist/src/charts/index.d.ts +0 -1
- package/dist/src/charts/shared.d.ts +0 -3
- package/dist/src/components/TkxAIChatBubble.d.ts +0 -9
- package/dist/src/components/TkxAIConfidenceBar.d.ts +0 -6
- package/dist/src/components/TkxAIThinking.d.ts +0 -6
- package/dist/src/components/TkxAccordion.d.ts +0 -1
- package/dist/src/components/TkxAffix.d.ts +0 -1
- package/dist/src/components/TkxAlert.d.ts +0 -1
- package/dist/src/components/TkxAnchor.d.ts +0 -1
- package/dist/src/components/TkxAppBar.d.ts +0 -1
- package/dist/src/components/TkxAutocomplete.d.ts +0 -1
- package/dist/src/components/TkxAvatar.d.ts +0 -1
- package/dist/src/components/TkxBadge.d.ts +0 -1
- package/dist/src/components/TkxBottomNav.d.ts +0 -1
- package/dist/src/components/TkxBreadcrumb.d.ts +0 -1
- package/dist/src/components/TkxButton.d.ts +0 -1
- package/dist/src/components/TkxCard.d.ts +0 -1
- package/dist/src/components/TkxCarousel.d.ts +0 -1
- package/dist/src/components/TkxCascader.d.ts +0 -1
- package/dist/src/components/TkxChat.d.ts +0 -1
- package/dist/src/components/TkxCheckbox.d.ts +0 -1
- package/dist/src/components/TkxClock.d.ts +0 -1
- package/dist/src/components/TkxColorPicker.d.ts +0 -1
- package/dist/src/components/TkxCommand.d.ts +0 -1
- package/dist/src/components/TkxConfigProvider.d.ts +0 -30
- package/dist/src/components/TkxDataGrid.d.ts +0 -15
- package/dist/src/components/TkxDatePicker.d.ts +0 -1
- package/dist/src/components/TkxDivider.d.ts +0 -1
- package/dist/src/components/TkxDrawer.d.ts +0 -1
- package/dist/src/components/TkxDropdown.d.ts +0 -1
- package/dist/src/components/TkxEmpty.d.ts +0 -1
- package/dist/src/components/TkxFileUpload.d.ts +0 -1
- package/dist/src/components/TkxForm.d.ts +0 -35
- package/dist/src/components/TkxIcon.d.ts +0 -1
- package/dist/src/components/TkxImage.d.ts +0 -1
- package/dist/src/components/TkxInput.d.ts +1 -1
- package/dist/src/components/TkxLayout.d.ts +0 -22
- package/dist/src/components/TkxList.d.ts +0 -1
- package/dist/src/components/TkxLiveFeed.d.ts +0 -1
- package/dist/src/components/TkxLiveLog.d.ts +0 -1
- package/dist/src/components/TkxLiveMetrics.d.ts +0 -1
- package/dist/src/components/TkxLogo.d.ts +0 -1
- package/dist/src/components/TkxMarkdown.d.ts +0 -10
- package/dist/src/components/TkxMasonry.d.ts +0 -1
- package/dist/src/components/TkxMentions.d.ts +0 -1
- package/dist/src/components/TkxMenu.d.ts +0 -1
- package/dist/src/components/TkxModal.d.ts +0 -1
- package/dist/src/components/TkxNumberInput.d.ts +0 -1
- package/dist/src/components/TkxOTP.d.ts +0 -1
- package/dist/src/components/TkxOrgChart.d.ts +32 -0
- package/dist/src/components/TkxPagination.d.ts +0 -1
- package/dist/src/components/TkxPlayground.d.ts +0 -13
- package/dist/src/components/TkxPopover.d.ts +0 -1
- package/dist/src/components/TkxProgress.d.ts +0 -1
- package/dist/src/components/TkxQRCode.d.ts +0 -1
- package/dist/src/components/TkxQuantumForm.d.ts +0 -1
- package/dist/src/components/TkxRadio.d.ts +0 -1
- package/dist/src/components/TkxRating.d.ts +0 -1
- package/dist/src/components/TkxRealTimeChart.d.ts +0 -1
- package/dist/src/components/TkxResult.d.ts +0 -1
- package/dist/src/components/TkxRichTextDisplay.d.ts +0 -1
- package/dist/src/components/TkxSegmented.d.ts +0 -1
- package/dist/src/components/TkxSelect.d.ts +0 -3
- package/dist/src/components/TkxSkeleton.d.ts +0 -1
- package/dist/src/components/TkxSlider.d.ts +0 -1
- package/dist/src/components/TkxSnackbar.d.ts +0 -1
- package/dist/src/components/TkxSpeedDial.d.ts +0 -1
- package/dist/src/components/TkxSpin.d.ts +0 -1
- package/dist/src/components/TkxStatistic.d.ts +0 -1
- package/dist/src/components/TkxStepper.d.ts +0 -1
- package/dist/src/components/TkxTable.d.ts +0 -1
- package/dist/src/components/TkxTabs.d.ts +0 -1
- package/dist/src/components/TkxTag.d.ts +0 -1
- package/dist/src/components/TkxThemeBuilder.d.ts +0 -1
- package/dist/src/components/TkxTimeline.d.ts +0 -1
- package/dist/src/components/TkxToast.d.ts +0 -1
- package/dist/src/components/TkxToggle.d.ts +0 -1
- package/dist/src/components/TkxToolbar.d.ts +0 -1
- package/dist/src/components/TkxTooltip.d.ts +0 -1
- package/dist/src/components/TkxTour.d.ts +0 -1
- package/dist/src/components/TkxTransferList.d.ts +0 -1
- package/dist/src/components/TkxTreeView.d.ts +0 -1
- package/dist/src/components/TkxTypography.d.ts +0 -1
- package/dist/src/components/TkxVideoPlayer.d.ts +0 -1
- package/dist/src/components/TkxWatermark.d.ts +0 -1
- package/dist/src/components/index.d.ts +1 -1
- package/dist/src/engine/css.d.ts +0 -1
- package/dist/src/engine/index.d.ts +0 -1
- package/dist/src/engine/quantum-ai.d.ts +0 -73
- package/dist/src/engine/quantum.d.ts +0 -1
- package/dist/src/engine/security.d.ts +45 -9
- package/dist/src/engine/tkx.d.ts +0 -53
- package/dist/src/engine/wcag.d.ts +0 -1
- package/dist/src/headless/index.d.ts +0 -1
- package/dist/src/headless/useControllable.d.ts +0 -15
- package/dist/src/headless/useDebounce.d.ts +0 -12
- package/dist/src/headless/useDisclosure.d.ts +0 -13
- package/dist/src/headless/useFormState.d.ts +0 -13
- package/dist/src/headless/useInfiniteQuery.d.ts +0 -11
- package/dist/src/headless/useIntersectionObserver.d.ts +0 -10
- package/dist/src/headless/useListSelection.d.ts +0 -9
- package/dist/src/headless/useLocalStorage.d.ts +0 -8
- package/dist/src/headless/useMediaQuery.d.ts +0 -10
- package/dist/src/headless/useRovingTabIndex.d.ts +0 -15
- package/dist/src/headless/useSSE.d.ts +0 -9
- package/dist/src/headless/useThrottle.d.ts +0 -7
- package/dist/src/headless/useWebSocket.d.ts +0 -9
- package/dist/src/hooks/index.d.ts +0 -1
- package/dist/src/i18n/I18nProvider.d.ts +0 -1
- package/dist/src/i18n/index.d.ts +0 -1
- package/dist/src/quantum/index.d.ts +0 -1
- package/dist/src/realtime/index.d.ts +0 -1
- package/dist/src/themes/index.d.ts +0 -1
- package/package.json +5 -3
- package/dist/TkxForm-BaO4wvXt.js +0 -320
- package/dist/TkxForm-M6ttomry.cjs +0 -12
- package/dist/chunk-Bmb41Sf3.cjs +0 -1
- package/dist/hooks-6pRsPOyG.js +0 -58
- package/dist/hooks-mivgRljH.cjs +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/src/a11y/index.d.ts.map +0 -1
- package/dist/src/charts/TkxAreaChart.d.ts.map +0 -1
- package/dist/src/charts/TkxBarChart.d.ts.map +0 -1
- package/dist/src/charts/TkxDonutChart.d.ts.map +0 -1
- package/dist/src/charts/TkxLineChart.d.ts.map +0 -1
- package/dist/src/charts/TkxPieChart.d.ts.map +0 -1
- package/dist/src/charts/TkxRadarChart.d.ts.map +0 -1
- package/dist/src/charts/TkxScatterChart.d.ts.map +0 -1
- package/dist/src/charts/index.d.ts.map +0 -1
- package/dist/src/charts/shared.d.ts.map +0 -1
- package/dist/src/components/TkxAIChatBubble.d.ts.map +0 -1
- package/dist/src/components/TkxAIConfidenceBar.d.ts.map +0 -1
- package/dist/src/components/TkxAIThinking.d.ts.map +0 -1
- package/dist/src/components/TkxAccordion.d.ts.map +0 -1
- package/dist/src/components/TkxAffix.d.ts.map +0 -1
- package/dist/src/components/TkxAlert.d.ts.map +0 -1
- package/dist/src/components/TkxAnchor.d.ts.map +0 -1
- package/dist/src/components/TkxAppBar.d.ts.map +0 -1
- package/dist/src/components/TkxAutocomplete.d.ts.map +0 -1
- package/dist/src/components/TkxAvatar.d.ts.map +0 -1
- package/dist/src/components/TkxBadge.d.ts.map +0 -1
- package/dist/src/components/TkxBottomNav.d.ts.map +0 -1
- package/dist/src/components/TkxBreadcrumb.d.ts.map +0 -1
- package/dist/src/components/TkxButton.d.ts.map +0 -1
- package/dist/src/components/TkxCard.d.ts.map +0 -1
- package/dist/src/components/TkxCarousel.d.ts.map +0 -1
- package/dist/src/components/TkxCascader.d.ts.map +0 -1
- package/dist/src/components/TkxChat.d.ts.map +0 -1
- package/dist/src/components/TkxCheckbox.d.ts.map +0 -1
- package/dist/src/components/TkxClock.d.ts.map +0 -1
- package/dist/src/components/TkxColorPicker.d.ts.map +0 -1
- package/dist/src/components/TkxCommand.d.ts.map +0 -1
- package/dist/src/components/TkxConfigProvider.d.ts.map +0 -1
- package/dist/src/components/TkxDataGrid.d.ts.map +0 -1
- package/dist/src/components/TkxDatePicker.d.ts.map +0 -1
- package/dist/src/components/TkxDivider.d.ts.map +0 -1
- package/dist/src/components/TkxDrawer.d.ts.map +0 -1
- package/dist/src/components/TkxDropdown.d.ts.map +0 -1
- package/dist/src/components/TkxEmpty.d.ts.map +0 -1
- package/dist/src/components/TkxFileUpload.d.ts.map +0 -1
- package/dist/src/components/TkxForm.d.ts.map +0 -1
- package/dist/src/components/TkxIcon.d.ts.map +0 -1
- package/dist/src/components/TkxImage.d.ts.map +0 -1
- package/dist/src/components/TkxInput.d.ts.map +0 -1
- package/dist/src/components/TkxLayout.d.ts.map +0 -1
- package/dist/src/components/TkxList.d.ts.map +0 -1
- package/dist/src/components/TkxLiveFeed.d.ts.map +0 -1
- package/dist/src/components/TkxLiveLog.d.ts.map +0 -1
- package/dist/src/components/TkxLiveMetrics.d.ts.map +0 -1
- package/dist/src/components/TkxLogo.d.ts.map +0 -1
- package/dist/src/components/TkxMarkdown.d.ts.map +0 -1
- package/dist/src/components/TkxMasonry.d.ts.map +0 -1
- package/dist/src/components/TkxMentions.d.ts.map +0 -1
- package/dist/src/components/TkxMenu.d.ts.map +0 -1
- package/dist/src/components/TkxModal.d.ts.map +0 -1
- package/dist/src/components/TkxNumberInput.d.ts.map +0 -1
- package/dist/src/components/TkxOTP.d.ts.map +0 -1
- package/dist/src/components/TkxPagination.d.ts.map +0 -1
- package/dist/src/components/TkxPlayground.d.ts.map +0 -1
- package/dist/src/components/TkxPopover.d.ts.map +0 -1
- package/dist/src/components/TkxProgress.d.ts.map +0 -1
- package/dist/src/components/TkxQRCode.d.ts.map +0 -1
- package/dist/src/components/TkxQuantumForm.d.ts.map +0 -1
- package/dist/src/components/TkxRadio.d.ts.map +0 -1
- package/dist/src/components/TkxRating.d.ts.map +0 -1
- package/dist/src/components/TkxRealTimeChart.d.ts.map +0 -1
- package/dist/src/components/TkxResult.d.ts.map +0 -1
- package/dist/src/components/TkxRichTextDisplay.d.ts.map +0 -1
- package/dist/src/components/TkxSegmented.d.ts.map +0 -1
- package/dist/src/components/TkxSelect.d.ts.map +0 -1
- package/dist/src/components/TkxSkeleton.d.ts.map +0 -1
- package/dist/src/components/TkxSlider.d.ts.map +0 -1
- package/dist/src/components/TkxSnackbar.d.ts.map +0 -1
- package/dist/src/components/TkxSpeedDial.d.ts.map +0 -1
- package/dist/src/components/TkxSpin.d.ts.map +0 -1
- package/dist/src/components/TkxStatistic.d.ts.map +0 -1
- package/dist/src/components/TkxStepper.d.ts.map +0 -1
- package/dist/src/components/TkxTable.d.ts.map +0 -1
- package/dist/src/components/TkxTabs.d.ts.map +0 -1
- package/dist/src/components/TkxTag.d.ts.map +0 -1
- package/dist/src/components/TkxThemeBuilder.d.ts.map +0 -1
- package/dist/src/components/TkxTimeline.d.ts.map +0 -1
- package/dist/src/components/TkxToast.d.ts.map +0 -1
- package/dist/src/components/TkxToggle.d.ts.map +0 -1
- package/dist/src/components/TkxToolbar.d.ts.map +0 -1
- package/dist/src/components/TkxTooltip.d.ts.map +0 -1
- package/dist/src/components/TkxTour.d.ts.map +0 -1
- package/dist/src/components/TkxTransferList.d.ts.map +0 -1
- package/dist/src/components/TkxTreeView.d.ts.map +0 -1
- package/dist/src/components/TkxTypography.d.ts.map +0 -1
- package/dist/src/components/TkxVideoPlayer.d.ts.map +0 -1
- package/dist/src/components/TkxWatermark.d.ts.map +0 -1
- package/dist/src/components/index.d.ts.map +0 -1
- package/dist/src/engine/css.d.ts.map +0 -1
- package/dist/src/engine/index.d.ts.map +0 -1
- package/dist/src/engine/quantum-ai.d.ts.map +0 -1
- package/dist/src/engine/quantum.d.ts.map +0 -1
- package/dist/src/engine/security.d.ts.map +0 -1
- package/dist/src/engine/tkx.d.ts.map +0 -1
- package/dist/src/engine/wcag.d.ts.map +0 -1
- package/dist/src/headless/index.d.ts.map +0 -1
- package/dist/src/headless/useControllable.d.ts.map +0 -1
- package/dist/src/headless/useDebounce.d.ts.map +0 -1
- package/dist/src/headless/useDisclosure.d.ts.map +0 -1
- package/dist/src/headless/useFormState.d.ts.map +0 -1
- package/dist/src/headless/useInfiniteQuery.d.ts.map +0 -1
- package/dist/src/headless/useIntersectionObserver.d.ts.map +0 -1
- package/dist/src/headless/useListSelection.d.ts.map +0 -1
- package/dist/src/headless/useLocalStorage.d.ts.map +0 -1
- package/dist/src/headless/useMediaQuery.d.ts.map +0 -1
- package/dist/src/headless/useRovingTabIndex.d.ts.map +0 -1
- package/dist/src/headless/useSSE.d.ts.map +0 -1
- package/dist/src/headless/useThrottle.d.ts.map +0 -1
- package/dist/src/headless/useWebSocket.d.ts.map +0 -1
- package/dist/src/hooks/index.d.ts.map +0 -1
- package/dist/src/i18n/I18nProvider.d.ts.map +0 -1
- package/dist/src/i18n/index.d.ts.map +0 -1
- package/dist/src/quantum/index.d.ts.map +0 -1
- package/dist/src/realtime/index.d.ts.map +0 -1
- package/dist/src/themes/index.d.ts.map +0 -1
- package/dist/themes-BbJanqiC.js +0 -498
- package/dist/themes-CMq2vWXj.cjs +0 -2
- package/dist/tkx-BoP5V5zy.cjs +0 -4
- package/dist/tkx-mOKMzvUK.js +0 -1174
- package/src/a11y/index.tsx +0 -87
- package/src/charts/TkxAreaChart.tsx +0 -121
- package/src/charts/TkxBarChart.tsx +0 -117
- package/src/charts/TkxDonutChart.tsx +0 -164
- package/src/charts/TkxLineChart.tsx +0 -137
- package/src/charts/TkxPieChart.tsx +0 -103
- package/src/charts/TkxRadarChart.tsx +0 -92
- package/src/charts/TkxScatterChart.tsx +0 -104
- package/src/charts/index.ts +0 -22
- package/src/charts/shared.ts +0 -47
- package/src/components/TkxAIChatBubble.tsx +0 -256
- package/src/components/TkxAIConfidenceBar.tsx +0 -133
- package/src/components/TkxAIThinking.tsx +0 -193
- package/src/components/TkxAccordion.tsx +0 -590
- package/src/components/TkxAffix.tsx +0 -140
- package/src/components/TkxAlert.tsx +0 -94
- package/src/components/TkxAnchor.tsx +0 -195
- package/src/components/TkxAppBar.tsx +0 -262
- package/src/components/TkxAutocomplete.tsx +0 -455
- package/src/components/TkxAvatar.tsx +0 -103
- package/src/components/TkxBadge.tsx +0 -75
- package/src/components/TkxBottomNav.tsx +0 -241
- package/src/components/TkxBreadcrumb.tsx +0 -324
- package/src/components/TkxButton.tsx +0 -155
- package/src/components/TkxCard.tsx +0 -96
- package/src/components/TkxCarousel.tsx +0 -554
- package/src/components/TkxCascader.tsx +0 -278
- package/src/components/TkxChat.tsx +0 -356
- package/src/components/TkxCheckbox.tsx +0 -220
- package/src/components/TkxClock.tsx +0 -603
- package/src/components/TkxColorPicker.tsx +0 -635
- package/src/components/TkxCommand.tsx +0 -646
- package/src/components/TkxConfigProvider.tsx +0 -460
- package/src/components/TkxDataGrid.tsx +0 -941
- package/src/components/TkxDatePicker.tsx +0 -1625
- package/src/components/TkxDivider.tsx +0 -51
- package/src/components/TkxDrawer.tsx +0 -236
- package/src/components/TkxDropdown.tsx +0 -804
- package/src/components/TkxEmpty.tsx +0 -221
- package/src/components/TkxFileUpload.tsx +0 -373
- package/src/components/TkxForm.tsx +0 -683
- package/src/components/TkxIcon.tsx +0 -685
- package/src/components/TkxImage.tsx +0 -279
- package/src/components/TkxInput.tsx +0 -103
- package/src/components/TkxLayout.tsx +0 -649
- package/src/components/TkxList.tsx +0 -244
- package/src/components/TkxLiveFeed.tsx +0 -331
- package/src/components/TkxLiveLog.tsx +0 -472
- package/src/components/TkxLiveMetrics.tsx +0 -315
- package/src/components/TkxLogo.tsx +0 -299
- package/src/components/TkxMarkdown.tsx +0 -855
- package/src/components/TkxMasonry.tsx +0 -178
- package/src/components/TkxMentions.tsx +0 -212
- package/src/components/TkxMenu.tsx +0 -1044
- package/src/components/TkxModal.tsx +0 -122
- package/src/components/TkxNumberInput.tsx +0 -410
- package/src/components/TkxOTP.tsx +0 -297
- package/src/components/TkxPagination.tsx +0 -390
- package/src/components/TkxPlayground.tsx +0 -845
- package/src/components/TkxPopover.tsx +0 -297
- package/src/components/TkxProgress.tsx +0 -114
- package/src/components/TkxQRCode.tsx +0 -176
- package/src/components/TkxQuantumForm.tsx +0 -594
- package/src/components/TkxRadio.tsx +0 -286
- package/src/components/TkxRating.tsx +0 -288
- package/src/components/TkxRealTimeChart.tsx +0 -383
- package/src/components/TkxResult.tsx +0 -130
- package/src/components/TkxRichTextDisplay.tsx +0 -396
- package/src/components/TkxSegmented.tsx +0 -171
- package/src/components/TkxSelect.tsx +0 -1130
- package/src/components/TkxSkeleton.tsx +0 -107
- package/src/components/TkxSlider.tsx +0 -495
- package/src/components/TkxSnackbar.tsx +0 -316
- package/src/components/TkxSpeedDial.tsx +0 -397
- package/src/components/TkxSpin.tsx +0 -263
- package/src/components/TkxStatistic.tsx +0 -263
- package/src/components/TkxStepper.tsx +0 -487
- package/src/components/TkxTable.tsx +0 -424
- package/src/components/TkxTabs.tsx +0 -126
- package/src/components/TkxTag.tsx +0 -321
- package/src/components/TkxThemeBuilder.tsx +0 -687
- package/src/components/TkxTimeline.tsx +0 -305
- package/src/components/TkxToast.tsx +0 -287
- package/src/components/TkxToggle.tsx +0 -95
- package/src/components/TkxToolbar.tsx +0 -262
- package/src/components/TkxTooltip.tsx +0 -85
- package/src/components/TkxTour.tsx +0 -241
- package/src/components/TkxTransferList.tsx +0 -489
- package/src/components/TkxTreeView.tsx +0 -423
- package/src/components/TkxTypography.tsx +0 -267
- package/src/components/TkxVideoPlayer.tsx +0 -1015
- package/src/components/TkxWatermark.tsx +0 -145
- package/src/components/index.ts +0 -80
- package/src/engine/css.ts +0 -126
- package/src/engine/index.ts +0 -12
- package/src/engine/quantum-ai.ts +0 -1045
- package/src/engine/quantum.ts +0 -207
- package/src/engine/security.ts +0 -232
- package/src/engine/tkx.ts +0 -1084
- package/src/engine/wcag.ts +0 -276
- package/src/headless/index.ts +0 -52
- package/src/headless/useControllable.ts +0 -42
- package/src/headless/useDebounce.ts +0 -37
- package/src/headless/useDisclosure.ts +0 -30
- package/src/headless/useFormState.ts +0 -113
- package/src/headless/useInfiniteQuery.ts +0 -155
- package/src/headless/useIntersectionObserver.ts +0 -53
- package/src/headless/useListSelection.ts +0 -103
- package/src/headless/useLocalStorage.ts +0 -48
- package/src/headless/useMediaQuery.ts +0 -39
- package/src/headless/useRovingTabIndex.ts +0 -86
- package/src/headless/useSSE.ts +0 -167
- package/src/headless/useThrottle.ts +0 -48
- package/src/headless/useWebSocket.ts +0 -231
- package/src/hooks/index.ts +0 -122
- package/src/i18n/I18nProvider.tsx +0 -36
- package/src/i18n/index.ts +0 -877
- package/src/quantum/index.ts +0 -39
- package/src/realtime/index.ts +0 -21
- package/src/styles/global.css +0 -167
- package/src/themes/index.ts +0 -294
|
@@ -1,1625 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useState,
|
|
5
|
-
useRef,
|
|
6
|
-
useEffect,
|
|
7
|
-
useCallback,
|
|
8
|
-
useId,
|
|
9
|
-
useReducer,
|
|
10
|
-
type CSSProperties,
|
|
11
|
-
type KeyboardEvent,
|
|
12
|
-
} from 'react';
|
|
13
|
-
import { createPortal } from 'react-dom';
|
|
14
|
-
import { useTheme } from '../themes';
|
|
15
|
-
import { sanitizeString } from '../engine/security';
|
|
16
|
-
import { useReducedMotion } from '../hooks';
|
|
17
|
-
|
|
18
|
-
// ── Types ─────────────────────────────────────────────────────────────────────
|
|
19
|
-
|
|
20
|
-
export type DatePickerMode = 'single' | 'range' | 'multiple';
|
|
21
|
-
export type DatePickerView = 'day' | 'month' | 'year';
|
|
22
|
-
|
|
23
|
-
export interface DatePreset {
|
|
24
|
-
label: string;
|
|
25
|
-
getValue: () => [Date, Date];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface TkxDatePickerProps {
|
|
29
|
-
// Value
|
|
30
|
-
value?: Date | null;
|
|
31
|
-
onChange?: (date: Date | null) => void;
|
|
32
|
-
rangeValue?: [Date | null, Date | null];
|
|
33
|
-
onRangeChange?: (range: [Date | null, Date | null]) => void;
|
|
34
|
-
multiValue?: Date[];
|
|
35
|
-
onMultiChange?: (dates: Date[]) => void;
|
|
36
|
-
|
|
37
|
-
// Config
|
|
38
|
-
mode?: DatePickerMode;
|
|
39
|
-
minDate?: Date;
|
|
40
|
-
maxDate?: Date;
|
|
41
|
-
disabledDates?: Date[] | ((date: Date) => boolean);
|
|
42
|
-
locale?: string;
|
|
43
|
-
dateFormat?: string;
|
|
44
|
-
|
|
45
|
-
// Time picker
|
|
46
|
-
showTime?: boolean;
|
|
47
|
-
timeValue?: { h: number; m: number };
|
|
48
|
-
onTimeChange?: (time: { h: number; m: number }) => void;
|
|
49
|
-
|
|
50
|
-
// Presets
|
|
51
|
-
showPresets?: boolean;
|
|
52
|
-
customPresets?: DatePreset[];
|
|
53
|
-
|
|
54
|
-
// UI
|
|
55
|
-
label?: string;
|
|
56
|
-
placeholder?: string;
|
|
57
|
-
hint?: string;
|
|
58
|
-
isDisabled?: boolean;
|
|
59
|
-
isInvalid?: boolean;
|
|
60
|
-
errorMessage?: string;
|
|
61
|
-
numberOfMonths?: number;
|
|
62
|
-
|
|
63
|
-
id?: string;
|
|
64
|
-
className?: string;
|
|
65
|
-
style?: CSSProperties;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ── Constants ─────────────────────────────────────────────────────────────────
|
|
69
|
-
|
|
70
|
-
const DAYS_SHORT = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
71
|
-
const MONTH_NAMES = [
|
|
72
|
-
'January', 'February', 'March', 'April', 'May', 'June',
|
|
73
|
-
'July', 'August', 'September', 'October', 'November', 'December',
|
|
74
|
-
];
|
|
75
|
-
const MONTH_ABBR = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
76
|
-
|
|
77
|
-
// ── Date helpers ──────────────────────────────────────────────────────────────
|
|
78
|
-
|
|
79
|
-
function isSameDay(a: Date, b: Date): boolean {
|
|
80
|
-
return (
|
|
81
|
-
a.getFullYear() === b.getFullYear() &&
|
|
82
|
-
a.getMonth() === b.getMonth() &&
|
|
83
|
-
a.getDate() === b.getDate()
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function startOfDay(d: Date): Date {
|
|
88
|
-
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function isInRange(d: Date, start: Date | null, end: Date | null): boolean {
|
|
92
|
-
if (!start || !end) return false;
|
|
93
|
-
const t = startOfDay(d).getTime();
|
|
94
|
-
const s = startOfDay(start).getTime();
|
|
95
|
-
const e = startOfDay(end).getTime();
|
|
96
|
-
const lo = Math.min(s, e);
|
|
97
|
-
const hi = Math.max(s, e);
|
|
98
|
-
return t > lo && t < hi;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function isRangeEndpoint(d: Date, start: Date | null, end: Date | null): boolean {
|
|
102
|
-
if (start && isSameDay(d, start)) return true;
|
|
103
|
-
if (end && isSameDay(d, end)) return true;
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Format a date using either a custom token-based `dateFormat` string
|
|
109
|
-
* (e.g. "YYYY-MM-DD", "DD/MM/YYYY", "MMM D, YYYY") or fall back to the
|
|
110
|
-
* locale's 2-digit date style.
|
|
111
|
-
*
|
|
112
|
-
* Supported tokens: YYYY, YY, MMMM, MMM, MM, M, DD, D.
|
|
113
|
-
*/
|
|
114
|
-
function formatDate(
|
|
115
|
-
d: Date | null | undefined,
|
|
116
|
-
locale = 'en-US',
|
|
117
|
-
dateFormat?: string,
|
|
118
|
-
): string {
|
|
119
|
-
if (!d) return '';
|
|
120
|
-
if (dateFormat) {
|
|
121
|
-
const yyyy = String(d.getFullYear());
|
|
122
|
-
const yy = yyyy.slice(-2);
|
|
123
|
-
const M = d.getMonth() + 1;
|
|
124
|
-
const MM = String(M).padStart(2, '0');
|
|
125
|
-
const MMM = MONTH_ABBR[d.getMonth()];
|
|
126
|
-
const MMMM = MONTH_NAMES[d.getMonth()];
|
|
127
|
-
const D = d.getDate();
|
|
128
|
-
const DD = String(D).padStart(2, '0');
|
|
129
|
-
// Order matters: longest tokens first so "MM" doesn't clobber "MMM".
|
|
130
|
-
return dateFormat
|
|
131
|
-
.replace(/YYYY/g, yyyy)
|
|
132
|
-
.replace(/YY/g, yy)
|
|
133
|
-
.replace(/MMMM/g, MMMM)
|
|
134
|
-
.replace(/MMM/g, MMM)
|
|
135
|
-
.replace(/MM/g, MM)
|
|
136
|
-
.replace(/\bM\b/g, String(M))
|
|
137
|
-
.replace(/DD/g, DD)
|
|
138
|
-
.replace(/\bD\b/g, String(D));
|
|
139
|
-
}
|
|
140
|
-
return d.toLocaleDateString(locale, { month: '2-digit', day: '2-digit', year: 'numeric' });
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Parse a date string. Accepts US MM/DD/YYYY and common ISO-ish shapes
|
|
145
|
-
* (YYYY-MM-DD, DD/MM/YYYY, D/M/YYYY). If `dateFormat` is supplied and the
|
|
146
|
-
* input doesn't match any format, we attempt a token-driven parse.
|
|
147
|
-
*/
|
|
148
|
-
function parseDate(str: string, dateFormat?: string): Date | null {
|
|
149
|
-
// MM/DD/YYYY (legacy default)
|
|
150
|
-
const us = str.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
151
|
-
if (us) {
|
|
152
|
-
const [, m, d, y] = us.map(Number);
|
|
153
|
-
if (m >= 1 && m <= 12 && d >= 1 && d <= 31) {
|
|
154
|
-
const date = new Date(y, m - 1, d);
|
|
155
|
-
if (date.getMonth() === m - 1) return date;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// YYYY-MM-DD
|
|
159
|
-
const iso = str.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);
|
|
160
|
-
if (iso) {
|
|
161
|
-
const [, y, m, d] = iso.map(Number);
|
|
162
|
-
const date = new Date(y, m - 1, d);
|
|
163
|
-
if (date.getMonth() === m - 1) return date;
|
|
164
|
-
}
|
|
165
|
-
// DD/MM/YYYY when user explicitly asked for a DD-first format
|
|
166
|
-
if (dateFormat && /^DD/.test(dateFormat)) {
|
|
167
|
-
const eu = str.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
|
|
168
|
-
if (eu) {
|
|
169
|
-
const [, d, m, y] = eu.map(Number);
|
|
170
|
-
const date = new Date(y, m - 1, d);
|
|
171
|
-
if (date.getMonth() === m - 1) return date;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return null;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function getDaysInMonth(year: number, month: number): number {
|
|
178
|
-
return new Date(year, month + 1, 0).getDate();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function getCalendarGrid(year: number, month: number): Date[] {
|
|
182
|
-
const firstDay = new Date(year, month, 1).getDay();
|
|
183
|
-
const daysInMonth = getDaysInMonth(year, month);
|
|
184
|
-
const cells: Date[] = [];
|
|
185
|
-
|
|
186
|
-
// Previous month tail
|
|
187
|
-
const prevDays = getDaysInMonth(year, month - 1);
|
|
188
|
-
for (let i = firstDay - 1; i >= 0; i--) {
|
|
189
|
-
cells.push(new Date(year, month - 1, prevDays - i));
|
|
190
|
-
}
|
|
191
|
-
// Current month
|
|
192
|
-
for (let d = 1; d <= daysInMonth; d++) {
|
|
193
|
-
cells.push(new Date(year, month, d));
|
|
194
|
-
}
|
|
195
|
-
// Next month head
|
|
196
|
-
let nextDay = 1;
|
|
197
|
-
while (cells.length < 42) {
|
|
198
|
-
cells.push(new Date(year, month + 1, nextDay++));
|
|
199
|
-
}
|
|
200
|
-
return cells;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function getDecadeStart(year: number): number {
|
|
204
|
-
return Math.floor(year / 10) * 10;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// ── Built-in presets ──────────────────────────────────────────────────────────
|
|
208
|
-
|
|
209
|
-
function buildBuiltinPresets(): DatePreset[] {
|
|
210
|
-
return [
|
|
211
|
-
{
|
|
212
|
-
label: 'Today',
|
|
213
|
-
getValue: () => {
|
|
214
|
-
const t = startOfDay(new Date());
|
|
215
|
-
return [t, t];
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
label: 'Yesterday',
|
|
220
|
-
getValue: () => {
|
|
221
|
-
const y = startOfDay(new Date());
|
|
222
|
-
y.setDate(y.getDate() - 1);
|
|
223
|
-
return [y, y];
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
label: 'Last 7 days',
|
|
228
|
-
getValue: () => {
|
|
229
|
-
const end = startOfDay(new Date());
|
|
230
|
-
const start = new Date(end);
|
|
231
|
-
start.setDate(start.getDate() - 6);
|
|
232
|
-
return [start, end];
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
label: 'Last 30 days',
|
|
237
|
-
getValue: () => {
|
|
238
|
-
const end = startOfDay(new Date());
|
|
239
|
-
const start = new Date(end);
|
|
240
|
-
start.setDate(start.getDate() - 29);
|
|
241
|
-
return [start, end];
|
|
242
|
-
},
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
label: 'Last 90 days',
|
|
246
|
-
getValue: () => {
|
|
247
|
-
const end = startOfDay(new Date());
|
|
248
|
-
const start = new Date(end);
|
|
249
|
-
start.setDate(start.getDate() - 89);
|
|
250
|
-
return [start, end];
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
label: 'This week',
|
|
255
|
-
getValue: () => {
|
|
256
|
-
const today = startOfDay(new Date());
|
|
257
|
-
const start = new Date(today);
|
|
258
|
-
start.setDate(start.getDate() - start.getDay());
|
|
259
|
-
const end = new Date(start);
|
|
260
|
-
end.setDate(end.getDate() + 6);
|
|
261
|
-
return [start, end];
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
label: 'Last week',
|
|
266
|
-
getValue: () => {
|
|
267
|
-
const today = startOfDay(new Date());
|
|
268
|
-
const end = new Date(today);
|
|
269
|
-
end.setDate(end.getDate() - end.getDay() - 1);
|
|
270
|
-
const start = new Date(end);
|
|
271
|
-
start.setDate(start.getDate() - 6);
|
|
272
|
-
return [start, end];
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
label: 'This month',
|
|
277
|
-
getValue: () => {
|
|
278
|
-
const t = new Date();
|
|
279
|
-
return [
|
|
280
|
-
new Date(t.getFullYear(), t.getMonth(), 1),
|
|
281
|
-
new Date(t.getFullYear(), t.getMonth() + 1, 0),
|
|
282
|
-
];
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
label: 'Last month',
|
|
287
|
-
getValue: () => {
|
|
288
|
-
const t = new Date();
|
|
289
|
-
return [
|
|
290
|
-
new Date(t.getFullYear(), t.getMonth() - 1, 1),
|
|
291
|
-
new Date(t.getFullYear(), t.getMonth(), 0),
|
|
292
|
-
];
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
label: 'This quarter',
|
|
297
|
-
getValue: () => {
|
|
298
|
-
const t = new Date();
|
|
299
|
-
const q = Math.floor(t.getMonth() / 3);
|
|
300
|
-
return [
|
|
301
|
-
new Date(t.getFullYear(), q * 3, 1),
|
|
302
|
-
new Date(t.getFullYear(), q * 3 + 3, 0),
|
|
303
|
-
];
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
label: 'Last quarter',
|
|
308
|
-
getValue: () => {
|
|
309
|
-
const t = new Date();
|
|
310
|
-
const q = Math.floor(t.getMonth() / 3);
|
|
311
|
-
const prevQ = q === 0 ? 3 : q - 1;
|
|
312
|
-
const prevY = q === 0 ? t.getFullYear() - 1 : t.getFullYear();
|
|
313
|
-
return [
|
|
314
|
-
new Date(prevY, prevQ * 3, 1),
|
|
315
|
-
new Date(prevY, prevQ * 3 + 3, 0),
|
|
316
|
-
];
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
label: 'This year',
|
|
321
|
-
getValue: () => {
|
|
322
|
-
const y = new Date().getFullYear();
|
|
323
|
-
return [new Date(y, 0, 1), new Date(y, 11, 31)];
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
label: 'Last year',
|
|
328
|
-
getValue: () => {
|
|
329
|
-
const y = new Date().getFullYear() - 1;
|
|
330
|
-
return [new Date(y, 0, 1), new Date(y, 11, 31)];
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
];
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// ── Portal helper ─────────────────────────────────────────────────────────────
|
|
337
|
-
|
|
338
|
-
interface PopupPosition {
|
|
339
|
-
top: number;
|
|
340
|
-
left: number;
|
|
341
|
-
flipUp: boolean;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
function getPopupPosition(
|
|
345
|
-
anchorEl: HTMLElement,
|
|
346
|
-
popupHeight: number,
|
|
347
|
-
): PopupPosition {
|
|
348
|
-
const rect = anchorEl.getBoundingClientRect();
|
|
349
|
-
const viewportH = window.innerHeight;
|
|
350
|
-
const scrollY = window.scrollY;
|
|
351
|
-
const scrollX = window.scrollX;
|
|
352
|
-
|
|
353
|
-
const spaceBelow = viewportH - rect.bottom;
|
|
354
|
-
const flipUp = spaceBelow < popupHeight + 8 && rect.top > popupHeight + 8;
|
|
355
|
-
|
|
356
|
-
return {
|
|
357
|
-
top: flipUp
|
|
358
|
-
? scrollY + rect.top - popupHeight - 4
|
|
359
|
-
: scrollY + rect.bottom + 4,
|
|
360
|
-
left: scrollX + rect.left,
|
|
361
|
-
flipUp,
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// ── Time Picker Column ────────────────────────────────────────────────────────
|
|
366
|
-
|
|
367
|
-
interface TimeColumnProps {
|
|
368
|
-
values: number[];
|
|
369
|
-
selected: number;
|
|
370
|
-
onSelect: (v: number) => void;
|
|
371
|
-
label: string;
|
|
372
|
-
theme: ReturnType<typeof import('../themes').useTheme>;
|
|
373
|
-
format?: (v: number) => string;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
function TimeColumn({ values, selected, onSelect, label, theme, format }: TimeColumnProps) {
|
|
377
|
-
const itemRefs = useRef<(HTMLButtonElement | null)[]>([]);
|
|
378
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
379
|
-
|
|
380
|
-
useEffect(() => {
|
|
381
|
-
const el = itemRefs.current[selected];
|
|
382
|
-
if (el && containerRef.current) {
|
|
383
|
-
el.scrollIntoView({ block: 'nearest' });
|
|
384
|
-
}
|
|
385
|
-
}, [selected]);
|
|
386
|
-
|
|
387
|
-
const fmt = format ?? ((v: number) => String(v).padStart(2, '0'));
|
|
388
|
-
|
|
389
|
-
return (
|
|
390
|
-
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '4px' }}>
|
|
391
|
-
<div style={{ fontSize: '11px', fontWeight: 600, color: theme.textMuted, textTransform: 'uppercase', letterSpacing: '0.05em' }}>
|
|
392
|
-
{label}
|
|
393
|
-
</div>
|
|
394
|
-
<div
|
|
395
|
-
ref={containerRef}
|
|
396
|
-
style={{
|
|
397
|
-
height: '160px',
|
|
398
|
-
overflowY: 'auto',
|
|
399
|
-
width: '52px',
|
|
400
|
-
scrollbarWidth: 'thin',
|
|
401
|
-
border: `1px solid ${theme.border}`,
|
|
402
|
-
borderRadius: '8px',
|
|
403
|
-
padding: '4px',
|
|
404
|
-
}}
|
|
405
|
-
>
|
|
406
|
-
{values.map((v) => {
|
|
407
|
-
const isSelected = v === selected;
|
|
408
|
-
return (
|
|
409
|
-
<button
|
|
410
|
-
key={v}
|
|
411
|
-
ref={(el) => { itemRefs.current[v] = el; }}
|
|
412
|
-
type="button"
|
|
413
|
-
onClick={() => onSelect(v)}
|
|
414
|
-
style={{
|
|
415
|
-
display: 'flex',
|
|
416
|
-
alignItems: 'center',
|
|
417
|
-
justifyContent: 'center',
|
|
418
|
-
width: '100%',
|
|
419
|
-
height: '32px',
|
|
420
|
-
borderRadius: '6px',
|
|
421
|
-
border: 'none',
|
|
422
|
-
cursor: 'pointer',
|
|
423
|
-
fontSize: '13px',
|
|
424
|
-
fontWeight: isSelected ? 600 : 400,
|
|
425
|
-
backgroundColor: isSelected ? theme.primary : 'transparent',
|
|
426
|
-
color: isSelected ? theme.bg : theme.text,
|
|
427
|
-
fontFamily: 'monospace',
|
|
428
|
-
transition: 'background-color 100ms ease',
|
|
429
|
-
}}
|
|
430
|
-
>
|
|
431
|
-
{fmt(v)}
|
|
432
|
-
</button>
|
|
433
|
-
);
|
|
434
|
-
})}
|
|
435
|
-
</div>
|
|
436
|
-
</div>
|
|
437
|
-
);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
// ── Calendar Month Grid ───────────────────────────────────────────────────────
|
|
441
|
-
|
|
442
|
-
interface CalendarMonthProps {
|
|
443
|
-
year: number;
|
|
444
|
-
month: number;
|
|
445
|
-
today: Date;
|
|
446
|
-
mode: DatePickerMode;
|
|
447
|
-
selectedDate: Date | null;
|
|
448
|
-
selectedRange: [Date | null, Date | null];
|
|
449
|
-
multiDates: Date[];
|
|
450
|
-
hoverDate: Date | null;
|
|
451
|
-
focusedDate: Date | null;
|
|
452
|
-
isDateDisabled: (d: Date) => boolean;
|
|
453
|
-
onSelectDate: (d: Date) => void;
|
|
454
|
-
onHoverDate: (d: Date | null) => void;
|
|
455
|
-
onSetFocused: (d: Date | null) => void;
|
|
456
|
-
theme: ReturnType<typeof import('../themes').useTheme>;
|
|
457
|
-
locale: string;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function CalendarMonth({
|
|
461
|
-
year,
|
|
462
|
-
month,
|
|
463
|
-
today,
|
|
464
|
-
mode,
|
|
465
|
-
selectedDate,
|
|
466
|
-
selectedRange,
|
|
467
|
-
multiDates,
|
|
468
|
-
hoverDate,
|
|
469
|
-
focusedDate,
|
|
470
|
-
isDateDisabled,
|
|
471
|
-
onSelectDate,
|
|
472
|
-
onHoverDate,
|
|
473
|
-
onSetFocused,
|
|
474
|
-
theme,
|
|
475
|
-
locale,
|
|
476
|
-
}: CalendarMonthProps) {
|
|
477
|
-
const cells = getCalendarGrid(year, month);
|
|
478
|
-
|
|
479
|
-
return (
|
|
480
|
-
<div>
|
|
481
|
-
{/* Day-of-week header */}
|
|
482
|
-
<div
|
|
483
|
-
style={{
|
|
484
|
-
display: 'grid',
|
|
485
|
-
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
486
|
-
gap: '2px',
|
|
487
|
-
marginBottom: '4px',
|
|
488
|
-
}}
|
|
489
|
-
>
|
|
490
|
-
{DAYS_SHORT.map((d) => (
|
|
491
|
-
<div
|
|
492
|
-
key={d}
|
|
493
|
-
style={{
|
|
494
|
-
textAlign: 'center',
|
|
495
|
-
fontSize: '11px',
|
|
496
|
-
fontWeight: 600,
|
|
497
|
-
color: theme.textMuted,
|
|
498
|
-
padding: '4px 0',
|
|
499
|
-
textTransform: 'uppercase',
|
|
500
|
-
letterSpacing: '0.05em',
|
|
501
|
-
}}
|
|
502
|
-
>
|
|
503
|
-
{d}
|
|
504
|
-
</div>
|
|
505
|
-
))}
|
|
506
|
-
</div>
|
|
507
|
-
|
|
508
|
-
{/* Day grid */}
|
|
509
|
-
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: '2px' }}>
|
|
510
|
-
{cells.map((cell, idx) => {
|
|
511
|
-
const isCurrentMonth = cell.getMonth() === month;
|
|
512
|
-
const isToday = isSameDay(cell, today);
|
|
513
|
-
const isWeekend = cell.getDay() === 0 || cell.getDay() === 6;
|
|
514
|
-
const disabled = isDateDisabled(cell);
|
|
515
|
-
|
|
516
|
-
const isSelectedSingle = mode === 'single' && selectedDate != null && isSameDay(cell, selectedDate);
|
|
517
|
-
const isMultiSelected = mode === 'multiple' && multiDates.some((d) => isSameDay(d, cell));
|
|
518
|
-
const isRangeStart = mode === 'range' && isRangeEndpoint(cell, selectedRange[0], null);
|
|
519
|
-
const isRangeEnd = mode === 'range' && isRangeEndpoint(cell, null, selectedRange[1]);
|
|
520
|
-
const isRangeEndpt = isRangeStart || isRangeEnd;
|
|
521
|
-
|
|
522
|
-
// Range hover preview
|
|
523
|
-
const effectiveEnd = mode === 'range' && selectedRange[0] && !selectedRange[1] && hoverDate
|
|
524
|
-
? hoverDate
|
|
525
|
-
: selectedRange[1];
|
|
526
|
-
const inRangeHighlight = mode === 'range' && isInRange(cell, selectedRange[0], effectiveEnd);
|
|
527
|
-
const isHoverEndpoint = mode === 'range' && selectedRange[0] && !selectedRange[1] && hoverDate && isSameDay(cell, hoverDate);
|
|
528
|
-
|
|
529
|
-
const isFullySelected = isSelectedSingle || isMultiSelected || isRangeEndpt;
|
|
530
|
-
const isFocused = focusedDate != null && isSameDay(cell, focusedDate);
|
|
531
|
-
|
|
532
|
-
let bg = 'transparent';
|
|
533
|
-
let textColor = isCurrentMonth
|
|
534
|
-
? isWeekend ? `${theme.text}cc` : theme.text
|
|
535
|
-
: `${theme.textMuted}60`;
|
|
536
|
-
let borderStyle = 'none';
|
|
537
|
-
let fontWeight = 400;
|
|
538
|
-
|
|
539
|
-
if (isFullySelected || isHoverEndpoint) {
|
|
540
|
-
bg = theme.primary;
|
|
541
|
-
textColor = theme.bg;
|
|
542
|
-
fontWeight = 600;
|
|
543
|
-
} else if (inRangeHighlight) {
|
|
544
|
-
bg = `${theme.primary}18`;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
if (isToday && !isFullySelected) {
|
|
548
|
-
borderStyle = `2px solid ${theme.primary}`;
|
|
549
|
-
fontWeight = 600;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
if (disabled) {
|
|
553
|
-
textColor = `${theme.textMuted}50`;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
if (isFocused && !isFullySelected) {
|
|
557
|
-
borderStyle = `2px solid ${theme.secondary}`;
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
const ariaLabel = cell.toLocaleDateString(locale, {
|
|
561
|
-
weekday: 'long',
|
|
562
|
-
year: 'numeric',
|
|
563
|
-
month: 'long',
|
|
564
|
-
day: 'numeric',
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
return (
|
|
568
|
-
<button
|
|
569
|
-
key={idx}
|
|
570
|
-
type="button"
|
|
571
|
-
aria-label={ariaLabel}
|
|
572
|
-
aria-pressed={isFullySelected}
|
|
573
|
-
aria-disabled={disabled}
|
|
574
|
-
disabled={disabled}
|
|
575
|
-
onClick={() => !disabled && onSelectDate(cell)}
|
|
576
|
-
onMouseEnter={() => onHoverDate(cell)}
|
|
577
|
-
onMouseLeave={() => onHoverDate(null)}
|
|
578
|
-
onFocus={() => onSetFocused(cell)}
|
|
579
|
-
style={{
|
|
580
|
-
width: '34px',
|
|
581
|
-
height: '34px',
|
|
582
|
-
borderRadius: '8px',
|
|
583
|
-
backgroundColor: bg,
|
|
584
|
-
color: textColor,
|
|
585
|
-
border: borderStyle,
|
|
586
|
-
fontSize: '13px',
|
|
587
|
-
fontWeight,
|
|
588
|
-
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
589
|
-
opacity: disabled ? 0.35 : 1,
|
|
590
|
-
display: 'flex',
|
|
591
|
-
alignItems: 'center',
|
|
592
|
-
justifyContent: 'center',
|
|
593
|
-
fontFamily: 'inherit',
|
|
594
|
-
position: 'relative',
|
|
595
|
-
outline: 'none',
|
|
596
|
-
textDecoration: disabled ? 'line-through' : 'none',
|
|
597
|
-
transition: 'background-color 80ms ease',
|
|
598
|
-
}}
|
|
599
|
-
>
|
|
600
|
-
{cell.getDate()}
|
|
601
|
-
</button>
|
|
602
|
-
);
|
|
603
|
-
})}
|
|
604
|
-
</div>
|
|
605
|
-
</div>
|
|
606
|
-
);
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// ── Main Component ────────────────────────────────────────────────────────────
|
|
610
|
-
|
|
611
|
-
export function TkxDatePicker({
|
|
612
|
-
value,
|
|
613
|
-
onChange,
|
|
614
|
-
rangeValue,
|
|
615
|
-
onRangeChange,
|
|
616
|
-
multiValue,
|
|
617
|
-
onMultiChange,
|
|
618
|
-
mode = 'single',
|
|
619
|
-
minDate,
|
|
620
|
-
maxDate,
|
|
621
|
-
disabledDates,
|
|
622
|
-
locale = 'en-US',
|
|
623
|
-
dateFormat,
|
|
624
|
-
showTime = false,
|
|
625
|
-
timeValue,
|
|
626
|
-
onTimeChange,
|
|
627
|
-
showPresets = false,
|
|
628
|
-
customPresets,
|
|
629
|
-
label,
|
|
630
|
-
placeholder = 'MM/DD/YYYY',
|
|
631
|
-
hint,
|
|
632
|
-
isDisabled = false,
|
|
633
|
-
isInvalid = false,
|
|
634
|
-
errorMessage,
|
|
635
|
-
numberOfMonths = 1,
|
|
636
|
-
id: idProp,
|
|
637
|
-
className,
|
|
638
|
-
style,
|
|
639
|
-
}: TkxDatePickerProps) {
|
|
640
|
-
const theme = useTheme();
|
|
641
|
-
const autoId = useId();
|
|
642
|
-
const id = idProp ?? autoId;
|
|
643
|
-
const reduced = useReducedMotion();
|
|
644
|
-
|
|
645
|
-
const today = startOfDay(new Date());
|
|
646
|
-
|
|
647
|
-
// ── State ────────────────────────────────────────────────────────────────────
|
|
648
|
-
|
|
649
|
-
// Controlled/uncontrolled single
|
|
650
|
-
const isSingleControlled = value !== undefined;
|
|
651
|
-
const [internalDate, setInternalDate] = useState<Date | null>(null);
|
|
652
|
-
const selectedDate: Date | null = isSingleControlled ? (value ?? null) : internalDate;
|
|
653
|
-
|
|
654
|
-
// Controlled/uncontrolled range
|
|
655
|
-
const isRangeControlled = rangeValue !== undefined;
|
|
656
|
-
const [internalRange, setInternalRange] = useState<[Date | null, Date | null]>([null, null]);
|
|
657
|
-
const selectedRange: [Date | null, Date | null] = isRangeControlled ? rangeValue! : internalRange;
|
|
658
|
-
|
|
659
|
-
// Controlled/uncontrolled multi
|
|
660
|
-
const isMultiControlled = multiValue !== undefined;
|
|
661
|
-
const [internalMulti, setInternalMulti] = useState<Date[]>([]);
|
|
662
|
-
const multiDates: Date[] = isMultiControlled ? multiValue! : internalMulti;
|
|
663
|
-
|
|
664
|
-
// Range picking phase
|
|
665
|
-
const [rangePicking, setRangePicking] = useState<'start' | 'end'>('start');
|
|
666
|
-
|
|
667
|
-
// Pending range/time (apply/cancel mode)
|
|
668
|
-
const needsApply = mode === 'range' || (mode === 'single' && showTime);
|
|
669
|
-
const [pendingRange, setPendingRange] = useState<[Date | null, Date | null]>([null, null]);
|
|
670
|
-
const [pendingDate, setPendingDate] = useState<Date | null>(null);
|
|
671
|
-
|
|
672
|
-
// Calendar view
|
|
673
|
-
const initRef = selectedDate ?? selectedRange[0] ?? today;
|
|
674
|
-
const [viewYear, setViewYear] = useState(initRef.getFullYear());
|
|
675
|
-
const [viewMonth, setViewMonth] = useState(initRef.getMonth());
|
|
676
|
-
const [calView, setCalView] = useState<DatePickerView>('day');
|
|
677
|
-
|
|
678
|
-
// Time
|
|
679
|
-
const [internalTime, setInternalTime] = useState<{ h: number; m: number }>({ h: 0, m: 0 });
|
|
680
|
-
const currentTime = timeValue ?? internalTime;
|
|
681
|
-
|
|
682
|
-
// UI
|
|
683
|
-
const [open, setOpen] = useState(false);
|
|
684
|
-
const [inputValue, setInputValue] = useState(() => {
|
|
685
|
-
if (mode === 'single') return formatDate(selectedDate, locale, dateFormat);
|
|
686
|
-
if (mode === 'range') {
|
|
687
|
-
const [s, e] = selectedRange;
|
|
688
|
-
if (s && e) return `${formatDate(s, locale, dateFormat)} – ${formatDate(e, locale, dateFormat)}`;
|
|
689
|
-
}
|
|
690
|
-
return '';
|
|
691
|
-
});
|
|
692
|
-
const [focusedDate, setFocusedDate] = useState<Date | null>(null);
|
|
693
|
-
const [hoverDate, setHoverDate] = useState<Date | null>(null);
|
|
694
|
-
const [popupPos, setPopupPos] = useState<PopupPosition>({ top: 0, left: 0, flipUp: false });
|
|
695
|
-
const [, forceUpdate] = useReducer((x: number) => x + 1, 0);
|
|
696
|
-
|
|
697
|
-
const anchorRef = useRef<HTMLDivElement>(null);
|
|
698
|
-
const popupRef = useRef<HTMLDivElement>(null);
|
|
699
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
700
|
-
|
|
701
|
-
const POPUP_ESTIMATED_HEIGHT = showPresets ? 420 : showTime ? 480 : 360;
|
|
702
|
-
|
|
703
|
-
// ── Sync input value ─────────────────────────────────────────────────────────
|
|
704
|
-
|
|
705
|
-
useEffect(() => {
|
|
706
|
-
if (mode === 'single') {
|
|
707
|
-
setInputValue(formatDate(selectedDate, locale, dateFormat));
|
|
708
|
-
} else if (mode === 'range') {
|
|
709
|
-
const [s, e] = selectedRange;
|
|
710
|
-
if (s && e) {
|
|
711
|
-
setInputValue(`${formatDate(s, locale, dateFormat)} – ${formatDate(e, locale, dateFormat)}`);
|
|
712
|
-
} else if (s) {
|
|
713
|
-
setInputValue(formatDate(s, locale, dateFormat));
|
|
714
|
-
} else {
|
|
715
|
-
setInputValue('');
|
|
716
|
-
}
|
|
717
|
-
} else if (mode === 'multiple') {
|
|
718
|
-
setInputValue(multiDates.length > 0 ? `${multiDates.length} date${multiDates.length !== 1 ? 's' : ''} selected` : '');
|
|
719
|
-
}
|
|
720
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
721
|
-
}, [selectedDate, selectedRange, multiDates, mode, locale, dateFormat]);
|
|
722
|
-
|
|
723
|
-
// ── Position popup ───────────────────────────────────────────────────────────
|
|
724
|
-
|
|
725
|
-
const updatePosition = useCallback(() => {
|
|
726
|
-
if (!anchorRef.current) return;
|
|
727
|
-
setPopupPos(getPopupPosition(anchorRef.current, POPUP_ESTIMATED_HEIGHT));
|
|
728
|
-
}, [POPUP_ESTIMATED_HEIGHT]);
|
|
729
|
-
|
|
730
|
-
useEffect(() => {
|
|
731
|
-
if (!open) return;
|
|
732
|
-
updatePosition();
|
|
733
|
-
window.addEventListener('scroll', updatePosition, true);
|
|
734
|
-
window.addEventListener('resize', updatePosition);
|
|
735
|
-
return () => {
|
|
736
|
-
window.removeEventListener('scroll', updatePosition, true);
|
|
737
|
-
window.removeEventListener('resize', updatePosition);
|
|
738
|
-
};
|
|
739
|
-
}, [open, updatePosition]);
|
|
740
|
-
|
|
741
|
-
// ── Outside click ────────────────────────────────────────────────────────────
|
|
742
|
-
|
|
743
|
-
useEffect(() => {
|
|
744
|
-
if (!open) return;
|
|
745
|
-
const handler = (e: PointerEvent) => {
|
|
746
|
-
if (
|
|
747
|
-
anchorRef.current?.contains(e.target as Node) ||
|
|
748
|
-
popupRef.current?.contains(e.target as Node)
|
|
749
|
-
) return;
|
|
750
|
-
setOpen(false);
|
|
751
|
-
};
|
|
752
|
-
document.addEventListener('pointerdown', handler);
|
|
753
|
-
return () => document.removeEventListener('pointerdown', handler);
|
|
754
|
-
}, [open]);
|
|
755
|
-
|
|
756
|
-
// ── Escape key ───────────────────────────────────────────────────────────────
|
|
757
|
-
|
|
758
|
-
useEffect(() => {
|
|
759
|
-
if (!open) return;
|
|
760
|
-
const handler = (e: globalThis.KeyboardEvent) => {
|
|
761
|
-
if (e.key === 'Escape') {
|
|
762
|
-
setOpen(false);
|
|
763
|
-
inputRef.current?.focus();
|
|
764
|
-
}
|
|
765
|
-
};
|
|
766
|
-
document.addEventListener('keydown', handler);
|
|
767
|
-
return () => document.removeEventListener('keydown', handler);
|
|
768
|
-
}, [open]);
|
|
769
|
-
|
|
770
|
-
// ── isDateDisabled ────────────────────────────────────────────────────────────
|
|
771
|
-
|
|
772
|
-
const isDateDisabled = useCallback(
|
|
773
|
-
(d: Date): boolean => {
|
|
774
|
-
if (minDate && startOfDay(d) < startOfDay(minDate)) return true;
|
|
775
|
-
if (maxDate && startOfDay(d) > startOfDay(maxDate)) return true;
|
|
776
|
-
if (!disabledDates) return false;
|
|
777
|
-
if (typeof disabledDates === 'function') return disabledDates(d);
|
|
778
|
-
return disabledDates.some((dd) => isSameDay(dd, d));
|
|
779
|
-
},
|
|
780
|
-
[minDate, maxDate, disabledDates]
|
|
781
|
-
);
|
|
782
|
-
|
|
783
|
-
// ── Select date logic ─────────────────────────────────────────────────────────
|
|
784
|
-
|
|
785
|
-
const selectDate = useCallback(
|
|
786
|
-
(d: Date) => {
|
|
787
|
-
if (isDateDisabled(d)) return;
|
|
788
|
-
|
|
789
|
-
if (mode === 'single') {
|
|
790
|
-
if (needsApply) {
|
|
791
|
-
setPendingDate(d);
|
|
792
|
-
} else {
|
|
793
|
-
if (!isSingleControlled) setInternalDate(d);
|
|
794
|
-
onChange?.(d);
|
|
795
|
-
setInputValue(formatDate(d, locale, dateFormat));
|
|
796
|
-
setOpen(false);
|
|
797
|
-
}
|
|
798
|
-
} else if (mode === 'range') {
|
|
799
|
-
if (rangePicking === 'start') {
|
|
800
|
-
const newRange: [Date, null] = [d, null];
|
|
801
|
-
setPendingRange(newRange);
|
|
802
|
-
if (!isRangeControlled) setInternalRange(newRange);
|
|
803
|
-
onRangeChange?.(newRange);
|
|
804
|
-
setRangePicking('end');
|
|
805
|
-
} else {
|
|
806
|
-
const start = pendingRange[0] ?? selectedRange[0];
|
|
807
|
-
const ordered: [Date | null, Date | null] =
|
|
808
|
-
start && d < start ? [d, start] : [start, d];
|
|
809
|
-
setPendingRange(ordered);
|
|
810
|
-
if (!needsApply) {
|
|
811
|
-
if (!isRangeControlled) setInternalRange(ordered);
|
|
812
|
-
onRangeChange?.(ordered);
|
|
813
|
-
setRangePicking('start');
|
|
814
|
-
setOpen(false);
|
|
815
|
-
} else {
|
|
816
|
-
setRangePicking('start');
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
} else if (mode === 'multiple') {
|
|
820
|
-
const exists = multiDates.some((md) => isSameDay(md, d));
|
|
821
|
-
const next = exists
|
|
822
|
-
? multiDates.filter((md) => !isSameDay(md, d))
|
|
823
|
-
: [...multiDates, d];
|
|
824
|
-
if (!isMultiControlled) setInternalMulti(next);
|
|
825
|
-
onMultiChange?.(next);
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
forceUpdate();
|
|
829
|
-
},
|
|
830
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
831
|
-
[mode, isDateDisabled, isSingleControlled, isRangeControlled, isMultiControlled,
|
|
832
|
-
onChange, onRangeChange, onMultiChange, rangePicking, pendingRange, selectedRange,
|
|
833
|
-
multiDates, needsApply, locale]
|
|
834
|
-
);
|
|
835
|
-
|
|
836
|
-
// ── Apply / Cancel ────────────────────────────────────────────────────────────
|
|
837
|
-
|
|
838
|
-
const handleApply = useCallback(() => {
|
|
839
|
-
if (mode === 'single') {
|
|
840
|
-
const d = pendingDate ?? selectedDate;
|
|
841
|
-
if (!isSingleControlled) setInternalDate(d);
|
|
842
|
-
onChange?.(d);
|
|
843
|
-
} else if (mode === 'range') {
|
|
844
|
-
if (!isRangeControlled) setInternalRange(pendingRange);
|
|
845
|
-
onRangeChange?.(pendingRange);
|
|
846
|
-
}
|
|
847
|
-
setOpen(false);
|
|
848
|
-
setRangePicking('start');
|
|
849
|
-
}, [mode, pendingDate, pendingRange, selectedDate, isSingleControlled, isRangeControlled,
|
|
850
|
-
onChange, onRangeChange]);
|
|
851
|
-
|
|
852
|
-
const handleCancel = useCallback(() => {
|
|
853
|
-
setPendingDate(null);
|
|
854
|
-
setPendingRange([null, null]);
|
|
855
|
-
setRangePicking('start');
|
|
856
|
-
setOpen(false);
|
|
857
|
-
}, []);
|
|
858
|
-
|
|
859
|
-
// ── Navigation ────────────────────────────────────────────────────────────────
|
|
860
|
-
|
|
861
|
-
const prevMonth = () => {
|
|
862
|
-
if (viewMonth === 0) { setViewMonth(11); setViewYear((y) => y - 1); }
|
|
863
|
-
else setViewMonth((m) => m - 1);
|
|
864
|
-
setCalView('day');
|
|
865
|
-
};
|
|
866
|
-
const nextMonth = () => {
|
|
867
|
-
if (viewMonth === 11) { setViewMonth(0); setViewYear((y) => y + 1); }
|
|
868
|
-
else setViewMonth((m) => m + 1);
|
|
869
|
-
setCalView('day');
|
|
870
|
-
};
|
|
871
|
-
const prevYear = () => setViewYear((y) => y - 1);
|
|
872
|
-
const nextYear = () => setViewYear((y) => y + 1);
|
|
873
|
-
const prevDecade = () => setViewYear((y) => y - 10);
|
|
874
|
-
const nextDecade = () => setViewYear((y) => y + 10);
|
|
875
|
-
|
|
876
|
-
// ── Input manual typing ───────────────────────────────────────────────────────
|
|
877
|
-
|
|
878
|
-
const handleInputChange = (v: string) => {
|
|
879
|
-
setInputValue(v);
|
|
880
|
-
if (mode === 'single') {
|
|
881
|
-
const parsed = parseDate(v, dateFormat);
|
|
882
|
-
if (parsed && !isDateDisabled(parsed)) {
|
|
883
|
-
if (!isSingleControlled) setInternalDate(parsed);
|
|
884
|
-
onChange?.(parsed);
|
|
885
|
-
setViewYear(parsed.getFullYear());
|
|
886
|
-
setViewMonth(parsed.getMonth());
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
// ── Clear ─────────────────────────────────────────────────────────────────────
|
|
892
|
-
|
|
893
|
-
const handleClear = (e: React.MouseEvent) => {
|
|
894
|
-
e.stopPropagation();
|
|
895
|
-
if (mode === 'single') {
|
|
896
|
-
if (!isSingleControlled) setInternalDate(null);
|
|
897
|
-
onChange?.(null);
|
|
898
|
-
setInputValue('');
|
|
899
|
-
} else if (mode === 'range') {
|
|
900
|
-
const empty: [null, null] = [null, null];
|
|
901
|
-
if (!isRangeControlled) setInternalRange(empty);
|
|
902
|
-
onRangeChange?.(empty);
|
|
903
|
-
setPendingRange(empty);
|
|
904
|
-
setInputValue('');
|
|
905
|
-
setRangePicking('start');
|
|
906
|
-
} else if (mode === 'multiple') {
|
|
907
|
-
if (!isMultiControlled) setInternalMulti([]);
|
|
908
|
-
onMultiChange?.([]);
|
|
909
|
-
setInputValue('');
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
// ── Keyboard navigation in calendar ──────────────────────────────────────────
|
|
914
|
-
|
|
915
|
-
const handleCalendarKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
|
|
916
|
-
if (calView !== 'day') return;
|
|
917
|
-
const base = focusedDate ?? selectedDate ?? today;
|
|
918
|
-
let next: Date | null = null;
|
|
919
|
-
|
|
920
|
-
if (e.key === 'ArrowRight') next = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 1);
|
|
921
|
-
else if (e.key === 'ArrowLeft') next = new Date(base.getFullYear(), base.getMonth(), base.getDate() - 1);
|
|
922
|
-
else if (e.key === 'ArrowDown') next = new Date(base.getFullYear(), base.getMonth(), base.getDate() + 7);
|
|
923
|
-
else if (e.key === 'ArrowUp') next = new Date(base.getFullYear(), base.getMonth(), base.getDate() - 7);
|
|
924
|
-
else if (e.key === 'Enter' && focusedDate) { selectDate(focusedDate); return; }
|
|
925
|
-
|
|
926
|
-
if (next) {
|
|
927
|
-
e.preventDefault();
|
|
928
|
-
setFocusedDate(next);
|
|
929
|
-
if (next.getMonth() !== viewMonth || next.getFullYear() !== viewYear) {
|
|
930
|
-
setViewMonth(next.getMonth());
|
|
931
|
-
setViewYear(next.getFullYear());
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
// ── Today button ──────────────────────────────────────────────────────────────
|
|
937
|
-
|
|
938
|
-
const goToToday = () => {
|
|
939
|
-
setViewYear(today.getFullYear());
|
|
940
|
-
setViewMonth(today.getMonth());
|
|
941
|
-
setCalView('day');
|
|
942
|
-
selectDate(today);
|
|
943
|
-
};
|
|
944
|
-
|
|
945
|
-
// ── Preset selection ──────────────────────────────────────────────────────────
|
|
946
|
-
|
|
947
|
-
const allPresets = customPresets ?? buildBuiltinPresets();
|
|
948
|
-
|
|
949
|
-
const applyPreset = (preset: DatePreset) => {
|
|
950
|
-
const [start, end] = preset.getValue();
|
|
951
|
-
const range: [Date, Date] = [start, end];
|
|
952
|
-
setPendingRange(range);
|
|
953
|
-
if (!isRangeControlled) setInternalRange(range);
|
|
954
|
-
onRangeChange?.(range);
|
|
955
|
-
setViewYear(start.getFullYear());
|
|
956
|
-
setViewMonth(start.getMonth());
|
|
957
|
-
setRangePicking('start');
|
|
958
|
-
if (!needsApply) setOpen(false);
|
|
959
|
-
};
|
|
960
|
-
|
|
961
|
-
// ── Second month for dual view ─────────────────────────────────────────────
|
|
962
|
-
|
|
963
|
-
const month2 = viewMonth === 11 ? 0 : viewMonth + 1;
|
|
964
|
-
const year2 = viewMonth === 11 ? viewYear + 1 : viewYear;
|
|
965
|
-
|
|
966
|
-
const dualView = numberOfMonths >= 2;
|
|
967
|
-
|
|
968
|
-
// ── Sanitize strings ──────────────────────────────────────────────────────────
|
|
969
|
-
|
|
970
|
-
const safeLabel = label ? sanitizeString(label) : undefined;
|
|
971
|
-
const safeHint = hint ? sanitizeString(hint) : undefined;
|
|
972
|
-
const safeError = errorMessage ? sanitizeString(errorMessage) : undefined;
|
|
973
|
-
const safeHolder = sanitizeString(placeholder);
|
|
974
|
-
|
|
975
|
-
// ── Has value? ────────────────────────────────────────────────────────────────
|
|
976
|
-
|
|
977
|
-
const hasValue =
|
|
978
|
-
(mode === 'single' && selectedDate != null) ||
|
|
979
|
-
(mode === 'range' && (selectedRange[0] != null || selectedRange[1] != null)) ||
|
|
980
|
-
(mode === 'multiple' && multiDates.length > 0);
|
|
981
|
-
|
|
982
|
-
// ── Display range for calendar ────────────────────────────────────────────────
|
|
983
|
-
|
|
984
|
-
const displayRange: [Date | null, Date | null] =
|
|
985
|
-
mode === 'range'
|
|
986
|
-
? (needsApply ? pendingRange : selectedRange)
|
|
987
|
-
: [null, null];
|
|
988
|
-
|
|
989
|
-
// ── Render ────────────────────────────────────────────────────────────────────
|
|
990
|
-
|
|
991
|
-
const borderColor = isInvalid ? theme.danger : open ? theme.primary : theme.border;
|
|
992
|
-
|
|
993
|
-
const hours = Array.from({ length: 24 }, (_, i) => i);
|
|
994
|
-
const minutes = Array.from({ length: 60 }, (_, i) => i);
|
|
995
|
-
|
|
996
|
-
const popupContent = (
|
|
997
|
-
<div
|
|
998
|
-
ref={popupRef}
|
|
999
|
-
role="dialog"
|
|
1000
|
-
aria-label="Date picker"
|
|
1001
|
-
aria-modal="false"
|
|
1002
|
-
onKeyDown={handleCalendarKeyDown}
|
|
1003
|
-
style={{
|
|
1004
|
-
position: 'absolute',
|
|
1005
|
-
top: popupPos.top,
|
|
1006
|
-
left: popupPos.left,
|
|
1007
|
-
zIndex: 9999,
|
|
1008
|
-
backgroundColor: theme.surface,
|
|
1009
|
-
border: `1px solid ${theme.border}`,
|
|
1010
|
-
borderRadius: '14px',
|
|
1011
|
-
boxShadow: `0 8px 30px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.1)`,
|
|
1012
|
-
display: 'flex',
|
|
1013
|
-
overflow: 'hidden',
|
|
1014
|
-
minWidth: dualView ? '580px' : '300px',
|
|
1015
|
-
maxWidth: dualView && showPresets ? '780px' : dualView ? '620px' : showPresets ? '520px' : '300px',
|
|
1016
|
-
opacity: open ? 1 : 0,
|
|
1017
|
-
transform: open
|
|
1018
|
-
? 'translateY(0) scale(1)'
|
|
1019
|
-
: popupPos.flipUp
|
|
1020
|
-
? 'translateY(4px) scale(0.98)'
|
|
1021
|
-
: 'translateY(-4px) scale(0.98)',
|
|
1022
|
-
transition: reduced ? 'none' : 'opacity 120ms ease, transform 120ms ease',
|
|
1023
|
-
fontFamily: 'inherit',
|
|
1024
|
-
}}
|
|
1025
|
-
>
|
|
1026
|
-
{/* Presets sidebar */}
|
|
1027
|
-
{showPresets && mode === 'range' && (
|
|
1028
|
-
<div
|
|
1029
|
-
style={{
|
|
1030
|
-
width: '148px',
|
|
1031
|
-
flexShrink: 0,
|
|
1032
|
-
borderRight: `1px solid ${theme.border}`,
|
|
1033
|
-
padding: '8px 6px',
|
|
1034
|
-
overflowY: 'auto',
|
|
1035
|
-
display: 'flex',
|
|
1036
|
-
flexDirection: 'column',
|
|
1037
|
-
gap: '1px',
|
|
1038
|
-
}}
|
|
1039
|
-
>
|
|
1040
|
-
<div
|
|
1041
|
-
style={{
|
|
1042
|
-
fontSize: '11px',
|
|
1043
|
-
fontWeight: 600,
|
|
1044
|
-
color: theme.textMuted,
|
|
1045
|
-
textTransform: 'uppercase',
|
|
1046
|
-
letterSpacing: '0.07em',
|
|
1047
|
-
padding: '4px 8px 8px',
|
|
1048
|
-
}}
|
|
1049
|
-
>
|
|
1050
|
-
Quick select
|
|
1051
|
-
</div>
|
|
1052
|
-
{allPresets.map((preset) => {
|
|
1053
|
-
const [pStart, pEnd] = preset.getValue();
|
|
1054
|
-
const isActive =
|
|
1055
|
-
displayRange[0] && displayRange[1] &&
|
|
1056
|
-
isSameDay(displayRange[0], pStart) &&
|
|
1057
|
-
isSameDay(displayRange[1], pEnd);
|
|
1058
|
-
return (
|
|
1059
|
-
<button
|
|
1060
|
-
key={preset.label}
|
|
1061
|
-
type="button"
|
|
1062
|
-
onClick={() => applyPreset(preset)}
|
|
1063
|
-
style={{
|
|
1064
|
-
width: '100%',
|
|
1065
|
-
textAlign: 'left',
|
|
1066
|
-
padding: '7px 10px',
|
|
1067
|
-
borderRadius: '7px',
|
|
1068
|
-
border: 'none',
|
|
1069
|
-
cursor: 'pointer',
|
|
1070
|
-
fontSize: '13px',
|
|
1071
|
-
backgroundColor: isActive ? `${theme.primary}20` : 'transparent',
|
|
1072
|
-
color: isActive ? theme.primary : theme.text,
|
|
1073
|
-
fontWeight: isActive ? 600 : 400,
|
|
1074
|
-
fontFamily: 'inherit',
|
|
1075
|
-
transition: 'background-color 80ms ease',
|
|
1076
|
-
}}
|
|
1077
|
-
onMouseEnter={(e) => {
|
|
1078
|
-
if (!isActive) (e.currentTarget as HTMLButtonElement).style.backgroundColor = `${theme.surfaceAlt}`;
|
|
1079
|
-
}}
|
|
1080
|
-
onMouseLeave={(e) => {
|
|
1081
|
-
if (!isActive) (e.currentTarget as HTMLButtonElement).style.backgroundColor = 'transparent';
|
|
1082
|
-
}}
|
|
1083
|
-
>
|
|
1084
|
-
{preset.label}
|
|
1085
|
-
</button>
|
|
1086
|
-
);
|
|
1087
|
-
})}
|
|
1088
|
-
</div>
|
|
1089
|
-
)}
|
|
1090
|
-
|
|
1091
|
-
{/* Calendar area */}
|
|
1092
|
-
<div style={{ flex: 1, padding: '16px', display: 'flex', flexDirection: 'column', gap: '12px', minWidth: 0 }}>
|
|
1093
|
-
{/* Header navigation */}
|
|
1094
|
-
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
|
1095
|
-
{/* Prev button */}
|
|
1096
|
-
<button
|
|
1097
|
-
type="button"
|
|
1098
|
-
aria-label={calView === 'day' ? 'Previous month' : calView === 'month' ? 'Previous year' : 'Previous decade'}
|
|
1099
|
-
onClick={() => {
|
|
1100
|
-
if (calView === 'day') prevMonth();
|
|
1101
|
-
else if (calView === 'month') prevYear();
|
|
1102
|
-
else prevDecade();
|
|
1103
|
-
}}
|
|
1104
|
-
style={{
|
|
1105
|
-
border: 'none',
|
|
1106
|
-
background: 'transparent',
|
|
1107
|
-
cursor: 'pointer',
|
|
1108
|
-
color: theme.textMuted,
|
|
1109
|
-
padding: '6px',
|
|
1110
|
-
borderRadius: '6px',
|
|
1111
|
-
display: 'flex',
|
|
1112
|
-
alignItems: 'center',
|
|
1113
|
-
}}
|
|
1114
|
-
>
|
|
1115
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
1116
|
-
<polyline points="15 18 9 12 15 6" />
|
|
1117
|
-
</svg>
|
|
1118
|
-
</button>
|
|
1119
|
-
|
|
1120
|
-
{/* Breadcrumb: "April 2026" */}
|
|
1121
|
-
<div style={{ display: 'flex', alignItems: 'center', gap: '6px' }}>
|
|
1122
|
-
{calView === 'day' && (
|
|
1123
|
-
<>
|
|
1124
|
-
<button
|
|
1125
|
-
type="button"
|
|
1126
|
-
onClick={() => setCalView('month')}
|
|
1127
|
-
style={{
|
|
1128
|
-
border: 'none',
|
|
1129
|
-
background: 'transparent',
|
|
1130
|
-
cursor: 'pointer',
|
|
1131
|
-
fontSize: '14px',
|
|
1132
|
-
fontWeight: 600,
|
|
1133
|
-
color: theme.text,
|
|
1134
|
-
padding: '4px 6px',
|
|
1135
|
-
borderRadius: '6px',
|
|
1136
|
-
fontFamily: 'inherit',
|
|
1137
|
-
}}
|
|
1138
|
-
>
|
|
1139
|
-
{MONTH_NAMES[viewMonth]}
|
|
1140
|
-
</button>
|
|
1141
|
-
<button
|
|
1142
|
-
type="button"
|
|
1143
|
-
onClick={() => setCalView('year')}
|
|
1144
|
-
style={{
|
|
1145
|
-
border: 'none',
|
|
1146
|
-
background: 'transparent',
|
|
1147
|
-
cursor: 'pointer',
|
|
1148
|
-
fontSize: '14px',
|
|
1149
|
-
fontWeight: 600,
|
|
1150
|
-
color: theme.text,
|
|
1151
|
-
padding: '4px 6px',
|
|
1152
|
-
borderRadius: '6px',
|
|
1153
|
-
fontFamily: 'inherit',
|
|
1154
|
-
}}
|
|
1155
|
-
>
|
|
1156
|
-
{viewYear}
|
|
1157
|
-
</button>
|
|
1158
|
-
{dualView && (
|
|
1159
|
-
<>
|
|
1160
|
-
<span style={{ color: theme.textMuted, fontSize: '14px' }}>–</span>
|
|
1161
|
-
<span style={{ fontSize: '14px', fontWeight: 600, color: theme.text }}>
|
|
1162
|
-
{MONTH_NAMES[month2]} {year2}
|
|
1163
|
-
</span>
|
|
1164
|
-
</>
|
|
1165
|
-
)}
|
|
1166
|
-
</>
|
|
1167
|
-
)}
|
|
1168
|
-
{calView === 'month' && (
|
|
1169
|
-
<button
|
|
1170
|
-
type="button"
|
|
1171
|
-
onClick={() => setCalView('year')}
|
|
1172
|
-
style={{
|
|
1173
|
-
border: 'none',
|
|
1174
|
-
background: 'transparent',
|
|
1175
|
-
cursor: 'pointer',
|
|
1176
|
-
fontSize: '14px',
|
|
1177
|
-
fontWeight: 600,
|
|
1178
|
-
color: theme.text,
|
|
1179
|
-
padding: '4px 6px',
|
|
1180
|
-
borderRadius: '6px',
|
|
1181
|
-
fontFamily: 'inherit',
|
|
1182
|
-
}}
|
|
1183
|
-
>
|
|
1184
|
-
{viewYear}
|
|
1185
|
-
</button>
|
|
1186
|
-
)}
|
|
1187
|
-
{calView === 'year' && (
|
|
1188
|
-
<span style={{ fontSize: '14px', fontWeight: 600, color: theme.text }}>
|
|
1189
|
-
{getDecadeStart(viewYear)}–{getDecadeStart(viewYear) + 9}
|
|
1190
|
-
</span>
|
|
1191
|
-
)}
|
|
1192
|
-
</div>
|
|
1193
|
-
|
|
1194
|
-
{/* Next button */}
|
|
1195
|
-
<button
|
|
1196
|
-
type="button"
|
|
1197
|
-
aria-label={calView === 'day' ? 'Next month' : calView === 'month' ? 'Next year' : 'Next decade'}
|
|
1198
|
-
onClick={() => {
|
|
1199
|
-
if (calView === 'day') nextMonth();
|
|
1200
|
-
else if (calView === 'month') nextYear();
|
|
1201
|
-
else nextDecade();
|
|
1202
|
-
}}
|
|
1203
|
-
style={{
|
|
1204
|
-
border: 'none',
|
|
1205
|
-
background: 'transparent',
|
|
1206
|
-
cursor: 'pointer',
|
|
1207
|
-
color: theme.textMuted,
|
|
1208
|
-
padding: '6px',
|
|
1209
|
-
borderRadius: '6px',
|
|
1210
|
-
display: 'flex',
|
|
1211
|
-
alignItems: 'center',
|
|
1212
|
-
}}
|
|
1213
|
-
>
|
|
1214
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
1215
|
-
<polyline points="9 18 15 12 9 6" />
|
|
1216
|
-
</svg>
|
|
1217
|
-
</button>
|
|
1218
|
-
</div>
|
|
1219
|
-
|
|
1220
|
-
{/* View: Day */}
|
|
1221
|
-
{calView === 'day' && (
|
|
1222
|
-
<div style={{ display: 'flex', gap: '20px' }}>
|
|
1223
|
-
<CalendarMonth
|
|
1224
|
-
year={viewYear}
|
|
1225
|
-
month={viewMonth}
|
|
1226
|
-
today={today}
|
|
1227
|
-
mode={mode}
|
|
1228
|
-
selectedDate={selectedDate}
|
|
1229
|
-
selectedRange={displayRange}
|
|
1230
|
-
multiDates={multiDates}
|
|
1231
|
-
hoverDate={hoverDate}
|
|
1232
|
-
focusedDate={focusedDate}
|
|
1233
|
-
isDateDisabled={isDateDisabled}
|
|
1234
|
-
onSelectDate={selectDate}
|
|
1235
|
-
onHoverDate={setHoverDate}
|
|
1236
|
-
onSetFocused={setFocusedDate}
|
|
1237
|
-
theme={theme}
|
|
1238
|
-
locale={locale}
|
|
1239
|
-
/>
|
|
1240
|
-
{dualView && (
|
|
1241
|
-
<CalendarMonth
|
|
1242
|
-
year={year2}
|
|
1243
|
-
month={month2}
|
|
1244
|
-
today={today}
|
|
1245
|
-
mode={mode}
|
|
1246
|
-
selectedDate={selectedDate}
|
|
1247
|
-
selectedRange={displayRange}
|
|
1248
|
-
multiDates={multiDates}
|
|
1249
|
-
hoverDate={hoverDate}
|
|
1250
|
-
focusedDate={focusedDate}
|
|
1251
|
-
isDateDisabled={isDateDisabled}
|
|
1252
|
-
onSelectDate={selectDate}
|
|
1253
|
-
onHoverDate={setHoverDate}
|
|
1254
|
-
onSetFocused={setFocusedDate}
|
|
1255
|
-
theme={theme}
|
|
1256
|
-
locale={locale}
|
|
1257
|
-
/>
|
|
1258
|
-
)}
|
|
1259
|
-
</div>
|
|
1260
|
-
)}
|
|
1261
|
-
|
|
1262
|
-
{/* View: Month picker */}
|
|
1263
|
-
{calView === 'month' && (
|
|
1264
|
-
<div
|
|
1265
|
-
style={{
|
|
1266
|
-
display: 'grid',
|
|
1267
|
-
gridTemplateColumns: 'repeat(3, 1fr)',
|
|
1268
|
-
gap: '6px',
|
|
1269
|
-
}}
|
|
1270
|
-
>
|
|
1271
|
-
{MONTH_ABBR.map((name, idx) => {
|
|
1272
|
-
const isCurrentViewMonth = idx === viewMonth;
|
|
1273
|
-
const isTodayMonth = idx === today.getMonth() && viewYear === today.getFullYear();
|
|
1274
|
-
return (
|
|
1275
|
-
<button
|
|
1276
|
-
key={name}
|
|
1277
|
-
type="button"
|
|
1278
|
-
onClick={() => {
|
|
1279
|
-
setViewMonth(idx);
|
|
1280
|
-
setCalView('day');
|
|
1281
|
-
}}
|
|
1282
|
-
style={{
|
|
1283
|
-
padding: '10px',
|
|
1284
|
-
borderRadius: '8px',
|
|
1285
|
-
border: isTodayMonth && !isCurrentViewMonth ? `2px solid ${theme.primary}` : 'none',
|
|
1286
|
-
cursor: 'pointer',
|
|
1287
|
-
fontSize: '13px',
|
|
1288
|
-
fontWeight: isCurrentViewMonth ? 600 : 400,
|
|
1289
|
-
backgroundColor: isCurrentViewMonth ? theme.primary : 'transparent',
|
|
1290
|
-
color: isCurrentViewMonth ? theme.bg : theme.text,
|
|
1291
|
-
fontFamily: 'inherit',
|
|
1292
|
-
transition: 'background-color 80ms ease',
|
|
1293
|
-
}}
|
|
1294
|
-
>
|
|
1295
|
-
{name}
|
|
1296
|
-
</button>
|
|
1297
|
-
);
|
|
1298
|
-
})}
|
|
1299
|
-
</div>
|
|
1300
|
-
)}
|
|
1301
|
-
|
|
1302
|
-
{/* View: Year picker (decade grid) */}
|
|
1303
|
-
{calView === 'year' && (
|
|
1304
|
-
<div
|
|
1305
|
-
style={{
|
|
1306
|
-
display: 'grid',
|
|
1307
|
-
gridTemplateColumns: 'repeat(4, 1fr)',
|
|
1308
|
-
gap: '6px',
|
|
1309
|
-
}}
|
|
1310
|
-
>
|
|
1311
|
-
{Array.from({ length: 12 }, (_, i) => {
|
|
1312
|
-
const yr = getDecadeStart(viewYear) - 1 + i;
|
|
1313
|
-
const isCurrentYear = yr === viewYear;
|
|
1314
|
-
const isTodayYear = yr === today.getFullYear();
|
|
1315
|
-
const isOutsideDecade = i === 0 || i === 11;
|
|
1316
|
-
return (
|
|
1317
|
-
<button
|
|
1318
|
-
key={yr}
|
|
1319
|
-
type="button"
|
|
1320
|
-
onClick={() => {
|
|
1321
|
-
setViewYear(yr);
|
|
1322
|
-
setCalView('month');
|
|
1323
|
-
}}
|
|
1324
|
-
style={{
|
|
1325
|
-
padding: '10px 6px',
|
|
1326
|
-
borderRadius: '8px',
|
|
1327
|
-
border: isTodayYear && !isCurrentYear ? `2px solid ${theme.primary}` : 'none',
|
|
1328
|
-
cursor: 'pointer',
|
|
1329
|
-
fontSize: '13px',
|
|
1330
|
-
fontWeight: isCurrentYear ? 600 : 400,
|
|
1331
|
-
backgroundColor: isCurrentYear ? theme.primary : 'transparent',
|
|
1332
|
-
color: isCurrentYear ? theme.bg : isOutsideDecade ? theme.textMuted : theme.text,
|
|
1333
|
-
fontFamily: 'inherit',
|
|
1334
|
-
transition: 'background-color 80ms ease',
|
|
1335
|
-
opacity: isOutsideDecade ? 0.5 : 1,
|
|
1336
|
-
}}
|
|
1337
|
-
>
|
|
1338
|
-
{yr}
|
|
1339
|
-
</button>
|
|
1340
|
-
);
|
|
1341
|
-
})}
|
|
1342
|
-
</div>
|
|
1343
|
-
)}
|
|
1344
|
-
|
|
1345
|
-
{/* Time picker */}
|
|
1346
|
-
{showTime && calView === 'day' && (
|
|
1347
|
-
<div
|
|
1348
|
-
style={{
|
|
1349
|
-
borderTop: `1px solid ${theme.border}`,
|
|
1350
|
-
paddingTop: '12px',
|
|
1351
|
-
display: 'flex',
|
|
1352
|
-
alignItems: 'flex-start',
|
|
1353
|
-
gap: '8px',
|
|
1354
|
-
justifyContent: 'center',
|
|
1355
|
-
}}
|
|
1356
|
-
>
|
|
1357
|
-
<TimeColumn
|
|
1358
|
-
values={hours}
|
|
1359
|
-
selected={currentTime.h}
|
|
1360
|
-
onSelect={(h) => {
|
|
1361
|
-
if (!timeValue) setInternalTime((t) => ({ ...t, h }));
|
|
1362
|
-
onTimeChange?.({ ...currentTime, h });
|
|
1363
|
-
}}
|
|
1364
|
-
label="Hour"
|
|
1365
|
-
theme={theme}
|
|
1366
|
-
/>
|
|
1367
|
-
<div style={{ display: 'flex', alignItems: 'center', height: '40px', marginTop: '28px', fontSize: '16px', fontWeight: 700, color: theme.textMuted }}>
|
|
1368
|
-
:
|
|
1369
|
-
</div>
|
|
1370
|
-
<TimeColumn
|
|
1371
|
-
values={minutes}
|
|
1372
|
-
selected={currentTime.m}
|
|
1373
|
-
onSelect={(m) => {
|
|
1374
|
-
if (!timeValue) setInternalTime((t) => ({ ...t, m }));
|
|
1375
|
-
onTimeChange?.({ ...currentTime, m });
|
|
1376
|
-
}}
|
|
1377
|
-
label="Min"
|
|
1378
|
-
theme={theme}
|
|
1379
|
-
/>
|
|
1380
|
-
</div>
|
|
1381
|
-
)}
|
|
1382
|
-
|
|
1383
|
-
{/* Multiple selection count */}
|
|
1384
|
-
{mode === 'multiple' && calView === 'day' && multiDates.length > 0 && (
|
|
1385
|
-
<div
|
|
1386
|
-
style={{
|
|
1387
|
-
borderTop: `1px solid ${theme.border}`,
|
|
1388
|
-
paddingTop: '8px',
|
|
1389
|
-
fontSize: '12px',
|
|
1390
|
-
color: theme.textMuted,
|
|
1391
|
-
textAlign: 'center',
|
|
1392
|
-
}}
|
|
1393
|
-
>
|
|
1394
|
-
{multiDates.length} date{multiDates.length !== 1 ? 's' : ''} selected
|
|
1395
|
-
</div>
|
|
1396
|
-
)}
|
|
1397
|
-
|
|
1398
|
-
{/* Footer */}
|
|
1399
|
-
<div
|
|
1400
|
-
style={{
|
|
1401
|
-
borderTop: `1px solid ${theme.border}`,
|
|
1402
|
-
paddingTop: '10px',
|
|
1403
|
-
display: 'flex',
|
|
1404
|
-
alignItems: 'center',
|
|
1405
|
-
justifyContent: needsApply ? 'space-between' : 'flex-start',
|
|
1406
|
-
gap: '8px',
|
|
1407
|
-
}}
|
|
1408
|
-
>
|
|
1409
|
-
{/* Today button */}
|
|
1410
|
-
<button
|
|
1411
|
-
type="button"
|
|
1412
|
-
onClick={goToToday}
|
|
1413
|
-
style={{
|
|
1414
|
-
border: 'none',
|
|
1415
|
-
background: 'transparent',
|
|
1416
|
-
cursor: 'pointer',
|
|
1417
|
-
fontSize: '13px',
|
|
1418
|
-
color: theme.primary,
|
|
1419
|
-
fontWeight: 500,
|
|
1420
|
-
padding: '6px 10px',
|
|
1421
|
-
borderRadius: '6px',
|
|
1422
|
-
fontFamily: 'inherit',
|
|
1423
|
-
}}
|
|
1424
|
-
>
|
|
1425
|
-
Today
|
|
1426
|
-
</button>
|
|
1427
|
-
|
|
1428
|
-
{/* Apply / Cancel */}
|
|
1429
|
-
{needsApply && (
|
|
1430
|
-
<div style={{ display: 'flex', gap: '6px' }}>
|
|
1431
|
-
<button
|
|
1432
|
-
type="button"
|
|
1433
|
-
onClick={handleCancel}
|
|
1434
|
-
style={{
|
|
1435
|
-
padding: '6px 14px',
|
|
1436
|
-
borderRadius: '7px',
|
|
1437
|
-
border: `1px solid ${theme.border}`,
|
|
1438
|
-
cursor: 'pointer',
|
|
1439
|
-
fontSize: '13px',
|
|
1440
|
-
fontWeight: 500,
|
|
1441
|
-
backgroundColor: 'transparent',
|
|
1442
|
-
color: theme.text,
|
|
1443
|
-
fontFamily: 'inherit',
|
|
1444
|
-
}}
|
|
1445
|
-
>
|
|
1446
|
-
Cancel
|
|
1447
|
-
</button>
|
|
1448
|
-
<button
|
|
1449
|
-
type="button"
|
|
1450
|
-
onClick={handleApply}
|
|
1451
|
-
style={{
|
|
1452
|
-
padding: '6px 14px',
|
|
1453
|
-
borderRadius: '7px',
|
|
1454
|
-
border: 'none',
|
|
1455
|
-
cursor: 'pointer',
|
|
1456
|
-
fontSize: '13px',
|
|
1457
|
-
fontWeight: 600,
|
|
1458
|
-
backgroundColor: theme.primary,
|
|
1459
|
-
color: theme.bg,
|
|
1460
|
-
fontFamily: 'inherit',
|
|
1461
|
-
}}
|
|
1462
|
-
>
|
|
1463
|
-
Apply
|
|
1464
|
-
</button>
|
|
1465
|
-
</div>
|
|
1466
|
-
)}
|
|
1467
|
-
</div>
|
|
1468
|
-
</div>
|
|
1469
|
-
</div>
|
|
1470
|
-
);
|
|
1471
|
-
|
|
1472
|
-
return (
|
|
1473
|
-
<div
|
|
1474
|
-
className={className}
|
|
1475
|
-
style={{
|
|
1476
|
-
display: 'flex',
|
|
1477
|
-
flexDirection: 'column',
|
|
1478
|
-
gap: '4px',
|
|
1479
|
-
width: '100%',
|
|
1480
|
-
position: 'relative',
|
|
1481
|
-
...style,
|
|
1482
|
-
}}
|
|
1483
|
-
>
|
|
1484
|
-
{/* Label */}
|
|
1485
|
-
{safeLabel && (
|
|
1486
|
-
<label
|
|
1487
|
-
htmlFor={id}
|
|
1488
|
-
style={{ fontSize: '13px', fontWeight: 500, color: theme.text, marginBottom: '2px' }}
|
|
1489
|
-
>
|
|
1490
|
-
{safeLabel}
|
|
1491
|
-
</label>
|
|
1492
|
-
)}
|
|
1493
|
-
|
|
1494
|
-
{/* Input field */}
|
|
1495
|
-
<div
|
|
1496
|
-
ref={anchorRef}
|
|
1497
|
-
style={{
|
|
1498
|
-
display: 'flex',
|
|
1499
|
-
alignItems: 'center',
|
|
1500
|
-
border: `1.5px solid ${borderColor}`,
|
|
1501
|
-
borderRadius: '8px',
|
|
1502
|
-
backgroundColor: theme.surface,
|
|
1503
|
-
overflow: 'hidden',
|
|
1504
|
-
transition: reduced ? 'none' : 'border-color 120ms ease',
|
|
1505
|
-
opacity: isDisabled ? 0.5 : 1,
|
|
1506
|
-
}}
|
|
1507
|
-
>
|
|
1508
|
-
{/* Calendar icon */}
|
|
1509
|
-
<span
|
|
1510
|
-
style={{
|
|
1511
|
-
display: 'flex',
|
|
1512
|
-
alignItems: 'center',
|
|
1513
|
-
paddingLeft: '10px',
|
|
1514
|
-
color: theme.textMuted,
|
|
1515
|
-
flexShrink: 0,
|
|
1516
|
-
}}
|
|
1517
|
-
>
|
|
1518
|
-
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
1519
|
-
<rect x="3" y="4" width="18" height="18" rx="2" /><line x1="16" y1="2" x2="16" y2="6" /><line x1="8" y1="2" x2="8" y2="6" /><line x1="3" y1="10" x2="21" y2="10" />
|
|
1520
|
-
</svg>
|
|
1521
|
-
</span>
|
|
1522
|
-
|
|
1523
|
-
<input
|
|
1524
|
-
ref={inputRef}
|
|
1525
|
-
id={id}
|
|
1526
|
-
type="text"
|
|
1527
|
-
value={inputValue}
|
|
1528
|
-
placeholder={safeHolder}
|
|
1529
|
-
disabled={isDisabled}
|
|
1530
|
-
aria-invalid={isInvalid}
|
|
1531
|
-
aria-haspopup="dialog"
|
|
1532
|
-
aria-expanded={open}
|
|
1533
|
-
readOnly={mode === 'range' || mode === 'multiple'}
|
|
1534
|
-
onChange={(e) => handleInputChange(e.target.value)}
|
|
1535
|
-
onFocus={() => {
|
|
1536
|
-
if (!isDisabled) {
|
|
1537
|
-
setOpen(true);
|
|
1538
|
-
}
|
|
1539
|
-
}}
|
|
1540
|
-
style={{
|
|
1541
|
-
flex: 1,
|
|
1542
|
-
backgroundColor: 'transparent',
|
|
1543
|
-
border: 'none',
|
|
1544
|
-
outline: 'none',
|
|
1545
|
-
fontSize: '14px',
|
|
1546
|
-
padding: '9px 8px',
|
|
1547
|
-
color: theme.text,
|
|
1548
|
-
cursor: mode !== 'single' ? 'pointer' : 'text',
|
|
1549
|
-
fontFamily: 'inherit',
|
|
1550
|
-
minWidth: 0,
|
|
1551
|
-
}}
|
|
1552
|
-
/>
|
|
1553
|
-
|
|
1554
|
-
{/* Clear button */}
|
|
1555
|
-
{hasValue && !isDisabled && (
|
|
1556
|
-
<button
|
|
1557
|
-
type="button"
|
|
1558
|
-
aria-label="Clear selection"
|
|
1559
|
-
onClick={handleClear}
|
|
1560
|
-
style={{
|
|
1561
|
-
display: 'flex',
|
|
1562
|
-
alignItems: 'center',
|
|
1563
|
-
justifyContent: 'center',
|
|
1564
|
-
width: '28px',
|
|
1565
|
-
height: '28px',
|
|
1566
|
-
border: 'none',
|
|
1567
|
-
background: 'transparent',
|
|
1568
|
-
cursor: 'pointer',
|
|
1569
|
-
color: theme.textMuted,
|
|
1570
|
-
flexShrink: 0,
|
|
1571
|
-
borderRadius: '4px',
|
|
1572
|
-
marginRight: '4px',
|
|
1573
|
-
}}
|
|
1574
|
-
>
|
|
1575
|
-
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
1576
|
-
<line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
|
|
1577
|
-
</svg>
|
|
1578
|
-
</button>
|
|
1579
|
-
)}
|
|
1580
|
-
|
|
1581
|
-
{/* Toggle button */}
|
|
1582
|
-
<button
|
|
1583
|
-
type="button"
|
|
1584
|
-
aria-label={open ? 'Close calendar' : 'Open calendar'}
|
|
1585
|
-
tabIndex={-1}
|
|
1586
|
-
disabled={isDisabled}
|
|
1587
|
-
onClick={() => {
|
|
1588
|
-
if (!isDisabled) {
|
|
1589
|
-
setOpen((o) => !o);
|
|
1590
|
-
}
|
|
1591
|
-
}}
|
|
1592
|
-
style={{
|
|
1593
|
-
display: 'flex',
|
|
1594
|
-
alignItems: 'center',
|
|
1595
|
-
justifyContent: 'center',
|
|
1596
|
-
width: '34px',
|
|
1597
|
-
height: '36px',
|
|
1598
|
-
border: 'none',
|
|
1599
|
-
background: 'transparent',
|
|
1600
|
-
cursor: isDisabled ? 'not-allowed' : 'pointer',
|
|
1601
|
-
color: theme.textMuted,
|
|
1602
|
-
flexShrink: 0,
|
|
1603
|
-
}}
|
|
1604
|
-
>
|
|
1605
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" style={{ transform: open ? 'rotate(180deg)' : 'rotate(0deg)', transition: reduced ? 'none' : 'transform 160ms ease' }}>
|
|
1606
|
-
<polyline points="6 9 12 15 18 9" />
|
|
1607
|
-
</svg>
|
|
1608
|
-
</button>
|
|
1609
|
-
</div>
|
|
1610
|
-
|
|
1611
|
-
{/* Hint / Error */}
|
|
1612
|
-
{safeHint && !isInvalid && (
|
|
1613
|
-
<span style={{ fontSize: '12px', color: theme.textMuted }}>{safeHint}</span>
|
|
1614
|
-
)}
|
|
1615
|
-
{isInvalid && safeError && (
|
|
1616
|
-
<span role="alert" style={{ fontSize: '12px', color: theme.danger }}>{safeError}</span>
|
|
1617
|
-
)}
|
|
1618
|
-
|
|
1619
|
-
{/* Portal popup */}
|
|
1620
|
-
{open && typeof document !== 'undefined' && createPortal(popupContent, document.body)}
|
|
1621
|
-
</div>
|
|
1622
|
-
);
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
TkxDatePicker.displayName = 'TkxDatePicker';
|