@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,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <toast-ui> — Notification popup.
|
|
3
|
+
*
|
|
4
|
+
* Positioned fixed, auto-dismisses after a configurable duration.
|
|
5
|
+
* Animated enter/exit via translateY + opacity.
|
|
6
|
+
*
|
|
7
|
+
* Usage (declarative):
|
|
8
|
+
* <toast-ui text="Saved!" variant="success"></toast-ui>
|
|
9
|
+
*
|
|
10
|
+
* Usage (imperative):
|
|
11
|
+
* AdiaToast.show({ text: 'Saved!', variant: 'success', duration: 3000 });
|
|
12
|
+
*
|
|
13
|
+
* Events:
|
|
14
|
+
* close — fired after the toast finishes its exit animation
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { AdiaElement, html } from '@core/element.js';
|
|
18
|
+
|
|
19
|
+
class AdiaToast extends AdiaElement {
|
|
20
|
+
#timer = null;
|
|
21
|
+
#removing = false;
|
|
22
|
+
#closeTimer = null;
|
|
23
|
+
#openRaf = null;
|
|
24
|
+
|
|
25
|
+
static properties = {
|
|
26
|
+
text: { type: String, default: '', reflect: true },
|
|
27
|
+
variant: { type: String, default: 'info', reflect: true },
|
|
28
|
+
duration: { type: Number, default: 4000, reflect: true },
|
|
29
|
+
position: { type: String, default: 'bottom-right', reflect: true },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
static parts = {
|
|
33
|
+
message: '<div slot="message"></div>',
|
|
34
|
+
close: '<span slot="close" role="button" tabindex="0" aria-label="Dismiss"></span>',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
static template = () => html``;
|
|
38
|
+
|
|
39
|
+
#onClick = (e) => {
|
|
40
|
+
if (e.target.closest('[slot="close"]')) this.dismiss();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
#onKeydown = (e) => {
|
|
44
|
+
if (e.target.closest('[slot="close"]') && (e.key === 'Enter' || e.key === ' ')) {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
this.dismiss();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
connected() {
|
|
51
|
+
this.addEventListener('click', this.#onClick);
|
|
52
|
+
this.addEventListener('keydown', this.#onKeydown);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#getDuration() {
|
|
56
|
+
const raw = getComputedStyle(this).getPropertyValue('--toast-duration').trim();
|
|
57
|
+
return parseFloat(raw) || 200;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
render() {
|
|
61
|
+
const message = this.ensure('message');
|
|
62
|
+
message.textContent = this.text;
|
|
63
|
+
|
|
64
|
+
const close = this.ensure('close');
|
|
65
|
+
if (close.parentElement !== this) this.appendChild(close);
|
|
66
|
+
|
|
67
|
+
this.setAttribute('role', 'status');
|
|
68
|
+
this.setAttribute('aria-live', 'polite');
|
|
69
|
+
|
|
70
|
+
// Schedule auto-open animation
|
|
71
|
+
if (!this.hasAttribute('data-open') && !this.#removing) {
|
|
72
|
+
this.#openRaf = requestAnimationFrame(() => {
|
|
73
|
+
this.#openRaf = null;
|
|
74
|
+
this.setAttribute('data-open', '');
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Schedule auto-dismiss
|
|
79
|
+
this.#scheduleAutoDismiss();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#scheduleAutoDismiss() {
|
|
83
|
+
if (this.#timer) clearTimeout(this.#timer);
|
|
84
|
+
if (this.duration > 0) {
|
|
85
|
+
this.#timer = setTimeout(() => this.dismiss(), this.duration);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
dismiss() {
|
|
90
|
+
if (this.#removing) return;
|
|
91
|
+
this.#removing = true;
|
|
92
|
+
if (this.#timer) { clearTimeout(this.#timer); this.#timer = null; }
|
|
93
|
+
|
|
94
|
+
this.removeAttribute('data-open');
|
|
95
|
+
this.setAttribute('data-closing', '');
|
|
96
|
+
|
|
97
|
+
this.#closeTimer = setTimeout(() => {
|
|
98
|
+
this.#closeTimer = null;
|
|
99
|
+
this.removeAttribute('data-closing');
|
|
100
|
+
this.dispatchEvent(new Event('close', { bubbles: true }));
|
|
101
|
+
this.remove();
|
|
102
|
+
}, this.#getDuration());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
disconnected() {
|
|
106
|
+
this.removeEventListener('click', this.#onClick);
|
|
107
|
+
this.removeEventListener('keydown', this.#onKeydown);
|
|
108
|
+
if (this.#timer) { clearTimeout(this.#timer); this.#timer = null; }
|
|
109
|
+
if (this.#closeTimer) { clearTimeout(this.#closeTimer); this.#closeTimer = null; }
|
|
110
|
+
if (this.#openRaf != null) { cancelAnimationFrame(this.#openRaf); this.#openRaf = null; }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Static convenience — creates a toast, appends to body, auto-removes.
|
|
115
|
+
* @param {Object} opts
|
|
116
|
+
* @param {string} opts.text
|
|
117
|
+
* @param {string} [opts.variant='info']
|
|
118
|
+
* @param {number} [opts.duration=4000]
|
|
119
|
+
* @param {string} [opts.position='bottom-right']
|
|
120
|
+
* @returns {AdiaToast}
|
|
121
|
+
*/
|
|
122
|
+
static #containers = new Map();
|
|
123
|
+
|
|
124
|
+
static #getContainer(position) {
|
|
125
|
+
if (AdiaToast.#containers.has(position)) return AdiaToast.#containers.get(position);
|
|
126
|
+
const el = document.createElement('div');
|
|
127
|
+
el.setAttribute('data-toast-container', position);
|
|
128
|
+
document.body.appendChild(el);
|
|
129
|
+
AdiaToast.#containers.set(position, el);
|
|
130
|
+
return el;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
static show({ text, variant = 'info', duration = 4000, position = 'bottom-right' } = {}) {
|
|
134
|
+
const container = AdiaToast.#getContainer(position);
|
|
135
|
+
const toast = document.createElement('toast-ui');
|
|
136
|
+
toast.text = text;
|
|
137
|
+
toast.variant = variant;
|
|
138
|
+
toast.duration = duration;
|
|
139
|
+
toast.position = position;
|
|
140
|
+
container.appendChild(toast);
|
|
141
|
+
return toast;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
customElements.define('toast-ui', AdiaToast);
|
|
145
|
+
|
|
146
|
+
export { AdiaToast };
|
|
@@ -0,0 +1,184 @@
|
|
|
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: AdiaToast
|
|
5
|
+
tag: toast-ui
|
|
6
|
+
component: Toast
|
|
7
|
+
category: container
|
|
8
|
+
version: 1
|
|
9
|
+
description: Notification popup with auto-dismiss. Animated enter/exit.
|
|
10
|
+
props:
|
|
11
|
+
icon:
|
|
12
|
+
description: Leading Phosphor icon name; when omitted, defaults from `variant` (success → check, danger → x, etc.).
|
|
13
|
+
type: string
|
|
14
|
+
default: ""
|
|
15
|
+
closable:
|
|
16
|
+
description: When true, renders a dismiss button.
|
|
17
|
+
type: boolean
|
|
18
|
+
default: true
|
|
19
|
+
duration:
|
|
20
|
+
description: Auto-dismiss time in milliseconds. 0 disables auto-dismiss.
|
|
21
|
+
type: number
|
|
22
|
+
default: 4000
|
|
23
|
+
open:
|
|
24
|
+
description: Controls visibility and triggers auto-dismiss timer
|
|
25
|
+
type: boolean
|
|
26
|
+
default: false
|
|
27
|
+
reflect: true
|
|
28
|
+
position:
|
|
29
|
+
description: Screen position
|
|
30
|
+
type: string
|
|
31
|
+
default: bottom-right
|
|
32
|
+
enum:
|
|
33
|
+
- top-left
|
|
34
|
+
- top-center
|
|
35
|
+
- top-right
|
|
36
|
+
- bottom-left
|
|
37
|
+
- bottom-center
|
|
38
|
+
- bottom-right
|
|
39
|
+
text:
|
|
40
|
+
description: Toast message text
|
|
41
|
+
type: string
|
|
42
|
+
default: ""
|
|
43
|
+
variant:
|
|
44
|
+
description: Color variant. `error` kept as alias for `danger`.
|
|
45
|
+
type: string
|
|
46
|
+
default: info
|
|
47
|
+
enum:
|
|
48
|
+
- default
|
|
49
|
+
- success
|
|
50
|
+
- warning
|
|
51
|
+
- error
|
|
52
|
+
- info
|
|
53
|
+
- danger
|
|
54
|
+
- primary
|
|
55
|
+
- muted
|
|
56
|
+
- neutral
|
|
57
|
+
events:
|
|
58
|
+
close:
|
|
59
|
+
description: Fired when the toast is dismissed via click or auto-timeout
|
|
60
|
+
slots: {}
|
|
61
|
+
states:
|
|
62
|
+
- name: idle
|
|
63
|
+
description: Default, ready for interaction.
|
|
64
|
+
traits: []
|
|
65
|
+
tokens:
|
|
66
|
+
--toast-background:
|
|
67
|
+
description: Override background color
|
|
68
|
+
--toast-border-color:
|
|
69
|
+
description: Override border color
|
|
70
|
+
--toast-foreground:
|
|
71
|
+
description: Override text color
|
|
72
|
+
a2ui:
|
|
73
|
+
rules: []
|
|
74
|
+
anti_patterns: []
|
|
75
|
+
examples:
|
|
76
|
+
- name: toast-notification
|
|
77
|
+
description: Column of three toast notification components showing success, warning, and error variants.
|
|
78
|
+
a2ui: >-
|
|
79
|
+
[
|
|
80
|
+
{
|
|
81
|
+
"id": "root",
|
|
82
|
+
"component": "Column",
|
|
83
|
+
"gap": "2",
|
|
84
|
+
"children": [
|
|
85
|
+
"t1",
|
|
86
|
+
"t2",
|
|
87
|
+
"t3"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "t1",
|
|
92
|
+
"component": "Toast",
|
|
93
|
+
"variant": "success",
|
|
94
|
+
"title": "Saved successfully",
|
|
95
|
+
"description": "Your changes have been saved.",
|
|
96
|
+
"dismissible": true
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"id": "t2",
|
|
100
|
+
"component": "Toast",
|
|
101
|
+
"variant": "warning",
|
|
102
|
+
"title": "Storage almost full",
|
|
103
|
+
"description": "You are using 90% of your available storage.",
|
|
104
|
+
"dismissible": true
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"id": "t3",
|
|
108
|
+
"component": "Toast",
|
|
109
|
+
"variant": "error",
|
|
110
|
+
"title": "Upload failed",
|
|
111
|
+
"description": "The file could not be uploaded. Please try again.",
|
|
112
|
+
"dismissible": true
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
keywords:
|
|
116
|
+
- toast
|
|
117
|
+
- inbox
|
|
118
|
+
- message
|
|
119
|
+
- snackbar
|
|
120
|
+
- popup
|
|
121
|
+
- warning
|
|
122
|
+
- error
|
|
123
|
+
- success
|
|
124
|
+
- info
|
|
125
|
+
- notification
|
|
126
|
+
- remind
|
|
127
|
+
- alert
|
|
128
|
+
synonyms:
|
|
129
|
+
alert:
|
|
130
|
+
- alert
|
|
131
|
+
- banner
|
|
132
|
+
- toast
|
|
133
|
+
- notification
|
|
134
|
+
error:
|
|
135
|
+
- alert
|
|
136
|
+
- error
|
|
137
|
+
- toast
|
|
138
|
+
- empty
|
|
139
|
+
inbox:
|
|
140
|
+
- notification
|
|
141
|
+
- alert
|
|
142
|
+
- toast
|
|
143
|
+
- message
|
|
144
|
+
- email
|
|
145
|
+
- mail
|
|
146
|
+
- folder
|
|
147
|
+
info:
|
|
148
|
+
- alert
|
|
149
|
+
- toast
|
|
150
|
+
- notification
|
|
151
|
+
- tooltip
|
|
152
|
+
message:
|
|
153
|
+
- chat
|
|
154
|
+
- notification
|
|
155
|
+
- toast
|
|
156
|
+
- alert
|
|
157
|
+
notification:
|
|
158
|
+
- notification
|
|
159
|
+
- toast
|
|
160
|
+
- alert
|
|
161
|
+
- badge
|
|
162
|
+
popup:
|
|
163
|
+
- toast
|
|
164
|
+
- notification
|
|
165
|
+
- alert
|
|
166
|
+
- popover
|
|
167
|
+
- drawer
|
|
168
|
+
remind:
|
|
169
|
+
- notification
|
|
170
|
+
- toast
|
|
171
|
+
- calendar
|
|
172
|
+
snackbar:
|
|
173
|
+
- toast
|
|
174
|
+
- notification
|
|
175
|
+
- alert
|
|
176
|
+
success:
|
|
177
|
+
- alert
|
|
178
|
+
- toast
|
|
179
|
+
- notification
|
|
180
|
+
warning:
|
|
181
|
+
- alert
|
|
182
|
+
- error
|
|
183
|
+
- toast
|
|
184
|
+
related: []
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://adiaui.dev/a2ui/v0_9/components/ToggleGroup.json",
|
|
4
|
+
"title": "ToggleGroup",
|
|
5
|
+
"description": "Multi-select button group (unlike segmented which is single-select).",
|
|
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
|
+
"component": {
|
|
17
|
+
"const": "ToggleGroup"
|
|
18
|
+
},
|
|
19
|
+
"single": {
|
|
20
|
+
"description": "When true, restrict to one active option (single-select).",
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"default": false
|
|
23
|
+
},
|
|
24
|
+
"value": {
|
|
25
|
+
"description": "Comma-separated selected values",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"default": ""
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": [
|
|
31
|
+
"component"
|
|
32
|
+
],
|
|
33
|
+
"unevaluatedProperties": false,
|
|
34
|
+
"x-adiaui": {
|
|
35
|
+
"anti_patterns": [],
|
|
36
|
+
"category": "navigation",
|
|
37
|
+
"events": {
|
|
38
|
+
"change": {
|
|
39
|
+
"description": "Fired when selection changes. detail: { value }"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"examples": [
|
|
43
|
+
{
|
|
44
|
+
"description": "Basic ToggleGroup usage",
|
|
45
|
+
"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\": \"ToggleGroup\",\n \"value\": \"\"\n }\n]",
|
|
46
|
+
"name": "basic-toggle-group"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"keywords": [
|
|
50
|
+
"togglegroup",
|
|
51
|
+
"toggle-group",
|
|
52
|
+
"toggle",
|
|
53
|
+
"group"
|
|
54
|
+
],
|
|
55
|
+
"name": "AdiaToggleGroup",
|
|
56
|
+
"related": [],
|
|
57
|
+
"slots": {
|
|
58
|
+
"default": {
|
|
59
|
+
"description": "Default slot — primary child content."
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"states": [
|
|
63
|
+
{
|
|
64
|
+
"description": "Default, ready for interaction.",
|
|
65
|
+
"name": "idle"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"synonyms": {},
|
|
69
|
+
"tag": "toggle-group-ui",
|
|
70
|
+
"tokens": {
|
|
71
|
+
"--toggle-group-border": {
|
|
72
|
+
"description": "Border color of the group container"
|
|
73
|
+
},
|
|
74
|
+
"--toggle-group-height": {
|
|
75
|
+
"description": "Height of the group container"
|
|
76
|
+
},
|
|
77
|
+
"--toggle-group-radius": {
|
|
78
|
+
"description": "Border radius of the group container"
|
|
79
|
+
},
|
|
80
|
+
"--toggle-option-bg-hover": {
|
|
81
|
+
"description": "Background color on hover"
|
|
82
|
+
},
|
|
83
|
+
"--toggle-option-border": {
|
|
84
|
+
"description": "Border color between adjacent options"
|
|
85
|
+
},
|
|
86
|
+
"--toggle-option-duration": {
|
|
87
|
+
"description": "Transition duration"
|
|
88
|
+
},
|
|
89
|
+
"--toggle-option-easing": {
|
|
90
|
+
"description": "Transition easing function"
|
|
91
|
+
},
|
|
92
|
+
"--toggle-option-fg": {
|
|
93
|
+
"description": "Default text color"
|
|
94
|
+
},
|
|
95
|
+
"--toggle-option-fg-disabled": {
|
|
96
|
+
"description": "Text color when disabled"
|
|
97
|
+
},
|
|
98
|
+
"--toggle-option-fg-hover": {
|
|
99
|
+
"description": "Text color on hover"
|
|
100
|
+
},
|
|
101
|
+
"--toggle-option-focus-ring": {
|
|
102
|
+
"description": "Focus ring box-shadow"
|
|
103
|
+
},
|
|
104
|
+
"--toggle-option-font-size": {
|
|
105
|
+
"description": "Font size for option text and icons"
|
|
106
|
+
},
|
|
107
|
+
"--toggle-option-gap": {
|
|
108
|
+
"description": "Gap between icon and text within an option"
|
|
109
|
+
},
|
|
110
|
+
"--toggle-option-height": {
|
|
111
|
+
"description": "Min-height of each option"
|
|
112
|
+
},
|
|
113
|
+
"--toggle-option-px": {
|
|
114
|
+
"description": "Horizontal padding of each option"
|
|
115
|
+
},
|
|
116
|
+
"--toggle-option-selected-bg": {
|
|
117
|
+
"description": "Background color when selected"
|
|
118
|
+
},
|
|
119
|
+
"--toggle-option-selected-fg": {
|
|
120
|
+
"description": "Text color when selected"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"traits": [],
|
|
124
|
+
"version": 1
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
@scope (toggle-group-ui) {
|
|
2
|
+
:where(:scope) {
|
|
3
|
+
/* ── Tokens ── */
|
|
4
|
+
--toggle-group-border-width: 1px;
|
|
5
|
+
--toggle-group-border-color: var(--a-ui-border);
|
|
6
|
+
--toggle-group-radius: var(--a-radius);
|
|
7
|
+
--toggle-group-height: var(--a-size);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:scope {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
border: var(--toggle-group-border-width) solid var(--toggle-group-border-color);
|
|
14
|
+
border-radius: var(--toggle-group-radius);
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@scope (toggle-option-ui) {
|
|
20
|
+
:where(:scope) {
|
|
21
|
+
/* ── Layout ── */
|
|
22
|
+
--toggle-option-gap: var(--a-space-1);
|
|
23
|
+
--toggle-option-height: var(--a-size);
|
|
24
|
+
--toggle-option-px: var(--a-ui-px);
|
|
25
|
+
--toggle-option-border-width: 1px;
|
|
26
|
+
--toggle-option-border-color: var(--a-ui-border);
|
|
27
|
+
|
|
28
|
+
/* ── Colors ── */
|
|
29
|
+
--toggle-option-bg: transparent;
|
|
30
|
+
--toggle-option-fg: var(--a-fg-muted);
|
|
31
|
+
--toggle-option-fg-hover: var(--a-fg);
|
|
32
|
+
--toggle-option-bg-hover: var(--a-bg-muted);
|
|
33
|
+
--toggle-option-selected-bg: var(--a-accent-muted);
|
|
34
|
+
--toggle-option-selected-fg: var(--a-accent-bg);
|
|
35
|
+
--toggle-option-fg-disabled: var(--a-ui-text-disabled);
|
|
36
|
+
|
|
37
|
+
/* ── Typography ── */
|
|
38
|
+
--toggle-option-font-size: var(--a-ui-size);
|
|
39
|
+
|
|
40
|
+
/* ── Transition ── */
|
|
41
|
+
--toggle-option-duration: var(--a-duration-fast);
|
|
42
|
+
--toggle-option-easing: var(--a-easing);
|
|
43
|
+
|
|
44
|
+
/* ── State ── */
|
|
45
|
+
--toggle-option-focus-ring: var(--a-focus-ring);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:scope {
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
display: inline-flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
gap: var(--toggle-option-gap);
|
|
54
|
+
min-height: var(--toggle-option-height);
|
|
55
|
+
padding: 0 var(--toggle-option-px);
|
|
56
|
+
border: none;
|
|
57
|
+
background: var(--toggle-option-bg);
|
|
58
|
+
color: var(--toggle-option-fg);
|
|
59
|
+
font: inherit;
|
|
60
|
+
font-size: var(--toggle-option-font-size);
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
transition:
|
|
63
|
+
background var(--toggle-option-duration) var(--toggle-option-easing),
|
|
64
|
+
color var(--toggle-option-duration) var(--toggle-option-easing);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Adjacent options share borders */
|
|
68
|
+
:scope + :scope {
|
|
69
|
+
border-inline-start: var(--toggle-option-border-width) solid var(--toggle-option-border-color);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
:scope:not([disabled]):hover {
|
|
73
|
+
--toggle-option-bg: var(--toggle-option-bg-hover);
|
|
74
|
+
--toggle-option-fg: var(--toggle-option-fg-hover);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:scope:focus-visible {
|
|
78
|
+
outline: none;
|
|
79
|
+
box-shadow: var(--toggle-option-focus-ring);
|
|
80
|
+
z-index: 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:scope[data-selected] {
|
|
84
|
+
--toggle-option-bg: var(--toggle-option-selected-bg);
|
|
85
|
+
--toggle-option-fg: var(--toggle-option-selected-fg);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:scope[disabled] {
|
|
89
|
+
--toggle-option-fg: var(--toggle-option-fg-disabled);
|
|
90
|
+
cursor: not-allowed;
|
|
91
|
+
pointer-events: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Icon sizing */
|
|
95
|
+
icon-ui {
|
|
96
|
+
--a-icon-size: var(--toggle-option-font-size);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[data-text] {
|
|
100
|
+
white-space: nowrap;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <toggle-group-ui value="bold,italic">
|
|
3
|
+
* <toggle-option-ui value="bold" icon="text-b"></toggle-option-ui>
|
|
4
|
+
* <toggle-option-ui value="italic" icon="text-italic"></toggle-option-ui>
|
|
5
|
+
* <toggle-option-ui value="underline" icon="text-underline"></toggle-option-ui>
|
|
6
|
+
* </toggle-group-ui>
|
|
7
|
+
*
|
|
8
|
+
* Multi-select button group (unlike segmented which is single-select).
|
|
9
|
+
*
|
|
10
|
+
* Properties:
|
|
11
|
+
* value — comma-separated selected values
|
|
12
|
+
* single — restrict to one active option at a time (default false: multi-select)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { AdiaElement } from '@core/element.js';
|
|
16
|
+
|
|
17
|
+
// ── Toggle Option ──
|
|
18
|
+
//
|
|
19
|
+
// Parent-managed. Selection state flows through `toggle-group-ui`'s `value`
|
|
20
|
+
// (and `single` mode flag). Items don't expose `checked` — parent applies
|
|
21
|
+
// `data-selected` on the DOM element when the item's `value` is part of the
|
|
22
|
+
// group's comma-separated `value` list. Consistent with native `<option>`
|
|
23
|
+
// inside `<select>`.
|
|
24
|
+
|
|
25
|
+
class AdiaToggleOption extends AdiaElement {
|
|
26
|
+
static properties = {
|
|
27
|
+
value: { type: String, default: '', reflect: true },
|
|
28
|
+
text: { type: String, default: '', reflect: true },
|
|
29
|
+
icon: { type: String, default: '', reflect: true },
|
|
30
|
+
disabled: { type: Boolean, default: false, reflect: true },
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
static template = () => null;
|
|
34
|
+
|
|
35
|
+
#stamped = false;
|
|
36
|
+
|
|
37
|
+
connected() {
|
|
38
|
+
this.setAttribute('role', 'button');
|
|
39
|
+
this.setAttribute('tabindex', '0');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
render() {
|
|
43
|
+
if (!this.#stamped) {
|
|
44
|
+
this.#stamped = true;
|
|
45
|
+
this.#stamp();
|
|
46
|
+
}
|
|
47
|
+
if (this.disabled) this.setAttribute('aria-disabled', 'true');
|
|
48
|
+
else this.removeAttribute('aria-disabled');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#stamp() {
|
|
52
|
+
let inner = '';
|
|
53
|
+
if (this.icon) inner += `<icon-ui name="${this.icon}"></icon-ui>`;
|
|
54
|
+
if (this.text) inner += `<span data-text>${this.text}</span>`;
|
|
55
|
+
this.innerHTML = inner;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
disconnected() {
|
|
59
|
+
this.#stamped = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
customElements.define('toggle-option-ui', AdiaToggleOption);
|
|
63
|
+
|
|
64
|
+
// ── Toggle Group ──
|
|
65
|
+
|
|
66
|
+
class AdiaToggleGroup extends AdiaElement {
|
|
67
|
+
static properties = {
|
|
68
|
+
value: { type: String, default: '', reflect: true },
|
|
69
|
+
single: { type: Boolean, default: false, reflect: true },
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
static template = () => null;
|
|
73
|
+
|
|
74
|
+
#bound = false;
|
|
75
|
+
|
|
76
|
+
get #valueSet() {
|
|
77
|
+
return new Set(this.value ? this.value.split(',').map(v => v.trim()).filter(Boolean) : []);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
connected() {
|
|
81
|
+
if (!this.#bound) {
|
|
82
|
+
this.#bound = true;
|
|
83
|
+
this.addEventListener('click', this.#onClick);
|
|
84
|
+
this.addEventListener('keydown', this.#onKey);
|
|
85
|
+
}
|
|
86
|
+
this.setAttribute('role', 'group');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
render() {
|
|
90
|
+
const selected = this.#valueSet;
|
|
91
|
+
for (const opt of this.querySelectorAll('toggle-option-ui')) {
|
|
92
|
+
const optVal = opt.value || opt.getAttribute('value') || '';
|
|
93
|
+
if (selected.has(optVal)) {
|
|
94
|
+
opt.setAttribute('data-selected', '');
|
|
95
|
+
opt.setAttribute('aria-pressed', 'true');
|
|
96
|
+
} else {
|
|
97
|
+
opt.removeAttribute('data-selected');
|
|
98
|
+
opt.setAttribute('aria-pressed', 'false');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
#toggle(opt) {
|
|
104
|
+
if (opt.disabled) return;
|
|
105
|
+
const optVal = opt.value || opt.getAttribute('value') || '';
|
|
106
|
+
if (!optVal) return;
|
|
107
|
+
|
|
108
|
+
const selected = this.#valueSet;
|
|
109
|
+
|
|
110
|
+
if (this.single) {
|
|
111
|
+
if (selected.has(optVal)) {
|
|
112
|
+
selected.clear();
|
|
113
|
+
} else {
|
|
114
|
+
selected.clear();
|
|
115
|
+
selected.add(optVal);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
if (selected.has(optVal)) selected.delete(optVal);
|
|
119
|
+
else selected.add(optVal);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.value = [...selected].join(',');
|
|
123
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, detail: { value: this.value } }));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
#onClick = (e) => {
|
|
127
|
+
const opt = e.target.closest('toggle-option-ui');
|
|
128
|
+
if (opt && this.contains(opt)) this.#toggle(opt);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
#onKey = (e) => {
|
|
132
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
const opt = e.target.closest('toggle-option-ui');
|
|
135
|
+
if (opt && this.contains(opt)) this.#toggle(opt);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
disconnected() {
|
|
140
|
+
this.removeEventListener('click', this.#onClick);
|
|
141
|
+
this.removeEventListener('keydown', this.#onKey);
|
|
142
|
+
this.#bound = false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
customElements.define('toggle-group-ui', AdiaToggleGroup);
|
|
146
|
+
|
|
147
|
+
export { AdiaToggleGroup, AdiaToggleOption };
|