@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
|
@@ -1,16 +1,112 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
2
3
|
import { cn } from "../../utils/cn.js";
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export type InputSize = "xs" | "md" | "lg";
|
|
6
|
+
export type InputVariant = "default" | "bare";
|
|
7
|
+
export type InputPart = "root" | "start" | "end" | "input";
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
const height: Readonly<Record<InputSize, string>> = {
|
|
10
|
+
xs: "h-control-sm",
|
|
11
|
+
md: "h-input",
|
|
12
|
+
lg: "h-control-lg text-fs-140",
|
|
13
|
+
};
|
|
14
|
+
const paddingX: Readonly<Record<InputSize, string>> = {
|
|
15
|
+
xs: "px-2.5",
|
|
16
|
+
md: "px-3",
|
|
17
|
+
lg: "px-4",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const inputSizeClasses: Readonly<Record<InputSize, string>> = {
|
|
21
|
+
xs: `${height.xs} ${paddingX.xs}`,
|
|
22
|
+
md: `${height.md} ${paddingX.md}`,
|
|
23
|
+
lg: `${height.lg} ${paddingX.lg}`,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const CHROME = "rounded-input border-control bg-surface-control";
|
|
27
|
+
const TEXT = "min-w-0 text-control text-ink placeholder:text-ink-3";
|
|
28
|
+
const RING =
|
|
29
|
+
"focus:border-transparent focus:outline-2 focus:outline-accent-ink focus:-outline-offset-1";
|
|
30
|
+
const INVALID = "aria-[invalid=true]:border-danger";
|
|
31
|
+
|
|
32
|
+
export interface InputProps extends Omit<ComponentPropsWithRef<"input">, "size"> {
|
|
33
|
+
/** `xs` is the 30px compact field (the height of the small `Button`), `lg` the thumb-friendly one. Default `md`. */
|
|
34
|
+
size?: InputSize;
|
|
35
|
+
/** `bare` drops the border, background and side padding, for a field that sits inside chrome of its own. */
|
|
36
|
+
variant?: InputVariant;
|
|
37
|
+
/** Content before the text (an icon, a currency symbol, a button). Adds a wrapper that draws the field. */
|
|
38
|
+
start?: ReactNode;
|
|
39
|
+
/** Content after the text (an icon, a unit, a clear or reveal button). Adds a wrapper that draws the field. */
|
|
40
|
+
end?: ReactNode;
|
|
41
|
+
/** Per-part classes merged with `cn`; consumer classes win. Parts other than `input` only exist with `start` or `end`. */
|
|
42
|
+
classNames?: ClassNames<InputPart>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Text field. With `start` or `end` the field is drawn by a wrapper, so `className` then targets that
|
|
47
|
+
* wrapper (its width, margins) and `classNames.input` the `<input>`; without them `className` stays on
|
|
48
|
+
* the `<input>` as before.
|
|
49
|
+
*/
|
|
50
|
+
export function Input({
|
|
51
|
+
size = "md",
|
|
52
|
+
variant = "default",
|
|
53
|
+
start,
|
|
54
|
+
end,
|
|
55
|
+
className,
|
|
56
|
+
classNames,
|
|
57
|
+
...props
|
|
58
|
+
}: InputProps) {
|
|
59
|
+
const bare = variant === "bare";
|
|
60
|
+
|
|
61
|
+
if (start == null && end == null) {
|
|
62
|
+
return (
|
|
63
|
+
<input
|
|
64
|
+
className={cn(
|
|
65
|
+
"w-full",
|
|
66
|
+
TEXT,
|
|
67
|
+
bare
|
|
68
|
+
? [
|
|
69
|
+
height[size],
|
|
70
|
+
"bg-transparent outline-none focus-visible:outline-2 focus-visible:outline-accent-ink",
|
|
71
|
+
]
|
|
72
|
+
: [CHROME, RING, INVALID, inputSizeClasses[size]],
|
|
73
|
+
classNames?.input,
|
|
74
|
+
className,
|
|
75
|
+
)}
|
|
76
|
+
{...props}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const adornment = "flex shrink-0 items-center text-ink-3 [&>svg]:size-4";
|
|
7
82
|
return (
|
|
8
|
-
<
|
|
83
|
+
<span
|
|
9
84
|
className={cn(
|
|
10
|
-
"
|
|
85
|
+
"flex w-full min-w-0 items-center gap-2",
|
|
86
|
+
height[size],
|
|
87
|
+
bare
|
|
88
|
+
? "has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-accent-ink"
|
|
89
|
+
: [
|
|
90
|
+
CHROME,
|
|
91
|
+
paddingX[size],
|
|
92
|
+
"focus-within:border-transparent focus-within:outline-2 focus-within:outline-accent-ink focus-within:-outline-offset-1 has-[input[aria-invalid=true]]:border-danger",
|
|
93
|
+
],
|
|
94
|
+
"has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50",
|
|
95
|
+
classNames?.root,
|
|
11
96
|
className,
|
|
12
97
|
)}
|
|
13
|
-
|
|
14
|
-
|
|
98
|
+
>
|
|
99
|
+
{start != null ? <span className={cn(adornment, classNames?.start)}>{start}</span> : null}
|
|
100
|
+
<input
|
|
101
|
+
className={cn(
|
|
102
|
+
"h-full flex-1 bg-transparent outline-none",
|
|
103
|
+
TEXT,
|
|
104
|
+
size === "lg" && "text-fs-140",
|
|
105
|
+
classNames?.input,
|
|
106
|
+
)}
|
|
107
|
+
{...props}
|
|
108
|
+
/>
|
|
109
|
+
{end != null ? <span className={cn(adornment, classNames?.end)}>{end}</span> : null}
|
|
110
|
+
</span>
|
|
15
111
|
);
|
|
16
112
|
}
|
|
@@ -5,7 +5,7 @@ import { Input, type InputProps } from "../input/index.js";
|
|
|
5
5
|
|
|
6
6
|
export type InputIconPart = "root" | "icon" | "input";
|
|
7
7
|
|
|
8
|
-
export interface InputIconProps extends InputProps {
|
|
8
|
+
export interface InputIconProps extends Omit<InputProps, "classNames" | "start" | "end"> {
|
|
9
9
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the input and is merged last. */
|
|
10
10
|
classNames?: ClassNames<InputIconPart>;
|
|
11
11
|
/** Leading icon element (e.g. an `@jcsoftdev/ui/icons` icon). */
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { type ReactNode, useId, useMemo } from "react";
|
|
2
|
+
import { Check } from "../../icons/index.js";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
import { isGroup, type ListboxItem, type ListboxOption } from "./listbox.js";
|
|
5
|
+
|
|
6
|
+
export const LISTBOX_SURFACE =
|
|
7
|
+
"z-85 min-w-(--ui-popper-anchor-width) max-h-[min(20rem,var(--ui-popper-available-height))] max-w-(--ui-popper-available-width) overflow-y-auto overscroll-contain rounded-popover surface-overlay p-1.5 text-ink shadow-overlay";
|
|
8
|
+
|
|
9
|
+
const OPTION =
|
|
10
|
+
"flex min-h-[max(2rem,var(--touch-target))] w-full cursor-pointer items-center gap-2 rounded-event px-2.5 py-1.5 text-body text-ink outline-none data-[highlighted]:bg-surface-2 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50";
|
|
11
|
+
|
|
12
|
+
export function optionDomId(base: string, index: number): string {
|
|
13
|
+
return `${base}-opt-${index}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ListboxItemsProps<O extends ListboxOption> {
|
|
17
|
+
items: readonly ListboxItem<O>[];
|
|
18
|
+
/** Options in display order; an option's position here is its id and `activeIndex` slot. */
|
|
19
|
+
flat: readonly O[];
|
|
20
|
+
idBase: string;
|
|
21
|
+
isSelected: (option: O) => boolean;
|
|
22
|
+
activeIndex: number;
|
|
23
|
+
onActivate: (index: number) => void;
|
|
24
|
+
onPick: (option: O) => void;
|
|
25
|
+
optionClassName?: string | undefined;
|
|
26
|
+
groupClassName?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Renders options (and optional group headings) with the WAI-ARIA listbox roles. */
|
|
30
|
+
export function ListboxItems<O extends ListboxOption>({
|
|
31
|
+
items,
|
|
32
|
+
flat,
|
|
33
|
+
idBase,
|
|
34
|
+
isSelected,
|
|
35
|
+
activeIndex,
|
|
36
|
+
onActivate,
|
|
37
|
+
onPick,
|
|
38
|
+
optionClassName,
|
|
39
|
+
groupClassName,
|
|
40
|
+
}: ListboxItemsProps<O>): ReactNode {
|
|
41
|
+
const headingBase = useId();
|
|
42
|
+
const indexes = useMemo(() => new Map(flat.map((option, index) => [option, index])), [flat]);
|
|
43
|
+
|
|
44
|
+
const renderOption = (option: O) => {
|
|
45
|
+
const index = indexes.get(option) ?? -1;
|
|
46
|
+
const selected = isSelected(option);
|
|
47
|
+
return (
|
|
48
|
+
// biome-ignore lint/a11y/useFocusableInteractive: options are never focused; the owner keeps focus and points at one with aria-activedescendant.
|
|
49
|
+
// biome-ignore lint/a11y/useKeyWithClickEvents: the owner (trigger or input) handles every key.
|
|
50
|
+
<div
|
|
51
|
+
key={`${index}-${option.value}`}
|
|
52
|
+
id={optionDomId(idBase, index)}
|
|
53
|
+
role="option"
|
|
54
|
+
aria-selected={selected}
|
|
55
|
+
aria-disabled={option.disabled || undefined}
|
|
56
|
+
data-selected={selected ? "" : undefined}
|
|
57
|
+
data-disabled={option.disabled ? "" : undefined}
|
|
58
|
+
data-highlighted={index === activeIndex ? "" : undefined}
|
|
59
|
+
// Focus stays on the trigger or the input; the press must not move it.
|
|
60
|
+
onPointerDown={(event) => event.preventDefault()}
|
|
61
|
+
onMouseDown={(event) => event.preventDefault()}
|
|
62
|
+
onPointerMove={() => {
|
|
63
|
+
if (!option.disabled && index !== activeIndex) onActivate(index);
|
|
64
|
+
}}
|
|
65
|
+
onClick={() => {
|
|
66
|
+
if (!option.disabled) onPick(option);
|
|
67
|
+
}}
|
|
68
|
+
className={cn(OPTION, optionClassName)}
|
|
69
|
+
>
|
|
70
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
71
|
+
<span className={cn("truncate", selected && "font-semibold")}>{option.label}</span>
|
|
72
|
+
{option.description ? (
|
|
73
|
+
<span className="truncate text-ink-3 text-meta">{option.description}</span>
|
|
74
|
+
) : null}
|
|
75
|
+
</span>
|
|
76
|
+
{selected ? (
|
|
77
|
+
<Check aria-hidden="true" className="size-3.5 shrink-0 text-accent-ink" />
|
|
78
|
+
) : null}
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return items.map((item, position) => {
|
|
84
|
+
if (!isGroup(item)) return renderOption(item);
|
|
85
|
+
const headingId = `${headingBase}-g${position}`;
|
|
86
|
+
return (
|
|
87
|
+
// biome-ignore lint/a11y/useSemanticElements: a fieldset inside a listbox breaks the listbox > group > option structure.
|
|
88
|
+
<div key={`group-${item.label}`} role="group" aria-labelledby={headingId}>
|
|
89
|
+
<div
|
|
90
|
+
id={headingId}
|
|
91
|
+
role="presentation"
|
|
92
|
+
className={cn(
|
|
93
|
+
"px-2.5 pt-2 pb-1 font-semibold text-ink-3 text-meta uppercase tracking-wide",
|
|
94
|
+
groupClassName,
|
|
95
|
+
)}
|
|
96
|
+
>
|
|
97
|
+
{item.label}
|
|
98
|
+
</div>
|
|
99
|
+
{item.options.map(renderOption)}
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/** Pure rules shared by `SelectMenu` and `Combobox`: option shapes, navigation, typeahead and filtering. */
|
|
2
|
+
|
|
3
|
+
export interface ListboxOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** Extra words matched by a `Combobox` search, never shown. */
|
|
9
|
+
keywords?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ListboxGroup<O extends ListboxOption = ListboxOption> {
|
|
13
|
+
label: string;
|
|
14
|
+
options: O[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type ListboxItem<O extends ListboxOption = ListboxOption> = O | ListboxGroup<O>;
|
|
18
|
+
|
|
19
|
+
export function isGroup<O extends ListboxOption>(item: ListboxItem<O>): item is ListboxGroup<O> {
|
|
20
|
+
return "options" in item;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Options in display order with the group headings removed. */
|
|
24
|
+
export function flattenItems<O extends ListboxOption>(items: readonly ListboxItem<O>[]): O[] {
|
|
25
|
+
return items.flatMap((item) => (isGroup(item) ? item.options : [item]));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ListboxMove = "next" | "prev" | "first" | "last";
|
|
29
|
+
|
|
30
|
+
/** Index of the enabled option a key moves to, or `current` when nothing is reachable. The list does not wrap. */
|
|
31
|
+
export function moveActive(
|
|
32
|
+
options: readonly ListboxOption[],
|
|
33
|
+
current: number,
|
|
34
|
+
move: ListboxMove,
|
|
35
|
+
): number {
|
|
36
|
+
const enabled = (index: number) => options[index] !== undefined && !options[index]?.disabled;
|
|
37
|
+
if (move === "first") {
|
|
38
|
+
for (let i = 0; i < options.length; i++) if (enabled(i)) return i;
|
|
39
|
+
return current;
|
|
40
|
+
}
|
|
41
|
+
if (move === "last") {
|
|
42
|
+
for (let i = options.length - 1; i >= 0; i--) if (enabled(i)) return i;
|
|
43
|
+
return current;
|
|
44
|
+
}
|
|
45
|
+
const step = move === "next" ? 1 : -1;
|
|
46
|
+
for (let i = current + step; i >= 0 && i < options.length; i += step) if (enabled(i)) return i;
|
|
47
|
+
return current;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const fold = (text: string) => text.normalize("NFD").replace(/\p{M}/gu, "").toLocaleLowerCase();
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Option a typed prefix lands on. A single repeated character cycles through the options that
|
|
54
|
+
* start with it; a longer prefix keeps matching from the active option.
|
|
55
|
+
*/
|
|
56
|
+
export function typeaheadIndex(
|
|
57
|
+
options: readonly ListboxOption[],
|
|
58
|
+
query: string,
|
|
59
|
+
active: number,
|
|
60
|
+
): number {
|
|
61
|
+
if (!query) return -1;
|
|
62
|
+
const needle = fold(query);
|
|
63
|
+
const repeated = needle.length > 1 && [...needle].every((char) => char === needle[0]);
|
|
64
|
+
const search = repeated ? needle.slice(0, 1) : needle;
|
|
65
|
+
const start = needle.length === 1 || repeated ? active + 1 : active;
|
|
66
|
+
for (let offset = 0; offset < options.length; offset++) {
|
|
67
|
+
const index = (start + offset + options.length) % options.length;
|
|
68
|
+
const option = options[index];
|
|
69
|
+
if (option && !option.disabled && fold(option.label).startsWith(search)) return index;
|
|
70
|
+
}
|
|
71
|
+
return -1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Typeahead buffer: characters typed within `timeout` ms of each other form one prefix. */
|
|
75
|
+
export function nextTypeahead(
|
|
76
|
+
state: { buffer: string; at: number },
|
|
77
|
+
key: string,
|
|
78
|
+
now: number,
|
|
79
|
+
timeout = 600,
|
|
80
|
+
): { buffer: string; at: number } {
|
|
81
|
+
const buffer = now - state.at > timeout ? key : state.buffer + key;
|
|
82
|
+
return { buffer, at: now };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** True for a key that types a character (not a shortcut or a named key). */
|
|
86
|
+
export function isTypeaheadKey(event: {
|
|
87
|
+
key: string;
|
|
88
|
+
ctrlKey: boolean;
|
|
89
|
+
metaKey: boolean;
|
|
90
|
+
altKey: boolean;
|
|
91
|
+
}): boolean {
|
|
92
|
+
return event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Accent- and case-insensitive match against label, description and keywords. */
|
|
96
|
+
export function matchesQuery(option: ListboxOption, query: string): boolean {
|
|
97
|
+
const needle = fold(query.trim());
|
|
98
|
+
if (!needle) return true;
|
|
99
|
+
return fold(`${option.label} ${option.description ?? ""} ${option.keywords ?? ""}`).includes(
|
|
100
|
+
needle,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Keeps matching options, dropping groups left empty and capping the number of options shown. */
|
|
105
|
+
export function filterItems<O extends ListboxOption>(
|
|
106
|
+
items: readonly ListboxItem<O>[],
|
|
107
|
+
predicate: (option: O) => boolean,
|
|
108
|
+
limit = Number.POSITIVE_INFINITY,
|
|
109
|
+
): ListboxItem<O>[] {
|
|
110
|
+
let left = limit;
|
|
111
|
+
const result: ListboxItem<O>[] = [];
|
|
112
|
+
for (const item of items) {
|
|
113
|
+
if (left <= 0) break;
|
|
114
|
+
if (isGroup(item)) {
|
|
115
|
+
const options = item.options.filter(predicate).slice(0, left);
|
|
116
|
+
left -= options.length;
|
|
117
|
+
if (options.length > 0) result.push({ ...item, options });
|
|
118
|
+
} else if (predicate(item)) {
|
|
119
|
+
result.push(item);
|
|
120
|
+
left -= 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { snapToStep } from "../slider/model.js";
|
|
2
|
+
|
|
3
|
+
/** A typed number: dot or comma decimal, `NaN` for empty or unreadable text ("", "-"). */
|
|
4
|
+
export function parseNumber(text: string): number {
|
|
5
|
+
const trimmed = text.trim().replace(",", ".");
|
|
6
|
+
return trimmed === "" ? Number.NaN : Number(trimmed);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The text after stepping `text` by `direction` steps, kept within `min`/`max` and on the step grid.
|
|
11
|
+
* An empty or unreadable text goes to `min` when there is one, else to one step in `direction`.
|
|
12
|
+
*/
|
|
13
|
+
export function stepText(
|
|
14
|
+
text: string,
|
|
15
|
+
direction: 1 | -1,
|
|
16
|
+
limits: { min: number; max: number; step: number },
|
|
17
|
+
): string {
|
|
18
|
+
const { min, max, step } = limits;
|
|
19
|
+
const parsed = parseNumber(text);
|
|
20
|
+
if (Number.isNaN(parsed)) {
|
|
21
|
+
return String(snapToStep(Number.isFinite(min) ? min : direction * step, min, max, step));
|
|
22
|
+
}
|
|
23
|
+
return String(snapToStep(parsed + direction * step, min, max, step));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Whether another step in `direction` would stay within the limits, for the buttons. */
|
|
27
|
+
export function canStep(
|
|
28
|
+
text: string,
|
|
29
|
+
direction: 1 | -1,
|
|
30
|
+
limits: { min: number; max: number },
|
|
31
|
+
): boolean {
|
|
32
|
+
const parsed = parseNumber(text);
|
|
33
|
+
if (Number.isNaN(parsed)) return true;
|
|
34
|
+
return direction === 1 ? parsed < limits.max : parsed > limits.min;
|
|
35
|
+
}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type ChangeEvent,
|
|
5
|
+
type ChangeEventHandler,
|
|
6
|
+
type KeyboardEvent,
|
|
7
|
+
useId,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react";
|
|
4
11
|
import { Minus, Plus } from "../../icons/index.js";
|
|
5
12
|
import type { ClassNames } from "../../utils/class-names.js";
|
|
6
13
|
import { cn } from "../../utils/cn.js";
|
|
7
14
|
import { snapToStep } from "../slider/model.js";
|
|
15
|
+
import { canStep, parseNumber, stepText } from "./model.js";
|
|
8
16
|
|
|
9
17
|
export type NumberStepperPart = "root" | "decrement" | "increment" | "input" | "unit";
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
value?: number;
|
|
13
|
-
defaultValue?: number;
|
|
14
|
-
onValueChange?: (value: number) => void;
|
|
19
|
+
interface NumberStepperBaseProps {
|
|
15
20
|
min?: number;
|
|
16
21
|
max?: number;
|
|
17
22
|
step?: number;
|
|
@@ -19,37 +24,85 @@ export interface NumberStepperProps {
|
|
|
19
24
|
/** Text after the number, e.g. "min" or "unid."; read by screen readers through aria-valuetext. */
|
|
20
25
|
unit?: string;
|
|
21
26
|
name?: string;
|
|
27
|
+
/** Id of the text input; `Field` sets it so the label points at the control. */
|
|
28
|
+
id?: string;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
required?: boolean;
|
|
31
|
+
invalid?: boolean;
|
|
22
32
|
"aria-label"?: string;
|
|
23
33
|
"aria-labelledby"?: string;
|
|
34
|
+
"aria-describedby"?: string;
|
|
35
|
+
"aria-invalid"?: boolean;
|
|
24
36
|
className?: string;
|
|
25
37
|
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the root and is merged last. */
|
|
26
38
|
classNames?: ClassNames<NumberStepperPart>;
|
|
27
39
|
}
|
|
28
40
|
|
|
29
|
-
/**
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
/** Numeric mode (default): the value is a finite number, typing is committed on blur or Enter and snapped to `step`. */
|
|
42
|
+
export interface NumberStepperNumberProps extends NumberStepperBaseProps {
|
|
43
|
+
mode?: "number";
|
|
44
|
+
value?: number;
|
|
45
|
+
defaultValue?: number;
|
|
46
|
+
onValueChange?: (value: number) => void;
|
|
47
|
+
onChange?: never;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* String mode: the caller owns the text. Typing is never rewritten, the field may be empty, and every
|
|
52
|
+
* change (typing, the buttons, ArrowUp/ArrowDown) reports both `onChange(event)` with the new text in
|
|
53
|
+
* `event.target.value` and `onValueChange(text)`. `min`, `max` and `step` bound the stepping and the ARIA range.
|
|
54
|
+
*/
|
|
55
|
+
export interface NumberStepperStringProps extends NumberStepperBaseProps {
|
|
56
|
+
mode: "string";
|
|
57
|
+
value?: string;
|
|
58
|
+
defaultValue?: string;
|
|
59
|
+
onValueChange?: (value: string) => void;
|
|
60
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type NumberStepperProps = NumberStepperNumberProps | NumberStepperStringProps;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Counter with minus/plus buttons and a typeable value; ArrowUp/ArrowDown step it, Home/End jump.
|
|
67
|
+
* Numeric by default; `mode="string"` hands the text to the caller (empty state, change event).
|
|
68
|
+
*/
|
|
69
|
+
export function NumberStepper(props: NumberStepperProps) {
|
|
70
|
+
const {
|
|
71
|
+
min = Number.NEGATIVE_INFINITY,
|
|
72
|
+
max = Number.POSITIVE_INFINITY,
|
|
73
|
+
step = 1,
|
|
74
|
+
disabled,
|
|
75
|
+
unit,
|
|
76
|
+
name,
|
|
77
|
+
id: idProp,
|
|
78
|
+
placeholder,
|
|
79
|
+
required,
|
|
80
|
+
invalid,
|
|
81
|
+
className,
|
|
82
|
+
classNames,
|
|
83
|
+
"aria-label": ariaLabel,
|
|
84
|
+
"aria-labelledby": ariaLabelledBy,
|
|
85
|
+
"aria-describedby": ariaDescribedBy,
|
|
86
|
+
"aria-invalid": ariaInvalid,
|
|
87
|
+
} = props;
|
|
88
|
+
const autoId = useId();
|
|
89
|
+
const id = idProp ?? autoId;
|
|
90
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
91
|
+
const isString = props.mode === "string";
|
|
92
|
+
const [innerNumber, setInnerNumber] = useState(isString ? 0 : (props.defaultValue ?? 0));
|
|
93
|
+
const [innerText, setInnerText] = useState(isString ? (props.defaultValue ?? "") : "");
|
|
47
94
|
const [draft, setDraft] = useState<string | null>(null);
|
|
95
|
+
const controlled = props.value !== undefined;
|
|
96
|
+
const number = isString
|
|
97
|
+
? parseNumber(controlledText(props, innerText))
|
|
98
|
+
: (props.value ?? innerNumber);
|
|
99
|
+
const text = isString ? controlledText(props, innerText) : String(number);
|
|
48
100
|
|
|
49
101
|
const apply = (raw: number) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (
|
|
102
|
+
if (isString) return;
|
|
103
|
+
const next = Number.isFinite(raw) ? snapToStep(raw, min, max, step) : number;
|
|
104
|
+
if (!controlled) setInnerNumber(next);
|
|
105
|
+
if (next !== number) props.onValueChange?.(next);
|
|
53
106
|
};
|
|
54
107
|
|
|
55
108
|
const commitDraft = () => {
|
|
@@ -59,24 +112,51 @@ export function NumberStepper({
|
|
|
59
112
|
if (draft.trim() !== "") apply(parsed);
|
|
60
113
|
};
|
|
61
114
|
|
|
115
|
+
// String mode reports through a real change event, so `onChange(e)` works for the buttons too.
|
|
116
|
+
const setText = (next: string) => {
|
|
117
|
+
const input = inputRef.current;
|
|
118
|
+
const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
|
|
119
|
+
if (!input || !setter) return;
|
|
120
|
+
setter.call(input, next);
|
|
121
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const move = (direction: 1 | -1) => {
|
|
125
|
+
if (isString) setText(stepText(text, direction, { min, max, step }));
|
|
126
|
+
else apply(number + direction * step);
|
|
127
|
+
};
|
|
128
|
+
|
|
62
129
|
const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
63
|
-
if (event.key === "ArrowUp")
|
|
64
|
-
else if (event.key === "ArrowDown")
|
|
65
|
-
else if (event.key === "Home" && Number.isFinite(min))
|
|
66
|
-
|
|
67
|
-
|
|
130
|
+
if (event.key === "ArrowUp") move(1);
|
|
131
|
+
else if (event.key === "ArrowDown") move(-1);
|
|
132
|
+
else if (event.key === "Home" && Number.isFinite(min)) {
|
|
133
|
+
if (isString) setText(String(min));
|
|
134
|
+
else apply(min);
|
|
135
|
+
} else if (event.key === "End" && Number.isFinite(max)) {
|
|
136
|
+
if (isString) setText(String(max));
|
|
137
|
+
else apply(max);
|
|
138
|
+
} else if (event.key === "Enter" && !isString) commitDraft();
|
|
68
139
|
else return;
|
|
69
140
|
if (event.key !== "Enter") event.preventDefault();
|
|
70
141
|
};
|
|
71
142
|
|
|
143
|
+
const onChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
144
|
+
if (props.mode !== "string") return setDraft(event.target.value);
|
|
145
|
+
if (!controlled) setInnerText(event.target.value);
|
|
146
|
+
props.onChange?.(event);
|
|
147
|
+
props.onValueChange?.(event.target.value);
|
|
148
|
+
};
|
|
149
|
+
|
|
72
150
|
const button =
|
|
73
151
|
"grid h-full w-9 shrink-0 place-items-center text-ink-2 outline-none hover:bg-surface-sunken hover:text-ink focus-visible:focus-ring disabled:cursor-not-allowed disabled:opacity-40";
|
|
152
|
+
const valid = !Number.isNaN(number);
|
|
74
153
|
|
|
75
154
|
return (
|
|
76
155
|
<div
|
|
77
156
|
className={cn(
|
|
78
157
|
"inline-flex h-input min-w-32 max-w-full items-stretch overflow-hidden rounded-input border-control bg-surface-control",
|
|
79
158
|
disabled && "opacity-60",
|
|
159
|
+
(invalid || ariaInvalid) && "border-danger",
|
|
80
160
|
classNames?.root,
|
|
81
161
|
className,
|
|
82
162
|
)}
|
|
@@ -86,30 +166,36 @@ export function NumberStepper({
|
|
|
86
166
|
tabIndex={-1}
|
|
87
167
|
aria-label="Disminuir"
|
|
88
168
|
aria-controls={id}
|
|
89
|
-
disabled={disabled ||
|
|
90
|
-
onClick={() =>
|
|
169
|
+
disabled={disabled || !canStep(text, -1, { min, max })}
|
|
170
|
+
onClick={() => move(-1)}
|
|
91
171
|
className={cn(button, "pressable", classNames?.decrement)}
|
|
92
172
|
>
|
|
93
173
|
<Minus aria-hidden="true" className="size-3.5" />
|
|
94
174
|
</button>
|
|
95
175
|
<input
|
|
176
|
+
ref={inputRef}
|
|
96
177
|
id={id}
|
|
97
178
|
name={name}
|
|
98
179
|
role="spinbutton"
|
|
99
180
|
inputMode="decimal"
|
|
181
|
+
placeholder={placeholder}
|
|
182
|
+
required={required}
|
|
100
183
|
disabled={disabled}
|
|
101
|
-
aria-valuenow={
|
|
184
|
+
aria-valuenow={valid ? number : undefined}
|
|
102
185
|
aria-valuemin={Number.isFinite(min) ? min : undefined}
|
|
103
186
|
aria-valuemax={Number.isFinite(max) ? max : undefined}
|
|
104
|
-
aria-valuetext={unit ? `${
|
|
105
|
-
aria-label={
|
|
106
|
-
aria-labelledby={
|
|
107
|
-
|
|
108
|
-
|
|
187
|
+
aria-valuetext={unit && valid ? `${number} ${unit}` : undefined}
|
|
188
|
+
aria-label={ariaLabel}
|
|
189
|
+
aria-labelledby={ariaLabelledBy}
|
|
190
|
+
aria-describedby={ariaDescribedBy}
|
|
191
|
+
aria-invalid={ariaInvalid ?? (invalid || undefined)}
|
|
192
|
+
aria-required={required || undefined}
|
|
193
|
+
value={draft ?? text}
|
|
194
|
+
onChange={onChange}
|
|
109
195
|
onBlur={commitDraft}
|
|
110
196
|
onKeyDown={onKeyDown}
|
|
111
197
|
className={cn(
|
|
112
|
-
"w-14 min-w-0 flex-1 bg-transparent px-1 text-center text-control text-ink tabular-nums outline-none focus-visible:focus-ring",
|
|
198
|
+
"w-14 min-w-0 flex-1 bg-transparent px-1 text-center text-control text-ink tabular-nums outline-none placeholder:text-ink-3 focus-visible:focus-ring",
|
|
113
199
|
classNames?.input,
|
|
114
200
|
)}
|
|
115
201
|
/>
|
|
@@ -126,8 +212,8 @@ export function NumberStepper({
|
|
|
126
212
|
tabIndex={-1}
|
|
127
213
|
aria-label="Aumentar"
|
|
128
214
|
aria-controls={id}
|
|
129
|
-
disabled={disabled ||
|
|
130
|
-
onClick={() =>
|
|
215
|
+
disabled={disabled || !canStep(text, 1, { min, max })}
|
|
216
|
+
onClick={() => move(1)}
|
|
131
217
|
className={cn(button, "pressable", classNames?.increment)}
|
|
132
218
|
>
|
|
133
219
|
<Plus aria-hidden="true" className="size-3.5" />
|
|
@@ -135,3 +221,7 @@ export function NumberStepper({
|
|
|
135
221
|
</div>
|
|
136
222
|
);
|
|
137
223
|
}
|
|
224
|
+
|
|
225
|
+
function controlledText(props: NumberStepperProps, inner: string): string {
|
|
226
|
+
return props.mode === "string" ? (props.value ?? inner) : inner;
|
|
227
|
+
}
|