@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
package/core/anchor.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anchor positioning — positions a popover/panel relative to an anchor element.
|
|
3
|
+
*
|
|
4
|
+
* Uses native CSS Anchor Positioning when supported (Chrome 125+),
|
|
5
|
+
* falls back to JS (getBoundingClientRect + position: fixed) otherwise.
|
|
6
|
+
*
|
|
7
|
+
* Works with the Popover API: the popover renders in the top layer
|
|
8
|
+
* (via showPopover() on a popover="manual" or popover="auto" element),
|
|
9
|
+
* and we position it with either anchor() + position-area or manual coords.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* const cleanup = anchorPopover(trigger, panel, { placement: 'bottom-start', gap: 4 });
|
|
13
|
+
* cleanup(); // remove listeners / CSS
|
|
14
|
+
*
|
|
15
|
+
* Placements: bottom[-start|-end] | top[-start|-end] | left[-start|-end] | right[-start|-end]
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export const supportsAnchorCSS =
|
|
19
|
+
typeof CSS !== 'undefined'
|
|
20
|
+
? (CSS.supports?.('anchor-name: --x') ?? false) &&
|
|
21
|
+
(CSS.supports?.('position-area: bottom') ?? false)
|
|
22
|
+
: false;
|
|
23
|
+
|
|
24
|
+
let anchorIdCounter = 0;
|
|
25
|
+
|
|
26
|
+
export function anchorPopover(anchor, popover, options = {}) {
|
|
27
|
+
const { placement = 'bottom-start', gap = 4, matchWidth = false } = options;
|
|
28
|
+
|
|
29
|
+
// Prefer native CSS Anchor Positioning when the browser supports it.
|
|
30
|
+
if (supportsAnchorCSS) {
|
|
31
|
+
return anchorNative(anchor, popover, { placement, gap, matchWidth });
|
|
32
|
+
}
|
|
33
|
+
return anchorJS(anchor, popover, { placement, gap, matchWidth });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ── Native CSS Anchor Positioning ──
|
|
37
|
+
|
|
38
|
+
function anchorNative(anchor, popover, { placement, gap, matchWidth }) {
|
|
39
|
+
const name = `--a-anchor-${++anchorIdCounter}`;
|
|
40
|
+
const prevAnchorName = anchor.style.anchorName;
|
|
41
|
+
const prevStyles = {
|
|
42
|
+
position: popover.style.position,
|
|
43
|
+
positionAnchor: popover.style.positionAnchor,
|
|
44
|
+
positionArea: popover.style.positionArea,
|
|
45
|
+
positionTryFallbacks: popover.style.positionTryFallbacks,
|
|
46
|
+
margin: popover.style.margin,
|
|
47
|
+
width: popover.style.width,
|
|
48
|
+
top: popover.style.top,
|
|
49
|
+
left: popover.style.left,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
anchor.style.anchorName = name;
|
|
53
|
+
|
|
54
|
+
popover.style.position = 'fixed';
|
|
55
|
+
popover.style.positionAnchor = name;
|
|
56
|
+
popover.style.positionArea = placementToPositionArea(placement);
|
|
57
|
+
// Gap only on the main (anchor-adjacent) axis so start/end alignment stays tight.
|
|
58
|
+
popover.style.margin = placementToGapMargin(placement, gap);
|
|
59
|
+
// Let the browser flip across the opposite side + both perpendicular edges.
|
|
60
|
+
popover.style.positionTryFallbacks = 'flip-block, flip-inline, flip-block flip-inline';
|
|
61
|
+
|
|
62
|
+
if (matchWidth) {
|
|
63
|
+
popover.style.width = `anchor-size(${name} width)`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// top/left are controlled by position-area; make sure no stale values fight it.
|
|
67
|
+
popover.style.top = '';
|
|
68
|
+
popover.style.left = '';
|
|
69
|
+
|
|
70
|
+
return () => {
|
|
71
|
+
anchor.style.anchorName = prevAnchorName;
|
|
72
|
+
for (const [k, v] of Object.entries(prevStyles)) popover.style[k] = v;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Axis-specific margin so gap only separates on the main axis (TRBL).
|
|
77
|
+
function placementToGapMargin(placement, gap) {
|
|
78
|
+
if (placement.startsWith('bottom')) return `${gap}px 0 0 0`;
|
|
79
|
+
if (placement.startsWith('top')) return `0 0 ${gap}px 0`;
|
|
80
|
+
if (placement.startsWith('left')) return `0 ${gap}px 0 0`;
|
|
81
|
+
if (placement.startsWith('right')) return `0 0 0 ${gap}px`;
|
|
82
|
+
return `${gap}px`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Map our placement vocabulary to CSS position-area keywords.
|
|
86
|
+
function placementToPositionArea(placement) {
|
|
87
|
+
switch (placement) {
|
|
88
|
+
case 'bottom': return 'bottom span-all';
|
|
89
|
+
case 'bottom-start': return 'bottom span-right';
|
|
90
|
+
case 'bottom-end': return 'bottom span-left';
|
|
91
|
+
case 'top': return 'top span-all';
|
|
92
|
+
case 'top-start': return 'top span-right';
|
|
93
|
+
case 'top-end': return 'top span-left';
|
|
94
|
+
case 'left': return 'left span-all';
|
|
95
|
+
case 'left-start': return 'left span-bottom';
|
|
96
|
+
case 'left-end': return 'left span-top';
|
|
97
|
+
case 'right': return 'right span-all';
|
|
98
|
+
case 'right-start': return 'right span-bottom';
|
|
99
|
+
case 'right-end': return 'right span-top';
|
|
100
|
+
default: return 'bottom span-right';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ── JS fallback ──
|
|
105
|
+
|
|
106
|
+
function anchorJS(anchor, popover, { placement, gap, matchWidth }) {
|
|
107
|
+
function update() {
|
|
108
|
+
if (!anchor || !popover) return;
|
|
109
|
+
|
|
110
|
+
const a = anchor.getBoundingClientRect();
|
|
111
|
+
const p = popover.getBoundingClientRect();
|
|
112
|
+
const vw = window.innerWidth;
|
|
113
|
+
const vh = window.innerHeight;
|
|
114
|
+
|
|
115
|
+
let resolved = placement;
|
|
116
|
+
|
|
117
|
+
// Vertical flip
|
|
118
|
+
if (resolved.startsWith('bottom') && a.bottom + gap + p.height > vh && a.top - gap - p.height > 0) {
|
|
119
|
+
resolved = resolved.replace('bottom', 'top');
|
|
120
|
+
} else if (resolved.startsWith('top') && a.top - gap - p.height < 0 && a.bottom + gap + p.height < vh) {
|
|
121
|
+
resolved = resolved.replace('top', 'bottom');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let top, left;
|
|
125
|
+
|
|
126
|
+
if (resolved.startsWith('top')) {
|
|
127
|
+
top = a.top - p.height - gap;
|
|
128
|
+
} else if (resolved.startsWith('bottom')) {
|
|
129
|
+
top = a.bottom + gap;
|
|
130
|
+
} else if (resolved.startsWith('left')) {
|
|
131
|
+
left = a.left - p.width - gap;
|
|
132
|
+
if (resolved === 'left-start') top = a.top;
|
|
133
|
+
else if (resolved === 'left-end') top = a.bottom - p.height;
|
|
134
|
+
else top = a.top + (a.height - p.height) / 2;
|
|
135
|
+
} else if (resolved.startsWith('right')) {
|
|
136
|
+
left = a.right + gap;
|
|
137
|
+
if (resolved === 'right-start') top = a.top;
|
|
138
|
+
else if (resolved === 'right-end') top = a.bottom - p.height;
|
|
139
|
+
else top = a.top + (a.height - p.height) / 2;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (left === undefined) {
|
|
143
|
+
if (resolved.endsWith('-start')) left = a.left;
|
|
144
|
+
else if (resolved.endsWith('-end')) left = a.right - p.width;
|
|
145
|
+
else left = a.left + (a.width - p.width) / 2;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (left + p.width > vw - gap) left = a.right - p.width;
|
|
149
|
+
if (left < gap) left = a.left;
|
|
150
|
+
|
|
151
|
+
top = Math.max(gap, Math.min(top, vh - p.height - gap));
|
|
152
|
+
left = Math.max(gap, Math.min(left, vw - p.width - gap));
|
|
153
|
+
|
|
154
|
+
popover.style.position = 'fixed';
|
|
155
|
+
popover.style.top = `${top}px`;
|
|
156
|
+
popover.style.left = `${left}px`;
|
|
157
|
+
if (matchWidth) popover.style.width = `${a.width}px`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
popover.style.opacity = '0';
|
|
161
|
+
requestAnimationFrame(() => {
|
|
162
|
+
update();
|
|
163
|
+
popover.style.opacity = '';
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const scrollParents = getScrollParents(anchor);
|
|
167
|
+
for (const sp of scrollParents) sp.addEventListener('scroll', update, { passive: true });
|
|
168
|
+
window.addEventListener('resize', update, { passive: true });
|
|
169
|
+
|
|
170
|
+
return () => {
|
|
171
|
+
for (const sp of scrollParents) sp.removeEventListener('scroll', update);
|
|
172
|
+
window.removeEventListener('resize', update);
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getScrollParents(el) {
|
|
177
|
+
const parents = [document];
|
|
178
|
+
let node = el?.parentElement;
|
|
179
|
+
while (node) {
|
|
180
|
+
const style = getComputedStyle(node);
|
|
181
|
+
if (/auto|scroll/.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
182
|
+
parents.push(node);
|
|
183
|
+
}
|
|
184
|
+
node = node.parentElement;
|
|
185
|
+
}
|
|
186
|
+
return parents;
|
|
187
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdiaUI Controllers — Self-contained vanilla JS bundle.
|
|
3
|
+
* Includes: BaseController, RouteController.
|
|
4
|
+
*
|
|
5
|
+
* Zero dependencies. Drop into CodePen, StackBlitz, or any vanilla project.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ═══════════════════════════════════════════════════════════════
|
|
9
|
+
// BASE CONTROLLER
|
|
10
|
+
// ═══════════════════════════════════════════════════════════════
|
|
11
|
+
|
|
12
|
+
const validated = new WeakSet();
|
|
13
|
+
|
|
14
|
+
export class BaseController {
|
|
15
|
+
#host = null;
|
|
16
|
+
#subs = new Set();
|
|
17
|
+
|
|
18
|
+
get host() { return this.#host; }
|
|
19
|
+
|
|
20
|
+
connect(host) {
|
|
21
|
+
const ctor = this.constructor;
|
|
22
|
+
if (!validated.has(ctor) && ctor !== BaseController) {
|
|
23
|
+
validated.add(ctor);
|
|
24
|
+
if (!ctor.schema) {
|
|
25
|
+
console.warn(`AdiaUI: ${ctor.name} extends BaseController without static schema`);
|
|
26
|
+
}
|
|
27
|
+
if (this.getState === BaseController.prototype.getState) {
|
|
28
|
+
console.error(`AdiaUI: ${ctor.schema?.name ?? ctor.name} must implement getState()`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (this.#host && this.#host !== host) {
|
|
32
|
+
console.warn(`AdiaUI: ${ctor.schema?.name ?? ctor.name} already connected to a different host`);
|
|
33
|
+
}
|
|
34
|
+
this.#host = host;
|
|
35
|
+
this.onConnect(host);
|
|
36
|
+
this.reflect();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
disconnect(host) {
|
|
40
|
+
const h = host ?? this.#host;
|
|
41
|
+
if (!h) return;
|
|
42
|
+
this.onDisconnect(h);
|
|
43
|
+
this.#host = null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
subscribe(fn) {
|
|
47
|
+
this.#subs.add(fn);
|
|
48
|
+
return () => this.#subs.delete(fn);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
notify() {
|
|
52
|
+
this.reflect();
|
|
53
|
+
for (const fn of this.#subs) fn();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
onConnect(host) {}
|
|
57
|
+
onDisconnect(host) {}
|
|
58
|
+
reflect() {}
|
|
59
|
+
|
|
60
|
+
getState() {
|
|
61
|
+
throw new Error(`${this.constructor.schema?.name ?? this.constructor.name}: getState() not implemented`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ═══════════════════════════════════════════════════════════════
|
|
66
|
+
// ROUTE CONTROLLER
|
|
67
|
+
// ═══════════════════════════════════════════════════════════════
|
|
68
|
+
|
|
69
|
+
export class RouteController extends BaseController {
|
|
70
|
+
static schema = {
|
|
71
|
+
name: 'route',
|
|
72
|
+
state: { path: 'string', params: 'object', route: 'object', previous: 'string' },
|
|
73
|
+
commands: ['navigate', 'replace', 'back', 'forward', 'setRoutes'],
|
|
74
|
+
attributes: ['data-route-path'],
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
#routes = [];
|
|
78
|
+
#path = '';
|
|
79
|
+
#previous = '';
|
|
80
|
+
#params = {};
|
|
81
|
+
#route = null;
|
|
82
|
+
#historySync = true;
|
|
83
|
+
#boundPopState = null;
|
|
84
|
+
|
|
85
|
+
constructor({ routes = [], initial, historySync = true } = {}) {
|
|
86
|
+
super();
|
|
87
|
+
this.#routes = routes;
|
|
88
|
+
this.#historySync = historySync;
|
|
89
|
+
this.#path = initial ?? location.pathname;
|
|
90
|
+
this.#match();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getState() {
|
|
94
|
+
return {
|
|
95
|
+
path: this.#path,
|
|
96
|
+
params: { ...this.#params },
|
|
97
|
+
route: this.#route,
|
|
98
|
+
previous: this.#previous,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
reflect() {
|
|
103
|
+
const host = this.host;
|
|
104
|
+
if (!host) return;
|
|
105
|
+
host.setAttribute('data-route-path', this.#path);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
onConnect(host) {
|
|
109
|
+
if (this.#historySync) {
|
|
110
|
+
this.#boundPopState = () => {
|
|
111
|
+
this.#previous = this.#path;
|
|
112
|
+
this.#path = location.pathname;
|
|
113
|
+
this.#match();
|
|
114
|
+
this.notify();
|
|
115
|
+
};
|
|
116
|
+
window.addEventListener('popstate', this.#boundPopState);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
onDisconnect() {
|
|
121
|
+
if (this.#boundPopState) {
|
|
122
|
+
window.removeEventListener('popstate', this.#boundPopState);
|
|
123
|
+
this.#boundPopState = null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#match() {
|
|
128
|
+
this.#params = {};
|
|
129
|
+
this.#route = null;
|
|
130
|
+
for (const route of this.#routes) {
|
|
131
|
+
const match = this.#matchPath(route.path, this.#path);
|
|
132
|
+
if (match) {
|
|
133
|
+
this.#params = match.params;
|
|
134
|
+
this.#route = route;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
#matchPath(pattern, path) {
|
|
141
|
+
const patternParts = pattern.split('/').filter(Boolean);
|
|
142
|
+
const pathParts = path.split('/').filter(Boolean);
|
|
143
|
+
if (!pattern.includes(':')) {
|
|
144
|
+
return pattern === path ? { params: {} } : null;
|
|
145
|
+
}
|
|
146
|
+
if (patternParts.length !== pathParts.length) return null;
|
|
147
|
+
const params = {};
|
|
148
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
149
|
+
if (patternParts[i].startsWith(':')) {
|
|
150
|
+
params[patternParts[i].slice(1)] = pathParts[i];
|
|
151
|
+
} else if (patternParts[i] !== pathParts[i]) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return { params };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
commands = {
|
|
159
|
+
navigate: (path) => {
|
|
160
|
+
if (path === this.#path) return;
|
|
161
|
+
this.#previous = this.#path;
|
|
162
|
+
this.#path = path;
|
|
163
|
+
this.#match();
|
|
164
|
+
if (this.#historySync) history.pushState(null, '', path);
|
|
165
|
+
this.notify();
|
|
166
|
+
},
|
|
167
|
+
replace: (path) => {
|
|
168
|
+
this.#previous = this.#path;
|
|
169
|
+
this.#path = path;
|
|
170
|
+
this.#match();
|
|
171
|
+
if (this.#historySync) history.replaceState(null, '', path);
|
|
172
|
+
this.notify();
|
|
173
|
+
},
|
|
174
|
+
back: () => { if (this.#historySync) history.back(); },
|
|
175
|
+
forward: () => { if (this.#historySync) history.forward(); },
|
|
176
|
+
setRoutes: (routes) => {
|
|
177
|
+
this.#routes = routes;
|
|
178
|
+
this.#match();
|
|
179
|
+
this.notify();
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
package/core/element.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdiaUI Core — Light DOM web component base class.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports reactivity and rendering for backward compatibility:
|
|
5
|
+
* import { AdiaElement, signal, computed, effect, html, repeat } from './element.js';
|
|
6
|
+
*
|
|
7
|
+
* Or import each layer directly:
|
|
8
|
+
* import { signal, computed, effect } from './signals.js';
|
|
9
|
+
* import { html, css, repeat } from './template.js';
|
|
10
|
+
* import { AdiaElement } from './element.js';
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Re-export reactivity primitives
|
|
14
|
+
export { signal, computed, effect, batch, untracked, isSignal } from './signals.js';
|
|
15
|
+
|
|
16
|
+
// Re-export rendering
|
|
17
|
+
export { html, css, repeat } from './template.js';
|
|
18
|
+
|
|
19
|
+
// Internal imports for AdiaElement
|
|
20
|
+
import { signal, computed, effect } from './signals.js';
|
|
21
|
+
import { stamp, disposeParts, KEY_MAP } from './template.js';
|
|
22
|
+
|
|
23
|
+
// ═══════════════════════════════════════════════════════════════
|
|
24
|
+
// ADIA ELEMENT — Light DOM web component base class
|
|
25
|
+
// ═══════════════════════════════════════════════════════════════
|
|
26
|
+
|
|
27
|
+
const SIG = Symbol();
|
|
28
|
+
const CH = Symbol();
|
|
29
|
+
|
|
30
|
+
function installProps(el, props) {
|
|
31
|
+
el[CH] = new Map();
|
|
32
|
+
el[SIG] = new Map();
|
|
33
|
+
for (const [key, cfg] of Object.entries(props)) {
|
|
34
|
+
const attr = cfg.attribute ?? key.toLowerCase();
|
|
35
|
+
const type = cfg.type ?? String;
|
|
36
|
+
const sig = signal(cfg.default ?? undefined);
|
|
37
|
+
el[SIG].set(key, sig);
|
|
38
|
+
Object.defineProperty(el, key, {
|
|
39
|
+
get() { return sig.value; },
|
|
40
|
+
set(v) {
|
|
41
|
+
const old = sig.peek();
|
|
42
|
+
if (Object.is(old, v)) return;
|
|
43
|
+
el[CH].set(key, old);
|
|
44
|
+
sig.value = v;
|
|
45
|
+
if (cfg.reflect) reflect(el, attr, v, type);
|
|
46
|
+
},
|
|
47
|
+
configurable: true,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function reflect(el, a, v, t) {
|
|
53
|
+
t === Boolean
|
|
54
|
+
? v ? el.setAttribute(a, '') : el.removeAttribute(a)
|
|
55
|
+
: v == null ? el.removeAttribute(a) : el.setAttribute(a, String(v));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const parseAttr = (v, t) =>
|
|
59
|
+
t === Boolean ? v !== null : t === Number ? (v === null ? null : +v) : v;
|
|
60
|
+
|
|
61
|
+
function adoptStyles(ctor) {
|
|
62
|
+
if (Object.hasOwn(ctor, '_sa')) return;
|
|
63
|
+
ctor._sa = true;
|
|
64
|
+
const sheets = ctor.styles;
|
|
65
|
+
if (!sheets) return;
|
|
66
|
+
const list = Array.isArray(sheets) ? sheets : [sheets];
|
|
67
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, ...list.filter(s => !document.adoptedStyleSheets.includes(s))];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function prepareParts(ctor) {
|
|
71
|
+
if (Object.hasOwn(ctor, '_pp')) return;
|
|
72
|
+
ctor._pp = {};
|
|
73
|
+
const parts = ctor.parts;
|
|
74
|
+
if (!parts) return;
|
|
75
|
+
for (const [slot, markup] of Object.entries(parts)) {
|
|
76
|
+
const tpl = document.createElement('template');
|
|
77
|
+
tpl.innerHTML = markup;
|
|
78
|
+
ctor._pp[slot] = tpl.content.firstElementChild;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export class AdiaElement extends HTMLElement {
|
|
83
|
+
static get properties() { return {}; }
|
|
84
|
+
static get traits() { return []; }
|
|
85
|
+
static get observedAttributes() {
|
|
86
|
+
return Object.entries(this.properties).map(([k, c]) => c.attribute ?? k.toLowerCase());
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#fx = [];
|
|
90
|
+
#tc = [];
|
|
91
|
+
#as = [];
|
|
92
|
+
#ctrl = null;
|
|
93
|
+
#cu = null;
|
|
94
|
+
#tf = null;
|
|
95
|
+
#notify = signal(0);
|
|
96
|
+
|
|
97
|
+
constructor() {
|
|
98
|
+
super();
|
|
99
|
+
this.internals = this.attachInternals();
|
|
100
|
+
installProps(this, this.constructor.properties);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
connectedCallback() {
|
|
104
|
+
const ctor = this.constructor;
|
|
105
|
+
if (!ctor._tag) ctor._tag = this.localName;
|
|
106
|
+
adoptStyles(ctor);
|
|
107
|
+
prepareParts(ctor);
|
|
108
|
+
this.connected();
|
|
109
|
+
this.#fx.push(effect(() => {
|
|
110
|
+
for (const sig of this[SIG].values()) sig.value;
|
|
111
|
+
this.#notify.value;
|
|
112
|
+
const result = ctor.template(this);
|
|
113
|
+
if (result) stamp(result, this);
|
|
114
|
+
this.render();
|
|
115
|
+
if (this[CH].size) {
|
|
116
|
+
const changed = new Map(this[CH]);
|
|
117
|
+
this[CH].clear();
|
|
118
|
+
this.updated(changed);
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
host: this.localName,
|
|
122
|
+
onError: this.onError ? (e) => this.onError(e) : null,
|
|
123
|
+
}));
|
|
124
|
+
if (!this.#tf) this.#tf = new Set();
|
|
125
|
+
for (const t of ctor.traits) this.#applyTrait(t);
|
|
126
|
+
if (this.#ctrl) this.#connectCtrl();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
disconnectedCallback() {
|
|
130
|
+
if (this._i) disposeParts(this._i.p);
|
|
131
|
+
for (const d of this.#fx) d();
|
|
132
|
+
this.#fx.length = 0;
|
|
133
|
+
for (const s of this.#as) s.value = undefined;
|
|
134
|
+
this.#as.length = 0;
|
|
135
|
+
for (const t of this.#tc) t.disconnect(this);
|
|
136
|
+
this.#tc.length = 0;
|
|
137
|
+
this.#tf?.clear();
|
|
138
|
+
this.#cu?.();
|
|
139
|
+
this.#cu = null;
|
|
140
|
+
this.#ctrl?.disconnect?.(this);
|
|
141
|
+
this.disconnected();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
#connectCtrl() {
|
|
145
|
+
const c = this.#ctrl;
|
|
146
|
+
c.connect?.(this);
|
|
147
|
+
this.#cu = c.subscribe?.(() => { this.#notify.value++; });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
get controller() { return this.#ctrl; }
|
|
151
|
+
set controller(c) {
|
|
152
|
+
this.#cu?.();
|
|
153
|
+
this.#cu = null;
|
|
154
|
+
this.#ctrl?.disconnect?.(this);
|
|
155
|
+
this.#ctrl = c;
|
|
156
|
+
if (c && this.isConnected) this.#connectCtrl();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
#applyTrait(trait) {
|
|
160
|
+
this.#tf.add(trait);
|
|
161
|
+
const instance = trait();
|
|
162
|
+
instance.connect(this, { host: this, signal, computed, effect });
|
|
163
|
+
this.#tc.push(instance);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
addTrait(trait) {
|
|
167
|
+
if (!this.#tf) this.#tf = new Set();
|
|
168
|
+
if (this.#tf.has(trait)) return this;
|
|
169
|
+
this.#applyTrait(trait);
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
attributeChangedCallback(name, _, val) {
|
|
174
|
+
for (const [key, cfg] of Object.entries(this.constructor.properties)) {
|
|
175
|
+
if ((cfg.attribute ?? key.toLowerCase()) === name) {
|
|
176
|
+
this[key] = parseAttr(val, cfg.type ?? String);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
static template = () => null;
|
|
183
|
+
|
|
184
|
+
static create(props = {}) {
|
|
185
|
+
const tag = this._tag ?? customElements.getName?.(this);
|
|
186
|
+
if (!tag) throw new Error('Component not registered');
|
|
187
|
+
const el = document.createElement(tag);
|
|
188
|
+
for (const [k, v] of Object.entries(props)) el[k] = v;
|
|
189
|
+
return el;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
signal(v) { const s = signal(v); this.#as.push(s); return s; }
|
|
193
|
+
|
|
194
|
+
ensure(slot) {
|
|
195
|
+
for (const ch of this.children) {
|
|
196
|
+
if (ch.getAttribute('slot') === slot) return ch;
|
|
197
|
+
}
|
|
198
|
+
const deep = this.#findOwnSlot(slot);
|
|
199
|
+
if (deep) return deep;
|
|
200
|
+
prepareParts(this.constructor);
|
|
201
|
+
const blueprint = this.constructor._pp?.[slot];
|
|
202
|
+
if (!blueprint) return null;
|
|
203
|
+
const el = blueprint.cloneNode(true);
|
|
204
|
+
this.appendChild(el);
|
|
205
|
+
return el;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
drop(slot) {
|
|
209
|
+
for (const ch of this.children) {
|
|
210
|
+
if (ch.getAttribute('slot') === slot) { ch.remove(); return; }
|
|
211
|
+
}
|
|
212
|
+
const deep = this.#findOwnSlot(slot);
|
|
213
|
+
if (deep) deep.remove();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#findOwnSlot(slot) {
|
|
217
|
+
for (const found of this.querySelectorAll(`[slot="${slot}"]`)) {
|
|
218
|
+
let el = found.parentElement, owned = true;
|
|
219
|
+
while (el && el !== this) {
|
|
220
|
+
if (el.localName.includes('-')) { owned = false; break; }
|
|
221
|
+
el = el.parentElement;
|
|
222
|
+
}
|
|
223
|
+
if (owned && el === this) return found;
|
|
224
|
+
}
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
reconcile(parent, items, keyFn, stampFn) {
|
|
229
|
+
const map = parent[KEY_MAP] || new Map();
|
|
230
|
+
const newMap = new Map();
|
|
231
|
+
const order = [];
|
|
232
|
+
for (let i = 0; i < items.length; i++) {
|
|
233
|
+
const item = items[i];
|
|
234
|
+
const key = keyFn(item, i);
|
|
235
|
+
if (newMap.has(key)) continue;
|
|
236
|
+
let el = map.get(key);
|
|
237
|
+
if (el) { stampFn(item, i, el); }
|
|
238
|
+
else { el = stampFn(item, i, null); }
|
|
239
|
+
newMap.set(key, el);
|
|
240
|
+
order.push(key);
|
|
241
|
+
}
|
|
242
|
+
for (const [key, el] of map) { if (!newMap.has(key)) el.remove(); }
|
|
243
|
+
let ref = null;
|
|
244
|
+
for (let i = order.length - 1; i >= 0; i--) {
|
|
245
|
+
const el = newMap.get(order[i]);
|
|
246
|
+
if (el.nextSibling !== ref || el.parentNode !== parent)
|
|
247
|
+
parent.insertBefore(el, ref);
|
|
248
|
+
ref = el;
|
|
249
|
+
}
|
|
250
|
+
parent[KEY_MAP] = newMap;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
connected() {}
|
|
254
|
+
render() {}
|
|
255
|
+
disconnected() {}
|
|
256
|
+
updated(_changed) {}
|
|
257
|
+
}
|