@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
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://adiaui.dev/a2ui/v0_9/components/Menu.json",
|
|
4
|
+
"title": "Menu",
|
|
5
|
+
"description": "Dropdown action menu with roving focus and keyboard navigation. Uses Popover API.",
|
|
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
|
+
"anchor": {
|
|
17
|
+
"description": "ID of the anchor element the menu positions relative to",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"default": ""
|
|
20
|
+
},
|
|
21
|
+
"component": {
|
|
22
|
+
"const": "Menu"
|
|
23
|
+
},
|
|
24
|
+
"gap": {
|
|
25
|
+
"description": "Gap in px",
|
|
26
|
+
"type": "number",
|
|
27
|
+
"default": 4
|
|
28
|
+
},
|
|
29
|
+
"open": {
|
|
30
|
+
"description": "Controls visibility via popover API",
|
|
31
|
+
"type": "boolean",
|
|
32
|
+
"default": false
|
|
33
|
+
},
|
|
34
|
+
"placement": {
|
|
35
|
+
"description": "Preferred position relative to the anchor element",
|
|
36
|
+
"type": "string",
|
|
37
|
+
"enum": [
|
|
38
|
+
"bottom-start",
|
|
39
|
+
"bottom-end",
|
|
40
|
+
"top-start",
|
|
41
|
+
"top-end"
|
|
42
|
+
],
|
|
43
|
+
"default": "bottom-start"
|
|
44
|
+
},
|
|
45
|
+
"trigger": {
|
|
46
|
+
"description": "ID of the element that opens this menu (click handler + aria-controls).",
|
|
47
|
+
"type": "string",
|
|
48
|
+
"default": ""
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"required": [
|
|
52
|
+
"component"
|
|
53
|
+
],
|
|
54
|
+
"unevaluatedProperties": false,
|
|
55
|
+
"x-adiaui": {
|
|
56
|
+
"anti_patterns": [],
|
|
57
|
+
"category": "container",
|
|
58
|
+
"events": {
|
|
59
|
+
"action": {
|
|
60
|
+
"description": "Fired when a menu item is activated. Detail contains the triggering element."
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"examples": [
|
|
64
|
+
{
|
|
65
|
+
"description": "Basic Menu usage",
|
|
66
|
+
"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\": \"Menu\"\n }\n]",
|
|
67
|
+
"name": "basic-menu"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"keywords": [
|
|
71
|
+
"menu",
|
|
72
|
+
"navigation",
|
|
73
|
+
"navbar",
|
|
74
|
+
"hamburger",
|
|
75
|
+
"dropdown",
|
|
76
|
+
"popover",
|
|
77
|
+
"context-menu",
|
|
78
|
+
"right-click"
|
|
79
|
+
],
|
|
80
|
+
"name": "AdiaMenu",
|
|
81
|
+
"related": [],
|
|
82
|
+
"slots": {
|
|
83
|
+
"default": {
|
|
84
|
+
"description": "Menu items with role=\"menuitem\" and optional <hr> dividers"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"states": [
|
|
88
|
+
{
|
|
89
|
+
"description": "Default, ready for interaction.",
|
|
90
|
+
"name": "idle"
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"synonyms": {
|
|
94
|
+
"context-menu": [
|
|
95
|
+
"popover",
|
|
96
|
+
"menu"
|
|
97
|
+
],
|
|
98
|
+
"dropdown": [
|
|
99
|
+
"popover",
|
|
100
|
+
"menu",
|
|
101
|
+
"select",
|
|
102
|
+
"form"
|
|
103
|
+
],
|
|
104
|
+
"hamburger": [
|
|
105
|
+
"nav",
|
|
106
|
+
"menu",
|
|
107
|
+
"sidebar",
|
|
108
|
+
"drawer"
|
|
109
|
+
],
|
|
110
|
+
"menu": [
|
|
111
|
+
"nav",
|
|
112
|
+
"sidebar",
|
|
113
|
+
"popover",
|
|
114
|
+
"menu",
|
|
115
|
+
"command"
|
|
116
|
+
],
|
|
117
|
+
"navbar": [
|
|
118
|
+
"nav",
|
|
119
|
+
"menu",
|
|
120
|
+
"sidebar",
|
|
121
|
+
"breadcrumb"
|
|
122
|
+
],
|
|
123
|
+
"navigation": [
|
|
124
|
+
"nav",
|
|
125
|
+
"sidebar",
|
|
126
|
+
"breadcrumb",
|
|
127
|
+
"tabs",
|
|
128
|
+
"menu",
|
|
129
|
+
"pagination"
|
|
130
|
+
],
|
|
131
|
+
"popover": [
|
|
132
|
+
"popover",
|
|
133
|
+
"menu",
|
|
134
|
+
"tooltip"
|
|
135
|
+
],
|
|
136
|
+
"right-click": [
|
|
137
|
+
"popover",
|
|
138
|
+
"menu"
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
"tag": "menu-ui",
|
|
142
|
+
"tokens": {},
|
|
143
|
+
"traits": [],
|
|
144
|
+
"version": 1
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
@scope (menu-ui) {
|
|
2
|
+
:scope {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
position: relative;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Items/dividers in Light DOM are hidden unless they've been adopted
|
|
10
|
+
into the popover on open. Popover API also hides the popover itself when closed. */
|
|
11
|
+
menu-ui > menu-item-ui,
|
|
12
|
+
menu-ui > menu-divider-ui {
|
|
13
|
+
display: none !important;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* ── Top-layer: cannot inherit component tokens ── */
|
|
17
|
+
|
|
18
|
+
menu-ui [data-menu-popover] {
|
|
19
|
+
margin: 0;
|
|
20
|
+
padding: var(--a-space-1);
|
|
21
|
+
border: 1px solid var(--a-border-subtle);
|
|
22
|
+
border-radius: var(--a-radius-lg);
|
|
23
|
+
background: var(--a-bg-subtle);
|
|
24
|
+
box-shadow: var(--a-shadow-lg);
|
|
25
|
+
min-width: 10rem;
|
|
26
|
+
font-family: inherit;
|
|
27
|
+
font-size: var(--a-ui-size);
|
|
28
|
+
color: var(--a-fg);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@scope (menu-item-ui) {
|
|
32
|
+
:where(:scope) {
|
|
33
|
+
/* ── Layout ── */
|
|
34
|
+
--menu-item-gap: var(--a-space-2);
|
|
35
|
+
--menu-item-px: var(--a-space-2);
|
|
36
|
+
--menu-item-py: var(--a-space-1-5);
|
|
37
|
+
--menu-item-radius: var(--a-radius-md);
|
|
38
|
+
|
|
39
|
+
/* ── Colors ── */
|
|
40
|
+
--menu-item-bg: transparent;
|
|
41
|
+
--menu-item-fg: var(--a-fg-subtle);
|
|
42
|
+
--menu-item-fg-hover: var(--a-fg);
|
|
43
|
+
--menu-item-bg-hover: var(--a-bg-muted);
|
|
44
|
+
--menu-item-fg-disabled: var(--a-fg-disabled, var(--a-fg-muted));
|
|
45
|
+
--menu-item-icon-fg: var(--a-fg-muted);
|
|
46
|
+
--menu-item-icon-fg-hover: var(--a-fg);
|
|
47
|
+
--menu-item-icon-disabled: var(--a-fg-disabled, var(--a-fg-muted));
|
|
48
|
+
--menu-item-danger-fg: var(--a-danger-bg);
|
|
49
|
+
--menu-item-danger-bg: var(--a-danger-muted);
|
|
50
|
+
|
|
51
|
+
/* ── Typography ── */
|
|
52
|
+
--menu-item-font-size: var(--a-ui-size);
|
|
53
|
+
|
|
54
|
+
/* ── Transition ── */
|
|
55
|
+
--menu-item-duration: var(--a-duration-fast);
|
|
56
|
+
--menu-item-easing: var(--a-easing);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:scope {
|
|
60
|
+
box-sizing: border-box;
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: var(--menu-item-gap);
|
|
64
|
+
padding: var(--menu-item-py) var(--menu-item-px);
|
|
65
|
+
border-radius: var(--menu-item-radius);
|
|
66
|
+
font-size: var(--menu-item-font-size);
|
|
67
|
+
background: var(--menu-item-bg);
|
|
68
|
+
color: var(--menu-item-fg);
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
transition:
|
|
71
|
+
background var(--menu-item-duration) var(--menu-item-easing),
|
|
72
|
+
color var(--menu-item-duration) var(--menu-item-easing);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:scope:hover,
|
|
76
|
+
:scope:focus-visible {
|
|
77
|
+
--menu-item-bg: var(--menu-item-bg-hover);
|
|
78
|
+
--menu-item-fg: var(--menu-item-fg-hover);
|
|
79
|
+
outline: none;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Icon */
|
|
83
|
+
[slot="icon"] {
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
--a-icon-size: var(--menu-item-font-size);
|
|
86
|
+
color: var(--menu-item-icon-fg);
|
|
87
|
+
transition: color var(--menu-item-duration) var(--menu-item-easing);
|
|
88
|
+
}
|
|
89
|
+
:scope:hover [slot="icon"] {
|
|
90
|
+
color: var(--menu-item-icon-fg-hover);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Text */
|
|
94
|
+
[slot="text"] {
|
|
95
|
+
flex: 1;
|
|
96
|
+
white-space: nowrap;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* ── Variant: danger ── */
|
|
100
|
+
:scope[variant="danger"] {
|
|
101
|
+
--menu-item-fg: var(--a-danger-bg);
|
|
102
|
+
}
|
|
103
|
+
:scope[variant="danger"]:hover {
|
|
104
|
+
--menu-item-bg: var(--menu-item-danger-bg);
|
|
105
|
+
--menu-item-fg: var(--menu-item-danger-fg);
|
|
106
|
+
}
|
|
107
|
+
:scope[variant="danger"] [slot="icon"] {
|
|
108
|
+
color: var(--menu-item-danger-fg);
|
|
109
|
+
}
|
|
110
|
+
:scope[variant="danger"]:hover [slot="icon"] {
|
|
111
|
+
color: var(--menu-item-danger-fg);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* ── Disabled ── */
|
|
115
|
+
:scope[disabled] {
|
|
116
|
+
--menu-item-fg: var(--menu-item-fg-disabled);
|
|
117
|
+
pointer-events: none;
|
|
118
|
+
cursor: not-allowed;
|
|
119
|
+
}
|
|
120
|
+
:scope[disabled] [slot="icon"] {
|
|
121
|
+
color: var(--menu-item-icon-disabled);
|
|
122
|
+
}
|
|
123
|
+
:scope[disabled]:hover {
|
|
124
|
+
--menu-item-bg: transparent;
|
|
125
|
+
--menu-item-fg: var(--menu-item-fg-disabled);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@scope (menu-divider-ui) {
|
|
130
|
+
:where(:scope) {
|
|
131
|
+
/* ── Layout ── */
|
|
132
|
+
--menu-divider-my: var(--a-space-1);
|
|
133
|
+
|
|
134
|
+
/* ── Colors ── */
|
|
135
|
+
--menu-divider-color: var(--a-border-subtle);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
:scope {
|
|
139
|
+
box-sizing: border-box;
|
|
140
|
+
display: block;
|
|
141
|
+
height: 1px;
|
|
142
|
+
background: var(--menu-divider-color);
|
|
143
|
+
margin: var(--menu-divider-my) 0;
|
|
144
|
+
border: none;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <menu-ui>
|
|
3
|
+
* <button-ui slot="trigger" icon="dots-three-vertical" variant="ghost"></button-ui>
|
|
4
|
+
* <menu-item-ui icon="pencil" text="Edit" value="edit"></menu-item-ui>
|
|
5
|
+
* <menu-item-ui icon="copy" text="Duplicate" value="duplicate"></menu-item-ui>
|
|
6
|
+
* <menu-divider-ui></menu-divider-ui>
|
|
7
|
+
* <menu-item-ui icon="trash" text="Delete" value="delete" variant="danger"></menu-item-ui>
|
|
8
|
+
* </menu-ui>
|
|
9
|
+
*
|
|
10
|
+
* Dropdown action menu. Fires `action` events, does not hold a value.
|
|
11
|
+
*
|
|
12
|
+
* Platform:
|
|
13
|
+
* • Popover API (popover="manual") → top-layer, escapes overflow/z-index.
|
|
14
|
+
* • CSS Anchor Positioning (via @core/anchor.js) with JS fallback.
|
|
15
|
+
* • Roving focus + arrow/Home/End/Enter/Escape keyboard nav.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { AdiaElement } from '@core/element.js';
|
|
19
|
+
import { anchorPopover } from '@core/anchor.js';
|
|
20
|
+
|
|
21
|
+
class AdiaMenu extends AdiaElement {
|
|
22
|
+
static properties = {
|
|
23
|
+
open: { type: Boolean, default: false, reflect: true },
|
|
24
|
+
placement: { type: String, default: 'bottom-start', reflect: true },
|
|
25
|
+
gap: { type: Number, default: 4, reflect: true },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
static template = () => null;
|
|
29
|
+
|
|
30
|
+
#anchorCleanup = null;
|
|
31
|
+
#popover = null;
|
|
32
|
+
#bound = false;
|
|
33
|
+
|
|
34
|
+
connected() {
|
|
35
|
+
if (!this.#bound) {
|
|
36
|
+
this.#bound = true;
|
|
37
|
+
this.addEventListener('click', this.#onTriggerClick);
|
|
38
|
+
this.addEventListener('keydown', this.#onTriggerKey);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
render() {
|
|
43
|
+
if (this.open) this.#show();
|
|
44
|
+
else this.#hide();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ── Public API ──
|
|
48
|
+
show() { this.open = true; }
|
|
49
|
+
hide() { this.open = false; }
|
|
50
|
+
toggle() { this.open = !this.open; }
|
|
51
|
+
|
|
52
|
+
// ── Internal ──
|
|
53
|
+
|
|
54
|
+
#ensurePopover() {
|
|
55
|
+
if (this.#popover) return this.#popover;
|
|
56
|
+
const el = document.createElement('div');
|
|
57
|
+
el.setAttribute('data-menu-popover', '');
|
|
58
|
+
el.setAttribute('popover', 'manual');
|
|
59
|
+
el.setAttribute('role', 'menu');
|
|
60
|
+
el.addEventListener('toggle', this.#onToggle);
|
|
61
|
+
el.addEventListener('click', this.#onItemClick);
|
|
62
|
+
el.addEventListener('keydown', this.#onMenuKey);
|
|
63
|
+
this.appendChild(el);
|
|
64
|
+
this.#popover = el;
|
|
65
|
+
return el;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#show() {
|
|
69
|
+
const trigger = this.querySelector('[slot="trigger"]');
|
|
70
|
+
if (!trigger) return;
|
|
71
|
+
const pop = this.#ensurePopover();
|
|
72
|
+
|
|
73
|
+
// Move menu items into popover (so they render in the top layer).
|
|
74
|
+
const items = this.querySelectorAll(':scope > menu-item-ui, :scope > menu-divider-ui');
|
|
75
|
+
for (const item of items) pop.appendChild(item);
|
|
76
|
+
|
|
77
|
+
if (!pop.matches(':popover-open')) pop.showPopover?.();
|
|
78
|
+
|
|
79
|
+
this.#anchorCleanup?.();
|
|
80
|
+
this.#anchorCleanup = anchorPopover(trigger, pop, {
|
|
81
|
+
placement: this.placement,
|
|
82
|
+
gap: this.gap,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Focus first enabled item (only when opened via keyboard).
|
|
86
|
+
if (this.#openedByKeyboard) {
|
|
87
|
+
this.#openedByKeyboard = false;
|
|
88
|
+
requestAnimationFrame(() => this.#focusItem(0));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
requestAnimationFrame(() => {
|
|
92
|
+
document.addEventListener('pointerdown', this.#onOutside);
|
|
93
|
+
document.addEventListener('keydown', this.#onDocKey, true);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#hide() {
|
|
98
|
+
this.#anchorCleanup?.();
|
|
99
|
+
this.#anchorCleanup = null;
|
|
100
|
+
|
|
101
|
+
const pop = this.#popover;
|
|
102
|
+
if (pop) {
|
|
103
|
+
if (pop.matches(':popover-open')) pop.hidePopover?.();
|
|
104
|
+
// Move items back to host (before the popover div) so next open can re-adopt them.
|
|
105
|
+
const items = pop.querySelectorAll('menu-item-ui, menu-divider-ui');
|
|
106
|
+
for (const item of items) this.insertBefore(item, pop);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
document.removeEventListener('pointerdown', this.#onOutside);
|
|
110
|
+
document.removeEventListener('keydown', this.#onDocKey, true);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
#enabledItems() {
|
|
114
|
+
return Array.from(this.#popover?.querySelectorAll('menu-item-ui') ?? [])
|
|
115
|
+
.filter((el) => !el.disabled);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#focusItem(index) {
|
|
119
|
+
const items = this.#enabledItems();
|
|
120
|
+
if (!items.length) return;
|
|
121
|
+
const i = (index + items.length) % items.length;
|
|
122
|
+
const item = items[i];
|
|
123
|
+
item.setAttribute('tabindex', '-1');
|
|
124
|
+
item.focus({ preventScroll: true });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#focusedIndex() {
|
|
128
|
+
const items = this.#enabledItems();
|
|
129
|
+
return items.indexOf(document.activeElement);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ── Events ──
|
|
133
|
+
|
|
134
|
+
#openedByKeyboard = false;
|
|
135
|
+
|
|
136
|
+
#onTriggerClick = (e) => {
|
|
137
|
+
const trigger = this.querySelector('[slot="trigger"]');
|
|
138
|
+
if (!trigger) return;
|
|
139
|
+
if (e.target === trigger || trigger.contains(e.target)) {
|
|
140
|
+
this.#openedByKeyboard = false;
|
|
141
|
+
this.open = !this.open;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
#onTriggerKey = (e) => {
|
|
146
|
+
const trigger = this.querySelector('[slot="trigger"]');
|
|
147
|
+
if (!trigger || !(e.target === trigger || trigger.contains(e.target))) return;
|
|
148
|
+
if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
this.#openedByKeyboard = true;
|
|
151
|
+
this.open = true;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
#onItemClick = (e) => {
|
|
156
|
+
const item = e.target.closest('menu-item-ui');
|
|
157
|
+
if (!item || item.disabled) return;
|
|
158
|
+
this.dispatchEvent(new CustomEvent('action', {
|
|
159
|
+
bubbles: true,
|
|
160
|
+
detail: { value: item.value, text: item.text },
|
|
161
|
+
}));
|
|
162
|
+
this.open = false;
|
|
163
|
+
// Return focus to trigger for continued keyboard flow.
|
|
164
|
+
this.querySelector('[slot="trigger"]')?.focus?.({ preventScroll: true });
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
#onMenuKey = (e) => {
|
|
168
|
+
const items = this.#enabledItems();
|
|
169
|
+
if (!items.length) return;
|
|
170
|
+
const i = this.#focusedIndex();
|
|
171
|
+
switch (e.key) {
|
|
172
|
+
case 'ArrowDown': e.preventDefault(); this.#focusItem(i + 1); break;
|
|
173
|
+
case 'ArrowUp': e.preventDefault(); this.#focusItem(i - 1); break;
|
|
174
|
+
case 'Home': e.preventDefault(); this.#focusItem(0); break;
|
|
175
|
+
case 'End': e.preventDefault(); this.#focusItem(items.length - 1); break;
|
|
176
|
+
case 'Enter':
|
|
177
|
+
case ' ': {
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
const item = items[i] ?? items[0];
|
|
180
|
+
item?.click();
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
#onOutside = (e) => {
|
|
187
|
+
if (!this.open) return;
|
|
188
|
+
if (this.contains(e.target)) return;
|
|
189
|
+
this.open = false;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
#onDocKey = (e) => {
|
|
193
|
+
if (e.key === 'Escape' && this.open) {
|
|
194
|
+
e.stopPropagation();
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
this.open = false;
|
|
197
|
+
this.querySelector('[slot="trigger"]')?.focus?.({ preventScroll: true });
|
|
198
|
+
} else if (e.key === 'Tab' && this.open) {
|
|
199
|
+
// Tab dismisses the menu; let focus move naturally.
|
|
200
|
+
this.open = false;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
#onToggle = (e) => {
|
|
205
|
+
const nowOpen = e.newState === 'open';
|
|
206
|
+
if (nowOpen !== this.open) this.open = nowOpen;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
disconnected() {
|
|
210
|
+
this.#hide();
|
|
211
|
+
if (this.#popover) {
|
|
212
|
+
this.#popover.removeEventListener('toggle', this.#onToggle);
|
|
213
|
+
this.#popover.removeEventListener('click', this.#onItemClick);
|
|
214
|
+
this.#popover.removeEventListener('keydown', this.#onMenuKey);
|
|
215
|
+
}
|
|
216
|
+
this.#popover = null;
|
|
217
|
+
this.#bound = false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
customElements.define('menu-ui', AdiaMenu);
|
|
221
|
+
|
|
222
|
+
class AdiaMenuItem extends AdiaElement {
|
|
223
|
+
static properties = {
|
|
224
|
+
icon: { type: String, default: '', reflect: true },
|
|
225
|
+
text: { type: String, default: '', reflect: true },
|
|
226
|
+
value: { type: String, default: '', reflect: true },
|
|
227
|
+
variant: { type: String, default: 'default', reflect: true },
|
|
228
|
+
disabled: { type: Boolean, default: false, reflect: true },
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
static template = () => null;
|
|
232
|
+
|
|
233
|
+
connected() {
|
|
234
|
+
this.setAttribute('role', 'menuitem');
|
|
235
|
+
if (!this.hasAttribute('tabindex')) this.setAttribute('tabindex', '-1');
|
|
236
|
+
this.#stamp();
|
|
237
|
+
this.#syncAria();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
#stamp() {
|
|
241
|
+
if (this.querySelector('[slot="text"]')) return;
|
|
242
|
+
|
|
243
|
+
if (this.icon) {
|
|
244
|
+
const iconEl = document.createElement('icon-ui');
|
|
245
|
+
iconEl.setAttribute('slot', 'icon');
|
|
246
|
+
iconEl.setAttribute('name', this.icon);
|
|
247
|
+
this.appendChild(iconEl);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (this.text) {
|
|
251
|
+
const span = document.createElement('span');
|
|
252
|
+
span.setAttribute('slot', 'text');
|
|
253
|
+
span.textContent = this.text;
|
|
254
|
+
this.appendChild(span);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
#syncAria() {
|
|
259
|
+
if (this.disabled) this.setAttribute('aria-disabled', 'true');
|
|
260
|
+
else this.removeAttribute('aria-disabled');
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
render() {
|
|
264
|
+
const iconEl = this.querySelector('[slot="icon"]');
|
|
265
|
+
if (this.icon) {
|
|
266
|
+
if (iconEl) {
|
|
267
|
+
iconEl.setAttribute('name', this.icon);
|
|
268
|
+
} else {
|
|
269
|
+
const el = document.createElement('icon-ui');
|
|
270
|
+
el.setAttribute('slot', 'icon');
|
|
271
|
+
el.setAttribute('name', this.icon);
|
|
272
|
+
this.prepend(el);
|
|
273
|
+
}
|
|
274
|
+
} else if (iconEl) {
|
|
275
|
+
iconEl.remove();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const textEl = this.querySelector('[slot="text"]');
|
|
279
|
+
if (textEl) textEl.textContent = this.text;
|
|
280
|
+
|
|
281
|
+
this.#syncAria();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
customElements.define('menu-item-ui', AdiaMenuItem);
|
|
285
|
+
|
|
286
|
+
class AdiaMenuDivider extends AdiaElement {
|
|
287
|
+
static properties = {};
|
|
288
|
+
static template = () => null;
|
|
289
|
+
|
|
290
|
+
connected() {
|
|
291
|
+
this.setAttribute('role', 'separator');
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
customElements.define('menu-divider-ui', AdiaMenuDivider);
|
|
295
|
+
|
|
296
|
+
export { AdiaMenu, AdiaMenuItem, AdiaMenuDivider };
|
|
@@ -0,0 +1,123 @@
|
|
|
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: AdiaMenu
|
|
5
|
+
tag: menu-ui
|
|
6
|
+
component: Menu
|
|
7
|
+
category: container
|
|
8
|
+
version: 1
|
|
9
|
+
description: Dropdown action menu with roving focus and keyboard navigation. Uses Popover API.
|
|
10
|
+
props:
|
|
11
|
+
anchor:
|
|
12
|
+
description: ID of the anchor element the menu positions relative to
|
|
13
|
+
type: string
|
|
14
|
+
default: ""
|
|
15
|
+
trigger:
|
|
16
|
+
description: ID of the element that opens this menu (click handler + aria-controls).
|
|
17
|
+
type: string
|
|
18
|
+
default: ""
|
|
19
|
+
gap:
|
|
20
|
+
description: Gap in px
|
|
21
|
+
type: number
|
|
22
|
+
default: 4
|
|
23
|
+
open:
|
|
24
|
+
description: Controls visibility via popover API
|
|
25
|
+
type: boolean
|
|
26
|
+
default: false
|
|
27
|
+
reflect: true
|
|
28
|
+
placement:
|
|
29
|
+
description: Preferred position relative to the anchor element
|
|
30
|
+
type: string
|
|
31
|
+
default: bottom-start
|
|
32
|
+
enum:
|
|
33
|
+
- bottom-start
|
|
34
|
+
- bottom-end
|
|
35
|
+
- top-start
|
|
36
|
+
- top-end
|
|
37
|
+
events:
|
|
38
|
+
action:
|
|
39
|
+
description: Fired when a menu item is activated. Detail contains the triggering element.
|
|
40
|
+
slots:
|
|
41
|
+
default:
|
|
42
|
+
description: Menu items with role="menuitem" and optional <hr> dividers
|
|
43
|
+
states:
|
|
44
|
+
- name: idle
|
|
45
|
+
description: Default, ready for interaction.
|
|
46
|
+
traits: []
|
|
47
|
+
tokens: {}
|
|
48
|
+
a2ui:
|
|
49
|
+
rules: []
|
|
50
|
+
anti_patterns: []
|
|
51
|
+
examples:
|
|
52
|
+
- name: basic-menu
|
|
53
|
+
description: Basic Menu usage
|
|
54
|
+
a2ui: >-
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
"id": "root",
|
|
58
|
+
"component": "Card",
|
|
59
|
+
"children": [
|
|
60
|
+
"sec"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"id": "sec",
|
|
65
|
+
"component": "Section",
|
|
66
|
+
"children": [
|
|
67
|
+
"comp"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "comp",
|
|
72
|
+
"component": "Menu"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
keywords:
|
|
76
|
+
- menu
|
|
77
|
+
- navigation
|
|
78
|
+
- navbar
|
|
79
|
+
- hamburger
|
|
80
|
+
- dropdown
|
|
81
|
+
- popover
|
|
82
|
+
- context-menu
|
|
83
|
+
- right-click
|
|
84
|
+
synonyms:
|
|
85
|
+
context-menu:
|
|
86
|
+
- popover
|
|
87
|
+
- menu
|
|
88
|
+
dropdown:
|
|
89
|
+
- popover
|
|
90
|
+
- menu
|
|
91
|
+
- select
|
|
92
|
+
- form
|
|
93
|
+
hamburger:
|
|
94
|
+
- nav
|
|
95
|
+
- menu
|
|
96
|
+
- sidebar
|
|
97
|
+
- drawer
|
|
98
|
+
menu:
|
|
99
|
+
- nav
|
|
100
|
+
- sidebar
|
|
101
|
+
- popover
|
|
102
|
+
- menu
|
|
103
|
+
- command
|
|
104
|
+
navbar:
|
|
105
|
+
- nav
|
|
106
|
+
- menu
|
|
107
|
+
- sidebar
|
|
108
|
+
- breadcrumb
|
|
109
|
+
navigation:
|
|
110
|
+
- nav
|
|
111
|
+
- sidebar
|
|
112
|
+
- breadcrumb
|
|
113
|
+
- tabs
|
|
114
|
+
- menu
|
|
115
|
+
- pagination
|
|
116
|
+
popover:
|
|
117
|
+
- popover
|
|
118
|
+
- menu
|
|
119
|
+
- tooltip
|
|
120
|
+
right-click:
|
|
121
|
+
- popover
|
|
122
|
+
- menu
|
|
123
|
+
related: []
|