@kitn.ai/ui 0.25.2 → 0.26.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 +2 -2
- package/dist/components/attachment-types.d.ts +46 -1
- package/dist/components/attachments.d.ts +31 -0
- package/dist/components/audio-visualizer/fit-scale.d.ts +50 -0
- package/dist/components/audio-visualizer/index.d.ts +15 -1
- package/dist/components/audio-visualizer/variant-bar.d.ts +24 -1
- package/dist/components/chat-thread.d.ts +3 -41
- package/dist/components/code-block.d.ts +22 -0
- package/dist/components/conversation-item.d.ts +54 -1
- package/dist/components/conversation-list.d.ts +65 -0
- package/dist/components/form.d.ts +42 -0
- package/dist/components/message.d.ts +7 -0
- package/dist/components/toast.d.ts +2 -1
- package/dist/components/voice-input.d.ts +8 -0
- package/dist/components/voice-output.d.ts +12 -1
- package/dist/components/workspace-shell.d.ts +87 -0
- package/dist/{create-tween-B5Y4Im8G.js → create-tween-BFT6c-Y8.js} +1 -1
- package/dist/{create-tween-4z1XYLkR.js → create-tween-CJNlzoaO.js} +1 -1
- package/dist/{create-tween-CUzOlaMS.js → create-tween-CQED4T0g.js} +1 -1
- package/dist/custom-elements.json +2931 -2572
- package/dist/diagnostics/hook.d.ts +81 -0
- package/dist/diagnostics/index.d.ts +7 -0
- package/dist/diagnostics/report-request.d.ts +61 -0
- package/dist/diagnostics.d.ts +5 -0
- package/dist/diagnostics.js +209 -0
- package/dist/elements/agent-card.js +1 -1
- package/dist/elements/artifact.js +1 -1
- package/dist/elements/attachments.js +1 -1
- package/dist/elements/audio-visualizer.js +1 -1
- package/dist/elements/autoloader.js +1 -1
- package/dist/elements/avatar.js +1 -1
- package/dist/elements/badge.js +1 -1
- package/dist/elements/button.js +1 -1
- 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-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-b5A8hlHs.js → Icon--Y8vsFal.js} +1 -1
- package/dist/elements/chunks/action-icons-D9u3OzYW.js +1 -0
- package/dist/elements/chunks/arrow-left-CVh1TeN7.js +1 -0
- package/dist/elements/chunks/{artifact-BSuPYFHY.js → artifact-BkYcfIlZ.js} +1 -1
- package/dist/elements/chunks/attachments-DwfNlubq.js +1 -0
- package/dist/elements/chunks/audio-visualizer-D7lB6mvR.js +1 -0
- package/dist/elements/chunks/{badge-TIMiJFKc.js → badge-Q0-Cmwzz.js} +1 -1
- package/dist/elements/chunks/{button-B9okqG73.js → button-flUbeufF.js} +1 -1
- package/dist/elements/chunks/{card-renderer-CSoTL_e1.js → card-renderer-3Dyl-FpN.js} +1 -1
- package/dist/elements/chunks/check-B5kBPKeo.js +1 -0
- package/dist/elements/chunks/chevron-down-DZ1GS39h.js +1 -0
- package/dist/elements/chunks/chevron-right-CvP7OUd2.js +1 -0
- package/dist/elements/chunks/{choice-card-CGMc3kek.js → choice-card-D4QUIOWZ.js} +1 -1
- package/dist/elements/chunks/circle-CDf9g6MQ.js +1 -0
- package/dist/elements/chunks/circle-check-CA47Nqbz.js +1 -0
- package/dist/elements/chunks/{circle-x-mhH7pOK2.js → circle-x-CJ_HVbC8.js} +1 -1
- package/dist/elements/chunks/code-block-BdLiTitd.js +1 -0
- package/dist/elements/chunks/collapsible-BzbXpPzr.js +1 -0
- package/dist/elements/chunks/{composer-CZZmtYOT.js → composer-Byve-n8K.js} +2 -2
- package/dist/elements/chunks/{confirm-card-BWjf2-xo.js → confirm-card-B0flE3MN.js} +1 -1
- package/dist/elements/chunks/context-VLIL3sJ-.js +1 -0
- package/dist/elements/chunks/controllable-DTwTIlwp.js +1 -0
- package/dist/elements/chunks/conversation-item-BDztezOG.js +1 -0
- package/dist/elements/chunks/copy-Nf-kqxXH.js +1 -0
- package/dist/elements/chunks/{create-tween-CUrM6D_o.js → create-tween-c4Z8TDYz.js} +2 -2
- package/dist/elements/chunks/default-input-C2iLFq0b.js +1 -0
- package/dist/elements/chunks/define-wjHR1MkU.js +1 -0
- package/dist/elements/chunks/disclosure-CcNbyLy0.js +1 -0
- package/dist/elements/chunks/{download-DnCyWFJE.js → download-C4V7tBdb.js} +1 -1
- package/dist/elements/chunks/dropdown-BgWTthUx.js +1 -0
- package/dist/elements/chunks/{ellipsis-CVxqfsDZ.js → ellipsis-7gU33mL2.js} +1 -1
- package/dist/elements/chunks/embed-D3KewsIJ.js +1 -0
- package/dist/elements/chunks/{external-link-DG2sRdQL.js → external-link-CSOEsNlx.js} +1 -1
- package/dist/elements/chunks/{file-text-D0J9F6M7.js → file-text-D1G8khle.js} +1 -1
- package/dist/elements/chunks/{file-tree-yGWNK0Js.js → file-tree-zvB2i7P9.js} +1 -1
- package/dist/elements/chunks/{folder-NV1pi_ud.js → folder-WW2LGLid.js} +1 -1
- package/dist/elements/chunks/form-CQirdC4W.js +1 -0
- package/dist/elements/chunks/hover-card-CJJkfHTK.js +1 -0
- package/dist/elements/chunks/icon-Cfgmf4fa.js +1 -0
- package/dist/elements/chunks/{info-C8r5Q6cc.js → info-DX3YMOt6.js} +1 -1
- package/dist/elements/chunks/input-BtW9U6Sq.js +1 -0
- package/dist/elements/chunks/{kbd-OGJDUT-O.js → kbd-LGXwuT_V.js} +1 -1
- package/dist/elements/chunks/{link-BdsfLB7b.js → link-2My69BqT.js} +1 -1
- package/dist/elements/chunks/{link-preview-Cf5KOP-i.js → link-preview-OQ9IEq0f.js} +1 -1
- package/dist/elements/chunks/{loader-B5QzK_8_.js → loader-iOxc_Tu-.js} +1 -1
- package/dist/elements/chunks/{markdown-DbozyYqa.js → markdown-DgBFaGAz.js} +1 -1
- package/dist/elements/chunks/{message-DtXKPqiR.js → message-VMZohrXx.js} +1 -1
- package/dist/elements/chunks/message-circle-CpXMM-_n.js +1 -0
- package/dist/elements/chunks/message-square-DxcWtETQ.js +1 -0
- package/dist/elements/chunks/message-tZmV2A3p.js +1 -0
- package/dist/elements/chunks/{minimize-2-SegJ_oku.js → minimize-2-DPIUKTrT.js} +1 -1
- package/dist/elements/chunks/{model-switcher-D7JrFFHp.js → model-switcher-DsT8tFB0.js} +1 -1
- package/dist/elements/chunks/{overlay-CV7z2YuX.js → overlay-DuiwdXjm.js} +1 -1
- package/dist/elements/chunks/{paperclip-Bg0ITU3b.js → paperclip-CRZVp4z_.js} +1 -1
- package/dist/elements/chunks/{progress-bar-D1_rzt6N.js → progress-bar-DNy66e_E.js} +1 -1
- package/dist/elements/chunks/{prompt-suggestion-D5Sm8xF1.js → prompt-suggestion-Bn64Nl7L.js} +1 -1
- package/dist/elements/chunks/reasoning-Emn9N4-T.js +1 -0
- package/dist/elements/chunks/{resizable-Dpzjlvp4.js → resizable-D181b4fM.js} +1 -1
- package/dist/elements/chunks/{rotate-cw-DzVDJOA1.js → rotate-cw-CPWe37D9.js} +1 -1
- package/dist/elements/chunks/{scroll-area-93A1bbeG.js → scroll-area-ClZkZxIk.js} +1 -1
- package/dist/elements/chunks/scroll-button-DPE-t3x_.js +1 -0
- package/dist/elements/chunks/{separator-DH2r_ZSZ.js → separator-CeJHQqLW.js} +1 -1
- package/dist/elements/chunks/{settings-BFMOd6yB.js → settings-CqaHgJF9.js} +1 -1
- package/dist/elements/chunks/{settings-group-B3VZKIcz.js → settings-group-CjqjLCOn.js} +1 -1
- package/dist/elements/chunks/share-CyfnNEqp.js +1 -0
- package/dist/elements/chunks/{skeleton-N8BuWYmf.js → skeleton-D8akBnKS.js} +1 -1
- package/dist/elements/chunks/slots-DaNjX0rc.js +1 -0
- package/dist/elements/chunks/{source-w9V0NnBn.js → source-UWCvmVak.js} +1 -1
- package/dist/elements/chunks/{star-DHvACxtm.js → star-DoHFAikQ.js} +1 -1
- package/dist/elements/chunks/store-Cjq0qwYN.js +1 -0
- package/dist/elements/chunks/{tasks-card-lPxoodlA.js → tasks-card-CmZ5xh6v.js} +1 -1
- package/dist/elements/chunks/{text-shimmer-BY_rI3s5.js → text-shimmer-DYn09zrz.js} +1 -1
- package/dist/elements/chunks/textarea-skiGHURM.js +1 -0
- package/dist/elements/chunks/{thumbs-up-DQe0hvkZ.js → thumbs-up-DX2Ijk3H.js} +1 -1
- package/dist/elements/chunks/{toast-store-VUZZBhzH.js → toast-store-CFnQpThX.js} +1 -1
- package/dist/elements/chunks/{tool-C1YtxwPu.js → tool-DKQ2D1DP.js} +1 -1
- package/dist/elements/chunks/{tooltip-BqwnFWhn.js → tooltip-B0G99y8w.js} +1 -1
- package/dist/elements/chunks/{triangle-alert-B6or7F5u.js → triangle-alert-F9cyUEyy.js} +1 -1
- package/dist/elements/chunks/{use-card-resolution-DJg32jGH.js → use-card-resolution-DoA2f_EU.js} +1 -1
- package/dist/elements/chunks/{variant-aurora-QXTZPyST.js → variant-aurora-qt6Zct8M.js} +2 -2
- package/dist/elements/chunks/variant-custom-tJp22_BQ.js +1 -0
- package/dist/{variant-wave-BwzrHD1s.js → elements/chunks/variant-wave-CaQ5ti39.js} +2 -2
- package/dist/elements/chunks/x-B6UnOiLw.js +1 -0
- package/dist/elements/coachmark.js +1 -1
- package/dist/elements/code-block.js +1 -1
- package/dist/elements/command.js +1 -1
- package/dist/elements/compare.js +1 -1
- package/dist/elements/composer.js +1 -1
- package/dist/elements/confirm-card.js +1 -1
- package/dist/elements/context-meter.js +1 -1
- package/dist/elements/conversation-item.d.ts +1 -0
- package/dist/elements/conversation-item.js +1 -0
- package/dist/elements/conversation-list.js +1 -1
- package/dist/elements/default-input.d.ts +3 -3
- package/dist/elements/define.d.ts +27 -0
- package/dist/elements/diagnostic-events.d.ts +74 -0
- package/dist/elements/dialog.js +1 -1
- package/dist/elements/dock.d.ts +1 -0
- package/dist/elements/dock.js +149 -0
- package/dist/elements/dropdown.d.ts +1 -0
- package/dist/elements/dropdown.js +1 -0
- package/dist/elements/editable-label.js +1 -1
- package/dist/elements/element-diagnostics.d.ts +81 -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.js +1 -1
- package/dist/elements/icon.js +1 -1
- package/dist/elements/image.js +1 -1
- package/dist/elements/input.js +1 -1
- package/dist/elements/kbd.js +1 -1
- 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.js +1 -1
- 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.js +1 -1
- package/dist/elements/notice.js +1 -1
- package/dist/elements/pane-group.js +1 -1
- package/dist/elements/pane.js +1 -1
- package/dist/elements/popover.js +1 -1
- package/dist/elements/progress-bar.js +1 -1
- package/dist/elements/prompt-dock.js +1 -1
- 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.d.ts +2 -0
- package/dist/elements/remote.js +1 -1
- package/dist/elements/resizable.js +1 -1
- package/dist/elements/response-stream.js +3 -3
- package/dist/elements/screen.js +1 -1
- package/dist/elements/scroll-area.js +1 -1
- package/dist/elements/scroll-button.js +1 -1
- package/dist/elements/search.js +1 -1
- package/dist/elements/segmented.js +1 -1
- package/dist/elements/separator.js +1 -1
- package/dist/elements/setting-item.js +1 -1
- package/dist/elements/settings-group.js +1 -1
- package/dist/elements/skeleton.js +1 -1
- package/dist/elements/slots.d.ts +35 -3
- package/dist/elements/source.js +1 -1
- package/dist/elements/status.js +1 -1
- package/dist/elements/switch.js +1 -1
- package/dist/elements/tabs.js +1 -1
- 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/thread.js +1 -1
- package/dist/elements/toast.js +1 -1
- package/dist/elements/tool.js +1 -1
- package/dist/elements/tooltip.js +1 -1
- package/dist/elements/voice-input.js +1 -1
- package/dist/elements/voice-output.js +1 -1
- package/dist/elements.d.ts +232 -148
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5456 -4931
- package/dist/index.server.js +4142 -3669
- package/dist/kai-provider.es.js +40 -40
- package/dist/kai.es.js +1 -1
- package/dist/llms/llms-full.txt +184 -69
- package/dist/llms/llms.txt +3 -3
- package/dist/mcp.es.js +2669 -546
- package/dist/primitives/use-resize-observer.d.ts +23 -0
- package/dist/primitives/use-speech-recognition.d.ts +8 -0
- package/dist/primitives/use-text-stream.d.ts +5 -0
- package/dist/react/index.d.ts +115 -266
- package/dist/react.js +247 -221
- package/dist/register-impl-DpE7icIb.js +293 -0
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/tool-defs.d.ts +35 -0
- package/dist/schemas.js +403 -310
- package/dist/{solid-BMuDmFo_.js → solid-BtdqNZI7.js} +8435 -7394
- package/dist/{solid-CGYNdLRR.js → solid-CnavwBye.js} +5987 -5035
- package/dist/solid.d.ts +5 -0
- package/dist/solid.js +210 -203
- package/dist/solid.server.js +210 -203
- package/dist/state/index.d.ts +4 -0
- package/dist/state/persistence.d.ts +51 -0
- package/dist/state/stream.d.ts +50 -0
- package/dist/state/threads.d.ts +71 -0
- package/dist/state.js +269 -169
- package/dist/types.d.ts +4 -2
- package/dist/ui/dock.d.ts +109 -0
- package/dist/ui/hover-card.d.ts +44 -0
- package/dist/{variant-aurora-DwSOfraQ.js → variant-aurora-B8II3-I1.js} +27 -27
- package/dist/{variant-aurora-wKvAQ5wp.js → variant-aurora-CMNWOSJR.js} +28 -28
- package/dist/{variant-aurora-XEkPT0_z.js → variant-aurora-CcuDMWwQ.js} +2 -2
- package/dist/{variant-custom-eFIg2XWQ.js → variant-custom-BdvYC7af.js} +40 -40
- package/dist/{variant-custom-BhS9wIpU.js → variant-custom-C714mqKl.js} +65 -65
- package/dist/variant-custom-L16JLLZy.js +1 -0
- package/dist/{elements/chunks/variant-wave-DDCwhLas.js → variant-wave-2S4La2Ka.js} +2 -2
- package/dist/{variant-wave-CbVsmgwT.js → variant-wave-D7ruiA1W.js} +25 -25
- package/dist/{variant-wave-CUWGx9Bn.js → variant-wave-ecwykeyL.js} +21 -21
- package/dist/wire/chunk.d.ts +47 -0
- package/dist/wire/diagnostics.d.ts +575 -0
- package/dist/wire/encode-probe.d.ts +70 -0
- package/dist/wire/encode.d.ts +24 -0
- package/dist/wire/index.d.ts +2 -0
- package/dist/wire/sse.d.ts +10 -2
- package/dist/wire.js +917 -480
- package/frameworks/react/index.tsx +132 -93
- package/llms-full.txt +184 -69
- package/llms.txt +3 -3
- package/package.json +26 -6
- package/src/agent-tooling/archetypes.ts +41 -9
- package/src/agent-tooling/catalog/README.md +676 -0
- package/src/agent-tooling/catalog/catalog-types.ts +231 -0
- package/src/agent-tooling/catalog/fabrications.ts +96 -0
- package/src/agent-tooling/catalog/invariants.ts +284 -0
- package/src/agent-tooling/catalog/labs-titles.ts +114 -0
- package/src/agent-tooling/catalog/scenarios.ts +87 -0
- package/src/agent-tooling/catalog/surfaces.ts +275 -0
- package/src/agent-tooling/integrations/anthropic.ts +7 -1
- package/src/agent-tooling/integrations/cloudflare.ts +43 -2
- package/src/agent-tooling/integrations/langgraph.ts +7 -1
- package/src/agent-tooling/integrations/mastra.ts +7 -1
- package/src/agent-tooling/integrations/mock.ts +92 -17
- package/src/agent-tooling/integrations/ollama.ts +7 -1
- package/src/agent-tooling/integrations/openai.ts +7 -1
- package/src/agent-tooling/integrations/openrouter.ts +7 -1
- package/src/agent-tooling/integrations/pi.ts +56 -1
- package/src/agent-tooling/integrations/vercel-ai-sdk.ts +7 -1
- package/src/agent-tooling/mcp/css-raw.d.ts +12 -0
- package/src/agent-tooling/mcp/manifest.ts +100 -1
- package/src/agent-tooling/mcp/server.ts +61 -5
- package/src/agent-tooling/mcp/tools/reference.ts +440 -4
- package/src/agent-tooling/mcp/tools/scaffold.ts +1834 -307
- package/src/agent-tooling/mcp/tools/theme.ts +146 -30
- package/src/agent-tooling/mcp/validate-args.ts +141 -0
- package/src/agent-tooling/registry.ts +19 -7
- package/src/agent-tooling/route-emit.ts +26 -2
- package/src/components/attachment-types.ts +47 -1
- package/src/components/attachments.tsx +169 -22
- package/src/components/audio-visualizer/fit-scale.ts +112 -0
- package/src/components/audio-visualizer/index.tsx +80 -3
- package/src/components/audio-visualizer/variant-aurora.tsx +10 -4
- package/src/components/audio-visualizer/variant-bar.tsx +38 -6
- package/src/components/audio-visualizer/variant-custom.tsx +8 -2
- package/src/components/audio-visualizer/variant-grid.tsx +16 -11
- package/src/components/audio-visualizer/variant-radial.tsx +15 -10
- package/src/components/audio-visualizer/variant-wave.tsx +7 -2
- package/src/components/chat-container.tsx +4 -1
- package/src/components/chat-thread.tsx +36 -7
- package/src/components/code-block.tsx +79 -3
- package/src/components/composer.tsx +8 -1
- package/src/components/conversation-item.tsx +114 -4
- package/src/components/conversation-list.tsx +212 -12
- package/src/components/embed.tsx +4 -0
- package/src/components/form.tsx +41 -14
- package/src/components/message.tsx +75 -5
- package/src/components/response-stream.tsx +13 -7
- package/src/components/screen.tsx +5 -0
- package/src/components/scroll-button.tsx +7 -0
- package/src/components/toast.tsx +11 -5
- package/src/components/voice-input.tsx +35 -3
- package/src/components/voice-output.tsx +46 -6
- package/src/components/workspace-shell.tsx +285 -0
- package/src/diagnostics/hook.ts +352 -0
- package/src/diagnostics/index.ts +82 -0
- package/src/diagnostics/report-request.ts +296 -0
- package/src/elements/attachments.tsx +6 -7
- package/src/elements/audio-visualizer.tsx +48 -4
- package/src/elements/chat-workspace.tsx +159 -287
- package/src/elements/chat.tsx +12 -9
- package/src/elements/code-block.tsx +19 -1
- package/src/elements/command.tsx +4 -1
- package/src/elements/compiled.css +1 -1
- package/src/elements/conversation-item.tsx +80 -0
- package/src/elements/conversation-list.tsx +60 -11
- package/src/elements/default-input.tsx +5 -5
- package/src/elements/define.tsx +168 -8
- package/src/elements/diagnostic-events.ts +114 -0
- package/src/elements/dialog.tsx +47 -0
- package/src/elements/disclosure.ts +34 -12
- package/src/elements/dock.tsx +204 -0
- package/src/elements/dropdown.tsx +123 -0
- package/src/elements/element-diagnostics.ts +392 -0
- package/src/elements/element-manifest.json +12 -0
- package/src/elements/element-meta.json +672 -439
- package/src/elements/element-nonscalar.json +170 -0
- package/src/elements/element-types.d.ts +232 -148
- package/src/elements/menu.tsx +13 -0
- package/src/elements/prompt-dock.tsx +2 -1
- package/src/elements/prompt-input.tsx +8 -8
- package/src/elements/register-impl.ts +46 -0
- package/src/elements/register.ts +28 -0
- package/src/elements/resizable.tsx +52 -25
- package/src/elements/scroll-button.tsx +5 -0
- package/src/elements/slots.ts +107 -12
- package/src/elements/styles.css +30 -6
- package/src/elements/thinking-bar.tsx +16 -7
- package/src/elements/toast.tsx +3 -0
- package/src/elements/tool.tsx +26 -5
- package/src/elements/voice-input.tsx +11 -2
- package/src/elements/voice-output.tsx +16 -3
- package/src/index.ts +2 -0
- package/src/primitives/use-resize-observer.ts +33 -0
- package/src/primitives/use-speech-recognition.ts +12 -1
- package/src/primitives/use-stick-to-bottom.ts +34 -2
- package/src/primitives/use-text-stream.ts +33 -2
- package/src/remote/provider-runtime.ts +6 -3
- package/src/schemas/index.ts +1 -0
- package/src/schemas/tool-defs.ts +297 -6
- package/src/solid.ts +5 -0
- package/src/state/index.ts +12 -0
- package/src/state/persistence.ts +180 -0
- package/src/state/stream.ts +71 -4
- package/src/state/threads.ts +142 -0
- package/src/types.ts +4 -2
- package/src/ui/dialog.tsx +6 -0
- package/src/ui/dock.tsx +445 -0
- package/src/ui/dropdown.tsx +67 -23
- package/src/ui/hover-card.tsx +156 -6
- package/src/ui/input.tsx +29 -10
- package/src/ui/resizable.tsx +11 -0
- package/src/wire/chunk.ts +47 -0
- package/src/wire/consume.ts +185 -26
- package/src/wire/diagnostics.ts +727 -0
- package/src/wire/encode-probe.ts +214 -0
- package/src/wire/encode.ts +267 -14
- package/src/wire/formats/anthropic.ts +8 -1
- package/src/wire/formats/openai.ts +5 -0
- package/src/wire/index.ts +22 -0
- package/src/wire/read.ts +250 -6
- package/src/wire/sse.ts +16 -3
- package/dist/elements/chunks/action-icons-DW9muWrY.js +0 -1
- package/dist/elements/chunks/arrow-left-iJVnQmxA.js +0 -1
- package/dist/elements/chunks/attachments-CL6TaqIb.js +0 -1
- package/dist/elements/chunks/audio-visualizer-BuUqQmaO.js +0 -1
- package/dist/elements/chunks/chat-thread-DxoKaStk.js +0 -1
- package/dist/elements/chunks/check-MdLzbxrm.js +0 -1
- package/dist/elements/chunks/chevron-down-MK7IzDqe.js +0 -1
- package/dist/elements/chunks/chevron-right-C5jXhmtV.js +0 -1
- package/dist/elements/chunks/circle-BG7VkPep.js +0 -1
- package/dist/elements/chunks/circle-check-GqvO2UBs.js +0 -1
- package/dist/elements/chunks/code-block-ClhQO9RW.js +0 -1
- package/dist/elements/chunks/collapsible-DBcBkFPh.js +0 -1
- package/dist/elements/chunks/context-hKjNqiyQ.js +0 -1
- package/dist/elements/chunks/conversation-list-CsGJjSKG.js +0 -1
- package/dist/elements/chunks/default-input-B1Mem5wu.js +0 -1
- package/dist/elements/chunks/define-B_tXMYRm.js +0 -1
- package/dist/elements/chunks/disclosure-DAoYOKew.js +0 -1
- package/dist/elements/chunks/dropdown-CmNna5lT.js +0 -1
- package/dist/elements/chunks/embed-CjAD2jSi.js +0 -1
- package/dist/elements/chunks/form-Cp8Y00Wn.js +0 -1
- package/dist/elements/chunks/hover-card-6KtXpLwT.js +0 -1
- package/dist/elements/chunks/icon-97R8SR2p.js +0 -1
- package/dist/elements/chunks/input-DrseEjhp.js +0 -1
- package/dist/elements/chunks/message-CE4k-qaj.js +0 -1
- package/dist/elements/chunks/message-square-C9ovmtOo.js +0 -1
- package/dist/elements/chunks/reasoning-BrxQfpfI.js +0 -1
- package/dist/elements/chunks/scroll-button-CrTo7wm4.js +0 -1
- package/dist/elements/chunks/share-DgNbkJKY.js +0 -1
- package/dist/elements/chunks/slots-CIw9RlAe.js +0 -1
- package/dist/elements/chunks/store-HIPGhNz9.js +0 -1
- package/dist/elements/chunks/textarea-DPfuhswM.js +0 -1
- package/dist/elements/chunks/variant-custom-D5ZlmziF.js +0 -1
- package/dist/elements/chunks/video-Bb86fVYI.js +0 -1
- package/dist/elements/chunks/x-BOhjBeOd.js +0 -1
- package/dist/primitives/card-validate-generator.testlib.d.ts +0 -20
- package/dist/register-impl-DGmGzrEM.js +0 -145
- package/dist/variant-custom-MkTNTycd.js +0 -1
- package/src/primitives/card-validate-generator.testlib.ts +0 -38
package/src/elements/dialog.tsx
CHANGED
|
@@ -10,6 +10,44 @@ interface Props extends Record<string, unknown> {
|
|
|
10
10
|
open?: boolean;
|
|
11
11
|
/** Initial open state on mount (uncontrolled seed). */
|
|
12
12
|
defaultOpen?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Accessible name for the modal, used when no `header` slot is projected:
|
|
15
|
+
* `<kai-dialog label="Delete workspace">`. A projected `header` WINS over this
|
|
16
|
+
* (it becomes `aria-labelledby`), because ARIA resolves `aria-labelledby` ahead
|
|
17
|
+
* of `aria-label` and the visible heading is the name both a sighted and a
|
|
18
|
+
* screen-reader user can be talked through. Defaults to `Dialog` so a modal is
|
|
19
|
+
* never nameless.
|
|
20
|
+
*/
|
|
21
|
+
label?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The fallback accessible name.
|
|
26
|
+
*
|
|
27
|
+
* DELIBERATELY GENERIC, and a decision rather than a placeholder. A modal with no
|
|
28
|
+
* name at all fails WCAG and axe's `aria-dialog-name`; "Dialog, dialog" is merely
|
|
29
|
+
* redundant, and between the two the redundant one is strictly better — it is also
|
|
30
|
+
* what Shoelace and WebAwesome ship. The kit cannot know what a given modal is about,
|
|
31
|
+
* so inventing something specific here would be a worse default than saying nothing
|
|
32
|
+
* extra. Consumers name it properly with `label` or by projecting a `header`.
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_LABEL = 'Dialog';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The consumer's label, or the fallback — with "no label" meaning every way a
|
|
38
|
+
* consumer can arrive at one.
|
|
39
|
+
*
|
|
40
|
+
* The declared default is a SEED, not a floor: component-register writes the prop
|
|
41
|
+
* back as `null` when the attribute is removed and does NOT restore the declared
|
|
42
|
+
* value, so `props.label` is legitimately `null`/`undefined` at runtime. An empty or
|
|
43
|
+
* whitespace-only string is the same situation wearing a name — `aria-label=""` is a
|
|
44
|
+
* `role="dialog"` with no accessible name, i.e. the exact defect this exists to
|
|
45
|
+
* prevent, reached through the attribute that was supposed to prevent it. Each of
|
|
46
|
+
* those routes is a row in tests/elements/dialog.test.tsx, because a mutation run
|
|
47
|
+
* showed the plain `??` was uncovered.
|
|
48
|
+
*/
|
|
49
|
+
function resolveLabel(label: unknown): string {
|
|
50
|
+
return typeof label === 'string' && label.trim() !== '' ? label : DEFAULT_LABEL;
|
|
13
51
|
}
|
|
14
52
|
|
|
15
53
|
/** Events fired by `<kai-dialog>`. */
|
|
@@ -40,6 +78,10 @@ interface Events {
|
|
|
40
78
|
* the dialog. Focus moves into the panel on open and is restored on close, and a
|
|
41
79
|
* basic Tab focus trap keeps keyboard focus inside while open.
|
|
42
80
|
*
|
|
81
|
+
* The dialog is always named: a projected `header` becomes its `aria-labelledby`,
|
|
82
|
+
* and otherwise `label` becomes its `aria-label` (defaulting to `Dialog`). The
|
|
83
|
+
* header wins when both are present, since ARIA ranks `aria-labelledby` first.
|
|
84
|
+
*
|
|
43
85
|
* Open state is the standard disclosure surface: settable+reflecting `open`,
|
|
44
86
|
* `kai-open-change`, and `show()`/`hide()`/`toggle()`; seed with `default-open`.
|
|
45
87
|
* It also exposes `focus()` to move focus to the panel. Parts: `backdrop` ·
|
|
@@ -48,6 +90,7 @@ interface Events {
|
|
|
48
90
|
defineWebComponent<Props, Events>('kai-dialog', {
|
|
49
91
|
open: undefined,
|
|
50
92
|
defaultOpen: undefined,
|
|
93
|
+
label: DEFAULT_LABEL,
|
|
51
94
|
}, (props, ctx) => {
|
|
52
95
|
const { flag, element, expose } = ctx;
|
|
53
96
|
let api: DialogController | undefined;
|
|
@@ -87,6 +130,10 @@ defineWebComponent<Props, Events>('kai-dialog', {
|
|
|
87
130
|
return (
|
|
88
131
|
<Dialog
|
|
89
132
|
defaultOpen={flag('defaultOpen')}
|
|
133
|
+
// The primitive already ranks these correctly — it emits `aria-labelledby` when
|
|
134
|
+
// a header is present and `aria-label` only when one is not — so the facade just
|
|
135
|
+
// has to HAND the name over, which is the wiring that was missing.
|
|
136
|
+
aria-label={resolveLabel(props.label)}
|
|
90
137
|
header={hasHeader() ? <slot name="header" /> : undefined}
|
|
91
138
|
footer={hasFooter() ? <slot name="footer" /> : undefined}
|
|
92
139
|
controllerRef={(a) => (api = a)}
|
|
@@ -37,22 +37,23 @@ export function wireDisclosure<E extends { 'kai-open-change': { open: boolean }
|
|
|
37
37
|
getApi: () => OpenController | undefined,
|
|
38
38
|
openProp: () => unknown,
|
|
39
39
|
): void {
|
|
40
|
-
const { element, dispatch, flag, expose } = ctx;
|
|
40
|
+
const { element, dispatch, flag, reflectFlag, expose } = ctx;
|
|
41
41
|
let prev: boolean | undefined;
|
|
42
42
|
|
|
43
|
-
// Reflect internal open → the `[open]` host attribute + fire kai-open-change.
|
|
44
|
-
createEffect(() => {
|
|
45
|
-
const api = getApi();
|
|
46
|
-
if (!api) return;
|
|
47
|
-
const o = api.open();
|
|
48
|
-
element.toggleAttribute('open', o);
|
|
49
|
-
if (prev !== undefined && prev !== o) dispatch('kai-open-change', { open: o } as E['kai-open-change']);
|
|
50
|
-
prev = o;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
43
|
// External `open` prop/attr → drive internal state. Only when the consumer has
|
|
54
44
|
// EXPLICITLY set it (so a defaultOpen seed survives mount); the equality guard
|
|
55
|
-
// keeps the reflect
|
|
45
|
+
// keeps the reflect below from looping back through the prop.
|
|
46
|
+
//
|
|
47
|
+
// THIS RUNS FIRST, AND THE ORDER IS THE FIX FOR A REAL DEFECT. It used to run
|
|
48
|
+
// second, after the outward reflection — which on the very first pass read a
|
|
49
|
+
// controller still in its default CLOSED state and called
|
|
50
|
+
// `toggleAttribute('open', false)`, DELETING the author's attribute before anything
|
|
51
|
+
// had read it. This effect then saw no attribute and a prop that
|
|
52
|
+
// component-register had parsed to `undefined`, concluded nothing was asked for,
|
|
53
|
+
// and left the element shut. Net result: `<kai-reasoning open>` — the plain HTML
|
|
54
|
+
// spelling the `open` prop's own doc advertises — never opened; only `default-open`
|
|
55
|
+
// did. Reading intent IN before reflecting state OUT is what makes the author's
|
|
56
|
+
// attribute survive long enough to mean something.
|
|
56
57
|
createEffect(() => {
|
|
57
58
|
const api = getApi();
|
|
58
59
|
if (!api) return;
|
|
@@ -62,6 +63,27 @@ export function wireDisclosure<E extends { 'kai-open-change': { open: boolean }
|
|
|
62
63
|
if (desired !== untrack(api.open)) api.setOpen(desired);
|
|
63
64
|
});
|
|
64
65
|
|
|
66
|
+
// Reflect internal open → the `[open]` host attribute.
|
|
67
|
+
//
|
|
68
|
+
// Through `reflectFlag`, whose SOURCE is the controller rather than the prop — this
|
|
69
|
+
// element's truth is its internal open signal, not `props.open`. It also installs
|
|
70
|
+
// the read-back accessor, which this wiring needed and did not have: `el.open = true`
|
|
71
|
+
// used to leave `el.open === undefined`, exactly as `kai-chat`'s `loading` did
|
|
72
|
+
// (findings G-05). Returning `undefined` before the primitive has handed its
|
|
73
|
+
// controller up leaves the author's `<el open>` attribute alone.
|
|
74
|
+
reflectFlag('open', () => getApi()?.open());
|
|
75
|
+
|
|
76
|
+
// kai-open-change, fired once per change. Separate from the reflection above
|
|
77
|
+
// because it is a notification, not a reflection; both run in the same batch, so
|
|
78
|
+
// splitting them changes nothing observable about the ordering.
|
|
79
|
+
createEffect(() => {
|
|
80
|
+
const api = getApi();
|
|
81
|
+
if (!api) return;
|
|
82
|
+
const o = api.open();
|
|
83
|
+
if (prev !== undefined && prev !== o) dispatch('kai-open-change', { open: o } as E['kai-open-change']);
|
|
84
|
+
prev = o;
|
|
85
|
+
});
|
|
86
|
+
|
|
65
87
|
expose({
|
|
66
88
|
/** Open it programmatically (no-op while disabled). */
|
|
67
89
|
show: () => { if (!flag('disabled')) getApi()?.setOpen(true); },
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { untrack } from 'solid-js';
|
|
2
|
+
import { defineWebComponent } from './define';
|
|
3
|
+
import {
|
|
4
|
+
Dock, DockCloseGlyph, DockLauncherGlyph,
|
|
5
|
+
type DockController, type DockFocusOnOpen, type DockPosition,
|
|
6
|
+
} from '../ui/dock';
|
|
7
|
+
import { wireDisclosure } from './disclosure';
|
|
8
|
+
|
|
9
|
+
interface Props extends Record<string, unknown> {
|
|
10
|
+
/** Drive/observe open state (Shoelace-style: settable + reflected to the `open`
|
|
11
|
+
* attribute; the element still self-manages on the launcher and Escape). Set
|
|
12
|
+
* `el.open = true`, or `<kai-dock open>`; listen for `kai-open-change`. */
|
|
13
|
+
open?: boolean;
|
|
14
|
+
/** Initial open state on mount (uncontrolled seed). */
|
|
15
|
+
defaultOpen?: boolean;
|
|
16
|
+
/** Which corner the dock sits in. Logical, so `-end` follows the writing direction
|
|
17
|
+
* and an RTL page docks on the left. Attribute: `position`. */
|
|
18
|
+
position?: DockPosition;
|
|
19
|
+
/** The widget's NAME. Derives the panel's accessible name and both launcher names
|
|
20
|
+
* (`Open ${label}` / `Close ${label}`). Defaults to `Chat`. */
|
|
21
|
+
label?: string;
|
|
22
|
+
/** i18n override for the launcher's name while closed (default `Open ${label}`). */
|
|
23
|
+
openLabel?: string;
|
|
24
|
+
/** i18n override for the launcher's name while open (default `Close ${label}`). */
|
|
25
|
+
closeLabel?: string;
|
|
26
|
+
/** Show the unread dot. YOURS: it renders only while closed, and the dock never
|
|
27
|
+
* writes it back. Clear it in your `kai-open-change` handler. */
|
|
28
|
+
unread?: boolean;
|
|
29
|
+
/** Disable the launcher; `show()` and `toggle()` are gated on it. */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/** Where focus lands on open: `content` (default, the first element you slotted),
|
|
32
|
+
* `panel`, or `none`. Attribute: `focus-on-open`. */
|
|
33
|
+
focusOnOpen?: DockFocusOnOpen;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Events fired by `<kai-dock>`. */
|
|
37
|
+
interface Events {
|
|
38
|
+
/** The dock opened or closed (the launcher, Escape, a driven `open`, or a method). */
|
|
39
|
+
'kai-open-change': { open: boolean };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* `<kai-dock>` — the corner launcher: a floating button pinned to a corner of the
|
|
44
|
+
* viewport, and a panel above it holding whatever you slot in. This is the "chat
|
|
45
|
+
* bubble in the bottom-right" affordance. (Not to be confused with
|
|
46
|
+
* `<kai-prompt-dock>`, which is a recessed tray that frames a prompt INPUT and does
|
|
47
|
+
* not float, launch or open anything.)
|
|
48
|
+
*
|
|
49
|
+
* **How to use** — slot the surface, and let the dock own the button:
|
|
50
|
+
* ```html
|
|
51
|
+
* <kai-dock label="Aurora support">
|
|
52
|
+
* <kai-chat slot="panel" chat-title="Aurora Support"></kai-chat>
|
|
53
|
+
* </kai-dock>
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* The panel is content-agnostic: a `<kai-chat>`, a form, your own element. The dock
|
|
57
|
+
* never reads or types it. `slot="launcher"` / `slot="launcher-open"` swap the icon
|
|
58
|
+
* INSIDE the built-in button — the button itself is never slotted away, because the
|
|
59
|
+
* dock owns `aria-expanded`, `aria-controls`, the toggle wiring and the focus return,
|
|
60
|
+
* and a replaced button would take all four with it.
|
|
61
|
+
*
|
|
62
|
+
* Open state is the standard disclosure surface: settable+reflecting `open`,
|
|
63
|
+
* `kai-open-change`, and `show()`/`hide()`/`toggle()`; seed with `default-open`. It
|
|
64
|
+
* also exposes `focus()` — the panel while open, the launcher while closed.
|
|
65
|
+
*
|
|
66
|
+
* Neither `default-open` nor `open` moves focus at mount. A widget docked on someone
|
|
67
|
+
* else's page does not get to steal focus on load, which is the one place this
|
|
68
|
+
* element differs from `<kai-dialog>`, where a modal opened at mount takes focus on
|
|
69
|
+
* purpose. Opening it later does move focus, per `focus-on-open`.
|
|
70
|
+
*
|
|
71
|
+
* Closed does not mean gone: the panel keeps its layout box (`visibility: hidden` +
|
|
72
|
+
* `inert`), so a thread inside it never re-measures from zero and a reply that lands
|
|
73
|
+
* while closed is really there. `unread` is yours to set and yours to clear; the dot
|
|
74
|
+
* just stops rendering while open.
|
|
75
|
+
*
|
|
76
|
+
* Escape closes only while the dock holds focus, and is never swallowed — a widget
|
|
77
|
+
* docked on someone else's page does not get to eat their Escape. There is no focus
|
|
78
|
+
* trap; the page stays usable, which is the point of "docked".
|
|
79
|
+
*
|
|
80
|
+
* Geometry is CSS custom properties, not props: `--kai-dock-width` ·
|
|
81
|
+
* `--kai-dock-height` · `--kai-dock-inset` · `--kai-dock-gap` · `--kai-dock-radius` ·
|
|
82
|
+
* `--kai-dock-z` · `--kai-dock-launcher-size`. Narrow viewports go full-bleed by
|
|
83
|
+
* default. Parts: `launcher` · `panel` · `badge`.
|
|
84
|
+
*
|
|
85
|
+
* Put it as a body-level child: a `transform` / `filter` / `contain` ancestor makes
|
|
86
|
+
* `position: fixed` resolve against that ancestor instead of the viewport.
|
|
87
|
+
*
|
|
88
|
+
* **Migrating a hand-rolled widget onto this element changes two behaviours**, both
|
|
89
|
+
* deliberately, so check them rather than assuming a drop-in:
|
|
90
|
+
*
|
|
91
|
+
* 1. **Escape is scoped to the dock.** Hand-rolled versions of this widget typically
|
|
92
|
+
* listen on `document` and close on any Escape anywhere on the page. This one
|
|
93
|
+
* closes only while the dock holds focus, and never stops the event. If your app
|
|
94
|
+
* relied on Escape-anywhere, that is now the host page's key again.
|
|
95
|
+
* 2. **The panel keeps its layout box while closed.** It is hidden with
|
|
96
|
+
* `visibility` + `inert`, not `display: none`, and is never unmounted, so whatever
|
|
97
|
+
* you slot in KEEPS RENDERING in the background: a stream still folds in, timers
|
|
98
|
+
* still run, and heights stay measured. That is what makes `unread` honest and
|
|
99
|
+
* what stops a reopened thread re-measuring from zero, but it does mean a panel
|
|
100
|
+
* that was free while `display: none` no longer is.
|
|
101
|
+
*/
|
|
102
|
+
defineWebComponent<Props, Events>('kai-dock', {
|
|
103
|
+
open: undefined,
|
|
104
|
+
defaultOpen: undefined,
|
|
105
|
+
position: 'bottom-end',
|
|
106
|
+
label: 'Chat',
|
|
107
|
+
openLabel: undefined,
|
|
108
|
+
closeLabel: undefined,
|
|
109
|
+
unread: undefined,
|
|
110
|
+
disabled: undefined,
|
|
111
|
+
focusOnOpen: 'content',
|
|
112
|
+
}, (props, ctx) => {
|
|
113
|
+
const { flag, element, expose, reflectFlag } = ctx;
|
|
114
|
+
let api: DockController | undefined;
|
|
115
|
+
let panel: HTMLElement | undefined;
|
|
116
|
+
let launcher: HTMLButtonElement | undefined;
|
|
117
|
+
|
|
118
|
+
// The standard disclosure surface: settable+reflecting `open`, kai-open-change,
|
|
119
|
+
// show/hide/toggle. See ./disclosure — and note it is the SOLE emitter of the
|
|
120
|
+
// event, so the primitive's onOpenChange is deliberately not wired here.
|
|
121
|
+
wireDisclosure(ctx, () => api, () => props.open);
|
|
122
|
+
|
|
123
|
+
// The other three booleans get the same read-back treatment, for the same reason:
|
|
124
|
+
// `<kai-dock unread>` parses to `undefined`, so without this the property would
|
|
125
|
+
// contradict the attribute that set it (findings G-05). Reflecting `unread` syncs
|
|
126
|
+
// the ATTRIBUTE to the prop and never changes the VALUE — the dock still never
|
|
127
|
+
// decides that a message has been read.
|
|
128
|
+
reflectFlag('unread');
|
|
129
|
+
reflectFlag('disabled');
|
|
130
|
+
reflectFlag('defaultOpen');
|
|
131
|
+
|
|
132
|
+
// Seed the primitive from EITHER spelling, read once at upgrade.
|
|
133
|
+
//
|
|
134
|
+
// `open` is folded in here rather than left to wireDisclosure's effect on purpose.
|
|
135
|
+
// That effect runs a tick after mount, so `<kai-dock open>` would mount closed and
|
|
136
|
+
// then transition — which the primitive's focus effect would correctly read as a
|
|
137
|
+
// real open and steal focus with, on page load, on someone else's page. Seeding
|
|
138
|
+
// makes mount a non-event for both spellings; wireDisclosure's effect then finds
|
|
139
|
+
// the value already correct and its equality guard makes it a no-op.
|
|
140
|
+
//
|
|
141
|
+
// UNTRACKED, and that is not defensive noise — it is the fix for a real defect this
|
|
142
|
+
// element shipped for about ten minutes. A facade body runs inside the tracking
|
|
143
|
+
// scope that inserts it, so a bare `flag('open')` here subscribes the WHOLE FACADE
|
|
144
|
+
// to `open`: every toggle re-ran it, which re-created the `<Dock>`, its panel div
|
|
145
|
+
// and its controller. The visible symptoms were far away from the cause — focus
|
|
146
|
+
// never moved (each fresh focus effect was re-seeded with the current state, so it
|
|
147
|
+
// saw no transition) and `kai-open-change` never fired (wireDisclosure had latched
|
|
148
|
+
// the first, discarded controller). Reading a prop at the top level of a facade is
|
|
149
|
+
// the general trap; `untrack` is how you say "seed", and it is what makes this a
|
|
150
|
+
// seed rather than a subscription.
|
|
151
|
+
const seed = untrack(() => flag('open') || flag('defaultOpen'));
|
|
152
|
+
|
|
153
|
+
expose({
|
|
154
|
+
/** Move focus to the panel while open, or to the launcher while closed. */
|
|
155
|
+
focus: (options?: FocusOptions) =>
|
|
156
|
+
(api?.open() ? panel : launcher)?.focus(options),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// The `content` focus target: the first element assigned to the panel. Read off the
|
|
160
|
+
// live slots rather than off `element.children`, so it is the ASSIGNMENT that
|
|
161
|
+
// decides — a child whose `slot` attribute changes moves with it, and a comment or
|
|
162
|
+
// whitespace text node is not mistaken for content.
|
|
163
|
+
const contentTarget = () => {
|
|
164
|
+
const slots = panel?.querySelectorAll('slot');
|
|
165
|
+
for (const slot of Array.from(slots ?? [])) {
|
|
166
|
+
const first = (slot as HTMLSlotElement).assignedElements()[0];
|
|
167
|
+
if (first instanceof HTMLElement) return first;
|
|
168
|
+
}
|
|
169
|
+
return undefined;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<Dock
|
|
174
|
+
defaultOpen={seed}
|
|
175
|
+
position={props.position as DockPosition}
|
|
176
|
+
label={props.label as string}
|
|
177
|
+
openLabel={props.openLabel as string | undefined}
|
|
178
|
+
closeLabel={props.closeLabel as string | undefined}
|
|
179
|
+
unread={flag('unread')}
|
|
180
|
+
disabled={flag('disabled')}
|
|
181
|
+
focusOnOpen={props.focusOnOpen as DockFocusOnOpen}
|
|
182
|
+
contentTarget={contentTarget}
|
|
183
|
+
controllerRef={(a) => (api = a)}
|
|
184
|
+
panelRef={(el) => (panel = el)}
|
|
185
|
+
launcherRef={(el) => (launcher = el)}
|
|
186
|
+
// NATIVE SLOT FALLBACK does the whole icon chain, with no occupancy tracking and
|
|
187
|
+
// no MutationObserver: an unfilled slot renders its fallback content, and a slot
|
|
188
|
+
// nested in another slot's fallback still receives its own assignment. So
|
|
189
|
+
// `launcher-open` wins while open; failing that the consumer's `launcher` glyph
|
|
190
|
+
// STAYS rather than morphing into a built-in ✕ that clashes with their art;
|
|
191
|
+
// failing that the built-in ✕. Both defaults are the primitive's own, imported
|
|
192
|
+
// rather than re-drawn here.
|
|
193
|
+
launcher={<slot name="launcher"><DockLauncherGlyph /></slot>}
|
|
194
|
+
launcherOpen={(
|
|
195
|
+
<slot name="launcher-open">
|
|
196
|
+
<slot name="launcher"><DockCloseGlyph /></slot>
|
|
197
|
+
</slot>
|
|
198
|
+
)}
|
|
199
|
+
>
|
|
200
|
+
<slot name="panel" />
|
|
201
|
+
<slot />
|
|
202
|
+
</Dock>
|
|
203
|
+
);
|
|
204
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Show } from 'solid-js';
|
|
2
|
+
import { MoreHorizontal } from 'lucide-solid';
|
|
3
|
+
import { Dropdown, DropdownTrigger, DropdownContent, type DropdownController } from '../ui/dropdown';
|
|
4
|
+
import { renderIcon } from '../ui/icon';
|
|
5
|
+
import { cn } from '../utils/cn';
|
|
6
|
+
import { defineWebComponent } from './define';
|
|
7
|
+
import { wireDisclosure } from './disclosure';
|
|
8
|
+
|
|
9
|
+
interface Props extends Record<string, unknown> {
|
|
10
|
+
/** Built-in trigger: leading icon (a named icon like `"plus"`, an image
|
|
11
|
+
* URL/data-URI, or text). A slotted `slot="trigger"` overrides it. */
|
|
12
|
+
triggerIcon?: string;
|
|
13
|
+
/** Built-in trigger: a text label. This is the trigger's VISIBLE text, so it is
|
|
14
|
+
* also its accessible name, and `label` does not override it: an accessible
|
|
15
|
+
* name that does not contain the visible text is unreachable by speech input
|
|
16
|
+
* (WCAG 2.5.3, Label in Name). Same rule `kai-menu` follows. */
|
|
17
|
+
triggerLabel?: string;
|
|
18
|
+
/** Built-in trigger: a trailing icon (e.g. `"chevron-down"` for a select look). */
|
|
19
|
+
triggerIconTrailing?: string;
|
|
20
|
+
/** Accessible name for a trigger with no visible label. Ignored when
|
|
21
|
+
* `triggerLabel` is set, which is already the visible name. It DOES name a
|
|
22
|
+
* slotted `slot="trigger"`, which is VISUAL content with the name supplied
|
|
23
|
+
* separately: the same two-slot distinction `kai-menu` documents. */
|
|
24
|
+
label?: string;
|
|
25
|
+
/** Stretch the trigger to the full width of its container (a block row).
|
|
26
|
+
* Attribute: `full`. */
|
|
27
|
+
full?: boolean;
|
|
28
|
+
/** Drive/observe open state (Shoelace-style: settable + reflected to the `open`
|
|
29
|
+
* attribute, the menu still self-manages on click/keyboard). Set `el.open = true`,
|
|
30
|
+
* or `<kai-dropdown open>`; listen for `kai-open-change`. */
|
|
31
|
+
open?: boolean;
|
|
32
|
+
/** Initial open state on mount (uncontrolled seed). */
|
|
33
|
+
defaultOpen?: boolean;
|
|
34
|
+
/** Disable the trigger: click/keyboard and `show()` no longer open the menu. */
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Events fired by `<kai-dropdown>`. */
|
|
39
|
+
interface Events {
|
|
40
|
+
/** The menu opened or closed (click, keyboard, Escape, outside-click, or a method). */
|
|
41
|
+
'kai-open-change': { open: boolean };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `<kai-dropdown>` — a trigger plus a floating menu surface you fill yourself.
|
|
46
|
+
*
|
|
47
|
+
* The sibling of `<kai-menu>`, split by who owns the menu body: `kai-menu` renders
|
|
48
|
+
* a JSON `items` tree for you, this one gives you the surface and lets you slot
|
|
49
|
+
* ARBITRARY markup into it — the shape a framework consumer needs when the rows
|
|
50
|
+
* are their own components rather than data.
|
|
51
|
+
*
|
|
52
|
+
* ```html
|
|
53
|
+
* <kai-dropdown label="Row actions">
|
|
54
|
+
* <span slot="trigger">⋮</span>
|
|
55
|
+
* <div role="menuitem" tabindex="-1">Rename</div>
|
|
56
|
+
* <div role="menuitem" tabindex="-1">Duplicate</div>
|
|
57
|
+
* </kai-dropdown>
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* The default slot is the menu body; `trigger` is the control it anchors to. It
|
|
61
|
+
* fires `kai-open-change` with `{ open }` on every change, accepts `open` /
|
|
62
|
+
* `defaultOpen` / `disabled`, and exposes `show()` / `hide()` / `toggle()`.
|
|
63
|
+
*
|
|
64
|
+
* KEYBOARD: give each row `role="menuitem"` and it joins roving focus. ArrowUp/Down,
|
|
65
|
+
* Home/End and typeahead reach SLOTTED rows because `menuItems()` in
|
|
66
|
+
* `../ui/dropdown.tsx` walks the flat tree rather than querying the shadow tree,
|
|
67
|
+
* which contains none of the light-DOM nodes a `<slot>` projects. Rows carrying
|
|
68
|
+
* `aria-disabled="true"` are skipped.
|
|
69
|
+
*/
|
|
70
|
+
defineWebComponent<Props, Events>('kai-dropdown', {
|
|
71
|
+
triggerIcon: undefined,
|
|
72
|
+
triggerLabel: undefined,
|
|
73
|
+
triggerIconTrailing: undefined,
|
|
74
|
+
label: undefined,
|
|
75
|
+
full: false,
|
|
76
|
+
open: undefined,
|
|
77
|
+
defaultOpen: undefined,
|
|
78
|
+
disabled: undefined,
|
|
79
|
+
}, (props, ctx) => {
|
|
80
|
+
const { flag } = ctx;
|
|
81
|
+
let api: DropdownController | undefined;
|
|
82
|
+
|
|
83
|
+
// The standard overlay surface: settable+reflecting `open`, kai-open-change,
|
|
84
|
+
// show/hide/toggle, disabled-gating. See ./disclosure.
|
|
85
|
+
wireDisclosure(ctx, () => api, () => props.open);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<>
|
|
89
|
+
{/* The host shrinks to the trigger by default (UA inline); `full` makes it a
|
|
90
|
+
block whose trigger fills the width — the kai-button/kai-menu pattern. */}
|
|
91
|
+
<style>{':host([full]){display:block}'}</style>
|
|
92
|
+
<Dropdown
|
|
93
|
+
defaultOpen={flag('defaultOpen')}
|
|
94
|
+
disabled={flag('disabled')}
|
|
95
|
+
controllerRef={(a) => (api = a)}
|
|
96
|
+
>
|
|
97
|
+
<DropdownTrigger
|
|
98
|
+
class={cn(
|
|
99
|
+
'inline-flex items-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
100
|
+
props.triggerLabel
|
|
101
|
+
? 'gap-1.5 px-2 py-1.5 text-sm font-medium text-muted-foreground hover:bg-accent hover:text-foreground'
|
|
102
|
+
: 'justify-center p-1.5 text-foreground hover:bg-muted',
|
|
103
|
+
flag('full') && 'w-full',
|
|
104
|
+
)}
|
|
105
|
+
// A visible `triggerLabel` IS the name, so `label` must not be layered
|
|
106
|
+
// over it: aria-label REPLACES the computed name, locking speech-input
|
|
107
|
+
// users out (WCAG 2.5.3). Same rule kai-menu and kai-button follow.
|
|
108
|
+
aria-label={props.triggerLabel ? undefined : (props.label ?? 'Open menu')}
|
|
109
|
+
>
|
|
110
|
+
<slot name="trigger">
|
|
111
|
+
<Show when={props.triggerIcon}>{renderIcon(props.triggerIcon, { class: 'size-4 shrink-0' })}</Show>
|
|
112
|
+
<Show when={props.triggerLabel}>{props.triggerLabel}</Show>
|
|
113
|
+
<Show when={props.triggerIconTrailing}>{renderIcon(props.triggerIconTrailing, { class: 'size-3.5 shrink-0 opacity-60' })}</Show>
|
|
114
|
+
<Show when={!props.triggerIcon && !props.triggerLabel}><MoreHorizontal class="size-4" /></Show>
|
|
115
|
+
</slot>
|
|
116
|
+
</DropdownTrigger>
|
|
117
|
+
<DropdownContent class="min-w-[10rem]">
|
|
118
|
+
<slot />
|
|
119
|
+
</DropdownContent>
|
|
120
|
+
</Dropdown>
|
|
121
|
+
</>
|
|
122
|
+
);
|
|
123
|
+
});
|