@ctrl-ui/react 0.8.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 +70 -0
- package/dist/action-bar.d.ts +44 -0
- package/dist/action-bar.js +89 -0
- package/dist/activity.d.ts +53 -0
- package/dist/activity.js +188 -0
- package/dist/audio-recorder.d.ts +32 -0
- package/dist/audio-recorder.js +235 -0
- package/dist/audio-visualizer.d.ts +12 -0
- package/dist/audio-visualizer.js +58 -0
- package/dist/blocks/chat.d.ts +10 -0
- package/dist/blocks/chat.js +12 -0
- package/dist/blocks/coding-agent.d.ts +61 -0
- package/dist/blocks/coding-agent.js +255 -0
- package/dist/blocks/file-explorer-data.d.ts +57 -0
- package/dist/blocks/file-explorer-data.js +74 -0
- package/dist/blocks/file-explorer.d.ts +24 -0
- package/dist/blocks/file-explorer.js +427 -0
- package/dist/blocks/settings-data.d.ts +36 -0
- package/dist/blocks/settings-data.js +66 -0
- package/dist/blocks/settings.d.ts +19 -0
- package/dist/blocks/settings.js +282 -0
- package/dist/blocks/theme-toggle.d.ts +43 -0
- package/dist/blocks/theme-toggle.js +180 -0
- package/dist/chat-composer-attachment.d.ts +55 -0
- package/dist/chat-composer-attachment.js +267 -0
- package/dist/chat-composer-editor/extensions/mention.d.ts +14 -0
- package/dist/chat-composer-editor/extensions/mention.js +278 -0
- package/dist/chat-composer-editor/ghost.d.ts +5 -0
- package/dist/chat-composer-editor/ghost.js +55 -0
- package/dist/chat-composer-editor/schema.d.ts +6 -0
- package/dist/chat-composer-editor/schema.js +25 -0
- package/dist/chat-composer-editor/serialize.d.ts +6 -0
- package/dist/chat-composer-editor/serialize.js +16 -0
- package/dist/chat-composer-editor/types.d.ts +29 -0
- package/dist/chat-composer-editor/types.js +0 -0
- package/dist/chat-composer-editor.d.ts +9 -0
- package/dist/chat-composer-editor.js +154 -0
- package/dist/chat-composer.d.ts +60 -0
- package/dist/chat-composer.js +134 -0
- package/dist/chat-layout.d.ts +27 -0
- package/dist/chat-layout.js +114 -0
- package/dist/chat-message.d.ts +31 -0
- package/dist/chat-message.js +95 -0
- package/dist/code-block-editor.d.ts +59 -0
- package/dist/code-block-editor.js +250 -0
- package/dist/context-model.d.ts +33 -0
- package/dist/context-model.js +52 -0
- package/dist/context.d.ts +47 -0
- package/dist/context.js +335 -0
- package/dist/control-props.d.ts +28 -0
- package/dist/control-props.js +4 -0
- package/dist/control-variants.d.ts +8 -0
- package/dist/control-variants.js +14 -0
- package/dist/dynamic-notification-glass.d.ts +10 -0
- package/dist/dynamic-notification-glass.js +311 -0
- package/dist/dynamic-notification-liquid.d.ts +24 -0
- package/dist/dynamic-notification-liquid.js +682 -0
- package/dist/dynamic-notification-siri-wave.d.ts +4 -0
- package/dist/dynamic-notification-siri-wave.js +82 -0
- package/dist/dynamic-notification.d.ts +74 -0
- package/dist/dynamic-notification.js +342 -0
- package/dist/environment-variables.d.ts +124 -0
- package/dist/environment-variables.js +492 -0
- package/dist/extensions/create-track-highlight.d.ts +12 -0
- package/dist/extensions/create-track-highlight.js +147 -0
- package/dist/extensions/track-highlight.d.ts +22 -0
- package/dist/extensions/track-highlight.js +52 -0
- package/dist/hooks/use-audio-recorder.d.ts +107 -0
- package/dist/hooks/use-audio-recorder.js +577 -0
- package/dist/hooks/use-chat-composer.d.ts +56 -0
- package/dist/hooks/use-chat-composer.js +63 -0
- package/dist/hooks/use-chat-message.d.ts +28 -0
- package/dist/hooks/use-chat-message.js +24 -0
- package/dist/hooks/use-color-area.d.ts +18 -0
- package/dist/hooks/use-color-area.js +60 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +22 -0
- package/dist/hooks/use-copy-to-clipboard.js +90 -0
- package/dist/hooks/use-dropzone.d.ts +59 -0
- package/dist/hooks/use-dropzone.js +372 -0
- package/dist/hooks/use-dynamic-notification.d.ts +37 -0
- package/dist/hooks/use-dynamic-notification.js +87 -0
- package/dist/hooks/use-environment-variables.d.ts +51 -0
- package/dist/hooks/use-environment-variables.js +188 -0
- package/dist/hooks/use-mobile.d.ts +5 -0
- package/dist/hooks/use-mobile.js +29 -0
- package/dist/hooks/use-textarea-trigger-menu.d.ts +8 -0
- package/dist/hooks/use-textarea-trigger-menu.js +69 -0
- package/dist/hooks/use-trigger-menu.d.ts +49 -0
- package/dist/hooks/use-trigger-menu.js +102 -0
- package/dist/hooks/use-user-ask.d.ts +48 -0
- package/dist/hooks/use-user-ask.js +167 -0
- package/dist/inline-attachment.d.ts +37 -0
- package/dist/inline-attachment.js +192 -0
- package/dist/inline-citation.d.ts +56 -0
- package/dist/inline-citation.js +319 -0
- package/dist/knob-contracts/accordion-knobs.d.ts +5 -0
- package/dist/knob-contracts/accordion-knobs.js +9 -0
- package/dist/knob-contracts/action-bar-knobs.d.ts +5 -0
- package/dist/knob-contracts/action-bar-knobs.js +4 -0
- package/dist/knob-contracts/activity-knobs.d.ts +5 -0
- package/dist/knob-contracts/activity-knobs.js +9 -0
- package/dist/knob-contracts/alert-knobs.d.ts +5 -0
- package/dist/knob-contracts/alert-knobs.js +9 -0
- package/dist/knob-contracts/audio-recorder-knobs.d.ts +5 -0
- package/dist/knob-contracts/audio-recorder-knobs.js +9 -0
- package/dist/knob-contracts/audio-visualizer-knobs.d.ts +5 -0
- package/dist/knob-contracts/audio-visualizer-knobs.js +9 -0
- package/dist/knob-contracts/avatar-knobs.d.ts +5 -0
- package/dist/knob-contracts/avatar-knobs.js +9 -0
- package/dist/knob-contracts/badge-knobs.d.ts +5 -0
- package/dist/knob-contracts/badge-knobs.js +9 -0
- package/dist/knob-contracts/button-group-knobs.d.ts +5 -0
- package/dist/knob-contracts/button-group-knobs.js +9 -0
- package/dist/knob-contracts/button-knobs.d.ts +5 -0
- package/dist/knob-contracts/button-knobs.js +25 -0
- package/dist/knob-contracts/calendar-knobs.d.ts +5 -0
- package/dist/knob-contracts/calendar-knobs.js +10 -0
- package/dist/knob-contracts/card-knobs.d.ts +5 -0
- package/dist/knob-contracts/card-knobs.js +11 -0
- package/dist/knob-contracts/chat-composer-attachment-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-composer-attachment-knobs.js +11 -0
- package/dist/knob-contracts/chat-composer-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-composer-knobs.js +18 -0
- package/dist/knob-contracts/chat-layout-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-layout-knobs.js +11 -0
- package/dist/knob-contracts/chat-message-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-message-knobs.js +17 -0
- package/dist/knob-contracts/choice-knobs.d.ts +5 -0
- package/dist/knob-contracts/choice-knobs.js +9 -0
- package/dist/knob-contracts/code-block-editor-knobs.d.ts +5 -0
- package/dist/knob-contracts/code-block-editor-knobs.js +11 -0
- package/dist/knob-contracts/code-diff-knobs.d.ts +5 -0
- package/dist/knob-contracts/code-diff-knobs.js +18 -0
- package/dist/knob-contracts/code-knobs.d.ts +5 -0
- package/dist/knob-contracts/code-knobs.js +11 -0
- package/dist/knob-contracts/collapsible-knobs.d.ts +5 -0
- package/dist/knob-contracts/collapsible-knobs.js +4 -0
- package/dist/knob-contracts/color-picker-knobs.d.ts +5 -0
- package/dist/knob-contracts/color-picker-knobs.js +12 -0
- package/dist/knob-contracts/context-knobs.d.ts +5 -0
- package/dist/knob-contracts/context-knobs.js +13 -0
- package/dist/knob-contracts/dockable-panel-knobs.d.ts +5 -0
- package/dist/knob-contracts/dockable-panel-knobs.js +12 -0
- package/dist/knob-contracts/dropzone-knobs.d.ts +5 -0
- package/dist/knob-contracts/dropzone-knobs.js +11 -0
- package/dist/knob-contracts/dynamic-notification-knobs.d.ts +5 -0
- package/dist/knob-contracts/dynamic-notification-knobs.js +18 -0
- package/dist/knob-contracts/empty-knobs.d.ts +5 -0
- package/dist/knob-contracts/empty-knobs.js +12 -0
- package/dist/knob-contracts/environment-variables-knobs.d.ts +5 -0
- package/dist/knob-contracts/environment-variables-knobs.js +11 -0
- package/dist/knob-contracts/field-knobs.d.ts +5 -0
- package/dist/knob-contracts/field-knobs.js +16 -0
- package/dist/knob-contracts/gradient-editor-knobs.d.ts +5 -0
- package/dist/knob-contracts/gradient-editor-knobs.js +13 -0
- package/dist/knob-contracts/infinite-canvas-knobs.d.ts +5 -0
- package/dist/knob-contracts/infinite-canvas-knobs.js +13 -0
- package/dist/knob-contracts/inline-attachment-knobs.d.ts +5 -0
- package/dist/knob-contracts/inline-attachment-knobs.js +14 -0
- package/dist/knob-contracts/inline-citation-knobs.d.ts +5 -0
- package/dist/knob-contracts/inline-citation-knobs.js +14 -0
- package/dist/knob-contracts/item-knobs.d.ts +5 -0
- package/dist/knob-contracts/item-knobs.js +10 -0
- package/dist/knob-contracts/kbd-knobs.d.ts +5 -0
- package/dist/knob-contracts/kbd-knobs.js +10 -0
- package/dist/knob-contracts/markdown-block-knobs.d.ts +5 -0
- package/dist/knob-contracts/markdown-block-knobs.js +11 -0
- package/dist/knob-contracts/markdown-knobs.d.ts +5 -0
- package/dist/knob-contracts/markdown-knobs.js +14 -0
- package/dist/knob-contracts/morphing-panel-knobs.d.ts +5 -0
- package/dist/knob-contracts/morphing-panel-knobs.js +11 -0
- package/dist/knob-contracts/pagination-knobs.d.ts +5 -0
- package/dist/knob-contracts/pagination-knobs.js +10 -0
- package/dist/knob-contracts/phone-input-knobs.d.ts +5 -0
- package/dist/knob-contracts/phone-input-knobs.js +10 -0
- package/dist/knob-contracts/popup-knobs.d.ts +5 -0
- package/dist/knob-contracts/popup-knobs.js +21 -0
- package/dist/knob-contracts/range-knobs.d.ts +5 -0
- package/dist/knob-contracts/range-knobs.js +13 -0
- package/dist/knob-contracts/resizable-knobs.d.ts +5 -0
- package/dist/knob-contracts/resizable-knobs.js +14 -0
- package/dist/knob-contracts/rich-tooltip-knobs.d.ts +5 -0
- package/dist/knob-contracts/rich-tooltip-knobs.js +13 -0
- package/dist/knob-contracts/scroll-area-knobs.d.ts +5 -0
- package/dist/knob-contracts/scroll-area-knobs.js +8 -0
- package/dist/knob-contracts/separator-knobs.d.ts +5 -0
- package/dist/knob-contracts/separator-knobs.js +4 -0
- package/dist/knob-contracts/sidebar-knobs.d.ts +5 -0
- package/dist/knob-contracts/sidebar-knobs.js +26 -0
- package/dist/knob-contracts/skeleton-knobs.d.ts +5 -0
- package/dist/knob-contracts/skeleton-knobs.js +4 -0
- package/dist/knob-contracts/source-badge-knobs.d.ts +5 -0
- package/dist/knob-contracts/source-badge-knobs.js +11 -0
- package/dist/knob-contracts/spinner-knobs.d.ts +5 -0
- package/dist/knob-contracts/spinner-knobs.js +4 -0
- package/dist/knob-contracts/stepper-knobs.d.ts +5 -0
- package/dist/knob-contracts/stepper-knobs.js +11 -0
- package/dist/knob-contracts/switch-knobs.d.ts +5 -0
- package/dist/knob-contracts/switch-knobs.js +12 -0
- package/dist/knob-contracts/table-knobs.d.ts +5 -0
- package/dist/knob-contracts/table-knobs.js +12 -0
- package/dist/knob-contracts/table-of-contents-knobs.d.ts +5 -0
- package/dist/knob-contracts/table-of-contents-knobs.js +8 -0
- package/dist/knob-contracts/tabs-knobs.d.ts +5 -0
- package/dist/knob-contracts/tabs-knobs.js +16 -0
- package/dist/knob-contracts/task-list-knobs.d.ts +5 -0
- package/dist/knob-contracts/task-list-knobs.js +14 -0
- package/dist/knob-contracts/thread-rail-knobs.d.ts +5 -0
- package/dist/knob-contracts/thread-rail-knobs.js +14 -0
- package/dist/knob-contracts/timeline-knobs.d.ts +5 -0
- package/dist/knob-contracts/timeline-knobs.js +12 -0
- package/dist/knob-contracts/toolbar-knobs.d.ts +5 -0
- package/dist/knob-contracts/toolbar-knobs.js +20 -0
- package/dist/knob-contracts/track-highlight-knobs.d.ts +5 -0
- package/dist/knob-contracts/track-highlight-knobs.js +11 -0
- package/dist/knob-contracts/transcript-divider-knobs.d.ts +5 -0
- package/dist/knob-contracts/transcript-divider-knobs.js +10 -0
- package/dist/knob-contracts/tree-knobs.d.ts +5 -0
- package/dist/knob-contracts/tree-knobs.js +13 -0
- package/dist/knob-contracts/user-ask-knobs.d.ts +5 -0
- package/dist/knob-contracts/user-ask-knobs.js +17 -0
- package/dist/lib/cn.d.ts +5 -0
- package/dist/lib/cn.js +34 -0
- package/dist/lib/code-block-shiki.d.ts +9 -0
- package/dist/lib/code-block-shiki.js +6 -0
- package/dist/lib/code-tokens.d.ts +28 -0
- package/dist/lib/code-tokens.js +160 -0
- package/dist/lib/color.d.ts +72 -0
- package/dist/lib/color.js +490 -0
- package/dist/lib/contrast.d.ts +30 -0
- package/dist/lib/contrast.js +64 -0
- package/dist/lib/diff.d.ts +50 -0
- package/dist/lib/diff.js +315 -0
- package/dist/lib/dropzone-validation.d.ts +66 -0
- package/dist/lib/dropzone-validation.js +228 -0
- package/dist/lib/env-file.d.ts +28 -0
- package/dist/lib/env-file.js +218 -0
- package/dist/lib/format-audio-recorder-duration.d.ts +4 -0
- package/dist/lib/format-audio-recorder-duration.js +7 -0
- package/dist/lib/liquid-glass-optics.d.ts +4 -0
- package/dist/lib/liquid-glass-optics.js +96 -0
- package/dist/lib/phone-input-format.d.ts +6 -0
- package/dist/lib/phone-input-format.js +26 -0
- package/dist/lib/phone-number.d.ts +18 -0
- package/dist/lib/phone-number.js +28 -0
- package/dist/lib/trigger-detect.d.ts +15 -0
- package/dist/lib/trigger-detect.js +77 -0
- package/dist/markdown-block.d.ts +25 -0
- package/dist/markdown-block.js +77 -0
- package/dist/skin.config.d.ts +5 -0
- package/dist/skin.config.js +4 -0
- package/dist/skin.d.ts +69 -0
- package/dist/skin.js +62 -0
- package/dist/source-badge.d.ts +23 -0
- package/dist/source-badge.js +72 -0
- package/dist/styles/chat-composer-editor.css +44 -0
- package/dist/styles/code.css +57 -0
- package/dist/styles/effects.css +126 -0
- package/dist/styles/index.css +81 -0
- package/dist/styles/recipes/accordion.css +87 -0
- package/dist/styles/recipes/action-bar.css +19 -0
- package/dist/styles/recipes/activity.css +129 -0
- package/dist/styles/recipes/alert.css +75 -0
- package/dist/styles/recipes/audio-recorder.css +102 -0
- package/dist/styles/recipes/audio-visualizer.css +90 -0
- package/dist/styles/recipes/avatar.css +52 -0
- package/dist/styles/recipes/badge.css +110 -0
- package/dist/styles/recipes/button-group.css +64 -0
- package/dist/styles/recipes/button.css +305 -0
- package/dist/styles/recipes/calendar.css +152 -0
- package/dist/styles/recipes/card.css +93 -0
- package/dist/styles/recipes/chat-composer-attachment.css +177 -0
- package/dist/styles/recipes/chat-composer.css +195 -0
- package/dist/styles/recipes/chat-layout.css +108 -0
- package/dist/styles/recipes/chat-message.css +160 -0
- package/dist/styles/recipes/choice.css +108 -0
- package/dist/styles/recipes/code-block-editor.css +136 -0
- package/dist/styles/recipes/code-diff.css +256 -0
- package/dist/styles/recipes/code.css +136 -0
- package/dist/styles/recipes/collapsible.css +27 -0
- package/dist/styles/recipes/color-picker-details.css +61 -0
- package/dist/styles/recipes/color-picker-values.css +117 -0
- package/dist/styles/recipes/color-picker.css +158 -0
- package/dist/styles/recipes/context.css +237 -0
- package/dist/styles/recipes/dockable-panel.css +106 -0
- package/dist/styles/recipes/dropzone.css +149 -0
- package/dist/styles/recipes/dynamic-notification-input.css +29 -0
- package/dist/styles/recipes/dynamic-notification-motion.css +298 -0
- package/dist/styles/recipes/dynamic-notification.css +241 -0
- package/dist/styles/recipes/empty.css +96 -0
- package/dist/styles/recipes/environment-variables.css +173 -0
- package/dist/styles/recipes/field-parts.css +148 -0
- package/dist/styles/recipes/field.css +234 -0
- package/dist/styles/recipes/gradient-editor.css +109 -0
- package/dist/styles/recipes/infinite-canvas.css +78 -0
- package/dist/styles/recipes/inline-attachment.css +182 -0
- package/dist/styles/recipes/inline-citation.css +174 -0
- package/dist/styles/recipes/item.css +107 -0
- package/dist/styles/recipes/kbd.css +55 -0
- package/dist/styles/recipes/markdown-block.css +75 -0
- package/dist/styles/recipes/markdown.css +204 -0
- package/dist/styles/recipes/morphing-panel.css +123 -0
- package/dist/styles/recipes/pagination.css +86 -0
- package/dist/styles/recipes/phone-input.css +105 -0
- package/dist/styles/recipes/popup-controls.css +59 -0
- package/dist/styles/recipes/popup-drawer.css +162 -0
- package/dist/styles/recipes/popup-lists.css +198 -0
- package/dist/styles/recipes/popup-motion.css +94 -0
- package/dist/styles/recipes/popup-toast.css +126 -0
- package/dist/styles/recipes/popup.css +396 -0
- package/dist/styles/recipes/range.css +259 -0
- package/dist/styles/recipes/resizable.css +170 -0
- package/dist/styles/recipes/rich-tooltip.css +272 -0
- package/dist/styles/recipes/scroll-area.css +59 -0
- package/dist/styles/recipes/separator.css +12 -0
- package/dist/styles/recipes/sidebar.css +345 -0
- package/dist/styles/recipes/skeleton.css +23 -0
- package/dist/styles/recipes/source-badge.css +77 -0
- package/dist/styles/recipes/spinner.css +33 -0
- package/dist/styles/recipes/stepper.css +178 -0
- package/dist/styles/recipes/switch.css +149 -0
- package/dist/styles/recipes/table-of-contents.css +107 -0
- package/dist/styles/recipes/table.css +124 -0
- package/dist/styles/recipes/tabs.css +235 -0
- package/dist/styles/recipes/task-list.css +146 -0
- package/dist/styles/recipes/thread-rail.css +247 -0
- package/dist/styles/recipes/timeline.css +107 -0
- package/dist/styles/recipes/toolbar.css +260 -0
- package/dist/styles/recipes/track-highlight.css +73 -0
- package/dist/styles/recipes/transcript-divider.css +64 -0
- package/dist/styles/recipes/tree.css +137 -0
- package/dist/styles/recipes/user-ask-details.css +45 -0
- package/dist/styles/recipes/user-ask.css +204 -0
- package/dist/styles/skin-theme.css +137 -0
- package/dist/styles/skin.css +143 -0
- package/dist/styles/theme.css +628 -0
- package/dist/styles/type-scale.css +45 -0
- package/dist/surface-variants.d.ts +6 -0
- package/dist/surface-variants.js +16 -0
- package/dist/task-list.d.ts +34 -0
- package/dist/task-list.js +177 -0
- package/dist/thread-rail.d.ts +52 -0
- package/dist/thread-rail.js +190 -0
- package/dist/transcript-divider.d.ts +15 -0
- package/dist/transcript-divider.js +25 -0
- package/dist/ui/accordion.d.ts +31 -0
- package/dist/ui/accordion.js +60 -0
- package/dist/ui/alert-dialog.d.ts +36 -0
- package/dist/ui/alert-dialog.js +100 -0
- package/dist/ui/alert.d.ts +21 -0
- package/dist/ui/alert.js +36 -0
- package/dist/ui/aspect-ratio.d.ts +8 -0
- package/dist/ui/aspect-ratio.js +17 -0
- package/dist/ui/autocomplete.d.ts +70 -0
- package/dist/ui/autocomplete.js +150 -0
- package/dist/ui/avatar.d.ts +24 -0
- package/dist/ui/avatar.js +44 -0
- package/dist/ui/badge.d.ts +20 -0
- package/dist/ui/badge.js +36 -0
- package/dist/ui/button-group.d.ts +24 -0
- package/dist/ui/button-group.js +45 -0
- package/dist/ui/button.d.ts +36 -0
- package/dist/ui/button.js +104 -0
- package/dist/ui/calendar.d.ts +11 -0
- package/dist/ui/calendar.js +160 -0
- package/dist/ui/card.d.ts +36 -0
- package/dist/ui/card.js +70 -0
- package/dist/ui/checkbox-group.d.ts +11 -0
- package/dist/ui/checkbox-group.js +16 -0
- package/dist/ui/checkbox.d.ts +23 -0
- package/dist/ui/checkbox.js +58 -0
- package/dist/ui/code-diff.d.ts +28 -0
- package/dist/ui/code-diff.js +561 -0
- package/dist/ui/code.d.ts +62 -0
- package/dist/ui/code.js +292 -0
- package/dist/ui/collapsible.d.ts +31 -0
- package/dist/ui/collapsible.js +72 -0
- package/dist/ui/color-picker.d.ts +137 -0
- package/dist/ui/color-picker.js +797 -0
- package/dist/ui/combobox-disabled-selection.d.ts +5 -0
- package/dist/ui/combobox-disabled-selection.js +11 -0
- package/dist/ui/combobox.d.ts +70 -0
- package/dist/ui/combobox.js +194 -0
- package/dist/ui/command.d.ts +44 -0
- package/dist/ui/command.js +166 -0
- package/dist/ui/context-menu.d.ts +86 -0
- package/dist/ui/context-menu.js +202 -0
- package/dist/ui/dialog.d.ts +38 -0
- package/dist/ui/dialog.js +124 -0
- package/dist/ui/dockable-panel-geometry.d.ts +18 -0
- package/dist/ui/dockable-panel-geometry.js +17 -0
- package/dist/ui/dockable-panel.d.ts +58 -0
- package/dist/ui/dockable-panel.js +366 -0
- package/dist/ui/drawer.d.ts +42 -0
- package/dist/ui/drawer.js +182 -0
- package/dist/ui/dropdown-menu.d.ts +46 -0
- package/dist/ui/dropdown-menu.js +89 -0
- package/dist/ui/dropzone.d.ts +66 -0
- package/dist/ui/dropzone.js +311 -0
- package/dist/ui/empty.d.ts +28 -0
- package/dist/ui/empty.js +59 -0
- package/dist/ui/field.d.ts +64 -0
- package/dist/ui/field.js +166 -0
- package/dist/ui/form.d.ts +10 -0
- package/dist/ui/form.js +17 -0
- package/dist/ui/gradient-editor.d.ts +47 -0
- package/dist/ui/gradient-editor.js +301 -0
- package/dist/ui/hover-card.d.ts +25 -0
- package/dist/ui/hover-card.js +46 -0
- package/dist/ui/infinite-canvas.d.ts +40 -0
- package/dist/ui/infinite-canvas.js +278 -0
- package/dist/ui/input-group.d.ts +21 -0
- package/dist/ui/input-group.js +44 -0
- package/dist/ui/input-otp.d.ts +38 -0
- package/dist/ui/input-otp.js +45 -0
- package/dist/ui/input.d.ts +12 -0
- package/dist/ui/input.js +18 -0
- package/dist/ui/item.d.ts +46 -0
- package/dist/ui/item.js +110 -0
- package/dist/ui/kbd.d.ts +12 -0
- package/dist/ui/kbd.js +23 -0
- package/dist/ui/markdown-elements.d.ts +52 -0
- package/dist/ui/markdown-elements.js +211 -0
- package/dist/ui/markdown.d.ts +14 -0
- package/dist/ui/markdown.js +31 -0
- package/dist/ui/menubar.d.ts +74 -0
- package/dist/ui/menubar.js +162 -0
- package/dist/ui/meter.d.ts +34 -0
- package/dist/ui/meter.js +57 -0
- package/dist/ui/morphing-panel.d.ts +24 -0
- package/dist/ui/morphing-panel.js +87 -0
- package/dist/ui/native-select.d.ts +12 -0
- package/dist/ui/native-select.js +41 -0
- package/dist/ui/navigation-menu.d.ts +51 -0
- package/dist/ui/navigation-menu.js +135 -0
- package/dist/ui/number-field.d.ts +72 -0
- package/dist/ui/number-field.js +124 -0
- package/dist/ui/pagination.d.ts +26 -0
- package/dist/ui/pagination.js +77 -0
- package/dist/ui/phone-input.d.ts +30 -0
- package/dist/ui/phone-input.js +263 -0
- package/dist/ui/popover.d.ts +34 -0
- package/dist/ui/popover.js +87 -0
- package/dist/ui/progress.d.ts +34 -0
- package/dist/ui/progress.js +57 -0
- package/dist/ui/radio-group.d.ts +29 -0
- package/dist/ui/radio-group.js +37 -0
- package/dist/ui/resizable.d.ts +56 -0
- package/dist/ui/resizable.js +82 -0
- package/dist/ui/responsive-dialog.d.ts +18 -0
- package/dist/ui/responsive-dialog.js +121 -0
- package/dist/ui/rich-tooltip-tour.d.ts +12 -0
- package/dist/ui/rich-tooltip-tour.js +20 -0
- package/dist/ui/rich-tooltip.d.ts +83 -0
- package/dist/ui/rich-tooltip.js +331 -0
- package/dist/ui/scroll-area.d.ts +25 -0
- package/dist/ui/scroll-area.js +93 -0
- package/dist/ui/select.d.ts +44 -0
- package/dist/ui/select.js +124 -0
- package/dist/ui/separator.d.ts +9 -0
- package/dist/ui/separator.js +16 -0
- package/dist/ui/sheet.d.ts +25 -0
- package/dist/ui/sheet.js +76 -0
- package/dist/ui/sidebar.d.ts +88 -0
- package/dist/ui/sidebar.js +362 -0
- package/dist/ui/skeleton.d.ts +8 -0
- package/dist/ui/skeleton.js +13 -0
- package/dist/ui/slider.d.ts +24 -0
- package/dist/ui/slider.js +114 -0
- package/dist/ui/spinner.d.ts +12 -0
- package/dist/ui/spinner.js +26 -0
- package/dist/ui/stepper.d.ts +58 -0
- package/dist/ui/stepper.js +232 -0
- package/dist/ui/switch.d.ts +26 -0
- package/dist/ui/switch.js +71 -0
- package/dist/ui/table-of-contents.d.ts +22 -0
- package/dist/ui/table-of-contents.js +181 -0
- package/dist/ui/table.d.ts +37 -0
- package/dist/ui/table.js +83 -0
- package/dist/ui/tabs.d.ts +36 -0
- package/dist/ui/tabs.js +127 -0
- package/dist/ui/textarea.d.ts +9 -0
- package/dist/ui/textarea.js +16 -0
- package/dist/ui/timeline.d.ts +40 -0
- package/dist/ui/timeline.js +80 -0
- package/dist/ui/toast.d.ts +28 -0
- package/dist/ui/toast.js +132 -0
- package/dist/ui/toggle.d.ts +20 -0
- package/dist/ui/toggle.js +71 -0
- package/dist/ui/toolbar.d.ts +40 -0
- package/dist/ui/toolbar.js +72 -0
- package/dist/ui/tooltip.d.ts +27 -0
- package/dist/ui/tooltip.js +93 -0
- package/dist/ui/tree.d.ts +56 -0
- package/dist/ui/tree.js +438 -0
- package/dist/ui/trigger-menu.d.ts +46 -0
- package/dist/ui/trigger-menu.js +116 -0
- package/dist/user-ask.d.ts +50 -0
- package/dist/user-ask.js +398 -0
- package/package.json +115 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { createContext, useContext, useId, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { CheckIcon, CircleAlertIcon } from "lucide-react";
|
|
6
|
+
//#region src/ui/stepper.tsx
|
|
7
|
+
const StepperContext = createContext(null);
|
|
8
|
+
function useStepper() {
|
|
9
|
+
const context = useContext(StepperContext);
|
|
10
|
+
if (!context) throw new Error("Stepper parts must be used within <Stepper>.");
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
13
|
+
const StepperItemContext = createContext(null);
|
|
14
|
+
function useStepperItem() {
|
|
15
|
+
const context = useContext(StepperItemContext);
|
|
16
|
+
if (!context) throw new Error("Stepper item parts must be used within <StepperItem>.");
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
function stateForStep(value, step) {
|
|
20
|
+
if (value === null) return "neutral";
|
|
21
|
+
if (step < value) return "complete";
|
|
22
|
+
if (step === value) return "current";
|
|
23
|
+
return "upcoming";
|
|
24
|
+
}
|
|
25
|
+
function indicatorStateLabel(state, invalid) {
|
|
26
|
+
if (invalid) return "invalid";
|
|
27
|
+
if (state === "neutral") return null;
|
|
28
|
+
return state;
|
|
29
|
+
}
|
|
30
|
+
function defaultIndicatorContent(step, state, invalid) {
|
|
31
|
+
if (invalid) return /* @__PURE__ */ jsx(CircleAlertIcon, { className: "size-4" });
|
|
32
|
+
if (state === "complete") return /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" });
|
|
33
|
+
return step + 1;
|
|
34
|
+
}
|
|
35
|
+
function itemLayout(orientation, responsive) {
|
|
36
|
+
if (orientation === "vertical") return "grid min-w-0 grid-cols-[2rem_minmax(0,1fr)]";
|
|
37
|
+
return cn("relative grid min-w-0 flex-1 grid-cols-1 justify-items-center", responsive && "@max-md/stepper:w-full @max-md/stepper:flex-none @max-md/stepper:grid-cols-[2rem_minmax(0,1fr)] @max-md/stepper:justify-items-stretch");
|
|
38
|
+
}
|
|
39
|
+
function partLayout(orientation, responsive, part) {
|
|
40
|
+
const vertical = {
|
|
41
|
+
indicator: "col-start-1 row-span-2 row-start-1",
|
|
42
|
+
title: "col-start-2 row-start-1",
|
|
43
|
+
description: "col-start-2 row-start-2"
|
|
44
|
+
}[part];
|
|
45
|
+
if (orientation === "vertical") return vertical;
|
|
46
|
+
const horizontal = {
|
|
47
|
+
indicator: "col-start-1 row-start-1",
|
|
48
|
+
title: "col-start-1 row-start-2",
|
|
49
|
+
description: "col-start-1 row-start-3"
|
|
50
|
+
}[part];
|
|
51
|
+
if (!responsive) return horizontal;
|
|
52
|
+
const narrow = {
|
|
53
|
+
indicator: "@max-md/stepper:col-start-1 @max-md/stepper:row-span-2 @max-md/stepper:row-start-1",
|
|
54
|
+
title: "@max-md/stepper:col-start-2 @max-md/stepper:row-start-1",
|
|
55
|
+
description: "@max-md/stepper:col-start-2 @max-md/stepper:row-start-2"
|
|
56
|
+
}[part];
|
|
57
|
+
return cn(horizontal, narrow);
|
|
58
|
+
}
|
|
59
|
+
function Stepper({ value, defaultValue = null, onValueChange, orientation = "horizontal", contentMode = "current", responsive = true, id, className, children, ...props }) {
|
|
60
|
+
const generatedId = useId();
|
|
61
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
62
|
+
const controlled = value !== void 0;
|
|
63
|
+
const currentValue = value !== void 0 ? value : internalValue;
|
|
64
|
+
const selectStep = (step) => {
|
|
65
|
+
if (!controlled) setInternalValue(step);
|
|
66
|
+
onValueChange?.(step);
|
|
67
|
+
};
|
|
68
|
+
return /* @__PURE__ */ jsx(StepperContext.Provider, {
|
|
69
|
+
value: {
|
|
70
|
+
value: currentValue,
|
|
71
|
+
orientation,
|
|
72
|
+
contentMode,
|
|
73
|
+
responsive,
|
|
74
|
+
baseId: id ?? generatedId,
|
|
75
|
+
selectStep
|
|
76
|
+
},
|
|
77
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
78
|
+
...props,
|
|
79
|
+
id,
|
|
80
|
+
"data-control-ui": "stepper",
|
|
81
|
+
"data-control-family": "stepper",
|
|
82
|
+
"data-slot": "root",
|
|
83
|
+
"data-orientation": orientation,
|
|
84
|
+
"data-content-mode": contentMode,
|
|
85
|
+
"data-responsive": responsive ? "true" : void 0,
|
|
86
|
+
className: cn(responsive && "@container/stepper", "w-full", className),
|
|
87
|
+
children
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function StepperList({ className, ...props }) {
|
|
92
|
+
const { orientation, responsive } = useStepper();
|
|
93
|
+
return /* @__PURE__ */ jsx("ol", {
|
|
94
|
+
...props,
|
|
95
|
+
"data-control-ui": "stepper",
|
|
96
|
+
"data-control-family": "stepper",
|
|
97
|
+
"data-slot": "list",
|
|
98
|
+
"data-orientation": orientation,
|
|
99
|
+
className: cn(orientation === "horizontal" ? "flex w-full items-start" : "flex w-full flex-col", orientation === "horizontal" && responsive && "@max-md/stepper:flex-col @max-md/stepper:items-stretch", className)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function StepperItem({ step, disabled = false, invalid = false, className, children, ...props }) {
|
|
103
|
+
const { value, orientation, responsive, baseId } = useStepper();
|
|
104
|
+
const state = stateForStep(value, step);
|
|
105
|
+
const contextValue = {
|
|
106
|
+
step,
|
|
107
|
+
state,
|
|
108
|
+
disabled,
|
|
109
|
+
invalid,
|
|
110
|
+
titleId: `${baseId}-step-${step}-title`,
|
|
111
|
+
contentId: `${baseId}-step-${step}-content`
|
|
112
|
+
};
|
|
113
|
+
return /* @__PURE__ */ jsx(StepperItemContext.Provider, {
|
|
114
|
+
value: contextValue,
|
|
115
|
+
children: /* @__PURE__ */ jsx("li", {
|
|
116
|
+
...props,
|
|
117
|
+
"data-control-ui": "stepper",
|
|
118
|
+
"data-control-family": "stepper",
|
|
119
|
+
"data-slot": "item",
|
|
120
|
+
"data-step": step,
|
|
121
|
+
"data-state": state,
|
|
122
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
123
|
+
"data-invalid": invalid ? "true" : void 0,
|
|
124
|
+
"aria-current": state === "current" ? "step" : void 0,
|
|
125
|
+
className: cn("relative", itemLayout(orientation, responsive), className),
|
|
126
|
+
children
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function StepperTrigger({ disabled: disabledProp, className, onClick, type = "button", ...props }) {
|
|
131
|
+
const { orientation, responsive, selectStep } = useStepper();
|
|
132
|
+
const { step, state, disabled, invalid, contentId } = useStepperItem();
|
|
133
|
+
const isDisabled = disabled || Boolean(disabledProp);
|
|
134
|
+
return /* @__PURE__ */ jsx("button", {
|
|
135
|
+
...props,
|
|
136
|
+
"data-control-ui": "stepper",
|
|
137
|
+
"data-control-family": "stepper",
|
|
138
|
+
"data-slot": "trigger",
|
|
139
|
+
"data-state": state,
|
|
140
|
+
"data-invalid": invalid ? "true" : void 0,
|
|
141
|
+
type,
|
|
142
|
+
disabled: isDisabled,
|
|
143
|
+
"aria-controls": contentId,
|
|
144
|
+
className: cn("group/stepper-trigger col-span-full row-span-3 row-start-1 grid w-full min-w-0 grid-cols-1 justify-items-center disabled:pointer-events-none disabled:cursor-not-allowed", orientation === "vertical" && "row-span-2 grid-cols-[2rem_minmax(0,1fr)] justify-items-stretch", orientation === "horizontal" && responsive && "@max-md/stepper:row-span-2 @max-md/stepper:grid-cols-[2rem_minmax(0,1fr)] @max-md/stepper:justify-items-stretch", className),
|
|
145
|
+
onClick: (event) => {
|
|
146
|
+
onClick?.(event);
|
|
147
|
+
if (!event.defaultPrevented && !isDisabled) selectStep(step);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function StepperIndicator({ className, children, ...props }) {
|
|
152
|
+
const { orientation, responsive } = useStepper();
|
|
153
|
+
const { step, state, disabled, invalid } = useStepperItem();
|
|
154
|
+
const stateLabel = indicatorStateLabel(state, invalid);
|
|
155
|
+
const status = [
|
|
156
|
+
`Step ${step + 1}`,
|
|
157
|
+
stateLabel,
|
|
158
|
+
disabled ? "disabled" : null
|
|
159
|
+
].filter(Boolean).join(", ");
|
|
160
|
+
const indicatorContent = children ?? defaultIndicatorContent(step, state, invalid);
|
|
161
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
162
|
+
...props,
|
|
163
|
+
"data-control-ui": "stepper",
|
|
164
|
+
"data-control-family": "stepper",
|
|
165
|
+
"data-slot": "indicator",
|
|
166
|
+
"data-state": state,
|
|
167
|
+
"data-invalid": invalid ? "true" : void 0,
|
|
168
|
+
className: cn("relative z-10 flex shrink-0 items-center justify-center", partLayout(orientation, responsive, "indicator"), className),
|
|
169
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
170
|
+
"aria-hidden": "true",
|
|
171
|
+
children: indicatorContent
|
|
172
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
173
|
+
className: "sr-only",
|
|
174
|
+
children: status
|
|
175
|
+
})]
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function StepperSeparator({ className, ...props }) {
|
|
179
|
+
const { orientation, responsive } = useStepper();
|
|
180
|
+
const { state, invalid } = useStepperItem();
|
|
181
|
+
return /* @__PURE__ */ jsx("span", {
|
|
182
|
+
...props,
|
|
183
|
+
"data-control-ui": "stepper",
|
|
184
|
+
"data-control-family": "stepper",
|
|
185
|
+
"data-slot": "separator",
|
|
186
|
+
"data-state": state,
|
|
187
|
+
"data-invalid": invalid ? "true" : void 0,
|
|
188
|
+
"aria-hidden": "true",
|
|
189
|
+
className: cn("absolute", orientation === "horizontal" && "top-4 right-[calc(-50%+1rem)] left-[calc(50%+1rem)]", orientation === "vertical" && "top-8 bottom-0 left-4", orientation === "horizontal" && responsive && "@max-md/stepper:top-8 @max-md/stepper:right-auto @max-md/stepper:bottom-0 @max-md/stepper:left-4", className)
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function StepperTitle({ className, ...props }) {
|
|
193
|
+
const { orientation, responsive } = useStepper();
|
|
194
|
+
const { titleId } = useStepperItem();
|
|
195
|
+
return /* @__PURE__ */ jsx("span", {
|
|
196
|
+
...props,
|
|
197
|
+
id: titleId,
|
|
198
|
+
"data-control-ui": "stepper",
|
|
199
|
+
"data-control-family": "stepper",
|
|
200
|
+
"data-slot": "title",
|
|
201
|
+
className: cn("min-w-0", partLayout(orientation, responsive, "title"), className)
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function StepperDescription({ className, ...props }) {
|
|
205
|
+
const { orientation, responsive } = useStepper();
|
|
206
|
+
return /* @__PURE__ */ jsx("span", {
|
|
207
|
+
...props,
|
|
208
|
+
"data-control-ui": "stepper",
|
|
209
|
+
"data-control-family": "stepper",
|
|
210
|
+
"data-slot": "description",
|
|
211
|
+
className: cn("min-w-0", partLayout(orientation, responsive, "description"), className)
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function StepperContent({ step, keepMounted = true, className, ...props }) {
|
|
215
|
+
const { value, contentMode, baseId } = useStepper();
|
|
216
|
+
const active = value === step;
|
|
217
|
+
const hidden = contentMode === "current" && !active;
|
|
218
|
+
if (hidden && !keepMounted) return null;
|
|
219
|
+
return /* @__PURE__ */ jsx("section", {
|
|
220
|
+
...props,
|
|
221
|
+
id: `${baseId}-step-${step}-content`,
|
|
222
|
+
"data-control-ui": "stepper",
|
|
223
|
+
"data-control-family": "stepper",
|
|
224
|
+
"data-slot": "content",
|
|
225
|
+
"data-state": active ? "active" : "inactive",
|
|
226
|
+
hidden,
|
|
227
|
+
"aria-labelledby": `${baseId}-step-${step}-title`,
|
|
228
|
+
className
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
export { Stepper, StepperContent, StepperDescription, StepperIndicator, StepperItem, StepperList, StepperSeparator, StepperTitle, StepperTrigger };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SwitchKnobStyle } from "../knob-contracts/switch-knobs.js";
|
|
2
|
+
import { CSSProperties, ReactNode } from "react";
|
|
3
|
+
//#region src/ui/switch.d.ts
|
|
4
|
+
type SwitchProps = Omit<{
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
defaultChecked?: boolean;
|
|
7
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
name?: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
checkedIcon?: ReactNode;
|
|
17
|
+
uncheckedIcon?: ReactNode;
|
|
18
|
+
"aria-label"?: string;
|
|
19
|
+
"aria-labelledby"?: string;
|
|
20
|
+
"aria-describedby"?: string;
|
|
21
|
+
}, "style"> & {
|
|
22
|
+
style?: CSSProperties & SwitchKnobStyle;
|
|
23
|
+
};
|
|
24
|
+
declare function Switch({ className, checked, defaultChecked, onCheckedChange, disabled, readOnly, required, name, value, id, icon, checkedIcon, uncheckedIcon, ...props }: SwitchProps): import("react").JSX.Element;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Switch, SwitchProps };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
5
|
+
//#region src/ui/switch.tsx
|
|
6
|
+
function Switch({ className, checked, defaultChecked, onCheckedChange, disabled, readOnly, required, name, value, id, icon, checkedIcon, uncheckedIcon, ...props }) {
|
|
7
|
+
const hasStateIcons = checkedIcon !== void 0 || uncheckedIcon !== void 0;
|
|
8
|
+
const hasIcon = icon !== void 0 || hasStateIcons;
|
|
9
|
+
const singleIcon = hasStateIcons ? void 0 : icon;
|
|
10
|
+
const onIcon = checkedIcon ?? icon;
|
|
11
|
+
const offIcon = uncheckedIcon ?? icon;
|
|
12
|
+
return /* @__PURE__ */ jsx(Switch$1.Root, {
|
|
13
|
+
"data-control-ui": "switch",
|
|
14
|
+
"data-control-family": "switch",
|
|
15
|
+
"data-slot": "root",
|
|
16
|
+
checked,
|
|
17
|
+
defaultChecked,
|
|
18
|
+
onCheckedChange,
|
|
19
|
+
disabled,
|
|
20
|
+
readOnly,
|
|
21
|
+
required,
|
|
22
|
+
name,
|
|
23
|
+
value,
|
|
24
|
+
id,
|
|
25
|
+
nativeButton: true,
|
|
26
|
+
render: /* @__PURE__ */ jsx("button", { type: "button" }),
|
|
27
|
+
className: cn("relative inline-flex shrink-0 cursor-pointer items-center", "data-[disabled]:cursor-not-allowed", className),
|
|
28
|
+
...props,
|
|
29
|
+
children: /* @__PURE__ */ jsx(Switch$1.Thumb, {
|
|
30
|
+
"data-control-ui": "switch",
|
|
31
|
+
"data-control-family": "switch",
|
|
32
|
+
"data-slot": "thumb",
|
|
33
|
+
className: "pointer-events-none relative block",
|
|
34
|
+
children: hasIcon ? /* @__PURE__ */ jsx(SwitchThumbIcon, {
|
|
35
|
+
icon: singleIcon,
|
|
36
|
+
checkedIcon: onIcon,
|
|
37
|
+
uncheckedIcon: offIcon
|
|
38
|
+
}) : null
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function SwitchThumbIcon({ icon, checkedIcon, uncheckedIcon }) {
|
|
43
|
+
const base = "absolute inset-0 flex items-center justify-center [&_svg]:size-2.5 [&_svg]:stroke-[2.5]";
|
|
44
|
+
if (icon !== void 0) return /* @__PURE__ */ jsx("span", {
|
|
45
|
+
"aria-hidden": true,
|
|
46
|
+
"data-control-ui": "switch",
|
|
47
|
+
"data-control-family": "switch",
|
|
48
|
+
"data-slot": "thumb-icon",
|
|
49
|
+
className: base,
|
|
50
|
+
children: icon
|
|
51
|
+
});
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [uncheckedIcon !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
53
|
+
"aria-hidden": true,
|
|
54
|
+
"data-control-ui": "switch",
|
|
55
|
+
"data-control-family": "switch",
|
|
56
|
+
"data-slot": "thumb-icon",
|
|
57
|
+
"data-switch-icon": "unchecked",
|
|
58
|
+
className: base,
|
|
59
|
+
children: uncheckedIcon
|
|
60
|
+
}) : null, checkedIcon !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
61
|
+
"aria-hidden": true,
|
|
62
|
+
"data-control-ui": "switch",
|
|
63
|
+
"data-control-family": "switch",
|
|
64
|
+
"data-slot": "thumb-icon",
|
|
65
|
+
"data-switch-icon": "checked",
|
|
66
|
+
className: base,
|
|
67
|
+
children: checkedIcon
|
|
68
|
+
}) : null] });
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { Switch };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TableOfContentsKnobStyle } from "../knob-contracts/table-of-contents-knobs.js";
|
|
2
|
+
import { CSSProperties, ComponentProps } from "react";
|
|
3
|
+
//#region src/ui/table-of-contents.d.ts
|
|
4
|
+
type TocItem = {
|
|
5
|
+
href: string;
|
|
6
|
+
label: string;
|
|
7
|
+
level?: number;
|
|
8
|
+
children?: TocItem[];
|
|
9
|
+
};
|
|
10
|
+
declare const tableOfContentsVariants: readonly ["background", "trail", "both"];
|
|
11
|
+
type TableOfContentsVariant = (typeof tableOfContentsVariants)[number];
|
|
12
|
+
type TableOfContentsProps = Omit<Omit<ComponentProps<"nav">, "children">, "style"> & {
|
|
13
|
+
style?: CSSProperties & TableOfContentsKnobStyle;
|
|
14
|
+
} & {
|
|
15
|
+
items: TocItem[];
|
|
16
|
+
label?: string;
|
|
17
|
+
variant?: TableOfContentsVariant;
|
|
18
|
+
};
|
|
19
|
+
declare function useVisibleSections(ids: string[]): string[];
|
|
20
|
+
declare function TableOfContents({ items, label, variant, className, style, ...props }: TableOfContentsProps): import("react").JSX.Element | null;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { TableOfContents, TableOfContentsProps, TableOfContentsVariant, TocItem, tableOfContentsVariants, useVisibleSections };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { TrackHighlight } from "../extensions/track-highlight.js";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/ui/table-of-contents.tsx
|
|
7
|
+
const tableOfContentsVariants = [
|
|
8
|
+
"background",
|
|
9
|
+
"trail",
|
|
10
|
+
"both"
|
|
11
|
+
];
|
|
12
|
+
const DETECTION_MARGIN = "-80px 0px -20% 0px";
|
|
13
|
+
const TOC_ITEM_SELECTOR = "[data-control-ui=\"table-of-contents\"][data-slot=\"item\"]";
|
|
14
|
+
const TOC_ACTIVE_SELECTOR = "[data-control-ui=\"table-of-contents\"][data-slot=\"item\"][data-active]";
|
|
15
|
+
const tableOfContentsItemClass = "block";
|
|
16
|
+
const tableOfContentsHighlightClass = "";
|
|
17
|
+
const tableOfContentsTrailClass = "absolute inset-y-0 left-0 w-0.5";
|
|
18
|
+
function getScrollContainer(el) {
|
|
19
|
+
let node = el.parentElement;
|
|
20
|
+
while (node) {
|
|
21
|
+
if (/(auto|scroll|overlay)/.test(getComputedStyle(node).overflowY)) return node;
|
|
22
|
+
node = node.parentElement;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
function useVisibleSections(ids) {
|
|
27
|
+
const [visibleState, setVisibleState] = useState({
|
|
28
|
+
idsKey: "",
|
|
29
|
+
visibleIds: []
|
|
30
|
+
});
|
|
31
|
+
const idsKey = ids.join("|");
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const elements = (idsKey ? idsKey.split("|") : []).map((id) => document.getElementById(id)).filter((el) => el !== null);
|
|
34
|
+
const firstElement = elements[0];
|
|
35
|
+
if (!firstElement) return;
|
|
36
|
+
const order = new Map(elements.map((el, index) => [el.id, index]));
|
|
37
|
+
const visible = /* @__PURE__ */ new Set();
|
|
38
|
+
const observer = new IntersectionObserver((entries) => {
|
|
39
|
+
for (const entry of entries) if (entry.isIntersecting) visible.add(entry.target.id);
|
|
40
|
+
else visible.delete(entry.target.id);
|
|
41
|
+
setVisibleState({
|
|
42
|
+
idsKey,
|
|
43
|
+
visibleIds: [...visible].sort((a, b) => (order.get(a) ?? 0) - (order.get(b) ?? 0))
|
|
44
|
+
});
|
|
45
|
+
}, {
|
|
46
|
+
root: getScrollContainer(firstElement),
|
|
47
|
+
rootMargin: DETECTION_MARGIN,
|
|
48
|
+
threshold: 0
|
|
49
|
+
});
|
|
50
|
+
for (const el of elements) observer.observe(el);
|
|
51
|
+
return () => observer.disconnect();
|
|
52
|
+
}, [idsKey]);
|
|
53
|
+
return visibleState.idsKey === idsKey ? visibleState.visibleIds : [];
|
|
54
|
+
}
|
|
55
|
+
function collectLevels(items, fallbackLevel = 2) {
|
|
56
|
+
return items.flatMap((item) => {
|
|
57
|
+
const level = item.level ?? fallbackLevel;
|
|
58
|
+
return [level, ...collectLevels(item.children ?? [], level + 1)];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function normalizeItems(items, baseLevel, fallbackLevel = 2, nestingDepth = 0) {
|
|
62
|
+
return items.map((item) => {
|
|
63
|
+
const level = item.level ?? fallbackLevel;
|
|
64
|
+
const depth = Math.max(nestingDepth, Math.max(0, level - baseLevel));
|
|
65
|
+
const nestedItems = item.children;
|
|
66
|
+
const children = nestedItems && nestedItems.length > 0 ? normalizeItems(nestedItems, baseLevel, level + 1, nestingDepth + 1) : void 0;
|
|
67
|
+
return {
|
|
68
|
+
...item,
|
|
69
|
+
level,
|
|
70
|
+
depth,
|
|
71
|
+
children
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function flattenItems(items) {
|
|
76
|
+
return items.flatMap((item) => [item, ...flattenItems(item.children ?? [])]);
|
|
77
|
+
}
|
|
78
|
+
function activeIdsInRange(visibleIds, targetIds) {
|
|
79
|
+
let firstIndex = targetIds.length;
|
|
80
|
+
let lastIndex = -1;
|
|
81
|
+
for (const id of visibleIds) {
|
|
82
|
+
const index = targetIds.indexOf(id);
|
|
83
|
+
if (index < 0) continue;
|
|
84
|
+
firstIndex = Math.min(firstIndex, index);
|
|
85
|
+
lastIndex = Math.max(lastIndex, index);
|
|
86
|
+
}
|
|
87
|
+
if (lastIndex < 0) return /* @__PURE__ */ new Set();
|
|
88
|
+
return new Set(targetIds.slice(firstIndex, lastIndex + 1));
|
|
89
|
+
}
|
|
90
|
+
function TableOfContents({ items, label = "On this page", variant = "both", className, style, ...props }) {
|
|
91
|
+
const normalizedItems = normalizeItems(items, Math.min(...collectLevels(items), 2));
|
|
92
|
+
const targetIds = flattenItems(normalizedItems).map((item) => item.href.replace(/^#/, ""));
|
|
93
|
+
const activeSet = activeIdsInRange(useVisibleSections(targetIds), targetIds);
|
|
94
|
+
const railStyle = style;
|
|
95
|
+
const highlightStyle = style;
|
|
96
|
+
if (items.length === 0) return null;
|
|
97
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
98
|
+
"data-control-ui": "table-of-contents",
|
|
99
|
+
"data-control-family": "table-of-contents",
|
|
100
|
+
"data-slot": "root",
|
|
101
|
+
"data-variant": variant,
|
|
102
|
+
"aria-label": label,
|
|
103
|
+
className: cn("sticky top-6", className),
|
|
104
|
+
style,
|
|
105
|
+
...props,
|
|
106
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
107
|
+
"data-control-ui": "table-of-contents",
|
|
108
|
+
"data-control-family": "table-of-contents",
|
|
109
|
+
"data-slot": "label",
|
|
110
|
+
children: label
|
|
111
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
112
|
+
"data-control-ui": "table-of-contents",
|
|
113
|
+
"data-control-family": "table-of-contents",
|
|
114
|
+
"data-slot": "track",
|
|
115
|
+
className: "relative isolate",
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ jsx("span", {
|
|
118
|
+
"aria-hidden": true,
|
|
119
|
+
"data-control-ui": "table-of-contents",
|
|
120
|
+
"data-control-family": "table-of-contents",
|
|
121
|
+
"data-slot": "rail",
|
|
122
|
+
className: "pointer-events-none absolute inset-y-0 left-0 -z-20 w-px",
|
|
123
|
+
style: railStyle
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ jsx(TrackHighlight, {
|
|
126
|
+
"data-variant": variant,
|
|
127
|
+
itemSelector: TOC_ITEM_SELECTOR,
|
|
128
|
+
activeSelector: TOC_ACTIVE_SELECTOR,
|
|
129
|
+
range: true,
|
|
130
|
+
followHover: false,
|
|
131
|
+
style: highlightStyle,
|
|
132
|
+
className: tableOfContentsHighlightClass,
|
|
133
|
+
children: variant !== "background" && /* @__PURE__ */ jsx("div", {
|
|
134
|
+
"aria-hidden": true,
|
|
135
|
+
"data-control-ui": "table-of-contents",
|
|
136
|
+
"data-control-family": "table-of-contents",
|
|
137
|
+
"data-slot": "trail",
|
|
138
|
+
className: tableOfContentsTrailClass
|
|
139
|
+
})
|
|
140
|
+
}),
|
|
141
|
+
/* @__PURE__ */ jsx(TocList, {
|
|
142
|
+
items: normalizedItems,
|
|
143
|
+
activeSet,
|
|
144
|
+
variant,
|
|
145
|
+
root: true
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function TocList({ items, activeSet, variant, root = false }) {
|
|
152
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
153
|
+
"data-control-ui": "table-of-contents",
|
|
154
|
+
"data-control-family": "table-of-contents",
|
|
155
|
+
"data-slot": "list",
|
|
156
|
+
"data-nested": root ? void 0 : "true",
|
|
157
|
+
children: items.map((item) => {
|
|
158
|
+
const targetId = item.href.replace(/^#/, "");
|
|
159
|
+
const isActive = activeSet.has(targetId);
|
|
160
|
+
return /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("a", {
|
|
161
|
+
"data-control-ui": "table-of-contents",
|
|
162
|
+
"data-control-family": "table-of-contents",
|
|
163
|
+
"data-slot": "item",
|
|
164
|
+
"data-active": isActive || void 0,
|
|
165
|
+
"data-variant": variant,
|
|
166
|
+
"data-level": item.level,
|
|
167
|
+
"data-depth": item.depth,
|
|
168
|
+
"aria-current": isActive ? "location" : void 0,
|
|
169
|
+
href: item.href,
|
|
170
|
+
className: tableOfContentsItemClass,
|
|
171
|
+
children: item.label
|
|
172
|
+
}), item.children && /* @__PURE__ */ jsx(TocList, {
|
|
173
|
+
items: item.children,
|
|
174
|
+
activeSet,
|
|
175
|
+
variant
|
|
176
|
+
})] }, item.href);
|
|
177
|
+
})
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
export { TableOfContents, tableOfContentsVariants, useVisibleSections };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TableKnobStyle } from "../knob-contracts/table-knobs.js";
|
|
2
|
+
import { CSSProperties, ComponentProps } from "react";
|
|
3
|
+
//#region src/ui/table.d.ts
|
|
4
|
+
type TableProps = Omit<ComponentProps<"table">, "style"> & {
|
|
5
|
+
style?: CSSProperties & TableKnobStyle;
|
|
6
|
+
};
|
|
7
|
+
type TableHeaderProps = Omit<ComponentProps<"thead">, "style"> & {
|
|
8
|
+
style?: CSSProperties & TableKnobStyle;
|
|
9
|
+
};
|
|
10
|
+
type TableBodyProps = Omit<ComponentProps<"tbody">, "style"> & {
|
|
11
|
+
style?: CSSProperties & TableKnobStyle;
|
|
12
|
+
};
|
|
13
|
+
type TableFooterProps = Omit<ComponentProps<"tfoot">, "style"> & {
|
|
14
|
+
style?: CSSProperties & TableKnobStyle;
|
|
15
|
+
};
|
|
16
|
+
type TableRowProps = Omit<ComponentProps<"tr">, "style"> & {
|
|
17
|
+
style?: CSSProperties & TableKnobStyle;
|
|
18
|
+
};
|
|
19
|
+
type TableHeadProps = Omit<ComponentProps<"th">, "style"> & {
|
|
20
|
+
style?: CSSProperties & TableKnobStyle;
|
|
21
|
+
};
|
|
22
|
+
type TableCellProps = ComponentProps<"td"> & {
|
|
23
|
+
style?: CSSProperties & TableKnobStyle;
|
|
24
|
+
};
|
|
25
|
+
type TableCaptionProps = Omit<ComponentProps<"caption">, "style"> & {
|
|
26
|
+
style?: CSSProperties & TableKnobStyle;
|
|
27
|
+
};
|
|
28
|
+
declare function Table({ className, ...props }: TableProps): import("react").JSX.Element;
|
|
29
|
+
declare function TableHeader({ className, ...props }: TableHeaderProps): import("react").JSX.Element;
|
|
30
|
+
declare function TableBody({ className, ...props }: TableBodyProps): import("react").JSX.Element;
|
|
31
|
+
declare function TableFooter({ className, ...props }: TableFooterProps): import("react").JSX.Element;
|
|
32
|
+
declare function TableRow({ className, ...props }: TableRowProps): import("react").JSX.Element;
|
|
33
|
+
declare function TableHead({ className, ...props }: TableHeadProps): import("react").JSX.Element;
|
|
34
|
+
declare function TableCell({ className, ...props }: TableCellProps): import("react").JSX.Element;
|
|
35
|
+
declare function TableCaption({ className, ...props }: TableCaptionProps): import("react").JSX.Element;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Table, TableBody, TableBodyProps, TableCaption, TableCaptionProps, TableCell, TableCellProps, TableFooter, TableFooterProps, TableHead, TableHeadProps, TableHeader, TableHeaderProps, TableProps, TableRow, TableRowProps };
|
package/dist/ui/table.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/ui/table.tsx
|
|
4
|
+
function Table({ className, ...props }) {
|
|
5
|
+
return /* @__PURE__ */ jsx("div", {
|
|
6
|
+
"data-control-ui": "table",
|
|
7
|
+
"data-control-family": "table",
|
|
8
|
+
"data-slot": "container",
|
|
9
|
+
className: "relative w-full overflow-x-auto",
|
|
10
|
+
children: /* @__PURE__ */ jsx("table", {
|
|
11
|
+
"data-control-ui": "table",
|
|
12
|
+
"data-control-family": "table",
|
|
13
|
+
"data-slot": "root",
|
|
14
|
+
className: cn("w-full caption-bottom", className),
|
|
15
|
+
...props
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function TableHeader({ className, ...props }) {
|
|
20
|
+
return /* @__PURE__ */ jsx("thead", {
|
|
21
|
+
"data-control-ui": "table",
|
|
22
|
+
"data-control-family": "table",
|
|
23
|
+
"data-slot": "header",
|
|
24
|
+
className,
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function TableBody({ className, ...props }) {
|
|
29
|
+
return /* @__PURE__ */ jsx("tbody", {
|
|
30
|
+
"data-control-ui": "table",
|
|
31
|
+
"data-control-family": "table",
|
|
32
|
+
"data-slot": "body",
|
|
33
|
+
className,
|
|
34
|
+
...props
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function TableFooter({ className, ...props }) {
|
|
38
|
+
return /* @__PURE__ */ jsx("tfoot", {
|
|
39
|
+
"data-control-ui": "table",
|
|
40
|
+
"data-control-family": "table",
|
|
41
|
+
"data-slot": "footer",
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function TableRow({ className, ...props }) {
|
|
47
|
+
return /* @__PURE__ */ jsx("tr", {
|
|
48
|
+
"data-control-ui": "table",
|
|
49
|
+
"data-control-family": "table",
|
|
50
|
+
"data-slot": "row",
|
|
51
|
+
className,
|
|
52
|
+
...props
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function TableHead({ className, ...props }) {
|
|
56
|
+
return /* @__PURE__ */ jsx("th", {
|
|
57
|
+
"data-control-ui": "table",
|
|
58
|
+
"data-control-family": "table",
|
|
59
|
+
"data-slot": "head",
|
|
60
|
+
className: cn("whitespace-nowrap align-middle [&:has([role=checkbox])]:pr-0", className),
|
|
61
|
+
...props
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function TableCell({ className, ...props }) {
|
|
65
|
+
return /* @__PURE__ */ jsx("td", {
|
|
66
|
+
"data-control-ui": "table",
|
|
67
|
+
"data-control-family": "table",
|
|
68
|
+
"data-slot": "cell",
|
|
69
|
+
className: cn("whitespace-nowrap align-middle [&:has([role=checkbox])]:pr-0", className),
|
|
70
|
+
...props
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function TableCaption({ className, ...props }) {
|
|
74
|
+
return /* @__PURE__ */ jsx("caption", {
|
|
75
|
+
"data-control-ui": "table",
|
|
76
|
+
"data-control-family": "table",
|
|
77
|
+
"data-slot": "caption",
|
|
78
|
+
className,
|
|
79
|
+
...props
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };
|