@atmos.build/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/dist/components/alert-dialog.d.ts +14 -0
- package/dist/components/alert-dialog.js +40 -0
- package/dist/components/at-search.d.ts +35 -0
- package/dist/components/at-search.js +57 -0
- package/dist/components/attachment-thumbnail-stack.d.ts +13 -0
- package/dist/components/attachment-thumbnail-stack.js +23 -0
- package/dist/components/audio-preview.d.ts +33 -0
- package/dist/components/audio-preview.js +176 -0
- package/dist/components/avatar-uploader.d.ts +29 -0
- package/dist/components/avatar-uploader.js +67 -0
- package/dist/components/avatar.d.ts +12 -0
- package/dist/components/avatar.js +38 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/badge.js +25 -0
- package/dist/components/button-group.d.ts +12 -0
- package/dist/components/button-group.js +29 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +42 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +154 -0
- package/dist/components/channel-list.d.ts +33 -0
- package/dist/components/channel-list.js +40 -0
- package/dist/components/charts/area-chart.d.ts +2 -0
- package/dist/components/charts/area-chart.js +5 -0
- package/dist/components/charts/bar-chart.d.ts +2 -0
- package/dist/components/charts/bar-chart.js +58 -0
- package/dist/components/charts/colors.d.ts +2 -0
- package/dist/components/charts/colors.js +42 -0
- package/dist/components/charts/hover.d.ts +20 -0
- package/dist/components/charts/hover.js +31 -0
- package/dist/components/charts/index.d.ts +10 -0
- package/dist/components/charts/index.js +9 -0
- package/dist/components/charts/layout.d.ts +35 -0
- package/dist/components/charts/layout.js +101 -0
- package/dist/components/charts/legend.d.ts +6 -0
- package/dist/components/charts/legend.js +7 -0
- package/dist/components/charts/line-area-chart.d.ts +4 -0
- package/dist/components/charts/line-area-chart.js +86 -0
- package/dist/components/charts/line-chart.d.ts +2 -0
- package/dist/components/charts/line-chart.js +5 -0
- package/dist/components/charts/pie-chart.d.ts +2 -0
- package/dist/components/charts/pie-chart.js +22 -0
- package/dist/components/charts/radar-chart.d.ts +2 -0
- package/dist/components/charts/radar-chart.js +29 -0
- package/dist/components/charts/radial-chart.d.ts +2 -0
- package/dist/components/charts/radial-chart.js +19 -0
- package/dist/components/charts/scatter-chart.d.ts +2 -0
- package/dist/components/charts/scatter-chart.js +16 -0
- package/dist/components/charts/story-data.d.ts +24 -0
- package/dist/components/charts/story-data.js +48 -0
- package/dist/components/charts/types.d.ts +43 -0
- package/dist/components/charts/types.js +1 -0
- package/dist/components/checkbox.d.ts +4 -0
- package/dist/components/checkbox.js +10 -0
- package/dist/components/chip.d.ts +25 -0
- package/dist/components/chip.js +36 -0
- package/dist/components/code-editor-theme.d.ts +19 -0
- package/dist/components/code-editor-theme.js +100 -0
- package/dist/components/collapsible-section-header.d.ts +82 -0
- package/dist/components/collapsible-section-header.js +82 -0
- package/dist/components/collection-view/collection-view-group-settings.d.ts +73 -0
- package/dist/components/collection-view/collection-view-group-settings.js +55 -0
- package/dist/components/collection-view/collection-view-settings.d.ts +115 -0
- package/dist/components/collection-view/collection-view-settings.js +146 -0
- package/dist/components/collection-view/collection-view.d.ts +87 -0
- package/dist/components/collection-view/collection-view.js +95 -0
- package/dist/components/collection-view/index.d.ts +6 -0
- package/dist/components/collection-view/index.js +6 -0
- package/dist/components/collection-view/use-collection-detail-navigation.d.ts +11 -0
- package/dist/components/collection-view/use-collection-detail-navigation.js +12 -0
- package/dist/components/collection-view/use-collection-escape.d.ts +9 -0
- package/dist/components/collection-view/use-collection-escape.js +20 -0
- package/dist/components/collection-view/use-collection-selection.d.ts +42 -0
- package/dist/components/collection-view/use-collection-selection.js +203 -0
- package/dist/components/color-picker.d.ts +18 -0
- package/dist/components/color-picker.js +77 -0
- package/dist/components/color-swatch-list.d.ts +16 -0
- package/dist/components/color-swatch-list.js +60 -0
- package/dist/components/combobox/combobox.d.ts +4 -0
- package/dist/components/combobox/combobox.js +70 -0
- package/dist/components/combobox/compound.d.ts +68 -0
- package/dist/components/combobox/compound.js +151 -0
- package/dist/components/combobox/context.d.ts +34 -0
- package/dist/components/combobox/context.js +123 -0
- package/dist/components/combobox/create-step.d.ts +12 -0
- package/dist/components/combobox/create-step.js +8 -0
- package/dist/components/combobox/index.d.ts +10 -0
- package/dist/components/combobox/index.js +5 -0
- package/dist/components/combobox/inline-create-form.d.ts +24 -0
- package/dist/components/combobox/inline-create-form.js +43 -0
- package/dist/components/combobox/types.d.ts +57 -0
- package/dist/components/combobox/types.js +10 -0
- package/dist/components/command.d.ts +35 -0
- package/dist/components/command.js +76 -0
- package/dist/components/comment-pin.d.ts +13 -0
- package/dist/components/comment-pin.js +33 -0
- package/dist/components/confidence-meter.d.ts +11 -0
- package/dist/components/confidence-meter.js +24 -0
- package/dist/components/context-menu.d.ts +31 -0
- package/dist/components/context-menu.js +54 -0
- package/dist/components/copy-button.d.ts +12 -0
- package/dist/components/copy-button.js +32 -0
- package/dist/components/date-picker.d.ts +29 -0
- package/dist/components/date-picker.js +86 -0
- package/dist/components/date-tile.d.ts +11 -0
- package/dist/components/date-tile.js +16 -0
- package/dist/components/date-time-picker.d.ts +25 -0
- package/dist/components/date-time-picker.js +153 -0
- package/dist/components/detail-breadcrumb-utils.d.ts +2 -0
- package/dist/components/detail-breadcrumb-utils.js +18 -0
- package/dist/components/detail-nav-bar.d.ts +28 -0
- package/dist/components/detail-nav-bar.js +28 -0
- package/dist/components/detail-top-bar.d.ts +49 -0
- package/dist/components/detail-top-bar.js +41 -0
- package/dist/components/dialog.d.ts +22 -0
- package/dist/components/dialog.js +51 -0
- package/dist/components/dropdown-menu.d.ts +29 -0
- package/dist/components/dropdown-menu.js +52 -0
- package/dist/components/editable-doc-title.d.ts +17 -0
- package/dist/components/editable-doc-title.js +147 -0
- package/dist/components/empty-state.d.ts +12 -0
- package/dist/components/empty-state.js +6 -0
- package/dist/components/filter-condition-editor.d.ts +18 -0
- package/dist/components/filter-condition-editor.js +102 -0
- package/dist/components/form-dialog.d.ts +30 -0
- package/dist/components/form-dialog.js +52 -0
- package/dist/components/formula-editor.d.ts +18 -0
- package/dist/components/formula-editor.js +154 -0
- package/dist/components/hover-card.d.ts +52 -0
- package/dist/components/hover-card.js +51 -0
- package/dist/components/icon-button.d.ts +15 -0
- package/dist/components/icon-button.js +18 -0
- package/dist/components/inline-alert.d.ts +11 -0
- package/dist/components/inline-alert.js +17 -0
- package/dist/components/input.d.ts +3 -0
- package/dist/components/input.js +7 -0
- package/dist/components/kanban-board.d.ts +27 -0
- package/dist/components/kanban-board.js +145 -0
- package/dist/components/kbd.d.ts +3 -0
- package/dist/components/kbd.js +8 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +9 -0
- package/dist/components/markdown-editor/index.d.ts +4 -0
- package/dist/components/markdown-editor/index.js +2 -0
- package/dist/components/markdown-editor/markdown-editor.d.ts +16 -0
- package/dist/components/markdown-editor/markdown-editor.js +53 -0
- package/dist/components/markdown-editor/serialize.d.ts +12 -0
- package/dist/components/markdown-editor/serialize.js +122 -0
- package/dist/components/markdown-editor/vim.d.ts +8 -0
- package/dist/components/markdown-editor/vim.js +394 -0
- package/dist/components/metric-grid.d.ts +41 -0
- package/dist/components/metric-grid.js +39 -0
- package/dist/components/microphone-priority.d.ts +29 -0
- package/dist/components/microphone-priority.js +15 -0
- package/dist/components/middle-truncate.d.ts +6 -0
- package/dist/components/middle-truncate.js +15 -0
- package/dist/components/multi-combobox.d.ts +48 -0
- package/dist/components/multi-combobox.js +221 -0
- package/dist/components/naut-avatar-engine.d.ts +83 -0
- package/dist/components/naut-avatar-engine.js +803 -0
- package/dist/components/naut-avatar.d.ts +31 -0
- package/dist/components/naut-avatar.js +108 -0
- package/dist/components/navigable-list.d.ts +4 -0
- package/dist/components/navigable-list.js +20 -0
- package/dist/components/note-icon-picker.d.ts +20 -0
- package/dist/components/note-icon-picker.js +84 -0
- package/dist/components/note-icon.d.ts +690 -0
- package/dist/components/note-icon.js +353 -0
- package/dist/components/note-row.d.ts +33 -0
- package/dist/components/note-row.js +29 -0
- package/dist/components/overlapping-dots.d.ts +10 -0
- package/dist/components/overlapping-dots.js +13 -0
- package/dist/components/overview-card.d.ts +12 -0
- package/dist/components/overview-card.js +9 -0
- package/dist/components/panel-header.d.ts +8 -0
- package/dist/components/panel-header.js +6 -0
- package/dist/components/panel-section-states.d.ts +9 -0
- package/dist/components/panel-section-states.js +10 -0
- package/dist/components/person-avatar.d.ts +10 -0
- package/dist/components/person-avatar.js +23 -0
- package/dist/components/photo-avatar.d.ts +11 -0
- package/dist/components/photo-avatar.js +24 -0
- package/dist/components/picker-field.d.ts +23 -0
- package/dist/components/picker-field.js +24 -0
- package/dist/components/popover-stack.d.ts +26 -0
- package/dist/components/popover-stack.js +89 -0
- package/dist/components/popover.d.ts +12 -0
- package/dist/components/popover.js +31 -0
- package/dist/components/portal-login-barrier.d.ts +12 -0
- package/dist/components/portal-login-barrier.js +41 -0
- package/dist/components/presence-dot.d.ts +8 -0
- package/dist/components/presence-dot.js +15 -0
- package/dist/components/presence-overlay.d.ts +27 -0
- package/dist/components/presence-overlay.js +34 -0
- package/dist/components/property-list.d.ts +64 -0
- package/dist/components/property-list.js +313 -0
- package/dist/components/property-panel.d.ts +54 -0
- package/dist/components/property-panel.js +87 -0
- package/dist/components/property-selector.d.ts +36 -0
- package/dist/components/property-selector.js +141 -0
- package/dist/components/provenance-chip.d.ts +12 -0
- package/dist/components/provenance-chip.js +17 -0
- package/dist/components/qr-code.d.ts +13 -0
- package/dist/components/qr-code.js +42 -0
- package/dist/components/qr-encode.d.ts +2 -0
- package/dist/components/qr-encode.js +469 -0
- package/dist/components/quantity-stepper.d.ts +25 -0
- package/dist/components/quantity-stepper.js +43 -0
- package/dist/components/radio-group.d.ts +5 -0
- package/dist/components/radio-group.js +13 -0
- package/dist/components/rename-dialog.d.ts +19 -0
- package/dist/components/rename-dialog.js +35 -0
- package/dist/components/row-surface.d.ts +1 -0
- package/dist/components/row-surface.js +5 -0
- package/dist/components/row-trailing.d.ts +30 -0
- package/dist/components/row-trailing.js +59 -0
- package/dist/components/run-status-badge.d.ts +16 -0
- package/dist/components/run-status-badge.js +43 -0
- package/dist/components/scroll-area.d.ts +5 -0
- package/dist/components/scroll-area.js +12 -0
- package/dist/components/select.d.ts +15 -0
- package/dist/components/select.js +39 -0
- package/dist/components/selectable-card.d.ts +33 -0
- package/dist/components/selectable-card.js +66 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +8 -0
- package/dist/components/settings-dialog-shell.d.ts +46 -0
- package/dist/components/settings-dialog-shell.js +48 -0
- package/dist/components/shimmer-text.d.ts +8 -0
- package/dist/components/shimmer-text.js +26 -0
- package/dist/components/side-panel-tokens.d.ts +27 -0
- package/dist/components/side-panel-tokens.js +26 -0
- package/dist/components/side-panel.d.ts +94 -0
- package/dist/components/side-panel.js +106 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +6 -0
- package/dist/components/sortable.d.ts +65 -0
- package/dist/components/sortable.js +110 -0
- package/dist/components/spec-strip.d.ts +18 -0
- package/dist/components/spec-strip.js +15 -0
- package/dist/components/speech-playback.d.ts +25 -0
- package/dist/components/speech-playback.js +35 -0
- package/dist/components/sql-editor.d.ts +13 -0
- package/dist/components/sql-editor.js +228 -0
- package/dist/components/stat-tile.d.ts +7 -0
- package/dist/components/stat-tile.js +6 -0
- package/dist/components/status-badge.d.ts +17 -0
- package/dist/components/status-badge.js +8 -0
- package/dist/components/status-tone.d.ts +9 -0
- package/dist/components/status-tone.js +10 -0
- package/dist/components/sticky-header-fade.d.ts +8 -0
- package/dist/components/sticky-header-fade.js +11 -0
- package/dist/components/swatch-button.d.ts +14 -0
- package/dist/components/swatch-button.js +25 -0
- package/dist/components/switch.d.ts +6 -0
- package/dist/components/switch.js +9 -0
- package/dist/components/system-load/index.d.ts +6 -0
- package/dist/components/system-load/index.js +6 -0
- package/dist/components/system-load/load-block.d.ts +20 -0
- package/dist/components/system-load/load-block.js +23 -0
- package/dist/components/system-load/load-grid.d.ts +16 -0
- package/dist/components/system-load/load-grid.js +23 -0
- package/dist/components/system-load/load-meter.d.ts +25 -0
- package/dist/components/system-load/load-meter.js +29 -0
- package/dist/components/system-load/load-tone.d.ts +21 -0
- package/dist/components/system-load/load-tone.js +29 -0
- package/dist/components/system-load/meter-row.d.ts +31 -0
- package/dist/components/system-load/meter-row.js +29 -0
- package/dist/components/system-load/resource-meter.d.ts +19 -0
- package/dist/components/system-load/resource-meter.js +15 -0
- package/dist/components/tab-title-bar.d.ts +12 -0
- package/dist/components/tab-title-bar.js +9 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +29 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +97 -0
- package/dist/components/template-chip-input.d.ts +36 -0
- package/dist/components/template-chip-input.js +271 -0
- package/dist/components/template-input.d.ts +24 -0
- package/dist/components/template-input.js +57 -0
- package/dist/components/terminal-spinner.d.ts +11 -0
- package/dist/components/terminal-spinner.js +48 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/textarea.js +7 -0
- package/dist/components/time-column.d.ts +24 -0
- package/dist/components/time-column.js +60 -0
- package/dist/components/timestamped-transcript.d.ts +38 -0
- package/dist/components/timestamped-transcript.js +29 -0
- package/dist/components/timezone-picker.d.ts +22 -0
- package/dist/components/timezone-picker.js +60 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +29 -0
- package/dist/components/transcription-overlay.d.ts +47 -0
- package/dist/components/transcription-overlay.js +30 -0
- package/dist/components/usage-bar.d.ts +17 -0
- package/dist/components/usage-bar.js +26 -0
- package/dist/components/view-query-bar.d.ts +13 -0
- package/dist/components/view-query-bar.js +13 -0
- package/dist/components/view-query-controls.d.ts +159 -0
- package/dist/components/view-query-controls.js +109 -0
- package/dist/components/view-save-menu.d.ts +20 -0
- package/dist/components/view-save-menu.js +13 -0
- package/dist/components/view-sort-editor.d.ts +40 -0
- package/dist/components/view-sort-editor.js +47 -0
- package/dist/components/voice-line.d.ts +37 -0
- package/dist/components/voice-line.js +293 -0
- package/dist/components/weekly-schedule-editor.d.ts +15 -0
- package/dist/components/weekly-schedule-editor.js +28 -0
- package/dist/flow/canvas/canvas-frame.d.ts +160 -0
- package/dist/flow/canvas/canvas-frame.js +521 -0
- package/dist/flow/canvas/collaborator-layer.d.ts +12 -0
- package/dist/flow/canvas/collaborator-layer.js +43 -0
- package/dist/flow/canvas/connector-edge.d.ts +22 -0
- package/dist/flow/canvas/connector-edge.js +61 -0
- package/dist/flow/canvas/editor-context.d.ts +23 -0
- package/dist/flow/canvas/editor-context.js +6 -0
- package/dist/flow/canvas/graph-core.d.ts +60 -0
- package/dist/flow/canvas/graph-core.js +296 -0
- package/dist/flow/canvas/minimap-sticky-overlay.d.ts +4 -0
- package/dist/flow/canvas/minimap-sticky-overlay.js +45 -0
- package/dist/flow/canvas/node-card.d.ts +46 -0
- package/dist/flow/canvas/node-card.js +56 -0
- package/dist/flow/canvas/node-library.d.ts +40 -0
- package/dist/flow/canvas/node-library.js +54 -0
- package/dist/flow/canvas/sticky-notes.d.ts +25 -0
- package/dist/flow/canvas/sticky-notes.js +101 -0
- package/dist/flow/collaborative-graph-presence.d.ts +28 -0
- package/dist/flow/collaborative-graph-presence.js +55 -0
- package/dist/flow/collaborative-graph-sync.d.ts +40 -0
- package/dist/flow/collaborative-graph-sync.js +127 -0
- package/dist/flow/editor/adapter.d.ts +64 -0
- package/dist/flow/editor/adapter.js +1 -0
- package/dist/flow/editor/command-registry.d.ts +10 -0
- package/dist/flow/editor/command-registry.js +35 -0
- package/dist/flow/editor/dag-canvas.d.ts +18 -0
- package/dist/flow/editor/dag-canvas.js +33 -0
- package/dist/flow/editor/flow-editor.d.ts +54 -0
- package/dist/flow/editor/flow-editor.js +199 -0
- package/dist/flow/editor/issues-popover.d.ts +11 -0
- package/dist/flow/editor/issues-popover.js +70 -0
- package/dist/flow/editor/library-rail.d.ts +19 -0
- package/dist/flow/editor/library-rail.js +25 -0
- package/dist/flow/editor/make-controller.d.ts +18 -0
- package/dist/flow/editor/make-controller.js +44 -0
- package/dist/flow/editor/node-chip.d.ts +2 -0
- package/dist/flow/editor/node-chip.js +16 -0
- package/dist/flow/editor/save-publish-bar.d.ts +27 -0
- package/dist/flow/editor/save-publish-bar.js +14 -0
- package/dist/flow/editor/settings-dialog.d.ts +11 -0
- package/dist/flow/editor/settings-dialog.js +11 -0
- package/dist/flow/editor/settings-shell.d.ts +21 -0
- package/dist/flow/editor/settings-shell.js +20 -0
- package/dist/flow/editor/side-rail.d.ts +22 -0
- package/dist/flow/editor/side-rail.js +15 -0
- package/dist/flow/editor/use-dag-editor.d.ts +94 -0
- package/dist/flow/editor/use-dag-editor.js +502 -0
- package/dist/flow/index.d.ts +25 -0
- package/dist/flow/index.js +25 -0
- package/dist/flow/presence-motion.d.ts +10 -0
- package/dist/flow/presence-motion.js +88 -0
- package/dist/flow/styles.css +1 -0
- package/dist/flow/use-collaborative-graph.d.ts +61 -0
- package/dist/flow/use-collaborative-graph.js +396 -0
- package/dist/flow/use-debounced-value.d.ts +1 -0
- package/dist/flow/use-debounced-value.js +10 -0
- package/dist/hooks/use-detail-nav.d.ts +11 -0
- package/dist/hooks/use-detail-nav.js +49 -0
- package/dist/hooks/use-flush-on-hide.d.ts +1 -0
- package/dist/hooks/use-flush-on-hide.js +21 -0
- package/dist/hooks/use-media-query.d.ts +1 -0
- package/dist/hooks/use-media-query.js +20 -0
- package/dist/hooks/use-virtualizer.d.ts +1 -0
- package/dist/hooks/use-virtualizer.js +1 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.js +139 -0
- package/dist/lib/brand-style.d.ts +6 -0
- package/dist/lib/brand-style.js +16 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +5 -0
- package/dist/lib/composited-glint.d.ts +7 -0
- package/dist/lib/composited-glint.js +98 -0
- package/dist/lib/date-time-format.d.ts +2 -0
- package/dist/lib/date-time-format.js +21 -0
- package/dist/lib/disclosure-state.d.ts +11 -0
- package/dist/lib/disclosure-state.js +22 -0
- package/dist/lib/label-swatches.d.ts +10 -0
- package/dist/lib/label-swatches.js +24 -0
- package/dist/lib/local-ui-state.d.ts +10 -0
- package/dist/lib/local-ui-state.js +95 -0
- package/dist/lib/parse-loose-datetime.d.ts +1 -0
- package/dist/lib/parse-loose-datetime.js +180 -0
- package/dist/lib/parse-loose-time.d.ts +6 -0
- package/dist/lib/parse-loose-time.js +53 -0
- package/dist/lib/parse-loose.d.ts +1 -0
- package/dist/lib/parse-loose.js +170 -0
- package/dist/lib/react-19-jsx.d.ts +8 -0
- package/dist/lib/react-19-jsx.js +1 -0
- package/dist/lib/view-chrome.d.ts +5 -0
- package/dist/lib/view-chrome.js +5 -0
- package/dist/lib/view-query/config.d.ts +26 -0
- package/dist/lib/view-query/config.js +162 -0
- package/dist/lib/view-query/evaluate.d.ts +11 -0
- package/dist/lib/view-query/evaluate.js +196 -0
- package/dist/lib/view-query/group-order.d.ts +25 -0
- package/dist/lib/view-query/group-order.js +49 -0
- package/dist/lib/view-query/index.d.ts +6 -0
- package/dist/lib/view-query/index.js +6 -0
- package/dist/lib/view-query/model.d.ts +34 -0
- package/dist/lib/view-query/model.js +88 -0
- package/dist/lib/view-query/sort.d.ts +7 -0
- package/dist/lib/view-query/sort.js +30 -0
- package/dist/lib/view-query/types.d.ts +70 -0
- package/dist/lib/view-query/types.js +12 -0
- package/dist/lib/weekly-schedule.d.ts +8 -0
- package/dist/lib/weekly-schedule.js +10 -0
- package/dist/mcp-app/index.d.ts +4 -0
- package/dist/mcp-app/index.js +3 -0
- package/dist/mcp-app/shadcn.css +629 -0
- package/dist/mcp-app/styles.css +72 -0
- package/dist/mcp-app/theme.d.ts +2 -0
- package/dist/mcp-app/theme.js +62 -0
- package/dist/mcp-app/use-atmos-mcp-app.d.ts +109 -0
- package/dist/mcp-app/use-atmos-mcp-app.js +30 -0
- package/dist/mcp-app/vite.d.ts +7 -0
- package/dist/mcp-app/vite.js +30 -0
- package/dist/tokens/index.d.ts +7 -0
- package/dist/tokens/index.js +7 -0
- package/dist/tokens/semantic.css +110 -0
- package/dist/tokens/tokens.css +195 -0
- package/package.json +98 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
function equalSets(left, right) {
|
|
3
|
+
return left.size === right.size && [...left].every((id) => right.has(id));
|
|
4
|
+
}
|
|
5
|
+
const alwaysSelectable = () => true;
|
|
6
|
+
export function useCollectionSelection({ itemIds, isSelectable = alwaysSelectable, selectedIds: controlledSelection, defaultSelectedIds, defaultFocusedId, onSelectionChange, onOpen, onDelete, }) {
|
|
7
|
+
const [internalSelection, setInternalSelection] = useState(() => new Set(defaultSelectedIds));
|
|
8
|
+
const [focusedId, setFocusedId] = useState(defaultFocusedId);
|
|
9
|
+
const [anchorId, setAnchorId] = useState(defaultFocusedId);
|
|
10
|
+
const requestedSelection = controlledSelection ?? internalSelection;
|
|
11
|
+
const selectableIds = useMemo(() => itemIds.filter(isSelectable), [isSelectable, itemIds]);
|
|
12
|
+
const availableIds = useMemo(() => new Set(selectableIds), [selectableIds]);
|
|
13
|
+
const indexById = useMemo(() => new Map(selectableIds.map((id, index) => [id, index])), [selectableIds]);
|
|
14
|
+
const selectedIds = useMemo(() => new Set([...requestedSelection].filter((id) => availableIds.has(id))), [availableIds, requestedSelection]);
|
|
15
|
+
const reconciledFocusedId = focusedId && availableIds.has(focusedId) ? focusedId : undefined;
|
|
16
|
+
const reconciledAnchorId = anchorId && availableIds.has(anchorId) ? anchorId : undefined;
|
|
17
|
+
const commit = useCallback((next) => {
|
|
18
|
+
const ordered = new Set(selectableIds.filter((id) => next.has(id)));
|
|
19
|
+
if (controlledSelection === undefined)
|
|
20
|
+
setInternalSelection(ordered);
|
|
21
|
+
onSelectionChange?.(ordered);
|
|
22
|
+
}, [controlledSelection, onSelectionChange, selectableIds]);
|
|
23
|
+
const range = useCallback((from, to) => {
|
|
24
|
+
const first = indexById.get(from);
|
|
25
|
+
const last = indexById.get(to);
|
|
26
|
+
if (first === undefined || last === undefined)
|
|
27
|
+
return new Set([to]);
|
|
28
|
+
const start = Math.min(first, last);
|
|
29
|
+
const end = Math.max(first, last);
|
|
30
|
+
return new Set(selectableIds.slice(start, end + 1));
|
|
31
|
+
}, [indexById, selectableIds]);
|
|
32
|
+
const select = useCallback((id, modifiers = {}) => {
|
|
33
|
+
if (!availableIds.has(id))
|
|
34
|
+
return;
|
|
35
|
+
const additive = Boolean(modifiers.metaKey || modifiers.ctrlKey);
|
|
36
|
+
let next;
|
|
37
|
+
if (modifiers.shiftKey && reconciledAnchorId) {
|
|
38
|
+
const selectedRange = range(reconciledAnchorId, id);
|
|
39
|
+
next = additive ? new Set([...selectedIds, ...selectedRange]) : selectedRange;
|
|
40
|
+
}
|
|
41
|
+
else if (additive) {
|
|
42
|
+
next = new Set(selectedIds);
|
|
43
|
+
if (next.has(id))
|
|
44
|
+
next.delete(id);
|
|
45
|
+
else
|
|
46
|
+
next.add(id);
|
|
47
|
+
setAnchorId(id);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
next = new Set([id]);
|
|
51
|
+
setAnchorId(id);
|
|
52
|
+
}
|
|
53
|
+
setFocusedId(id);
|
|
54
|
+
commit(next);
|
|
55
|
+
}, [availableIds, commit, range, reconciledAnchorId, selectedIds]);
|
|
56
|
+
const activate = useCallback((id, modifiers = {}) => {
|
|
57
|
+
if (modifiers.metaKey || modifiers.ctrlKey || modifiers.shiftKey) {
|
|
58
|
+
select(id, modifiers);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
onOpen?.(id);
|
|
62
|
+
}, [onOpen, select]);
|
|
63
|
+
const handleKeyDown = useCallback((event) => {
|
|
64
|
+
const command = Boolean(event.metaKey || event.ctrlKey);
|
|
65
|
+
if (command && event.key.toLowerCase() === 'a') {
|
|
66
|
+
event.preventDefault?.();
|
|
67
|
+
commit(new Set(selectableIds));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (command && (event.key === 'Backspace' || event.key === 'Delete') && onDelete) {
|
|
71
|
+
const targets = selectedIds.size > 0
|
|
72
|
+
? selectableIds.filter((id) => selectedIds.has(id))
|
|
73
|
+
: reconciledFocusedId
|
|
74
|
+
? [reconciledFocusedId]
|
|
75
|
+
: [];
|
|
76
|
+
if (targets.length === 0)
|
|
77
|
+
return;
|
|
78
|
+
event.preventDefault?.();
|
|
79
|
+
onDelete(targets);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (event.key === 'Enter' && reconciledFocusedId) {
|
|
83
|
+
event.preventDefault?.();
|
|
84
|
+
onOpen?.(reconciledFocusedId);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp')
|
|
88
|
+
return;
|
|
89
|
+
if (selectableIds.length === 0)
|
|
90
|
+
return;
|
|
91
|
+
event.preventDefault?.();
|
|
92
|
+
const currentIndex = reconciledFocusedId ? (indexById.get(reconciledFocusedId) ?? -1) : -1;
|
|
93
|
+
const offset = event.key === 'ArrowDown' ? 1 : -1;
|
|
94
|
+
const initialIndex = event.key === 'ArrowDown' ? 0 : selectableIds.length - 1;
|
|
95
|
+
const nextIndex = currentIndex < 0
|
|
96
|
+
? initialIndex
|
|
97
|
+
: Math.max(0, Math.min(selectableIds.length - 1, currentIndex + offset));
|
|
98
|
+
const nextId = selectableIds[nextIndex];
|
|
99
|
+
if (!nextId)
|
|
100
|
+
return;
|
|
101
|
+
const rangeAnchor = reconciledAnchorId ?? reconciledFocusedId ?? nextId;
|
|
102
|
+
setFocusedId(nextId);
|
|
103
|
+
if (event.shiftKey) {
|
|
104
|
+
setAnchorId(rangeAnchor);
|
|
105
|
+
const selectedRange = range(rangeAnchor, nextId);
|
|
106
|
+
commit(command ? new Set([...selectedIds, ...selectedRange]) : selectedRange);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
setAnchorId(nextId);
|
|
110
|
+
commit(new Set([nextId]));
|
|
111
|
+
}
|
|
112
|
+
}, [
|
|
113
|
+
commit,
|
|
114
|
+
indexById,
|
|
115
|
+
onDelete,
|
|
116
|
+
onOpen,
|
|
117
|
+
range,
|
|
118
|
+
reconciledAnchorId,
|
|
119
|
+
reconciledFocusedId,
|
|
120
|
+
selectableIds,
|
|
121
|
+
selectedIds,
|
|
122
|
+
]);
|
|
123
|
+
const clearSelection = useCallback(() => {
|
|
124
|
+
setFocusedId(undefined);
|
|
125
|
+
setAnchorId(undefined);
|
|
126
|
+
commit(new Set());
|
|
127
|
+
}, [commit]);
|
|
128
|
+
const focusItem = useCallback((id, options = {}) => {
|
|
129
|
+
if (id === undefined) {
|
|
130
|
+
setFocusedId(undefined);
|
|
131
|
+
if (options.establishAnchor)
|
|
132
|
+
setAnchorId(undefined);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (!availableIds.has(id))
|
|
136
|
+
return;
|
|
137
|
+
setFocusedId(id);
|
|
138
|
+
if (options.establishAnchor)
|
|
139
|
+
setAnchorId(id);
|
|
140
|
+
}, [availableIds]);
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (!equalSets(requestedSelection, selectedIds))
|
|
143
|
+
onSelectionChange?.(selectedIds);
|
|
144
|
+
}, [onSelectionChange, requestedSelection, selectedIds]);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (equalSets(internalSelection, selectedIds) &&
|
|
147
|
+
focusedId === reconciledFocusedId &&
|
|
148
|
+
anchorId === reconciledAnchorId) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
let active = true;
|
|
152
|
+
queueMicrotask(() => {
|
|
153
|
+
if (!active)
|
|
154
|
+
return;
|
|
155
|
+
if (controlledSelection === undefined && !equalSets(internalSelection, selectedIds)) {
|
|
156
|
+
setInternalSelection(selectedIds);
|
|
157
|
+
}
|
|
158
|
+
if (focusedId !== reconciledFocusedId)
|
|
159
|
+
setFocusedId(reconciledFocusedId);
|
|
160
|
+
if (anchorId !== reconciledAnchorId)
|
|
161
|
+
setAnchorId(reconciledAnchorId);
|
|
162
|
+
});
|
|
163
|
+
return () => {
|
|
164
|
+
active = false;
|
|
165
|
+
};
|
|
166
|
+
}, [
|
|
167
|
+
anchorId,
|
|
168
|
+
controlledSelection,
|
|
169
|
+
focusedId,
|
|
170
|
+
internalSelection,
|
|
171
|
+
reconciledAnchorId,
|
|
172
|
+
reconciledFocusedId,
|
|
173
|
+
selectedIds,
|
|
174
|
+
]);
|
|
175
|
+
const getItemProps = useCallback((id) => ({
|
|
176
|
+
role: 'option',
|
|
177
|
+
'aria-selected': selectedIds.has(id),
|
|
178
|
+
tabIndex: reconciledFocusedId === id ? 0 : -1,
|
|
179
|
+
onClick: (modifiers) => activate(id, modifiers),
|
|
180
|
+
onKeyDown: handleKeyDown,
|
|
181
|
+
}), [activate, handleKeyDown, reconciledFocusedId, selectedIds]);
|
|
182
|
+
return useMemo(() => ({
|
|
183
|
+
selectedIds,
|
|
184
|
+
focusedId: reconciledFocusedId,
|
|
185
|
+
anchorId: reconciledAnchorId,
|
|
186
|
+
focusItem,
|
|
187
|
+
select,
|
|
188
|
+
activate,
|
|
189
|
+
handleKeyDown,
|
|
190
|
+
clearSelection,
|
|
191
|
+
getItemProps,
|
|
192
|
+
}), [
|
|
193
|
+
clearSelection,
|
|
194
|
+
activate,
|
|
195
|
+
focusItem,
|
|
196
|
+
getItemProps,
|
|
197
|
+
handleKeyDown,
|
|
198
|
+
reconciledAnchorId,
|
|
199
|
+
reconciledFocusedId,
|
|
200
|
+
select,
|
|
201
|
+
selectedIds,
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Button } from './button.js';
|
|
3
|
+
export declare const DEFAULT_COLOR_PALETTE: readonly ["#ef4444", "#f97316", "#f59e0b", "#eab308", "#84cc16", "#22c55e", "#10b981", "#14b8a6", "#06b6d4", "#0ea5e9", "#3b82f6", "#6366f1", "#8b5cf6", "#a855f7", "#d946ef", "#ec4899", "#f43f5e", "#64748b"];
|
|
4
|
+
export declare const DEFAULT_COMPACT_COLOR_PALETTE: readonly ["#64748b", "#0ea5e9", "#10b981", "#f59e0b", "#f43f5e", "#8b5cf6", "#ec4899", "#14b8a6"];
|
|
5
|
+
export interface ColorPickerProps {
|
|
6
|
+
value: string | undefined;
|
|
7
|
+
onChange: (value: string) => void;
|
|
8
|
+
swatches?: readonly string[];
|
|
9
|
+
allowCustom?: boolean;
|
|
10
|
+
hexPlaceholder?: string;
|
|
11
|
+
'aria-label'?: string;
|
|
12
|
+
hexAriaLabel?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
align?: 'start' | 'center' | 'end';
|
|
15
|
+
className?: string;
|
|
16
|
+
size?: React.ComponentProps<typeof Button>['size'];
|
|
17
|
+
}
|
|
18
|
+
export declare const ColorPicker: React.ForwardRefExoticComponent<ColorPickerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { SwatchButton } from './swatch-button.js';
|
|
5
|
+
import { Button } from './button.js';
|
|
6
|
+
import { Input } from './input.js';
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from './popover.js';
|
|
8
|
+
import { cn } from '../lib/cn.js';
|
|
9
|
+
export const DEFAULT_COLOR_PALETTE = [
|
|
10
|
+
'#ef4444',
|
|
11
|
+
'#f97316',
|
|
12
|
+
'#f59e0b',
|
|
13
|
+
'#eab308',
|
|
14
|
+
'#84cc16',
|
|
15
|
+
'#22c55e',
|
|
16
|
+
'#10b981',
|
|
17
|
+
'#14b8a6',
|
|
18
|
+
'#06b6d4',
|
|
19
|
+
'#0ea5e9',
|
|
20
|
+
'#3b82f6',
|
|
21
|
+
'#6366f1',
|
|
22
|
+
'#8b5cf6',
|
|
23
|
+
'#a855f7',
|
|
24
|
+
'#d946ef',
|
|
25
|
+
'#ec4899',
|
|
26
|
+
'#f43f5e',
|
|
27
|
+
'#64748b',
|
|
28
|
+
];
|
|
29
|
+
export const DEFAULT_COMPACT_COLOR_PALETTE = [
|
|
30
|
+
'#64748b',
|
|
31
|
+
'#0ea5e9',
|
|
32
|
+
'#10b981',
|
|
33
|
+
'#f59e0b',
|
|
34
|
+
'#f43f5e',
|
|
35
|
+
'#8b5cf6',
|
|
36
|
+
'#ec4899',
|
|
37
|
+
'#14b8a6',
|
|
38
|
+
];
|
|
39
|
+
const HEX_RE = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
40
|
+
function normalizeHex(input) {
|
|
41
|
+
const v = input.trim();
|
|
42
|
+
const withHash = v.startsWith('#') ? v : `#${v}`;
|
|
43
|
+
if (!HEX_RE.test(withHash))
|
|
44
|
+
return null;
|
|
45
|
+
return withHash.toLowerCase();
|
|
46
|
+
}
|
|
47
|
+
export const ColorPicker = React.forwardRef(function ColorPicker({ value, onChange, swatches = DEFAULT_COLOR_PALETTE, allowCustom = true, hexPlaceholder, 'aria-label': ariaLabel, hexAriaLabel, disabled, align = 'start', className, size = 'icon', }, ref) {
|
|
48
|
+
const [open, setOpen] = React.useState(false);
|
|
49
|
+
const [draft, setDraft] = React.useState('');
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
if (open)
|
|
52
|
+
setDraft(value ?? '');
|
|
53
|
+
}, [open, value]);
|
|
54
|
+
const selected = value ? normalizeHex(value) : null;
|
|
55
|
+
const commitHex = (raw) => {
|
|
56
|
+
const hex = normalizeHex(raw);
|
|
57
|
+
if (hex)
|
|
58
|
+
onChange(hex);
|
|
59
|
+
};
|
|
60
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { ref: ref, type: "button", variant: "outline", size: size, disabled: disabled, "aria-label": ariaLabel, "data-slot": "color-picker-trigger", className: cn('p-1', className), children: _jsx("span", { className: "size-4 rounded-[5px] ring-1 ring-black/10 dark:ring-white/15", style: { backgroundColor: selected ?? 'transparent' }, "data-slot": "color-picker-swatch" }) }) }), _jsxs(PopoverContent, { align: align, sideOffset: 6, className: "w-auto p-2.5", "data-slot": "color-picker-content", children: [_jsx("div", { role: "radiogroup", "aria-label": ariaLabel, className: "grid grid-cols-6 gap-1.5", children: swatches.map((swatch) => {
|
|
61
|
+
const hex = normalizeHex(swatch) ?? swatch;
|
|
62
|
+
const isActive = selected === hex;
|
|
63
|
+
return (_jsx(SwatchButton, { color: hex, selected: isActive, label: swatch, role: "radio", "aria-checked": isActive, "data-testid": `color-${hex}`, onSelect: () => {
|
|
64
|
+
onChange(hex);
|
|
65
|
+
setOpen(false);
|
|
66
|
+
} }, swatch));
|
|
67
|
+
}) }), allowCustom ? (_jsx(Input, { value: draft, placeholder: hexPlaceholder ?? '#000000', "aria-label": hexAriaLabel ?? ariaLabel, "data-slot": "color-picker-hex", className: "mt-2.5 h-7 font-mono text-xs", onChange: (e) => {
|
|
68
|
+
setDraft(e.target.value);
|
|
69
|
+
commitHex(e.target.value);
|
|
70
|
+
}, onKeyDown: (e) => {
|
|
71
|
+
if (e.key === 'Enter') {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
if (normalizeHex(draft))
|
|
74
|
+
setOpen(false);
|
|
75
|
+
}
|
|
76
|
+
} })) : null] })] }));
|
|
77
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type LabelColorSwatch } from '../lib/label-swatches.js';
|
|
2
|
+
export interface ColorSwatchListLabels {
|
|
3
|
+
swatch: (token: string, fallback: string) => string;
|
|
4
|
+
}
|
|
5
|
+
export interface ColorSwatchListProps {
|
|
6
|
+
value?: string | null;
|
|
7
|
+
onPick: (token: string) => void;
|
|
8
|
+
onCancel?: () => void;
|
|
9
|
+
focusOnMount?: boolean;
|
|
10
|
+
swatches?: readonly LabelColorSwatch[];
|
|
11
|
+
searchPlaceholder?: string;
|
|
12
|
+
ariaLabel?: string;
|
|
13
|
+
onActiveChange?: (token: string | null) => void;
|
|
14
|
+
labels?: ColorSwatchListLabels;
|
|
15
|
+
}
|
|
16
|
+
export declare function ColorSwatchList({ value, onPick, onCancel, focusOnMount, swatches, searchPlaceholder, ariaLabel, onActiveChange, labels, }: ColorSwatchListProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useMemo, useRef, useState, } from 'react';
|
|
4
|
+
import { Check } from 'lucide-react';
|
|
5
|
+
import { LABEL_SWATCHES } from '../lib/label-swatches.js';
|
|
6
|
+
import { cn } from '../lib/cn.js';
|
|
7
|
+
const DEFAULT_LABELS = {
|
|
8
|
+
swatch: (_token, fallback) => fallback,
|
|
9
|
+
};
|
|
10
|
+
export function ColorSwatchList({ value, onPick, onCancel, focusOnMount = true, swatches = LABEL_SWATCHES, searchPlaceholder, ariaLabel, onActiveChange, labels = DEFAULT_LABELS, }) {
|
|
11
|
+
const [query, setQuery] = useState('');
|
|
12
|
+
const [activeOverride, setActiveOverride] = useState(null);
|
|
13
|
+
const inputRef = useRef(null);
|
|
14
|
+
const listId = useId();
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (focusOnMount)
|
|
17
|
+
inputRef.current?.focus();
|
|
18
|
+
}, [focusOnMount]);
|
|
19
|
+
const colors = useMemo(() => {
|
|
20
|
+
const q = query.trim().toLowerCase();
|
|
21
|
+
if (!q)
|
|
22
|
+
return swatches;
|
|
23
|
+
return swatches.filter((s) => s.token.toLowerCase().includes(q) ||
|
|
24
|
+
s.name.toLowerCase().includes(q) ||
|
|
25
|
+
labels.swatch(s.token, s.name).toLowerCase().includes(q));
|
|
26
|
+
}, [labels, query, swatches]);
|
|
27
|
+
const tokens = useMemo(() => colors.map((s) => s.token), [colors]);
|
|
28
|
+
const activeToken = activeOverride && tokens.includes(activeOverride) ? activeOverride : (tokens[0] ?? null);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
onActiveChange?.(activeToken);
|
|
31
|
+
}, [activeToken, onActiveChange]);
|
|
32
|
+
const handleKey = (e) => {
|
|
33
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
34
|
+
if (tokens.length === 0)
|
|
35
|
+
return;
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
const idx = activeToken ? tokens.indexOf(activeToken) : -1;
|
|
38
|
+
const delta = e.key === 'ArrowDown' ? 1 : -1;
|
|
39
|
+
setActiveOverride(tokens[(idx + delta + tokens.length) % tokens.length] ?? null);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (e.key === 'Enter') {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
if (activeToken)
|
|
45
|
+
onPick(activeToken);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (e.key === 'Escape') {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
onCancel?.();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const activeDomId = activeToken ? `${listId}-row-${activeToken}` : undefined;
|
|
54
|
+
return (_jsxs("div", { className: "-mx-3", children: [_jsx("div", { className: "border-border/60 border-b px-2.5 pb-1.5", children: _jsx("input", { ref: inputRef, type: "text", role: "combobox", "aria-autocomplete": "list", "aria-controls": listId, "aria-expanded": true, "aria-activedescendant": activeDomId, value: query, placeholder: searchPlaceholder, onChange: (e) => setQuery(e.target.value), onKeyDown: handleKey, className: "placeholder:text-muted-foreground/70 w-full bg-transparent text-[13px] outline-none" }) }), _jsx("ul", { id: listId, role: "listbox", "aria-label": ariaLabel, className: "max-h-[220px] overflow-y-auto py-1", children: colors.map((s) => {
|
|
55
|
+
const active = activeToken === s.token;
|
|
56
|
+
return (
|
|
57
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events -- keyboard handled by the parent input via aria-activedescendant
|
|
58
|
+
_jsxs("li", { id: `${listId}-row-${s.token}`, role: "option", "aria-selected": active, "data-active": active || undefined, onMouseEnter: () => setActiveOverride(s.token), onClick: () => onPick(s.token), className: cn('text-foreground mx-1 flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-[13px]', active && 'bg-muted'), children: [_jsx("span", { "aria-hidden": true, className: cn('inline-block size-3 shrink-0 rounded-full', s.dot) }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: labels.swatch(s.token, s.name) }), value === s.token ? (_jsx(Check, { className: "text-muted-foreground size-3.5 shrink-0", "aria-hidden": true })) : null] }, s.token));
|
|
59
|
+
}) })] }));
|
|
60
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, useMemo } from 'react';
|
|
4
|
+
import { RefreshCw } from 'lucide-react';
|
|
5
|
+
import { Button } from '../button.js';
|
|
6
|
+
import { cn } from '../../lib/cn.js';
|
|
7
|
+
import { ComboboxContent, ComboboxCreate, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, ComboboxRoot, ComboboxTrigger, } from './compound.js';
|
|
8
|
+
import { useCombobox } from './context.js';
|
|
9
|
+
import { ComboboxCreateStep } from './create-step.js';
|
|
10
|
+
import { DEFAULT_COMBOBOX_LABELS } from './types.js';
|
|
11
|
+
export function Combobox(props) {
|
|
12
|
+
const { children, triggerClassName, contentClassName, open, onOpenChange, ...body } = props;
|
|
13
|
+
return (_jsxs(ComboboxRoot, { open: open, onOpenChange: onOpenChange, children: [_jsx(ComboboxTrigger, { className: triggerClassName, children: children }), _jsx(ComboboxContent, { className: contentClassName, children: _jsx(Body, { ...body }) })] }));
|
|
14
|
+
}
|
|
15
|
+
function Body({ value, onSelect, useItems, getId, getLabel, renderItem, getSection, createLabel, CreateForm, renderCreateStep, onQuickCreate, emptyText, loadingText, placeholder, allowCreate = true, showCreateWhenEmpty = false, createLabelWhenEmpty, triggerKey, labels: labelsProp, }) {
|
|
16
|
+
const labels = { ...DEFAULT_COMBOBOX_LABELS, ...labelsProp };
|
|
17
|
+
const { query, debouncedQuery, mode, setMode, setOpen } = useCombobox();
|
|
18
|
+
const result = useItems(debouncedQuery);
|
|
19
|
+
const items = useMemo(() => result.data ?? [], [result.data]);
|
|
20
|
+
const trimmedQuery = query.trim();
|
|
21
|
+
const isPending = result.isLoading || trimmedQuery !== debouncedQuery.trim();
|
|
22
|
+
const hasExactMatch = useMemo(() => {
|
|
23
|
+
if (!getLabel || !trimmedQuery)
|
|
24
|
+
return false;
|
|
25
|
+
const needle = trimmedQuery.toLowerCase();
|
|
26
|
+
return items.some((i) => getLabel(i).toLowerCase() === needle);
|
|
27
|
+
}, [items, trimmedQuery, getLabel]);
|
|
28
|
+
const canCreate = Boolean(onQuickCreate) || Boolean(CreateForm) || Boolean(renderCreateStep);
|
|
29
|
+
const showCreate = allowCreate &&
|
|
30
|
+
canCreate &&
|
|
31
|
+
(trimmedQuery.length > 0 ? !hasExactMatch : showCreateWhenEmpty);
|
|
32
|
+
const activeCreateLabel = trimmedQuery.length > 0 ? createLabel : (createLabelWhenEmpty ?? createLabel);
|
|
33
|
+
const hasStep = Boolean(renderCreateStep) || Boolean(CreateForm);
|
|
34
|
+
const handleSelectItem = (item) => {
|
|
35
|
+
onSelect(item);
|
|
36
|
+
setOpen(false);
|
|
37
|
+
};
|
|
38
|
+
const pickCreate = () => {
|
|
39
|
+
if (onQuickCreate) {
|
|
40
|
+
onQuickCreate(trimmedQuery);
|
|
41
|
+
setOpen(false);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setMode('create');
|
|
45
|
+
};
|
|
46
|
+
const inCreateMode = mode === 'create' && hasStep;
|
|
47
|
+
const onStepCreated = (item) => {
|
|
48
|
+
onSelect(item);
|
|
49
|
+
setOpen(false);
|
|
50
|
+
};
|
|
51
|
+
const onStepCancel = () => setMode('list');
|
|
52
|
+
const stepBody = renderCreateStep
|
|
53
|
+
? renderCreateStep({ query: trimmedQuery, onCreated: onStepCreated, onCancel: onStepCancel })
|
|
54
|
+
: CreateForm
|
|
55
|
+
? (_jsx(CreateForm, { initialValue: trimmedQuery, onCreated: onStepCreated, onCancel: onStepCancel }))
|
|
56
|
+
: null;
|
|
57
|
+
if (inCreateMode) {
|
|
58
|
+
return (_jsx("div", { className: "animate-in fade-in-0 slide-in-from-top-1 duration-150", children: _jsx(ComboboxCreateStep, { label: createLabel, labels: labels, children: stepBody }) }));
|
|
59
|
+
}
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsx(ComboboxInput, { placeholder: placeholder ?? labels.searchPlaceholder, triggerKey: triggerKey, loading: isPending }), _jsxs(ComboboxList, { label: labels.searchResults, children: [result.isError && items.length === 0 ? (_jsx("li", { className: "px-1.5 py-1", children: _jsx(ErrorBanner, { onRetry: result.refetch, labels: labels }) })) : items.length === 0 && !showCreate ? (_jsx(ComboboxEmpty, { pending: isPending, pendingText: loadingText, children: trimmedQuery.length === 0 ? labels.typeToSearch : (emptyText ?? labels.noMatches) })) : (items.map((item, index) => {
|
|
61
|
+
const id = getId(item);
|
|
62
|
+
const section = getSection?.(item);
|
|
63
|
+
const previous = index > 0 ? items[index - 1] : undefined;
|
|
64
|
+
const sectionChanged = getSection && section !== undefined && (index === 0 || getSection(previous) !== section);
|
|
65
|
+
return (_jsxs(Fragment, { children: [sectionChanged ? (_jsx("li", { role: "presentation", className: cn('text-muted-foreground px-2 pb-0.5 text-[10.5px]', index > 0 && 'border-border/60 mt-1 border-t pt-1.5'), children: section })) : null, _jsx(ComboboxItem, { value: id, selected: value === id, onSelect: () => handleSelectItem(item), children: ({ active, selected }) => renderItem(item, { active, selected }) })] }, id));
|
|
66
|
+
})), showCreate ? (_jsx(ComboboxCreate, { query: trimmedQuery, onCreate: pickCreate, label: activeCreateLabel })) : null] })] }));
|
|
67
|
+
}
|
|
68
|
+
function ErrorBanner({ onRetry, labels }) {
|
|
69
|
+
return (_jsxs("div", { role: "alert", className: "flex items-center justify-between gap-2 rounded-md border border-destructive/30 bg-destructive/5 px-2.5 py-1.5 text-[12px] text-destructive", children: [_jsx("span", { children: labels.loadFailed }), onRetry ? (_jsxs(Button, { size: "xs", variant: "ghost", onClick: onRetry, type: "button", children: [_jsx(RefreshCw, { className: "size-3" }), " ", labels.retry] })) : null] }));
|
|
70
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import { StackedPopoverContent, StackedPopoverTrigger } from '../popover-stack.js';
|
|
3
|
+
import { type ComboboxProviderProps } from './context.js';
|
|
4
|
+
export type ComboboxRootProps = ComboboxProviderProps;
|
|
5
|
+
export declare function ComboboxRoot(props: ComboboxRootProps): import("react").JSX.Element;
|
|
6
|
+
export type ComboboxTriggerProps = ComponentProps<typeof StackedPopoverTrigger> & {
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function ComboboxTrigger({ asChild, children, className, ...rest }: ComboboxTriggerProps): import("react").JSX.Element;
|
|
10
|
+
export type ComboboxContentProps = ComponentProps<typeof StackedPopoverContent>;
|
|
11
|
+
export declare function ComboboxContent({ className, ...rest }: ComboboxContentProps): import("react").JSX.Element;
|
|
12
|
+
export type ComboboxInputProps = {
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
triggerKey?: string;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function ComboboxInput({ placeholder, triggerKey, loading, className }: ComboboxInputProps): import("react").JSX.Element;
|
|
19
|
+
export type ComboboxListProps = {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
label?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function ComboboxList({ children, className, label }: ComboboxListProps): import("react").JSX.Element;
|
|
25
|
+
export type ComboboxItemProps = {
|
|
26
|
+
value: string;
|
|
27
|
+
onSelect: () => void;
|
|
28
|
+
selected?: boolean;
|
|
29
|
+
children: ReactNode | ((opts: {
|
|
30
|
+
active: boolean;
|
|
31
|
+
selected: boolean;
|
|
32
|
+
}) => ReactNode);
|
|
33
|
+
className?: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function ComboboxItem({ value, onSelect, selected, children, className, }: ComboboxItemProps): import("react").JSX.Element;
|
|
36
|
+
export type ComboboxItemActionsProps = {
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
className?: string;
|
|
39
|
+
};
|
|
40
|
+
export declare function ComboboxItemActions({ children, className }: ComboboxItemActionsProps): import("react").JSX.Element;
|
|
41
|
+
export declare const comboboxPortalProps: Record<string, string>;
|
|
42
|
+
export type ComboboxEmptyProps = {
|
|
43
|
+
children?: ReactNode;
|
|
44
|
+
pending?: boolean;
|
|
45
|
+
pendingText?: ReactNode;
|
|
46
|
+
className?: string;
|
|
47
|
+
};
|
|
48
|
+
export declare function ComboboxEmpty({ children, pending, pendingText, className }: ComboboxEmptyProps): import("react").JSX.Element;
|
|
49
|
+
export type ComboboxCreateProps = {
|
|
50
|
+
query: string;
|
|
51
|
+
onCreate: () => void;
|
|
52
|
+
label: string;
|
|
53
|
+
className?: string;
|
|
54
|
+
};
|
|
55
|
+
export declare function ComboboxCreate({ query, onCreate, label, className }: ComboboxCreateProps): import("react").JSX.Element;
|
|
56
|
+
export type ComboboxActionProps = {
|
|
57
|
+
value: string;
|
|
58
|
+
onSelect: () => void;
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
className?: string;
|
|
61
|
+
};
|
|
62
|
+
export declare function ComboboxAction({ value, onSelect, children, className, }: ComboboxActionProps): import("react").JSX.Element;
|
|
63
|
+
export type ComboboxGroupProps = {
|
|
64
|
+
label?: string;
|
|
65
|
+
children: ReactNode;
|
|
66
|
+
className?: string;
|
|
67
|
+
};
|
|
68
|
+
export declare function ComboboxGroup({ label, children, className }: ComboboxGroupProps): import("react").JSX.Element;
|