@kumix/ui 0.3.17 → 0.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/README.md +30 -18
- package/dist/account-avatar-DILzuuvz.js +23 -0
- package/dist/account-avatar-DILzuuvz.js.map +1 -0
- package/dist/{cascader-types-BnH6wYD-.d.ts → cascader-types-DVT-znZ-.d.ts} +6 -3
- package/dist/cascader-types-DVT-znZ-.d.ts.map +1 -0
- package/dist/components/agents/agent-activity/activity-row.js +1 -1
- package/dist/components/agents/agent-activity/index.js +1 -1
- package/dist/components/agents/agent-code.js +1 -1
- package/dist/components/agents/ai-sidebar.js +1 -1
- package/dist/components/agents/approval-card/index.js +1 -1
- package/dist/components/agents/citations.js +1 -1
- package/dist/components/agents/code-block.js +1 -1
- package/dist/components/agents/file-diff.js +1 -1
- package/dist/components/agents/image-generation.js +1 -1
- package/dist/components/agents/message-bubble.js +1 -1
- package/dist/components/agents/prompt-input.js +1 -1
- package/dist/components/agents/streaming-response.js +1 -1
- package/dist/components/agents/todo-list.js +1 -1
- package/dist/components/agents/tool-approval.js +1 -1
- package/dist/components/agents/tool-result.js +1 -1
- package/dist/components/agents/voice-orb.d.ts +19 -0
- package/dist/components/agents/voice-orb.d.ts.map +1 -0
- package/dist/components/agents/voice-orb.js +389 -0
- package/dist/components/agents/voice-orb.js.map +1 -0
- package/dist/components/charts/bump-chart/context.d.ts +2 -0
- package/dist/components/charts/bump-chart/context.js +3 -0
- package/dist/components/charts/bump-chart/legend.d.ts +6 -0
- package/dist/components/charts/bump-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/bump-chart/legend.js +60 -0
- package/dist/components/charts/bump-chart/legend.js.map +1 -0
- package/dist/components/charts/bump-chart/plot.d.ts +6 -0
- package/dist/components/charts/bump-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/bump-chart/plot.js +3 -0
- package/dist/components/charts/bump-chart/point.d.ts +10 -0
- package/dist/components/charts/bump-chart/point.d.ts.map +1 -0
- package/dist/components/charts/bump-chart/point.js +124 -0
- package/dist/components/charts/bump-chart/point.js.map +1 -0
- package/dist/components/charts/bump-chart/series.d.ts +11 -0
- package/dist/components/charts/bump-chart/series.d.ts.map +1 -0
- package/dist/components/charts/bump-chart/series.js +101 -0
- package/dist/components/charts/bump-chart/series.js.map +1 -0
- package/dist/components/charts/bump-chart.d.ts +10 -0
- package/dist/components/charts/bump-chart.d.ts.map +1 -0
- package/dist/components/charts/bump-chart.js +23 -0
- package/dist/components/charts/bump-chart.js.map +1 -0
- package/dist/components/charts/composition-chart/context.d.ts +2 -0
- package/dist/components/charts/composition-chart/context.js +3 -0
- package/dist/components/charts/composition-chart/legend.d.ts +6 -0
- package/dist/components/charts/composition-chart/legend.d.ts.map +1 -0
- package/dist/components/charts/composition-chart/legend.js +51 -0
- package/dist/components/charts/composition-chart/legend.js.map +1 -0
- package/dist/components/charts/composition-chart/plot.d.ts +6 -0
- package/dist/components/charts/composition-chart/plot.d.ts.map +1 -0
- package/dist/components/charts/composition-chart/plot.js +174 -0
- package/dist/components/charts/composition-chart/plot.js.map +1 -0
- package/dist/components/charts/composition-chart/tooltip-content.d.ts +6 -0
- package/dist/components/charts/composition-chart/tooltip-content.d.ts.map +1 -0
- package/dist/components/charts/composition-chart/tooltip-content.js +63 -0
- package/dist/components/charts/composition-chart/tooltip-content.js.map +1 -0
- package/dist/components/charts/composition-chart.d.ts +9 -0
- package/dist/components/charts/composition-chart.d.ts.map +1 -0
- package/dist/components/charts/composition-chart.js +26 -0
- package/dist/components/charts/composition-chart.js.map +1 -0
- package/dist/components/charts/funnel-chart.d.ts +50 -0
- package/dist/components/charts/funnel-chart.d.ts.map +1 -0
- package/dist/components/charts/funnel-chart.js +216 -0
- package/dist/components/charts/funnel-chart.js.map +1 -0
- package/dist/components/charts/heat-calendar/grid.d.ts +8 -0
- package/dist/components/charts/heat-calendar/grid.d.ts.map +1 -0
- package/dist/components/charts/heat-calendar/grid.js +127 -0
- package/dist/components/charts/heat-calendar/grid.js.map +1 -0
- package/dist/components/charts/heat-calendar/legend.d.ts +6 -0
- package/dist/components/charts/heat-calendar/legend.d.ts.map +1 -0
- package/dist/components/charts/heat-calendar/legend.js +48 -0
- package/dist/components/charts/heat-calendar/legend.js.map +1 -0
- package/dist/components/charts/heat-calendar/tooltip.d.ts +2 -0
- package/dist/components/charts/heat-calendar/tooltip.js +50 -0
- package/dist/components/charts/heat-calendar/tooltip.js.map +1 -0
- package/dist/components/charts/heat-calendar.d.ts +9 -0
- package/dist/components/charts/heat-calendar.d.ts.map +1 -0
- package/dist/components/charts/heat-calendar.js +23 -0
- package/dist/components/charts/heat-calendar.js.map +1 -0
- package/dist/components/charts/liquidity-heatmap.d.ts +51 -0
- package/dist/components/charts/liquidity-heatmap.d.ts.map +1 -0
- package/dist/components/charts/liquidity-heatmap.js +311 -0
- package/dist/components/charts/liquidity-heatmap.js.map +1 -0
- package/dist/components/charts/order-book/depth-row.d.ts +13 -0
- package/dist/components/charts/order-book/depth-row.d.ts.map +1 -0
- package/dist/components/charts/order-book/depth-row.js +99 -0
- package/dist/components/charts/order-book/depth-row.js.map +1 -0
- package/dist/components/charts/order-book.d.ts +57 -0
- package/dist/components/charts/order-book.d.ts.map +1 -0
- package/dist/components/charts/order-book.js +207 -0
- package/dist/components/charts/order-book.js.map +1 -0
- package/dist/components/charts/price-target-fan/header.d.ts +8 -0
- package/dist/components/charts/price-target-fan/header.d.ts.map +1 -0
- package/dist/components/charts/price-target-fan/header.js +43 -0
- package/dist/components/charts/price-target-fan/header.js.map +1 -0
- package/dist/components/charts/price-target-fan/plot.d.ts +16 -0
- package/dist/components/charts/price-target-fan/plot.d.ts.map +1 -0
- package/dist/components/charts/price-target-fan/plot.js +142 -0
- package/dist/components/charts/price-target-fan/plot.js.map +1 -0
- package/dist/components/charts/price-target-fan/series.d.ts +15 -0
- package/dist/components/charts/price-target-fan/series.d.ts.map +1 -0
- package/dist/components/charts/price-target-fan/series.js +238 -0
- package/dist/components/charts/price-target-fan/series.js.map +1 -0
- package/dist/components/charts/price-target-fan/tooltip.d.ts +2 -0
- package/dist/components/charts/price-target-fan/tooltip.js +58 -0
- package/dist/components/charts/price-target-fan/tooltip.js.map +1 -0
- package/dist/components/charts/price-target-fan.d.ts +10 -0
- package/dist/components/charts/price-target-fan.d.ts.map +1 -0
- package/dist/components/charts/price-target-fan.js +24 -0
- package/dist/components/charts/price-target-fan.js.map +1 -0
- package/dist/components/charts/returns-calendar/grid.d.ts +8 -0
- package/dist/components/charts/returns-calendar/grid.d.ts.map +1 -0
- package/dist/components/charts/returns-calendar/grid.js +176 -0
- package/dist/components/charts/returns-calendar/grid.js.map +1 -0
- package/dist/components/charts/returns-calendar/tooltip.d.ts +2 -0
- package/dist/components/charts/returns-calendar/tooltip.js +55 -0
- package/dist/components/charts/returns-calendar/tooltip.js.map +1 -0
- package/dist/components/charts/returns-calendar.d.ts +48 -0
- package/dist/components/charts/returns-calendar.d.ts.map +1 -0
- package/dist/components/charts/returns-calendar.js +22 -0
- package/dist/components/charts/returns-calendar.js.map +1 -0
- package/dist/components/charts/status-bar/legend.d.ts +8 -0
- package/dist/components/charts/status-bar/legend.d.ts.map +1 -0
- package/dist/components/charts/status-bar/legend.js +37 -0
- package/dist/components/charts/status-bar/legend.js.map +1 -0
- package/dist/components/charts/status-bar/plot.d.ts +12 -0
- package/dist/components/charts/status-bar/plot.d.ts.map +1 -0
- package/dist/components/charts/status-bar/plot.js +176 -0
- package/dist/components/charts/status-bar/plot.js.map +1 -0
- package/dist/components/charts/status-bar/tooltip.d.ts +2 -0
- package/dist/components/charts/status-bar/tooltip.js +49 -0
- package/dist/components/charts/status-bar/tooltip.js.map +1 -0
- package/dist/components/charts/status-bar.d.ts +9 -0
- package/dist/components/charts/status-bar.d.ts.map +1 -0
- package/dist/components/charts/status-bar.js +64 -0
- package/dist/components/charts/status-bar.js.map +1 -0
- package/dist/components/charts/treemap/legend.d.ts +8 -0
- package/dist/components/charts/treemap/legend.d.ts.map +1 -0
- package/dist/components/charts/treemap/legend.js +35 -0
- package/dist/components/charts/treemap/legend.js.map +1 -0
- package/dist/components/charts/treemap/plot.d.ts +13 -0
- package/dist/components/charts/treemap/plot.d.ts.map +1 -0
- package/dist/components/charts/treemap/plot.js +123 -0
- package/dist/components/charts/treemap/plot.js.map +1 -0
- package/dist/components/charts/treemap/tile.d.ts +10 -0
- package/dist/components/charts/treemap/tile.d.ts.map +1 -0
- package/dist/components/charts/treemap/tile.js +114 -0
- package/dist/components/charts/treemap/tile.js.map +1 -0
- package/dist/components/charts/treemap/tooltip.d.ts +11 -0
- package/dist/components/charts/treemap/tooltip.d.ts.map +1 -0
- package/dist/components/charts/treemap/tooltip.js +73 -0
- package/dist/components/charts/treemap/tooltip.js.map +1 -0
- package/dist/components/charts/treemap.d.ts +56 -0
- package/dist/components/charts/treemap.d.ts.map +1 -0
- package/dist/components/charts/treemap.js +71 -0
- package/dist/components/charts/treemap.js.map +1 -0
- package/dist/components/charts/volume-profile/plot.d.ts +12 -0
- package/dist/components/charts/volume-profile/plot.d.ts.map +1 -0
- package/dist/components/charts/volume-profile/plot.js +211 -0
- package/dist/components/charts/volume-profile/plot.js.map +1 -0
- package/dist/components/charts/volume-profile/summary.d.ts +6 -0
- package/dist/components/charts/volume-profile/summary.d.ts.map +1 -0
- package/dist/components/charts/volume-profile/summary.js +76 -0
- package/dist/components/charts/volume-profile/summary.js.map +1 -0
- package/dist/components/charts/volume-profile/tooltip.d.ts +2 -0
- package/dist/components/charts/volume-profile/tooltip.js +84 -0
- package/dist/components/charts/volume-profile/tooltip.js.map +1 -0
- package/dist/components/charts/volume-profile.d.ts +111 -0
- package/dist/components/charts/volume-profile.d.ts.map +1 -0
- package/dist/components/charts/volume-profile.js +82 -0
- package/dist/components/charts/volume-profile.js.map +1 -0
- package/dist/components/custom/confirm-dialog.js +1 -1
- package/dist/components/motion/adaptive-stepper.js +1 -1
- package/dist/components/motion/alert.d.ts +40 -0
- package/dist/components/motion/alert.d.ts.map +1 -0
- package/dist/components/motion/alert.js +247 -0
- package/dist/components/motion/alert.js.map +1 -0
- package/dist/components/motion/animated-badge.js +1 -1
- package/dist/components/motion/animated-sidebar.js +1 -1
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/animated-toast-stack.js +1 -1
- package/dist/components/motion/arc-picker.d.ts +28 -0
- package/dist/components/motion/arc-picker.d.ts.map +1 -0
- package/dist/components/motion/arc-picker.js +569 -0
- package/dist/components/motion/arc-picker.js.map +1 -0
- package/dist/components/motion/aspect-ratio.d.ts +23 -0
- package/dist/components/motion/aspect-ratio.d.ts.map +1 -0
- package/dist/components/motion/aspect-ratio.js +61 -0
- package/dist/components/motion/aspect-ratio.js.map +1 -0
- package/dist/components/motion/attachment-upload.d.ts.map +1 -1
- package/dist/components/motion/attachment-upload.js +2 -2
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
- package/dist/components/motion/availability-scheduler/day-row.js +2 -2
- package/dist/components/motion/availability-scheduler/index.js +1 -1
- package/dist/components/motion/bloom-menu.js +1 -1
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +1 -1
- package/dist/components/motion/breadcrumb.d.ts +37 -0
- package/dist/components/motion/breadcrumb.d.ts.map +1 -0
- package/dist/components/motion/breadcrumb.js +259 -0
- package/dist/components/motion/breadcrumb.js.map +1 -0
- package/dist/components/motion/button/stateful.js +1 -1
- package/dist/components/motion/card-folder.js +1 -1
- package/dist/components/motion/center-morph-modal.js +1 -1
- package/dist/components/motion/collapsible.d.ts +34 -0
- package/dist/components/motion/collapsible.d.ts.map +1 -0
- package/dist/components/motion/collapsible.js +237 -0
- package/dist/components/motion/collapsible.js.map +1 -0
- package/dist/components/motion/color-selector.d.ts +28 -0
- package/dist/components/motion/color-selector.d.ts.map +1 -0
- package/dist/components/motion/color-selector.js +97 -0
- package/dist/components/motion/color-selector.js.map +1 -0
- package/dist/components/motion/combobox/list.js +1 -1
- package/dist/components/motion/combobox/trigger.js +1 -1
- package/dist/components/motion/command-palette.js +1 -1
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/context-menu.js +1 -1
- package/dist/components/motion/date-range-picker.d.ts +107 -0
- package/dist/components/motion/date-range-picker.d.ts.map +1 -0
- package/dist/components/motion/date-range-picker.js +907 -0
- package/dist/components/motion/date-range-picker.js.map +1 -0
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/feedback-widget.js +1 -1
- package/dist/components/motion/file-tree.js +1 -1
- package/dist/components/motion/file-upload.js +1 -1
- package/dist/components/motion/infinite-masonry.js +1 -1
- package/dist/components/motion/knockout-bracket.d.ts +190 -0
- package/dist/components/motion/knockout-bracket.d.ts.map +1 -0
- package/dist/components/motion/knockout-bracket.js +952 -0
- package/dist/components/motion/knockout-bracket.js.map +1 -0
- package/dist/components/motion/knockout-wheel.d.ts +183 -0
- package/dist/components/motion/knockout-wheel.d.ts.map +1 -0
- package/dist/components/motion/knockout-wheel.js +1039 -0
- package/dist/components/motion/knockout-wheel.js.map +1 -0
- package/dist/components/motion/morphing-lightbox.d.ts +67 -0
- package/dist/components/motion/morphing-lightbox.d.ts.map +1 -0
- package/dist/components/motion/morphing-lightbox.js +499 -0
- package/dist/components/motion/morphing-lightbox.js.map +1 -0
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.js +1 -1
- package/dist/components/motion/morphing-search.js.map +1 -1
- package/dist/components/motion/morphing-tabs.js +1 -1
- package/dist/components/motion/multi-select/list.js +1 -1
- package/dist/components/motion/multi-select/trigger.js +1 -1
- package/dist/components/motion/notification-stack.js +1 -1
- package/dist/components/motion/overflow-actions.js +1 -1
- package/dist/components/motion/popover-morph.d.ts +5 -1
- package/dist/components/motion/popover-morph.d.ts.map +1 -1
- package/dist/components/motion/popover-morph.js +78 -27
- package/dist/components/motion/popover-morph.js.map +1 -1
- package/dist/components/motion/prediction-market-card.d.ts +37 -0
- package/dist/components/motion/prediction-market-card.d.ts.map +1 -0
- package/dist/components/motion/prediction-market-card.js +216 -0
- package/dist/components/motion/prediction-market-card.js.map +1 -0
- package/dist/components/motion/prediction-market.d.ts +49 -0
- package/dist/components/motion/prediction-market.d.ts.map +1 -0
- package/dist/components/motion/prediction-market.js +440 -0
- package/dist/components/motion/prediction-market.js.map +1 -0
- package/dist/components/motion/project-folder.js +1 -1
- package/dist/components/motion/project-folder.js.map +1 -1
- package/dist/components/motion/select-morph.js +1 -1
- package/dist/components/motion/select.js +1 -1
- package/dist/components/motion/signup-form.js +1 -1
- package/dist/components/motion/sortable-list.d.ts +53 -0
- package/dist/components/motion/sortable-list.d.ts.map +1 -0
- package/dist/components/motion/sortable-list.js +254 -0
- package/dist/components/motion/sortable-list.js.map +1 -0
- package/dist/components/motion/sortable-stack.d.ts +2 -0
- package/dist/components/motion/sortable-stack.js +3 -0
- package/dist/components/motion/swap/controls.d.ts +22 -0
- package/dist/components/motion/swap/controls.d.ts.map +1 -0
- package/dist/components/motion/swap/controls.js +167 -0
- package/dist/components/motion/swap/controls.js.map +1 -0
- package/dist/components/motion/swap/field.d.ts +14 -0
- package/dist/components/motion/swap/field.d.ts.map +1 -0
- package/dist/components/motion/swap/field.js +107 -0
- package/dist/components/motion/swap/field.js.map +1 -0
- package/dist/components/motion/swap/quote-row.d.ts +13 -0
- package/dist/components/motion/swap/quote-row.d.ts.map +1 -0
- package/dist/components/motion/swap/quote-row.js +55 -0
- package/dist/components/motion/swap/quote-row.js.map +1 -0
- package/dist/components/motion/swap/token-badges.d.ts +19 -0
- package/dist/components/motion/swap/token-badges.d.ts.map +1 -0
- package/dist/components/motion/swap/token-badges.js +54 -0
- package/dist/components/motion/swap/token-badges.js.map +1 -0
- package/dist/components/motion/swap/token-picker.d.ts +14 -0
- package/dist/components/motion/swap/token-picker.d.ts.map +1 -0
- package/dist/components/motion/swap/token-picker.js +190 -0
- package/dist/components/motion/swap/token-picker.js.map +1 -0
- package/dist/components/motion/swap.d.ts +14 -0
- package/dist/components/motion/swap.d.ts.map +1 -0
- package/dist/components/motion/swap.js +378 -0
- package/dist/components/motion/swap.js.map +1 -0
- package/dist/components/motion/table/row-handle.js +1 -1
- package/dist/components/motion/table/table-header.js +1 -1
- package/dist/components/motion/tabs.d.ts +5 -9
- package/dist/components/motion/tabs.d.ts.map +1 -1
- package/dist/components/motion/tabs.js +14 -5
- package/dist/components/motion/tabs.js.map +1 -1
- package/dist/components/motion/theme-toggle.js +1 -1
- package/dist/components/motion/tooltip/positioner.d.ts +33 -0
- package/dist/components/motion/tooltip/positioner.d.ts.map +1 -0
- package/dist/components/motion/tooltip/positioner.js +3 -0
- package/dist/components/motion/tooltip-surface.d.ts +5 -4
- package/dist/components/motion/tooltip-surface.d.ts.map +1 -1
- package/dist/components/motion/tooltip-surface.js +22 -73
- package/dist/components/motion/tooltip-surface.js.map +1 -1
- package/dist/components/motion/tooltip.d.ts +3 -1
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/tooltip.js +54 -103
- package/dist/components/motion/tooltip.js.map +1 -1
- package/dist/components/motion/wallet-card/account-avatar.d.ts +8 -0
- package/dist/components/motion/wallet-card/account-avatar.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/account-avatar.js +3 -0
- package/dist/components/motion/wallet-card/account-switcher.d.ts +14 -0
- package/dist/components/motion/wallet-card/account-switcher.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/account-switcher.js +153 -0
- package/dist/components/motion/wallet-card/account-switcher.js.map +1 -0
- package/dist/components/motion/wallet-card/actions.d.ts +12 -0
- package/dist/components/motion/wallet-card/actions.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/actions.js +58 -0
- package/dist/components/motion/wallet-card/actions.js.map +1 -0
- package/dist/components/motion/wallet-card/balance-delta.d.ts +12 -0
- package/dist/components/motion/wallet-card/balance-delta.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/balance-delta.js +72 -0
- package/dist/components/motion/wallet-card/balance-delta.js.map +1 -0
- package/dist/components/motion/wallet-card/copy-button.d.ts +12 -0
- package/dist/components/motion/wallet-card/copy-button.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/copy-button.js +41 -0
- package/dist/components/motion/wallet-card/copy-button.js.map +1 -0
- package/dist/components/motion/wallet-card/index.d.ts +13 -0
- package/dist/components/motion/wallet-card/index.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/index.js +115 -0
- package/dist/components/motion/wallet-card/index.js.map +1 -0
- package/dist/components/motion/wallet-card/search-bar.d.ts +17 -0
- package/dist/components/motion/wallet-card/search-bar.d.ts.map +1 -0
- package/dist/components/motion/wallet-card/search-bar.js +156 -0
- package/dist/components/motion/wallet-card/search-bar.js.map +1 -0
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/alert.js +1 -1
- package/dist/components/reui/autocomplete.js +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-async.d.ts +3 -2
- package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-async.js.map +1 -1
- package/dist/components/reui/cascader/cascader-columns.js +4 -4
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -1
- package/dist/components/reui/cascader/cascader-context.d.ts +12 -4
- package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-context.js.map +1 -1
- package/dist/components/reui/cascader/cascader-footer.js +1 -1
- package/dist/components/reui/cascader/cascader-i18n.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-item.d.ts +2 -2
- package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-item.js +23 -17
- package/dist/components/reui/cascader/cascader-item.js.map +1 -1
- package/dist/components/reui/cascader/cascader-lib.d.ts +8 -1
- package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-lib.js +19 -11
- package/dist/components/reui/cascader/cascader-lib.js.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-nav.js +6 -5
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -1
- package/dist/components/reui/cascader/cascader-types.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader-virtual.js.map +1 -1
- package/dist/components/reui/cascader/cascader.d.ts +6 -2
- package/dist/components/reui/cascader/cascader.d.ts.map +1 -1
- package/dist/components/reui/cascader/cascader.js +59 -21
- package/dist/components/reui/cascader/cascader.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-filter.js +3 -3
- package/dist/components/reui/data-grid/data-grid-column-filter.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-header.js +18 -14
- package/dist/components/reui/data-grid/data-grid-column-header.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js +1 -1
- package/dist/components/reui/data-grid/data-grid-column-visibility.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-pagination.js +2 -2
- package/dist/components/reui/data-grid/data-grid-pagination.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-scroll-area.js +85 -61
- package/dist/components/reui/data-grid/data-grid-scroll-area.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts +7 -2
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js +68 -39
- package/dist/components/reui/data-grid/data-grid-table-dnd-rows.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts +7 -2
- package/dist/components/reui/data-grid/data-grid-table-dnd.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-dnd.js +90 -26
- package/dist/components/reui/data-grid/data-grid-table-dnd.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js +1 -1
- package/dist/components/reui/data-grid/data-grid-table-virtual.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.js +157 -38
- package/dist/components/reui/data-grid/data-grid-table.js.map +1 -1
- package/dist/components/reui/data-grid/data-grid.d.ts +16 -0
- package/dist/components/reui/data-grid/data-grid.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid.js +81 -51
- package/dist/components/reui/data-grid/data-grid.js.map +1 -1
- package/dist/components/reui/date-selector.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-agenda-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-month-view.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +2 -2
- package/dist/components/reui/filters/filters-advanced.js +2 -2
- package/dist/components/reui/filters/filters-advanced.js.map +1 -1
- package/dist/components/reui/filters/filters-builder.d.ts +1 -1
- package/dist/components/reui/filters/filters-builder.js +1 -1
- package/dist/components/reui/filters/filters-chip.js +2 -2
- package/dist/components/reui/filters/filters-editors.js +1 -1
- package/dist/components/reui/filters/filters-lib.d.ts +1 -1
- package/dist/components/reui/filters/filters.js +1 -1
- package/dist/components/reui/frame.js +1 -1
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +2 -2
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/reui/kanban.d.ts.map +1 -1
- package/dist/components/reui/kanban.js +30 -1
- package/dist/components/reui/kanban.js.map +1 -1
- package/dist/components/reui/number-field.js +1 -1
- package/dist/components/reui/phone-input.js +1 -1
- package/dist/components/reui/rating.js +1 -1
- package/dist/components/reui/signature-pad.d.ts +160 -0
- package/dist/components/reui/signature-pad.d.ts.map +1 -0
- package/dist/components/reui/signature-pad.js +764 -0
- package/dist/components/reui/signature-pad.js.map +1 -0
- package/dist/components/reui/time-picker.d.ts +202 -0
- package/dist/components/reui/time-picker.d.ts.map +1 -0
- package/dist/components/reui/time-picker.js +1002 -0
- package/dist/components/reui/time-picker.js.map +1 -0
- package/dist/components/reui/tree.js +1 -1
- package/dist/components/ui/accordion.js +1 -1
- package/dist/components/ui/alert-dialog.js +1 -1
- package/dist/components/ui/alert.js +1 -1
- package/dist/components/ui/attachment.js +1 -1
- package/dist/components/ui/breadcrumb.js +1 -1
- package/dist/components/ui/bubble.js +1 -1
- package/dist/components/ui/button-group.js +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/calendar.js +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/combobox.js +1 -1
- package/dist/components/ui/command.js +1 -1
- package/dist/components/ui/context-menu.js +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dropdown-menu.js +1 -1
- package/dist/components/ui/empty.js +1 -1
- package/dist/components/ui/field.js +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/input-otp.js +1 -1
- package/dist/components/ui/item.js +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/marker.js +1 -1
- package/dist/components/ui/menubar.js +1 -1
- package/dist/components/ui/message-scroller.js +1 -1
- package/dist/components/ui/native-select.js +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/pagination.js +1 -1
- package/dist/components/ui/questionnaire.js +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/spinner.js +1 -1
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/toast.js +1 -1
- package/dist/components/ui/toggle.js +1 -1
- package/dist/constants-CsKm9sSk.js +30 -0
- package/dist/constants-CsKm9sSk.js.map +1 -0
- package/dist/context-3_vY1jbv.js +141 -0
- package/dist/context-3_vY1jbv.js.map +1 -0
- package/dist/context-BE60udRT.js +99 -0
- package/dist/context-BE60udRT.js.map +1 -0
- package/dist/context-BYXeJQnz.d.ts +150 -0
- package/dist/context-BYXeJQnz.d.ts.map +1 -0
- package/dist/context-Bc6VC1HA.js +181 -0
- package/dist/context-Bc6VC1HA.js.map +1 -0
- package/dist/context-BqjZ1Z_w.js +111 -0
- package/dist/context-BqjZ1Z_w.js.map +1 -0
- package/dist/context-CZfRKkcZ.js +204 -0
- package/dist/context-CZfRKkcZ.js.map +1 -0
- package/dist/context-Cn-00gfW.js +169 -0
- package/dist/context-Cn-00gfW.js.map +1 -0
- package/dist/context-Cnlo53sV.d.ts +92 -0
- package/dist/context-Cnlo53sV.d.ts.map +1 -0
- package/dist/context-Rl5VCYA8.js +257 -0
- package/dist/context-Rl5VCYA8.js.map +1 -0
- package/dist/context-sD8DQga-.js +122 -0
- package/dist/context-sD8DQga-.js.map +1 -0
- package/dist/{copy-menu-TIKvPaAZ.js → copy-menu-C5GaT4Z-.js} +2 -2
- package/dist/{copy-menu-TIKvPaAZ.js.map → copy-menu-C5GaT4Z-.js.map} +1 -1
- package/dist/ease-B82HVmio.d.ts +50 -0
- package/dist/ease-B82HVmio.d.ts.map +1 -0
- package/dist/hooks/use-modal-scope.d.ts +6 -0
- package/dist/hooks/use-modal-scope.d.ts.map +1 -0
- package/dist/hooks/use-modal-scope.js +83 -0
- package/dist/hooks/use-modal-scope.js.map +1 -0
- package/dist/lib/ease.d.ts +2 -49
- package/dist/model-DfeFradZ.d.ts +9 -0
- package/dist/model-DfeFradZ.d.ts.map +1 -0
- package/dist/model-DlbIqCZg.d.ts +41 -0
- package/dist/model-DlbIqCZg.d.ts.map +1 -0
- package/dist/plot-CdFTbMI_.js +131 -0
- package/dist/plot-CdFTbMI_.js.map +1 -0
- package/dist/positioner-3mCqiebN.js +204 -0
- package/dist/positioner-3mCqiebN.js.map +1 -0
- package/dist/tooltip-BarafYiU.d.ts +67 -0
- package/dist/tooltip-BarafYiU.d.ts.map +1 -0
- package/dist/tooltip-BqxVD6D-.d.ts +64 -0
- package/dist/tooltip-BqxVD6D-.d.ts.map +1 -0
- package/dist/tooltip-C01qUgsW.d.ts +133 -0
- package/dist/tooltip-C01qUgsW.d.ts.map +1 -0
- package/dist/tooltip-C6qUs7px.d.ts +36 -0
- package/dist/tooltip-C6qUs7px.d.ts.map +1 -0
- package/dist/tooltip-DQ4DXgeu.d.ts +94 -0
- package/dist/tooltip-DQ4DXgeu.d.ts.map +1 -0
- package/dist/types-B_6p3LXz.d.ts +36 -0
- package/dist/types-B_6p3LXz.d.ts.map +1 -0
- package/dist/types-D6e3gWOA.d.ts +22 -0
- package/dist/types-D6e3gWOA.d.ts.map +1 -0
- package/dist/use-geometry-CH0foIo7.d.ts +9 -0
- package/dist/use-geometry-CH0foIo7.d.ts.map +1 -0
- package/dist/utils-B3YXTsDI.js +26 -0
- package/dist/utils-B3YXTsDI.js.map +1 -0
- package/package.json +14 -9
- package/dist/cascader-types-BnH6wYD-.d.ts.map +0 -1
- package/dist/lib/ease.d.ts.map +0 -1
|
@@ -0,0 +1,1002 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button } from "../ui/button.js";
|
|
3
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "../ui/input-group.js";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover.js";
|
|
5
|
+
import { createContext, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { cn } from "@kumix/utils";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { ClockIcon } from "lucide-react";
|
|
9
|
+
import { flushSync } from "react-dom";
|
|
10
|
+
//#region src/components/reui/time-picker.tsx
|
|
11
|
+
const DEFAULT_TIME_PICKER_I18N = {
|
|
12
|
+
labels: {
|
|
13
|
+
placeholder: "Select time",
|
|
14
|
+
hour: "Hour",
|
|
15
|
+
minute: "Minute",
|
|
16
|
+
second: "Second",
|
|
17
|
+
period: "AM/PM",
|
|
18
|
+
am: "AM",
|
|
19
|
+
pm: "PM",
|
|
20
|
+
now: "Now",
|
|
21
|
+
clear: "Clear",
|
|
22
|
+
confirm: "OK",
|
|
23
|
+
panelLabel: "Choose time",
|
|
24
|
+
openPicker: "Open time picker"
|
|
25
|
+
},
|
|
26
|
+
functions: {
|
|
27
|
+
formatSegment: (value) => String(value).padStart(2, "0"),
|
|
28
|
+
formatValue: (time, context) => {
|
|
29
|
+
const { hourCycle, granularity, periodPosition, labels } = context;
|
|
30
|
+
const hour = hourCycle === 12 ? time.hour % 12 || 12 : time.hour;
|
|
31
|
+
let text = `${context.formatSegment(hour, "hour")}:${context.formatSegment(time.minute, "minute")}`;
|
|
32
|
+
if (granularity === "second") text += `:${context.formatSegment(time.second, "second")}`;
|
|
33
|
+
if (hourCycle === 24) return text;
|
|
34
|
+
const period = time.hour < 12 ? labels.am : labels.pm;
|
|
35
|
+
return periodPosition === "start" ? `${period} ${text}` : `${text} ${period}`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/** Merges per section, so an override can carry one key without restating the rest. */
|
|
40
|
+
function mergeTimePickerI18n(overrides) {
|
|
41
|
+
if (!overrides?.labels && !overrides?.functions) return DEFAULT_TIME_PICKER_I18N;
|
|
42
|
+
return {
|
|
43
|
+
labels: {
|
|
44
|
+
...DEFAULT_TIME_PICKER_I18N.labels,
|
|
45
|
+
...overrides.labels
|
|
46
|
+
},
|
|
47
|
+
functions: {
|
|
48
|
+
...DEFAULT_TIME_PICKER_I18N.functions,
|
|
49
|
+
...overrides.functions
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
54
|
+
const toSeconds = (time) => time.hour * 3600 + time.minute * 60 + time.second;
|
|
55
|
+
const periodOf = (hour) => hour < 12 ? "am" : "pm";
|
|
56
|
+
const sameTime = (a, b) => a === b || !!a && !!b && toSeconds(a) === toSeconds(b);
|
|
57
|
+
/**
|
|
58
|
+
* Reads the value format, the one `<input type="time">` uses: `HH:mm` or
|
|
59
|
+
* `HH:mm:ss` in 24-hour time. A fraction of a second is dropped. Anything
|
|
60
|
+
* else, `""` and `24:00` included, reads as no value.
|
|
61
|
+
*/
|
|
62
|
+
function parseTimeValue(value) {
|
|
63
|
+
const match = /^\s*(\d{1,2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?\s*$/.exec(value ?? "");
|
|
64
|
+
if (!match) return null;
|
|
65
|
+
const time = {
|
|
66
|
+
hour: Number(match[1]),
|
|
67
|
+
minute: Number(match[2]),
|
|
68
|
+
second: Number(match[3] ?? 0)
|
|
69
|
+
};
|
|
70
|
+
return time.hour < 24 && time.minute < 60 && time.second < 60 ? time : null;
|
|
71
|
+
}
|
|
72
|
+
/** Writes the value format: `HH:mm`, or `HH:mm:ss` at `second` granularity. */
|
|
73
|
+
function formatTimeValue(time, granularity = "minute") {
|
|
74
|
+
const value = `${pad(time.hour)}:${pad(time.minute)}`;
|
|
75
|
+
return granularity === "second" ? `${value}:${pad(time.second)}` : value;
|
|
76
|
+
}
|
|
77
|
+
function normalizeTyped(text) {
|
|
78
|
+
return text.normalize("NFKC").replace(/[٠-٩]/g, (digit) => String(digit.charCodeAt(0) - 1632)).replace(/[۰-۹]/g, (digit) => String(digit.charCodeAt(0) - 1776)).replace(/[ ]/g, " ").toLowerCase();
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Reads what a person types into `TimePickerInput`: `9`, `930`, `0930`,
|
|
82
|
+
* `9:30`, `14.30`, `14h30`, `2:30 pm`, `2p`, a localized period on either
|
|
83
|
+
* side, and full-width, Arabic-Indic or Persian digits. A 12-hour time typed
|
|
84
|
+
* without a period takes `period`.
|
|
85
|
+
*/
|
|
86
|
+
function parseTimeInput(text, options = {}) {
|
|
87
|
+
const labels = options.labels ?? DEFAULT_TIME_PICKER_I18N.labels;
|
|
88
|
+
let source = normalizeTyped(text).trim();
|
|
89
|
+
let period;
|
|
90
|
+
for (const [label, value] of [[labels.pm, "pm"], [labels.am, "am"]]) {
|
|
91
|
+
const needle = normalizeTyped(label).trim();
|
|
92
|
+
if (needle && source.includes(needle)) {
|
|
93
|
+
period = value;
|
|
94
|
+
source = source.replace(needle, " ").trim();
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!period) {
|
|
99
|
+
const suffix = /\s*([ap])\.?\s*(?:m\.?)?$/.exec(source);
|
|
100
|
+
if (suffix) {
|
|
101
|
+
period = suffix[1] === "a" ? "am" : "pm";
|
|
102
|
+
source = source.slice(0, suffix.index);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (/[^\d\s:.h]/.test(source)) return null;
|
|
106
|
+
const parts = source.split(/[^\d]+/).filter(Boolean);
|
|
107
|
+
let fields = parts;
|
|
108
|
+
if (parts.length === 1 && parts[0].length > 2) {
|
|
109
|
+
const digits = parts[0];
|
|
110
|
+
if (digits.length > 6) return null;
|
|
111
|
+
const hourLength = digits.length % 2 === 1 ? 1 : 2;
|
|
112
|
+
fields = [digits.slice(0, hourLength)];
|
|
113
|
+
for (let index = hourLength; index < digits.length; index += 2) fields.push(digits.slice(index, index + 2));
|
|
114
|
+
}
|
|
115
|
+
if (fields.length === 0 || fields.length > 3) return null;
|
|
116
|
+
if (fields.slice(1).some((field) => field.length !== 2)) return null;
|
|
117
|
+
let hour = Number(fields[0]);
|
|
118
|
+
const minute = Number(fields[1] ?? 0);
|
|
119
|
+
const second = Number(fields[2] ?? 0);
|
|
120
|
+
if (minute > 59 || second > 59) return null;
|
|
121
|
+
const resolved = period ?? (options.hourCycle === 12 && hour >= 1 && hour <= 12 ? options.period ?? "am" : void 0);
|
|
122
|
+
if (resolved) {
|
|
123
|
+
if (hour < 1 || hour > 12) return null;
|
|
124
|
+
hour = hour % 12 + (resolved === "pm" ? 12 : 0);
|
|
125
|
+
}
|
|
126
|
+
return hour < 24 ? {
|
|
127
|
+
hour,
|
|
128
|
+
minute,
|
|
129
|
+
second
|
|
130
|
+
} : null;
|
|
131
|
+
}
|
|
132
|
+
function stepValues(step, limit) {
|
|
133
|
+
const size = Math.floor(step ?? 1);
|
|
134
|
+
if (!Number.isFinite(size)) return [0];
|
|
135
|
+
const values = [];
|
|
136
|
+
for (let value = 0; value < limit; value += Math.max(1, size)) values.push(value);
|
|
137
|
+
return values;
|
|
138
|
+
}
|
|
139
|
+
const gridSize = (grid) => grid.hours.length * grid.minutes.length * grid.seconds.length;
|
|
140
|
+
function timeAt(grid, index) {
|
|
141
|
+
const seconds = grid.seconds.length;
|
|
142
|
+
const minutes = grid.minutes.length;
|
|
143
|
+
return {
|
|
144
|
+
hour: grid.hours[Math.floor(index / (minutes * seconds))],
|
|
145
|
+
minute: grid.minutes[Math.floor(index / seconds) % minutes],
|
|
146
|
+
second: grid.seconds[index % seconds]
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function lastAtOrBelow(values, limit) {
|
|
150
|
+
let found = 0;
|
|
151
|
+
for (let index = 0; index < values.length; index++) if (values[index] <= limit) found = index;
|
|
152
|
+
return found;
|
|
153
|
+
}
|
|
154
|
+
/** The latest grid time at or before `seconds`. Always exists: 00:00:00 is on the grid. */
|
|
155
|
+
function floorIndex(grid, seconds) {
|
|
156
|
+
const hour = lastAtOrBelow(grid.hours, seconds / 3600);
|
|
157
|
+
const inHour = seconds - grid.hours[hour] * 3600;
|
|
158
|
+
const minute = lastAtOrBelow(grid.minutes, inHour / 60);
|
|
159
|
+
const second = lastAtOrBelow(grid.seconds, inHour - grid.minutes[minute] * 60);
|
|
160
|
+
return (hour * grid.minutes.length + minute) * grid.seconds.length + second;
|
|
161
|
+
}
|
|
162
|
+
function spanInWindow(grid, from, to) {
|
|
163
|
+
const { min, max } = grid;
|
|
164
|
+
if (min !== null && max !== null && min > max) return to >= min || from <= max;
|
|
165
|
+
return (min === null || to >= min) && (max === null || from <= max);
|
|
166
|
+
}
|
|
167
|
+
function isEnabled(grid, time) {
|
|
168
|
+
const seconds = toSeconds(time);
|
|
169
|
+
return spanInWindow(grid, seconds, seconds) && !grid.isTimeDisabled?.(formatTimeValue(time, grid.granularity), time);
|
|
170
|
+
}
|
|
171
|
+
function matches(time, filter) {
|
|
172
|
+
return (filter.hour === void 0 || time.hour === filter.hour) && (filter.minute === void 0 || time.minute === filter.minute) && (filter.second === void 0 || time.second === filter.second) && (filter.period === void 0 || periodOf(time.hour) === filter.period);
|
|
173
|
+
}
|
|
174
|
+
/** Whether any enabled time matches `filter`. Hours outside the window cost O(1). */
|
|
175
|
+
function hasEnabled(grid, filter) {
|
|
176
|
+
for (const hour of grid.hours) {
|
|
177
|
+
if (filter.hour !== void 0 && hour !== filter.hour) continue;
|
|
178
|
+
if (filter.period !== void 0 && periodOf(hour) !== filter.period) continue;
|
|
179
|
+
if (!spanInWindow(grid, hour * 3600, hour * 3600 + 3599)) continue;
|
|
180
|
+
for (const minute of grid.minutes) {
|
|
181
|
+
if (filter.minute !== void 0 && minute !== filter.minute) continue;
|
|
182
|
+
for (const second of grid.seconds) {
|
|
183
|
+
if (filter.second !== void 0 && second !== filter.second) continue;
|
|
184
|
+
if (isEnabled(grid, {
|
|
185
|
+
hour,
|
|
186
|
+
minute,
|
|
187
|
+
second
|
|
188
|
+
})) return true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The enabled time closest to `target` among those matching `filter`,
|
|
196
|
+
* walking outwards from it. A tie goes to the earlier time.
|
|
197
|
+
*/
|
|
198
|
+
function nearestEnabled(grid, target, filter = {}) {
|
|
199
|
+
const goal = toSeconds(target);
|
|
200
|
+
const total = gridSize(grid);
|
|
201
|
+
let back = floorIndex(grid, goal);
|
|
202
|
+
let ahead = back + 1;
|
|
203
|
+
while (back >= 0 || ahead < total) {
|
|
204
|
+
const behind = back >= 0 ? timeAt(grid, back) : null;
|
|
205
|
+
const next = ahead < total ? timeAt(grid, ahead) : null;
|
|
206
|
+
const useBack = !!behind && (!next || goal - toSeconds(behind) <= toSeconds(next) - goal);
|
|
207
|
+
const time = useBack ? behind : next;
|
|
208
|
+
if (matches(time, filter) && isEnabled(grid, time)) return time;
|
|
209
|
+
if (useBack) back--;
|
|
210
|
+
else ahead++;
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
/** The first enabled time from `start` in `direction`, optionally wrapping round the day. */
|
|
215
|
+
function walkEnabled(grid, start, direction, wrap) {
|
|
216
|
+
const total = gridSize(grid);
|
|
217
|
+
let index = start;
|
|
218
|
+
for (let step = 0; step < total; step++) {
|
|
219
|
+
if (index < 0 || index >= total) {
|
|
220
|
+
if (!wrap) return null;
|
|
221
|
+
index = (index + total) % total;
|
|
222
|
+
}
|
|
223
|
+
const time = timeAt(grid, index);
|
|
224
|
+
if (isEnabled(grid, time)) return time;
|
|
225
|
+
index += direction;
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
/** The next enabled time after `from`, or before it with -1, wrapping at midnight. */
|
|
230
|
+
function stepEnabled(grid, from, direction) {
|
|
231
|
+
const index = floorIndex(grid, toSeconds(from));
|
|
232
|
+
const onGrid = sameTime(timeAt(grid, index), from);
|
|
233
|
+
return walkEnabled(grid, direction === 1 ? index + 1 : onGrid ? index - 1 : index, direction, true);
|
|
234
|
+
}
|
|
235
|
+
/** The earliest enabled time, counted from `min` so a night shift starts at 22:00. */
|
|
236
|
+
function firstEnabledTime(grid) {
|
|
237
|
+
if (grid.min === null) return walkEnabled(grid, 0, 1, true);
|
|
238
|
+
const index = floorIndex(grid, grid.min);
|
|
239
|
+
return walkEnabled(grid, toSeconds(timeAt(grid, index)) < grid.min ? index + 1 : index, 1, true);
|
|
240
|
+
}
|
|
241
|
+
const TimePickerContext = createContext(null);
|
|
242
|
+
/** "inline" unless a part renders inside `TimePickerContent`. */
|
|
243
|
+
const SurfaceContext = createContext("inline");
|
|
244
|
+
function useTimePickerContext(part) {
|
|
245
|
+
const context = useContext(TimePickerContext);
|
|
246
|
+
if (!context) throw new Error(`${part} must be used within a TimePicker`);
|
|
247
|
+
return context;
|
|
248
|
+
}
|
|
249
|
+
/** The picker's state and actions, inside a `TimePicker`. */
|
|
250
|
+
function useTimePicker() {
|
|
251
|
+
const context = useTimePickerContext("useTimePicker");
|
|
252
|
+
return {
|
|
253
|
+
value: context.time ? formatTimeValue(context.time, context.granularity) : null,
|
|
254
|
+
time: context.time,
|
|
255
|
+
open: context.open,
|
|
256
|
+
setOpen: context.setOpen,
|
|
257
|
+
setValue: (value) => context.commit(parseTimeValue(value)),
|
|
258
|
+
now: () => pickNow(context),
|
|
259
|
+
clear: () => context.select(null),
|
|
260
|
+
confirm: context.confirm
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function pickNow(context) {
|
|
264
|
+
const now = /* @__PURE__ */ new Date();
|
|
265
|
+
const { grid } = context;
|
|
266
|
+
const index = floorIndex(grid, now.getHours() * 3600 + (context.granularity === "hour" ? 0 : now.getMinutes() * 60) + (context.granularity === "second" ? now.getSeconds() : 0));
|
|
267
|
+
const time = walkEnabled(grid, index, 1, false) ?? walkEnabled(grid, index - 1, -1, false);
|
|
268
|
+
if (time) context.select(time);
|
|
269
|
+
}
|
|
270
|
+
function assignRef(ref, node) {
|
|
271
|
+
if (typeof ref === "function") ref(node);
|
|
272
|
+
else if (ref) ref.current = node;
|
|
273
|
+
}
|
|
274
|
+
function TimePicker({ value, defaultValue = null, onValueChange, open: openProp, defaultOpen = false, onOpenChange, hourCycle = 24, granularity = "minute", periodPosition = "end", hourStep, minuteStep, secondStep, min, max, isTimeDisabled, requireConfirm = false, fade = true, disabled = false, readOnly = false, invalid = false, name, form, required = false, inputRef, id: idProp, "aria-label": label, "aria-labelledby": labelledBy, "aria-describedby": describedBy, i18n: i18nProp, placeholder, className, children }) {
|
|
275
|
+
const generatedId = useId();
|
|
276
|
+
const id = idProp ?? generatedId;
|
|
277
|
+
const [uncontrolled, setUncontrolled] = useState(defaultValue);
|
|
278
|
+
const [initialValue] = useState(defaultValue);
|
|
279
|
+
const [openState, setOpenState] = useState(defaultOpen);
|
|
280
|
+
const [draft, setDraft] = useState(null);
|
|
281
|
+
const open = openProp ?? openState;
|
|
282
|
+
const [seenOpen, setSeenOpen] = useState(open);
|
|
283
|
+
if (seenOpen !== open) {
|
|
284
|
+
setSeenOpen(open);
|
|
285
|
+
setDraft(null);
|
|
286
|
+
}
|
|
287
|
+
const goal = useRef(null);
|
|
288
|
+
const focusTarget = useRef(null);
|
|
289
|
+
const columns = useRef(null);
|
|
290
|
+
const fieldRef = useRef(null);
|
|
291
|
+
const resetRef = useRef(() => {});
|
|
292
|
+
const raw = (value !== void 0 ? value : uncontrolled) || null;
|
|
293
|
+
const time = parseTimeValue(raw);
|
|
294
|
+
const i18n = useMemo(() => mergeTimePickerI18n(i18nProp), [i18nProp]);
|
|
295
|
+
const grid = useMemo(() => ({
|
|
296
|
+
hours: stepValues(hourStep, 24),
|
|
297
|
+
minutes: granularity === "hour" ? [0] : stepValues(minuteStep, 60),
|
|
298
|
+
seconds: granularity === "second" ? stepValues(secondStep, 60) : [0],
|
|
299
|
+
min: parseSeconds(min),
|
|
300
|
+
max: parseSeconds(max),
|
|
301
|
+
granularity,
|
|
302
|
+
isTimeDisabled
|
|
303
|
+
}), [
|
|
304
|
+
hourStep,
|
|
305
|
+
minuteStep,
|
|
306
|
+
secondStep,
|
|
307
|
+
granularity,
|
|
308
|
+
min,
|
|
309
|
+
max,
|
|
310
|
+
isTimeDisabled
|
|
311
|
+
]);
|
|
312
|
+
const firstEnabled = useMemo(() => firstEnabledTime(grid), [grid]);
|
|
313
|
+
const setOpen = (next) => {
|
|
314
|
+
if (next && disabled) return;
|
|
315
|
+
if (openProp === void 0) setOpenState(next);
|
|
316
|
+
onOpenChange?.(next);
|
|
317
|
+
};
|
|
318
|
+
const commit = (next) => {
|
|
319
|
+
setDraft(null);
|
|
320
|
+
const nextValue = next ? formatTimeValue(next, granularity) : null;
|
|
321
|
+
if (nextValue === raw) return;
|
|
322
|
+
if (value === void 0) setUncontrolled(nextValue);
|
|
323
|
+
onValueChange?.(nextValue);
|
|
324
|
+
};
|
|
325
|
+
const context = {
|
|
326
|
+
id,
|
|
327
|
+
time,
|
|
328
|
+
display: draft ? draft.time : time,
|
|
329
|
+
grid,
|
|
330
|
+
firstEnabled,
|
|
331
|
+
hourCycle,
|
|
332
|
+
granularity,
|
|
333
|
+
periodPosition,
|
|
334
|
+
i18n,
|
|
335
|
+
disabled,
|
|
336
|
+
readOnly,
|
|
337
|
+
invalid,
|
|
338
|
+
requireConfirm,
|
|
339
|
+
required,
|
|
340
|
+
fade,
|
|
341
|
+
label,
|
|
342
|
+
labelledBy,
|
|
343
|
+
describedBy,
|
|
344
|
+
open,
|
|
345
|
+
setOpen,
|
|
346
|
+
select: (next) => {
|
|
347
|
+
if (disabled || readOnly) return;
|
|
348
|
+
if (requireConfirm) setDraft({ time: next });
|
|
349
|
+
else commit(next);
|
|
350
|
+
},
|
|
351
|
+
commit,
|
|
352
|
+
confirm: () => {
|
|
353
|
+
if (draft) commit(draft.time);
|
|
354
|
+
if (open) setOpen(false);
|
|
355
|
+
},
|
|
356
|
+
hasDraft: draft !== null,
|
|
357
|
+
discardDraft: () => setDraft(null),
|
|
358
|
+
format: (next) => i18n.functions.formatValue(next, {
|
|
359
|
+
hourCycle,
|
|
360
|
+
granularity,
|
|
361
|
+
periodPosition,
|
|
362
|
+
labels: i18n.labels,
|
|
363
|
+
formatSegment: i18n.functions.formatSegment
|
|
364
|
+
}),
|
|
365
|
+
getGoal: () => goal.current,
|
|
366
|
+
setGoal: (next) => {
|
|
367
|
+
goal.current = next;
|
|
368
|
+
},
|
|
369
|
+
registerFocusTarget: (node) => {
|
|
370
|
+
if (node) focusTarget.current = node;
|
|
371
|
+
},
|
|
372
|
+
registerColumns: (node) => {
|
|
373
|
+
columns.current = node;
|
|
374
|
+
},
|
|
375
|
+
getColumns: () => columns.current
|
|
376
|
+
};
|
|
377
|
+
useEffect(() => {
|
|
378
|
+
resetRef.current = () => commit(parseTimeValue(initialValue));
|
|
379
|
+
});
|
|
380
|
+
const hasField = !!name || required;
|
|
381
|
+
useEffect(() => {
|
|
382
|
+
const root = fieldRef.current?.getRootNode();
|
|
383
|
+
if (!root) return;
|
|
384
|
+
let pending = 0;
|
|
385
|
+
const onReset = (event) => {
|
|
386
|
+
if (event.target !== fieldRef.current?.form) return;
|
|
387
|
+
pending = window.setTimeout(() => {
|
|
388
|
+
if (!event.defaultPrevented) resetRef.current();
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
root.addEventListener("reset", onReset, true);
|
|
392
|
+
return () => {
|
|
393
|
+
root.removeEventListener("reset", onReset, true);
|
|
394
|
+
window.clearTimeout(pending);
|
|
395
|
+
};
|
|
396
|
+
}, []);
|
|
397
|
+
return /* @__PURE__ */ jsxs(TimePickerContext.Provider, {
|
|
398
|
+
value: context,
|
|
399
|
+
children: [/* @__PURE__ */ jsx(Popover, {
|
|
400
|
+
open,
|
|
401
|
+
onOpenChange: (next) => setOpen(next),
|
|
402
|
+
children: children === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(TimePickerTrigger, {
|
|
403
|
+
className,
|
|
404
|
+
placeholder
|
|
405
|
+
}), /* @__PURE__ */ jsx(TimePickerContent, {})] }) : children
|
|
406
|
+
}), hasField && /* @__PURE__ */ jsx("input", {
|
|
407
|
+
ref: (node) => {
|
|
408
|
+
fieldRef.current = node;
|
|
409
|
+
assignRef(inputRef, node);
|
|
410
|
+
},
|
|
411
|
+
type: "text",
|
|
412
|
+
name,
|
|
413
|
+
form,
|
|
414
|
+
required,
|
|
415
|
+
disabled,
|
|
416
|
+
value: time ? formatTimeValue(time, granularity) : "",
|
|
417
|
+
onChange: () => {},
|
|
418
|
+
tabIndex: -1,
|
|
419
|
+
"aria-hidden": "true",
|
|
420
|
+
"data-slot": "time-picker-field",
|
|
421
|
+
onFocus: (event) => {
|
|
422
|
+
const target = focusTarget.current ?? columns.current?.querySelector(LIST_SELECTOR);
|
|
423
|
+
if (target) target.focus();
|
|
424
|
+
else event.currentTarget.blur();
|
|
425
|
+
},
|
|
426
|
+
className: "pointer-events-none absolute size-px max-w-px opacity-0"
|
|
427
|
+
})]
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
function parseSeconds(value) {
|
|
431
|
+
const time = parseTimeValue(value);
|
|
432
|
+
return time ? toSeconds(time) : null;
|
|
433
|
+
}
|
|
434
|
+
const CLOCK_ICON = /* @__PURE__ */ jsx(ClockIcon, { "aria-hidden": "true" });
|
|
435
|
+
/** The committed value as text, or the placeholder. For custom trigger content. */
|
|
436
|
+
function TimePickerValue({ placeholder, className, ...props }) {
|
|
437
|
+
const context = useTimePickerContext("TimePickerValue");
|
|
438
|
+
return /* @__PURE__ */ jsx("span", {
|
|
439
|
+
id: `${context.id}-value`,
|
|
440
|
+
"data-slot": "time-picker-value",
|
|
441
|
+
"data-placeholder": context.time ? void 0 : "",
|
|
442
|
+
className: cn("truncate", className),
|
|
443
|
+
...props,
|
|
444
|
+
children: context.time ? context.format(context.time) : placeholder ?? context.i18n.labels.placeholder
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
const TRIGGER_CLASS = "justify-between font-normal normal-case tracking-normal tabular-nums data-placeholder:text-muted-foreground";
|
|
448
|
+
/** A shadcn Button that opens the picker. Children replace the value and icon. */
|
|
449
|
+
function TimePickerTrigger({ className, variant = "outline", placeholder, children, ref, ...props }) {
|
|
450
|
+
const context = useTimePickerContext("TimePickerTrigger");
|
|
451
|
+
const labelledBy = props["aria-labelledby"] ?? context.labelledBy;
|
|
452
|
+
const buttonProps = {
|
|
453
|
+
variant,
|
|
454
|
+
disabled: context.disabled,
|
|
455
|
+
"aria-label": context.label,
|
|
456
|
+
"aria-describedby": context.describedBy,
|
|
457
|
+
...context.invalid && {
|
|
458
|
+
"aria-invalid": true,
|
|
459
|
+
"data-invalid": ""
|
|
460
|
+
},
|
|
461
|
+
...props,
|
|
462
|
+
"aria-labelledby": labelledBy ? `${labelledBy} ${context.id}-value` : void 0,
|
|
463
|
+
id: context.id,
|
|
464
|
+
ref: (node) => {
|
|
465
|
+
context.registerFocusTarget(node);
|
|
466
|
+
assignRef(ref, node);
|
|
467
|
+
},
|
|
468
|
+
"data-slot": "time-picker-trigger",
|
|
469
|
+
"data-placeholder": context.time ? void 0 : "",
|
|
470
|
+
className: cn(TRIGGER_CLASS, className)
|
|
471
|
+
};
|
|
472
|
+
const content = children === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(TimePickerValue, { placeholder }), /* @__PURE__ */ jsx("span", {
|
|
473
|
+
"data-icon": "inline-end",
|
|
474
|
+
"aria-hidden": "true",
|
|
475
|
+
className: "flex text-muted-foreground",
|
|
476
|
+
children: CLOCK_ICON
|
|
477
|
+
})] }) : children;
|
|
478
|
+
return /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
479
|
+
id: context.id,
|
|
480
|
+
render: /* @__PURE__ */ jsx(Button, { ...buttonProps }),
|
|
481
|
+
children: content
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* A typable field with a clock button that opens the picker. Text is read on
|
|
486
|
+
* blur and Enter; ArrowUp and ArrowDown step to the next selectable time and
|
|
487
|
+
* Alt+ArrowDown opens the popover.
|
|
488
|
+
*/
|
|
489
|
+
function TimePickerInput({ className, placeholder, onBlur, onKeyDown, onChange, ref, ...props }) {
|
|
490
|
+
const context = useTimePickerContext("TimePickerInput");
|
|
491
|
+
const { grid, time } = context;
|
|
492
|
+
const [text, setText] = useState(null);
|
|
493
|
+
const shown = text ?? (time ? context.format(time) : "");
|
|
494
|
+
const mask = context.hourCycle === 12 ? context.periodPosition === "start" ? "-- --:--" : "--:-- --" : context.granularity === "second" ? "--:--:--" : "--:--";
|
|
495
|
+
const parse = (source) => {
|
|
496
|
+
if (context.hourCycle === 24) return parseTimeInput(source, { labels: context.i18n.labels });
|
|
497
|
+
const period = time ? periodOf(time.hour) : context.firstEnabled ? periodOf(context.firstEnabled.hour) : "am";
|
|
498
|
+
const options = {
|
|
499
|
+
hourCycle: 12,
|
|
500
|
+
labels: context.i18n.labels
|
|
501
|
+
};
|
|
502
|
+
const here = parseTimeInput(source, {
|
|
503
|
+
...options,
|
|
504
|
+
period
|
|
505
|
+
});
|
|
506
|
+
const there = parseTimeInput(source, {
|
|
507
|
+
...options,
|
|
508
|
+
period: period === "am" ? "pm" : "am"
|
|
509
|
+
});
|
|
510
|
+
if (!here || !there || sameTime(here, there)) return here;
|
|
511
|
+
const inBounds = (typed) => spanInWindow(grid, toSeconds(typed), toSeconds(typed));
|
|
512
|
+
if (inBounds(here)) return here;
|
|
513
|
+
return inBounds(there) ? there : here;
|
|
514
|
+
};
|
|
515
|
+
const read = () => {
|
|
516
|
+
if (text === null) return;
|
|
517
|
+
setText(null);
|
|
518
|
+
if (!text.trim()) return context.commit(null);
|
|
519
|
+
if (text === (time ? context.format(time) : "")) return;
|
|
520
|
+
const typed = parse(text);
|
|
521
|
+
if (!typed) return;
|
|
522
|
+
const truncated = {
|
|
523
|
+
hour: typed.hour,
|
|
524
|
+
minute: context.granularity === "hour" ? 0 : typed.minute,
|
|
525
|
+
second: context.granularity === "second" ? typed.second : 0
|
|
526
|
+
};
|
|
527
|
+
const next = nearestEnabled(grid, truncated);
|
|
528
|
+
if (next) context.commit(next);
|
|
529
|
+
};
|
|
530
|
+
const clockProps = {
|
|
531
|
+
size: "icon-xs",
|
|
532
|
+
disabled: context.disabled,
|
|
533
|
+
"aria-label": context.i18n.labels.openPicker,
|
|
534
|
+
"data-slot": "time-picker-input-trigger"
|
|
535
|
+
};
|
|
536
|
+
return /* @__PURE__ */ jsxs(InputGroup, {
|
|
537
|
+
"data-slot": "time-picker-input",
|
|
538
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
539
|
+
className,
|
|
540
|
+
children: [/* @__PURE__ */ jsx(InputGroupInput, {
|
|
541
|
+
value: shown,
|
|
542
|
+
placeholder: placeholder ?? mask,
|
|
543
|
+
disabled: context.disabled,
|
|
544
|
+
readOnly: context.readOnly,
|
|
545
|
+
required: context.required,
|
|
546
|
+
autoComplete: "off",
|
|
547
|
+
autoCorrect: "off",
|
|
548
|
+
autoCapitalize: "off",
|
|
549
|
+
spellCheck: false,
|
|
550
|
+
"aria-keyshortcuts": "Alt+ArrowDown",
|
|
551
|
+
"aria-label": context.label,
|
|
552
|
+
"aria-labelledby": context.labelledBy,
|
|
553
|
+
"aria-describedby": context.describedBy,
|
|
554
|
+
"aria-invalid": context.invalid || void 0,
|
|
555
|
+
className: "tabular-nums",
|
|
556
|
+
onChange: (event) => {
|
|
557
|
+
onChange?.(event);
|
|
558
|
+
setText(event.target.value);
|
|
559
|
+
},
|
|
560
|
+
onBlur: (event) => {
|
|
561
|
+
onBlur?.(event);
|
|
562
|
+
read();
|
|
563
|
+
},
|
|
564
|
+
onKeyDown: (event) => {
|
|
565
|
+
onKeyDown?.(event);
|
|
566
|
+
if (event.defaultPrevented) return;
|
|
567
|
+
if (event.key === "Enter") flushSync(() => read());
|
|
568
|
+
else if (event.key === "Escape" && text !== null) {
|
|
569
|
+
event.preventDefault();
|
|
570
|
+
setText(null);
|
|
571
|
+
} else if (event.altKey && event.key === "ArrowDown") {
|
|
572
|
+
event.preventDefault();
|
|
573
|
+
read();
|
|
574
|
+
context.setOpen(true);
|
|
575
|
+
} else if ((event.key === "ArrowUp" || event.key === "ArrowDown") && !event.altKey && !context.readOnly) {
|
|
576
|
+
event.preventDefault();
|
|
577
|
+
const direction = event.key === "ArrowUp" ? 1 : -1;
|
|
578
|
+
const from = text !== null && parse(text) || time;
|
|
579
|
+
const next = from ? stepEnabled(grid, from, direction) : direction === 1 ? context.firstEnabled : walkEnabled(grid, gridSize(grid) - 1, -1, true);
|
|
580
|
+
setText(null);
|
|
581
|
+
if (next) context.commit(next);
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
...props,
|
|
585
|
+
id: context.id,
|
|
586
|
+
ref: (node) => {
|
|
587
|
+
context.registerFocusTarget(node);
|
|
588
|
+
assignRef(ref, node);
|
|
589
|
+
}
|
|
590
|
+
}), /* @__PURE__ */ jsx(InputGroupAddon, {
|
|
591
|
+
align: "inline-end",
|
|
592
|
+
children: /* @__PURE__ */ jsx(PopoverTrigger, {
|
|
593
|
+
render: /* @__PURE__ */ jsx(InputGroupButton, { ...clockProps }),
|
|
594
|
+
children: CLOCK_ICON
|
|
595
|
+
})
|
|
596
|
+
})]
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
const TABBABLE = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
600
|
+
/**
|
|
601
|
+
* The popover: columns and footer by default. Tab cycles inside it, as in a
|
|
602
|
+
* date picker dialog, in both twins.
|
|
603
|
+
*/
|
|
604
|
+
function TimePickerContent({ className, align = "start", onKeyDown, children, ...props }) {
|
|
605
|
+
const context = useTimePickerContext("TimePickerContent");
|
|
606
|
+
return /* @__PURE__ */ jsx(PopoverContent, {
|
|
607
|
+
align,
|
|
608
|
+
"aria-labelledby": context.labelledBy,
|
|
609
|
+
"aria-label": context.labelledBy ? void 0 : context.label ?? context.i18n.labels.panelLabel,
|
|
610
|
+
className: cn("w-auto gap-0 overflow-hidden p-0", className),
|
|
611
|
+
onKeyDown: (event) => {
|
|
612
|
+
onKeyDown?.(event);
|
|
613
|
+
if (event.defaultPrevented || event.key !== "Tab") return;
|
|
614
|
+
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
615
|
+
const items = Array.from(event.currentTarget.querySelectorAll(TABBABLE));
|
|
616
|
+
const active = event.currentTarget.ownerDocument.activeElement;
|
|
617
|
+
const first = items[0];
|
|
618
|
+
const last = items[items.length - 1];
|
|
619
|
+
if (!event.shiftKey && active === last) {
|
|
620
|
+
event.preventDefault();
|
|
621
|
+
first?.focus();
|
|
622
|
+
} else if (event.shiftKey && active === first) {
|
|
623
|
+
event.preventDefault();
|
|
624
|
+
last?.focus();
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
...props,
|
|
628
|
+
children: /* @__PURE__ */ jsx(SurfaceContext.Provider, {
|
|
629
|
+
value: "popup",
|
|
630
|
+
children: children === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(TimePickerColumns, {}), /* @__PURE__ */ jsx(TimePickerFooter, {})] }) : children
|
|
631
|
+
})
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* The columns and the footer, rendered in place: put it straight inside a
|
|
636
|
+
* `TimePicker`, with no trigger or content, for an always-open picker.
|
|
637
|
+
*/
|
|
638
|
+
function TimePickerPanel({ className, children, ...props }) {
|
|
639
|
+
const context = useTimePickerContext("TimePickerPanel");
|
|
640
|
+
const inline = useContext(SurfaceContext) === "inline";
|
|
641
|
+
return /* @__PURE__ */ jsx("div", {
|
|
642
|
+
role: inline ? "group" : void 0,
|
|
643
|
+
"aria-labelledby": inline ? context.labelledBy : void 0,
|
|
644
|
+
"aria-label": inline && !context.labelledBy ? context.label ?? context.i18n.labels.panelLabel : void 0,
|
|
645
|
+
"data-slot": "time-picker-panel",
|
|
646
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
647
|
+
className: cn("flex w-fit flex-col", className),
|
|
648
|
+
...props,
|
|
649
|
+
children: children === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(TimePickerColumns, {}), /* @__PURE__ */ jsx(TimePickerFooter, {})] }) : children
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* The row of columns: one per unit the picker needs by default. Always left
|
|
654
|
+
* to right, because a time reads hour first in right-to-left text too.
|
|
655
|
+
*/
|
|
656
|
+
function TimePickerColumns({ className, children, ref, ...props }) {
|
|
657
|
+
const context = useTimePickerContext("TimePickerColumns");
|
|
658
|
+
const { display, granularity } = context;
|
|
659
|
+
const period = context.hourCycle === 12 && /* @__PURE__ */ jsx(TimePickerColumn, { type: "period" });
|
|
660
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
661
|
+
dir: "ltr",
|
|
662
|
+
"data-slot": "time-picker-columns",
|
|
663
|
+
className: cn("flex divide-x", className),
|
|
664
|
+
...props,
|
|
665
|
+
ref: (node) => {
|
|
666
|
+
context.registerColumns(node);
|
|
667
|
+
assignRef(ref, node);
|
|
668
|
+
},
|
|
669
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
670
|
+
id: `${context.id}-current`,
|
|
671
|
+
hidden: true,
|
|
672
|
+
children: display ? context.format(display) : context.i18n.labels.placeholder
|
|
673
|
+
}), children === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
674
|
+
context.periodPosition === "start" && period,
|
|
675
|
+
/* @__PURE__ */ jsx(TimePickerColumn, { type: "hour" }),
|
|
676
|
+
granularity !== "hour" && /* @__PURE__ */ jsx(TimePickerColumn, { type: "minute" }),
|
|
677
|
+
granularity === "second" && /* @__PURE__ */ jsx(TimePickerColumn, { type: "second" }),
|
|
678
|
+
context.periodPosition === "end" && period
|
|
679
|
+
] }) : children]
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
const LIST_SELECTOR = "[data-slot=\"time-picker-column-list\"]:not([aria-disabled=\"true\"])";
|
|
683
|
+
const COLUMN_CLASS = "group/time-picker-column flex min-w-16 flex-1 flex-col [--time-picker-option-height:calc(var(--spacing)*7)] [--time-picker-list-padding:calc(var(--spacing)*1)]";
|
|
684
|
+
const LABEL_CLASS = "text-muted-foreground text-center text-xs whitespace-nowrap transition-colors select-none group-has-focus-visible/time-picker-column:text-foreground px-1.5 pt-2 pb-1";
|
|
685
|
+
const LIST_CLASS = "group/time-picker-list relative flex h-[calc(var(--time-picker-option-height)*var(--time-picker-rows,5)+var(--spacing)*(var(--time-picker-rows,5)-1)+var(--time-picker-list-padding)*2)] flex-col gap-1 overflow-y-auto overscroll-contain px-2 py-(--time-picker-list-padding) outline-none [scrollbar-width:none] data-empty:focus-visible:outline-solid data-empty:focus-visible:outline-2 data-empty:focus-visible:-outline-offset-2 data-empty:focus-visible:outline-ring data-fade:[mask-image:linear-gradient(to_bottom,transparent,#000_var(--time-picker-fade-start,0px),#000_calc(100%-var(--time-picker-fade-end,0px)),transparent)] data-overflow-start:[--time-picker-fade-start:var(--time-picker-fade-size,var(--time-picker-option-height))] data-overflow-end:[--time-picker-fade-end:var(--time-picker-fade-size,var(--time-picker-option-height))] [&::-webkit-scrollbar]:hidden";
|
|
686
|
+
const OPTION_CLASS = "flex h-(--time-picker-option-height) shrink-0 cursor-default items-center justify-center tabular-nums transition-[color,background-color,box-shadow] duration-100 select-none not-aria-selected:hover:bg-accent not-aria-selected:hover:text-accent-foreground aria-selected:bg-primary aria-selected:font-medium aria-selected:text-primary-foreground aria-disabled:pointer-events-none aria-disabled:opacity-50 forced-colors:aria-selected:bg-[Highlight] forced-colors:aria-selected:text-[HighlightText] forced-colors:group-focus-visible/time-picker-list:data-highlighted:outline-solid forced-colors:group-focus-visible/time-picker-list:data-highlighted:outline-2 group-focus-visible/time-picker-list:data-highlighted:ring-3 ring-ring/50 rounded-md text-sm";
|
|
687
|
+
function syncOverflow(list) {
|
|
688
|
+
list.toggleAttribute("data-overflow-start", list.scrollTop > 1);
|
|
689
|
+
list.toggleAttribute("data-overflow-end", list.scrollTop + list.clientHeight < list.scrollHeight - 1);
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* One unit as a listbox. Selection follows the keyboard, like a native wheel.
|
|
693
|
+
* Renders nothing for a unit the granularity or the hour cycle leaves out.
|
|
694
|
+
*/
|
|
695
|
+
function TimePickerColumn({ type, label, className, ...props }) {
|
|
696
|
+
const context = useTimePickerContext("TimePickerColumn");
|
|
697
|
+
const { display, grid, hourCycle, i18n, firstEnabled } = context;
|
|
698
|
+
const baseId = useId();
|
|
699
|
+
const listRef = useRef(null);
|
|
700
|
+
const typeahead = useRef({
|
|
701
|
+
text: "",
|
|
702
|
+
at: 0
|
|
703
|
+
});
|
|
704
|
+
const listPeriod = display ? periodOf(display.hour) : firstEnabled ? periodOf(firstEnabled.hour) : "am";
|
|
705
|
+
const displayHour = display?.hour;
|
|
706
|
+
const displayMinute = display?.minute;
|
|
707
|
+
const options = columnOptions(type, grid, useMemo(() => {
|
|
708
|
+
if (type === "period") return [hasEnabled(grid, { period: "am" }), hasEnabled(grid, { period: "pm" })];
|
|
709
|
+
if (type === "hour") return grid.hours.map((hour) => hasEnabled(grid, { hour }));
|
|
710
|
+
return (type === "minute" ? grid.minutes : grid.seconds).map((value) => hasEnabled(grid, {
|
|
711
|
+
hour: displayHour,
|
|
712
|
+
minute: type === "second" ? displayMinute : value,
|
|
713
|
+
second: type === "second" ? value : void 0
|
|
714
|
+
}));
|
|
715
|
+
}, [
|
|
716
|
+
type,
|
|
717
|
+
grid,
|
|
718
|
+
displayHour,
|
|
719
|
+
displayMinute
|
|
720
|
+
]), hourCycle, listPeriod, i18n);
|
|
721
|
+
const current = display ? type === "period" ? periodOf(display.hour) : display[type] : void 0;
|
|
722
|
+
const selectedIndex = options.findIndex((option) => option.value === current);
|
|
723
|
+
const enabled = options.flatMap((option, index) => option.disabled ? [] : [index]);
|
|
724
|
+
const highlightIndex = highlightFor(options, enabled, selectedIndex, current, firstEnabled && !display ? columnValueOf(firstEnabled, type) : void 0);
|
|
725
|
+
const highlighted = highlightIndex === -1 ? void 0 : options[highlightIndex];
|
|
726
|
+
const optionId = (option) => `${baseId}-${option.value}`;
|
|
727
|
+
const highlightedId = highlighted ? optionId(highlighted) : void 0;
|
|
728
|
+
const interactive = !context.disabled;
|
|
729
|
+
const editable = interactive && !context.readOnly;
|
|
730
|
+
useLayoutEffect(() => {
|
|
731
|
+
const list = listRef.current;
|
|
732
|
+
if (!list) return;
|
|
733
|
+
const center = () => {
|
|
734
|
+
const option = highlightedId ? list.ownerDocument.getElementById(highlightedId) : null;
|
|
735
|
+
if (option) list.scrollTop = option.offsetTop - (list.clientHeight - option.offsetHeight) / 2;
|
|
736
|
+
syncOverflow(list);
|
|
737
|
+
};
|
|
738
|
+
center();
|
|
739
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
740
|
+
const observer = new ResizeObserver(center);
|
|
741
|
+
observer.observe(list);
|
|
742
|
+
return () => observer.disconnect();
|
|
743
|
+
}, [highlightedId]);
|
|
744
|
+
if (type === "period" && hourCycle !== 12 || type === "minute" && context.granularity === "hour" || type === "second" && context.granularity !== "second") return null;
|
|
745
|
+
const pick = (option) => {
|
|
746
|
+
if (option.disabled || !editable) return;
|
|
747
|
+
const kept = context.getGoal();
|
|
748
|
+
const base = kept && sameTime(kept.result, display) ? kept.goal : display ?? {
|
|
749
|
+
hour: 0,
|
|
750
|
+
minute: 0,
|
|
751
|
+
second: 0
|
|
752
|
+
};
|
|
753
|
+
const target = option.value === "am" || option.value === "pm" ? {
|
|
754
|
+
...base,
|
|
755
|
+
hour: base.hour % 12 + (option.value === "pm" ? 12 : 0)
|
|
756
|
+
} : {
|
|
757
|
+
...base,
|
|
758
|
+
[type]: option.value
|
|
759
|
+
};
|
|
760
|
+
const filter = type === "period" ? { period: option.value } : { [type]: option.value };
|
|
761
|
+
const time = nearestEnabled(grid, target, filter);
|
|
762
|
+
if (!time) return;
|
|
763
|
+
context.setGoal({
|
|
764
|
+
goal: target,
|
|
765
|
+
result: time
|
|
766
|
+
});
|
|
767
|
+
context.select(time);
|
|
768
|
+
};
|
|
769
|
+
const onKeyDown = (event) => {
|
|
770
|
+
if (event.ctrlKey || event.metaKey || event.nativeEvent.isComposing) return;
|
|
771
|
+
if (event.altKey) {
|
|
772
|
+
if (event.key === "ArrowUp" && context.open) {
|
|
773
|
+
event.preventDefault();
|
|
774
|
+
context.confirm();
|
|
775
|
+
}
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const down = event.key === "ArrowDown" || event.key === "PageDown";
|
|
779
|
+
let position = selectedIndex;
|
|
780
|
+
if (position === -1) {
|
|
781
|
+
const above = typeof current === "number" ? options.findIndex((option) => typeof option.value === "number" && option.value > current) : -1;
|
|
782
|
+
position = typeof current === "number" ? (above === -1 ? options.length : above) - .5 : highlightIndex === -1 ? -.5 : highlightIndex + (down ? -.5 : .5);
|
|
783
|
+
}
|
|
784
|
+
const move = (index) => {
|
|
785
|
+
event.preventDefault();
|
|
786
|
+
if (index !== void 0) pick(options[index]);
|
|
787
|
+
};
|
|
788
|
+
const last = enabled[enabled.length - 1];
|
|
789
|
+
switch (event.key) {
|
|
790
|
+
case "ArrowDown": return move(enabled.find((index) => index > position));
|
|
791
|
+
case "ArrowUp": return move(findLast(enabled, (index) => index < position));
|
|
792
|
+
case "Home": return move(enabled[0]);
|
|
793
|
+
case "End": return move(last);
|
|
794
|
+
case "PageDown": return move(enabled.find((index) => index >= position + 5) ?? last);
|
|
795
|
+
case "PageUp": return move(findLast(enabled, (index) => index <= position - 5) ?? enabled[0]);
|
|
796
|
+
case "ArrowLeft":
|
|
797
|
+
case "ArrowRight": {
|
|
798
|
+
event.preventDefault();
|
|
799
|
+
const lists = Array.from(context.getColumns()?.querySelectorAll(LIST_SELECTOR) ?? []);
|
|
800
|
+
lists[lists.indexOf(event.currentTarget) + (event.key === "ArrowRight" ? 1 : -1)]?.focus();
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
case " ":
|
|
804
|
+
event.preventDefault();
|
|
805
|
+
if (highlighted && highlightIndex !== selectedIndex) pick(highlighted);
|
|
806
|
+
return;
|
|
807
|
+
case "Enter":
|
|
808
|
+
event.preventDefault();
|
|
809
|
+
if (highlighted && highlightIndex !== selectedIndex) pick(highlighted);
|
|
810
|
+
return context.confirm();
|
|
811
|
+
case "Escape":
|
|
812
|
+
if (!context.open && context.hasDraft) {
|
|
813
|
+
event.preventDefault();
|
|
814
|
+
event.stopPropagation();
|
|
815
|
+
context.discardDraft();
|
|
816
|
+
}
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
const key = normalizeTyped(event.key);
|
|
820
|
+
if (key.length !== 1) return;
|
|
821
|
+
if (type === "period") {
|
|
822
|
+
const found = enabled.filter((index) => {
|
|
823
|
+
const option = options[index];
|
|
824
|
+
return option.value === (key === "a" ? "am" : key === "p" ? "pm" : "") || normalizeTyped(option.label).startsWith(key);
|
|
825
|
+
});
|
|
826
|
+
if (found.length === 0) return;
|
|
827
|
+
move(found[(found.indexOf(highlightIndex) + 1) % found.length]);
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
if (!/\d/.test(key)) return;
|
|
831
|
+
const buffer = typeahead.current;
|
|
832
|
+
let typed = !(event.timeStamp - buffer.at > 1e3) && buffer.text.length === 1 ? buffer.text + key : key;
|
|
833
|
+
const find = (text) => options.findIndex((option) => !option.disabled && option.typed === Number(text));
|
|
834
|
+
let index = find(typed);
|
|
835
|
+
if (index === -1 && typed.length === 2) {
|
|
836
|
+
typed = key;
|
|
837
|
+
index = find(typed);
|
|
838
|
+
}
|
|
839
|
+
if (index === -1) index = options.findIndex((option) => !option.disabled && option.typed !== null && pad(option.typed).startsWith(typed));
|
|
840
|
+
typeahead.current = {
|
|
841
|
+
text: typed,
|
|
842
|
+
at: event.timeStamp
|
|
843
|
+
};
|
|
844
|
+
if (index !== -1) move(index);
|
|
845
|
+
};
|
|
846
|
+
const headerId = `${baseId}-label`;
|
|
847
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
848
|
+
"data-slot": "time-picker-column",
|
|
849
|
+
"data-type": type,
|
|
850
|
+
className: cn(COLUMN_CLASS, className),
|
|
851
|
+
...props,
|
|
852
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
853
|
+
id: headerId,
|
|
854
|
+
"data-slot": "time-picker-column-label",
|
|
855
|
+
className: LABEL_CLASS,
|
|
856
|
+
children: label ?? i18n.labels[type]
|
|
857
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
858
|
+
ref: listRef,
|
|
859
|
+
role: "listbox",
|
|
860
|
+
"aria-labelledby": headerId,
|
|
861
|
+
"aria-describedby": `${context.id}-current`,
|
|
862
|
+
"aria-activedescendant": highlightedId,
|
|
863
|
+
"aria-disabled": context.disabled || void 0,
|
|
864
|
+
"aria-readonly": context.readOnly || void 0,
|
|
865
|
+
tabIndex: interactive ? 0 : -1,
|
|
866
|
+
"data-slot": "time-picker-column-list",
|
|
867
|
+
"data-empty": highlighted ? void 0 : "",
|
|
868
|
+
"data-fade": context.fade ? "" : void 0,
|
|
869
|
+
onKeyDown: interactive ? onKeyDown : void 0,
|
|
870
|
+
onScroll: (event) => syncOverflow(event.currentTarget),
|
|
871
|
+
className: LIST_CLASS,
|
|
872
|
+
children: options.map((option, index) => /* @__PURE__ */ jsx("div", {
|
|
873
|
+
id: optionId(option),
|
|
874
|
+
role: "option",
|
|
875
|
+
"aria-selected": index === selectedIndex,
|
|
876
|
+
"aria-disabled": option.disabled || void 0,
|
|
877
|
+
"data-highlighted": index === highlightIndex ? "" : void 0,
|
|
878
|
+
"data-slot": "time-picker-option",
|
|
879
|
+
onClick: editable ? () => pick(option) : void 0,
|
|
880
|
+
className: OPTION_CLASS,
|
|
881
|
+
children: option.label
|
|
882
|
+
}, option.value))
|
|
883
|
+
})]
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
function columnValueOf(time, type) {
|
|
887
|
+
return type === "period" ? periodOf(time.hour) : time[type];
|
|
888
|
+
}
|
|
889
|
+
function columnOptions(type, grid, flags, hourCycle, period, i18n) {
|
|
890
|
+
const { formatSegment } = i18n.functions;
|
|
891
|
+
if (type === "period") return ["am", "pm"].map((value, index) => ({
|
|
892
|
+
value,
|
|
893
|
+
label: i18n.labels[value],
|
|
894
|
+
typed: null,
|
|
895
|
+
disabled: !flags[index]
|
|
896
|
+
}));
|
|
897
|
+
if (type === "hour") return grid.hours.flatMap((hour, index) => {
|
|
898
|
+
if (hourCycle === 12 && periodOf(hour) !== period) return [];
|
|
899
|
+
const shown = hourCycle === 12 ? hour % 12 || 12 : hour;
|
|
900
|
+
return [{
|
|
901
|
+
value: hour,
|
|
902
|
+
label: formatSegment(shown, "hour"),
|
|
903
|
+
typed: shown,
|
|
904
|
+
disabled: !flags[index]
|
|
905
|
+
}];
|
|
906
|
+
});
|
|
907
|
+
return (type === "minute" ? grid.minutes : grid.seconds).map((value, index) => ({
|
|
908
|
+
value,
|
|
909
|
+
label: formatSegment(value, type),
|
|
910
|
+
typed: value,
|
|
911
|
+
disabled: !flags[index]
|
|
912
|
+
}));
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* The row the keyboard sits on: the selection; for a value off the steps
|
|
916
|
+
* the enabled row below it; when empty, the first enabled time's row.
|
|
917
|
+
*/
|
|
918
|
+
function highlightFor(options, enabled, selectedIndex, current, first) {
|
|
919
|
+
if (selectedIndex !== -1) return selectedIndex;
|
|
920
|
+
if (typeof current === "number") return findLast(enabled, (index) => {
|
|
921
|
+
const value = options[index].value;
|
|
922
|
+
return typeof value === "number" && value < current;
|
|
923
|
+
}) ?? enabled[0] ?? -1;
|
|
924
|
+
return enabled.find((index) => options[index].value === first) ?? enabled[0] ?? -1;
|
|
925
|
+
}
|
|
926
|
+
function findLast(items, test) {
|
|
927
|
+
for (let index = items.length - 1; index >= 0; index--) if (test(items[index])) return items[index];
|
|
928
|
+
}
|
|
929
|
+
const FOOTER_CLASS = "flex items-center justify-between gap-2 border-t p-1.5";
|
|
930
|
+
/** The action row. Without children: Now and Clear, plus OK in a popover or under `requireConfirm`. */
|
|
931
|
+
function TimePickerFooter({ className, children, ...props }) {
|
|
932
|
+
const context = useTimePickerContext("TimePickerFooter");
|
|
933
|
+
const popup = useContext(SurfaceContext) === "popup";
|
|
934
|
+
return /* @__PURE__ */ jsx("div", {
|
|
935
|
+
"data-slot": "time-picker-footer",
|
|
936
|
+
className: cn(FOOTER_CLASS, className),
|
|
937
|
+
...props,
|
|
938
|
+
children: children === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
939
|
+
/* @__PURE__ */ jsx(TimePickerNow, {}),
|
|
940
|
+
/* @__PURE__ */ jsx(TimePickerClear, {}),
|
|
941
|
+
(popup || context.requireConfirm) && /* @__PURE__ */ jsx(TimePickerConfirm, {})
|
|
942
|
+
] }) : children
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
/** Sets the current time, floored to the steps and moved inside the bounds. */
|
|
946
|
+
function TimePickerNow({ variant = "ghost", size = "sm", onClick, children, ...props }) {
|
|
947
|
+
const context = useTimePickerContext("TimePickerNow");
|
|
948
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
949
|
+
type: "button",
|
|
950
|
+
variant,
|
|
951
|
+
size,
|
|
952
|
+
disabled: context.disabled || context.readOnly,
|
|
953
|
+
"data-slot": "time-picker-now",
|
|
954
|
+
onClick: (event) => {
|
|
955
|
+
onClick?.(event);
|
|
956
|
+
if (!event.defaultPrevented) pickNow(context);
|
|
957
|
+
},
|
|
958
|
+
...props,
|
|
959
|
+
children: children === void 0 ? context.i18n.labels.now : children
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
/** Empties the value, then hands focus to the first column. */
|
|
963
|
+
function TimePickerClear({ variant = "ghost", size = "sm", className, onClick, children, ...props }) {
|
|
964
|
+
const context = useTimePickerContext("TimePickerClear");
|
|
965
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
966
|
+
type: "button",
|
|
967
|
+
variant,
|
|
968
|
+
size,
|
|
969
|
+
disabled: context.disabled || context.readOnly,
|
|
970
|
+
"data-slot": "time-picker-clear",
|
|
971
|
+
className: cn("text-muted-foreground", className),
|
|
972
|
+
onClick: (event) => {
|
|
973
|
+
onClick?.(event);
|
|
974
|
+
if (event.defaultPrevented) return;
|
|
975
|
+
context.select(null);
|
|
976
|
+
context.getColumns()?.querySelector(LIST_SELECTOR)?.focus({ preventScroll: true });
|
|
977
|
+
},
|
|
978
|
+
...props,
|
|
979
|
+
children: children === void 0 ? context.i18n.labels.clear : children
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
/** Commits a pending draft and closes the popover. */
|
|
983
|
+
function TimePickerConfirm({ variant, size = "sm", onClick, children, ...props }) {
|
|
984
|
+
const context = useTimePickerContext("TimePickerConfirm");
|
|
985
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
986
|
+
type: "button",
|
|
987
|
+
variant: variant ?? (context.requireConfirm ? "default" : "secondary"),
|
|
988
|
+
size,
|
|
989
|
+
disabled: context.disabled,
|
|
990
|
+
"data-slot": "time-picker-confirm",
|
|
991
|
+
onClick: (event) => {
|
|
992
|
+
onClick?.(event);
|
|
993
|
+
if (!event.defaultPrevented) context.confirm();
|
|
994
|
+
},
|
|
995
|
+
...props,
|
|
996
|
+
children: children === void 0 ? context.i18n.labels.confirm : children
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
//#endregion
|
|
1000
|
+
export { DEFAULT_TIME_PICKER_I18N, TimePicker, TimePickerClear, TimePickerColumn, TimePickerColumns, TimePickerConfirm, TimePickerContent, TimePickerFooter, TimePickerInput, TimePickerNow, TimePickerPanel, TimePickerTrigger, TimePickerValue, formatTimeValue, mergeTimePickerI18n, parseTimeInput, parseTimeValue, useTimePicker };
|
|
1001
|
+
|
|
1002
|
+
//# sourceMappingURL=time-picker.js.map
|