@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,72 @@
|
|
|
1
|
+
//#region src/lib/color.d.ts
|
|
2
|
+
type Hsva = {
|
|
3
|
+
h: number;
|
|
4
|
+
s: number;
|
|
5
|
+
v: number;
|
|
6
|
+
a: number;
|
|
7
|
+
};
|
|
8
|
+
type Rgba = {
|
|
9
|
+
r: number;
|
|
10
|
+
g: number;
|
|
11
|
+
b: number;
|
|
12
|
+
a: number;
|
|
13
|
+
};
|
|
14
|
+
type Hsla = {
|
|
15
|
+
h: number;
|
|
16
|
+
s: number;
|
|
17
|
+
l: number;
|
|
18
|
+
a: number;
|
|
19
|
+
};
|
|
20
|
+
type Oklcha = {
|
|
21
|
+
L: number;
|
|
22
|
+
C: number;
|
|
23
|
+
H: number;
|
|
24
|
+
a: number;
|
|
25
|
+
};
|
|
26
|
+
type ColorFormat = "hex" | "rgb" | "hsl" | "oklch";
|
|
27
|
+
type ChannelId = "r" | "g" | "b" | "h" | "s" | "l" | "okl" | "okc" | "okh" | "a";
|
|
28
|
+
type ChannelSpec = {
|
|
29
|
+
id: ChannelId;
|
|
30
|
+
label: string;
|
|
31
|
+
value: number;
|
|
32
|
+
min: number;
|
|
33
|
+
max: number;
|
|
34
|
+
step: number;
|
|
35
|
+
};
|
|
36
|
+
declare function hsvaToRgba({ h, s, v, a }: Hsva): Rgba;
|
|
37
|
+
declare function rgbaToHsva({ r, g, b, a }: Rgba): Hsva;
|
|
38
|
+
declare function hsvaToHsla({ h, s, v, a }: Hsva): Hsla;
|
|
39
|
+
declare function hslaToHsva({ h, s, l, a }: Hsla): Hsva;
|
|
40
|
+
declare function rgbaToHsla(rgba: Rgba): Hsla;
|
|
41
|
+
declare function hslaToRgba(hsla: Hsla): Rgba;
|
|
42
|
+
declare function hsvaToOklcha(hsva: Hsva): Oklcha;
|
|
43
|
+
declare function oklchaToHsva({ L, C, H, a }: Oklcha): Hsva;
|
|
44
|
+
declare function hexToRgba(input: string): Rgba | null;
|
|
45
|
+
declare function rgbaToHex(rgba: Rgba, withAlpha?: boolean): string;
|
|
46
|
+
declare function formatColor(hsva: Hsva, format: ColorFormat, opts?: {
|
|
47
|
+
alpha?: boolean;
|
|
48
|
+
}): string;
|
|
49
|
+
declare function parseColor(input: string): Hsva | null;
|
|
50
|
+
declare function getChannels(hsva: Hsva, format: ColorFormat): ChannelSpec[];
|
|
51
|
+
declare function setChannel(hsva: Hsva, id: ChannelId, value: number): Hsva;
|
|
52
|
+
declare function pointToSaturationValue(rect: {
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
}, offsetX: number, offsetY: number): {
|
|
56
|
+
s: number;
|
|
57
|
+
v: number;
|
|
58
|
+
};
|
|
59
|
+
type GradientKind = "linear" | "radial" | "conic";
|
|
60
|
+
declare function formatGradient(stops: {
|
|
61
|
+
position: number;
|
|
62
|
+
color: string;
|
|
63
|
+
}[], type: GradientKind, angle: number): string;
|
|
64
|
+
declare function pointToHueSat(rect: {
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
}, offsetX: number, offsetY: number): {
|
|
68
|
+
h: number;
|
|
69
|
+
s: number;
|
|
70
|
+
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { ChannelId, ChannelSpec, ColorFormat, GradientKind, Hsla, Hsva, Oklcha, Rgba, formatColor, formatGradient, getChannels, hexToRgba, hslaToHsva, hslaToRgba, hsvaToHsla, hsvaToOklcha, hsvaToRgba, oklchaToHsva, parseColor, pointToHueSat, pointToSaturationValue, rgbaToHex, rgbaToHsla, rgbaToHsva, setChannel };
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
//#region src/lib/color.ts
|
|
2
|
+
const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
3
|
+
const clamp01 = (n) => clamp(n, 0, 1);
|
|
4
|
+
const wrapHue = (h) => (h % 360 + 360) % 360;
|
|
5
|
+
const round = (n) => Math.round(n);
|
|
6
|
+
function hsvaToRgba({ h, s, v, a }) {
|
|
7
|
+
const S = clamp01(s / 100);
|
|
8
|
+
const V = clamp01(v / 100);
|
|
9
|
+
const c = V * S;
|
|
10
|
+
const hh = wrapHue(h) / 60;
|
|
11
|
+
const x = c * (1 - Math.abs(hh % 2 - 1));
|
|
12
|
+
const m = V - c;
|
|
13
|
+
let r = 0;
|
|
14
|
+
let g = 0;
|
|
15
|
+
let b = 0;
|
|
16
|
+
if (hh < 1) [r, g, b] = [
|
|
17
|
+
c,
|
|
18
|
+
x,
|
|
19
|
+
0
|
|
20
|
+
];
|
|
21
|
+
else if (hh < 2) [r, g, b] = [
|
|
22
|
+
x,
|
|
23
|
+
c,
|
|
24
|
+
0
|
|
25
|
+
];
|
|
26
|
+
else if (hh < 3) [r, g, b] = [
|
|
27
|
+
0,
|
|
28
|
+
c,
|
|
29
|
+
x
|
|
30
|
+
];
|
|
31
|
+
else if (hh < 4) [r, g, b] = [
|
|
32
|
+
0,
|
|
33
|
+
x,
|
|
34
|
+
c
|
|
35
|
+
];
|
|
36
|
+
else if (hh < 5) [r, g, b] = [
|
|
37
|
+
x,
|
|
38
|
+
0,
|
|
39
|
+
c
|
|
40
|
+
];
|
|
41
|
+
else [r, g, b] = [
|
|
42
|
+
c,
|
|
43
|
+
0,
|
|
44
|
+
x
|
|
45
|
+
];
|
|
46
|
+
return {
|
|
47
|
+
r: round((r + m) * 255),
|
|
48
|
+
g: round((g + m) * 255),
|
|
49
|
+
b: round((b + m) * 255),
|
|
50
|
+
a: clamp01(a)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function rgbaToHsva({ r, g, b, a }) {
|
|
54
|
+
const R = clamp(r, 0, 255) / 255;
|
|
55
|
+
const G = clamp(g, 0, 255) / 255;
|
|
56
|
+
const B = clamp(b, 0, 255) / 255;
|
|
57
|
+
const max = Math.max(R, G, B);
|
|
58
|
+
const d = max - Math.min(R, G, B);
|
|
59
|
+
let h = 0;
|
|
60
|
+
if (d !== 0) {
|
|
61
|
+
if (max === R) h = 60 * ((G - B) / d % 6);
|
|
62
|
+
else if (max === G) h = 60 * ((B - R) / d + 2);
|
|
63
|
+
else h = 60 * ((R - G) / d + 4);
|
|
64
|
+
}
|
|
65
|
+
const s = max === 0 ? 0 : d / max;
|
|
66
|
+
return {
|
|
67
|
+
h: wrapHue(h),
|
|
68
|
+
s: s * 100,
|
|
69
|
+
v: max * 100,
|
|
70
|
+
a: clamp01(a)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function hsvaToHsla({ h, s, v, a }) {
|
|
74
|
+
const S = clamp01(s / 100);
|
|
75
|
+
const V = clamp01(v / 100);
|
|
76
|
+
const L = V * (1 - S / 2);
|
|
77
|
+
const Sl = L === 0 || L === 1 ? 0 : (V - L) / Math.min(L, 1 - L);
|
|
78
|
+
return {
|
|
79
|
+
h: wrapHue(h),
|
|
80
|
+
s: Sl * 100,
|
|
81
|
+
l: L * 100,
|
|
82
|
+
a: clamp01(a)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function hslaToHsva({ h, s, l, a }) {
|
|
86
|
+
const S = clamp01(s / 100);
|
|
87
|
+
const L = clamp01(l / 100);
|
|
88
|
+
const V = L + S * Math.min(L, 1 - L);
|
|
89
|
+
const Sv = V === 0 ? 0 : 2 * (1 - L / V);
|
|
90
|
+
return {
|
|
91
|
+
h: wrapHue(h),
|
|
92
|
+
s: Sv * 100,
|
|
93
|
+
v: V * 100,
|
|
94
|
+
a: clamp01(a)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function rgbaToHsla(rgba) {
|
|
98
|
+
return hsvaToHsla(rgbaToHsva(rgba));
|
|
99
|
+
}
|
|
100
|
+
function hslaToRgba(hsla) {
|
|
101
|
+
return hsvaToRgba(hslaToHsva(hsla));
|
|
102
|
+
}
|
|
103
|
+
const srgbToLinear = (c) => c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4;
|
|
104
|
+
const linearToSrgb = (c) => c <= .0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - .055;
|
|
105
|
+
function rgbToOklch(r255, g255, b255) {
|
|
106
|
+
const r = srgbToLinear(clamp(r255, 0, 255) / 255);
|
|
107
|
+
const g = srgbToLinear(clamp(g255, 0, 255) / 255);
|
|
108
|
+
const b = srgbToLinear(clamp(b255, 0, 255) / 255);
|
|
109
|
+
const l = .4122214708 * r + .5363325363 * g + .0514459929 * b;
|
|
110
|
+
const m = .2119034982 * r + .6806995451 * g + .1073969566 * b;
|
|
111
|
+
const s = .0883024619 * r + .2817188376 * g + .6299787005 * b;
|
|
112
|
+
const l_ = Math.cbrt(l);
|
|
113
|
+
const m_ = Math.cbrt(m);
|
|
114
|
+
const s_ = Math.cbrt(s);
|
|
115
|
+
const L = .2104542553 * l_ + .793617785 * m_ - .0040720468 * s_;
|
|
116
|
+
const A = 1.9779984951 * l_ - 2.428592205 * m_ + .4505937099 * s_;
|
|
117
|
+
const B = .0259040371 * l_ + .7827717662 * m_ - .808675766 * s_;
|
|
118
|
+
const C = Math.hypot(A, B);
|
|
119
|
+
let H = Math.atan2(B, A) * 180 / Math.PI;
|
|
120
|
+
if (H < 0) H += 360;
|
|
121
|
+
return {
|
|
122
|
+
L,
|
|
123
|
+
C,
|
|
124
|
+
H
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function oklchToRgb(L, C, H) {
|
|
128
|
+
const hr = H * Math.PI / 180;
|
|
129
|
+
const a = C * Math.cos(hr);
|
|
130
|
+
const b = C * Math.sin(hr);
|
|
131
|
+
const l_ = L + .3963377774 * a + .2158037573 * b;
|
|
132
|
+
const m_ = L - .1055613458 * a - .0638541728 * b;
|
|
133
|
+
const s_ = L - .0894841775 * a - 1.291485548 * b;
|
|
134
|
+
const l = l_ ** 3;
|
|
135
|
+
const m = m_ ** 3;
|
|
136
|
+
const s = s_ ** 3;
|
|
137
|
+
const r = 4.0767416621 * l - 3.3077115913 * m + .2309699292 * s;
|
|
138
|
+
const g = -1.2684380046 * l + 2.6097574011 * m - .3413193965 * s;
|
|
139
|
+
const bl = -.0041960863 * l - .7034186147 * m + 1.707614701 * s;
|
|
140
|
+
const to = (c) => clamp(round(linearToSrgb(c) * 255), 0, 255);
|
|
141
|
+
return {
|
|
142
|
+
r: to(r),
|
|
143
|
+
g: to(g),
|
|
144
|
+
b: to(bl)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function hsvaToOklcha(hsva) {
|
|
148
|
+
const { r, g, b } = hsvaToRgba(hsva);
|
|
149
|
+
const { L, C, H } = rgbToOklch(r, g, b);
|
|
150
|
+
return {
|
|
151
|
+
L,
|
|
152
|
+
C,
|
|
153
|
+
H,
|
|
154
|
+
a: clamp01(hsva.a)
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function oklchaToHsva({ L, C, H, a }) {
|
|
158
|
+
const { r, g, b } = oklchToRgb(L, C, H);
|
|
159
|
+
return rgbaToHsva({
|
|
160
|
+
r,
|
|
161
|
+
g,
|
|
162
|
+
b,
|
|
163
|
+
a
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const hex2 = (n) => clamp(round(n), 0, 255).toString(16).padStart(2, "0");
|
|
167
|
+
function hexToRgba(input) {
|
|
168
|
+
const m = input.trim().replace(/^#/, "");
|
|
169
|
+
const read = (h) => Number.parseInt(h, 16);
|
|
170
|
+
if (m.length === 3 || m.length === 4) {
|
|
171
|
+
if (!/^[0-9a-f]+$/i.test(m)) return null;
|
|
172
|
+
const [red, green, blue, alpha] = m;
|
|
173
|
+
if (!red || !green || !blue) return null;
|
|
174
|
+
return {
|
|
175
|
+
r: read(red + red),
|
|
176
|
+
g: read(green + green),
|
|
177
|
+
b: read(blue + blue),
|
|
178
|
+
a: alpha ? read(alpha + alpha) / 255 : 1
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (m.length === 6 || m.length === 8) {
|
|
182
|
+
if (!/^[0-9a-f]+$/i.test(m)) return null;
|
|
183
|
+
return {
|
|
184
|
+
r: read(m.slice(0, 2)),
|
|
185
|
+
g: read(m.slice(2, 4)),
|
|
186
|
+
b: read(m.slice(4, 6)),
|
|
187
|
+
a: m.length === 8 ? read(m.slice(6, 8)) / 255 : 1
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
function rgbaToHex(rgba, withAlpha = rgba.a < 1) {
|
|
193
|
+
const base = `#${hex2(rgba.r)}${hex2(rgba.g)}${hex2(rgba.b)}`;
|
|
194
|
+
return withAlpha ? `${base}${hex2(clamp01(rgba.a) * 255)}` : base;
|
|
195
|
+
}
|
|
196
|
+
const trimNum = (n, d) => n.toFixed(d).replace(/\.?0+$/, "");
|
|
197
|
+
function oklchTriplet(L, C, H) {
|
|
198
|
+
const Ls = trimNum(L, 4);
|
|
199
|
+
if (C < 1e-4) return `${Ls} 0 0`;
|
|
200
|
+
return `${Ls} ${trimNum(C, 4)} ${trimNum(H, 3)}`;
|
|
201
|
+
}
|
|
202
|
+
function formatColor(hsva, format, opts) {
|
|
203
|
+
const useAlpha = opts?.alpha !== false && hsva.a < 1;
|
|
204
|
+
const alphaSuffix = useAlpha ? ` / ${trimNum(clamp01(hsva.a), 3)}` : "";
|
|
205
|
+
switch (format) {
|
|
206
|
+
case "hex": return rgbaToHex(hsvaToRgba(hsva), useAlpha);
|
|
207
|
+
case "rgb": {
|
|
208
|
+
const { r, g, b } = hsvaToRgba(hsva);
|
|
209
|
+
return `rgb(${r} ${g} ${b}${alphaSuffix})`;
|
|
210
|
+
}
|
|
211
|
+
case "hsl": {
|
|
212
|
+
const { h, s, l } = hsvaToHsla(hsva);
|
|
213
|
+
return `hsl(${trimNum(wrapHue(h), 1)} ${trimNum(s, 1)}% ${trimNum(l, 1)}%${alphaSuffix})`;
|
|
214
|
+
}
|
|
215
|
+
case "oklch": {
|
|
216
|
+
const { L, C, H } = hsvaToOklcha(hsva);
|
|
217
|
+
return `oklch(${oklchTriplet(L, C, H)}${alphaSuffix})`;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const NAMED = {
|
|
222
|
+
transparent: "#00000000",
|
|
223
|
+
black: "#000000",
|
|
224
|
+
white: "#ffffff",
|
|
225
|
+
red: "#ff0000",
|
|
226
|
+
green: "#008000",
|
|
227
|
+
blue: "#0000ff",
|
|
228
|
+
yellow: "#ffff00",
|
|
229
|
+
orange: "#ffa500",
|
|
230
|
+
purple: "#800080",
|
|
231
|
+
gray: "#808080",
|
|
232
|
+
grey: "#808080"
|
|
233
|
+
};
|
|
234
|
+
function readAlpha(token) {
|
|
235
|
+
if (token === void 0) return 1;
|
|
236
|
+
const t = token.trim();
|
|
237
|
+
if (t.endsWith("%")) return clamp01(Number.parseFloat(t) / 100);
|
|
238
|
+
return clamp01(Number.parseFloat(t));
|
|
239
|
+
}
|
|
240
|
+
function parseHexColor(raw) {
|
|
241
|
+
const rgba = hexToRgba(raw);
|
|
242
|
+
return rgba ? rgbaToHsva(rgba) : null;
|
|
243
|
+
}
|
|
244
|
+
function parseRgbFunction(raw) {
|
|
245
|
+
const match = raw.match(/^rgba?\(\s*([\d.]+%?)[\s,]+([\d.]+%?)[\s,]+([\d.]+%?)\s*(?:[/,]\s*([\d.]+%?))?\s*\)$/);
|
|
246
|
+
if (!match) return null;
|
|
247
|
+
const [, red, green, blue, alpha] = match;
|
|
248
|
+
if (!red || !green || !blue) return null;
|
|
249
|
+
const chan = (t) => t.endsWith("%") ? Number.parseFloat(t) / 100 * 255 : Number.parseFloat(t);
|
|
250
|
+
return rgbaToHsva({
|
|
251
|
+
r: chan(red),
|
|
252
|
+
g: chan(green),
|
|
253
|
+
b: chan(blue),
|
|
254
|
+
a: readAlpha(alpha)
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function parseHslFunction(raw) {
|
|
258
|
+
const match = raw.match(/^hsla?\(\s*([\d.]+)(?:deg)?[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*(?:[/,]\s*([\d.]+%?))?\s*\)$/);
|
|
259
|
+
if (!match) return null;
|
|
260
|
+
const [, hue, saturation, lightness, alpha] = match;
|
|
261
|
+
if (!hue || !saturation || !lightness) return null;
|
|
262
|
+
return hslaToHsva({
|
|
263
|
+
h: Number.parseFloat(hue),
|
|
264
|
+
s: Number.parseFloat(saturation),
|
|
265
|
+
l: Number.parseFloat(lightness),
|
|
266
|
+
a: readAlpha(alpha)
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function parseOklchFunction(raw) {
|
|
270
|
+
const match = raw.match(/^oklch\(\s*([\d.]+%?)\s+([\d.]+%?)\s+([\d.]+)\s*(?:[/,]\s*([\d.]+%?))?\s*\)$/);
|
|
271
|
+
if (!match) return null;
|
|
272
|
+
const [, lightness, chroma, hue, alpha] = match;
|
|
273
|
+
if (!lightness || !chroma || !hue) return null;
|
|
274
|
+
return oklchaToHsva({
|
|
275
|
+
L: lightness.endsWith("%") ? Number.parseFloat(lightness) / 100 : Number.parseFloat(lightness),
|
|
276
|
+
C: chroma.endsWith("%") ? Number.parseFloat(chroma) / 100 * .4 : Number.parseFloat(chroma),
|
|
277
|
+
H: Number.parseFloat(hue),
|
|
278
|
+
a: readAlpha(alpha)
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function parseColor(input) {
|
|
282
|
+
const raw = input.trim().toLowerCase();
|
|
283
|
+
if (!raw) return null;
|
|
284
|
+
const named = NAMED[raw];
|
|
285
|
+
if (named) return parseHexColor(named);
|
|
286
|
+
if (raw.startsWith("#")) return parseHexColor(raw);
|
|
287
|
+
return parseRgbFunction(raw) ?? parseHslFunction(raw) ?? parseOklchFunction(raw);
|
|
288
|
+
}
|
|
289
|
+
function preserveAchromatic(next, prev) {
|
|
290
|
+
const out = { ...next };
|
|
291
|
+
if (out.v === 0) {
|
|
292
|
+
out.h = prev.h;
|
|
293
|
+
out.s = prev.s;
|
|
294
|
+
} else if (out.s === 0) out.h = prev.h;
|
|
295
|
+
return out;
|
|
296
|
+
}
|
|
297
|
+
function getChannels(hsva, format) {
|
|
298
|
+
const alpha = {
|
|
299
|
+
id: "a",
|
|
300
|
+
label: "A",
|
|
301
|
+
value: round(clamp01(hsva.a) * 100),
|
|
302
|
+
min: 0,
|
|
303
|
+
max: 100,
|
|
304
|
+
step: 1
|
|
305
|
+
};
|
|
306
|
+
switch (format) {
|
|
307
|
+
case "hex":
|
|
308
|
+
case "rgb": {
|
|
309
|
+
const { r, g, b } = hsvaToRgba(hsva);
|
|
310
|
+
return [
|
|
311
|
+
{
|
|
312
|
+
id: "r",
|
|
313
|
+
label: "R",
|
|
314
|
+
value: round(r),
|
|
315
|
+
min: 0,
|
|
316
|
+
max: 255,
|
|
317
|
+
step: 1
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
id: "g",
|
|
321
|
+
label: "G",
|
|
322
|
+
value: round(g),
|
|
323
|
+
min: 0,
|
|
324
|
+
max: 255,
|
|
325
|
+
step: 1
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
id: "b",
|
|
329
|
+
label: "B",
|
|
330
|
+
value: round(b),
|
|
331
|
+
min: 0,
|
|
332
|
+
max: 255,
|
|
333
|
+
step: 1
|
|
334
|
+
},
|
|
335
|
+
alpha
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
case "hsl": {
|
|
339
|
+
const { h, s, l } = hsvaToHsla(hsva);
|
|
340
|
+
return [
|
|
341
|
+
{
|
|
342
|
+
id: "h",
|
|
343
|
+
label: "H",
|
|
344
|
+
value: round(wrapHue(h)),
|
|
345
|
+
min: 0,
|
|
346
|
+
max: 360,
|
|
347
|
+
step: 1
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
id: "s",
|
|
351
|
+
label: "S",
|
|
352
|
+
value: round(s),
|
|
353
|
+
min: 0,
|
|
354
|
+
max: 100,
|
|
355
|
+
step: 1
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
id: "l",
|
|
359
|
+
label: "L",
|
|
360
|
+
value: round(l),
|
|
361
|
+
min: 0,
|
|
362
|
+
max: 100,
|
|
363
|
+
step: 1
|
|
364
|
+
},
|
|
365
|
+
alpha
|
|
366
|
+
];
|
|
367
|
+
}
|
|
368
|
+
case "oklch": {
|
|
369
|
+
const { L, C, H } = hsvaToOklcha(hsva);
|
|
370
|
+
return [
|
|
371
|
+
{
|
|
372
|
+
id: "okl",
|
|
373
|
+
label: "L",
|
|
374
|
+
value: Number(trimNum(L, 3)),
|
|
375
|
+
min: 0,
|
|
376
|
+
max: 1,
|
|
377
|
+
step: .001
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
id: "okc",
|
|
381
|
+
label: "C",
|
|
382
|
+
value: Number(trimNum(C, 3)),
|
|
383
|
+
min: 0,
|
|
384
|
+
max: .4,
|
|
385
|
+
step: .001
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
id: "okh",
|
|
389
|
+
label: "H",
|
|
390
|
+
value: round(wrapHue(H)),
|
|
391
|
+
min: 0,
|
|
392
|
+
max: 360,
|
|
393
|
+
step: 1
|
|
394
|
+
},
|
|
395
|
+
alpha
|
|
396
|
+
];
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
function setChannel(hsva, id, value) {
|
|
401
|
+
switch (id) {
|
|
402
|
+
case "a": return {
|
|
403
|
+
...hsva,
|
|
404
|
+
a: clamp01(value / 100)
|
|
405
|
+
};
|
|
406
|
+
case "r":
|
|
407
|
+
case "g":
|
|
408
|
+
case "b": return preserveAchromatic({
|
|
409
|
+
...rgbaToHsva({
|
|
410
|
+
...hsvaToRgba(hsva),
|
|
411
|
+
[id]: clamp(value, 0, 255)
|
|
412
|
+
}),
|
|
413
|
+
a: hsva.a
|
|
414
|
+
}, hsva);
|
|
415
|
+
case "h": return {
|
|
416
|
+
...hsva,
|
|
417
|
+
...hslaToHsva({
|
|
418
|
+
...hsvaToHsla(hsva),
|
|
419
|
+
h: wrapHue(value)
|
|
420
|
+
}),
|
|
421
|
+
a: hsva.a
|
|
422
|
+
};
|
|
423
|
+
case "s":
|
|
424
|
+
case "l": {
|
|
425
|
+
const hsla = hsvaToHsla(hsva);
|
|
426
|
+
const key = id === "s" ? "s" : "l";
|
|
427
|
+
return preserveAchromatic({
|
|
428
|
+
...hslaToHsva({
|
|
429
|
+
...hsla,
|
|
430
|
+
[key]: clamp(value, 0, 100)
|
|
431
|
+
}),
|
|
432
|
+
h: hsla.h,
|
|
433
|
+
a: hsva.a
|
|
434
|
+
}, hsva);
|
|
435
|
+
}
|
|
436
|
+
case "okl":
|
|
437
|
+
case "okc":
|
|
438
|
+
case "okh": {
|
|
439
|
+
const ok = hsvaToOklcha(hsva);
|
|
440
|
+
let mapped = ok;
|
|
441
|
+
if (id === "okl") mapped = {
|
|
442
|
+
...ok,
|
|
443
|
+
L: clamp01(value)
|
|
444
|
+
};
|
|
445
|
+
else if (id === "okc") mapped = {
|
|
446
|
+
...ok,
|
|
447
|
+
C: clamp(value, 0, .5)
|
|
448
|
+
};
|
|
449
|
+
else mapped = {
|
|
450
|
+
...ok,
|
|
451
|
+
H: wrapHue(value)
|
|
452
|
+
};
|
|
453
|
+
return preserveAchromatic({
|
|
454
|
+
...oklchaToHsva(mapped),
|
|
455
|
+
a: hsva.a
|
|
456
|
+
}, hsva);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function pointToSaturationValue(rect, offsetX, offsetY) {
|
|
461
|
+
return {
|
|
462
|
+
s: rect.width <= 0 ? 0 : clamp01(offsetX / rect.width) * 100,
|
|
463
|
+
v: rect.height <= 0 ? 0 : (1 - clamp01(offsetY / rect.height)) * 100
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
function formatGradient(stops, type, angle) {
|
|
467
|
+
const list = [...stops].sort((a, b) => a.position - b.position).map((stop) => `${stop.color} ${round(clamp01(stop.position) * 100)}%`).join(", ");
|
|
468
|
+
switch (type) {
|
|
469
|
+
case "linear": return `linear-gradient(${round(angle)}deg, ${list})`;
|
|
470
|
+
case "radial": return `radial-gradient(circle, ${list})`;
|
|
471
|
+
case "conic": return `conic-gradient(from ${round(angle)}deg, ${list})`;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function pointToHueSat(rect, offsetX, offsetY) {
|
|
475
|
+
const cx = rect.width / 2;
|
|
476
|
+
const cy = rect.height / 2;
|
|
477
|
+
const dx = offsetX - cx;
|
|
478
|
+
const dy = offsetY - cy;
|
|
479
|
+
const radius = Math.min(cx, cy);
|
|
480
|
+
const dist = Math.hypot(dx, dy);
|
|
481
|
+
let h = Math.atan2(dy, dx) * 180 / Math.PI;
|
|
482
|
+
h = wrapHue(h);
|
|
483
|
+
const s = radius <= 0 ? 0 : clamp01(dist / radius) * 100;
|
|
484
|
+
return {
|
|
485
|
+
h,
|
|
486
|
+
s
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
//#endregion
|
|
490
|
+
export { formatColor, formatGradient, getChannels, hexToRgba, hslaToHsva, hslaToRgba, hsvaToHsla, hsvaToOklcha, hsvaToRgba, oklchaToHsva, parseColor, pointToHueSat, pointToSaturationValue, rgbaToHex, rgbaToHsla, rgbaToHsva, setChannel };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Hsva, Rgba } from "./color.js";
|
|
2
|
+
//#region src/lib/contrast.d.ts
|
|
3
|
+
type WcagLevel = "AA" | "AAA";
|
|
4
|
+
type WcagLevels = {
|
|
5
|
+
AA: boolean;
|
|
6
|
+
AAA: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const AA_RATIO = 4.5;
|
|
9
|
+
declare const AAA_RATIO = 7;
|
|
10
|
+
declare const TARGET_RATIO: Record<WcagLevel, number>;
|
|
11
|
+
declare function luminanceFromRgb({ r, g, b }: {
|
|
12
|
+
r: number;
|
|
13
|
+
g: number;
|
|
14
|
+
b: number;
|
|
15
|
+
}): number;
|
|
16
|
+
declare function contrastRatio(a: {
|
|
17
|
+
r: number;
|
|
18
|
+
g: number;
|
|
19
|
+
b: number;
|
|
20
|
+
}, b: {
|
|
21
|
+
r: number;
|
|
22
|
+
g: number;
|
|
23
|
+
b: number;
|
|
24
|
+
}): number;
|
|
25
|
+
declare function wcagLevels(ratio: number): WcagLevels;
|
|
26
|
+
declare function nextFixLevel(levels: WcagLevels): WcagLevel | null;
|
|
27
|
+
declare function contrastOf(color: Hsva, background: Rgba): number;
|
|
28
|
+
declare function fixColorForContrast(color: Hsva, background: Rgba, target?: number): Hsva | null;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { AAA_RATIO, AA_RATIO, TARGET_RATIO, WcagLevel, WcagLevels, contrastOf, contrastRatio, fixColorForContrast, luminanceFromRgb, nextFixLevel, wcagLevels };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { hsvaToOklcha, hsvaToRgba, oklchaToHsva } from "./color.js";
|
|
2
|
+
//#region src/lib/contrast.ts
|
|
3
|
+
const AA_RATIO = 4.5;
|
|
4
|
+
const AAA_RATIO = 7;
|
|
5
|
+
const TARGET_RATIO = {
|
|
6
|
+
AA: AA_RATIO,
|
|
7
|
+
AAA: 7
|
|
8
|
+
};
|
|
9
|
+
function channelLuminance(c) {
|
|
10
|
+
const s = c / 255;
|
|
11
|
+
return s <= .03928 ? s / 12.92 : ((s + .055) / 1.055) ** 2.4;
|
|
12
|
+
}
|
|
13
|
+
function luminanceFromRgb({ r, g, b }) {
|
|
14
|
+
return .2126 * channelLuminance(r) + .7152 * channelLuminance(g) + .0722 * channelLuminance(b);
|
|
15
|
+
}
|
|
16
|
+
function contrastRatio(a, b) {
|
|
17
|
+
const la = luminanceFromRgb(a) + .05;
|
|
18
|
+
const lb = luminanceFromRgb(b) + .05;
|
|
19
|
+
return la > lb ? la / lb : lb / la;
|
|
20
|
+
}
|
|
21
|
+
function wcagLevels(ratio) {
|
|
22
|
+
return {
|
|
23
|
+
AA: ratio >= AA_RATIO,
|
|
24
|
+
AAA: ratio >= 7
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function nextFixLevel(levels) {
|
|
28
|
+
if (!levels.AA) return "AA";
|
|
29
|
+
if (!levels.AAA) return "AAA";
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
function contrastOf(color, background) {
|
|
33
|
+
return contrastRatio(hsvaToRgba(color), background);
|
|
34
|
+
}
|
|
35
|
+
function fixColorForContrast(color, background, target = AA_RATIO) {
|
|
36
|
+
const ok = hsvaToOklcha(color);
|
|
37
|
+
const ratioAtL = (L) => contrastRatio(hsvaToRgba(oklchaToHsva({
|
|
38
|
+
L,
|
|
39
|
+
C: ok.C,
|
|
40
|
+
H: ok.H,
|
|
41
|
+
a: 1
|
|
42
|
+
})), background);
|
|
43
|
+
if (ratioAtL(ok.L) >= target) return null;
|
|
44
|
+
let best = null;
|
|
45
|
+
for (let step = 0; step <= 100; step++) {
|
|
46
|
+
const L = step / 100;
|
|
47
|
+
if (ratioAtL(L) < target) continue;
|
|
48
|
+
const dist = Math.abs(L - ok.L);
|
|
49
|
+
if (!best || dist < best.dist) best = {
|
|
50
|
+
L,
|
|
51
|
+
dist
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const pick = (L) => oklchaToHsva({
|
|
55
|
+
L,
|
|
56
|
+
C: ok.C,
|
|
57
|
+
H: ok.H,
|
|
58
|
+
a: color.a
|
|
59
|
+
});
|
|
60
|
+
if (best) return pick(best.L);
|
|
61
|
+
return ratioAtL(0) >= ratioAtL(1) ? pick(0) : pick(1);
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { AAA_RATIO, AA_RATIO, TARGET_RATIO, contrastOf, contrastRatio, fixColorForContrast, luminanceFromRgb, nextFixLevel, wcagLevels };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/lib/diff.d.ts
|
|
2
|
+
type CodeDiffLineType = "add" | "del" | "context";
|
|
3
|
+
type CodeLineType = CodeDiffLineType;
|
|
4
|
+
type LineDiffType = "word" | "char" | "none";
|
|
5
|
+
type DiffFileType = "change" | "new" | "deleted" | "rename";
|
|
6
|
+
type DiffSegment = {
|
|
7
|
+
text: string;
|
|
8
|
+
emphasis: boolean;
|
|
9
|
+
};
|
|
10
|
+
type DiffLine = {
|
|
11
|
+
type: CodeLineType;
|
|
12
|
+
oldNo?: number;
|
|
13
|
+
newNo?: number;
|
|
14
|
+
text: string;
|
|
15
|
+
segments?: DiffSegment[];
|
|
16
|
+
};
|
|
17
|
+
type DiffHunk = {
|
|
18
|
+
header?: string;
|
|
19
|
+
oldStart: number;
|
|
20
|
+
oldCount: number;
|
|
21
|
+
newStart: number;
|
|
22
|
+
newCount: number;
|
|
23
|
+
lines: DiffLine[];
|
|
24
|
+
collapsedBefore: number;
|
|
25
|
+
};
|
|
26
|
+
type DiffFile = {
|
|
27
|
+
name: string;
|
|
28
|
+
oldName?: string;
|
|
29
|
+
type: DiffFileType;
|
|
30
|
+
lang?: string;
|
|
31
|
+
hunks: DiffHunk[];
|
|
32
|
+
oldLines: string[];
|
|
33
|
+
newLines: string[];
|
|
34
|
+
isPartial: boolean;
|
|
35
|
+
additions: number;
|
|
36
|
+
deletions: number;
|
|
37
|
+
};
|
|
38
|
+
type BuildDiffOptions = {
|
|
39
|
+
name?: string;
|
|
40
|
+
lang?: string;
|
|
41
|
+
context?: number;
|
|
42
|
+
lineDiffType?: LineDiffType;
|
|
43
|
+
maxLineDiffLength?: number;
|
|
44
|
+
};
|
|
45
|
+
declare function computeWordDiff(oldText: string, newText: string, kind: LineDiffType, maxLength: number): [DiffSegment[] | undefined, DiffSegment[] | undefined];
|
|
46
|
+
declare function diffRunEnd(lines: readonly DiffLine[], start: number, type: DiffLine["type"]): number;
|
|
47
|
+
declare function buildDiffFromFiles(oldText: string, newText: string, options?: BuildDiffOptions): DiffFile;
|
|
48
|
+
declare function buildDiffFromPatch(patchText: string, options?: BuildDiffOptions): DiffFile[];
|
|
49
|
+
//#endregion
|
|
50
|
+
export { BuildDiffOptions, CodeDiffLineType, CodeLineType, DiffFile, DiffFileType, DiffHunk, DiffLine, DiffSegment, LineDiffType, buildDiffFromFiles, buildDiffFromPatch, computeWordDiff, diffRunEnd };
|