@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,342 @@
|
|
|
1
|
+
/* ═══════════════════════════════════════════════════════════════
|
|
2
|
+
DRAWER-N — Slide-out panel using native <dialog>.
|
|
3
|
+
|
|
4
|
+
Layout aligns with card-ui: header uses a 3-column grid
|
|
5
|
+
(icon | heading+description | action+close), footer uses a
|
|
6
|
+
flex row with [slot="description"] + [slot="action"] semantics.
|
|
7
|
+
═══════════════════════════════════════════════════════════════ */
|
|
8
|
+
|
|
9
|
+
@scope (drawer-ui) {
|
|
10
|
+
:where(:scope) {
|
|
11
|
+
/* ── Geometry ── */
|
|
12
|
+
--drawer-width: 24rem;
|
|
13
|
+
--drawer-height: 24rem;
|
|
14
|
+
--drawer-inset: var(--a-space-4);
|
|
15
|
+
--drawer-header-pad: var(--drawer-inset);
|
|
16
|
+
--drawer-footer-pad: var(--drawer-inset);
|
|
17
|
+
--drawer-header-gap: var(--a-space-2);
|
|
18
|
+
--drawer-footer-gap: var(--a-space-2);
|
|
19
|
+
|
|
20
|
+
/* ── Motion ── */
|
|
21
|
+
--drawer-duration: var(--a-duration);
|
|
22
|
+
--drawer-easing: var(--a-easing-out);
|
|
23
|
+
|
|
24
|
+
/* ── Colors ── */
|
|
25
|
+
--drawer-bg: var(--a-canvas-1);
|
|
26
|
+
--drawer-border: var(--a-border-subtle);
|
|
27
|
+
--drawer-divider: var(--a-border-subtle);
|
|
28
|
+
--drawer-shadow: var(--a-shadow-lg);
|
|
29
|
+
--drawer-backdrop: var(--a-scrim-dialog);
|
|
30
|
+
--drawer-fg: var(--a-fg);
|
|
31
|
+
--drawer-heading-fg: var(--a-fg-strong);
|
|
32
|
+
--drawer-description-fg: var(--a-fg-subtle);
|
|
33
|
+
|
|
34
|
+
/* ── Typography ── */
|
|
35
|
+
--drawer-font-family: var(--a-font-family);
|
|
36
|
+
--drawer-heading-size: var(--a-ui-lg);
|
|
37
|
+
--drawer-heading-weight: var(--a-weight-semibold);
|
|
38
|
+
--drawer-description-size: var(--a-caption-size);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:scope {
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
display: contents;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* ── Size variants ── */
|
|
47
|
+
:scope[size="sm"] { --drawer-width: min(18rem, 90vw); }
|
|
48
|
+
:scope[size="md"] { --drawer-width: min(24rem, 90vw); }
|
|
49
|
+
:scope[size="lg"] { --drawer-width: min(36rem, 90vw); }
|
|
50
|
+
|
|
51
|
+
/* ═══════ Dialog shell ═══════ */
|
|
52
|
+
|
|
53
|
+
> [slot="dialog"]:not([open]) { display: none; }
|
|
54
|
+
|
|
55
|
+
> [slot="dialog"][open] {
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
position: fixed;
|
|
58
|
+
inset: 0;
|
|
59
|
+
width: 100%;
|
|
60
|
+
height: 100%;
|
|
61
|
+
max-width: none;
|
|
62
|
+
max-height: none;
|
|
63
|
+
margin: 0;
|
|
64
|
+
padding: 0;
|
|
65
|
+
border: none;
|
|
66
|
+
background: transparent;
|
|
67
|
+
overflow: clip;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
> [slot="dialog"]::backdrop {
|
|
71
|
+
background: var(--drawer-backdrop);
|
|
72
|
+
opacity: 0;
|
|
73
|
+
transition: opacity var(--drawer-duration) var(--drawer-easing);
|
|
74
|
+
}
|
|
75
|
+
> [slot="dialog"][data-open]::backdrop { opacity: 1; }
|
|
76
|
+
> [slot="dialog"][data-closing]::backdrop { opacity: 0; }
|
|
77
|
+
|
|
78
|
+
/* ═══════ Panel ═══════ */
|
|
79
|
+
|
|
80
|
+
> [slot="dialog"] > [slot="panel"] {
|
|
81
|
+
box-sizing: border-box;
|
|
82
|
+
position: absolute;
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
background: var(--drawer-bg);
|
|
86
|
+
color: var(--drawer-fg);
|
|
87
|
+
font-family: var(--drawer-font-family);
|
|
88
|
+
box-shadow: var(--drawer-shadow);
|
|
89
|
+
overflow-y: auto;
|
|
90
|
+
opacity: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* ── Side: right (default) ── */
|
|
94
|
+
:scope:not([side]) > [slot="dialog"] > [slot="panel"],
|
|
95
|
+
:scope[side="right"] > [slot="dialog"] > [slot="panel"] {
|
|
96
|
+
top: 0; right: 0; bottom: 0;
|
|
97
|
+
width: var(--drawer-width);
|
|
98
|
+
border-left: 1px solid var(--drawer-border);
|
|
99
|
+
transform: translateX(100%);
|
|
100
|
+
}
|
|
101
|
+
:scope:not([side]) > [slot="dialog"][data-open] > [slot="panel"],
|
|
102
|
+
:scope[side="right"] > [slot="dialog"][data-open] > [slot="panel"] {
|
|
103
|
+
transition: transform var(--drawer-duration) var(--drawer-easing),
|
|
104
|
+
opacity var(--drawer-duration) var(--drawer-easing);
|
|
105
|
+
transform: translateX(0);
|
|
106
|
+
opacity: 1;
|
|
107
|
+
}
|
|
108
|
+
:scope:not([side]) > [slot="dialog"][data-closing] > [slot="panel"],
|
|
109
|
+
:scope[side="right"] > [slot="dialog"][data-closing] > [slot="panel"] {
|
|
110
|
+
transition: transform var(--drawer-duration) var(--drawer-easing),
|
|
111
|
+
opacity var(--drawer-duration) var(--drawer-easing);
|
|
112
|
+
transform: translateX(100%);
|
|
113
|
+
opacity: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* ── Side: left ── */
|
|
117
|
+
:scope[side="left"] > [slot="dialog"] > [slot="panel"] {
|
|
118
|
+
top: 0; left: 0; bottom: 0;
|
|
119
|
+
width: var(--drawer-width);
|
|
120
|
+
border-right: 1px solid var(--drawer-border);
|
|
121
|
+
transform: translateX(-100%);
|
|
122
|
+
}
|
|
123
|
+
:scope[side="left"] > [slot="dialog"][data-open] > [slot="panel"] {
|
|
124
|
+
transition: transform var(--drawer-duration) var(--drawer-easing),
|
|
125
|
+
opacity var(--drawer-duration) var(--drawer-easing);
|
|
126
|
+
transform: translateX(0); opacity: 1;
|
|
127
|
+
}
|
|
128
|
+
:scope[side="left"] > [slot="dialog"][data-closing] > [slot="panel"] {
|
|
129
|
+
transition: transform var(--drawer-duration) var(--drawer-easing),
|
|
130
|
+
opacity var(--drawer-duration) var(--drawer-easing);
|
|
131
|
+
transform: translateX(-100%); opacity: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* ── Side: bottom ── */
|
|
135
|
+
:scope[side="bottom"] > [slot="dialog"] > [slot="panel"] {
|
|
136
|
+
bottom: 0; left: 0; right: 0;
|
|
137
|
+
height: var(--drawer-height);
|
|
138
|
+
border-top: 1px solid var(--drawer-border);
|
|
139
|
+
transform: translateY(100%);
|
|
140
|
+
}
|
|
141
|
+
:scope[side="bottom"] > [slot="dialog"][data-open] > [slot="panel"] {
|
|
142
|
+
transition: transform var(--drawer-duration) var(--drawer-easing),
|
|
143
|
+
opacity var(--drawer-duration) var(--drawer-easing);
|
|
144
|
+
transform: translateY(0); opacity: 1;
|
|
145
|
+
}
|
|
146
|
+
:scope[side="bottom"] > [slot="dialog"][data-closing] > [slot="panel"] {
|
|
147
|
+
transition: transform var(--drawer-duration) var(--drawer-easing),
|
|
148
|
+
opacity var(--drawer-duration) var(--drawer-easing);
|
|
149
|
+
transform: translateY(100%); opacity: 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* ── Side: top ── */
|
|
153
|
+
:scope[side="top"] > [slot="dialog"] > [slot="panel"] {
|
|
154
|
+
top: 0; left: 0; right: 0;
|
|
155
|
+
height: var(--drawer-height);
|
|
156
|
+
border-bottom: 1px solid var(--drawer-border);
|
|
157
|
+
transform: translateY(-100%);
|
|
158
|
+
}
|
|
159
|
+
:scope[side="top"] > [slot="dialog"][data-open] > [slot="panel"] {
|
|
160
|
+
transition: transform var(--drawer-duration) var(--drawer-easing),
|
|
161
|
+
opacity var(--drawer-duration) var(--drawer-easing);
|
|
162
|
+
transform: translateY(0); opacity: 1;
|
|
163
|
+
}
|
|
164
|
+
:scope[side="top"] > [slot="dialog"][data-closing] > [slot="panel"] {
|
|
165
|
+
transition: transform var(--drawer-duration) var(--drawer-easing),
|
|
166
|
+
opacity var(--drawer-duration) var(--drawer-easing);
|
|
167
|
+
transform: translateY(-100%); opacity: 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* ═══════ Header — card-n-aligned grid ═══════
|
|
171
|
+
Block by default (fallback for empty/free-form content).
|
|
172
|
+
Grid activates when any slotted child is present. Column template
|
|
173
|
+
adapts to the presence of [slot="icon"] and [slot="action"|"close"]. */
|
|
174
|
+
|
|
175
|
+
[slot="panel"] > [slot="header"] {
|
|
176
|
+
display: block;
|
|
177
|
+
padding: var(--drawer-header-pad);
|
|
178
|
+
border-bottom: 1px solid var(--drawer-divider);
|
|
179
|
+
color: var(--drawer-heading-fg);
|
|
180
|
+
flex-shrink: 0;
|
|
181
|
+
/* Sticky so that with multiple <section> siblings scrolling below,
|
|
182
|
+
the header stays pinned to the top of the panel. */
|
|
183
|
+
position: sticky;
|
|
184
|
+
top: 0;
|
|
185
|
+
background: var(--drawer-bg);
|
|
186
|
+
z-index: 1;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
[slot="panel"] > [slot="header"]:has(> [slot]) {
|
|
190
|
+
display: grid;
|
|
191
|
+
gap: var(--drawer-header-gap);
|
|
192
|
+
align-items: center;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
[slot="panel"] > [slot="header"][padding] {
|
|
196
|
+
background: var(--a-canvas-0-scrim);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
[slot="panel"] > [slot="header"][center] {
|
|
200
|
+
text-align: center;
|
|
201
|
+
justify-items: center;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* Column templates — mirror card-ui. `:has(> …)` restricts to direct
|
|
205
|
+
children so that nested slot="icon" (e.g. inside an <avatar-ui>) doesn't
|
|
206
|
+
accidentally activate the icon column. Treat [slot="close"] as an
|
|
207
|
+
action-column occupant. */
|
|
208
|
+
[slot="panel"] > [slot="header"]:has(> [slot="icon"]):has(> :is([slot="action"], [slot="close"])) {
|
|
209
|
+
grid-template-columns: max-content 1fr max-content;
|
|
210
|
+
}
|
|
211
|
+
[slot="panel"] > [slot="header"]:has(> [slot="icon"]):not(:has(> :is([slot="action"], [slot="close"]))) {
|
|
212
|
+
grid-template-columns: max-content 1fr;
|
|
213
|
+
}
|
|
214
|
+
[slot="panel"] > [slot="header"]:not(:has(> [slot="icon"])):has(> :is([slot="action"], [slot="close"])) {
|
|
215
|
+
grid-template-columns: 1fr max-content;
|
|
216
|
+
}
|
|
217
|
+
[slot="panel"] > [slot="header"]:not(:has(> [slot="icon"])):not(:has(> :is([slot="action"], [slot="close"]))) {
|
|
218
|
+
grid-template-columns: 1fr;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* Icon — first column */
|
|
222
|
+
[slot="panel"] > [slot="header"] > [slot="icon"] {
|
|
223
|
+
grid-column: 1;
|
|
224
|
+
grid-row: 1;
|
|
225
|
+
align-self: center;
|
|
226
|
+
display: flex;
|
|
227
|
+
align-items: center;
|
|
228
|
+
justify-content: center;
|
|
229
|
+
}
|
|
230
|
+
[slot="panel"] > [slot="header"]:has(> :is([slot="description"], p, small)) > [slot="icon"] {
|
|
231
|
+
grid-row: 1 / span 2;
|
|
232
|
+
align-self: start;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* Heading — row 1 */
|
|
236
|
+
[slot="panel"] > [slot="header"] > :is([slot="heading"], h1, h2, h3, h4, h5, h6),
|
|
237
|
+
[slot="panel"] > [slot="header"] > [slot="heading"] :is(h1, h2, h3, h4, h5, h6) {
|
|
238
|
+
grid-row: 1;
|
|
239
|
+
line-height: 1.3;
|
|
240
|
+
margin: 0;
|
|
241
|
+
font-size: var(--drawer-heading-size);
|
|
242
|
+
font-weight: var(--drawer-heading-weight);
|
|
243
|
+
color: var(--drawer-heading-fg);
|
|
244
|
+
}
|
|
245
|
+
[slot="panel"] > [slot="header"] > [slot="heading"] {
|
|
246
|
+
display: flex;
|
|
247
|
+
align-items: center;
|
|
248
|
+
gap: var(--drawer-header-gap);
|
|
249
|
+
}
|
|
250
|
+
[slot="panel"] > [slot="header"]:has(> [slot="icon"]) > :is([slot="heading"], h1, h2, h3, h4, h5, h6) {
|
|
251
|
+
grid-column: 2;
|
|
252
|
+
}
|
|
253
|
+
[slot="panel"] > [slot="header"]:not(:has(> [slot="icon"])) > :is([slot="heading"], h1, h2, h3, h4, h5, h6) {
|
|
254
|
+
grid-column: 1;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* Description — row 2 */
|
|
258
|
+
[slot="panel"] > [slot="header"] > :is([slot="description"], p, small) {
|
|
259
|
+
grid-row: 2;
|
|
260
|
+
grid-column: 1 / -1;
|
|
261
|
+
line-height: 1.4;
|
|
262
|
+
margin: 0;
|
|
263
|
+
font-size: var(--drawer-description-size);
|
|
264
|
+
color: var(--drawer-description-fg);
|
|
265
|
+
}
|
|
266
|
+
[slot="panel"] > [slot="header"]:has(> [slot="icon"]) > :is([slot="description"], p, small) {
|
|
267
|
+
grid-column: 2 / -1;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/* Action + close — row 1, last column */
|
|
271
|
+
[slot="panel"] > [slot="header"] > :is([slot="action"], [slot="close"]) {
|
|
272
|
+
justify-self: end;
|
|
273
|
+
align-self: center;
|
|
274
|
+
grid-row: 1;
|
|
275
|
+
grid-column: -2 / -1;
|
|
276
|
+
display: flex;
|
|
277
|
+
align-items: center;
|
|
278
|
+
gap: var(--drawer-header-gap);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* ═══════ Body (section) ═══════
|
|
282
|
+
Padded by default. Multiple <section> siblings are allowed — they stack
|
|
283
|
+
inside the panel's own scroll region (see panel's overflow-y + sticky
|
|
284
|
+
header/footer above). [bleed] removes padding; [padding] adds a canvas
|
|
285
|
+
scrim background (card-ui parity). */
|
|
286
|
+
|
|
287
|
+
[slot="panel"] > [slot="body"] {
|
|
288
|
+
padding: var(--drawer-inset);
|
|
289
|
+
/* Last body takes any remaining vertical slack so the footer hugs the
|
|
290
|
+
bottom even when content is shorter than the viewport. */
|
|
291
|
+
flex: 0 0 auto;
|
|
292
|
+
}
|
|
293
|
+
[slot="panel"] > [slot="body"]:last-of-type { flex: 1 0 auto; }
|
|
294
|
+
[slot="panel"] > [slot="body"] + [slot="body"] { padding-top: 0; }
|
|
295
|
+
[slot="panel"] > [slot="body"][bleed] { padding: 0; }
|
|
296
|
+
[slot="panel"] > [slot="body"][padding] { background: var(--a-canvas-0-scrim); }
|
|
297
|
+
|
|
298
|
+
/* ═══════ Footer ═══════
|
|
299
|
+
Flex row for actions. [slot="description"] + [slot="action"] = space-between.
|
|
300
|
+
Mirrors card-ui footer semantics. */
|
|
301
|
+
|
|
302
|
+
[slot="panel"] > [slot="footer"] {
|
|
303
|
+
display: flex;
|
|
304
|
+
flex-wrap: wrap;
|
|
305
|
+
align-items: center;
|
|
306
|
+
gap: var(--drawer-footer-gap);
|
|
307
|
+
padding: var(--drawer-footer-pad);
|
|
308
|
+
border-top: 1px solid var(--drawer-divider);
|
|
309
|
+
flex-shrink: 0;
|
|
310
|
+
/* Sticky to the bottom so action buttons stay visible during scroll. */
|
|
311
|
+
position: sticky;
|
|
312
|
+
bottom: 0;
|
|
313
|
+
background: var(--drawer-bg);
|
|
314
|
+
z-index: 1;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
[slot="panel"] > [slot="footer"][justify="end"] {
|
|
318
|
+
justify-content: flex-end;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
[slot="panel"] > [slot="footer"]:has(> :is([slot="description"], p, small)):has(> [slot="action"]) {
|
|
322
|
+
justify-content: space-between;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
[slot="panel"] > [slot="footer"] :is([slot="description"], p, small) {
|
|
326
|
+
font-size: var(--drawer-description-size);
|
|
327
|
+
color: var(--drawer-description-fg);
|
|
328
|
+
flex: 1;
|
|
329
|
+
min-width: 0;
|
|
330
|
+
margin: 0;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
[slot="panel"] > [slot="footer"] [slot="action"] {
|
|
334
|
+
margin-inline-start: auto;
|
|
335
|
+
display: flex;
|
|
336
|
+
gap: var(--drawer-footer-gap);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
[slot="panel"] > [slot="footer"] > [slot="action"] ~ [slot="action"] {
|
|
340
|
+
margin-inline-start: 0;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <drawer-ui> — Slide-out panel anchored to a viewport edge.
|
|
3
|
+
*
|
|
4
|
+
* Uses native <dialog> for focus trapping, Escape key, and ::backdrop.
|
|
5
|
+
* Content panel slides in/out with CSS transitions.
|
|
6
|
+
* Exit animation plays before dialog.close() via [data-closing].
|
|
7
|
+
*
|
|
8
|
+
* Authoring — card-n-style tags (recommended):
|
|
9
|
+
* <drawer-ui side="right" size="md">
|
|
10
|
+
* <header>Title block</header>
|
|
11
|
+
* <section>Body content</section>
|
|
12
|
+
* <footer>Action buttons</footer>
|
|
13
|
+
* </drawer-ui>
|
|
14
|
+
*
|
|
15
|
+
* Authoring — explicit slots (also supported):
|
|
16
|
+
* <drawer-ui>
|
|
17
|
+
* <header slot="header">…</header>
|
|
18
|
+
* <section slot="body">…</section>
|
|
19
|
+
* <footer slot="footer">…</footer>
|
|
20
|
+
* </drawer-ui>
|
|
21
|
+
*
|
|
22
|
+
* Title-only (stamps an empty header with a close button):
|
|
23
|
+
* <drawer-ui text="Settings" side="right"></drawer-ui>
|
|
24
|
+
*
|
|
25
|
+
* API:
|
|
26
|
+
* drawer.show() · drawer.hide() · drawer.open = true|false
|
|
27
|
+
*
|
|
28
|
+
* Events:
|
|
29
|
+
* close — fired after the drawer finishes closing
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import { AdiaElement } from '@core/element.js';
|
|
33
|
+
|
|
34
|
+
class AdiaDrawer extends AdiaElement {
|
|
35
|
+
#bound = false;
|
|
36
|
+
#closing = false;
|
|
37
|
+
#previousFocus = null;
|
|
38
|
+
#closeTimer = null;
|
|
39
|
+
#openRaf = null;
|
|
40
|
+
#dialogRef = null;
|
|
41
|
+
|
|
42
|
+
static properties = {
|
|
43
|
+
text: { type: String, default: '', reflect: true },
|
|
44
|
+
side: { type: String, default: 'right', reflect: true },
|
|
45
|
+
size: { type: String, default: 'md', reflect: true },
|
|
46
|
+
permanent: { type: Boolean, default: false, reflect: true },
|
|
47
|
+
open: { type: Boolean, default: false, reflect: true },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
static parts = {
|
|
51
|
+
dialog: '<dialog slot="dialog"></dialog>',
|
|
52
|
+
panel: '<div slot="panel"></div>',
|
|
53
|
+
header: '<header slot="header"></header>',
|
|
54
|
+
close: '<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Close"></button-ui>',
|
|
55
|
+
body: '<section slot="body"></section>',
|
|
56
|
+
footer: '<footer slot="footer"></footer>',
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// No template — drawer composes from authored light-DOM children. An empty
|
|
60
|
+
// html`` result would trigger stamp() → replaceChildren(), wiping authored
|
|
61
|
+
// [slot=header|body|footer] before render() can migrate them into the panel.
|
|
62
|
+
|
|
63
|
+
#onPress = (e) => {
|
|
64
|
+
if (e.target.closest('[slot="close"]')) this.open = false;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
#onDialogCancel = (e) => {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
if (!this.permanent) this.open = false;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
#onDialogClose = () => {
|
|
73
|
+
this.open = false;
|
|
74
|
+
this.#previousFocus?.focus();
|
|
75
|
+
this.#previousFocus = null;
|
|
76
|
+
this.dispatchEvent(new Event('close', { bubbles: true }));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
#onDialogClick = (e) => {
|
|
80
|
+
if (e.target === this.#dialogRef && !this.permanent) this.open = false;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
connected() {
|
|
84
|
+
this.addEventListener('press', this.#onPress);
|
|
85
|
+
|
|
86
|
+
// Bind dialog listeners as soon as the dialog part is available.
|
|
87
|
+
const dialog = this.ensure('dialog');
|
|
88
|
+
if (dialog && !this.#bound) {
|
|
89
|
+
this.#bound = true;
|
|
90
|
+
this.#dialogRef = dialog;
|
|
91
|
+
dialog.addEventListener('cancel', this.#onDialogCancel);
|
|
92
|
+
dialog.addEventListener('close', this.#onDialogClose);
|
|
93
|
+
dialog.addEventListener('click', this.#onDialogClick);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
disconnected() {
|
|
98
|
+
this.removeEventListener('press', this.#onPress);
|
|
99
|
+
if (this.#dialogRef) {
|
|
100
|
+
this.#dialogRef.removeEventListener('cancel', this.#onDialogCancel);
|
|
101
|
+
this.#dialogRef.removeEventListener('close', this.#onDialogClose);
|
|
102
|
+
this.#dialogRef.removeEventListener('click', this.#onDialogClick);
|
|
103
|
+
}
|
|
104
|
+
if (this.#openRaf != null) {
|
|
105
|
+
cancelAnimationFrame(this.#openRaf);
|
|
106
|
+
this.#openRaf = null;
|
|
107
|
+
}
|
|
108
|
+
if (this.#closeTimer != null) {
|
|
109
|
+
clearTimeout(this.#closeTimer);
|
|
110
|
+
this.#closeTimer = null;
|
|
111
|
+
}
|
|
112
|
+
this.#bound = false;
|
|
113
|
+
this.#dialogRef = null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#getDuration() {
|
|
117
|
+
const raw = getComputedStyle(this).getPropertyValue('--drawer-duration').trim();
|
|
118
|
+
return parseFloat(raw) || 200;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Adopt a slotted part into the panel. Accepts either an explicit
|
|
123
|
+
* [slot="X"] element OR a bare tag matching the card-ui convention
|
|
124
|
+
* (<header> → header, <section> → body, <footer> → footer). The tag is only
|
|
125
|
+
* adopted when no slot attribute is set, so authors can still opt into
|
|
126
|
+
* explicit slotting. The slot attribute is normalized onto the adopted
|
|
127
|
+
* element so downstream CSS selectors (`[slot="header"]`) match in both
|
|
128
|
+
* cases.
|
|
129
|
+
*/
|
|
130
|
+
#adoptSlot(slot, panel, mode = 'append') {
|
|
131
|
+
const fallbackTag = { header: 'header', body: 'section', footer: 'footer' }[slot];
|
|
132
|
+
const isMatch = (c) => c.getAttribute('slot') === slot
|
|
133
|
+
|| (fallbackTag && !c.getAttribute('slot') && c.localName === fallbackTag);
|
|
134
|
+
|
|
135
|
+
const inDirect = [...this.children].find(isMatch);
|
|
136
|
+
const inPanel = [...panel.children].find(c => c.getAttribute('slot') === slot);
|
|
137
|
+
|
|
138
|
+
if (inDirect && inPanel && inDirect !== inPanel) {
|
|
139
|
+
// User provided their own after we stamped a default — drop the stamp.
|
|
140
|
+
inPanel.remove();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const el = inDirect || inPanel || (() => {
|
|
144
|
+
const blueprint = this.constructor._pp?.[slot];
|
|
145
|
+
if (!blueprint) return null;
|
|
146
|
+
const clone = blueprint.cloneNode(true);
|
|
147
|
+
clone.setAttribute('data-stamped', '');
|
|
148
|
+
return clone;
|
|
149
|
+
})();
|
|
150
|
+
if (!el) return null;
|
|
151
|
+
|
|
152
|
+
if (el.getAttribute('slot') !== slot) el.setAttribute('slot', slot);
|
|
153
|
+
|
|
154
|
+
if (el.parentElement !== panel) {
|
|
155
|
+
if (mode === 'prepend') panel.prepend(el);
|
|
156
|
+
else panel.appendChild(el);
|
|
157
|
+
}
|
|
158
|
+
return el;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
render() {
|
|
162
|
+
const dialog = this.ensure('dialog');
|
|
163
|
+
|
|
164
|
+
if (this.text) {
|
|
165
|
+
dialog.setAttribute('aria-label', this.text);
|
|
166
|
+
this.setAttribute('aria-label', this.text);
|
|
167
|
+
} else {
|
|
168
|
+
dialog.removeAttribute('aria-label');
|
|
169
|
+
this.removeAttribute('aria-label');
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const panel = this.ensure('panel');
|
|
173
|
+
if (panel.parentElement !== dialog) dialog.appendChild(panel);
|
|
174
|
+
|
|
175
|
+
const header = this.#adoptSlot('header', panel, 'prepend');
|
|
176
|
+
|
|
177
|
+
// text="…" shorthand: stamp a [slot="heading"] into the header so the
|
|
178
|
+
// card-ui grid picks it up. Any author-supplied heading wins.
|
|
179
|
+
if (header) {
|
|
180
|
+
let stampedHeading = header.querySelector(':scope > [slot="heading"][data-stamped]');
|
|
181
|
+
const hasAuthorHeading = [...header.children].some(c =>
|
|
182
|
+
!c.hasAttribute('data-stamped') &&
|
|
183
|
+
(c.getAttribute('slot') === 'heading' || /^h[1-6]$/.test(c.localName))
|
|
184
|
+
);
|
|
185
|
+
if (this.text && !hasAuthorHeading) {
|
|
186
|
+
if (!stampedHeading) {
|
|
187
|
+
stampedHeading = document.createElement('span');
|
|
188
|
+
stampedHeading.setAttribute('slot', 'heading');
|
|
189
|
+
stampedHeading.setAttribute('data-stamped', '');
|
|
190
|
+
header.prepend(stampedHeading);
|
|
191
|
+
}
|
|
192
|
+
if (stampedHeading.textContent !== this.text) stampedHeading.textContent = this.text;
|
|
193
|
+
} else if (stampedHeading) {
|
|
194
|
+
stampedHeading.remove();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!this.permanent) {
|
|
199
|
+
const close = this.ensure('close');
|
|
200
|
+
if (header && close.parentElement !== header) header.appendChild(close);
|
|
201
|
+
} else {
|
|
202
|
+
this.drop('close');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Body — multiple sections allowed (card-ui parity). Accepts either
|
|
206
|
+
// bare <section> tags or explicit [slot="body"]. If the author provides
|
|
207
|
+
// none, stamp an empty default so title-only drawers still lay out.
|
|
208
|
+
const authorSections = [...this.children].filter(c =>
|
|
209
|
+
c.getAttribute('slot') === 'body'
|
|
210
|
+
|| (c.localName === 'section' && !c.getAttribute('slot'))
|
|
211
|
+
);
|
|
212
|
+
if (authorSections.length === 0) {
|
|
213
|
+
this.#adoptSlot('body', panel, 'append');
|
|
214
|
+
} else {
|
|
215
|
+
for (const s of authorSections) {
|
|
216
|
+
if (s.getAttribute('slot') !== 'body') s.setAttribute('slot', 'body');
|
|
217
|
+
if (s.parentElement !== panel) panel.appendChild(s);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Footer is opt-in — only mounted if the author supplied one (either
|
|
222
|
+
// [slot="footer"] or a bare <footer> tag, card-ui style).
|
|
223
|
+
const userFooter = [...this.children].find(c =>
|
|
224
|
+
c.getAttribute('slot') === 'footer' || (!c.getAttribute('slot') && c.localName === 'footer')
|
|
225
|
+
);
|
|
226
|
+
if (userFooter) {
|
|
227
|
+
if (userFooter.getAttribute('slot') !== 'footer') userFooter.setAttribute('slot', 'footer');
|
|
228
|
+
if (userFooter.parentElement !== panel) panel.appendChild(userFooter);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Sync open state
|
|
232
|
+
if (this.open && !dialog.open) {
|
|
233
|
+
this.#closing = false;
|
|
234
|
+
this.#previousFocus = document.activeElement;
|
|
235
|
+
dialog.showModal();
|
|
236
|
+
this.#openRaf = requestAnimationFrame(() => {
|
|
237
|
+
this.#openRaf = null;
|
|
238
|
+
dialog.setAttribute('data-open', '');
|
|
239
|
+
});
|
|
240
|
+
} else if (!this.open && dialog.open && !this.#closing) {
|
|
241
|
+
this.#animateClose(dialog);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
#animateClose(dialog) {
|
|
246
|
+
this.#closing = true;
|
|
247
|
+
dialog.removeAttribute('data-open');
|
|
248
|
+
dialog.setAttribute('data-closing', '');
|
|
249
|
+
|
|
250
|
+
this.#closeTimer = setTimeout(() => {
|
|
251
|
+
this.#closeTimer = null;
|
|
252
|
+
this.#closing = false;
|
|
253
|
+
dialog.removeAttribute('data-closing');
|
|
254
|
+
if (dialog.open) dialog.close();
|
|
255
|
+
}, this.#getDuration());
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
show() { this.open = true; }
|
|
259
|
+
hide() { this.open = false; }
|
|
260
|
+
}
|
|
261
|
+
customElements.define('drawer-ui', AdiaDrawer);
|
|
262
|
+
|
|
263
|
+
export { AdiaDrawer };
|