@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,24 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const activeState = defineTrait({
|
|
4
|
+
name: 'active-state',
|
|
5
|
+
attributes: ['data-active-state-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
function onClick() {
|
|
10
|
+
if (host.hasAttribute('data-active-state-active')) {
|
|
11
|
+
host.removeAttribute('data-active-state-active');
|
|
12
|
+
} else {
|
|
13
|
+
host.setAttribute('data-active-state-active', '');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
host.addEventListener('click', onClick);
|
|
18
|
+
|
|
19
|
+
return () => {
|
|
20
|
+
host.removeEventListener('click', onClick);
|
|
21
|
+
host.removeAttribute('data-active-state-active');
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const anchorPositioning = defineTrait({
|
|
4
|
+
name: 'anchor-positioning',
|
|
5
|
+
attributes: ['data-anchor-positioning-placed', 'data-anchor-placement-actual'],
|
|
6
|
+
events: ['anchor-placed'],
|
|
7
|
+
config: ['data-anchor', 'data-anchor-placement', 'data-anchor-gap'],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const anchorSel = host.getAttribute('data-anchor');
|
|
10
|
+
const placement = host.getAttribute('data-anchor-placement') || 'bottom';
|
|
11
|
+
const gap = parseInt(host.getAttribute('data-anchor-gap'), 10) || 0;
|
|
12
|
+
|
|
13
|
+
function position() {
|
|
14
|
+
const anchor = document.querySelector(anchorSel) ||
|
|
15
|
+
document.getElementById(anchorSel);
|
|
16
|
+
if (!anchor) return;
|
|
17
|
+
|
|
18
|
+
const ar = anchor.getBoundingClientRect();
|
|
19
|
+
const hr = host.getBoundingClientRect();
|
|
20
|
+
const vw = window.innerWidth;
|
|
21
|
+
const vh = window.innerHeight;
|
|
22
|
+
|
|
23
|
+
let top, left;
|
|
24
|
+
let actual = placement;
|
|
25
|
+
|
|
26
|
+
if (placement.startsWith('bottom')) {
|
|
27
|
+
top = ar.bottom + gap;
|
|
28
|
+
left = ar.left + (ar.width - hr.width) / 2;
|
|
29
|
+
if (top + hr.height > vh) { top = ar.top - hr.height - gap; actual = 'top'; }
|
|
30
|
+
} else if (placement.startsWith('top')) {
|
|
31
|
+
top = ar.top - hr.height - gap;
|
|
32
|
+
left = ar.left + (ar.width - hr.width) / 2;
|
|
33
|
+
if (top < 0) { top = ar.bottom + gap; actual = 'bottom'; }
|
|
34
|
+
} else if (placement.startsWith('left')) {
|
|
35
|
+
top = ar.top + (ar.height - hr.height) / 2;
|
|
36
|
+
left = ar.left - hr.width - gap;
|
|
37
|
+
if (left < 0) { left = ar.right + gap; actual = 'right'; }
|
|
38
|
+
} else {
|
|
39
|
+
top = ar.top + (ar.height - hr.height) / 2;
|
|
40
|
+
left = ar.right + gap;
|
|
41
|
+
if (left + hr.width > vw) { left = ar.left - hr.width - gap; actual = 'left'; }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
left = Math.max(0, Math.min(left, vw - hr.width));
|
|
45
|
+
top = Math.max(0, Math.min(top, vh - hr.height));
|
|
46
|
+
|
|
47
|
+
host.style.position = 'fixed';
|
|
48
|
+
host.style.top = `${top}px`;
|
|
49
|
+
host.style.left = `${left}px`;
|
|
50
|
+
host.setAttribute('data-anchor-positioning-placed', '');
|
|
51
|
+
host.setAttribute('data-anchor-placement-actual', actual);
|
|
52
|
+
host.dispatchEvent(new CustomEvent('anchor-placed', { bubbles: true, detail: { actual } }));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
position();
|
|
56
|
+
window.addEventListener('scroll', position, true);
|
|
57
|
+
window.addEventListener('resize', position);
|
|
58
|
+
|
|
59
|
+
return () => {
|
|
60
|
+
window.removeEventListener('scroll', position, true);
|
|
61
|
+
window.removeEventListener('resize', position);
|
|
62
|
+
host.removeAttribute('data-anchor-positioning-placed');
|
|
63
|
+
host.removeAttribute('data-anchor-placement-actual');
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const attentionPulse = defineTrait({
|
|
4
|
+
name: 'attention-pulse',
|
|
5
|
+
attributes: ['data-attention-pulse-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: ['data-pulse-interval'],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const interval = parseInt(host.getAttribute('data-pulse-interval'), 10) || 2000;
|
|
10
|
+
const keyframeName = `adia-pulse-${Math.random().toString(36).slice(2, 8)}`;
|
|
11
|
+
|
|
12
|
+
const style = document.createElement('style');
|
|
13
|
+
style.textContent = `
|
|
14
|
+
@keyframes ${keyframeName} {
|
|
15
|
+
0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); }
|
|
16
|
+
50% { box-shadow: 0 0 12px 4px rgba(59, 130, 246, 0.3); }
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
document.head.appendChild(style);
|
|
20
|
+
|
|
21
|
+
host.style.animation = `${keyframeName} ${interval}ms ease-in-out infinite`;
|
|
22
|
+
host.setAttribute('data-attention-pulse-active', '');
|
|
23
|
+
|
|
24
|
+
return () => {
|
|
25
|
+
host.style.animation = '';
|
|
26
|
+
style.remove();
|
|
27
|
+
host.removeAttribute('data-attention-pulse-active');
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const confettiBurst = defineTrait({
|
|
4
|
+
name: 'confetti-burst',
|
|
5
|
+
attributes: ['data-confetti-burst-active'],
|
|
6
|
+
events: ['confetti-burst-done'],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const canvas = document.createElement('canvas');
|
|
10
|
+
canvas.style.cssText = 'position:absolute;inset:0;pointer-events:none;z-index:9999;';
|
|
11
|
+
host.style.position = host.style.position || 'relative';
|
|
12
|
+
host.appendChild(canvas);
|
|
13
|
+
|
|
14
|
+
const ctx = canvas.getContext('2d');
|
|
15
|
+
let rafId = null;
|
|
16
|
+
|
|
17
|
+
const colors = ['#f44', '#4a4', '#44f', '#ff4', '#f4f', '#4ff'];
|
|
18
|
+
const particles = Array.from({ length: 80 }, () => ({
|
|
19
|
+
x: 0.5,
|
|
20
|
+
y: 0.5,
|
|
21
|
+
vx: (Math.random() - 0.5) * 8,
|
|
22
|
+
vy: (Math.random() - 0.5) * 8 - 2,
|
|
23
|
+
size: Math.random() * 4 + 2,
|
|
24
|
+
color: colors[Math.floor(Math.random() * colors.length)],
|
|
25
|
+
life: 1,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
host.setAttribute('data-confetti-burst-active', '');
|
|
29
|
+
const startTime = performance.now();
|
|
30
|
+
|
|
31
|
+
function tick(now) {
|
|
32
|
+
const elapsed = now - startTime;
|
|
33
|
+
if (elapsed > 2000) {
|
|
34
|
+
canvas.remove();
|
|
35
|
+
host.removeAttribute('data-confetti-burst-active');
|
|
36
|
+
host.dispatchEvent(new CustomEvent('confetti-burst-done', { bubbles: true }));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
canvas.width = host.offsetWidth;
|
|
41
|
+
canvas.height = host.offsetHeight;
|
|
42
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
43
|
+
|
|
44
|
+
for (const p of particles) {
|
|
45
|
+
p.x += p.vx * 0.004;
|
|
46
|
+
p.y += p.vy * 0.004;
|
|
47
|
+
p.vy += 0.15;
|
|
48
|
+
p.life = Math.max(0, 1 - elapsed / 2000);
|
|
49
|
+
ctx.globalAlpha = p.life;
|
|
50
|
+
ctx.fillStyle = p.color;
|
|
51
|
+
ctx.fillRect(p.x * canvas.width, p.y * canvas.height, p.size, p.size);
|
|
52
|
+
}
|
|
53
|
+
ctx.globalAlpha = 1;
|
|
54
|
+
rafId = requestAnimationFrame(tick);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
rafId = requestAnimationFrame(tick);
|
|
58
|
+
|
|
59
|
+
return () => {
|
|
60
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
61
|
+
canvas.remove();
|
|
62
|
+
host.removeAttribute('data-confetti-burst-active');
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const confetti = defineTrait({
|
|
4
|
+
name: 'confetti',
|
|
5
|
+
attributes: ['data-confetti-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const canvas = document.createElement('canvas');
|
|
10
|
+
canvas.style.cssText = 'position:absolute;inset:0;pointer-events:none;z-index:9999;';
|
|
11
|
+
host.style.position = host.style.position || 'relative';
|
|
12
|
+
host.appendChild(canvas);
|
|
13
|
+
|
|
14
|
+
const ctx = canvas.getContext('2d');
|
|
15
|
+
let rafId = null;
|
|
16
|
+
let running = true;
|
|
17
|
+
|
|
18
|
+
const colors = ['#f44', '#4a4', '#44f', '#ff4', '#f4f', '#4ff'];
|
|
19
|
+
const particles = Array.from({ length: 60 }, () => ({
|
|
20
|
+
x: Math.random(),
|
|
21
|
+
y: Math.random() * -1,
|
|
22
|
+
vx: (Math.random() - 0.5) * 2,
|
|
23
|
+
vy: Math.random() * 2 + 1,
|
|
24
|
+
size: Math.random() * 4 + 2,
|
|
25
|
+
color: colors[Math.floor(Math.random() * colors.length)],
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
function resize() {
|
|
29
|
+
canvas.width = host.offsetWidth;
|
|
30
|
+
canvas.height = host.offsetHeight;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function tick() {
|
|
34
|
+
if (!running) return;
|
|
35
|
+
resize();
|
|
36
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
37
|
+
for (const p of particles) {
|
|
38
|
+
p.x += p.vx * 0.002;
|
|
39
|
+
p.y += p.vy * 0.003;
|
|
40
|
+
if (p.y > 1.1) { p.y = -0.1; p.x = Math.random(); }
|
|
41
|
+
ctx.fillStyle = p.color;
|
|
42
|
+
ctx.fillRect(p.x * canvas.width, p.y * canvas.height, p.size, p.size);
|
|
43
|
+
}
|
|
44
|
+
rafId = requestAnimationFrame(tick);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
host.setAttribute('data-confetti-active', '');
|
|
48
|
+
tick();
|
|
49
|
+
|
|
50
|
+
return () => {
|
|
51
|
+
running = false;
|
|
52
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
53
|
+
canvas.remove();
|
|
54
|
+
host.removeAttribute('data-confetti-active');
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const countUp = defineTrait({
|
|
4
|
+
name: 'count-up',
|
|
5
|
+
attributes: ['data-count-up-active'],
|
|
6
|
+
events: ['count-up-done'],
|
|
7
|
+
config: ['data-count-up-target', 'data-count-duration'],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const target = parseFloat(host.getAttribute('data-count-up-target')) || 0;
|
|
10
|
+
const duration = parseInt(host.getAttribute('data-count-duration'), 10) || 1000;
|
|
11
|
+
let rafId = null;
|
|
12
|
+
|
|
13
|
+
function easeOutQuart(t) {
|
|
14
|
+
return 1 - Math.pow(1 - t, 4);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const start = performance.now();
|
|
18
|
+
host.setAttribute('data-count-up-active', '');
|
|
19
|
+
|
|
20
|
+
function tick(now) {
|
|
21
|
+
const elapsed = now - start;
|
|
22
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
23
|
+
const value = target * easeOutQuart(progress);
|
|
24
|
+
host.textContent = Math.round(value);
|
|
25
|
+
|
|
26
|
+
if (progress < 1) {
|
|
27
|
+
rafId = requestAnimationFrame(tick);
|
|
28
|
+
} else {
|
|
29
|
+
host.textContent = target;
|
|
30
|
+
host.removeAttribute('data-count-up-active');
|
|
31
|
+
host.dispatchEvent(new CustomEvent('count-up-done', { bubbles: true }));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
rafId = requestAnimationFrame(tick);
|
|
36
|
+
|
|
37
|
+
return () => {
|
|
38
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
39
|
+
host.removeAttribute('data-count-up-active');
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
});
|
package/traits/define.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* defineTrait() — Factory for creating composable behavior traits.
|
|
3
|
+
*
|
|
4
|
+
* A trait is a reusable behavior package: event listeners, attribute management,
|
|
5
|
+
* and cleanup — defined once, attached to any element.
|
|
6
|
+
*
|
|
7
|
+
* import { defineTrait } from '@traits/define.js';
|
|
8
|
+
*
|
|
9
|
+
* export const pressable = defineTrait({
|
|
10
|
+
* name: 'pressable',
|
|
11
|
+
* attributes: ['data-pressable-pressed'],
|
|
12
|
+
* events: ['press'],
|
|
13
|
+
* config: [],
|
|
14
|
+
* setup({ host }) {
|
|
15
|
+
* // attach behavior, return cleanup function
|
|
16
|
+
* },
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* // On any DOM element:
|
|
21
|
+
* const inst = pressable();
|
|
22
|
+
* inst.connect(myElement);
|
|
23
|
+
* inst.disconnect(myElement);
|
|
24
|
+
*
|
|
25
|
+
* // On a AdiaElement:
|
|
26
|
+
* class MyButton extends AdiaElement {
|
|
27
|
+
* static traits = [pressable];
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const registry = new Map();
|
|
32
|
+
|
|
33
|
+
export function defineTrait(spec) {
|
|
34
|
+
if (!spec.name) throw new Error('Trait requires a name');
|
|
35
|
+
if (!spec.setup) throw new Error(`Trait "${spec.name}" requires a setup function`);
|
|
36
|
+
|
|
37
|
+
const schema = Object.freeze({
|
|
38
|
+
name: spec.name,
|
|
39
|
+
attributes: Object.freeze(spec.attributes || []),
|
|
40
|
+
events: Object.freeze(spec.events || []),
|
|
41
|
+
config: Object.freeze(spec.config || []),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function factory() {
|
|
45
|
+
let cleanup = null;
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
schema,
|
|
49
|
+
connect(host, ctx) {
|
|
50
|
+
cleanup = spec.setup({ host, ...(ctx || {}) });
|
|
51
|
+
},
|
|
52
|
+
disconnect(host) {
|
|
53
|
+
if (cleanup) { cleanup(); cleanup = null; }
|
|
54
|
+
// Validate: warn if managed attributes are still present
|
|
55
|
+
for (const attr of schema.attributes) {
|
|
56
|
+
if (host.hasAttribute(attr)) {
|
|
57
|
+
console.warn(`Trait "${schema.name}": attribute "${attr}" still present after disconnect`);
|
|
58
|
+
host.removeAttribute(attr);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
factory.schema = schema;
|
|
66
|
+
registry.set(spec.name, schema);
|
|
67
|
+
return factory;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function getTraitSchema(name) {
|
|
71
|
+
return registry.get(name) || null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function listTraits() {
|
|
75
|
+
return [...registry.keys()];
|
|
76
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const dirtyState = defineTrait({
|
|
4
|
+
name: 'dirty-state',
|
|
5
|
+
attributes: ['data-dirty-state-dirty', 'data-dirty-state-pristine'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const initialValue = host.value ?? host.getAttribute('value') ?? '';
|
|
10
|
+
|
|
11
|
+
function check() {
|
|
12
|
+
const currentValue = host.value ?? host.getAttribute('value') ?? '';
|
|
13
|
+
if (currentValue !== initialValue) {
|
|
14
|
+
host.setAttribute('data-dirty-state-dirty', '');
|
|
15
|
+
host.removeAttribute('data-dirty-state-pristine');
|
|
16
|
+
} else {
|
|
17
|
+
host.setAttribute('data-dirty-state-pristine', '');
|
|
18
|
+
host.removeAttribute('data-dirty-state-dirty');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Set initial state
|
|
23
|
+
host.setAttribute('data-dirty-state-pristine', '');
|
|
24
|
+
|
|
25
|
+
function onInput() { check(); }
|
|
26
|
+
function onChange() { check(); }
|
|
27
|
+
|
|
28
|
+
host.addEventListener('input', onInput);
|
|
29
|
+
host.addEventListener('change', onChange);
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
host.removeEventListener('input', onInput);
|
|
33
|
+
host.removeEventListener('change', onChange);
|
|
34
|
+
host.removeAttribute('data-dirty-state-dirty');
|
|
35
|
+
host.removeAttribute('data-dirty-state-pristine');
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const dragGhost = defineTrait({
|
|
4
|
+
name: 'drag-ghost',
|
|
5
|
+
attributes: ['data-drag-ghost-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
let ghost = null;
|
|
10
|
+
|
|
11
|
+
function onDragStart(e) {
|
|
12
|
+
ghost = host.cloneNode(true);
|
|
13
|
+
ghost.style.cssText = `
|
|
14
|
+
position: fixed; top: -9999px; left: -9999px;
|
|
15
|
+
pointer-events: none; opacity: 0.8; z-index: 99999;
|
|
16
|
+
`;
|
|
17
|
+
document.body.appendChild(ghost);
|
|
18
|
+
e.dataTransfer?.setDragImage(ghost, 0, 0);
|
|
19
|
+
host.setAttribute('data-drag-ghost-active', '');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function onDragEnd() {
|
|
23
|
+
if (ghost) { ghost.remove(); ghost = null; }
|
|
24
|
+
host.removeAttribute('data-drag-ghost-active');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
host.setAttribute('draggable', 'true');
|
|
28
|
+
host.addEventListener('dragstart', onDragStart);
|
|
29
|
+
host.addEventListener('dragend', onDragEnd);
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
host.removeEventListener('dragstart', onDragStart);
|
|
33
|
+
host.removeEventListener('dragend', onDragEnd);
|
|
34
|
+
if (ghost) { ghost.remove(); ghost = null; }
|
|
35
|
+
host.removeAttribute('data-drag-ghost-active');
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const draggable = defineTrait({
|
|
4
|
+
name: 'draggable',
|
|
5
|
+
attributes: ['data-draggable-dragging'],
|
|
6
|
+
events: ['drag-end'],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
let dragging = false;
|
|
10
|
+
let startX = 0;
|
|
11
|
+
let startY = 0;
|
|
12
|
+
let originX = 0;
|
|
13
|
+
let originY = 0;
|
|
14
|
+
|
|
15
|
+
function isDisabled() {
|
|
16
|
+
return host.hasAttribute('disabled');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function onPointerDown(e) {
|
|
20
|
+
if (isDisabled()) return;
|
|
21
|
+
dragging = true;
|
|
22
|
+
startX = e.clientX;
|
|
23
|
+
startY = e.clientY;
|
|
24
|
+
|
|
25
|
+
// Parse current translate values
|
|
26
|
+
const style = getComputedStyle(host);
|
|
27
|
+
const matrix = new DOMMatrixReadOnly(style.transform);
|
|
28
|
+
originX = matrix.m41;
|
|
29
|
+
originY = matrix.m42;
|
|
30
|
+
|
|
31
|
+
host.setPointerCapture(e.pointerId);
|
|
32
|
+
host.setAttribute('data-draggable-dragging', '');
|
|
33
|
+
host.style.touchAction = 'none';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onPointerMove(e) {
|
|
37
|
+
if (!dragging) return;
|
|
38
|
+
const dx = e.clientX - startX;
|
|
39
|
+
const dy = e.clientY - startY;
|
|
40
|
+
const x = originX + dx;
|
|
41
|
+
const y = originY + dy;
|
|
42
|
+
host.style.translate = `${x}px ${y}px`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function onPointerUp(e) {
|
|
46
|
+
if (!dragging) return;
|
|
47
|
+
dragging = false;
|
|
48
|
+
host.removeAttribute('data-draggable-dragging');
|
|
49
|
+
|
|
50
|
+
const dx = e.clientX - startX;
|
|
51
|
+
const dy = e.clientY - startY;
|
|
52
|
+
const x = originX + dx;
|
|
53
|
+
const y = originY + dy;
|
|
54
|
+
|
|
55
|
+
host.dispatchEvent(new CustomEvent('drag-end', {
|
|
56
|
+
bubbles: true,
|
|
57
|
+
detail: { x, y },
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
host.addEventListener('pointerdown', onPointerDown);
|
|
62
|
+
host.addEventListener('pointermove', onPointerMove);
|
|
63
|
+
host.addEventListener('pointerup', onPointerUp);
|
|
64
|
+
|
|
65
|
+
return () => {
|
|
66
|
+
host.removeEventListener('pointerdown', onPointerDown);
|
|
67
|
+
host.removeEventListener('pointermove', onPointerMove);
|
|
68
|
+
host.removeEventListener('pointerup', onPointerUp);
|
|
69
|
+
host.removeAttribute('data-draggable-dragging');
|
|
70
|
+
host.style.touchAction = '';
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const fadePresence = defineTrait({
|
|
4
|
+
name: 'fade-presence',
|
|
5
|
+
attributes: ['data-fade-presence-entering', 'data-fade-presence-exiting'],
|
|
6
|
+
events: ['fade-in-done', 'fade-out-done'],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
host.style.opacity = '0';
|
|
10
|
+
host.style.transition = 'opacity 200ms';
|
|
11
|
+
|
|
12
|
+
function onTransitionEnd() {
|
|
13
|
+
if (host.hasAttribute('data-fade-presence-entering')) {
|
|
14
|
+
host.removeAttribute('data-fade-presence-entering');
|
|
15
|
+
host.dispatchEvent(new CustomEvent('fade-in-done', { bubbles: true }));
|
|
16
|
+
} else if (host.hasAttribute('data-fade-presence-exiting')) {
|
|
17
|
+
host.removeAttribute('data-fade-presence-exiting');
|
|
18
|
+
host.dispatchEvent(new CustomEvent('fade-out-done', { bubbles: true }));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const observer = new MutationObserver(() => {
|
|
23
|
+
const visible = host.hasAttribute('data-fade-presence-visible');
|
|
24
|
+
if (visible) {
|
|
25
|
+
host.setAttribute('data-fade-presence-entering', '');
|
|
26
|
+
host.removeAttribute('data-fade-presence-exiting');
|
|
27
|
+
host.style.opacity = '1';
|
|
28
|
+
} else {
|
|
29
|
+
host.setAttribute('data-fade-presence-exiting', '');
|
|
30
|
+
host.removeAttribute('data-fade-presence-entering');
|
|
31
|
+
host.style.opacity = '0';
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
observer.observe(host, { attributes: true, attributeFilter: ['data-fade-presence-visible'] });
|
|
36
|
+
host.addEventListener('transitionend', onTransitionEnd);
|
|
37
|
+
|
|
38
|
+
// Apply initial state
|
|
39
|
+
if (host.hasAttribute('data-fade-presence-visible')) {
|
|
40
|
+
host.style.opacity = '1';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return () => {
|
|
44
|
+
observer.disconnect();
|
|
45
|
+
host.removeEventListener('transitionend', onTransitionEnd);
|
|
46
|
+
host.style.opacity = '';
|
|
47
|
+
host.style.transition = '';
|
|
48
|
+
host.removeAttribute('data-fade-presence-entering');
|
|
49
|
+
host.removeAttribute('data-fade-presence-exiting');
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
const FOCUSABLE_SELECTOR = 'a[href], [role="button"][tabindex], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), [contenteditable]';
|
|
4
|
+
|
|
5
|
+
export const focusTrap = defineTrait({
|
|
6
|
+
name: 'focus-trap',
|
|
7
|
+
attributes: ['data-focus-trap-active'],
|
|
8
|
+
events: ['focus-trap-escape'],
|
|
9
|
+
config: [],
|
|
10
|
+
setup({ host }) {
|
|
11
|
+
function getFocusableElements() {
|
|
12
|
+
return [...host.querySelectorAll(FOCUSABLE_SELECTOR)].filter(
|
|
13
|
+
(el) => !el.hasAttribute('disabled') && el.offsetParent !== null,
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function onKeyDown(e) {
|
|
18
|
+
if (e.key === 'Escape') {
|
|
19
|
+
host.dispatchEvent(new CustomEvent('focus-trap-escape', { bubbles: true }));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (e.key !== 'Tab') return;
|
|
24
|
+
|
|
25
|
+
const focusable = getFocusableElements();
|
|
26
|
+
if (focusable.length === 0) {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const first = focusable[0];
|
|
32
|
+
const last = focusable[focusable.length - 1];
|
|
33
|
+
|
|
34
|
+
if (e.shiftKey) {
|
|
35
|
+
if (document.activeElement === first) {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
last.focus();
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
if (document.activeElement === last) {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
first.focus();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
host.setAttribute('data-focus-trap-active', '');
|
|
48
|
+
host.addEventListener('keydown', onKeyDown);
|
|
49
|
+
|
|
50
|
+
// Auto-focus first focusable element
|
|
51
|
+
requestAnimationFrame(() => {
|
|
52
|
+
const focusable = getFocusableElements();
|
|
53
|
+
if (focusable.length > 0) {
|
|
54
|
+
focusable[0].focus();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return () => {
|
|
59
|
+
host.removeEventListener('keydown', onKeyDown);
|
|
60
|
+
host.removeAttribute('data-focus-trap-active');
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const focusable = defineTrait({
|
|
4
|
+
name: 'focusable',
|
|
5
|
+
attributes: ['data-focusable-keyboard'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
let hadMouseDown = false;
|
|
10
|
+
|
|
11
|
+
function onMouseDown() {
|
|
12
|
+
hadMouseDown = true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function onFocus() {
|
|
16
|
+
if (!hadMouseDown) {
|
|
17
|
+
host.setAttribute('data-focusable-keyboard', '');
|
|
18
|
+
}
|
|
19
|
+
hadMouseDown = false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function onBlur() {
|
|
23
|
+
host.removeAttribute('data-focusable-keyboard');
|
|
24
|
+
hadMouseDown = false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
host.addEventListener('mousedown', onMouseDown);
|
|
28
|
+
host.addEventListener('focus', onFocus);
|
|
29
|
+
host.addEventListener('blur', onBlur);
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
host.removeEventListener('mousedown', onMouseDown);
|
|
33
|
+
host.removeEventListener('focus', onFocus);
|
|
34
|
+
host.removeEventListener('blur', onBlur);
|
|
35
|
+
host.removeAttribute('data-focusable-keyboard');
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|