@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,33 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const glowFocus = defineTrait({
|
|
4
|
+
name: 'glow-focus',
|
|
5
|
+
attributes: ['data-glow-focus-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
let savedBoxShadow = '';
|
|
10
|
+
|
|
11
|
+
function onFocus() {
|
|
12
|
+
savedBoxShadow = host.style.boxShadow;
|
|
13
|
+
host.style.boxShadow = '0 0 8px 2px rgba(59, 130, 246, 0.6)';
|
|
14
|
+
host.style.transition = 'box-shadow 200ms ease';
|
|
15
|
+
host.setAttribute('data-glow-focus-active', '');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function onBlur() {
|
|
19
|
+
host.style.boxShadow = savedBoxShadow;
|
|
20
|
+
host.removeAttribute('data-glow-focus-active');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
host.addEventListener('focus', onFocus);
|
|
24
|
+
host.addEventListener('blur', onBlur);
|
|
25
|
+
|
|
26
|
+
return () => {
|
|
27
|
+
host.removeEventListener('focus', onFocus);
|
|
28
|
+
host.removeEventListener('blur', onBlur);
|
|
29
|
+
if (host.hasAttribute('data-glow-focus-active')) onBlur();
|
|
30
|
+
host.removeAttribute('data-glow-focus-active');
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const gradientShift = defineTrait({
|
|
4
|
+
name: 'gradient-shift',
|
|
5
|
+
attributes: ['data-gradient-shift-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const keyframeName = `adia-gradient-${Math.random().toString(36).slice(2, 8)}`;
|
|
10
|
+
|
|
11
|
+
const style = document.createElement('style');
|
|
12
|
+
style.textContent = `
|
|
13
|
+
@keyframes ${keyframeName} {
|
|
14
|
+
0% { background-position: 0% 50%; }
|
|
15
|
+
50% { background-position: 100% 50%; }
|
|
16
|
+
100% { background-position: 0% 50%; }
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
document.head.appendChild(style);
|
|
20
|
+
|
|
21
|
+
host.style.backgroundSize = '200% 200%';
|
|
22
|
+
host.style.animation = `${keyframeName} 3s ease infinite`;
|
|
23
|
+
host.setAttribute('data-gradient-shift-active', '');
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
host.style.backgroundSize = '';
|
|
27
|
+
host.style.animation = '';
|
|
28
|
+
style.remove();
|
|
29
|
+
host.removeAttribute('data-gradient-shift-active');
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const hapticFeedback = defineTrait({
|
|
4
|
+
name: 'haptic-feedback',
|
|
5
|
+
attributes: ['data-haptic-feedback-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: ['data-haptic-pattern'],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
if (!navigator.vibrate) {
|
|
10
|
+
return () => {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const patternStr = host.getAttribute('data-haptic-pattern') || '10';
|
|
14
|
+
const pattern = patternStr.split(',').map(Number);
|
|
15
|
+
|
|
16
|
+
function onPress() {
|
|
17
|
+
navigator.vibrate(pattern);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
host.addEventListener('press', onPress);
|
|
21
|
+
host.setAttribute('data-haptic-feedback-active', '');
|
|
22
|
+
|
|
23
|
+
return () => {
|
|
24
|
+
host.removeEventListener('press', onPress);
|
|
25
|
+
host.removeAttribute('data-haptic-feedback-active');
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
});
|
package/traits/hotkey.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
function isMac() {
|
|
4
|
+
if (typeof navigator !== 'undefined') {
|
|
5
|
+
if (navigator.platform) return /Mac|iPhone|iPad|iPod/.test(navigator.platform);
|
|
6
|
+
if (navigator.userAgent) return /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function parseCombo(str) {
|
|
12
|
+
const parts = str.toLowerCase().split('+').map((s) => s.trim());
|
|
13
|
+
const mac = isMac();
|
|
14
|
+
return {
|
|
15
|
+
ctrl: parts.includes('ctrl'),
|
|
16
|
+
meta: parts.includes('meta') || (parts.includes('mod') && mac),
|
|
17
|
+
alt: parts.includes('alt'),
|
|
18
|
+
shift: parts.includes('shift'),
|
|
19
|
+
ctrlOrMod: parts.includes('mod') && !mac,
|
|
20
|
+
key: parts.find((p) => !['ctrl', 'meta', 'alt', 'shift', 'mod'].includes(p)) || '',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function matchesCombo(e, combo) {
|
|
25
|
+
const ctrlMatch = combo.ctrlOrMod ? e.ctrlKey : combo.ctrl ? e.ctrlKey : !e.ctrlKey;
|
|
26
|
+
const metaMatch = combo.meta ? e.metaKey : !e.metaKey;
|
|
27
|
+
const altMatch = combo.alt ? e.altKey : !e.altKey;
|
|
28
|
+
const shiftMatch = combo.shift ? e.shiftKey : !e.shiftKey;
|
|
29
|
+
const keyMatch = e.key.toLowerCase() === combo.key;
|
|
30
|
+
return ctrlMatch && metaMatch && altMatch && shiftMatch && keyMatch;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const hotkey = defineTrait({
|
|
34
|
+
name: 'hotkey',
|
|
35
|
+
attributes: [],
|
|
36
|
+
events: ['hotkey'],
|
|
37
|
+
config: ['data-hotkey', 'data-hotkey-global'],
|
|
38
|
+
setup({ host }) {
|
|
39
|
+
const comboStr = host.getAttribute('data-hotkey');
|
|
40
|
+
if (!comboStr) return () => {};
|
|
41
|
+
|
|
42
|
+
const combo = parseCombo(comboStr);
|
|
43
|
+
const isGlobal = host.hasAttribute('data-hotkey-global');
|
|
44
|
+
const target = isGlobal ? document : host;
|
|
45
|
+
|
|
46
|
+
function onKeyDown(e) {
|
|
47
|
+
if (matchesCombo(e, combo)) {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
host.dispatchEvent(new CustomEvent('hotkey', {
|
|
50
|
+
bubbles: true,
|
|
51
|
+
detail: { combo: comboStr, originalEvent: e },
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
target.addEventListener('keydown', onKeyDown);
|
|
57
|
+
|
|
58
|
+
return () => {
|
|
59
|
+
target.removeEventListener('keydown', onKeyDown);
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const hoverable = defineTrait({
|
|
4
|
+
name: 'hoverable',
|
|
5
|
+
attributes: ['data-hoverable-hover'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
function onPointerEnter() {
|
|
10
|
+
host.setAttribute('data-hoverable-hover', '');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function onPointerLeave() {
|
|
14
|
+
host.removeAttribute('data-hoverable-hover');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
host.addEventListener('pointerenter', onPointerEnter);
|
|
18
|
+
host.addEventListener('pointerleave', onPointerLeave);
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
host.removeEventListener('pointerenter', onPointerEnter);
|
|
22
|
+
host.removeEventListener('pointerleave', onPointerLeave);
|
|
23
|
+
host.removeAttribute('data-hoverable-hover');
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
});
|
package/traits/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Interaction
|
|
2
|
+
export { pressable } from './pressable.js';
|
|
3
|
+
export { hoverable } from './hoverable.js';
|
|
4
|
+
export { focusable } from './focusable.js';
|
|
5
|
+
export { draggable } from './draggable.js';
|
|
6
|
+
export { resizable } from './resizable.js';
|
|
7
|
+
export { inertiaDrag } from './inertia-drag.js';
|
|
8
|
+
export { tossable } from './tossable.js';
|
|
9
|
+
export { scalePress } from './scale-press.js';
|
|
10
|
+
|
|
11
|
+
// Focus & Keyboard
|
|
12
|
+
export { focusTrap } from './focus-trap.js';
|
|
13
|
+
export { keyboardNav } from './keyboard-nav.js';
|
|
14
|
+
export { hotkey } from './hotkey.js';
|
|
15
|
+
export { rovingTabindex } from './roving-tabindex.js';
|
|
16
|
+
export { typeahead } from './typeahead.js';
|
|
17
|
+
|
|
18
|
+
// Form
|
|
19
|
+
export { dirtyState } from './dirty-state.js';
|
|
20
|
+
export { validation } from './validation.js';
|
|
21
|
+
|
|
22
|
+
// Animation
|
|
23
|
+
export { fadePresence } from './fade-presence.js';
|
|
24
|
+
export { countUp } from './count-up.js';
|
|
25
|
+
export { attentionPulse } from './attention-pulse.js';
|
|
26
|
+
export { glowFocus } from './glow-focus.js';
|
|
27
|
+
export { gradientShift } from './gradient-shift.js';
|
|
28
|
+
export { confetti } from './confetti.js';
|
|
29
|
+
export { confettiBurst } from './confetti-burst.js';
|
|
30
|
+
export { springAnimate } from './spring-animate.js';
|
|
31
|
+
export { shimmerLoading } from './shimmer-loading.js';
|
|
32
|
+
export { ripple } from './ripple.js';
|
|
33
|
+
|
|
34
|
+
// Layout & Positioning
|
|
35
|
+
export { anchorPositioning } from './anchor-positioning.js';
|
|
36
|
+
export { portal } from './portal.js';
|
|
37
|
+
export { parallax } from './parallax.js';
|
|
38
|
+
export { magneticHover } from './magnetic-hover.js';
|
|
39
|
+
export { snapToGrid } from './snap-to-grid.js';
|
|
40
|
+
export { scrollLock } from './scroll-lock.js';
|
|
41
|
+
|
|
42
|
+
// Observer
|
|
43
|
+
export { intersectionObserver } from './intersection-observer.js';
|
|
44
|
+
export { resizeObserver } from './resize-observer.js';
|
|
45
|
+
|
|
46
|
+
// Visual Effect
|
|
47
|
+
export { noiseTexture } from './noise-texture.js';
|
|
48
|
+
export { dragGhost } from './drag-ghost.js';
|
|
49
|
+
export { hapticFeedback } from './haptic-feedback.js';
|
|
50
|
+
export { tiltHover } from './tilt-hover.js';
|
|
51
|
+
export { soundFeedback } from './sound-feedback.js';
|
|
52
|
+
export { typewriter } from './typewriter.js';
|
|
53
|
+
|
|
54
|
+
// State
|
|
55
|
+
export { activeState } from './active-state.js';
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
const FRICTION = 0.95;
|
|
4
|
+
const MIN_VELOCITY = 0.5;
|
|
5
|
+
|
|
6
|
+
export const inertiaDrag = defineTrait({
|
|
7
|
+
name: 'inertia-drag',
|
|
8
|
+
attributes: ['data-inertia-drag-coasting'],
|
|
9
|
+
events: ['drag-end'],
|
|
10
|
+
config: [],
|
|
11
|
+
setup({ host }) {
|
|
12
|
+
let dragging = false;
|
|
13
|
+
let coasting = false;
|
|
14
|
+
let rafId = null;
|
|
15
|
+
let startX = 0;
|
|
16
|
+
let startY = 0;
|
|
17
|
+
let originX = 0;
|
|
18
|
+
let originY = 0;
|
|
19
|
+
let currentX = 0;
|
|
20
|
+
let currentY = 0;
|
|
21
|
+
let velocityX = 0;
|
|
22
|
+
let velocityY = 0;
|
|
23
|
+
let lastTime = 0;
|
|
24
|
+
let lastClientX = 0;
|
|
25
|
+
let lastClientY = 0;
|
|
26
|
+
|
|
27
|
+
function parseTranslate() {
|
|
28
|
+
const style = getComputedStyle(host);
|
|
29
|
+
const matrix = new DOMMatrixReadOnly(style.transform);
|
|
30
|
+
return { x: matrix.m41, y: matrix.m42 };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function applyPosition(x, y) {
|
|
34
|
+
host.style.translate = `${x}px ${y}px`;
|
|
35
|
+
currentX = x;
|
|
36
|
+
currentY = y;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function decelerate() {
|
|
40
|
+
velocityX *= FRICTION;
|
|
41
|
+
velocityY *= FRICTION;
|
|
42
|
+
|
|
43
|
+
if (Math.abs(velocityX) < MIN_VELOCITY && Math.abs(velocityY) < MIN_VELOCITY) {
|
|
44
|
+
coasting = false;
|
|
45
|
+
host.removeAttribute('data-inertia-drag-coasting');
|
|
46
|
+
host.dispatchEvent(new CustomEvent('drag-end', {
|
|
47
|
+
bubbles: true,
|
|
48
|
+
detail: { x: currentX, y: currentY },
|
|
49
|
+
}));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
applyPosition(currentX + velocityX, currentY + velocityY);
|
|
54
|
+
rafId = requestAnimationFrame(decelerate);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function onPointerDown(e) {
|
|
58
|
+
if (host.hasAttribute('disabled')) return;
|
|
59
|
+
|
|
60
|
+
// Stop any coasting
|
|
61
|
+
if (rafId !== null) {
|
|
62
|
+
cancelAnimationFrame(rafId);
|
|
63
|
+
rafId = null;
|
|
64
|
+
}
|
|
65
|
+
coasting = false;
|
|
66
|
+
host.removeAttribute('data-inertia-drag-coasting');
|
|
67
|
+
|
|
68
|
+
dragging = true;
|
|
69
|
+
startX = e.clientX;
|
|
70
|
+
startY = e.clientY;
|
|
71
|
+
lastClientX = e.clientX;
|
|
72
|
+
lastClientY = e.clientY;
|
|
73
|
+
lastTime = performance.now();
|
|
74
|
+
velocityX = 0;
|
|
75
|
+
velocityY = 0;
|
|
76
|
+
|
|
77
|
+
const pos = parseTranslate();
|
|
78
|
+
originX = pos.x;
|
|
79
|
+
originY = pos.y;
|
|
80
|
+
|
|
81
|
+
host.setPointerCapture(e.pointerId);
|
|
82
|
+
host.style.touchAction = 'none';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function onPointerMove(e) {
|
|
86
|
+
if (!dragging) return;
|
|
87
|
+
const now = performance.now();
|
|
88
|
+
const dt = now - lastTime;
|
|
89
|
+
|
|
90
|
+
if (dt > 0) {
|
|
91
|
+
velocityX = (e.clientX - lastClientX) / dt * 16; // normalize to ~60fps frame
|
|
92
|
+
velocityY = (e.clientY - lastClientY) / dt * 16;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
lastClientX = e.clientX;
|
|
96
|
+
lastClientY = e.clientY;
|
|
97
|
+
lastTime = now;
|
|
98
|
+
|
|
99
|
+
const dx = e.clientX - startX;
|
|
100
|
+
const dy = e.clientY - startY;
|
|
101
|
+
applyPosition(originX + dx, originY + dy);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function onPointerUp() {
|
|
105
|
+
if (!dragging) return;
|
|
106
|
+
dragging = false;
|
|
107
|
+
|
|
108
|
+
if (Math.abs(velocityX) > MIN_VELOCITY || Math.abs(velocityY) > MIN_VELOCITY) {
|
|
109
|
+
coasting = true;
|
|
110
|
+
host.setAttribute('data-inertia-drag-coasting', '');
|
|
111
|
+
rafId = requestAnimationFrame(decelerate);
|
|
112
|
+
} else {
|
|
113
|
+
host.dispatchEvent(new CustomEvent('drag-end', {
|
|
114
|
+
bubbles: true,
|
|
115
|
+
detail: { x: currentX, y: currentY },
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
host.addEventListener('pointerdown', onPointerDown);
|
|
121
|
+
host.addEventListener('pointermove', onPointerMove);
|
|
122
|
+
host.addEventListener('pointerup', onPointerUp);
|
|
123
|
+
|
|
124
|
+
return () => {
|
|
125
|
+
host.removeEventListener('pointerdown', onPointerDown);
|
|
126
|
+
host.removeEventListener('pointermove', onPointerMove);
|
|
127
|
+
host.removeEventListener('pointerup', onPointerUp);
|
|
128
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
129
|
+
host.removeAttribute('data-inertia-drag-coasting');
|
|
130
|
+
host.style.touchAction = '';
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const intersectionObserver = defineTrait({
|
|
4
|
+
name: 'intersection-observer',
|
|
5
|
+
attributes: ['data-intersection-visible', 'data-intersection-ratio'],
|
|
6
|
+
events: ['element-visible', 'element-hidden'],
|
|
7
|
+
config: ['data-intersection-threshold'],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const threshold = parseFloat(host.getAttribute('data-intersection-threshold')) || 0;
|
|
10
|
+
|
|
11
|
+
const observer = new IntersectionObserver((entries) => {
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
host.setAttribute('data-intersection-ratio', entry.intersectionRatio.toFixed(2));
|
|
14
|
+
|
|
15
|
+
if (entry.isIntersecting) {
|
|
16
|
+
host.setAttribute('data-intersection-visible', '');
|
|
17
|
+
host.dispatchEvent(new CustomEvent('element-visible', { bubbles: true }));
|
|
18
|
+
} else {
|
|
19
|
+
host.removeAttribute('data-intersection-visible');
|
|
20
|
+
host.dispatchEvent(new CustomEvent('element-hidden', { bubbles: true }));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}, { threshold });
|
|
24
|
+
|
|
25
|
+
observer.observe(host);
|
|
26
|
+
|
|
27
|
+
return () => {
|
|
28
|
+
observer.disconnect();
|
|
29
|
+
host.removeAttribute('data-intersection-visible');
|
|
30
|
+
host.removeAttribute('data-intersection-ratio');
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
const KEY_MAP = {
|
|
4
|
+
ArrowUp: 'nav-up',
|
|
5
|
+
ArrowDown: 'nav-down',
|
|
6
|
+
ArrowLeft: 'nav-left',
|
|
7
|
+
ArrowRight: 'nav-right',
|
|
8
|
+
Enter: 'nav-enter',
|
|
9
|
+
Escape: 'nav-escape',
|
|
10
|
+
Home: 'nav-home',
|
|
11
|
+
End: 'nav-end',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const keyboardNav = defineTrait({
|
|
15
|
+
name: 'keyboard-nav',
|
|
16
|
+
attributes: [],
|
|
17
|
+
events: ['nav-up', 'nav-down', 'nav-left', 'nav-right', 'nav-enter', 'nav-escape', 'nav-home', 'nav-end'],
|
|
18
|
+
config: [],
|
|
19
|
+
setup({ host }) {
|
|
20
|
+
function onKeyDown(e) {
|
|
21
|
+
const eventName = KEY_MAP[e.key];
|
|
22
|
+
if (!eventName) return;
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
host.dispatchEvent(new CustomEvent(eventName, {
|
|
25
|
+
bubbles: true,
|
|
26
|
+
detail: { originalEvent: e },
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
host.addEventListener('keydown', onKeyDown);
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
host.removeEventListener('keydown', onKeyDown);
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const magneticHover = defineTrait({
|
|
4
|
+
name: 'magnetic-hover',
|
|
5
|
+
attributes: ['data-magnetic-hover-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
function onPointerMove(e) {
|
|
10
|
+
const rect = host.getBoundingClientRect();
|
|
11
|
+
const cx = rect.left + rect.width / 2;
|
|
12
|
+
const cy = rect.top + rect.height / 2;
|
|
13
|
+
const dx = (e.clientX - cx) * 0.15;
|
|
14
|
+
const dy = (e.clientY - cy) * 0.15;
|
|
15
|
+
host.style.translate = `${dx}px ${dy}px`;
|
|
16
|
+
host.setAttribute('data-magnetic-hover-active', '');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function onPointerLeave() {
|
|
20
|
+
host.style.translate = '';
|
|
21
|
+
host.style.transition = 'translate 300ms ease';
|
|
22
|
+
host.removeAttribute('data-magnetic-hover-active');
|
|
23
|
+
setTimeout(() => { host.style.transition = ''; }, 300);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
host.addEventListener('pointermove', onPointerMove);
|
|
27
|
+
host.addEventListener('pointerleave', onPointerLeave);
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
host.removeEventListener('pointermove', onPointerMove);
|
|
31
|
+
host.removeEventListener('pointerleave', onPointerLeave);
|
|
32
|
+
host.style.translate = '';
|
|
33
|
+
host.style.transition = '';
|
|
34
|
+
host.removeAttribute('data-magnetic-hover-active');
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const noiseTexture = defineTrait({
|
|
4
|
+
name: 'noise-texture',
|
|
5
|
+
attributes: ['data-noise-texture-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(#n)" opacity="0.08"/></svg>`;
|
|
10
|
+
const encoded = `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
11
|
+
|
|
12
|
+
const overlay = document.createElement('div');
|
|
13
|
+
overlay.style.cssText = `
|
|
14
|
+
position: absolute; inset: 0; pointer-events: none; z-index: 1;
|
|
15
|
+
background-image: ${encoded};
|
|
16
|
+
background-repeat: repeat;
|
|
17
|
+
border-radius: inherit;
|
|
18
|
+
opacity: 0.5;
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
host.style.position = host.style.position || 'relative';
|
|
22
|
+
host.appendChild(overlay);
|
|
23
|
+
host.setAttribute('data-noise-texture-active', '');
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
overlay.remove();
|
|
27
|
+
host.removeAttribute('data-noise-texture-active');
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const parallax = defineTrait({
|
|
4
|
+
name: 'parallax',
|
|
5
|
+
attributes: ['data-parallax-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: ['data-parallax-strength'],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const strength = parseFloat(host.getAttribute('data-parallax-strength')) || 0.5;
|
|
10
|
+
|
|
11
|
+
function getScrollParent(el) {
|
|
12
|
+
let node = el.parentElement;
|
|
13
|
+
while (node) {
|
|
14
|
+
const style = getComputedStyle(node);
|
|
15
|
+
if (/(auto|scroll)/.test(style.overflow + style.overflowY)) return node;
|
|
16
|
+
node = node.parentElement;
|
|
17
|
+
}
|
|
18
|
+
return window;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const scrollParent = getScrollParent(host);
|
|
22
|
+
|
|
23
|
+
function onScroll() {
|
|
24
|
+
const scrollY = scrollParent === window
|
|
25
|
+
? window.scrollY
|
|
26
|
+
: scrollParent.scrollTop;
|
|
27
|
+
const offset = scrollY * strength;
|
|
28
|
+
host.style.translate = `0 ${offset}px`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const target = scrollParent === window ? window : scrollParent;
|
|
32
|
+
target.addEventListener('scroll', onScroll, { passive: true });
|
|
33
|
+
host.setAttribute('data-parallax-active', '');
|
|
34
|
+
onScroll();
|
|
35
|
+
|
|
36
|
+
return () => {
|
|
37
|
+
target.removeEventListener('scroll', onScroll);
|
|
38
|
+
host.style.translate = '';
|
|
39
|
+
host.removeAttribute('data-parallax-active');
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
});
|
package/traits/portal.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const portal = defineTrait({
|
|
4
|
+
name: 'portal',
|
|
5
|
+
attributes: ['data-portal-active'],
|
|
6
|
+
events: [],
|
|
7
|
+
config: ['data-portal-target'],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const targetSel = host.getAttribute('data-portal-target') || 'body';
|
|
10
|
+
const originalParent = host.parentNode;
|
|
11
|
+
const originalNext = host.nextSibling;
|
|
12
|
+
const target = document.querySelector(targetSel);
|
|
13
|
+
|
|
14
|
+
if (target && target !== originalParent) {
|
|
15
|
+
target.appendChild(host);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
host.setAttribute('data-portal-active', '');
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
host.removeAttribute('data-portal-active');
|
|
22
|
+
if (originalParent && host.parentNode !== originalParent) {
|
|
23
|
+
originalParent.insertBefore(host, originalNext);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const pressable = defineTrait({
|
|
4
|
+
name: 'pressable',
|
|
5
|
+
attributes: ['data-pressable-pressed'],
|
|
6
|
+
events: ['press'],
|
|
7
|
+
config: [],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
let pressed = false;
|
|
10
|
+
|
|
11
|
+
function isDisabled() {
|
|
12
|
+
return host.hasAttribute('disabled');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function setPressed(value) {
|
|
16
|
+
pressed = value;
|
|
17
|
+
if (value) {
|
|
18
|
+
host.setAttribute('data-pressable-pressed', '');
|
|
19
|
+
} else {
|
|
20
|
+
host.removeAttribute('data-pressable-pressed');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function onPointerDown(e) {
|
|
25
|
+
if (isDisabled()) return;
|
|
26
|
+
setPressed(true);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function onPointerUp(e) {
|
|
30
|
+
if (!pressed) return;
|
|
31
|
+
setPressed(false);
|
|
32
|
+
if (!isDisabled()) {
|
|
33
|
+
host.dispatchEvent(new CustomEvent('press', { bubbles: true }));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function onPointerLeave(e) {
|
|
38
|
+
if (pressed) setPressed(false);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function onKeyDown(e) {
|
|
42
|
+
if (isDisabled()) return;
|
|
43
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
setPressed(true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function onKeyUp(e) {
|
|
50
|
+
if (!pressed) return;
|
|
51
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
setPressed(false);
|
|
54
|
+
if (!isDisabled()) {
|
|
55
|
+
host.dispatchEvent(new CustomEvent('press', { bubbles: true }));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
host.addEventListener('pointerdown', onPointerDown);
|
|
61
|
+
host.addEventListener('pointerup', onPointerUp);
|
|
62
|
+
host.addEventListener('pointerleave', onPointerLeave);
|
|
63
|
+
host.addEventListener('keydown', onKeyDown);
|
|
64
|
+
host.addEventListener('keyup', onKeyUp);
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
host.removeEventListener('pointerdown', onPointerDown);
|
|
68
|
+
host.removeEventListener('pointerup', onPointerUp);
|
|
69
|
+
host.removeEventListener('pointerleave', onPointerLeave);
|
|
70
|
+
host.removeEventListener('keydown', onKeyDown);
|
|
71
|
+
host.removeEventListener('keyup', onKeyUp);
|
|
72
|
+
host.removeAttribute('data-pressable-pressed');
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
});
|