@adia-ai/web-components 0.0.1
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 +195 -0
- package/a2ui/dockables/action.js +152 -0
- package/a2ui/dockables/base.js +30 -0
- package/a2ui/dockables/controller.js +97 -0
- package/a2ui/dockables/data-source.js +103 -0
- package/a2ui/dockables/index.js +6 -0
- package/a2ui/dockables/lifecycle.js +84 -0
- package/a2ui/dockables/provider.js +59 -0
- package/a2ui/index.js +19 -0
- package/a2ui/manifest-runtime.js +226 -0
- package/a2ui/registry.js +200 -0
- package/a2ui/renderer.js +361 -0
- package/a2ui/root.js +152 -0
- package/a2ui/stream.js +243 -0
- package/a2ui/surface-manifest.js +294 -0
- package/a2ui/surface.js +222 -0
- package/a2ui/wire-factory.js +134 -0
- package/a2ui/wiring-engine.js +209 -0
- package/a2ui/wiring-registry.js +342 -0
- package/components/accordion/accordion.a2ui.json +129 -0
- package/components/accordion/accordion.css +133 -0
- package/components/accordion/accordion.js +125 -0
- package/components/accordion/accordion.yaml +527 -0
- package/components/action-list/action-list.a2ui.json +64 -0
- package/components/action-list/action-list.css +115 -0
- package/components/action-list/action-list.js +149 -0
- package/components/action-list/action-list.yaml +56 -0
- package/components/agent-artifact/agent-artifact.a2ui.json +99 -0
- package/components/agent-artifact/agent-artifact.css +94 -0
- package/components/agent-artifact/agent-artifact.js +169 -0
- package/components/agent-artifact/agent-artifact.yaml +71 -0
- package/components/agent-feedback-bar/agent-feedback-bar.a2ui.json +91 -0
- package/components/agent-feedback-bar/agent-feedback-bar.css +33 -0
- package/components/agent-feedback-bar/agent-feedback-bar.js +152 -0
- package/components/agent-feedback-bar/agent-feedback-bar.yaml +65 -0
- package/components/agent-questions/agent-questions.a2ui.json +89 -0
- package/components/agent-questions/agent-questions.css +146 -0
- package/components/agent-questions/agent-questions.js +189 -0
- package/components/agent-questions/agent-questions.yaml +63 -0
- package/components/agent-reasoning/agent-reasoning.a2ui.json +100 -0
- package/components/agent-reasoning/agent-reasoning.css +273 -0
- package/components/agent-reasoning/agent-reasoning.js +469 -0
- package/components/agent-reasoning/agent-reasoning.yaml +70 -0
- package/components/agent-suggestions/agent-suggestions.a2ui.json +87 -0
- package/components/agent-suggestions/agent-suggestions.css +18 -0
- package/components/agent-suggestions/agent-suggestions.js +87 -0
- package/components/agent-suggestions/agent-suggestions.yaml +59 -0
- package/components/agent-trace/agent-trace.a2ui.json +78 -0
- package/components/agent-trace/agent-trace.css +275 -0
- package/components/agent-trace/agent-trace.js +216 -0
- package/components/agent-trace/agent-trace.yaml +53 -0
- package/components/alert/alert.a2ui.json +211 -0
- package/components/alert/alert.css +88 -0
- package/components/alert/alert.js +96 -0
- package/components/alert/alert.yaml +205 -0
- package/components/avatar/avatar.a2ui.json +215 -0
- package/components/avatar/avatar.css +159 -0
- package/components/avatar/avatar.js +157 -0
- package/components/avatar/avatar.yaml +559 -0
- package/components/badge/badge.a2ui.json +169 -0
- package/components/badge/badge.css +78 -0
- package/components/badge/badge.js +53 -0
- package/components/badge/badge.yaml +612 -0
- package/components/block/block.a2ui.json +135 -0
- package/components/block/block.css +29 -0
- package/components/block/block.js +23 -0
- package/components/block/block.yaml +115 -0
- package/components/breadcrumb/breadcrumb.a2ui.json +86 -0
- package/components/breadcrumb/breadcrumb.css +78 -0
- package/components/breadcrumb/breadcrumb.js +44 -0
- package/components/breadcrumb/breadcrumb.yaml +84 -0
- package/components/button/button.a2ui.json +172 -0
- package/components/button/button.css +168 -0
- package/components/button/button.js +60 -0
- package/components/button/button.yaml +120 -0
- package/components/calendar-picker/calendar-picker.a2ui.json +139 -0
- package/components/calendar-picker/calendar-picker.css +321 -0
- package/components/calendar-picker/calendar-picker.js +324 -0
- package/components/calendar-picker/calendar-picker.yaml +243 -0
- package/components/canvas/canvas.a2ui.json +75 -0
- package/components/canvas/canvas.css +52 -0
- package/components/canvas/canvas.js +179 -0
- package/components/canvas/canvas.yaml +62 -0
- package/components/card/card.a2ui.json +276 -0
- package/components/card/card.css +362 -0
- package/components/card/card.js +58 -0
- package/components/card/card.yaml +527 -0
- package/components/chart/chart.a2ui.json +298 -0
- package/components/chart/chart.css +512 -0
- package/components/chart/chart.js +1075 -0
- package/components/chart/chart.yaml +540 -0
- package/components/chat/chat-input.css +141 -0
- package/components/chat/chat-input.js +242 -0
- package/components/chat/chat.a2ui.json +181 -0
- package/components/chat/chat.css +193 -0
- package/components/chat/chat.js +155 -0
- package/components/chat/chat.yaml +230 -0
- package/components/check/check.a2ui.json +134 -0
- package/components/check/check.css +126 -0
- package/components/check/check.js +58 -0
- package/components/check/check.yaml +109 -0
- package/components/code/code.a2ui.json +153 -0
- package/components/code/code.css +133 -0
- package/components/code/code.js +114 -0
- package/components/code/code.yaml +163 -0
- package/components/col/col.a2ui.json +104 -0
- package/components/col/col.css +36 -0
- package/components/col/col.js +19 -0
- package/components/col/col.yaml +364 -0
- package/components/color-picker/color-picker.a2ui.json +100 -0
- package/components/color-picker/color-picker.css +182 -0
- package/components/color-picker/color-picker.js +537 -0
- package/components/color-picker/color-picker.yaml +105 -0
- package/components/command/command.a2ui.json +221 -0
- package/components/command/command.css +251 -0
- package/components/command/command.js +284 -0
- package/components/command/command.yaml +186 -0
- package/components/description-list/description-list.a2ui.json +89 -0
- package/components/description-list/description-list.css +70 -0
- package/components/description-list/description-list.js +75 -0
- package/components/description-list/description-list.yaml +59 -0
- package/components/divider/divider.a2ui.json +126 -0
- package/components/divider/divider.css +102 -0
- package/components/divider/divider.js +47 -0
- package/components/divider/divider.yaml +366 -0
- package/components/drawer/drawer.a2ui.json +199 -0
- package/components/drawer/drawer.css +342 -0
- package/components/drawer/drawer.js +263 -0
- package/components/drawer/drawer.yaml +366 -0
- package/components/embed/embed.a2ui.json +150 -0
- package/components/embed/embed.css +28 -0
- package/components/embed/embed.js +63 -0
- package/components/embed/embed.yaml +224 -0
- package/components/empty-state/empty-state.a2ui.json +133 -0
- package/components/empty-state/empty-state.css +58 -0
- package/components/empty-state/empty-state.js +87 -0
- package/components/empty-state/empty-state.yaml +314 -0
- package/components/footer/footer.a2ui.json +79 -0
- package/components/footer/footer.yaml +239 -0
- package/components/grid/grid.a2ui.json +171 -0
- package/components/grid/grid.css +37 -0
- package/components/grid/grid.js +21 -0
- package/components/grid/grid.yaml +577 -0
- package/components/header/header.a2ui.json +76 -0
- package/components/header/header.yaml +336 -0
- package/components/heatmap/heatmap.a2ui.json +150 -0
- package/components/heatmap/heatmap.css +146 -0
- package/components/heatmap/heatmap.js +246 -0
- package/components/heatmap/heatmap.yaml +131 -0
- package/components/icon/icon.a2ui.json +79 -0
- package/components/icon/icon.css +20 -0
- package/components/icon/icon.js +26 -0
- package/components/icon/icon.yaml +233 -0
- package/components/image/image.a2ui.json +261 -0
- package/components/image/image.css +76 -0
- package/components/image/image.js +102 -0
- package/components/image/image.yaml +477 -0
- package/components/index.js +85 -0
- package/components/input/input.a2ui.json +284 -0
- package/components/input/input.css +162 -0
- package/components/input/input.js +148 -0
- package/components/input/input.yaml +496 -0
- package/components/inspector/inspector.a2ui.json +67 -0
- package/components/inspector/inspector.css +31 -0
- package/components/inspector/inspector.js +133 -0
- package/components/inspector/inspector.yaml +58 -0
- package/components/kbd/kbd.a2ui.json +96 -0
- package/components/kbd/kbd.css +62 -0
- package/components/kbd/kbd.js +24 -0
- package/components/kbd/kbd.yaml +213 -0
- package/components/list/list.a2ui.json +145 -0
- package/components/list/list.css +103 -0
- package/components/list/list.js +236 -0
- package/components/list/list.yaml +122 -0
- package/components/menu/menu.a2ui.json +146 -0
- package/components/menu/menu.css +146 -0
- package/components/menu/menu.js +296 -0
- package/components/menu/menu.yaml +123 -0
- package/components/modal/modal.a2ui.json +136 -0
- package/components/modal/modal.css +153 -0
- package/components/modal/modal.js +181 -0
- package/components/modal/modal.yaml +114 -0
- package/components/noodles/noodles.a2ui.json +145 -0
- package/components/noodles/noodles.css +118 -0
- package/components/noodles/noodles.js +470 -0
- package/components/noodles/noodles.yaml +123 -0
- package/components/otp-input/otp-input.a2ui.json +104 -0
- package/components/otp-input/otp-input.css +78 -0
- package/components/otp-input/otp-input.js +170 -0
- package/components/otp-input/otp-input.yaml +218 -0
- package/components/pagination/pagination.a2ui.json +122 -0
- package/components/pagination/pagination.css +162 -0
- package/components/pagination/pagination.js +185 -0
- package/components/pagination/pagination.yaml +165 -0
- package/components/pane/pane.a2ui.json +94 -0
- package/components/pane/pane.css +166 -0
- package/components/pane/pane.js +140 -0
- package/components/pane/pane.yaml +197 -0
- package/components/pipeline-status/pipeline-status.a2ui.json +90 -0
- package/components/pipeline-status/pipeline-status.css +162 -0
- package/components/pipeline-status/pipeline-status.js +176 -0
- package/components/pipeline-status/pipeline-status.yaml +99 -0
- package/components/popover/popover.a2ui.json +181 -0
- package/components/popover/popover.css +57 -0
- package/components/popover/popover.js +170 -0
- package/components/popover/popover.yaml +257 -0
- package/components/progress/progress.a2ui.json +199 -0
- package/components/progress/progress.css +88 -0
- package/components/progress/progress.js +64 -0
- package/components/progress/progress.yaml +342 -0
- package/components/progress-row/progress-row.a2ui.json +100 -0
- package/components/progress-row/progress-row.css +57 -0
- package/components/progress-row/progress-row.js +92 -0
- package/components/progress-row/progress-row.yaml +87 -0
- package/components/radio/radio.a2ui.json +232 -0
- package/components/radio/radio.css +102 -0
- package/components/radio/radio.js +73 -0
- package/components/radio/radio.yaml +248 -0
- package/components/range/range.a2ui.json +151 -0
- package/components/range/range.css +148 -0
- package/components/range/range.js +177 -0
- package/components/range/range.yaml +188 -0
- package/components/rating/rating.a2ui.json +105 -0
- package/components/rating/rating.css +92 -0
- package/components/rating/rating.js +138 -0
- package/components/rating/rating.yaml +74 -0
- package/components/richtext/richtext.a2ui.json +82 -0
- package/components/richtext/richtext.css +225 -0
- package/components/richtext/richtext.js +74 -0
- package/components/richtext/richtext.yaml +89 -0
- package/components/row/row.a2ui.json +102 -0
- package/components/row/row.css +51 -0
- package/components/row/row.js +39 -0
- package/components/row/row.yaml +358 -0
- package/components/search/search.a2ui.json +186 -0
- package/components/search/search.css +28 -0
- package/components/search/search.js +124 -0
- package/components/search/search.yaml +154 -0
- package/components/section/section.a2ui.json +78 -0
- package/components/section/section.yaml +338 -0
- package/components/segment/segment.a2ui.json +100 -0
- package/components/segment/segment.css +81 -0
- package/components/segment/segment.js +32 -0
- package/components/segment/segment.yaml +216 -0
- package/components/segmented/segmented.a2ui.json +106 -0
- package/components/segmented/segmented.css +67 -0
- package/components/segmented/segmented.js +149 -0
- package/components/segmented/segmented.yaml +91 -0
- package/components/select/select.a2ui.json +203 -0
- package/components/select/select.css +277 -0
- package/components/select/select.js +388 -0
- package/components/select/select.yaml +375 -0
- package/components/skeleton/skeleton.a2ui.json +120 -0
- package/components/skeleton/skeleton.css +47 -0
- package/components/skeleton/skeleton.js +43 -0
- package/components/skeleton/skeleton.yaml +153 -0
- package/components/slider/slider.a2ui.json +162 -0
- package/components/slider/slider.css +137 -0
- package/components/slider/slider.js +162 -0
- package/components/slider/slider.yaml +299 -0
- package/components/stack/stack.a2ui.json +62 -0
- package/components/stack/stack.css +28 -0
- package/components/stack/stack.js +18 -0
- package/components/stack/stack.yaml +54 -0
- package/components/stat/stat.a2ui.json +246 -0
- package/components/stat/stat.css +101 -0
- package/components/stat/stat.js +91 -0
- package/components/stat/stat.yaml +206 -0
- package/components/stepper/stepper.a2ui.json +77 -0
- package/components/stepper/stepper.css +243 -0
- package/components/stepper/stepper.js +118 -0
- package/components/stepper/stepper.yaml +73 -0
- package/components/stream/stream.a2ui.json +98 -0
- package/components/stream/stream.css +37 -0
- package/components/stream/stream.js +99 -0
- package/components/stream/stream.yaml +87 -0
- package/components/swiper/swiper.a2ui.json +140 -0
- package/components/swiper/swiper.css +267 -0
- package/components/swiper/swiper.js +285 -0
- package/components/swiper/swiper.yaml +268 -0
- package/components/switch/switch.a2ui.json +134 -0
- package/components/switch/switch.css +104 -0
- package/components/switch/switch.js +53 -0
- package/components/switch/switch.yaml +322 -0
- package/components/table/cell-types.js +296 -0
- package/components/table/table.a2ui.json +458 -0
- package/components/table/table.css +531 -0
- package/components/table/table.js +1392 -0
- package/components/table/table.yaml +528 -0
- package/components/tabs/tab.js +34 -0
- package/components/tabs/tabs.a2ui.json +174 -0
- package/components/tabs/tabs.css +162 -0
- package/components/tabs/tabs.js +226 -0
- package/components/tabs/tabs.yaml +255 -0
- package/components/tag/tag.a2ui.json +148 -0
- package/components/tag/tag.css +118 -0
- package/components/tag/tag.js +88 -0
- package/components/tag/tag.yaml +125 -0
- package/components/text/text.a2ui.json +99 -0
- package/components/text/text.css +65 -0
- package/components/text/text.js +35 -0
- package/components/text/text.yaml +360 -0
- package/components/textarea/textarea.a2ui.json +91 -0
- package/components/textarea/textarea.css +93 -0
- package/components/textarea/textarea.js +114 -0
- package/components/textarea/textarea.yaml +79 -0
- package/components/timeline/timeline.a2ui.json +82 -0
- package/components/timeline/timeline.css +389 -0
- package/components/timeline/timeline.js +171 -0
- package/components/timeline/timeline.yaml +185 -0
- package/components/toast/toast.a2ui.json +199 -0
- package/components/toast/toast.css +211 -0
- package/components/toast/toast.js +146 -0
- package/components/toast/toast.yaml +184 -0
- package/components/toggle-group/toggle-group.a2ui.json +126 -0
- package/components/toggle-group/toggle-group.css +102 -0
- package/components/toggle-group/toggle-group.js +147 -0
- package/components/toggle-group/toggle-group.yaml +98 -0
- package/components/toolbar/toolbar.a2ui.json +131 -0
- package/components/toolbar/toolbar.css +132 -0
- package/components/toolbar/toolbar.js +366 -0
- package/components/toolbar/toolbar.yaml +238 -0
- package/components/tooltip/tooltip.a2ui.json +148 -0
- package/components/tooltip/tooltip.css +39 -0
- package/components/tooltip/tooltip.js +96 -0
- package/components/tooltip/tooltip.yaml +201 -0
- package/components/tree/tree.a2ui.json +119 -0
- package/components/tree/tree.css +133 -0
- package/components/tree/tree.js +253 -0
- package/components/tree/tree.yaml +92 -0
- package/components/upload/upload.a2ui.json +185 -0
- package/components/upload/upload.css +115 -0
- package/components/upload/upload.js +189 -0
- package/components/upload/upload.yaml +302 -0
- package/core/anchor.js +187 -0
- package/core/controller.js +182 -0
- package/core/element.js +257 -0
- package/core/form.js +217 -0
- package/core/icons.js +180 -0
- package/core/markdown.js +95 -0
- package/core/polyfills.js +23 -0
- package/core/provider.js +262 -0
- package/core/signals.js +113 -0
- package/core/template.js +226 -0
- package/core/transport.js +77 -0
- package/package.json +38 -0
- package/patterns/adia-chat/adia-chat.a2ui.json +149 -0
- package/patterns/adia-chat/adia-chat.css +10 -0
- package/patterns/adia-chat/adia-chat.js +297 -0
- package/patterns/adia-chat/adia-chat.yaml +118 -0
- package/patterns/adia-chat/css/adia-chat.empty.css +12 -0
- package/patterns/adia-chat/css/adia-chat.layout.css +60 -0
- package/patterns/adia-chat/css/adia-chat.markdown.css +74 -0
- package/patterns/adia-chat/css/adia-chat.messages.css +87 -0
- package/patterns/adia-chat/css/adia-chat.streaming.css +30 -0
- package/patterns/adia-chat/css/adia-chat.tokens.css +95 -0
- package/patterns/adia-chat/index.html +93 -0
- package/patterns/adia-editor/adia-editor.a2ui.json +58 -0
- package/patterns/adia-editor/adia-editor.css +6 -0
- package/patterns/adia-editor/adia-editor.js +56 -0
- package/patterns/adia-editor/adia-editor.yaml +36 -0
- package/patterns/adia-editor/css/adia-editor.layout.css +86 -0
- package/patterns/adia-editor/css/adia-editor.tokens.css +28 -0
- package/patterns/adia-editor/index.html +179 -0
- package/patterns/app-nav/app-nav.a2ui.json +89 -0
- package/patterns/app-nav/app-nav.css +92 -0
- package/patterns/app-nav/app-nav.js +99 -0
- package/patterns/app-nav/app-nav.yaml +54 -0
- package/patterns/app-nav-group/app-nav-group.a2ui.json +82 -0
- package/patterns/app-nav-group/app-nav-group.css +261 -0
- package/patterns/app-nav-group/app-nav-group.js +116 -0
- package/patterns/app-nav-group/app-nav-group.yaml +59 -0
- package/patterns/app-nav-item/app-nav-item.a2ui.json +83 -0
- package/patterns/app-nav-item/app-nav-item.css +156 -0
- package/patterns/app-nav-item/app-nav-item.js +42 -0
- package/patterns/app-nav-item/app-nav-item.yaml +62 -0
- package/patterns/app-shell/app-shell.a2ui.json +114 -0
- package/patterns/app-shell/app-shell.css +14 -0
- package/patterns/app-shell/app-shell.js +251 -0
- package/patterns/app-shell/app-shell.yaml +66 -0
- package/patterns/app-shell/css/app-shell.collapsed.css +86 -0
- package/patterns/app-shell/css/app-shell.helpers.css +42 -0
- package/patterns/app-shell/css/app-shell.main.css +58 -0
- package/patterns/app-shell/css/app-shell.shell.css +44 -0
- package/patterns/app-shell/css/app-shell.sidebar.css +116 -0
- package/patterns/app-shell/css/app-shell.templates.css +214 -0
- package/patterns/app-shell/css/app-shell.tokens.css +116 -0
- package/patterns/app-shell/index.html +112 -0
- package/patterns/gen-ui/gen-ui.a2ui.json +72 -0
- package/patterns/gen-ui/gen-ui.css +83 -0
- package/patterns/gen-ui/gen-ui.js +136 -0
- package/patterns/gen-ui/gen-ui.yaml +43 -0
- package/patterns/index.js +10 -0
- package/patterns/section-nav/section-nav.a2ui.json +91 -0
- package/patterns/section-nav/section-nav.css +59 -0
- package/patterns/section-nav/section-nav.js +42 -0
- package/patterns/section-nav/section-nav.yaml +58 -0
- package/patterns/section-nav-group/section-nav-group.a2ui.json +95 -0
- package/patterns/section-nav-group/section-nav-group.css +74 -0
- package/patterns/section-nav-group/section-nav-group.js +84 -0
- package/patterns/section-nav-group/section-nav-group.yaml +66 -0
- package/patterns/section-nav-item/section-nav-item.a2ui.json +97 -0
- package/patterns/section-nav-item/section-nav-item.css +96 -0
- package/patterns/section-nav-item/section-nav-item.js +66 -0
- package/patterns/section-nav-item/section-nav-item.yaml +70 -0
- package/styles/colors/index.css +6 -0
- package/styles/colors/parameters.css +52 -0
- package/styles/colors/primitives-accent.css +89 -0
- package/styles/colors/primitives-brand.css +89 -0
- package/styles/colors/primitives-danger.css +89 -0
- package/styles/colors/primitives-info.css +89 -0
- package/styles/colors/primitives-neutral.css +91 -0
- package/styles/colors/primitives-shared.css +57 -0
- package/styles/colors/primitives-success.css +89 -0
- package/styles/colors/primitives-warning.css +89 -0
- package/styles/colors/primitives.css +17 -0
- package/styles/colors/scrims.css +182 -0
- package/styles/colors/semantics.css +595 -0
- package/styles/colors/surfaces.css +43 -0
- package/styles/fonts.css +99 -0
- package/styles/layouts/admin.css +7 -0
- package/styles/prose.css +186 -0
- package/styles/styles.css +193 -0
- package/styles/themes.css +155 -0
- package/styles/tokens.css +304 -0
- package/styles/typography.css +853 -0
- package/traits/active-state.js +24 -0
- package/traits/anchor-positioning.js +66 -0
- package/traits/attention-pulse.js +30 -0
- package/traits/confetti-burst.js +65 -0
- package/traits/confetti.js +57 -0
- package/traits/count-up.js +42 -0
- package/traits/define.js +76 -0
- package/traits/dirty-state.js +38 -0
- package/traits/drag-ghost.js +38 -0
- package/traits/draggable.js +73 -0
- package/traits/fade-presence.js +52 -0
- package/traits/focus-trap.js +63 -0
- package/traits/focusable.js +38 -0
- package/traits/glow-focus.js +33 -0
- package/traits/gradient-shift.js +32 -0
- package/traits/haptic-feedback.js +28 -0
- package/traits/hotkey.js +62 -0
- package/traits/hoverable.js +26 -0
- package/traits/index.js +55 -0
- package/traits/inertia-drag.js +133 -0
- package/traits/intersection-observer.js +33 -0
- package/traits/keyboard-nav.js +36 -0
- package/traits/magnetic-hover.js +37 -0
- package/traits/noise-texture.js +30 -0
- package/traits/parallax.js +42 -0
- package/traits/portal.js +27 -0
- package/traits/pressable.js +75 -0
- package/traits/resizable.js +100 -0
- package/traits/resize-observer.js +31 -0
- package/traits/ripple.js +53 -0
- package/traits/roving-tabindex.js +67 -0
- package/traits/scale-press.js +43 -0
- package/traits/scroll-lock.js +27 -0
- package/traits/shimmer-loading.js +44 -0
- package/traits/snap-to-grid.js +28 -0
- package/traits/sound-feedback.js +30 -0
- package/traits/spring-animate.js +56 -0
- package/traits/tilt-hover.js +37 -0
- package/traits/tossable.js +178 -0
- package/traits/typeahead.js +63 -0
- package/traits/typewriter.js +35 -0
- package/traits/validation.js +118 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { AdiaElement } from '@core/element.js';
|
|
2
|
+
import { renderMarkdown } from '@core/markdown.js';
|
|
3
|
+
|
|
4
|
+
function escapeHTML(s) {
|
|
5
|
+
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* <chat-ui> — Minimal chat container.
|
|
10
|
+
*
|
|
11
|
+
* Structure:
|
|
12
|
+
* <chat-ui>
|
|
13
|
+
* <header>
|
|
14
|
+
* <span slot="avatar">AI</span>
|
|
15
|
+
* <span slot="name">Assistant</span>
|
|
16
|
+
* </header>
|
|
17
|
+
* <section>
|
|
18
|
+
* <!-- messages rendered here -->
|
|
19
|
+
* </section>
|
|
20
|
+
* <footer>
|
|
21
|
+
* <chat-input-ui placeholder="Type a message..."></chat-input-ui>
|
|
22
|
+
* </footer>
|
|
23
|
+
* </chat-ui>
|
|
24
|
+
*
|
|
25
|
+
* JS API:
|
|
26
|
+
* chat.appendMessage({ role: 'user', content: 'Hello' })
|
|
27
|
+
* chat.appendMessage({ role: 'assistant', content: 'Hi!' })
|
|
28
|
+
* chat.appendChunk('token') // append to last assistant message
|
|
29
|
+
* chat.startStreaming() // show cursor, disable input
|
|
30
|
+
* chat.stopStreaming() // hide cursor, enable input
|
|
31
|
+
* chat.clear()
|
|
32
|
+
* chat.messages // read all messages
|
|
33
|
+
*
|
|
34
|
+
* Events:
|
|
35
|
+
* chat-submit — user pressed send (detail: { text, model })
|
|
36
|
+
*/
|
|
37
|
+
class AdiaChat extends AdiaElement {
|
|
38
|
+
static properties = {
|
|
39
|
+
streaming: { type: Boolean, default: false, reflect: true },
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
static template = () => null; // wrapper mode
|
|
43
|
+
|
|
44
|
+
#messages = [];
|
|
45
|
+
#messagesEl = null;
|
|
46
|
+
#inputEl = null;
|
|
47
|
+
|
|
48
|
+
get messages() { return [...this.#messages]; }
|
|
49
|
+
|
|
50
|
+
connected() {
|
|
51
|
+
// Stamp default structure if empty
|
|
52
|
+
if (!this.querySelector('header') && !this.querySelector('section')) {
|
|
53
|
+
this.innerHTML = `
|
|
54
|
+
<header>
|
|
55
|
+
<span slot="avatar">AI</span>
|
|
56
|
+
<span slot="name">Assistant</span>
|
|
57
|
+
</header>
|
|
58
|
+
<section></section>
|
|
59
|
+
<footer>
|
|
60
|
+
<chat-input-ui placeholder="Type a message..."></chat-input-ui>
|
|
61
|
+
</footer>
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.#messagesEl = this.querySelector('section');
|
|
66
|
+
this.#inputEl = this.querySelector('chat-input-ui');
|
|
67
|
+
|
|
68
|
+
this.#inputEl?.addEventListener('submit', this.#onSubmit);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
disconnected() {
|
|
72
|
+
this.#inputEl?.removeEventListener('submit', this.#onSubmit);
|
|
73
|
+
this.#messagesEl = null;
|
|
74
|
+
this.#inputEl = null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#onSubmit = (e) => {
|
|
78
|
+
if (this.streaming) return;
|
|
79
|
+
const { text, model } = e.detail || {};
|
|
80
|
+
if (!text) return;
|
|
81
|
+
this.#inputEl.clear();
|
|
82
|
+
this.dispatchEvent(new CustomEvent('chat-submit', { bubbles: true, detail: { text, model } }));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
appendMessage({ role, content = '', render = false }) {
|
|
86
|
+
this.#messages.push({ role, content });
|
|
87
|
+
const el = document.createElement('div');
|
|
88
|
+
el.setAttribute('data-role', role);
|
|
89
|
+
|
|
90
|
+
const body = render ? renderMarkdown(content) : escapeHTML(content);
|
|
91
|
+
|
|
92
|
+
if (role === 'user') {
|
|
93
|
+
el.innerHTML = `<div slot="bubble">${body}</div>`;
|
|
94
|
+
} else {
|
|
95
|
+
const cursor = render ? '' : '<span slot="cursor"></span>';
|
|
96
|
+
el.innerHTML = `
|
|
97
|
+
<span slot="avatar">${role === 'assistant' ? 'AI' : role[0].toUpperCase()}</span>
|
|
98
|
+
<div slot="bubble">${body}${cursor}</div>
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
this.#messagesEl?.appendChild(el);
|
|
103
|
+
this.#scrollToBottom();
|
|
104
|
+
return el;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
appendChunk(text) {
|
|
108
|
+
const last = this.#messages[this.#messages.length - 1];
|
|
109
|
+
if (!last || last.role === 'user') return;
|
|
110
|
+
last.content += text;
|
|
111
|
+
|
|
112
|
+
const bubble = this.#messagesEl?.querySelector('[data-role]:last-child [slot="bubble"]');
|
|
113
|
+
if (bubble) {
|
|
114
|
+
const cursor = bubble.querySelector('[slot="cursor"]');
|
|
115
|
+
if (cursor) cursor.remove();
|
|
116
|
+
bubble.insertAdjacentText('beforeend', text);
|
|
117
|
+
bubble.insertAdjacentHTML('beforeend', '<span slot="cursor"></span>');
|
|
118
|
+
}
|
|
119
|
+
this.#scrollToBottom();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
startStreaming() {
|
|
123
|
+
this.streaming = true;
|
|
124
|
+
if (this.#inputEl) this.#inputEl.disabled = true;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
stopStreaming() {
|
|
128
|
+
this.streaming = false;
|
|
129
|
+
if (this.#inputEl) this.#inputEl.disabled = false;
|
|
130
|
+
// Remove cursor from last message
|
|
131
|
+
this.#messagesEl?.querySelector('[data-role]:last-child [slot="cursor"]')?.remove();
|
|
132
|
+
|
|
133
|
+
// Render markdown in the last assistant bubble
|
|
134
|
+
const last = this.#messages[this.#messages.length - 1];
|
|
135
|
+
if (last && last.role === 'assistant' && last.content) {
|
|
136
|
+
const bubble = this.#messagesEl?.querySelector('[data-role]:last-child [slot="bubble"]');
|
|
137
|
+
if (bubble) bubble.innerHTML = renderMarkdown(last.content);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this.#inputEl?.focus();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
clear() {
|
|
144
|
+
this.#messages.length = 0;
|
|
145
|
+
if (this.#messagesEl) this.#messagesEl.innerHTML = '';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#scrollToBottom() {
|
|
149
|
+
const el = this.#messagesEl;
|
|
150
|
+
if (el) requestAnimationFrame(() => { el.scrollTop = el.scrollHeight; });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
customElements.define('chat-ui', AdiaChat);
|
|
154
|
+
|
|
155
|
+
export { AdiaChat };
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Generated by scripts/migrate-yamls-to-v1.mjs — migrated to v1 contract.
|
|
2
|
+
# Edit this file; run `npm run build:components` to regenerate a2ui.json.
|
|
3
|
+
$schema: ../../../../scripts/schemas/component.yaml.schema.json
|
|
4
|
+
name: AdiaChat
|
|
5
|
+
tag: chat-ui
|
|
6
|
+
component: Chat
|
|
7
|
+
category: agent
|
|
8
|
+
version: 1
|
|
9
|
+
description: Minimal chat container.
|
|
10
|
+
props:
|
|
11
|
+
streaming:
|
|
12
|
+
description: "Component property: streaming."
|
|
13
|
+
type: boolean
|
|
14
|
+
default: false
|
|
15
|
+
events:
|
|
16
|
+
chat-submit:
|
|
17
|
+
description: "Fired on chat-submit."
|
|
18
|
+
slots:
|
|
19
|
+
default:
|
|
20
|
+
description: "Default slot — primary child content."
|
|
21
|
+
states:
|
|
22
|
+
- name: idle
|
|
23
|
+
description: Default, ready for interaction.
|
|
24
|
+
traits: []
|
|
25
|
+
tokens: {}
|
|
26
|
+
a2ui:
|
|
27
|
+
rules: []
|
|
28
|
+
anti_patterns: []
|
|
29
|
+
examples:
|
|
30
|
+
- name: basic-chat
|
|
31
|
+
description: Basic Chat usage
|
|
32
|
+
a2ui: >-
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
"id": "root",
|
|
36
|
+
"component": "Card",
|
|
37
|
+
"children": [
|
|
38
|
+
"sec"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "sec",
|
|
43
|
+
"component": "Section",
|
|
44
|
+
"children": [
|
|
45
|
+
"comp"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "comp",
|
|
50
|
+
"component": "Chat"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
- name: basic
|
|
54
|
+
description: Chat transcript with user and assistant messages; role attribute styles turns.
|
|
55
|
+
a2ui: >-
|
|
56
|
+
[
|
|
57
|
+
{
|
|
58
|
+
"id": "root",
|
|
59
|
+
"component": "Chat",
|
|
60
|
+
"children": [
|
|
61
|
+
"m1",
|
|
62
|
+
"m2"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "m1",
|
|
67
|
+
"component": "Text",
|
|
68
|
+
"role": "user",
|
|
69
|
+
"textContent": "What's the capital of France?"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "m2",
|
|
73
|
+
"component": "Text",
|
|
74
|
+
"role": "assistant",
|
|
75
|
+
"textContent": "The capital of France is Paris."
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
- name: streaming
|
|
79
|
+
description: Chat with streaming cursor on an in-progress assistant message.
|
|
80
|
+
a2ui: >-
|
|
81
|
+
[
|
|
82
|
+
{
|
|
83
|
+
"id": "root",
|
|
84
|
+
"component": "Chat",
|
|
85
|
+
"streaming": true,
|
|
86
|
+
"children": [
|
|
87
|
+
"m1",
|
|
88
|
+
"m2"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"id": "m1",
|
|
93
|
+
"component": "Text",
|
|
94
|
+
"role": "user",
|
|
95
|
+
"textContent": "Explain black holes briefly."
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"id": "m2",
|
|
99
|
+
"component": "Text",
|
|
100
|
+
"role": "assistant",
|
|
101
|
+
"streaming": true,
|
|
102
|
+
"textContent": "A black hole is a region of spacetime where gravity is so strong that"
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
- name: with-input
|
|
106
|
+
description: Chat transcript composed with ChatInput for a full conversation surface.
|
|
107
|
+
a2ui: >-
|
|
108
|
+
[
|
|
109
|
+
{
|
|
110
|
+
"id": "root",
|
|
111
|
+
"component": "Column",
|
|
112
|
+
"gap": "2",
|
|
113
|
+
"children": [
|
|
114
|
+
"chat",
|
|
115
|
+
"input"
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"id": "chat",
|
|
120
|
+
"component": "Chat",
|
|
121
|
+
"children": [
|
|
122
|
+
"m1",
|
|
123
|
+
"m2"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"id": "m1",
|
|
128
|
+
"component": "Text",
|
|
129
|
+
"role": "user",
|
|
130
|
+
"textContent": "Give me a short haiku about the ocean."
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"id": "m2",
|
|
134
|
+
"component": "Text",
|
|
135
|
+
"role": "assistant",
|
|
136
|
+
"textContent": "Waves whisper secrets — the tide retreats then returns, carrying the moon."
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "input",
|
|
140
|
+
"component": "ChatInput",
|
|
141
|
+
"placeholder": "Type a message..."
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
keywords:
|
|
145
|
+
- chat
|
|
146
|
+
- message
|
|
147
|
+
- messaging
|
|
148
|
+
- sms
|
|
149
|
+
- chatbot
|
|
150
|
+
- conversation
|
|
151
|
+
- ai-chat
|
|
152
|
+
- messenger
|
|
153
|
+
- assistant
|
|
154
|
+
- copilot
|
|
155
|
+
- gpt
|
|
156
|
+
- llm
|
|
157
|
+
- ai
|
|
158
|
+
- bot
|
|
159
|
+
- prompt
|
|
160
|
+
- comment
|
|
161
|
+
- support
|
|
162
|
+
synonyms:
|
|
163
|
+
ai:
|
|
164
|
+
- chat
|
|
165
|
+
- streaming
|
|
166
|
+
- response
|
|
167
|
+
- command
|
|
168
|
+
ai-chat:
|
|
169
|
+
- chat
|
|
170
|
+
- streaming
|
|
171
|
+
- response
|
|
172
|
+
assistant:
|
|
173
|
+
- chat
|
|
174
|
+
- streaming
|
|
175
|
+
- response
|
|
176
|
+
- command
|
|
177
|
+
bot:
|
|
178
|
+
- chat
|
|
179
|
+
- streaming
|
|
180
|
+
- response
|
|
181
|
+
chatbot:
|
|
182
|
+
- chat
|
|
183
|
+
- streaming
|
|
184
|
+
- response
|
|
185
|
+
comment:
|
|
186
|
+
- social
|
|
187
|
+
- post
|
|
188
|
+
- chat
|
|
189
|
+
conversation:
|
|
190
|
+
- chat
|
|
191
|
+
- streaming
|
|
192
|
+
- response
|
|
193
|
+
copilot:
|
|
194
|
+
- chat
|
|
195
|
+
- streaming
|
|
196
|
+
- response
|
|
197
|
+
- command
|
|
198
|
+
gpt:
|
|
199
|
+
- chat
|
|
200
|
+
- streaming
|
|
201
|
+
- response
|
|
202
|
+
llm:
|
|
203
|
+
- chat
|
|
204
|
+
- streaming
|
|
205
|
+
- response
|
|
206
|
+
message:
|
|
207
|
+
- chat
|
|
208
|
+
- notification
|
|
209
|
+
- toast
|
|
210
|
+
- alert
|
|
211
|
+
messaging:
|
|
212
|
+
- chat
|
|
213
|
+
- notification
|
|
214
|
+
- streaming
|
|
215
|
+
messenger:
|
|
216
|
+
- chat
|
|
217
|
+
- streaming
|
|
218
|
+
prompt:
|
|
219
|
+
- chat
|
|
220
|
+
- streaming
|
|
221
|
+
- command
|
|
222
|
+
- palette
|
|
223
|
+
sms:
|
|
224
|
+
- chat
|
|
225
|
+
- notification
|
|
226
|
+
support:
|
|
227
|
+
- faq
|
|
228
|
+
- accordion
|
|
229
|
+
- chat
|
|
230
|
+
related: []
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://adiaui.dev/a2ui/v0_9/components/Check.json",
|
|
4
|
+
"title": "Check",
|
|
5
|
+
"description": "Checkbox. The host IS the control.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"allOf": [
|
|
8
|
+
{
|
|
9
|
+
"$ref": "common_types.json#/$defs/ComponentCommon"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"$ref": "common_types.json#/$defs/CatalogComponentCommon"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"properties": {
|
|
16
|
+
"required": {
|
|
17
|
+
"description": "Marks as required",
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"default": false
|
|
20
|
+
},
|
|
21
|
+
"checked": {
|
|
22
|
+
"description": "Whether the checkbox is checked",
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"default": false
|
|
25
|
+
},
|
|
26
|
+
"component": {
|
|
27
|
+
"const": "Check"
|
|
28
|
+
},
|
|
29
|
+
"disabled": {
|
|
30
|
+
"description": "Disables the checkbox",
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"default": false
|
|
33
|
+
},
|
|
34
|
+
"hint": {
|
|
35
|
+
"description": "Help text below the label",
|
|
36
|
+
"type": "string",
|
|
37
|
+
"default": ""
|
|
38
|
+
},
|
|
39
|
+
"indeterminate": {
|
|
40
|
+
"description": "Indeterminate state (dash indicator). Cleared on toggle.",
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"default": false
|
|
43
|
+
},
|
|
44
|
+
"label": {
|
|
45
|
+
"description": "Label text beside the checkbox",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"default": ""
|
|
48
|
+
},
|
|
49
|
+
"name": {
|
|
50
|
+
"description": "Form field name",
|
|
51
|
+
"type": "string",
|
|
52
|
+
"default": ""
|
|
53
|
+
},
|
|
54
|
+
"value": {
|
|
55
|
+
"description": "Form value (submitted as 'on' when checked)",
|
|
56
|
+
"type": "string",
|
|
57
|
+
"default": ""
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"required": [
|
|
61
|
+
"component"
|
|
62
|
+
],
|
|
63
|
+
"unevaluatedProperties": false,
|
|
64
|
+
"x-adiaui": {
|
|
65
|
+
"anti_patterns": [],
|
|
66
|
+
"category": "layout",
|
|
67
|
+
"events": {
|
|
68
|
+
"change": {
|
|
69
|
+
"description": "Fired when checked state changes"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"examples": [
|
|
73
|
+
{
|
|
74
|
+
"description": "Basic Check usage",
|
|
75
|
+
"a2ui": "[\n {\n \"id\": \"root\",\n \"component\": \"Card\",\n \"children\": [\n \"sec\"\n ]\n },\n {\n \"id\": \"sec\",\n \"component\": \"Section\",\n \"children\": [\n \"comp\"\n ]\n },\n {\n \"id\": \"comp\",\n \"component\": \"Check\",\n \"label\": \"Example Check\"\n }\n]",
|
|
76
|
+
"name": "basic-check"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"keywords": [
|
|
80
|
+
"check"
|
|
81
|
+
],
|
|
82
|
+
"name": "AdiaCheck",
|
|
83
|
+
"related": [],
|
|
84
|
+
"slots": {
|
|
85
|
+
"box": {
|
|
86
|
+
"description": "Visual checkbox indicator"
|
|
87
|
+
},
|
|
88
|
+
"hint": {
|
|
89
|
+
"description": "Help text below the label"
|
|
90
|
+
},
|
|
91
|
+
"label": {
|
|
92
|
+
"description": "Label text beside the checkbox"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"states": [
|
|
96
|
+
{
|
|
97
|
+
"description": "Default, ready for interaction.",
|
|
98
|
+
"name": "idle"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"description": "Non-interactive; dimmed.",
|
|
102
|
+
"attribute": "disabled",
|
|
103
|
+
"name": "disabled"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"synonyms": {},
|
|
107
|
+
"tag": "check-ui",
|
|
108
|
+
"tokens": {
|
|
109
|
+
"--check-box-background": {
|
|
110
|
+
"description": "Unchecked background"
|
|
111
|
+
},
|
|
112
|
+
"--check-box-border-color": {
|
|
113
|
+
"description": "Unchecked border color"
|
|
114
|
+
},
|
|
115
|
+
"--check-box-radius": {
|
|
116
|
+
"description": "Checkbox border radius"
|
|
117
|
+
},
|
|
118
|
+
"--check-box-size": {
|
|
119
|
+
"description": "Checkbox indicator size"
|
|
120
|
+
},
|
|
121
|
+
"--check-checked-background": {
|
|
122
|
+
"description": "Checked/indeterminate background"
|
|
123
|
+
},
|
|
124
|
+
"--check-checked-border-color": {
|
|
125
|
+
"description": "Checked/indeterminate border"
|
|
126
|
+
},
|
|
127
|
+
"--check-checked-foreground": {
|
|
128
|
+
"description": "Checkmark/dash color"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"traits": [],
|
|
132
|
+
"version": 1
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
@scope (check-ui) {
|
|
2
|
+
:where(:scope) {
|
|
3
|
+
/* ── Tokens ── (size scales with universal [size] attribute via --a-toggle-size) */
|
|
4
|
+
--check-size: var(--a-toggle-size);
|
|
5
|
+
--check-gap: var(--a-space-2);
|
|
6
|
+
--check-font-size: var(--a-ui-size);
|
|
7
|
+
--check-radius: min(var(--a-radius-md), var(--a-space-1-5));
|
|
8
|
+
|
|
9
|
+
/* ── State: default ── */
|
|
10
|
+
--check-bg: var(--a-ui-bg);
|
|
11
|
+
--check-border: var(--a-ui-border);
|
|
12
|
+
--check-border-hover: var(--a-fg-subtle);
|
|
13
|
+
|
|
14
|
+
/* ── Transitions ── */
|
|
15
|
+
--check-duration: var(--a-duration-fast);
|
|
16
|
+
--check-easing: var(--a-easing);
|
|
17
|
+
|
|
18
|
+
/* ── Focus ── */
|
|
19
|
+
--check-focus-ring: var(--a-focus-ring);
|
|
20
|
+
|
|
21
|
+
/* ── State: default hover ── */
|
|
22
|
+
--check-bg-hover: var(--a-bg-muted);
|
|
23
|
+
|
|
24
|
+
/* ── State: checked ── */
|
|
25
|
+
--check-bg-checked: var(--a-primary);
|
|
26
|
+
--check-border-checked: var(--a-primary);
|
|
27
|
+
--check-fg-checked: white;
|
|
28
|
+
--check-bg-checked-hover: var(--a-primary-hover);
|
|
29
|
+
|
|
30
|
+
/* ── State: disabled ── */
|
|
31
|
+
--check-fg-disabled: var(--a-fg-muted);
|
|
32
|
+
|
|
33
|
+
/* ── Check icon (CSS border trick, no SVG) ── */
|
|
34
|
+
--_icon-w: 0;
|
|
35
|
+
--_icon-h: 0;
|
|
36
|
+
--_icon-border: none;
|
|
37
|
+
--_icon-bw: 0;
|
|
38
|
+
--_icon-transform: none;
|
|
39
|
+
|
|
40
|
+
/* ── Indeterminate indicator ── */
|
|
41
|
+
--_dash-bg: transparent;
|
|
42
|
+
--_dash-w: 0;
|
|
43
|
+
--_dash-h: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:scope {
|
|
47
|
+
/* ── Base ── */
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
display: inline-flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: var(--check-gap);
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
user-select: none;
|
|
54
|
+
font-size: var(--check-font-size);
|
|
55
|
+
outline: none;
|
|
56
|
+
}
|
|
57
|
+
:scope[disabled] { cursor: not-allowed; color: var(--check-fg-disabled); }
|
|
58
|
+
|
|
59
|
+
/* Box */
|
|
60
|
+
[slot="box"] {
|
|
61
|
+
flex-shrink: 0;
|
|
62
|
+
width: var(--check-size);
|
|
63
|
+
height: var(--check-size);
|
|
64
|
+
border: 1.5px solid var(--check-border);
|
|
65
|
+
border-radius: var(--check-radius);
|
|
66
|
+
background: var(--check-bg);
|
|
67
|
+
display: inline-flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
transition:
|
|
71
|
+
background var(--check-duration) var(--check-easing),
|
|
72
|
+
border-color var(--check-duration) var(--check-easing);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Icon (checkmark or dash) */
|
|
76
|
+
[slot="box"]::after {
|
|
77
|
+
content: '';
|
|
78
|
+
width: var(--_icon-w);
|
|
79
|
+
height: var(--_icon-h);
|
|
80
|
+
border: var(--_icon-border);
|
|
81
|
+
border-width: var(--_icon-bw);
|
|
82
|
+
transform: var(--_icon-transform);
|
|
83
|
+
background: var(--_dash-bg);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:scope:not([disabled]):hover [slot="box"] {
|
|
87
|
+
border-color: var(--check-border-hover);
|
|
88
|
+
background: var(--check-bg-hover);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Checked — CSS border checkmark */
|
|
92
|
+
:scope[checked] [slot="box"],
|
|
93
|
+
:scope[indeterminate] [slot="box"] {
|
|
94
|
+
background: var(--check-bg-checked);
|
|
95
|
+
border-color: var(--check-border-checked);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:scope[checked] {
|
|
99
|
+
--_icon-w: calc(var(--check-size) * 0.3);
|
|
100
|
+
--_icon-h: calc(var(--check-size) * 0.55);
|
|
101
|
+
--_icon-border: solid var(--check-fg-checked);
|
|
102
|
+
--_icon-bw: 0 calc(var(--check-size) * 0.12) calc(var(--check-size) * 0.12) 0;
|
|
103
|
+
--_icon-transform: rotate(45deg) translate(-1px, -1px);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Indeterminate — horizontal dash */
|
|
107
|
+
:scope[indeterminate] {
|
|
108
|
+
--_dash-bg: var(--check-fg-checked);
|
|
109
|
+
--_icon-w: calc(var(--check-size) * 0.5);
|
|
110
|
+
--_icon-h: calc(var(--check-size) * 0.12);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:scope[checked]:not([disabled]):hover [slot="box"],
|
|
114
|
+
:scope[indeterminate]:not([disabled]):hover [slot="box"] {
|
|
115
|
+
background: var(--check-bg-checked-hover);
|
|
116
|
+
border-color: var(--check-bg-checked-hover);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* Label */
|
|
120
|
+
:scope[label]::after { content: attr(label); }
|
|
121
|
+
|
|
122
|
+
/* Focus */
|
|
123
|
+
:scope:focus-visible [slot="box"] { box-shadow: var(--check-focus-ring); }
|
|
124
|
+
|
|
125
|
+
/* Size handled by universal [size] attribute system. */
|
|
126
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <check-ui> — Checkbox. The host IS the control.
|
|
3
|
+
* Pure CSS checkmark via border trick on [slot="box"]::after. No SVG.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AdiaFormElement } from '@core/form.js';
|
|
7
|
+
import { html } from '@core/element.js';
|
|
8
|
+
|
|
9
|
+
class AdiaCheck extends AdiaFormElement {
|
|
10
|
+
static properties = {
|
|
11
|
+
...AdiaFormElement.properties,
|
|
12
|
+
checked: { type: Boolean, default: false, reflect: true },
|
|
13
|
+
indeterminate: { type: Boolean, default: false, reflect: true },
|
|
14
|
+
label: { type: String, default: '', reflect: true },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
static template = () => html`<span slot="box"></span>`;
|
|
18
|
+
|
|
19
|
+
connected() {
|
|
20
|
+
super.connected();
|
|
21
|
+
this.setAttribute('role', 'checkbox');
|
|
22
|
+
this.setAttribute('tabindex', '0');
|
|
23
|
+
this.addEventListener('click', this.#toggle);
|
|
24
|
+
this.addEventListener('keydown', this.#onKey);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
render() {
|
|
28
|
+
if (this.indeterminate) {
|
|
29
|
+
this.setAttribute('aria-checked', 'mixed');
|
|
30
|
+
} else {
|
|
31
|
+
this.setAttribute('aria-checked', String(this.checked));
|
|
32
|
+
}
|
|
33
|
+
if (this.disabled) this.setAttribute('aria-disabled', 'true');
|
|
34
|
+
else this.removeAttribute('aria-disabled');
|
|
35
|
+
if (this.label) this.setAttribute('aria-label', this.label);
|
|
36
|
+
this.syncValue(this.checked ? (this.value || 'on') : '');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#toggle = () => {
|
|
40
|
+
if (this.disabled) return;
|
|
41
|
+
this.checked = !this.checked;
|
|
42
|
+
this.indeterminate = false;
|
|
43
|
+
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
#onKey = (e) => {
|
|
47
|
+
if (e.key === ' ' || e.key === 'Enter') { e.preventDefault(); this.#toggle(); }
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
disconnected() {
|
|
51
|
+
super.disconnected();
|
|
52
|
+
this.removeEventListener('click', this.#toggle);
|
|
53
|
+
this.removeEventListener('keydown', this.#onKey);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
customElements.define('check-ui', AdiaCheck);
|
|
57
|
+
|
|
58
|
+
export { AdiaCheck };
|