@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,178 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
const FRICTION = 0.92;
|
|
4
|
+
const BOUNCE_FACTOR = -0.6;
|
|
5
|
+
const MIN_VELOCITY = 0.3;
|
|
6
|
+
|
|
7
|
+
export const tossable = defineTrait({
|
|
8
|
+
name: 'tossable',
|
|
9
|
+
attributes: ['data-tossable-flying'],
|
|
10
|
+
events: ['toss-end'],
|
|
11
|
+
config: ['data-tossable-bounds'],
|
|
12
|
+
setup({ host }) {
|
|
13
|
+
let dragging = false;
|
|
14
|
+
let flying = false;
|
|
15
|
+
let rafId = null;
|
|
16
|
+
let startX = 0;
|
|
17
|
+
let startY = 0;
|
|
18
|
+
let originX = 0;
|
|
19
|
+
let originY = 0;
|
|
20
|
+
let currentX = 0;
|
|
21
|
+
let currentY = 0;
|
|
22
|
+
let velocityX = 0;
|
|
23
|
+
let velocityY = 0;
|
|
24
|
+
let lastTime = 0;
|
|
25
|
+
let lastClientX = 0;
|
|
26
|
+
let lastClientY = 0;
|
|
27
|
+
|
|
28
|
+
function parseTranslate() {
|
|
29
|
+
const style = getComputedStyle(host);
|
|
30
|
+
const matrix = new DOMMatrixReadOnly(style.transform);
|
|
31
|
+
return { x: matrix.m41, y: matrix.m42 };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getBounds() {
|
|
35
|
+
// Optional bounding: reads data-tossable-bounds="parent" or defaults to viewport
|
|
36
|
+
const boundsAttr = host.getAttribute('data-tossable-bounds');
|
|
37
|
+
if (boundsAttr === 'parent' && host.parentElement) {
|
|
38
|
+
return host.parentElement.getBoundingClientRect();
|
|
39
|
+
}
|
|
40
|
+
return { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight, width: window.innerWidth, height: window.innerHeight };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function applyPosition(x, y) {
|
|
44
|
+
host.style.translate = `${x}px ${y}px`;
|
|
45
|
+
currentX = x;
|
|
46
|
+
currentY = y;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function animateFling() {
|
|
50
|
+
velocityX *= FRICTION;
|
|
51
|
+
velocityY *= FRICTION;
|
|
52
|
+
|
|
53
|
+
let nextX = currentX + velocityX;
|
|
54
|
+
let nextY = currentY + velocityY;
|
|
55
|
+
|
|
56
|
+
// Bounce off bounds
|
|
57
|
+
const bounds = getBounds();
|
|
58
|
+
const rect = host.getBoundingClientRect();
|
|
59
|
+
const elW = rect.width;
|
|
60
|
+
const elH = rect.height;
|
|
61
|
+
|
|
62
|
+
// Check horizontal bounds (relative to translate origin)
|
|
63
|
+
const baseRect = host.offsetParent
|
|
64
|
+
? host.offsetParent.getBoundingClientRect()
|
|
65
|
+
: { left: 0, top: 0 };
|
|
66
|
+
|
|
67
|
+
const absLeft = baseRect.left + nextX;
|
|
68
|
+
const absRight = absLeft + elW;
|
|
69
|
+
const absTop = baseRect.top + nextY;
|
|
70
|
+
const absBottom = absTop + elH;
|
|
71
|
+
|
|
72
|
+
if (absLeft < bounds.left) {
|
|
73
|
+
nextX += bounds.left - absLeft;
|
|
74
|
+
velocityX *= BOUNCE_FACTOR;
|
|
75
|
+
} else if (absRight > bounds.right) {
|
|
76
|
+
nextX -= absRight - bounds.right;
|
|
77
|
+
velocityX *= BOUNCE_FACTOR;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (absTop < bounds.top) {
|
|
81
|
+
nextY += bounds.top - absTop;
|
|
82
|
+
velocityY *= BOUNCE_FACTOR;
|
|
83
|
+
} else if (absBottom > bounds.bottom) {
|
|
84
|
+
nextY -= absBottom - bounds.bottom;
|
|
85
|
+
velocityY *= BOUNCE_FACTOR;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
applyPosition(nextX, nextY);
|
|
89
|
+
|
|
90
|
+
if (Math.abs(velocityX) < MIN_VELOCITY && Math.abs(velocityY) < MIN_VELOCITY) {
|
|
91
|
+
flying = false;
|
|
92
|
+
host.removeAttribute('data-tossable-flying');
|
|
93
|
+
host.dispatchEvent(new CustomEvent('toss-end', {
|
|
94
|
+
bubbles: true,
|
|
95
|
+
detail: { x: currentX, y: currentY },
|
|
96
|
+
}));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
rafId = requestAnimationFrame(animateFling);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function onPointerDown(e) {
|
|
104
|
+
if (host.hasAttribute('disabled')) return;
|
|
105
|
+
|
|
106
|
+
if (rafId !== null) {
|
|
107
|
+
cancelAnimationFrame(rafId);
|
|
108
|
+
rafId = null;
|
|
109
|
+
}
|
|
110
|
+
flying = false;
|
|
111
|
+
host.removeAttribute('data-tossable-flying');
|
|
112
|
+
|
|
113
|
+
dragging = true;
|
|
114
|
+
startX = e.clientX;
|
|
115
|
+
startY = e.clientY;
|
|
116
|
+
lastClientX = e.clientX;
|
|
117
|
+
lastClientY = e.clientY;
|
|
118
|
+
lastTime = performance.now();
|
|
119
|
+
velocityX = 0;
|
|
120
|
+
velocityY = 0;
|
|
121
|
+
|
|
122
|
+
const pos = parseTranslate();
|
|
123
|
+
originX = pos.x;
|
|
124
|
+
originY = pos.y;
|
|
125
|
+
|
|
126
|
+
host.setPointerCapture(e.pointerId);
|
|
127
|
+
host.style.touchAction = 'none';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function onPointerMove(e) {
|
|
131
|
+
if (!dragging) return;
|
|
132
|
+
const now = performance.now();
|
|
133
|
+
const dt = now - lastTime;
|
|
134
|
+
|
|
135
|
+
if (dt > 0) {
|
|
136
|
+
velocityX = (e.clientX - lastClientX) / dt * 16;
|
|
137
|
+
velocityY = (e.clientY - lastClientY) / dt * 16;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
lastClientX = e.clientX;
|
|
141
|
+
lastClientY = e.clientY;
|
|
142
|
+
lastTime = now;
|
|
143
|
+
|
|
144
|
+
const dx = e.clientX - startX;
|
|
145
|
+
const dy = e.clientY - startY;
|
|
146
|
+
applyPosition(originX + dx, originY + dy);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function onPointerUp() {
|
|
150
|
+
if (!dragging) return;
|
|
151
|
+
dragging = false;
|
|
152
|
+
|
|
153
|
+
if (Math.abs(velocityX) > MIN_VELOCITY || Math.abs(velocityY) > MIN_VELOCITY) {
|
|
154
|
+
flying = true;
|
|
155
|
+
host.setAttribute('data-tossable-flying', '');
|
|
156
|
+
rafId = requestAnimationFrame(animateFling);
|
|
157
|
+
} else {
|
|
158
|
+
host.dispatchEvent(new CustomEvent('toss-end', {
|
|
159
|
+
bubbles: true,
|
|
160
|
+
detail: { x: currentX, y: currentY },
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
host.addEventListener('pointerdown', onPointerDown);
|
|
166
|
+
host.addEventListener('pointermove', onPointerMove);
|
|
167
|
+
host.addEventListener('pointerup', onPointerUp);
|
|
168
|
+
|
|
169
|
+
return () => {
|
|
170
|
+
host.removeEventListener('pointerdown', onPointerDown);
|
|
171
|
+
host.removeEventListener('pointermove', onPointerMove);
|
|
172
|
+
host.removeEventListener('pointerup', onPointerUp);
|
|
173
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
174
|
+
host.removeAttribute('data-tossable-flying');
|
|
175
|
+
host.style.touchAction = '';
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
const BUFFER_TIMEOUT = 500;
|
|
4
|
+
|
|
5
|
+
export const typeahead = defineTrait({
|
|
6
|
+
name: 'typeahead',
|
|
7
|
+
attributes: ['data-typeahead-match'],
|
|
8
|
+
events: ['typeahead-match'],
|
|
9
|
+
config: [],
|
|
10
|
+
setup({ host }) {
|
|
11
|
+
let buffer = '';
|
|
12
|
+
let timerId = null;
|
|
13
|
+
let lastMatch = null;
|
|
14
|
+
|
|
15
|
+
function clearBuffer() {
|
|
16
|
+
buffer = '';
|
|
17
|
+
timerId = null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function clearMatchAttribute() {
|
|
21
|
+
if (lastMatch) {
|
|
22
|
+
lastMatch.removeAttribute('data-typeahead-match');
|
|
23
|
+
lastMatch = null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function onKeyDown(e) {
|
|
28
|
+
// Ignore modifier keys, special keys
|
|
29
|
+
if (e.key.length !== 1 || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
30
|
+
|
|
31
|
+
buffer += e.key.toLowerCase();
|
|
32
|
+
|
|
33
|
+
if (timerId !== null) clearTimeout(timerId);
|
|
34
|
+
timerId = setTimeout(clearBuffer, BUFFER_TIMEOUT);
|
|
35
|
+
|
|
36
|
+
// Search children by textContent prefix match
|
|
37
|
+
const children = [...host.children];
|
|
38
|
+
const match = children.find((child) => {
|
|
39
|
+
const text = (child.textContent || '').trim().toLowerCase();
|
|
40
|
+
return text.startsWith(buffer);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
clearMatchAttribute();
|
|
44
|
+
|
|
45
|
+
if (match) {
|
|
46
|
+
lastMatch = match;
|
|
47
|
+
match.setAttribute('data-typeahead-match', '');
|
|
48
|
+
host.dispatchEvent(new CustomEvent('typeahead-match', {
|
|
49
|
+
bubbles: true,
|
|
50
|
+
detail: { element: match, query: buffer },
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
host.addEventListener('keydown', onKeyDown);
|
|
56
|
+
|
|
57
|
+
return () => {
|
|
58
|
+
host.removeEventListener('keydown', onKeyDown);
|
|
59
|
+
if (timerId !== null) clearTimeout(timerId);
|
|
60
|
+
clearMatchAttribute();
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
export const typewriter = defineTrait({
|
|
4
|
+
name: 'typewriter',
|
|
5
|
+
attributes: ['data-typewriter-active'],
|
|
6
|
+
events: ['typewriter-done'],
|
|
7
|
+
config: ['data-typewriter-speed'],
|
|
8
|
+
setup({ host }) {
|
|
9
|
+
const speed = parseInt(host.getAttribute('data-typewriter-speed'), 10) || 50;
|
|
10
|
+
const originalText = host.textContent;
|
|
11
|
+
let index = 0;
|
|
12
|
+
let timerId = null;
|
|
13
|
+
|
|
14
|
+
host.textContent = '';
|
|
15
|
+
host.setAttribute('data-typewriter-active', '');
|
|
16
|
+
|
|
17
|
+
function tick() {
|
|
18
|
+
if (index < originalText.length) {
|
|
19
|
+
host.textContent = originalText.slice(0, ++index);
|
|
20
|
+
timerId = setTimeout(tick, speed);
|
|
21
|
+
} else {
|
|
22
|
+
host.removeAttribute('data-typewriter-active');
|
|
23
|
+
host.dispatchEvent(new CustomEvent('typewriter-done', { bubbles: true }));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
timerId = setTimeout(tick, speed);
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
if (timerId) clearTimeout(timerId);
|
|
31
|
+
host.textContent = originalText;
|
|
32
|
+
host.removeAttribute('data-typewriter-active');
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { defineTrait } from './define.js';
|
|
2
|
+
|
|
3
|
+
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
4
|
+
|
|
5
|
+
function parseRules(str) {
|
|
6
|
+
if (!str) return [];
|
|
7
|
+
return str.split(',').map((r) => r.trim()).filter(Boolean).map((rule) => {
|
|
8
|
+
const [name, ...rest] = rule.split(':');
|
|
9
|
+
return { name: name.trim(), param: rest.join(':').trim() };
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function validateValue(value, rules) {
|
|
14
|
+
const errors = [];
|
|
15
|
+
|
|
16
|
+
for (const rule of rules) {
|
|
17
|
+
switch (rule.name) {
|
|
18
|
+
case 'required':
|
|
19
|
+
if (!value || value.trim().length === 0) {
|
|
20
|
+
errors.push('This field is required');
|
|
21
|
+
}
|
|
22
|
+
break;
|
|
23
|
+
|
|
24
|
+
case 'minlength': {
|
|
25
|
+
const min = parseInt(rule.param, 10);
|
|
26
|
+
if (value.length < min) {
|
|
27
|
+
errors.push(`Minimum length is ${min}`);
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
case 'maxlength': {
|
|
33
|
+
const max = parseInt(rule.param, 10);
|
|
34
|
+
if (value.length > max) {
|
|
35
|
+
errors.push(`Maximum length is ${max}`);
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
case 'pattern': {
|
|
41
|
+
const re = new RegExp(rule.param);
|
|
42
|
+
if (!re.test(value)) {
|
|
43
|
+
errors.push(`Does not match required pattern`);
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case 'min': {
|
|
49
|
+
const min = parseFloat(rule.param);
|
|
50
|
+
if (parseFloat(value) < min) {
|
|
51
|
+
errors.push(`Minimum value is ${min}`);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
case 'max': {
|
|
57
|
+
const max = parseFloat(rule.param);
|
|
58
|
+
if (parseFloat(value) > max) {
|
|
59
|
+
errors.push(`Maximum value is ${max}`);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
case 'email':
|
|
65
|
+
if (value && !EMAIL_RE.test(value)) {
|
|
66
|
+
errors.push('Invalid email address');
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return errors;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const validation = defineTrait({
|
|
76
|
+
name: 'validation',
|
|
77
|
+
attributes: ['data-validation-invalid', 'data-validation-valid', 'data-validation-message'],
|
|
78
|
+
events: ['validated'],
|
|
79
|
+
config: ['data-validate'],
|
|
80
|
+
setup({ host }) {
|
|
81
|
+
function validate() {
|
|
82
|
+
const rulesStr = host.getAttribute('data-validate') || '';
|
|
83
|
+
const rules = parseRules(rulesStr);
|
|
84
|
+
const value = host.value ?? host.getAttribute('value') ?? '';
|
|
85
|
+
const errors = validateValue(value, rules);
|
|
86
|
+
const valid = errors.length === 0;
|
|
87
|
+
|
|
88
|
+
if (valid) {
|
|
89
|
+
host.setAttribute('data-validation-valid', '');
|
|
90
|
+
host.removeAttribute('data-validation-invalid');
|
|
91
|
+
host.removeAttribute('data-validation-message');
|
|
92
|
+
} else {
|
|
93
|
+
host.setAttribute('data-validation-invalid', '');
|
|
94
|
+
host.setAttribute('data-validation-message', errors[0]);
|
|
95
|
+
host.removeAttribute('data-validation-valid');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
host.dispatchEvent(new CustomEvent('validated', {
|
|
99
|
+
bubbles: true,
|
|
100
|
+
detail: { valid, errors },
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function onInput() { validate(); }
|
|
105
|
+
function onChange() { validate(); }
|
|
106
|
+
|
|
107
|
+
host.addEventListener('input', onInput);
|
|
108
|
+
host.addEventListener('change', onChange);
|
|
109
|
+
|
|
110
|
+
return () => {
|
|
111
|
+
host.removeEventListener('input', onInput);
|
|
112
|
+
host.removeEventListener('change', onChange);
|
|
113
|
+
host.removeAttribute('data-validation-invalid');
|
|
114
|
+
host.removeAttribute('data-validation-valid');
|
|
115
|
+
host.removeAttribute('data-validation-message');
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
});
|