@jcsoftdev/ui 0.2.3 → 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/CHANGELOG.md +390 -7
- package/README.md +57 -3
- package/bin/ui-theme.mjs +1162 -25
- package/dist/ai/attachment/attachment.js +1 -1
- package/dist/ai/chat-list/group.js +3 -1
- package/dist/ai/conversation/conversation.js +1 -1
- package/dist/ai/internal/use-copy.d.ts +1 -5
- package/dist/ai/internal/use-copy.js +1 -32
- package/dist/ai/markdown/parse.js +59 -17
- package/dist/ai/source/source.js +1 -1
- package/dist/atoms/avatar/avatar.d.ts +13 -3
- package/dist/atoms/avatar/avatar.js +40 -2
- package/dist/atoms/avatar/index.d.ts +1 -1
- package/dist/atoms/avatar/index.js +3 -1
- package/dist/atoms/button/button.d.ts +4 -1
- package/dist/atoms/button/button.js +4 -2
- package/dist/atoms/checkbox/checkbox.d.ts +8 -3
- package/dist/atoms/checkbox/checkbox.js +26 -3
- package/dist/atoms/chip/chip.d.ts +19 -5
- package/dist/atoms/chip/chip.js +34 -5
- package/dist/atoms/chip/index.d.ts +1 -1
- package/dist/atoms/chip/index.js +6 -1
- package/dist/atoms/due-chip/due-chip.d.ts +31 -0
- package/dist/atoms/due-chip/due-chip.js +41 -0
- package/dist/atoms/due-chip/index.d.ts +2 -0
- package/dist/atoms/due-chip/index.js +6 -0
- package/dist/atoms/due-chip/model.d.ts +25 -0
- package/dist/atoms/due-chip/model.js +44 -0
- package/dist/atoms/icon-button/icon-button.d.ts +22 -0
- package/dist/atoms/icon-button/icon-button.js +38 -0
- package/dist/atoms/icon-button/index.d.ts +1 -0
- package/dist/atoms/icon-button/index.js +8 -0
- package/dist/atoms/index.d.ts +5 -0
- package/dist/atoms/index.js +5 -0
- package/dist/atoms/internal/hit-area.d.ts +6 -0
- package/dist/atoms/internal/hit-area.js +4 -0
- package/dist/atoms/kbd/index.d.ts +1 -0
- package/dist/atoms/kbd/index.js +4 -0
- package/dist/atoms/kbd/kbd.d.ts +7 -0
- package/dist/atoms/kbd/kbd.js +17 -0
- package/dist/atoms/radio-group/radio-group.js +6 -2
- package/dist/atoms/seal/index.d.ts +1 -0
- package/dist/atoms/seal/index.js +4 -0
- package/dist/atoms/seal/seal.d.ts +30 -0
- package/dist/atoms/seal/seal.js +71 -0
- package/dist/atoms/spinner/index.d.ts +1 -0
- package/dist/atoms/spinner/index.js +5 -0
- package/dist/atoms/spinner/spinner.d.ts +19 -0
- package/dist/atoms/spinner/spinner.js +31 -0
- package/dist/atoms/status-dot/index.d.ts +1 -1
- package/dist/atoms/status-dot/status-dot.d.ts +4 -2
- package/dist/atoms/status-dot/status-dot.js +5 -1
- package/dist/atoms/switch/switch.js +3 -1
- package/dist/calendar/date-calendar/date-calendar.d.ts +32 -0
- package/dist/calendar/date-calendar/date-calendar.js +189 -0
- package/dist/calendar/date-calendar/index.d.ts +1 -0
- package/dist/calendar/date-calendar/index.js +6 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/internal/date-utils.d.ts +26 -0
- package/dist/calendar/internal/date-utils.js +95 -1
- package/dist/charts/bar-chart/bar-race-chart.js +1 -0
- package/dist/charts/beeswarm-chart/beeswarm-chart.js +1 -1
- package/dist/charts/chord-chart/chord-chart.js +13 -5
- package/dist/charts/core/cartesian/cartesian-chart.d.ts +1 -1
- package/dist/charts/core/cartesian/cartesian-chart.js +48 -11
- package/dist/charts/core/cartesian/layout.d.ts +6 -1
- package/dist/charts/core/cartesian/layout.js +14 -5
- package/dist/charts/core/cartesian/marks.d.ts +2 -2
- package/dist/charts/core/cartesian/marks.js +1 -1
- package/dist/charts/core/cartesian/types.d.ts +28 -2
- package/dist/charts/core/category-explorer.d.ts +2 -2
- package/dist/charts/core/category-explorer.js +8 -4
- package/dist/charts/core/chart-dock.d.ts +26 -0
- package/dist/charts/core/chart-dock.js +45 -0
- package/dist/charts/core/chart-frame.d.ts +9 -2
- package/dist/charts/core/chart-frame.js +105 -25
- package/dist/charts/core/distribution/explorer.d.ts +5 -2
- package/dist/charts/core/distribution/explorer.js +12 -5
- package/dist/charts/core/distribution/xy-points.js +1 -1
- package/dist/charts/core/index.d.ts +3 -0
- package/dist/charts/core/index.js +3 -0
- package/dist/charts/core/leave-grace.d.ts +11 -0
- package/dist/charts/core/leave-grace.js +26 -0
- package/dist/charts/core/nearest.d.ts +14 -0
- package/dist/charts/core/nearest.js +22 -0
- package/dist/charts/core/plot-overlay.js +9 -3
- package/dist/charts/core/pointer.test-utils.d.ts +38 -0
- package/dist/charts/core/pointer.test-utils.js +123 -0
- package/dist/charts/core/tooltip.d.ts +25 -2
- package/dist/charts/core/tooltip.js +115 -40
- package/dist/charts/core/touch-select.d.ts +20 -0
- package/dist/charts/core/touch-select.js +184 -0
- package/dist/charts/core/types.d.ts +8 -4
- package/dist/charts/core/types.js +5 -0
- package/dist/charts/core/use-index-navigation.d.ts +17 -6
- package/dist/charts/core/use-index-navigation.js +47 -10
- package/dist/charts/donut-chart/donut-chart.d.ts +5 -1
- package/dist/charts/donut-chart/donut-chart.js +40 -1
- package/dist/charts/donut-chart/slice-labels.d.ts +20 -0
- package/dist/charts/donut-chart/slice-labels.js +20 -0
- package/dist/charts/dumbbell-chart/dumbbell-chart.js +6 -3
- package/dist/charts/fill-gauge-chart/fill-gauge-chart.js +1 -0
- package/dist/charts/funnel-chart/funnel-chart.js +2 -1
- package/dist/charts/gauge-chart/gauge-chart.js +2 -1
- package/dist/charts/heatmap-chart/heatmap-chart.d.ts +4 -1
- package/dist/charts/heatmap-chart/heatmap-chart.js +3 -1
- package/dist/charts/heatmap-chart/heatmap-grid.d.ts +4 -1
- package/dist/charts/heatmap-chart/heatmap-grid.js +3 -1
- package/dist/charts/hex-tile-map/hex-tile-map.js +124 -115
- package/dist/charts/hierarchy-morph/hierarchy-morph.js +2 -1
- package/dist/charts/icicle-chart/icicle-chart.js +7 -9
- package/dist/charts/lollipop-chart/lollipop-chart.js +6 -3
- package/dist/charts/maps/geo/map-viewport.js +1 -1
- package/dist/charts/polar-area-chart/polar-area-chart.js +42 -12
- package/dist/charts/progress-units/progress-units.js +1 -0
- package/dist/charts/radar-chart/radar-chart.js +1 -1
- package/dist/charts/radial-bar-chart/radial-bar-chart.js +2 -1
- package/dist/charts/range-area-chart/range-area-chart.js +3 -2
- package/dist/charts/sankey-chart/sankey-chart.js +12 -4
- package/dist/charts/tree-chart/tree-chart.js +1 -0
- package/dist/charts/treemap-chart/treemap-chart.js +2 -7
- package/dist/charts/waterfall-chart/waterfall-chart.js +6 -3
- package/dist/containers/action-bar/action-bar.d.ts +11 -2
- package/dist/containers/action-bar/action-bar.js +4 -1
- package/dist/containers/aside/aside.d.ts +14 -0
- package/dist/containers/aside/aside.js +25 -0
- package/dist/containers/aside/index.d.ts +1 -0
- package/dist/containers/aside/index.js +5 -0
- package/dist/containers/banner/banner.d.ts +4 -1
- package/dist/containers/banner/banner.js +9 -1
- package/dist/containers/card/card.d.ts +21 -3
- package/dist/containers/card/card.js +20 -5
- package/dist/containers/description-list/description-list.d.ts +29 -6
- package/dist/containers/description-list/description-list.js +47 -6
- package/dist/containers/feed/feed.d.ts +23 -0
- package/dist/containers/feed/feed.js +77 -0
- package/dist/containers/feed/index.d.ts +2 -0
- package/dist/containers/feed/index.js +10 -0
- package/dist/containers/feed/model.d.ts +19 -0
- package/dist/containers/feed/model.js +38 -0
- package/dist/containers/grid/grid.d.ts +15 -0
- package/dist/containers/grid/grid.js +24 -0
- package/dist/containers/grid/index.d.ts +1 -0
- package/dist/containers/grid/index.js +4 -0
- package/dist/containers/index.d.ts +9 -0
- package/dist/containers/index.js +9 -0
- package/dist/containers/kpi/kpi.d.ts +60 -7
- package/dist/containers/kpi/kpi.js +142 -28
- package/dist/containers/kpi-group/index.d.ts +1 -1
- package/dist/containers/kpi-group/index.js +3 -1
- package/dist/containers/kpi-group/kpi-group.d.ts +9 -1
- package/dist/containers/kpi-group/kpi-group.js +11 -1
- package/dist/containers/list-detail/index.d.ts +1 -0
- package/dist/containers/list-detail/index.js +20 -0
- package/dist/containers/list-detail/list-detail.d.ts +55 -0
- package/dist/containers/list-detail/list-detail.js +221 -0
- package/dist/containers/note/index.d.ts +1 -0
- package/dist/containers/note/index.js +4 -0
- package/dist/containers/note/note.d.ts +13 -0
- package/dist/containers/note/note.js +27 -0
- package/dist/containers/page/index.d.ts +1 -0
- package/dist/containers/page/index.js +4 -0
- package/dist/containers/page/page.d.ts +7 -0
- package/dist/containers/page/page.js +14 -0
- package/dist/containers/page-header/page-header.d.ts +8 -3
- package/dist/containers/page-header/page-header.js +35 -8
- package/dist/containers/responsive-list/responsive-list.d.ts +1 -1
- package/dist/containers/responsive-list/responsive-list.js +6 -3
- package/dist/containers/section/index.d.ts +1 -0
- package/dist/containers/section/index.js +6 -0
- package/dist/containers/section/section.d.ts +68 -0
- package/dist/containers/section/section.js +198 -0
- package/dist/containers/shortcuts/index.d.ts +1 -0
- package/dist/containers/shortcuts/index.js +8 -0
- package/dist/containers/shortcuts/shortcuts.d.ts +18 -0
- package/dist/containers/shortcuts/shortcuts.js +50 -0
- package/dist/containers/stack/index.d.ts +1 -0
- package/dist/containers/stack/index.js +6 -0
- package/dist/containers/stack/stack.d.ts +15 -0
- package/dist/containers/stack/stack.js +43 -0
- package/dist/containers/table/selection.d.ts +9 -0
- package/dist/containers/table/selection.js +20 -0
- package/dist/containers/table/table.d.ts +66 -4
- package/dist/containers/table/table.js +128 -7
- package/dist/containers/timeline/index.d.ts +1 -1
- package/dist/containers/timeline/index.js +4 -2
- package/dist/containers/timeline/timeline.d.ts +32 -5
- package/dist/containers/timeline/timeline.js +154 -90
- package/dist/forms/chip-group/chip-group.d.ts +54 -0
- package/dist/forms/chip-group/chip-group.js +114 -0
- package/dist/forms/chip-group/index.d.ts +1 -0
- package/dist/forms/chip-group/index.js +6 -0
- package/dist/forms/combobox/combobox.d.ts +60 -0
- package/dist/forms/combobox/combobox.js +281 -0
- package/dist/forms/combobox/index.d.ts +1 -0
- package/dist/forms/combobox/index.js +6 -0
- package/dist/forms/copy-field/copy-field.d.ts +17 -0
- package/dist/forms/copy-field/copy-field.js +72 -0
- package/dist/forms/copy-field/index.d.ts +1 -0
- package/dist/forms/copy-field/index.js +4 -0
- package/dist/forms/date-picker/date-picker.d.ts +40 -0
- package/dist/forms/date-picker/date-picker.js +183 -0
- package/dist/forms/date-picker/date-time-picker.d.ts +43 -0
- package/dist/forms/date-picker/date-time-picker.js +121 -0
- package/dist/forms/date-picker/index.d.ts +2 -0
- package/dist/forms/date-picker/index.js +10 -0
- package/dist/forms/date-picker/model.d.ts +35 -0
- package/dist/forms/date-picker/model.js +83 -0
- package/dist/forms/dropzone/dropzone.d.ts +30 -2
- package/dist/forms/dropzone/dropzone.js +153 -23
- package/dist/forms/emoji-picker/emoji-picker.js +1 -1
- package/dist/forms/field/field.d.ts +16 -10
- package/dist/forms/field/field.js +41 -5
- package/dist/forms/form/form.d.ts +15 -0
- package/dist/forms/form/form.js +29 -0
- package/dist/forms/form/index.d.ts +1 -0
- package/dist/forms/form/index.js +10 -0
- package/dist/forms/index.d.ts +6 -0
- package/dist/forms/index.js +6 -0
- package/dist/forms/input/index.d.ts +1 -1
- package/dist/forms/input/index.js +6 -2
- package/dist/forms/input/input.d.ts +23 -3
- package/dist/forms/input/input.js +78 -7
- package/dist/forms/input-icon/input-icon.d.ts +1 -1
- package/dist/forms/internal/listbox-items.d.ts +18 -0
- package/dist/forms/internal/listbox-items.js +88 -0
- package/dist/forms/internal/listbox.d.ts +44 -0
- package/dist/forms/internal/listbox.js +74 -0
- package/dist/forms/number-stepper/model.d.ts +16 -0
- package/dist/forms/number-stepper/model.js +23 -0
- package/dist/forms/number-stepper/number-stepper.d.ts +36 -6
- package/dist/forms/number-stepper/number-stepper.js +86 -37
- package/dist/forms/select-menu/index.d.ts +1 -0
- package/dist/forms/select-menu/index.js +6 -0
- package/dist/forms/select-menu/select-menu.d.ts +35 -0
- package/dist/forms/select-menu/select-menu.js +230 -0
- package/dist/glass/crystal-map.d.ts +70 -0
- package/dist/glass/crystal-map.js +88 -0
- package/dist/glass/displacement-map.d.ts +117 -0
- package/dist/glass/displacement-map.js +201 -0
- package/dist/glass/index.d.ts +8 -0
- package/dist/glass/index.js +63 -0
- package/dist/glass/lens-crystal.d.ts +29 -0
- package/dist/glass/lens-crystal.js +161 -0
- package/dist/glass/lens-dispersion.d.ts +11 -0
- package/dist/glass/lens-dispersion.js +19 -0
- package/dist/glass/liquid-glass.d.ts +41 -0
- package/dist/glass/liquid-glass.js +256 -0
- package/dist/glass/liquid-motion.d.ts +53 -0
- package/dist/glass/liquid-motion.js +302 -0
- package/dist/glass/liquid-options.d.ts +162 -0
- package/dist/glass/liquid-options.js +179 -0
- package/dist/glass/refraction.d.ts +100 -0
- package/dist/glass/refraction.js +714 -0
- package/dist/glass/specular-map.d.ts +26 -0
- package/dist/glass/specular-map.js +75 -0
- package/dist/glass/spring.d.ts +79 -0
- package/dist/glass/spring.js +58 -0
- package/dist/glass/support.d.ts +13 -0
- package/dist/glass/support.js +14 -0
- package/dist/glass/use-glass-refraction.d.ts +8 -0
- package/dist/glass/use-glass-refraction.js +16 -0
- package/dist/i18n/strings.d.ts +113 -0
- package/dist/i18n/strings.js +70 -2
- package/dist/i18n/ui-strings-provider.d.ts +1 -1
- package/dist/i18n/ui-strings-provider.js +6 -2
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +4 -0
- package/dist/icons/key.d.ts +2 -0
- package/dist/icons/key.js +12 -0
- package/dist/icons/webhook.d.ts +2 -0
- package/dist/icons/webhook.js +12 -0
- package/dist/liquid/index.d.ts +3 -0
- package/dist/liquid/index.js +29 -0
- package/dist/navigation/breadcrumbs/breadcrumbs.d.ts +29 -0
- package/dist/navigation/breadcrumbs/breadcrumbs.js +70 -0
- package/dist/navigation/breadcrumbs/index.d.ts +1 -0
- package/dist/navigation/breadcrumbs/index.js +6 -0
- package/dist/navigation/index.d.ts +2 -0
- package/dist/navigation/index.js +2 -0
- package/dist/navigation/segmented/index.d.ts +1 -1
- package/dist/navigation/segmented/model.d.ts +5 -0
- package/dist/navigation/segmented/model.js +6 -0
- package/dist/navigation/segmented/segmented.d.ts +17 -3
- package/dist/navigation/segmented/segmented.js +20 -4
- package/dist/navigation/stepper/index.d.ts +1 -1
- package/dist/navigation/stepper/index.js +3 -1
- package/dist/navigation/stepper/stepper.d.ts +8 -0
- package/dist/navigation/stepper/stepper.js +68 -45
- package/dist/navigation/tabs/index.d.ts +1 -0
- package/dist/navigation/tabs/index.js +6 -0
- package/dist/navigation/tabs/tabs-nav.d.ts +37 -0
- package/dist/navigation/tabs/tabs-nav.js +57 -0
- package/dist/navigation/wizard/index.d.ts +1 -0
- package/dist/navigation/wizard/index.js +6 -0
- package/dist/navigation/wizard/model.d.ts +33 -0
- package/dist/navigation/wizard/model.js +34 -0
- package/dist/navigation/wizard/wizard.d.ts +45 -0
- package/dist/navigation/wizard/wizard.js +169 -0
- package/dist/overlays/alert-dialog/alert-dialog.d.ts +103 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +342 -0
- package/dist/overlays/alert-dialog/index.d.ts +1 -0
- package/dist/overlays/alert-dialog/index.js +26 -0
- package/dist/overlays/context-menu/context-menu.d.ts +9 -1
- package/dist/overlays/context-menu/context-menu.js +4 -1
- package/dist/overlays/dialog/dialog.d.ts +9 -1
- package/dist/overlays/dialog/dialog.js +3 -0
- package/dist/overlays/drawer/drawer.d.ts +9 -1
- package/dist/overlays/drawer/drawer.js +3 -0
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +25 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +14 -4
- package/dist/overlays/dropdown-menu/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/index.js +8 -2
- package/dist/overlays/hover-card/hover-card.d.ts +10 -1
- package/dist/overlays/hover-card/hover-card.js +4 -1
- package/dist/overlays/index.d.ts +2 -0
- package/dist/overlays/index.js +2 -0
- package/dist/overlays/popover/popover.d.ts +9 -1
- package/dist/overlays/popover/popover.js +3 -0
- package/dist/overlays/testing/index.d.ts +5 -0
- package/dist/overlays/testing/index.js +4 -0
- package/dist/overlays/toaster/index.d.ts +2 -1
- package/dist/overlays/toaster/index.js +4 -2
- package/dist/overlays/toaster/toast-store.d.ts +6 -2
- package/dist/overlays/toaster/toast.d.ts +3 -0
- package/dist/overlays/toaster/toast.js +3 -0
- package/dist/overlays/toaster/toaster.d.ts +3 -0
- package/dist/overlays/toaster/toaster.js +36 -3
- package/dist/overlays/tooltip/index.d.ts +1 -0
- package/dist/overlays/tooltip/index.js +4 -0
- package/dist/overlays/tooltip/model.d.ts +10 -0
- package/dist/overlays/tooltip/model.js +13 -0
- package/dist/overlays/tooltip/tooltip.d.ts +41 -0
- package/dist/overlays/tooltip/tooltip.js +116 -0
- package/dist/palette/command-palette/command-palette.d.ts +12 -2
- package/dist/palette/command-palette/command-palette.js +5 -0
- package/dist/primitives/command/command.d.ts +3 -2
- package/dist/primitives/command/command.js +2 -0
- package/dist/primitives/menu/menu.js +1 -1
- package/dist/primitives/popper/popper.js +5 -0
- package/dist/primitives/use-dismissable-layer.js +1 -1
- package/dist/rich-text/rich-text-editor.js +94 -8
- package/dist/rich-text/sanitize.js +70 -20
- package/dist/shell/app-shell/app-shell.d.ts +17 -0
- package/dist/shell/app-shell/app-shell.js +44 -4
- package/dist/shell/bottom-nav/bottom-nav.d.ts +34 -0
- package/dist/shell/bottom-nav/bottom-nav.js +124 -0
- package/dist/shell/bottom-nav/index.d.ts +2 -0
- package/dist/shell/bottom-nav/index.js +9 -0
- package/dist/shell/bottom-nav/split.d.ts +11 -0
- package/dist/shell/bottom-nav/split.js +10 -0
- package/dist/shell/sidebar/sidebar.d.ts +16 -2
- package/dist/shell/sidebar/sidebar.js +46 -4
- package/dist/shell/topbar/topbar.d.ts +20 -9
- package/dist/shell/topbar/topbar.js +16 -9
- package/dist/states/empty-state/empty-state.d.ts +3 -1
- package/dist/states/empty-state/empty-state.js +9 -1
- package/dist/states/error-state/error-state.d.ts +8 -1
- package/dist/states/error-state/error-state.js +15 -9
- package/dist/states/index.d.ts +1 -0
- package/dist/states/index.js +1 -0
- package/dist/states/live-status-bar/index.d.ts +1 -0
- package/dist/states/live-status-bar/index.js +6 -0
- package/dist/states/live-status-bar/live-status-bar.d.ts +17 -0
- package/dist/states/live-status-bar/live-status-bar.js +49 -0
- package/dist/states/offline-banner/offline-banner.d.ts +3 -1
- package/dist/states/offline-banner/offline-banner.js +8 -4
- package/dist/states/skeleton/skeleton.d.ts +8 -2
- package/dist/states/skeleton/skeleton.js +44 -2
- package/dist/utils/class-groups.js +17 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/material.d.ts +13 -0
- package/dist/utils/material.js +6 -0
- package/dist/utils/tone.d.ts +8 -0
- package/dist/utils/tone.js +17 -0
- package/dist/utils/use-copy.d.ts +5 -0
- package/dist/utils/use-copy.js +35 -0
- package/icons/svg/key.svg +5 -0
- package/icons/svg/webhook.svg +5 -0
- package/package.json +31 -21
- package/scripts/build-theme.d.mts +22 -0
- package/scripts/build-theme.mjs +248 -5
- package/src/ai/attachment/attachment.tsx +1 -1
- package/src/ai/chat-list/group.ts +3 -1
- package/src/ai/conversation/conversation.tsx +1 -1
- package/src/ai/internal/use-copy.ts +1 -38
- package/src/ai/markdown/parse.ts +74 -17
- package/src/ai/source/source.tsx +1 -1
- package/src/atoms/avatar/avatar.tsx +57 -4
- package/src/atoms/avatar/index.ts +8 -1
- package/src/atoms/button/button.tsx +8 -3
- package/src/atoms/checkbox/checkbox.tsx +33 -4
- package/src/atoms/chip/chip.tsx +55 -8
- package/src/atoms/chip/index.ts +9 -1
- package/src/atoms/due-chip/due-chip.tsx +75 -0
- package/src/atoms/due-chip/index.ts +2 -0
- package/src/atoms/due-chip/model.ts +67 -0
- package/src/atoms/icon-button/icon-button.tsx +58 -0
- package/src/atoms/icon-button/index.ts +6 -0
- package/src/atoms/index.ts +5 -0
- package/src/atoms/internal/hit-area.ts +7 -0
- package/src/atoms/kbd/index.ts +1 -0
- package/src/atoms/kbd/kbd.tsx +20 -0
- package/src/atoms/radio-group/radio-group.tsx +8 -2
- package/src/atoms/seal/index.ts +1 -0
- package/src/atoms/seal/seal.tsx +107 -0
- package/src/atoms/spinner/index.ts +1 -0
- package/src/atoms/spinner/spinner.tsx +49 -0
- package/src/atoms/status-dot/index.ts +1 -0
- package/src/atoms/status-dot/status-dot.tsx +15 -3
- package/src/atoms/switch/switch.tsx +3 -1
- package/src/calendar/date-calendar/date-calendar.tsx +230 -0
- package/src/calendar/date-calendar/index.ts +5 -0
- package/src/calendar/index.ts +1 -0
- package/src/calendar/internal/date-utils.ts +115 -0
- package/src/charts/README.md +21 -0
- package/src/charts/bar-chart/bar-race-chart.tsx +1 -0
- package/src/charts/beeswarm-chart/beeswarm-chart.tsx +1 -1
- package/src/charts/chord-chart/chord-chart.tsx +13 -5
- package/src/charts/core/cartesian/cartesian-chart.tsx +55 -10
- package/src/charts/core/cartesian/layout.ts +29 -10
- package/src/charts/core/cartesian/marks.tsx +3 -3
- package/src/charts/core/cartesian/types.ts +30 -2
- package/src/charts/core/category-explorer.tsx +12 -6
- package/src/charts/core/chart-dock.tsx +68 -0
- package/src/charts/core/chart-frame.tsx +116 -27
- package/src/charts/core/distribution/explorer.tsx +17 -7
- package/src/charts/core/distribution/xy-points.tsx +1 -1
- package/src/charts/core/index.ts +3 -0
- package/src/charts/core/leave-grace.ts +35 -0
- package/src/charts/core/nearest.ts +38 -0
- package/src/charts/core/plot-overlay.tsx +9 -3
- package/src/charts/core/pointer.test-utils.ts +146 -0
- package/src/charts/core/tooltip.tsx +129 -15
- package/src/charts/core/touch-select.ts +250 -0
- package/src/charts/core/types.ts +13 -4
- package/src/charts/core/use-index-navigation.ts +70 -11
- package/src/charts/donut-chart/donut-chart.tsx +53 -3
- package/src/charts/donut-chart/slice-labels.ts +39 -0
- package/src/charts/dumbbell-chart/dumbbell-chart.tsx +8 -3
- package/src/charts/fill-gauge-chart/fill-gauge-chart.tsx +1 -0
- package/src/charts/funnel-chart/funnel-chart.tsx +2 -1
- package/src/charts/gauge-chart/gauge-chart.tsx +2 -1
- package/src/charts/heatmap-chart/heatmap-chart.tsx +5 -0
- package/src/charts/heatmap-chart/heatmap-grid.tsx +5 -1
- package/src/charts/hex-tile-map/hex-tile-map.tsx +6 -1
- package/src/charts/hierarchy-morph/hierarchy-morph.tsx +2 -1
- package/src/charts/icicle-chart/icicle-chart.tsx +8 -9
- package/src/charts/lollipop-chart/lollipop-chart.tsx +8 -3
- package/src/charts/maps/geo/map-viewport.tsx +1 -1
- package/src/charts/polar-area-chart/polar-area-chart.tsx +37 -12
- package/src/charts/progress-units/progress-units.tsx +1 -0
- package/src/charts/radar-chart/radar-chart.tsx +1 -1
- package/src/charts/radial-bar-chart/radial-bar-chart.tsx +2 -1
- package/src/charts/range-area-chart/range-area-chart.tsx +3 -2
- package/src/charts/sankey-chart/sankey-chart.tsx +12 -4
- package/src/charts/tree-chart/tree-chart.tsx +1 -0
- package/src/charts/treemap-chart/treemap-chart.tsx +2 -7
- package/src/charts/waterfall-chart/waterfall-chart.tsx +8 -3
- package/src/containers/action-bar/action-bar.tsx +13 -2
- package/src/containers/aside/aside.tsx +40 -0
- package/src/containers/aside/index.ts +1 -0
- package/src/containers/banner/banner.tsx +18 -1
- package/src/containers/card/card.tsx +43 -4
- package/src/containers/description-list/description-list.tsx +85 -9
- package/src/containers/feed/feed.tsx +99 -0
- package/src/containers/feed/index.ts +8 -0
- package/src/containers/feed/model.ts +54 -0
- package/src/containers/grid/grid.tsx +37 -0
- package/src/containers/grid/index.ts +1 -0
- package/src/containers/index.ts +9 -0
- package/src/containers/kpi/kpi.tsx +231 -38
- package/src/containers/kpi-group/index.ts +7 -1
- package/src/containers/kpi-group/kpi-group.tsx +26 -1
- package/src/containers/list-detail/index.ts +15 -0
- package/src/containers/list-detail/list-detail.tsx +293 -0
- package/src/containers/note/index.ts +1 -0
- package/src/containers/note/note.tsx +38 -0
- package/src/containers/page/index.ts +1 -0
- package/src/containers/page/page.tsx +17 -0
- package/src/containers/page-header/page-header.tsx +38 -8
- package/src/containers/responsive-list/responsive-list.tsx +7 -4
- package/src/containers/section/index.ts +11 -0
- package/src/containers/section/section.tsx +281 -0
- package/src/containers/shortcuts/index.ts +6 -0
- package/src/containers/shortcuts/shortcuts.tsx +92 -0
- package/src/containers/stack/index.ts +7 -0
- package/src/containers/stack/stack.tsx +55 -0
- package/src/containers/table/selection.ts +26 -0
- package/src/containers/table/table.tsx +215 -13
- package/src/containers/timeline/index.ts +3 -0
- package/src/containers/timeline/timeline.tsx +204 -93
- package/src/forms/chip-group/chip-group.tsx +184 -0
- package/src/forms/chip-group/index.ts +8 -0
- package/src/forms/combobox/combobox.tsx +359 -0
- package/src/forms/combobox/index.ts +7 -0
- package/src/forms/copy-field/copy-field.tsx +88 -0
- package/src/forms/copy-field/index.ts +1 -0
- package/src/forms/date-picker/date-picker.tsx +239 -0
- package/src/forms/date-picker/date-time-picker.tsx +178 -0
- package/src/forms/date-picker/index.ts +10 -0
- package/src/forms/date-picker/model.ts +108 -0
- package/src/forms/dropzone/dropzone.tsx +217 -35
- package/src/forms/emoji-picker/emoji-picker.tsx +1 -1
- package/src/forms/field/field.tsx +72 -7
- package/src/forms/form/form.tsx +46 -0
- package/src/forms/form/index.ts +8 -0
- package/src/forms/index.ts +6 -0
- package/src/forms/input/index.ts +8 -1
- package/src/forms/input/input.tsx +103 -7
- package/src/forms/input-icon/input-icon.tsx +1 -1
- package/src/forms/internal/listbox-items.tsx +103 -0
- package/src/forms/internal/listbox.ts +124 -0
- package/src/forms/number-stepper/model.ts +35 -0
- package/src/forms/number-stepper/number-stepper.tsx +132 -42
- package/src/forms/select-menu/index.ts +7 -0
- package/src/forms/select-menu/select-menu.tsx +280 -0
- package/src/glass/crystal-map.ts +150 -0
- package/src/glass/displacement-map.ts +317 -0
- package/src/glass/index.ts +43 -0
- package/src/glass/lens-crystal.ts +226 -0
- package/src/glass/lens-dispersion.ts +34 -0
- package/src/glass/liquid-glass.tsx +371 -0
- package/src/glass/liquid-motion.ts +395 -0
- package/src/glass/liquid-options.ts +306 -0
- package/src/glass/refraction.ts +1010 -0
- package/src/glass/specular-map.ts +95 -0
- package/src/glass/spring.ts +98 -0
- package/src/glass/support.ts +27 -0
- package/src/glass/use-glass-refraction.ts +21 -0
- package/src/i18n/strings.ts +113 -0
- package/src/i18n/ui-strings-provider.tsx +15 -4
- package/src/icons/index.ts +2 -0
- package/src/icons/key.tsx +13 -0
- package/src/icons/webhook.tsx +13 -0
- package/src/liquid/index.ts +24 -0
- package/src/navigation/breadcrumbs/breadcrumbs.tsx +103 -0
- package/src/navigation/breadcrumbs/index.ts +8 -0
- package/src/navigation/index.ts +2 -0
- package/src/navigation/segmented/index.ts +1 -0
- package/src/navigation/segmented/model.ts +11 -0
- package/src/navigation/segmented/segmented.tsx +45 -6
- package/src/navigation/stepper/index.ts +7 -1
- package/src/navigation/stepper/stepper.tsx +41 -5
- package/src/navigation/tabs/index.ts +7 -0
- package/src/navigation/tabs/tabs-nav.tsx +131 -0
- package/src/navigation/wizard/index.ts +7 -0
- package/src/navigation/wizard/model.ts +61 -0
- package/src/navigation/wizard/wizard.tsx +222 -0
- package/src/overlays/alert-dialog/alert-dialog.tsx +486 -0
- package/src/overlays/alert-dialog/index.ts +19 -0
- package/src/overlays/context-menu/context-menu.tsx +11 -1
- package/src/overlays/dialog/dialog.tsx +10 -0
- package/src/overlays/drawer/drawer.tsx +10 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +38 -4
- package/src/overlays/dropdown-menu/index.ts +3 -0
- package/src/overlays/hover-card/hover-card.tsx +12 -1
- package/src/overlays/index.ts +2 -0
- package/src/overlays/popover/popover.tsx +10 -0
- package/src/overlays/testing/index.ts +5 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +6 -2
- package/src/overlays/toaster/toast.ts +6 -0
- package/src/overlays/toaster/toaster.tsx +44 -2
- package/src/overlays/tooltip/index.ts +1 -0
- package/src/overlays/tooltip/model.ts +18 -0
- package/src/overlays/tooltip/tooltip.tsx +166 -0
- package/src/palette/command-palette/command-palette.tsx +15 -1
- package/src/primitives/command/command.tsx +4 -0
- package/src/primitives/menu/menu.tsx +1 -1
- package/src/primitives/popper/popper.tsx +10 -0
- package/src/primitives/use-dismissable-layer.ts +7 -2
- package/src/rich-text/rich-text-editor.tsx +116 -13
- package/src/rich-text/sanitize.ts +94 -23
- package/src/shell/app-shell/app-shell.tsx +60 -4
- package/src/shell/bottom-nav/bottom-nav.tsx +187 -0
- package/src/shell/bottom-nav/index.ts +8 -0
- package/src/shell/bottom-nav/split.ts +20 -0
- package/src/shell/sidebar/sidebar.tsx +51 -5
- package/src/shell/topbar/topbar.tsx +81 -58
- package/src/states/empty-state/empty-state.tsx +11 -1
- package/src/states/error-state/error-state.tsx +23 -8
- package/src/states/index.ts +1 -0
- package/src/states/live-status-bar/index.ts +6 -0
- package/src/states/live-status-bar/live-status-bar.tsx +62 -0
- package/src/states/offline-banner/offline-banner.tsx +13 -5
- package/src/states/skeleton/skeleton.tsx +68 -2
- package/src/utils/class-groups.ts +17 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/material.ts +16 -0
- package/src/utils/tone.ts +29 -0
- package/src/utils/use-copy.ts +38 -0
- package/styles/Theme.kt +64 -3
- package/styles/base.css +51 -0
- package/styles/tailwind.css +836 -0
- package/styles/theme.css +579 -34
- package/styles/tokens.css +788 -15
- package/tokens/default.json +918 -29
- package/scripts/build-theme.d.ts +0 -18
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { type ComponentProps, type KeyboardEvent, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { DateCalendar } from "../../calendar/date-calendar/date-calendar.js";
|
|
5
|
+
import { isIsoDate, type WeekStart } from "../../calendar/internal/date-utils.js";
|
|
6
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
7
|
+
import { Calendar as CalendarIcon, X } from "../../icons/index.js";
|
|
8
|
+
import * as PopoverPrimitive from "../../primitives/popover/popover.js";
|
|
9
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
10
|
+
import { cn } from "../../utils/cn.js";
|
|
11
|
+
import { useComposedRefs } from "../../utils/compose.js";
|
|
12
|
+
import { type Material, materialClass } from "../../utils/material.js";
|
|
13
|
+
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
14
|
+
import {
|
|
15
|
+
dateFormatFor,
|
|
16
|
+
displayPlaceholder,
|
|
17
|
+
formatDisplay,
|
|
18
|
+
maskDisplay,
|
|
19
|
+
parseDisplay,
|
|
20
|
+
} from "./model.js";
|
|
21
|
+
|
|
22
|
+
export type DatePickerPart = "root" | "input" | "clear" | "trigger" | "content" | "calendar";
|
|
23
|
+
|
|
24
|
+
export interface DatePickerProps
|
|
25
|
+
extends Omit<
|
|
26
|
+
ComponentProps<"input">,
|
|
27
|
+
| "value"
|
|
28
|
+
| "defaultValue"
|
|
29
|
+
| "onChange"
|
|
30
|
+
| "type"
|
|
31
|
+
| "min"
|
|
32
|
+
| "max"
|
|
33
|
+
| "size"
|
|
34
|
+
| "inputMode"
|
|
35
|
+
| "maxLength"
|
|
36
|
+
> {
|
|
37
|
+
/** Selected date as "YYYY-MM-DD" (controlled); `""` means none. Never converted through a time zone. */
|
|
38
|
+
value?: string;
|
|
39
|
+
defaultValue?: string;
|
|
40
|
+
/** Called with a valid "YYYY-MM-DD" date, or `""` when the field is cleared. */
|
|
41
|
+
onValueChange?: (value: string) => void;
|
|
42
|
+
/** Earliest allowed date, "YYYY-MM-DD". */
|
|
43
|
+
min?: string;
|
|
44
|
+
/** Latest allowed date, "YYYY-MM-DD". */
|
|
45
|
+
max?: string;
|
|
46
|
+
/** Extra dates that cannot be picked or typed (holidays, taken days). */
|
|
47
|
+
isDateDisabled?: (date: string) => boolean;
|
|
48
|
+
/** BCP 47 locale for labels and the typed format. Defaults to the `locale` UI string (es-PE: dd/mm/aaaa). */
|
|
49
|
+
locale?: string;
|
|
50
|
+
/** First day of the week in the calendar, 0 (Sunday) to 6. Defaults from the locale (es-PE: Monday). */
|
|
51
|
+
weekStartsOn?: WeekStart;
|
|
52
|
+
/** Shows a button that clears the date. Default `true`. */
|
|
53
|
+
clearable?: boolean;
|
|
54
|
+
clearLabel?: string;
|
|
55
|
+
/** Submits the "YYYY-MM-DD" value with a surrounding `<form>` through a hidden input. */
|
|
56
|
+
name?: string;
|
|
57
|
+
invalid?: boolean;
|
|
58
|
+
/** Portal target for the calendar popover. Defaults to `document.body`. */
|
|
59
|
+
container?: HTMLElement | null;
|
|
60
|
+
/** Popover surface material; see `PopoverContent`. */
|
|
61
|
+
material?: Material;
|
|
62
|
+
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the input and is merged last. */
|
|
63
|
+
classNames?: ClassNames<DatePickerPart>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const ICON_BUTTON =
|
|
67
|
+
"flex w-8 items-center justify-center rounded-input text-ink-3 outline-none hover:text-ink focus-visible:focus-ring disabled:pointer-events-none disabled:opacity-50";
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Typed date field plus a calendar popover. The value is an ISO "YYYY-MM-DD" string end to end,
|
|
71
|
+
* so it never shifts with the time zone. The person types in the locale's order ("07/09/2026" in
|
|
72
|
+
* es-PE) or picks from the calendar; Alt+ArrowDown opens it from the keyboard.
|
|
73
|
+
*/
|
|
74
|
+
export function DatePicker({
|
|
75
|
+
value: valueProp,
|
|
76
|
+
defaultValue = "",
|
|
77
|
+
onValueChange,
|
|
78
|
+
min,
|
|
79
|
+
max,
|
|
80
|
+
isDateDisabled,
|
|
81
|
+
locale: localeProp,
|
|
82
|
+
weekStartsOn,
|
|
83
|
+
clearable = true,
|
|
84
|
+
clearLabel,
|
|
85
|
+
name,
|
|
86
|
+
invalid,
|
|
87
|
+
container,
|
|
88
|
+
material,
|
|
89
|
+
disabled,
|
|
90
|
+
placeholder,
|
|
91
|
+
className,
|
|
92
|
+
classNames,
|
|
93
|
+
ref,
|
|
94
|
+
onBlur,
|
|
95
|
+
onKeyDown,
|
|
96
|
+
"aria-invalid": ariaInvalid,
|
|
97
|
+
...props
|
|
98
|
+
}: DatePickerProps) {
|
|
99
|
+
const strings = useUiStrings();
|
|
100
|
+
const locale = localeProp || strings.locale;
|
|
101
|
+
const format = useMemo(() => dateFormatFor(locale), [locale]);
|
|
102
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
103
|
+
const composedRef = useComposedRefs<HTMLInputElement>(ref, inputRef);
|
|
104
|
+
const [current, setCurrent] = useControllableState<string>({
|
|
105
|
+
prop: valueProp,
|
|
106
|
+
defaultProp: defaultValue,
|
|
107
|
+
onChange: onValueChange,
|
|
108
|
+
});
|
|
109
|
+
const date = isIsoDate(current) ? current : "";
|
|
110
|
+
const [draft, setDraft] = useState<string | null>(null);
|
|
111
|
+
const [open, setOpen] = useState(false);
|
|
112
|
+
|
|
113
|
+
const allowed = (iso: string) =>
|
|
114
|
+
!(min && iso < min) && !(max && iso > max) && !isDateDisabled?.(iso);
|
|
115
|
+
const typed = draft === null ? null : parseDisplay(draft, format);
|
|
116
|
+
const rejected = typed !== null && !allowed(typed);
|
|
117
|
+
|
|
118
|
+
const onChange = (raw: string) => {
|
|
119
|
+
const masked = maskDisplay(raw, format);
|
|
120
|
+
const iso = parseDisplay(masked, format);
|
|
121
|
+
if (iso && allowed(iso)) {
|
|
122
|
+
setCurrent(iso);
|
|
123
|
+
setDraft(null);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
setDraft(masked);
|
|
127
|
+
if (masked === "") setCurrent("");
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
131
|
+
onKeyDown?.(event);
|
|
132
|
+
if (event.defaultPrevented) return;
|
|
133
|
+
if (event.key === "ArrowDown" && event.altKey && !disabled) {
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
setOpen(true);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const hasClear = clearable && !disabled && date !== "";
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<PopoverPrimitive.Root open={open} onOpenChange={setOpen}>
|
|
143
|
+
<PopoverPrimitive.Anchor asChild>
|
|
144
|
+
<div className={cn("relative flex w-full min-w-0", classNames?.root)}>
|
|
145
|
+
<input
|
|
146
|
+
{...props}
|
|
147
|
+
ref={composedRef}
|
|
148
|
+
type="text"
|
|
149
|
+
inputMode="numeric"
|
|
150
|
+
autoComplete="off"
|
|
151
|
+
maxLength={10}
|
|
152
|
+
disabled={disabled}
|
|
153
|
+
placeholder={
|
|
154
|
+
placeholder ??
|
|
155
|
+
displayPlaceholder(format, {
|
|
156
|
+
day: strings.dayPlaceholder,
|
|
157
|
+
month: strings.monthPlaceholder,
|
|
158
|
+
year: strings.yearPlaceholder,
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
aria-invalid={ariaInvalid ?? (invalid || rejected || undefined)}
|
|
162
|
+
value={draft ?? formatDisplay(date, format)}
|
|
163
|
+
onChange={(event) => onChange(event.target.value)}
|
|
164
|
+
onBlur={(event) => {
|
|
165
|
+
onBlur?.(event);
|
|
166
|
+
setDraft(null);
|
|
167
|
+
}}
|
|
168
|
+
onKeyDown={handleKeyDown}
|
|
169
|
+
className={cn(
|
|
170
|
+
"h-input min-h-(--touch-target) w-full min-w-0 rounded-input border-control bg-surface-control pl-3 text-control text-ink tabular-nums placeholder:text-ink-3 focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-danger",
|
|
171
|
+
hasClear ? "pr-16" : "pr-9",
|
|
172
|
+
classNames?.input,
|
|
173
|
+
className,
|
|
174
|
+
)}
|
|
175
|
+
/>
|
|
176
|
+
<div className="absolute inset-y-0 right-0 flex items-center">
|
|
177
|
+
{hasClear ? (
|
|
178
|
+
<button
|
|
179
|
+
type="button"
|
|
180
|
+
aria-label={clearLabel ?? strings.clear}
|
|
181
|
+
onClick={() => {
|
|
182
|
+
setCurrent("");
|
|
183
|
+
setDraft(null);
|
|
184
|
+
inputRef.current?.focus();
|
|
185
|
+
}}
|
|
186
|
+
className={cn(ICON_BUTTON, classNames?.clear)}
|
|
187
|
+
>
|
|
188
|
+
<X aria-hidden="true" className="size-3.5" />
|
|
189
|
+
</button>
|
|
190
|
+
) : null}
|
|
191
|
+
<PopoverPrimitive.Trigger
|
|
192
|
+
disabled={disabled}
|
|
193
|
+
aria-label={strings.openCalendar}
|
|
194
|
+
className={cn(ICON_BUTTON, classNames?.trigger)}
|
|
195
|
+
>
|
|
196
|
+
<CalendarIcon aria-hidden="true" className="size-4" />
|
|
197
|
+
</PopoverPrimitive.Trigger>
|
|
198
|
+
</div>
|
|
199
|
+
{name ? <input type="hidden" name={name} value={date} disabled={disabled} /> : null}
|
|
200
|
+
</div>
|
|
201
|
+
</PopoverPrimitive.Anchor>
|
|
202
|
+
<PopoverPrimitive.Portal container={container}>
|
|
203
|
+
<PopoverPrimitive.Content
|
|
204
|
+
aria-label={strings.calendar}
|
|
205
|
+
sideOffset={4}
|
|
206
|
+
collisionPadding={8}
|
|
207
|
+
align="start"
|
|
208
|
+
// The calendar takes focus itself; closing hands it back to the field.
|
|
209
|
+
onOpenAutoFocus={(event) => event.preventDefault()}
|
|
210
|
+
onCloseAutoFocus={(event) => {
|
|
211
|
+
event.preventDefault();
|
|
212
|
+
inputRef.current?.focus({ preventScroll: true });
|
|
213
|
+
}}
|
|
214
|
+
className={cn(
|
|
215
|
+
"z-85 max-w-(--ui-popper-available-width) overflow-y-auto rounded-popover surface-overlay p-3 text-ink shadow-overlay",
|
|
216
|
+
materialClass(material, "surface-solid"),
|
|
217
|
+
classNames?.content,
|
|
218
|
+
)}
|
|
219
|
+
>
|
|
220
|
+
<DateCalendar
|
|
221
|
+
autoFocus
|
|
222
|
+
value={date || undefined}
|
|
223
|
+
min={min}
|
|
224
|
+
max={max}
|
|
225
|
+
isDateDisabled={isDateDisabled}
|
|
226
|
+
locale={locale}
|
|
227
|
+
weekStartsOn={weekStartsOn}
|
|
228
|
+
className={classNames?.calendar}
|
|
229
|
+
onSelect={(next) => {
|
|
230
|
+
setCurrent(next);
|
|
231
|
+
setDraft(null);
|
|
232
|
+
setOpen(false);
|
|
233
|
+
}}
|
|
234
|
+
/>
|
|
235
|
+
</PopoverPrimitive.Content>
|
|
236
|
+
</PopoverPrimitive.Portal>
|
|
237
|
+
</PopoverPrimitive.Root>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { type ComponentProps, useEffect, useId, useMemo, useState } from "react";
|
|
4
|
+
import { isIsoDate, type WeekStart } from "../../calendar/internal/date-utils.js";
|
|
5
|
+
import { useUiStrings } from "../../i18n/index.js";
|
|
6
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
7
|
+
import { cn } from "../../utils/cn.js";
|
|
8
|
+
import type { Material } from "../../utils/material.js";
|
|
9
|
+
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
10
|
+
import { TimeInput } from "../time-input/time-input.js";
|
|
11
|
+
import { DatePicker } from "./date-picker.js";
|
|
12
|
+
import { dateTimeInRange, joinDateTime, splitDateTime } from "./model.js";
|
|
13
|
+
|
|
14
|
+
export type DateTimePickerPart = "root" | "date" | "time";
|
|
15
|
+
|
|
16
|
+
export interface DateTimePickerProps
|
|
17
|
+
extends Omit<
|
|
18
|
+
ComponentProps<"div">,
|
|
19
|
+
"defaultValue" | "onChange" | "children" | "role" | "id" | "aria-label" | "aria-labelledby"
|
|
20
|
+
> {
|
|
21
|
+
/**
|
|
22
|
+
* "YYYY-MM-DDTHH:mm" (controlled), a wall-clock date and time with no zone: the component never
|
|
23
|
+
* converts it, so "2026-09-07T09:30" stays that string whatever the browser's time zone is.
|
|
24
|
+
* `""` while either half is missing or the pair is outside `min`/`max`.
|
|
25
|
+
*/
|
|
26
|
+
value?: string;
|
|
27
|
+
defaultValue?: string;
|
|
28
|
+
onValueChange?: (value: string) => void;
|
|
29
|
+
/** Earliest allowed value: a date ("2026-09-07", whole day) or a date-time. */
|
|
30
|
+
min?: string;
|
|
31
|
+
/** Latest allowed value: a date (whole day) or a date-time. */
|
|
32
|
+
max?: string;
|
|
33
|
+
isDateDisabled?: (date: string) => boolean;
|
|
34
|
+
locale?: string;
|
|
35
|
+
weekStartsOn?: WeekStart;
|
|
36
|
+
/** Minutes moved by ArrowUp / ArrowDown on the minutes of the time half. Default 5. */
|
|
37
|
+
step?: number;
|
|
38
|
+
/** Submits the combined value with a surrounding `<form>` through a hidden input. */
|
|
39
|
+
name?: string;
|
|
40
|
+
id?: string;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
required?: boolean;
|
|
43
|
+
invalid?: boolean;
|
|
44
|
+
"aria-label"?: string;
|
|
45
|
+
"aria-labelledby"?: string;
|
|
46
|
+
"aria-describedby"?: string;
|
|
47
|
+
"aria-invalid"?: boolean | "true" | "false";
|
|
48
|
+
container?: HTMLElement | null;
|
|
49
|
+
material?: Material;
|
|
50
|
+
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
51
|
+
classNames?: ClassNames<DateTimePickerPart>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const EMPTY = { date: "", time: "" };
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Date field with calendar plus a 24h time field, as one value. Replaces
|
|
58
|
+
* `<input type="datetime-local">`; the value is "YYYY-MM-DDTHH:mm" without a time zone.
|
|
59
|
+
*/
|
|
60
|
+
export function DateTimePicker({
|
|
61
|
+
value: valueProp,
|
|
62
|
+
defaultValue = "",
|
|
63
|
+
onValueChange,
|
|
64
|
+
min,
|
|
65
|
+
max,
|
|
66
|
+
isDateDisabled,
|
|
67
|
+
locale,
|
|
68
|
+
weekStartsOn,
|
|
69
|
+
step,
|
|
70
|
+
name,
|
|
71
|
+
id,
|
|
72
|
+
disabled,
|
|
73
|
+
required,
|
|
74
|
+
invalid,
|
|
75
|
+
container,
|
|
76
|
+
material,
|
|
77
|
+
className,
|
|
78
|
+
classNames,
|
|
79
|
+
"aria-label": ariaLabel,
|
|
80
|
+
"aria-labelledby": ariaLabelledBy,
|
|
81
|
+
"aria-describedby": ariaDescribedBy,
|
|
82
|
+
"aria-invalid": ariaInvalid,
|
|
83
|
+
...props
|
|
84
|
+
}: DateTimePickerProps) {
|
|
85
|
+
const strings = useUiStrings();
|
|
86
|
+
const autoId = useId();
|
|
87
|
+
const dateId = id ?? autoId;
|
|
88
|
+
const [current, setCurrent] = useControllableState<string>({
|
|
89
|
+
prop: valueProp,
|
|
90
|
+
defaultProp: defaultValue,
|
|
91
|
+
onChange: onValueChange,
|
|
92
|
+
});
|
|
93
|
+
const [parts, setParts] = useState(() => splitDateTime(current) ?? EMPTY);
|
|
94
|
+
const [synced, setSynced] = useState(current);
|
|
95
|
+
const [timeLabel, setTimeLabel] = useState(strings.time);
|
|
96
|
+
// After a comma the word is lowercase in every locale ("Fecha, hora"); alone it keeps its capital.
|
|
97
|
+
const suffix = strings.time.toLowerCase();
|
|
98
|
+
|
|
99
|
+
// Adopt a value set from outside (form reset, prefill) without losing a half-typed pair.
|
|
100
|
+
if (synced !== current) {
|
|
101
|
+
setSynced(current);
|
|
102
|
+
if (joinDateTime(parts) !== current) setParts(splitDateTime(current) ?? EMPTY);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// The time half is named "<field label>, <time>" so it differs from the date half.
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const label =
|
|
108
|
+
ariaLabel ??
|
|
109
|
+
ariaLabelledBy
|
|
110
|
+
?.split(" ")
|
|
111
|
+
.map((labelId) => document.getElementById(labelId)?.textContent ?? "")
|
|
112
|
+
.join(" ")
|
|
113
|
+
.trim() ??
|
|
114
|
+
(
|
|
115
|
+
document.getElementById(dateId) as HTMLInputElement | null
|
|
116
|
+
)?.labels?.[0]?.textContent?.trim();
|
|
117
|
+
setTimeLabel(label ? `${label}, ${suffix}` : strings.time);
|
|
118
|
+
}, [ariaLabel, ariaLabelledBy, dateId, strings.time, suffix]);
|
|
119
|
+
|
|
120
|
+
const joined = joinDateTime(parts);
|
|
121
|
+
const outOfRange = joined !== "" && !dateTimeInRange(joined, min, max);
|
|
122
|
+
const dateMin = min && isIsoDate(min.slice(0, 10)) ? min.slice(0, 10) : undefined;
|
|
123
|
+
const dateMax = max && isIsoDate(max.slice(0, 10)) ? max.slice(0, 10) : undefined;
|
|
124
|
+
|
|
125
|
+
const update = useMemo(
|
|
126
|
+
() => (next: { date: string; time: string }) => {
|
|
127
|
+
setParts(next);
|
|
128
|
+
const value = joinDateTime(next);
|
|
129
|
+
const committed = value && dateTimeInRange(value, min, max) ? value : "";
|
|
130
|
+
setCurrent(committed);
|
|
131
|
+
},
|
|
132
|
+
[min, max, setCurrent],
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const shared = {
|
|
136
|
+
disabled,
|
|
137
|
+
"aria-describedby": ariaDescribedBy,
|
|
138
|
+
"aria-invalid": ariaInvalid ?? (invalid || undefined),
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<div
|
|
143
|
+
{...props}
|
|
144
|
+
className={cn("flex w-full min-w-0 flex-wrap gap-2", classNames?.root, className)}
|
|
145
|
+
>
|
|
146
|
+
<DatePicker
|
|
147
|
+
{...shared}
|
|
148
|
+
id={dateId}
|
|
149
|
+
value={parts.date}
|
|
150
|
+
onValueChange={(date) => update({ ...parts, date })}
|
|
151
|
+
min={dateMin}
|
|
152
|
+
max={dateMax}
|
|
153
|
+
isDateDisabled={isDateDisabled}
|
|
154
|
+
locale={locale}
|
|
155
|
+
weekStartsOn={weekStartsOn}
|
|
156
|
+
required={required}
|
|
157
|
+
aria-label={ariaLabel}
|
|
158
|
+
aria-labelledby={ariaLabelledBy}
|
|
159
|
+
container={container}
|
|
160
|
+
material={material}
|
|
161
|
+
className={undefined}
|
|
162
|
+
classNames={{ root: cn("flex-[3_1_10rem]", classNames?.date) }}
|
|
163
|
+
/>
|
|
164
|
+
<div className={cn("flex min-w-0 flex-[2_1_6rem]", classNames?.time)}>
|
|
165
|
+
<TimeInput
|
|
166
|
+
{...shared}
|
|
167
|
+
aria-invalid={outOfRange ? true : shared["aria-invalid"]}
|
|
168
|
+
aria-label={timeLabel}
|
|
169
|
+
value={parts.time}
|
|
170
|
+
onValueChange={(time) => update({ ...parts, time })}
|
|
171
|
+
required={required}
|
|
172
|
+
step={step}
|
|
173
|
+
/>
|
|
174
|
+
</div>
|
|
175
|
+
{name ? <input type="hidden" name={name} value={current} disabled={disabled} /> : null}
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { isIsoDate, toIsoDate } from "../../calendar/internal/date-utils.js";
|
|
2
|
+
|
|
3
|
+
/** Typed-date and date-time rules for `DatePicker` / `DateTimePicker`. Strings in, strings out: no `Date` in local time. */
|
|
4
|
+
|
|
5
|
+
export type DatePart = "day" | "month" | "year";
|
|
6
|
+
|
|
7
|
+
export interface DateFormat {
|
|
8
|
+
order: DatePart[];
|
|
9
|
+
separator: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const FALLBACK: DateFormat = { order: ["day", "month", "year"], separator: "/" };
|
|
13
|
+
|
|
14
|
+
/** Field order and separator a locale writes numeric dates with: es-PE "dd/mm/yyyy", en-US "mm/dd/yyyy", sv-SE "yyyy-mm-dd". */
|
|
15
|
+
export function dateFormatFor(locale: string): DateFormat {
|
|
16
|
+
try {
|
|
17
|
+
const parts = new Intl.DateTimeFormat(locale, {
|
|
18
|
+
year: "numeric",
|
|
19
|
+
month: "2-digit",
|
|
20
|
+
day: "2-digit",
|
|
21
|
+
timeZone: "UTC",
|
|
22
|
+
}).formatToParts(new Date(Date.UTC(2006, 10, 22)));
|
|
23
|
+
const order = parts
|
|
24
|
+
.map((part) => part.type)
|
|
25
|
+
.filter((type): type is DatePart => type === "day" || type === "month" || type === "year");
|
|
26
|
+
const separator = parts.find((part) => part.type === "literal")?.value.trim();
|
|
27
|
+
if (order.length !== 3) return FALLBACK;
|
|
28
|
+
return { order, separator: separator || "/" };
|
|
29
|
+
} catch {
|
|
30
|
+
return FALLBACK;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SEGMENT: Record<DatePart, number> = { day: 2, month: 2, year: 4 };
|
|
35
|
+
|
|
36
|
+
/** "2026-09-07" as the locale writes it, or "" for anything that is not an ISO date. */
|
|
37
|
+
export function formatDisplay(iso: string, format: DateFormat): string {
|
|
38
|
+
if (!isIsoDate(iso)) return "";
|
|
39
|
+
const value: Record<DatePart, string> = {
|
|
40
|
+
year: iso.slice(0, 4),
|
|
41
|
+
month: iso.slice(5, 7),
|
|
42
|
+
day: iso.slice(8, 10),
|
|
43
|
+
};
|
|
44
|
+
return format.order.map((part) => value[part]).join(format.separator);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Keeps digits and inserts the separator once a segment is full and more digits follow. */
|
|
48
|
+
export function maskDisplay(raw: string, format: DateFormat): string {
|
|
49
|
+
let rest = raw.replace(/\D/g, "").slice(0, 8);
|
|
50
|
+
const segments: string[] = [];
|
|
51
|
+
for (const part of format.order) {
|
|
52
|
+
if (!rest) break;
|
|
53
|
+
segments.push(rest.slice(0, SEGMENT[part]));
|
|
54
|
+
rest = rest.slice(SEGMENT[part]);
|
|
55
|
+
}
|
|
56
|
+
return segments.join(format.separator);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Typed text to "YYYY-MM-DD"; null while it is incomplete or not a real date. */
|
|
60
|
+
export function parseDisplay(text: string, format: DateFormat): string | null {
|
|
61
|
+
const pieces = text.trim().split(format.separator);
|
|
62
|
+
if (pieces.length !== 3) return null;
|
|
63
|
+
const value: Partial<Record<DatePart, string>> = {};
|
|
64
|
+
for (const [index, part] of format.order.entries()) {
|
|
65
|
+
const piece = pieces[index] ?? "";
|
|
66
|
+
const valid = part === "year" ? /^\d{4}$/.test(piece) : /^\d{1,2}$/.test(piece);
|
|
67
|
+
if (!valid) return null;
|
|
68
|
+
value[part] = piece;
|
|
69
|
+
}
|
|
70
|
+
const iso = toIsoDate(Number(value.year), Number(value.month), Number(value.day));
|
|
71
|
+
return isIsoDate(iso) ? iso : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** "dd/mm/aaaa" built from the locale's order and the localized segment words. */
|
|
75
|
+
export function displayPlaceholder(
|
|
76
|
+
format: DateFormat,
|
|
77
|
+
words: { day: string; month: string; year: string },
|
|
78
|
+
): string {
|
|
79
|
+
return format.order.map((part) => words[part]).join(format.separator);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function isValidTime(time: string): boolean {
|
|
83
|
+
return /^([01]\d|2[0-3]):[0-5]\d$/.test(time);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const DATE_TIME = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})$/;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Splits "YYYY-MM-DDTHH:mm". The value is a wall-clock time with no zone: anything carrying a
|
|
90
|
+
* "Z", an offset or seconds is rejected instead of being silently reinterpreted.
|
|
91
|
+
*/
|
|
92
|
+
export function splitDateTime(value: string): { date: string; time: string } | null {
|
|
93
|
+
const match = DATE_TIME.exec(value);
|
|
94
|
+
if (!match) return null;
|
|
95
|
+
const [, date = "", time = ""] = match;
|
|
96
|
+
return isIsoDate(date) && isValidTime(time) ? { date, time } : null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function joinDateTime(parts: { date: string; time: string }): string {
|
|
100
|
+
return parts.date && parts.time ? `${parts.date}T${parts.time}` : "";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** `min`/`max` may be a date ("2026-09-07", whole day) or a date-time. Lexicographic compare is chronological. */
|
|
104
|
+
export function dateTimeInRange(value: string, min?: string, max?: string): boolean {
|
|
105
|
+
if (min && value < (min.length === 10 ? `${min}T00:00` : min)) return false;
|
|
106
|
+
if (max && value > (max.length === 10 ? `${max}T23:59` : max)) return false;
|
|
107
|
+
return true;
|
|
108
|
+
}
|