@kitn.ai/ui 0.17.0 → 0.18.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 +28 -5
- package/dist/components/artifact.d.ts +39 -1
- package/dist/components/attachment-types.d.ts +12 -0
- package/dist/components/attachments.d.ts +2 -10
- package/dist/components/card.d.ts +27 -0
- package/dist/components/chain-of-thought.d.ts +78 -2
- package/dist/components/chat-scope-picker.d.ts +7 -0
- package/dist/components/chat-thread.d.ts +37 -12
- package/dist/components/choice-card.d.ts +26 -0
- package/dist/components/coachmark.d.ts +49 -0
- package/dist/components/composer-dom.d.ts +35 -0
- package/dist/components/composer-highlight.d.ts +48 -0
- package/dist/components/composer-history.d.ts +34 -0
- package/dist/components/composer.d.ts +86 -0
- package/dist/components/confirm-card.d.ts +17 -0
- package/dist/components/conversation-item.d.ts +9 -0
- package/dist/components/conversation-list.d.ts +36 -1
- package/dist/components/file-tree.d.ts +15 -0
- package/dist/components/form.d.ts +34 -0
- package/dist/components/markdown.d.ts +3 -0
- package/dist/components/message.d.ts +12 -0
- package/dist/components/model-switcher.d.ts +7 -0
- package/dist/components/prompt-input.d.ts +13 -4
- package/dist/components/prompt-suggestion.d.ts +9 -1
- package/dist/components/reasoning.d.ts +14 -1
- package/dist/components/response-compare.d.ts +14 -0
- package/dist/components/screen.d.ts +46 -0
- package/dist/components/tasks-card.d.ts +49 -1
- package/dist/components/toast.d.ts +12 -2
- package/dist/components/tool-types.d.ts +10 -0
- package/dist/components/tool.d.ts +8 -8
- package/dist/components/voice-input.d.ts +27 -0
- package/dist/components/voice-output.d.ts +33 -0
- package/dist/core-C8fzo39E.js +12 -0
- package/dist/custom-elements.json +8392 -1860
- package/dist/elements/agent-card.d.ts +1 -0
- package/dist/elements/agent-card.js +1 -0
- package/dist/elements/artifact.js +1 -1
- package/dist/elements/attachments.js +1 -1
- package/dist/elements/autoloader.js +1 -1
- package/dist/elements/avatar.d.ts +1 -0
- package/dist/elements/avatar.js +1 -0
- package/dist/elements/badge.d.ts +1 -0
- package/dist/elements/badge.js +1 -0
- package/dist/elements/button.d.ts +1 -0
- package/dist/elements/button.js +1 -0
- package/dist/elements/card.js +1 -1
- package/dist/elements/cards.js +1 -1
- package/dist/elements/chain-of-thought.js +1 -1
- package/dist/elements/chat-scope-picker.js +1 -1
- package/dist/elements/chat-types.d.ts +47 -0
- package/dist/elements/chat-workspace.js +1 -1
- package/dist/elements/chat.js +1 -1
- package/dist/elements/checkpoint.js +1 -1
- package/dist/elements/choice.js +1 -1
- package/dist/elements/chunks/Icon-DLLBeLG5.js +1 -0
- package/dist/elements/chunks/action-icons-UB4V5FNq.js +1 -0
- package/dist/elements/chunks/arrow-left-C-gwlUmx.js +1 -0
- package/dist/elements/chunks/attachments-CgbErf1r.js +1 -0
- package/dist/elements/chunks/badge-DTQpgB6N.js +1 -0
- package/dist/elements/chunks/button-XDUM6lXs.js +1 -0
- package/dist/elements/chunks/card-CBlFZ-7I.js +1 -0
- package/dist/elements/chunks/chat-thread-BIhmqwNL.js +1 -0
- package/dist/elements/chunks/check-hGUoVIKb.js +1 -0
- package/dist/elements/chunks/chevron-down-DDoaSUtO.js +1 -0
- package/dist/elements/chunks/chevron-right-CdGEUakB.js +1 -0
- package/dist/elements/chunks/circle-BKAZdmzb.js +1 -0
- package/dist/elements/chunks/circle-check-CmYG-y3I.js +1 -0
- package/dist/elements/chunks/circle-x-DewgAEym.js +1 -0
- package/dist/elements/chunks/cn-CU7UAWzk.js +1 -0
- package/dist/elements/chunks/code-block-DedwxwFI.js +1 -0
- package/dist/elements/chunks/collapsible-FfgmTHtM.js +1 -0
- package/dist/elements/chunks/composer-Cfbw5HKT.js +65 -0
- package/dist/elements/chunks/context-DwJmxlRE.js +1 -0
- package/dist/elements/chunks/conversation-list-DsCQMfPq.js +1 -0
- package/dist/elements/chunks/default-input-BuqsoENC.js +1 -0
- package/dist/elements/chunks/define-rGsaWsLL.js +1 -0
- package/dist/elements/chunks/disclosure-CwoAkpMH.js +1 -0
- package/dist/elements/chunks/download-DJ06G3Bz.js +1 -0
- package/dist/elements/chunks/dropdown-BFg8ri_R.js +1 -0
- package/dist/elements/chunks/ellipsis-dlN6YvGw.js +1 -0
- package/dist/elements/chunks/external-link-DBX2lc_R.js +1 -0
- package/dist/elements/chunks/file-text-HfwUx4F9.js +1 -0
- package/dist/elements/chunks/file-tree-C6Toj71u.js +1 -0
- package/dist/elements/chunks/folder-MYuqa9Xp.js +1 -0
- package/dist/elements/chunks/hover-card-gE7iyXdW.js +1 -0
- package/dist/elements/chunks/icon-Vqz4ivrY.js +1 -0
- package/dist/elements/chunks/{index-CTBEJeo6.js → index-BCRhi84a.js} +1 -1
- package/dist/elements/chunks/info-B_toFS0l.js +1 -0
- package/dist/elements/chunks/input-gzbHYZvQ.js +1 -0
- package/dist/elements/chunks/kbd-n49c4KZm.js +1 -0
- package/dist/elements/chunks/link-CKPs9yM0.js +1 -0
- package/dist/elements/chunks/loader-q6MamGus.js +1 -0
- package/dist/elements/chunks/{markdown-CMTGx9r8.js → markdown-DBrcqq4S.js} +9 -9
- package/dist/elements/chunks/message-CTqaYI0s.js +1 -0
- package/dist/elements/chunks/message-feedback-Cvzm03w0.js +1 -0
- package/dist/elements/chunks/message-square-CUg9eRCi.js +1 -0
- package/dist/elements/chunks/minimize-2-l2klxP6K.js +1 -0
- package/dist/elements/chunks/model-switcher-CmyjiHO1.js +1 -0
- package/dist/elements/chunks/overlay-C8sOYqjT.js +1 -0
- package/dist/elements/chunks/paperclip-42Ia7xHD.js +1 -0
- package/dist/elements/chunks/progress-bar-tzKMWAwO.js +1 -0
- package/dist/elements/chunks/prompt-suggestion-D3F6vP_A.js +1 -0
- package/dist/elements/chunks/reasoning-BJNmmyov.js +1 -0
- package/dist/elements/chunks/resizable-BRsk19qI.js +1 -0
- package/dist/elements/chunks/rotate-cw-BgcggLHC.js +1 -0
- package/dist/elements/chunks/scroll-area-CgGbFFbT.js +1 -0
- package/dist/elements/chunks/separator-8hM4GdHE.js +1 -0
- package/dist/elements/chunks/settings-CaUIYOg-.js +1 -0
- package/dist/elements/chunks/settings-group-CYjOVIZQ.js +1 -0
- package/dist/elements/chunks/share-BTYM3Ddt.js +1 -0
- package/dist/elements/chunks/skeleton-DsTYrPUe.js +1 -0
- package/dist/elements/chunks/slots-DkZ-Cmha.js +1 -0
- package/dist/elements/chunks/star-9R3LBQ9n.js +1 -0
- package/dist/elements/chunks/store-CYl5Y0_u.js +1 -0
- package/dist/elements/chunks/text-shimmer-CaYGv8Se.js +1 -0
- package/dist/elements/chunks/textarea-NEr2SLcD.js +1 -0
- package/dist/elements/chunks/thumbs-up-DZYZkFfc.js +1 -0
- package/dist/elements/chunks/toast-store-ClxVZRcc.js +1 -0
- package/dist/elements/chunks/tool-CHZOmoe9.js +1 -0
- package/dist/elements/chunks/tooltip-WpHElELC.js +1 -0
- package/dist/elements/chunks/triangle-alert-BlS80PUg.js +1 -0
- package/dist/elements/chunks/use-card-resolution-VSVoxDeJ.js +1 -0
- package/dist/elements/chunks/video-DxTPZqT8.js +1 -0
- package/dist/elements/chunks/x-C1qtndxn.js +1 -0
- package/dist/elements/coachmark.d.ts +1 -0
- package/dist/elements/coachmark.js +1 -0
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command.d.ts +1 -0
- package/dist/elements/command.js +1 -0
- package/dist/elements/compare.js +1 -1
- package/dist/elements/composer.d.ts +1 -0
- package/dist/elements/composer.js +1 -0
- package/dist/elements/confirm-card.js +1 -1
- package/dist/elements/context-meter.js +1 -1
- package/dist/elements/conversation-list.js +1 -1
- package/dist/elements/css.d.ts +1 -0
- package/dist/elements/default-input.d.ts +51 -0
- package/dist/elements/define.d.ts +53 -0
- package/dist/elements/dialog.d.ts +1 -0
- package/dist/elements/dialog.js +1 -0
- package/dist/elements/disclosure.d.ts +37 -0
- package/dist/elements/editable-label.d.ts +1 -0
- package/dist/elements/editable-label.js +1 -0
- package/dist/elements/embed.js +1 -1
- package/dist/elements/empty.js +1 -1
- package/dist/elements/feedback-bar.js +1 -1
- package/dist/elements/file-tree.js +1 -1
- package/dist/elements/file-upload.js +1 -1
- package/dist/elements/form.js +1 -1
- package/dist/elements/hover-card.d.ts +1 -0
- package/dist/elements/hover-card.js +1 -0
- package/dist/elements/icon.d.ts +1 -0
- package/dist/elements/icon.js +1 -0
- package/dist/elements/image.js +1 -1
- package/dist/elements/input.d.ts +1 -0
- package/dist/elements/input.js +1 -0
- package/dist/elements/kbd.d.ts +1 -0
- package/dist/elements/kbd.js +1 -0
- package/dist/elements/link-preview.js +1 -1
- package/dist/elements/loader.js +1 -1
- package/dist/elements/markdown.js +1 -1
- package/dist/elements/menu.d.ts +1 -0
- package/dist/elements/menu.js +1 -0
- package/dist/elements/message-skills.js +1 -1
- package/dist/elements/message.js +1 -1
- package/dist/elements/model-switcher.js +1 -1
- package/dist/elements/nav.d.ts +1 -0
- package/dist/elements/nav.js +1 -0
- package/dist/elements/notice.d.ts +1 -0
- package/dist/elements/notice.js +1 -0
- package/dist/elements/pane-group.d.ts +1 -0
- package/dist/elements/pane-group.js +1 -0
- package/dist/elements/pane.d.ts +1 -0
- package/dist/elements/pane.js +1 -0
- package/dist/elements/popover.js +1 -1
- package/dist/elements/progress-bar.d.ts +1 -0
- package/dist/elements/progress-bar.js +1 -0
- package/dist/elements/prompt-dock.d.ts +1 -0
- package/dist/elements/prompt-dock.js +1 -0
- package/dist/elements/prompt-input.js +1 -1
- package/dist/elements/prompt-suggestions.js +1 -1
- package/dist/elements/reasoning.js +1 -1
- package/dist/elements/register-impl.d.ts +0 -0
- package/dist/elements/register.d.ts +13 -0
- package/dist/elements/remote.d.ts +1 -0
- package/dist/elements/remote.js +1 -0
- package/dist/elements/resizable.js +1 -1
- package/dist/elements/response-stream.js +2 -2
- package/dist/elements/screen.d.ts +1 -0
- package/dist/elements/screen.js +1 -0
- package/dist/elements/scroll-area.d.ts +1 -0
- package/dist/elements/scroll-area.js +1 -0
- package/dist/elements/scroll-button.js +1 -1
- package/dist/elements/search.d.ts +1 -0
- package/dist/elements/search.js +1 -0
- package/dist/elements/segmented.d.ts +1 -0
- package/dist/elements/segmented.js +1 -0
- package/dist/elements/separator.d.ts +1 -0
- package/dist/elements/separator.js +1 -0
- package/dist/elements/setting-item.d.ts +1 -0
- package/dist/elements/setting-item.js +1 -0
- package/dist/elements/settings-group.d.ts +1 -0
- package/dist/elements/settings-group.js +1 -0
- package/dist/elements/skeleton.d.ts +1 -0
- package/dist/elements/skeleton.js +1 -0
- package/dist/elements/slots.d.ts +176 -0
- package/dist/elements/source.js +1 -1
- package/dist/elements/status.d.ts +1 -0
- package/dist/elements/status.js +1 -0
- package/dist/elements/switch.js +1 -1
- package/dist/elements/tabs.d.ts +1 -0
- package/dist/elements/tabs.js +1 -0
- package/dist/elements/tasks.js +1 -1
- package/dist/elements/text-shimmer.js +1 -1
- package/dist/elements/thinking-bar.js +1 -1
- package/dist/elements/toast.js +1 -1
- package/dist/elements/tool.js +1 -1
- package/dist/elements/tooltip.d.ts +1 -0
- package/dist/elements/tooltip.js +1 -0
- package/dist/elements/voice-input.js +1 -1
- package/dist/elements/voice-output.d.ts +1 -0
- package/dist/elements/voice-output.js +1 -0
- package/dist/elements.d.ts +733 -58
- package/dist/engine-javascript-C1x7zo1_.js +141 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +8256 -5703
- package/dist/kai.es.js +1 -0
- package/dist/llms/llms-full.txt +1146 -64
- package/dist/llms/llms.txt +4 -4
- package/dist/mcp.es.js +62 -7
- package/dist/primitives/composer-model.d.ts +22 -0
- package/dist/primitives/composer-triggers.d.ts +19 -0
- package/dist/primitives/create-kai-chat.d.ts +38 -0
- package/dist/primitives/toast-store.d.ts +32 -2
- package/dist/primitives/use-speech-recognition.d.ts +26 -0
- package/dist/react/index.d.ts +1085 -97
- package/dist/react/runtime.d.ts +9 -2
- package/dist/react/use-kai-chat.d.ts +41 -0
- package/dist/react.js +572 -193
- package/dist/register-impl-CYWGkgbI.js +141 -0
- package/dist/schemas/tasks.schema.json +2 -2
- package/dist/state/index.d.ts +4 -0
- package/dist/state/messages.d.ts +11 -0
- package/dist/state/stream.d.ts +22 -0
- package/dist/state/suggestions.d.ts +4 -0
- package/dist/state.js +117 -0
- package/dist/theme.tokens.css +87 -0
- package/dist/types.d.ts +4 -0
- package/dist/ui/agent-card.d.ts +61 -0
- package/dist/ui/button.d.ts +5 -2
- package/dist/ui/card.d.ts +61 -0
- package/dist/ui/collapsible.d.ts +15 -1
- package/dist/ui/command.d.ts +33 -0
- package/dist/ui/dialog.d.ts +42 -0
- package/dist/ui/dropdown.d.ts +95 -1
- package/dist/ui/editable-label.d.ts +26 -0
- package/dist/ui/hover-card.d.ts +13 -1
- package/dist/ui/icon.d.ts +18 -0
- package/dist/ui/input.d.ts +33 -0
- package/dist/ui/kbd.d.ts +21 -0
- package/dist/ui/nav.d.ts +62 -0
- package/dist/ui/notice.d.ts +31 -0
- package/dist/ui/overlay.d.ts +12 -0
- package/dist/ui/pane-grid.d.ts +58 -0
- package/dist/ui/pane-group.d.ts +75 -0
- package/dist/ui/pane.d.ts +78 -0
- package/dist/ui/popover.d.ts +11 -1
- package/dist/ui/progress-bar.d.ts +23 -0
- package/dist/ui/prompt-dock.d.ts +96 -0
- package/dist/ui/resizable.d.ts +12 -0
- package/dist/ui/scroll-area.d.ts +4 -0
- package/dist/ui/segmented.d.ts +28 -0
- package/dist/ui/settings-group.d.ts +32 -0
- package/dist/ui/skeleton.d.ts +12 -0
- package/dist/ui/stat.d.ts +16 -0
- package/dist/ui/status.d.ts +13 -0
- package/dist/ui/switch.d.ts +8 -1
- package/dist/ui/tabs.d.ts +35 -0
- package/dist/ui/tooltip.d.ts +19 -1
- package/frameworks/react/index.tsx +1042 -157
- package/frameworks/react/runtime.tsx +30 -1
- package/frameworks/react/use-kai-chat.tsx +87 -0
- package/llms-full.txt +1146 -64
- package/llms.txt +4 -4
- package/package.json +23 -8
- package/src/agent-tooling/mcp/manifest.ts +14 -0
- package/src/agent-tooling/mcp/tools/debug.ts +10 -6
- package/src/agent-tooling/mcp/tools/reference.ts +32 -0
- package/src/agent-tooling/mcp/tools/scaffold.ts +30 -1
- package/src/components/artifact.tsx +98 -13
- package/src/components/attachment-types.ts +13 -0
- package/src/components/attachments.tsx +4 -14
- package/src/components/card.tsx +109 -15
- package/src/components/chain-of-thought.tsx +210 -1
- package/src/components/chat-scope-picker.tsx +13 -3
- package/src/components/chat-thread.tsx +225 -116
- package/src/components/choice-card.tsx +103 -11
- package/src/components/coachmark.tsx +245 -0
- package/src/components/component-meta.json +691 -102
- package/src/components/composer-dom.ts +159 -0
- package/src/components/composer-highlight.ts +242 -0
- package/src/components/composer-history.ts +82 -0
- package/src/components/composer.tsx +979 -0
- package/src/components/confirm-card.tsx +54 -1
- package/src/components/conversation-item.tsx +69 -7
- package/src/components/conversation-list.tsx +134 -37
- package/src/components/file-tree.tsx +197 -47
- package/src/components/form-widgets.tsx +9 -7
- package/src/components/form.tsx +140 -17
- package/src/components/image.tsx +3 -5
- package/src/components/link-preview.tsx +5 -4
- package/src/components/markdown.tsx +5 -2
- package/src/components/message.tsx +23 -4
- package/src/components/model-switcher.tsx +19 -4
- package/src/components/prompt-input.tsx +46 -75
- package/src/components/prompt-suggestion.tsx +48 -16
- package/src/components/reasoning.tsx +29 -6
- package/src/components/response-compare.tsx +31 -2
- package/src/components/screen.tsx +176 -0
- package/src/components/tasks-card.tsx +342 -21
- package/src/components/toast.tsx +119 -31
- package/src/components/tool-types.ts +10 -0
- package/src/components/tool.tsx +22 -16
- package/src/components/voice-input.tsx +102 -19
- package/src/components/voice-output.tsx +202 -0
- package/src/elements/agent-card.tsx +67 -0
- package/src/elements/artifact.tsx +53 -4
- package/src/elements/attachments.tsx +1 -0
- package/src/elements/avatar.tsx +33 -0
- package/src/elements/badge.tsx +32 -0
- package/src/elements/button.tsx +126 -0
- package/src/elements/card-media.jpg +0 -0
- package/src/elements/card.tsx +124 -31
- package/src/elements/cards.tsx +81 -7
- package/src/elements/chain-of-thought.tsx +77 -32
- package/src/elements/chat-scope-picker.tsx +35 -8
- package/src/elements/chat-types.ts +2 -2
- package/src/elements/chat-workspace.tsx +153 -41
- package/src/elements/chat.tsx +45 -23
- package/src/elements/choice.tsx +71 -19
- package/src/elements/coachmark.tsx +90 -0
- package/src/elements/command.tsx +209 -0
- package/src/elements/compare.tsx +24 -2
- package/src/elements/compiled.css +1 -1
- package/src/elements/composer.tsx +151 -0
- package/src/elements/confirm-card.tsx +36 -11
- package/src/elements/conversation-list.tsx +80 -11
- package/src/elements/default-input.tsx +75 -53
- package/src/elements/define.tsx +47 -6
- package/src/elements/dialog.tsx +98 -0
- package/src/elements/disclosure.ts +73 -0
- package/src/elements/editable-label.tsx +125 -0
- package/src/elements/element-manifest.json +129 -1
- package/src/elements/element-meta.json +5562 -1336
- package/src/elements/element-types.d.ts +732 -57
- package/src/elements/file-tree.tsx +12 -2
- package/src/elements/file-upload.tsx +1 -1
- package/src/elements/form.tsx +54 -11
- package/src/elements/hover-card.tsx +80 -0
- package/src/elements/icon-names.json +48 -0
- package/src/elements/icon.tsx +41 -0
- package/src/elements/input.tsx +203 -0
- package/src/elements/kbd.tsx +45 -0
- package/src/elements/menu.tsx +217 -0
- package/src/elements/message.tsx +58 -11
- package/src/elements/model-switcher.tsx +27 -1
- package/src/elements/nav.tsx +87 -0
- package/src/elements/notice.tsx +53 -0
- package/src/elements/pane-group.tsx +119 -0
- package/src/elements/pane.tsx +129 -0
- package/src/elements/popover.tsx +39 -17
- package/src/elements/progress-bar.tsx +39 -0
- package/src/elements/prompt-dock.tsx +81 -0
- package/src/elements/prompt-input.tsx +112 -63
- package/src/elements/prompt-suggestions.tsx +25 -9
- package/src/elements/reasoning.tsx +30 -9
- package/src/elements/register-impl.ts +38 -3
- package/src/elements/register.ts +11 -3
- package/src/elements/resizable.tsx +48 -11
- package/src/elements/screen.tsx +90 -0
- package/src/elements/scroll-area.tsx +33 -0
- package/src/elements/search.tsx +180 -0
- package/src/elements/segmented.tsx +135 -0
- package/src/elements/separator.tsx +36 -0
- package/src/elements/setting-item.tsx +50 -0
- package/src/elements/settings-group.tsx +37 -0
- package/src/elements/skeleton.tsx +45 -0
- package/src/elements/slots.ts +607 -0
- package/src/elements/source.tsx +13 -6
- package/src/elements/status.tsx +42 -0
- package/src/elements/switch.tsx +89 -14
- package/src/elements/tabs.tsx +95 -0
- package/src/elements/tasks.tsx +70 -14
- package/src/elements/toast.tsx +17 -2
- package/src/elements/tool.tsx +43 -9
- package/src/elements/tooltip.tsx +85 -0
- package/src/elements/video-poster.jpg +0 -0
- package/src/elements/voice-input.tsx +66 -16
- package/src/elements/voice-output.tsx +69 -0
- package/src/index.ts +5 -2
- package/src/primitives/card-schemas/tasks.schema.json +2 -2
- package/src/primitives/composer-model.ts +49 -0
- package/src/primitives/composer-triggers.ts +35 -0
- package/src/primitives/create-kai-chat.ts +66 -0
- package/src/primitives/toast-store.ts +43 -2
- package/src/primitives/use-speech-recognition.ts +135 -0
- package/src/state/index.ts +6 -0
- package/src/state/messages.ts +36 -0
- package/src/state/stream.ts +92 -0
- package/src/state/suggestions.ts +9 -0
- package/src/types.ts +4 -0
- package/src/ui/agent-card.tsx +212 -0
- package/src/ui/button.tsx +16 -5
- package/src/ui/card.tsx +245 -0
- package/src/ui/collapsible.tsx +30 -4
- package/src/ui/command.tsx +99 -0
- package/src/ui/dialog.tsx +217 -0
- package/src/ui/dropdown.tsx +375 -13
- package/src/ui/editable-label.tsx +112 -0
- package/src/ui/hover-card.tsx +28 -5
- package/src/ui/icon.tsx +110 -0
- package/src/ui/input.tsx +132 -0
- package/src/ui/kbd.tsx +118 -0
- package/src/ui/nav.tsx +282 -0
- package/src/ui/notice.tsx +84 -0
- package/src/ui/overlay.tsx +108 -2
- package/src/ui/pane-grid.tsx +116 -0
- package/src/ui/pane-group.tsx +280 -0
- package/src/ui/pane.tsx +193 -0
- package/src/ui/popover.tsx +16 -2
- package/src/ui/progress-bar.tsx +83 -0
- package/src/ui/prompt-dock.tsx +145 -0
- package/src/ui/resizable.tsx +69 -1
- package/src/ui/scroll-area.tsx +14 -3
- package/src/ui/segmented.tsx +109 -0
- package/src/ui/settings-group.tsx +67 -0
- package/src/ui/skeleton.tsx +62 -5
- package/src/ui/stat.tsx +41 -0
- package/src/ui/status.tsx +48 -0
- package/src/ui/switch.tsx +49 -23
- package/src/ui/tabs.tsx +168 -0
- package/src/ui/tooltip.tsx +52 -8
- package/theme.css +113 -0
- package/dist/components/slash-command.d.ts +0 -15
- package/dist/elements/chunks/Icon-D_Zmwmwh.js +0 -1
- package/dist/elements/chunks/action-icons-PVfIvcuG.js +0 -1
- package/dist/elements/chunks/attachments-Dp6vqtrc.js +0 -1
- package/dist/elements/chunks/button-CKyYD9G4.js +0 -1
- package/dist/elements/chunks/card-Cjho-PYk.js +0 -1
- package/dist/elements/chunks/chat-thread-RT808iPf.js +0 -1
- package/dist/elements/chunks/check-CDYaMYrM.js +0 -1
- package/dist/elements/chunks/chevron-down-3SBiq8HF.js +0 -1
- package/dist/elements/chunks/chevron-right-k2UFlIVK.js +0 -1
- package/dist/elements/chunks/cn-Dogu6PbV.js +0 -1
- package/dist/elements/chunks/code-block-BYUmfFSd.js +0 -1
- package/dist/elements/chunks/collapsible-BiNwdOn6.js +0 -1
- package/dist/elements/chunks/context-18g6oi4J.js +0 -1
- package/dist/elements/chunks/conversation-list-D9Y0NVdo.js +0 -1
- package/dist/elements/chunks/default-input-CSAoYYMd.js +0 -1
- package/dist/elements/chunks/download-D8K0Je8r.js +0 -1
- package/dist/elements/chunks/dropdown-bUs2iTia.js +0 -1
- package/dist/elements/chunks/external-link-6mA0wxab.js +0 -1
- package/dist/elements/chunks/file-text-DnaYk3Dm.js +0 -1
- package/dist/elements/chunks/file-tree-CgtRLlxK.js +0 -1
- package/dist/elements/chunks/hover-card-CIGw62gP.js +0 -1
- package/dist/elements/chunks/link-BlGSeoPy.js +0 -1
- package/dist/elements/chunks/loader-DvhR4qa0.js +0 -1
- package/dist/elements/chunks/message-CDZwXjhL.js +0 -1
- package/dist/elements/chunks/message-feedback-CYx81QiA.js +0 -1
- package/dist/elements/chunks/model-switcher-O_tUhoOT.js +0 -1
- package/dist/elements/chunks/overlay-DydXYMQW.js +0 -1
- package/dist/elements/chunks/prompt-suggestion-ldlWV5kd.js +0 -1
- package/dist/elements/chunks/reasoning-2PUnHlmr.js +0 -1
- package/dist/elements/chunks/resizable-B5WNbSeb.js +0 -1
- package/dist/elements/chunks/star-t9tI-P0q.js +0 -1
- package/dist/elements/chunks/store-C6rIooZz.js +0 -1
- package/dist/elements/chunks/text-shimmer-uh9V_KUh.js +0 -1
- package/dist/elements/chunks/textarea-3nm6Ia9U.js +0 -1
- package/dist/elements/chunks/thumbs-up-BBtguGld.js +0 -1
- package/dist/elements/chunks/toast-store-D8cL3fWl.js +0 -1
- package/dist/elements/chunks/tool-GJ3vwp1U.js +0 -1
- package/dist/elements/chunks/tooltip-DwKAz4XR.js +0 -1
- package/dist/elements/chunks/triangle-alert-Ct1zt2JL.js +0 -1
- package/dist/elements/chunks/use-card-resolution-D-_0Alzy.js +0 -1
- package/dist/elements/chunks/video-mVYiM99-.js +0 -1
- package/dist/elements/chunks/x-CzxL27Ch.js +0 -1
- package/dist/kitn-chat.es.js +0 -1
- package/dist/register-JyTglR6m.js +0 -1
- package/dist/register-impl-C6wlSsts.js +0 -77
- package/src/components/slash-command.tsx +0 -232
- package/src/elements/framework-usage.json +0 -588
- /package/dist/{kitn-chat-provider.d.ts → kai-provider.d.ts} +0 -0
- /package/dist/{kitn-chat-provider.es.js → kai-provider.es.js} +0 -0
package/src/ui/dropdown.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createContext, useContext, createSignal, createUniqueId, Show,
|
|
2
|
+
createContext, useContext, createSignal, createUniqueId, Show, onCleanup, splitProps,
|
|
3
3
|
type JSX, type Accessor,
|
|
4
4
|
} from 'solid-js';
|
|
5
5
|
import { Portal } from 'solid-js/web';
|
|
6
|
+
import { ChevronRight, Check } from 'lucide-solid';
|
|
6
7
|
import { cn } from '../utils/cn';
|
|
7
8
|
import { useChatConfig } from '../primitives/chat-config';
|
|
8
9
|
import { createPresence, usePosition, useDismiss, As, type AsTag } from './overlay';
|
|
@@ -17,6 +18,11 @@ interface DropdownCtx {
|
|
|
17
18
|
trigger: Accessor<HTMLElement | undefined>;
|
|
18
19
|
menu: Accessor<HTMLElement | undefined>;
|
|
19
20
|
openedViaKeyboard: Accessor<boolean>;
|
|
21
|
+
/** Register a portaled submenu surface so outside-click dismissal treats it as
|
|
22
|
+
* "inside" the menu tree (sub content lives in a sibling portal, not the menu DOM). */
|
|
23
|
+
registerSubMenu: (el: HTMLElement) => () => void;
|
|
24
|
+
/** Currently-mounted submenu surfaces, for the dismiss "inside" test. */
|
|
25
|
+
subMenus: Accessor<HTMLElement[]>;
|
|
20
26
|
}
|
|
21
27
|
const Ctx = createContext<DropdownCtx>();
|
|
22
28
|
const useDropdown = () => {
|
|
@@ -25,12 +31,37 @@ const useDropdown = () => {
|
|
|
25
31
|
return c;
|
|
26
32
|
};
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
// The roving-focus set: real menuitems AND checkbox/radio items, minus disabled.
|
|
35
|
+
// A DropdownSubTrigger is a menuitem too, so it participates. Labels/separators
|
|
36
|
+
// are intentionally excluded. Submenu content is portaled to a SIBLING node, so
|
|
37
|
+
// a parent's querySelectorAll scoped to its own menu never reaches sub items.
|
|
38
|
+
const ITEM_SELECTOR = '[role="menuitem"]:not([aria-disabled="true"]), [role="menuitemcheckbox"]:not([aria-disabled="true"]), [role="menuitemradio"]:not([aria-disabled="true"])';
|
|
39
|
+
|
|
40
|
+
/** Imperative open controller, handed to a parent (e.g. the kai-menu facade) via
|
|
41
|
+
* `controllerRef` so it can drive/observe the Dropdown's open state. */
|
|
42
|
+
export interface DropdownController { open: Accessor<boolean>; setOpen: (v: boolean) => void; }
|
|
43
|
+
|
|
44
|
+
export function Dropdown(props: {
|
|
45
|
+
children: JSX.Element;
|
|
46
|
+
/** Initial open state (uncontrolled seed). */
|
|
47
|
+
defaultOpen?: boolean;
|
|
48
|
+
/** When true, the trigger never opens the menu. */
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
/** Receive the open controller (open accessor + setOpen) once mounted. */
|
|
51
|
+
controllerRef?: (api: DropdownController) => void;
|
|
52
|
+
}) {
|
|
53
|
+
const [open, setOpenSig] = createSignal(props.defaultOpen ?? false);
|
|
30
54
|
const [viaKb, setViaKb] = createSignal(false);
|
|
31
55
|
const [trigger, setTrigger] = createSignal<HTMLElement>();
|
|
32
56
|
const [menu, setMenu] = createSignal<HTMLElement>();
|
|
57
|
+
const [subMenus, setSubMenus] = createSignal<HTMLElement[]>([]);
|
|
58
|
+
const registerSubMenu = (el: HTMLElement) => {
|
|
59
|
+
setSubMenus((prev) => [...prev, el]);
|
|
60
|
+
return () => setSubMenus((prev) => prev.filter((m) => m !== el));
|
|
61
|
+
};
|
|
33
62
|
const setOpen = (v: boolean, opts?: { viaKeyboard?: boolean; returnFocus?: boolean }) => {
|
|
63
|
+
// Gate opening while disabled; closing always works.
|
|
64
|
+
if (v && props.disabled) return;
|
|
34
65
|
setViaKb(!!opts?.viaKeyboard);
|
|
35
66
|
setOpenSig(v);
|
|
36
67
|
if (v) {
|
|
@@ -38,9 +69,8 @@ export function Dropdown(props: { children: JSX.Element }) {
|
|
|
38
69
|
// attempt focus now and re-assert in the menu ref's microtask so it lands
|
|
39
70
|
// once the node exists. Skip disabled items (roving-focus contract).
|
|
40
71
|
if (opts?.viaKeyboard) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
menu()?.querySelector<HTMLElement>(sel)?.focus();
|
|
72
|
+
queueMicrotask(() => menu()?.querySelector<HTMLElement>(ITEM_SELECTOR)?.focus());
|
|
73
|
+
menu()?.querySelector<HTMLElement>(ITEM_SELECTOR)?.focus();
|
|
44
74
|
}
|
|
45
75
|
} else if (opts?.returnFocus !== false) {
|
|
46
76
|
// Closing via keyboard/select: return focus to the trigger. The menu
|
|
@@ -51,10 +81,14 @@ export function Dropdown(props: { children: JSX.Element }) {
|
|
|
51
81
|
queueMicrotask(() => el?.focus());
|
|
52
82
|
}
|
|
53
83
|
};
|
|
84
|
+
// Hand the open controller up to a facade (e.g. kai-menu) so it can drive +
|
|
85
|
+
// observe open state via wireDisclosure. Mirrors HoverCardRoot.controllerRef.
|
|
86
|
+
props.controllerRef?.({ open, setOpen: (v: boolean) => setOpen(v) });
|
|
54
87
|
return (
|
|
55
88
|
<Ctx.Provider value={{
|
|
56
89
|
open, setOpen, triggerId: createUniqueId(), menuId: createUniqueId(),
|
|
57
90
|
setTrigger, setMenu, trigger, menu, openedViaKeyboard: viaKb,
|
|
91
|
+
registerSubMenu, subMenus,
|
|
58
92
|
}}>
|
|
59
93
|
{props.children}
|
|
60
94
|
</Ctx.Provider>
|
|
@@ -63,6 +97,10 @@ export function Dropdown(props: { children: JSX.Element }) {
|
|
|
63
97
|
|
|
64
98
|
export function DropdownTrigger(props: { as?: AsTag; children?: JSX.Element; class?: string; [k: string]: any }) {
|
|
65
99
|
const ctx = useDropdown();
|
|
100
|
+
// Forward extra attributes (e.g. aria-label for an icon-only trigger). The
|
|
101
|
+
// controlled wiring below (id/aria-*/onClick/onKeyDown/class/type) is applied
|
|
102
|
+
// AFTER the spread so it always wins over a caller-supplied duplicate.
|
|
103
|
+
const [, rest] = splitProps(props, ['as', 'children', 'class']);
|
|
66
104
|
const onKeyDown = (e: KeyboardEvent) => {
|
|
67
105
|
if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Enter' || e.key === ' ') {
|
|
68
106
|
e.preventDefault();
|
|
@@ -72,6 +110,7 @@ export function DropdownTrigger(props: { as?: AsTag; children?: JSX.Element; cla
|
|
|
72
110
|
return (
|
|
73
111
|
<As
|
|
74
112
|
as={props.as ?? 'button'}
|
|
113
|
+
{...rest}
|
|
75
114
|
ref={ctx.setTrigger}
|
|
76
115
|
id={ctx.triggerId}
|
|
77
116
|
aria-haspopup="menu"
|
|
@@ -91,14 +130,22 @@ export function DropdownContent(props: { children: JSX.Element; class?: string }
|
|
|
91
130
|
const ctx = useDropdown();
|
|
92
131
|
const config = useChatConfig();
|
|
93
132
|
const presence = createPresence(ctx.open);
|
|
94
|
-
const position = usePosition(ctx.trigger, ctx.menu, {
|
|
133
|
+
const position = usePosition(ctx.trigger, ctx.menu, {
|
|
134
|
+
placement: 'bottom-start',
|
|
135
|
+
gutter: 6,
|
|
136
|
+
// Trigger removed from the DOM -> close (no focus return; it's gone) so the
|
|
137
|
+
// menu portal doesn't orphan.
|
|
138
|
+
onDisconnect: () => ctx.setOpen(false, { returnFocus: false }),
|
|
139
|
+
});
|
|
95
140
|
useDismiss({
|
|
96
141
|
enabled: ctx.open,
|
|
97
142
|
onDismiss: (reason) => ctx.setOpen(false, { returnFocus: reason === 'escape' }),
|
|
98
|
-
|
|
143
|
+
// Open submenus portal to a sibling node, so include them as "inside" — a
|
|
144
|
+
// click on a sub item must not be treated as an outside dismiss.
|
|
145
|
+
refs: () => [ctx.trigger(), ctx.menu(), ...ctx.subMenus()],
|
|
99
146
|
});
|
|
100
147
|
|
|
101
|
-
const items = () => Array.from(ctx.menu()?.querySelectorAll<HTMLElement>(
|
|
148
|
+
const items = () => Array.from(ctx.menu()?.querySelectorAll<HTMLElement>(ITEM_SELECTOR) ?? []);
|
|
102
149
|
const focusIndex = (i: number) => {
|
|
103
150
|
const list = items();
|
|
104
151
|
if (!list.length) return;
|
|
@@ -145,7 +192,7 @@ export function DropdownContent(props: { children: JSX.Element; class?: string }
|
|
|
145
192
|
// synchronously; this ref-time microtask re-asserts focus once the
|
|
146
193
|
// menu node exists. Skip disabled items.
|
|
147
194
|
if (ctx.openedViaKeyboard()) {
|
|
148
|
-
queueMicrotask(() => el.querySelector<HTMLElement>(
|
|
195
|
+
queueMicrotask(() => el.querySelector<HTMLElement>(ITEM_SELECTOR)?.focus());
|
|
149
196
|
}
|
|
150
197
|
}}
|
|
151
198
|
id={ctx.menuId}
|
|
@@ -174,23 +221,338 @@ export function DropdownContent(props: { children: JSX.Element; class?: string }
|
|
|
174
221
|
);
|
|
175
222
|
}
|
|
176
223
|
|
|
177
|
-
export function DropdownItem(props: { children: JSX.Element; class?: string; onSelect?: () => void }) {
|
|
224
|
+
export function DropdownItem(props: { children: JSX.Element; class?: string; onSelect?: () => void; disabled?: boolean }) {
|
|
178
225
|
const ctx = useDropdown();
|
|
179
|
-
const activate = () => {
|
|
226
|
+
const activate = () => {
|
|
227
|
+
if (props.disabled) return;
|
|
228
|
+
props.onSelect?.();
|
|
229
|
+
ctx.setOpen(false);
|
|
230
|
+
};
|
|
180
231
|
return (
|
|
181
232
|
<div
|
|
182
233
|
role="menuitem"
|
|
183
234
|
tabindex={-1}
|
|
235
|
+
aria-disabled={props.disabled ? 'true' : undefined}
|
|
184
236
|
onClick={activate}
|
|
185
237
|
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); activate(); } }}
|
|
186
|
-
onPointerMove={(e) => (e.currentTarget as HTMLElement).focus()}
|
|
238
|
+
onPointerMove={(e) => { if (!props.disabled) (e.currentTarget as HTMLElement).focus(); }}
|
|
239
|
+
class={cn(
|
|
240
|
+
'flex cursor-pointer items-center rounded-md px-2 py-1.5 text-sm outline-none transition-colors',
|
|
241
|
+
'hover:bg-muted focus:bg-muted',
|
|
242
|
+
props.disabled && 'opacity-50 pointer-events-none',
|
|
243
|
+
props.class,
|
|
244
|
+
)}
|
|
245
|
+
>
|
|
246
|
+
{props.children}
|
|
247
|
+
</div>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* A thin, non-interactive divider between groups of items.
|
|
253
|
+
* a11y: `role="separator"` — exposed to AT as a group boundary; not in the
|
|
254
|
+
* roving-focus tab order (the `[role="menuitem"]` query skips it).
|
|
255
|
+
*/
|
|
256
|
+
export function DropdownSeparator(props: { class?: string }) {
|
|
257
|
+
return <div role="separator" class={cn('-mx-1 my-1 h-px bg-border', props.class)} />;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* A non-interactive section header.
|
|
262
|
+
* a11y: a plain muted label — NOT a menuitem and NOT focusable, so roving focus
|
|
263
|
+
* skips it; it labels the items that follow visually only (`select-none`).
|
|
264
|
+
*/
|
|
265
|
+
export function DropdownLabel(props: { children: JSX.Element; class?: string }) {
|
|
266
|
+
return (
|
|
267
|
+
<div class={cn('select-none px-2 py-1.5 text-xs font-medium text-muted-foreground', props.class)}>
|
|
268
|
+
{props.children}
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* A togglable menu item.
|
|
275
|
+
* a11y: `role="menuitemcheckbox"` + `aria-checked`. Activating fires `onSelect`
|
|
276
|
+
* but KEEPS THE MENU OPEN (the consumer flips `checked`). The Check sits at the
|
|
277
|
+
* TRAILING edge (toggle-style) so the item's leading content — an icon when
|
|
278
|
+
* present — aligns with the plain items above it instead of being pushed in by a
|
|
279
|
+
* reserved leading check column.
|
|
280
|
+
*/
|
|
281
|
+
export function DropdownCheckboxItem(props: { children: JSX.Element; class?: string; checked?: boolean; onSelect?: () => void; disabled?: boolean }) {
|
|
282
|
+
const activate = () => {
|
|
283
|
+
if (props.disabled) return;
|
|
284
|
+
props.onSelect?.(); /* stay open — consumer owns `checked` */
|
|
285
|
+
};
|
|
286
|
+
return (
|
|
287
|
+
<div
|
|
288
|
+
role="menuitemcheckbox"
|
|
289
|
+
aria-checked={props.checked ? 'true' : 'false'}
|
|
290
|
+
tabindex={-1}
|
|
291
|
+
aria-disabled={props.disabled ? 'true' : undefined}
|
|
292
|
+
onClick={activate}
|
|
293
|
+
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); activate(); } }}
|
|
294
|
+
onPointerMove={(e) => { if (!props.disabled) (e.currentTarget as HTMLElement).focus(); }}
|
|
295
|
+
class={cn(
|
|
296
|
+
'flex cursor-pointer items-center rounded-md px-2 py-1.5 text-sm outline-none transition-colors',
|
|
297
|
+
'hover:bg-muted focus:bg-muted',
|
|
298
|
+
props.disabled && 'opacity-50 pointer-events-none',
|
|
299
|
+
props.class,
|
|
300
|
+
)}
|
|
301
|
+
>
|
|
302
|
+
{props.children}
|
|
303
|
+
<span class="ml-auto flex size-4 shrink-0 items-center justify-center text-muted-foreground">
|
|
304
|
+
<Show when={props.checked}><Check class="size-4" aria-hidden="true" /></Show>
|
|
305
|
+
</span>
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* A single-select (radio) menu item.
|
|
312
|
+
* a11y: `role="menuitemradio"` + `aria-checked`. Behaves like the checkbox item —
|
|
313
|
+
* activating fires `onSelect` but KEEPS THE MENU OPEN (the consumer moves the
|
|
314
|
+
* selection within the group). The Check sits at the TRAILING edge so leading
|
|
315
|
+
* content aligns with plain items. Group membership is the consumer's concern;
|
|
316
|
+
* this primitive just renders the selected state and reports the click.
|
|
317
|
+
*/
|
|
318
|
+
export function DropdownRadioItem(props: { children: JSX.Element; class?: string; checked?: boolean; onSelect?: () => void; disabled?: boolean }) {
|
|
319
|
+
const activate = () => {
|
|
320
|
+
if (props.disabled) return;
|
|
321
|
+
props.onSelect?.(); /* stay open — consumer owns the group selection */
|
|
322
|
+
};
|
|
323
|
+
return (
|
|
324
|
+
<div
|
|
325
|
+
role="menuitemradio"
|
|
326
|
+
aria-checked={props.checked ? 'true' : 'false'}
|
|
327
|
+
tabindex={-1}
|
|
328
|
+
aria-disabled={props.disabled ? 'true' : undefined}
|
|
329
|
+
onClick={activate}
|
|
330
|
+
onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); activate(); } }}
|
|
331
|
+
onPointerMove={(e) => { if (!props.disabled) (e.currentTarget as HTMLElement).focus(); }}
|
|
187
332
|
class={cn(
|
|
188
333
|
'flex cursor-pointer items-center rounded-md px-2 py-1.5 text-sm outline-none transition-colors',
|
|
189
334
|
'hover:bg-muted focus:bg-muted',
|
|
335
|
+
props.disabled && 'opacity-50 pointer-events-none',
|
|
190
336
|
props.class,
|
|
191
337
|
)}
|
|
192
338
|
>
|
|
193
339
|
{props.children}
|
|
340
|
+
<span class="ml-auto flex size-4 shrink-0 items-center justify-center text-muted-foreground">
|
|
341
|
+
<Show when={props.checked}><Check class="size-4" aria-hidden="true" /></Show>
|
|
342
|
+
</span>
|
|
194
343
|
</div>
|
|
195
344
|
);
|
|
196
345
|
}
|
|
346
|
+
|
|
347
|
+
// ── Submenus ────────────────────────────────────────────────────────────────
|
|
348
|
+
|
|
349
|
+
interface DropdownSubCtx {
|
|
350
|
+
open: Accessor<boolean>;
|
|
351
|
+
setOpen: (v: boolean, opts?: { viaKeyboard?: boolean; returnFocus?: boolean }) => void;
|
|
352
|
+
triggerId: string;
|
|
353
|
+
menuId: string;
|
|
354
|
+
setTrigger: (el: HTMLElement) => void;
|
|
355
|
+
setMenu: (el: HTMLElement) => void;
|
|
356
|
+
trigger: Accessor<HTMLElement | undefined>;
|
|
357
|
+
menu: Accessor<HTMLElement | undefined>;
|
|
358
|
+
openedViaKeyboard: Accessor<boolean>;
|
|
359
|
+
/** clear any pending close timer (used when the pointer re-enters trigger or content) */
|
|
360
|
+
cancelClose: () => void;
|
|
361
|
+
/** schedule a deferred close, tolerating a pointer crossing the gap to the submenu */
|
|
362
|
+
scheduleClose: () => void;
|
|
363
|
+
}
|
|
364
|
+
const SubCtx = createContext<DropdownSubCtx>();
|
|
365
|
+
const useDropdownSub = () => {
|
|
366
|
+
const c = useContext(SubCtx);
|
|
367
|
+
if (!c) throw new Error('DropdownSub parts must be used within <DropdownSub>');
|
|
368
|
+
return c;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* A nested menu group. Mirrors the `Dropdown` context shape with its own open
|
|
373
|
+
* signal + trigger/content refs, plus a small close-delay so a pointer can cross
|
|
374
|
+
* the gap from the trigger to the submenu without it snapping shut.
|
|
375
|
+
*
|
|
376
|
+
* The submenu is tied to its PARENT open state: when the parent menu closes
|
|
377
|
+
* (Escape/outside-click/select), `useDismiss` on the parent unmounts the whole
|
|
378
|
+
* content tree, which tears this provider down and drops the sub with it.
|
|
379
|
+
*/
|
|
380
|
+
export function DropdownSub(props: { children: JSX.Element }) {
|
|
381
|
+
const [open, setOpenSig] = createSignal(false);
|
|
382
|
+
const [viaKb, setViaKb] = createSignal(false);
|
|
383
|
+
const [trigger, setTrigger] = createSignal<HTMLElement>();
|
|
384
|
+
const [menu, setMenu] = createSignal<HTMLElement>();
|
|
385
|
+
let closeTimer: ReturnType<typeof setTimeout> | undefined;
|
|
386
|
+
const cancelClose = () => { if (closeTimer) { clearTimeout(closeTimer); closeTimer = undefined; } };
|
|
387
|
+
const setOpen = (v: boolean, opts?: { viaKeyboard?: boolean; returnFocus?: boolean }) => {
|
|
388
|
+
cancelClose();
|
|
389
|
+
setViaKb(!!opts?.viaKeyboard);
|
|
390
|
+
setOpenSig(v);
|
|
391
|
+
if (v) {
|
|
392
|
+
if (opts?.viaKeyboard) {
|
|
393
|
+
queueMicrotask(() => menu()?.querySelector<HTMLElement>(ITEM_SELECTOR)?.focus());
|
|
394
|
+
menu()?.querySelector<HTMLElement>(ITEM_SELECTOR)?.focus();
|
|
395
|
+
}
|
|
396
|
+
} else if (opts?.returnFocus !== false) {
|
|
397
|
+
const el = trigger();
|
|
398
|
+
el?.focus();
|
|
399
|
+
queueMicrotask(() => el?.focus());
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const scheduleClose = () => {
|
|
403
|
+
cancelClose();
|
|
404
|
+
closeTimer = setTimeout(() => setOpen(false), 120);
|
|
405
|
+
};
|
|
406
|
+
onCleanup(cancelClose);
|
|
407
|
+
return (
|
|
408
|
+
<SubCtx.Provider value={{
|
|
409
|
+
open, setOpen, triggerId: createUniqueId(), menuId: createUniqueId(),
|
|
410
|
+
setTrigger, setMenu, trigger, menu, openedViaKeyboard: viaKb,
|
|
411
|
+
cancelClose, scheduleClose,
|
|
412
|
+
}}>
|
|
413
|
+
{props.children}
|
|
414
|
+
</SubCtx.Provider>
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* The item that opens a submenu.
|
|
420
|
+
* a11y: `role="menuitem"` + `aria-haspopup="menu"` + `aria-expanded`, trailing
|
|
421
|
+
* ChevronRight. Opens on pointerenter, click, ArrowRight, and Enter/Space;
|
|
422
|
+
* keyboard-open also moves focus into the sub's first item. ArrowRight/Enter are
|
|
423
|
+
* swallowed so the parent menu doesn't also act on them.
|
|
424
|
+
*/
|
|
425
|
+
export function DropdownSubTrigger(props: { children: JSX.Element; class?: string }) {
|
|
426
|
+
const sub = useDropdownSub();
|
|
427
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
428
|
+
if (e.key === 'ArrowRight' || e.key === 'Enter' || e.key === ' ') {
|
|
429
|
+
e.preventDefault();
|
|
430
|
+
e.stopPropagation();
|
|
431
|
+
sub.setOpen(true, { viaKeyboard: true });
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
return (
|
|
435
|
+
<div
|
|
436
|
+
ref={sub.setTrigger}
|
|
437
|
+
id={sub.triggerId}
|
|
438
|
+
role="menuitem"
|
|
439
|
+
tabindex={-1}
|
|
440
|
+
aria-haspopup="menu"
|
|
441
|
+
aria-expanded={sub.open()}
|
|
442
|
+
aria-controls={sub.open() ? sub.menuId : undefined}
|
|
443
|
+
onClick={() => sub.setOpen(!sub.open())}
|
|
444
|
+
onKeyDown={onKeyDown}
|
|
445
|
+
onPointerEnter={() => { sub.cancelClose(); sub.setOpen(true); }}
|
|
446
|
+
onPointerLeave={() => sub.scheduleClose()}
|
|
447
|
+
onPointerMove={(e) => (e.currentTarget as HTMLElement).focus()}
|
|
448
|
+
class={cn(
|
|
449
|
+
'flex cursor-pointer items-center rounded-md px-2 py-1.5 text-sm outline-none transition-colors',
|
|
450
|
+
'hover:bg-muted focus:bg-muted data-[expanded]:bg-muted',
|
|
451
|
+
props.class,
|
|
452
|
+
)}
|
|
453
|
+
data-expanded={sub.open() ? '' : undefined}
|
|
454
|
+
>
|
|
455
|
+
{props.children}
|
|
456
|
+
<ChevronRight class="ml-auto size-4 shrink-0 text-muted-foreground" aria-hidden="true" />
|
|
457
|
+
</div>
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* The submenu surface — same portal/positioning/roving-focus core as
|
|
463
|
+
* DropdownContent, anchored `right-start` off its trigger.
|
|
464
|
+
* a11y: ArrowLeft and Escape close the sub and RETURN FOCUS to the trigger;
|
|
465
|
+
* ArrowUp/Down/Home/End rove within; typeahead included (matches DropdownContent).
|
|
466
|
+
* Keyboard-open focuses the first item.
|
|
467
|
+
*/
|
|
468
|
+
export function DropdownSubContent(props: { children: JSX.Element; class?: string }) {
|
|
469
|
+
const sub = useDropdownSub();
|
|
470
|
+
const parent = useDropdown();
|
|
471
|
+
const config = useChatConfig();
|
|
472
|
+
const presence = createPresence(sub.open);
|
|
473
|
+
const position = usePosition(sub.trigger, sub.menu, {
|
|
474
|
+
placement: 'right-start',
|
|
475
|
+
gutter: 2,
|
|
476
|
+
// Sub trigger removed from the DOM -> close so the submenu portal doesn't orphan.
|
|
477
|
+
onDisconnect: () => sub.setOpen(false, { returnFocus: false }),
|
|
478
|
+
});
|
|
479
|
+
// Escape/ArrowLeft are handled by onKeyDown below (stopPropagation keeps them
|
|
480
|
+
// local to the sub). Outside-pointer dismiss is handled by the PARENT's
|
|
481
|
+
// useDismiss (whose refs include the registered submenu surface). A separate
|
|
482
|
+
// useDismiss here would double-fire Escape because document listeners run
|
|
483
|
+
// after stopPropagation on the element, not on the document.
|
|
484
|
+
|
|
485
|
+
const items = () => Array.from(sub.menu()?.querySelectorAll<HTMLElement>(ITEM_SELECTOR) ?? []);
|
|
486
|
+
const focusIndex = (i: number) => {
|
|
487
|
+
const list = items();
|
|
488
|
+
if (!list.length) return;
|
|
489
|
+
const idx = ((i % list.length) + list.length) % list.length;
|
|
490
|
+
list[idx].focus();
|
|
491
|
+
};
|
|
492
|
+
const activeItem = () => {
|
|
493
|
+
const root = sub.menu()?.getRootNode() as Document | ShadowRoot | undefined;
|
|
494
|
+
return (root?.activeElement ?? document.activeElement) as Element | null;
|
|
495
|
+
};
|
|
496
|
+
const currentIndex = () => items().findIndex((el) => el === activeItem());
|
|
497
|
+
|
|
498
|
+
const onKeyDown = (e: KeyboardEvent) => {
|
|
499
|
+
const list = items();
|
|
500
|
+
switch (e.key) {
|
|
501
|
+
case 'ArrowDown': e.preventDefault(); focusIndex(currentIndex() + 1); break;
|
|
502
|
+
case 'ArrowUp': e.preventDefault(); focusIndex(currentIndex() - 1); break;
|
|
503
|
+
case 'Home': e.preventDefault(); focusIndex(0); break;
|
|
504
|
+
case 'End': e.preventDefault(); focusIndex(list.length - 1); break;
|
|
505
|
+
case 'ArrowLeft': e.preventDefault(); e.stopPropagation(); sub.setOpen(false, { returnFocus: true }); break;
|
|
506
|
+
case 'Escape': e.preventDefault(); e.stopPropagation(); sub.setOpen(false, { returnFocus: true }); break;
|
|
507
|
+
default:
|
|
508
|
+
if (e.key.length === 1 && /\S/.test(e.key)) {
|
|
509
|
+
const start = currentIndex() + 1;
|
|
510
|
+
const lower = e.key.toLowerCase();
|
|
511
|
+
const match = list.findIndex((el, i) => i >= start && (el.textContent ?? '').trim().toLowerCase().startsWith(lower));
|
|
512
|
+
const found = match >= 0 ? match : list.findIndex((el) => (el.textContent ?? '').trim().toLowerCase().startsWith(lower));
|
|
513
|
+
if (found >= 0) { e.preventDefault(); focusIndex(found); }
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
return (
|
|
519
|
+
<Show when={presence.present()}>
|
|
520
|
+
<Portal mount={config.portalMount()}>
|
|
521
|
+
<div
|
|
522
|
+
ref={(el) => {
|
|
523
|
+
sub.setMenu(el); presence.setRef(el);
|
|
524
|
+
// Tell the parent menu this surface is part of its tree (outside-click).
|
|
525
|
+
const unregister = parent.registerSubMenu(el);
|
|
526
|
+
onCleanup(unregister);
|
|
527
|
+
if (sub.openedViaKeyboard()) {
|
|
528
|
+
queueMicrotask(() => el.querySelector<HTMLElement>(ITEM_SELECTOR)?.focus());
|
|
529
|
+
}
|
|
530
|
+
}}
|
|
531
|
+
id={sub.menuId}
|
|
532
|
+
role="menu"
|
|
533
|
+
aria-labelledby={sub.triggerId}
|
|
534
|
+
tabindex={-1}
|
|
535
|
+
data-expanded={presence.state() === 'open' ? '' : undefined}
|
|
536
|
+
data-closed={presence.state() === 'closed' ? '' : undefined}
|
|
537
|
+
onKeyDown={onKeyDown}
|
|
538
|
+
// Keep the sub open while the pointer is over it (cancel a pending close
|
|
539
|
+
// scheduled by the trigger's pointerleave); re-arm the close on exit.
|
|
540
|
+
onPointerEnter={() => sub.cancelClose()}
|
|
541
|
+
onPointerLeave={() => sub.scheduleClose()}
|
|
542
|
+
style={{
|
|
543
|
+
position: 'fixed', left: `${position.pos().x}px`, top: `${position.pos().y}px`,
|
|
544
|
+
visibility: position.hidden() ? 'hidden' : 'visible',
|
|
545
|
+
'pointer-events': position.hidden() ? 'none' : undefined,
|
|
546
|
+
}}
|
|
547
|
+
class={cn(
|
|
548
|
+
'z-50 min-w-[8rem] rounded-lg bg-card p-1 kai-elevation',
|
|
549
|
+
'animate-in fade-in-0 zoom-in-95 data-[closed]:animate-out data-[closed]:fade-out-0 data-[closed]:zoom-out-95',
|
|
550
|
+
props.class,
|
|
551
|
+
)}
|
|
552
|
+
>
|
|
553
|
+
{props.children}
|
|
554
|
+
</div>
|
|
555
|
+
</Portal>
|
|
556
|
+
</Show>
|
|
557
|
+
);
|
|
558
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { type JSX, Show, createSignal, createEffect, untrack } from 'solid-js';
|
|
2
|
+
import { cn } from '../utils/cn';
|
|
3
|
+
import { Input } from './input';
|
|
4
|
+
|
|
5
|
+
export interface EditableLabelProps {
|
|
6
|
+
/** The label text. */
|
|
7
|
+
value: string;
|
|
8
|
+
/** Controlled edit state. When it flips true the field opens; double-click and
|
|
9
|
+
* the host's `edit()` open it too. */
|
|
10
|
+
editing?: boolean;
|
|
11
|
+
/** Placeholder shown while editing (and as muted text when the value is empty). */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Disable entering edit mode. */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** Fires on commit (Enter / blur) with the new value — ONLY when it changed. */
|
|
16
|
+
onRename?: (value: string) => void;
|
|
17
|
+
/** Fires on Esc (cancel); the text is restored. */
|
|
18
|
+
onCancel?: () => void;
|
|
19
|
+
class?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* `EditableLabel`: inline rename. Shows `value` as text; double-click (or the
|
|
24
|
+
* `editing` prop, or a host `edit()`) swaps in an autofocused `Input` with the
|
|
25
|
+
* text pre-selected. Enter or blur commits (fires `onRename` only when the value
|
|
26
|
+
* changed); Esc cancels (fires `onCancel`, restores the text). Both exit editing.
|
|
27
|
+
*
|
|
28
|
+
* Parts: `text` (the read view), `input` (the field while editing).
|
|
29
|
+
*/
|
|
30
|
+
export function EditableLabel(props: EditableLabelProps): JSX.Element {
|
|
31
|
+
// `editing` is seeded from the controlled prop and follows it; double-click /
|
|
32
|
+
// commit / cancel toggle it locally without touching the prop (no feedback loop).
|
|
33
|
+
const [editing, setEditing] = createSignal(!!props.editing);
|
|
34
|
+
createEffect(() => setEditing(!!props.editing));
|
|
35
|
+
|
|
36
|
+
// The displayed text. Seeded from `value`, kept in sync with it, and updated
|
|
37
|
+
// optimistically on a successful rename so the read view shows the new label.
|
|
38
|
+
const [text, setText] = createSignal(props.value);
|
|
39
|
+
createEffect(() => setText(props.value));
|
|
40
|
+
|
|
41
|
+
let root: HTMLElement | undefined;
|
|
42
|
+
// Set before an Enter/Esc unmounts the field so its teardown blur does not
|
|
43
|
+
// double-commit (mirrors the AMUX inline-rename guard).
|
|
44
|
+
let suppressBlur = false;
|
|
45
|
+
|
|
46
|
+
const focusSelect = () => {
|
|
47
|
+
const input = root?.querySelector('input');
|
|
48
|
+
if (input) { input.focus(); input.select(); }
|
|
49
|
+
};
|
|
50
|
+
createEffect(() => { if (editing()) queueMicrotask(focusSelect); });
|
|
51
|
+
|
|
52
|
+
const enterEdit = () => { if (!props.disabled) setEditing(true); };
|
|
53
|
+
|
|
54
|
+
const commit = (next: string) => {
|
|
55
|
+
if (!untrack(editing)) return; // idempotent: a teardown blur after Enter is a no-op
|
|
56
|
+
setEditing(false);
|
|
57
|
+
if (next !== untrack(text)) { setText(next); props.onRename?.(next); }
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const cancel = () => {
|
|
61
|
+
if (!untrack(editing)) return;
|
|
62
|
+
setEditing(false);
|
|
63
|
+
props.onCancel?.();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const onFieldKeyDown = (e: KeyboardEvent) => {
|
|
67
|
+
const el = e.currentTarget as HTMLInputElement;
|
|
68
|
+
if (e.key === 'Enter') { e.preventDefault(); suppressBlur = true; commit(el.value); }
|
|
69
|
+
else if (e.key === 'Escape') { e.preventDefault(); suppressBlur = true; cancel(); }
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const onFieldBlur = (v: string) => {
|
|
73
|
+
if (suppressBlur) { suppressBlur = false; return; }
|
|
74
|
+
commit(v);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<span ref={root} class={cn('inline-flex max-w-full items-center', props.class)}>
|
|
79
|
+
<Show
|
|
80
|
+
when={editing()}
|
|
81
|
+
fallback={
|
|
82
|
+
<span
|
|
83
|
+
part="text"
|
|
84
|
+
tabindex={props.disabled ? undefined : 0}
|
|
85
|
+
class={cn(
|
|
86
|
+
'inline-block max-w-full truncate rounded px-1 py-0.5 text-sm text-foreground',
|
|
87
|
+
props.disabled ? 'cursor-default opacity-60' : 'cursor-text hover:bg-muted',
|
|
88
|
+
!text() && 'text-muted-foreground',
|
|
89
|
+
)}
|
|
90
|
+
onDblClick={enterEdit}
|
|
91
|
+
onKeyDown={(e) => {
|
|
92
|
+
if (!props.disabled && (e.key === 'Enter' || e.key === 'F2')) { e.preventDefault(); enterEdit(); }
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
{text() || props.placeholder || ''}
|
|
96
|
+
</span>
|
|
97
|
+
}
|
|
98
|
+
>
|
|
99
|
+
<Input
|
|
100
|
+
value={text()}
|
|
101
|
+
placeholder={props.placeholder}
|
|
102
|
+
disabled={props.disabled}
|
|
103
|
+
size="sm"
|
|
104
|
+
class="h-7 py-0"
|
|
105
|
+
aria-label={props.placeholder ?? 'Edit label'}
|
|
106
|
+
onKeyDown={onFieldKeyDown}
|
|
107
|
+
onValueChange={onFieldBlur}
|
|
108
|
+
/>
|
|
109
|
+
</Show>
|
|
110
|
+
</span>
|
|
111
|
+
);
|
|
112
|
+
}
|
package/src/ui/hover-card.tsx
CHANGED
|
@@ -25,13 +25,28 @@ const useHoverCard = () => {
|
|
|
25
25
|
return c;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
/** Imperative open controller, handed to a parent (e.g. the kai-hover-card facade)
|
|
29
|
+
* via `controllerRef` so it can drive/observe open state. */
|
|
30
|
+
export interface HoverCardController { open: Accessor<boolean>; setOpen: (v: boolean) => void; }
|
|
31
|
+
|
|
32
|
+
export interface HoverCardRootProps {
|
|
33
|
+
children: JSX.Element;
|
|
34
|
+
openDelay?: number;
|
|
35
|
+
closeDelay?: number;
|
|
36
|
+
/** Initial open state (uncontrolled seed). */
|
|
37
|
+
defaultOpen?: boolean;
|
|
38
|
+
/** When true, hover/focus never opens the card. */
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/** Receive the open controller (open accessor + setOpen) once mounted. */
|
|
41
|
+
controllerRef?: (api: HoverCardController) => void;
|
|
42
|
+
}
|
|
29
43
|
|
|
30
44
|
export function HoverCardRoot(props: HoverCardRootProps) {
|
|
31
|
-
const [open, setOpen] = createSignal(false);
|
|
45
|
+
const [open, setOpen] = createSignal(props.defaultOpen ?? false);
|
|
32
46
|
const [trigger, setTrigger] = createSignal<HTMLElement>();
|
|
33
47
|
const [content, setContent] = createSignal<HTMLElement>();
|
|
34
48
|
let timer: number | undefined;
|
|
49
|
+
props.controllerRef?.({ open, setOpen });
|
|
35
50
|
|
|
36
51
|
// ONE shared timer drives both trigger and content. Entering either cancels
|
|
37
52
|
// any pending close and schedules an open; leaving either cancels any pending
|
|
@@ -40,6 +55,7 @@ export function HoverCardRoot(props: HoverCardRootProps) {
|
|
|
40
55
|
// before it can run, so the card never flickers and there are no stale-timer
|
|
41
56
|
// sporadics (the HC-1 fix).
|
|
42
57
|
const enter = () => {
|
|
58
|
+
if (props.disabled) return;
|
|
43
59
|
clearTimeout(timer);
|
|
44
60
|
timer = window.setTimeout(() => setOpen(true), props.openDelay ?? 0);
|
|
45
61
|
};
|
|
@@ -70,7 +86,7 @@ export function HoverCardTrigger(props: HoverCardTriggerProps) {
|
|
|
70
86
|
return (
|
|
71
87
|
<As
|
|
72
88
|
as="span"
|
|
73
|
-
class={props.class}
|
|
89
|
+
class={cn('inline-block', props.class)}
|
|
74
90
|
ref={ctx.setTrigger}
|
|
75
91
|
onPointerEnter={ctx.enter}
|
|
76
92
|
onPointerLeave={ctx.leave}
|
|
@@ -117,8 +133,15 @@ export function HoverCardContent(props: HoverCardContentProps) {
|
|
|
117
133
|
// gutter: 0 places the outer shell flush with the trigger; the visual gap is
|
|
118
134
|
// recreated by transparent padding (gapPaddingStyle) so the hit area bridges
|
|
119
135
|
// it and a straight trigger->content transit never leaves a hot zone.
|
|
120
|
-
const position = usePosition(ctx.trigger, ctx.content, {
|
|
121
|
-
|
|
136
|
+
const position = usePosition(ctx.trigger, ctx.content, {
|
|
137
|
+
placement: props.placement ?? 'bottom',
|
|
138
|
+
gutter: 0,
|
|
139
|
+
// Trigger removed from the DOM -> close so the card portal doesn't orphan.
|
|
140
|
+
onDisconnect: () => ctx.close(),
|
|
141
|
+
});
|
|
142
|
+
// Escape OR an outside click closes immediately — an outside click is a
|
|
143
|
+
// deliberate dismiss, not a hover-out (which uses leave()'s grace delay).
|
|
144
|
+
useDismiss({ enabled: ctx.open, onDismiss: () => ctx.close(), refs: () => [ctx.trigger(), ctx.content()] });
|
|
122
145
|
|
|
123
146
|
return (
|
|
124
147
|
<Show when={presence.present()}>
|