@adia-ai/web-components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -0
- package/a2ui/dockables/action.js +152 -0
- package/a2ui/dockables/base.js +30 -0
- package/a2ui/dockables/controller.js +97 -0
- package/a2ui/dockables/data-source.js +103 -0
- package/a2ui/dockables/index.js +6 -0
- package/a2ui/dockables/lifecycle.js +84 -0
- package/a2ui/dockables/provider.js +59 -0
- package/a2ui/index.js +19 -0
- package/a2ui/manifest-runtime.js +226 -0
- package/a2ui/registry.js +200 -0
- package/a2ui/renderer.js +361 -0
- package/a2ui/root.js +152 -0
- package/a2ui/stream.js +243 -0
- package/a2ui/surface-manifest.js +294 -0
- package/a2ui/surface.js +222 -0
- package/a2ui/wire-factory.js +134 -0
- package/a2ui/wiring-engine.js +209 -0
- package/a2ui/wiring-registry.js +342 -0
- package/components/accordion/accordion.a2ui.json +129 -0
- package/components/accordion/accordion.css +133 -0
- package/components/accordion/accordion.js +125 -0
- package/components/accordion/accordion.yaml +527 -0
- package/components/action-list/action-list.a2ui.json +64 -0
- package/components/action-list/action-list.css +115 -0
- package/components/action-list/action-list.js +149 -0
- package/components/action-list/action-list.yaml +56 -0
- package/components/agent-artifact/agent-artifact.a2ui.json +99 -0
- package/components/agent-artifact/agent-artifact.css +94 -0
- package/components/agent-artifact/agent-artifact.js +169 -0
- package/components/agent-artifact/agent-artifact.yaml +71 -0
- package/components/agent-feedback-bar/agent-feedback-bar.a2ui.json +91 -0
- package/components/agent-feedback-bar/agent-feedback-bar.css +33 -0
- package/components/agent-feedback-bar/agent-feedback-bar.js +152 -0
- package/components/agent-feedback-bar/agent-feedback-bar.yaml +65 -0
- package/components/agent-questions/agent-questions.a2ui.json +89 -0
- package/components/agent-questions/agent-questions.css +146 -0
- package/components/agent-questions/agent-questions.js +189 -0
- package/components/agent-questions/agent-questions.yaml +63 -0
- package/components/agent-reasoning/agent-reasoning.a2ui.json +100 -0
- package/components/agent-reasoning/agent-reasoning.css +273 -0
- package/components/agent-reasoning/agent-reasoning.js +469 -0
- package/components/agent-reasoning/agent-reasoning.yaml +70 -0
- package/components/agent-suggestions/agent-suggestions.a2ui.json +87 -0
- package/components/agent-suggestions/agent-suggestions.css +18 -0
- package/components/agent-suggestions/agent-suggestions.js +87 -0
- package/components/agent-suggestions/agent-suggestions.yaml +59 -0
- package/components/agent-trace/agent-trace.a2ui.json +78 -0
- package/components/agent-trace/agent-trace.css +275 -0
- package/components/agent-trace/agent-trace.js +216 -0
- package/components/agent-trace/agent-trace.yaml +53 -0
- package/components/alert/alert.a2ui.json +211 -0
- package/components/alert/alert.css +88 -0
- package/components/alert/alert.js +96 -0
- package/components/alert/alert.yaml +205 -0
- package/components/avatar/avatar.a2ui.json +215 -0
- package/components/avatar/avatar.css +159 -0
- package/components/avatar/avatar.js +157 -0
- package/components/avatar/avatar.yaml +559 -0
- package/components/badge/badge.a2ui.json +169 -0
- package/components/badge/badge.css +78 -0
- package/components/badge/badge.js +53 -0
- package/components/badge/badge.yaml +612 -0
- package/components/block/block.a2ui.json +135 -0
- package/components/block/block.css +29 -0
- package/components/block/block.js +23 -0
- package/components/block/block.yaml +115 -0
- package/components/breadcrumb/breadcrumb.a2ui.json +86 -0
- package/components/breadcrumb/breadcrumb.css +78 -0
- package/components/breadcrumb/breadcrumb.js +44 -0
- package/components/breadcrumb/breadcrumb.yaml +84 -0
- package/components/button/button.a2ui.json +172 -0
- package/components/button/button.css +168 -0
- package/components/button/button.js +60 -0
- package/components/button/button.yaml +120 -0
- package/components/calendar-picker/calendar-picker.a2ui.json +139 -0
- package/components/calendar-picker/calendar-picker.css +321 -0
- package/components/calendar-picker/calendar-picker.js +324 -0
- package/components/calendar-picker/calendar-picker.yaml +243 -0
- package/components/canvas/canvas.a2ui.json +75 -0
- package/components/canvas/canvas.css +52 -0
- package/components/canvas/canvas.js +179 -0
- package/components/canvas/canvas.yaml +62 -0
- package/components/card/card.a2ui.json +276 -0
- package/components/card/card.css +362 -0
- package/components/card/card.js +58 -0
- package/components/card/card.yaml +527 -0
- package/components/chart/chart.a2ui.json +298 -0
- package/components/chart/chart.css +512 -0
- package/components/chart/chart.js +1075 -0
- package/components/chart/chart.yaml +540 -0
- package/components/chat/chat-input.css +141 -0
- package/components/chat/chat-input.js +242 -0
- package/components/chat/chat.a2ui.json +181 -0
- package/components/chat/chat.css +193 -0
- package/components/chat/chat.js +155 -0
- package/components/chat/chat.yaml +230 -0
- package/components/check/check.a2ui.json +134 -0
- package/components/check/check.css +126 -0
- package/components/check/check.js +58 -0
- package/components/check/check.yaml +109 -0
- package/components/code/code.a2ui.json +153 -0
- package/components/code/code.css +133 -0
- package/components/code/code.js +114 -0
- package/components/code/code.yaml +163 -0
- package/components/col/col.a2ui.json +104 -0
- package/components/col/col.css +36 -0
- package/components/col/col.js +19 -0
- package/components/col/col.yaml +364 -0
- package/components/color-picker/color-picker.a2ui.json +100 -0
- package/components/color-picker/color-picker.css +182 -0
- package/components/color-picker/color-picker.js +537 -0
- package/components/color-picker/color-picker.yaml +105 -0
- package/components/command/command.a2ui.json +221 -0
- package/components/command/command.css +251 -0
- package/components/command/command.js +284 -0
- package/components/command/command.yaml +186 -0
- package/components/description-list/description-list.a2ui.json +89 -0
- package/components/description-list/description-list.css +70 -0
- package/components/description-list/description-list.js +75 -0
- package/components/description-list/description-list.yaml +59 -0
- package/components/divider/divider.a2ui.json +126 -0
- package/components/divider/divider.css +102 -0
- package/components/divider/divider.js +47 -0
- package/components/divider/divider.yaml +366 -0
- package/components/drawer/drawer.a2ui.json +199 -0
- package/components/drawer/drawer.css +342 -0
- package/components/drawer/drawer.js +263 -0
- package/components/drawer/drawer.yaml +366 -0
- package/components/embed/embed.a2ui.json +150 -0
- package/components/embed/embed.css +28 -0
- package/components/embed/embed.js +63 -0
- package/components/embed/embed.yaml +224 -0
- package/components/empty-state/empty-state.a2ui.json +133 -0
- package/components/empty-state/empty-state.css +58 -0
- package/components/empty-state/empty-state.js +87 -0
- package/components/empty-state/empty-state.yaml +314 -0
- package/components/footer/footer.a2ui.json +79 -0
- package/components/footer/footer.yaml +239 -0
- package/components/grid/grid.a2ui.json +171 -0
- package/components/grid/grid.css +37 -0
- package/components/grid/grid.js +21 -0
- package/components/grid/grid.yaml +577 -0
- package/components/header/header.a2ui.json +76 -0
- package/components/header/header.yaml +336 -0
- package/components/heatmap/heatmap.a2ui.json +150 -0
- package/components/heatmap/heatmap.css +146 -0
- package/components/heatmap/heatmap.js +246 -0
- package/components/heatmap/heatmap.yaml +131 -0
- package/components/icon/icon.a2ui.json +79 -0
- package/components/icon/icon.css +20 -0
- package/components/icon/icon.js +26 -0
- package/components/icon/icon.yaml +233 -0
- package/components/image/image.a2ui.json +261 -0
- package/components/image/image.css +76 -0
- package/components/image/image.js +102 -0
- package/components/image/image.yaml +477 -0
- package/components/index.js +85 -0
- package/components/input/input.a2ui.json +284 -0
- package/components/input/input.css +162 -0
- package/components/input/input.js +148 -0
- package/components/input/input.yaml +496 -0
- package/components/inspector/inspector.a2ui.json +67 -0
- package/components/inspector/inspector.css +31 -0
- package/components/inspector/inspector.js +133 -0
- package/components/inspector/inspector.yaml +58 -0
- package/components/kbd/kbd.a2ui.json +96 -0
- package/components/kbd/kbd.css +62 -0
- package/components/kbd/kbd.js +24 -0
- package/components/kbd/kbd.yaml +213 -0
- package/components/list/list.a2ui.json +145 -0
- package/components/list/list.css +103 -0
- package/components/list/list.js +236 -0
- package/components/list/list.yaml +122 -0
- package/components/menu/menu.a2ui.json +146 -0
- package/components/menu/menu.css +146 -0
- package/components/menu/menu.js +296 -0
- package/components/menu/menu.yaml +123 -0
- package/components/modal/modal.a2ui.json +136 -0
- package/components/modal/modal.css +153 -0
- package/components/modal/modal.js +181 -0
- package/components/modal/modal.yaml +114 -0
- package/components/noodles/noodles.a2ui.json +145 -0
- package/components/noodles/noodles.css +118 -0
- package/components/noodles/noodles.js +470 -0
- package/components/noodles/noodles.yaml +123 -0
- package/components/otp-input/otp-input.a2ui.json +104 -0
- package/components/otp-input/otp-input.css +78 -0
- package/components/otp-input/otp-input.js +170 -0
- package/components/otp-input/otp-input.yaml +218 -0
- package/components/pagination/pagination.a2ui.json +122 -0
- package/components/pagination/pagination.css +162 -0
- package/components/pagination/pagination.js +185 -0
- package/components/pagination/pagination.yaml +165 -0
- package/components/pane/pane.a2ui.json +94 -0
- package/components/pane/pane.css +166 -0
- package/components/pane/pane.js +140 -0
- package/components/pane/pane.yaml +197 -0
- package/components/pipeline-status/pipeline-status.a2ui.json +90 -0
- package/components/pipeline-status/pipeline-status.css +162 -0
- package/components/pipeline-status/pipeline-status.js +176 -0
- package/components/pipeline-status/pipeline-status.yaml +99 -0
- package/components/popover/popover.a2ui.json +181 -0
- package/components/popover/popover.css +57 -0
- package/components/popover/popover.js +170 -0
- package/components/popover/popover.yaml +257 -0
- package/components/progress/progress.a2ui.json +199 -0
- package/components/progress/progress.css +88 -0
- package/components/progress/progress.js +64 -0
- package/components/progress/progress.yaml +342 -0
- package/components/progress-row/progress-row.a2ui.json +100 -0
- package/components/progress-row/progress-row.css +57 -0
- package/components/progress-row/progress-row.js +92 -0
- package/components/progress-row/progress-row.yaml +87 -0
- package/components/radio/radio.a2ui.json +232 -0
- package/components/radio/radio.css +102 -0
- package/components/radio/radio.js +73 -0
- package/components/radio/radio.yaml +248 -0
- package/components/range/range.a2ui.json +151 -0
- package/components/range/range.css +148 -0
- package/components/range/range.js +177 -0
- package/components/range/range.yaml +188 -0
- package/components/rating/rating.a2ui.json +105 -0
- package/components/rating/rating.css +92 -0
- package/components/rating/rating.js +138 -0
- package/components/rating/rating.yaml +74 -0
- package/components/richtext/richtext.a2ui.json +82 -0
- package/components/richtext/richtext.css +225 -0
- package/components/richtext/richtext.js +74 -0
- package/components/richtext/richtext.yaml +89 -0
- package/components/row/row.a2ui.json +102 -0
- package/components/row/row.css +51 -0
- package/components/row/row.js +39 -0
- package/components/row/row.yaml +358 -0
- package/components/search/search.a2ui.json +186 -0
- package/components/search/search.css +28 -0
- package/components/search/search.js +124 -0
- package/components/search/search.yaml +154 -0
- package/components/section/section.a2ui.json +78 -0
- package/components/section/section.yaml +338 -0
- package/components/segment/segment.a2ui.json +100 -0
- package/components/segment/segment.css +81 -0
- package/components/segment/segment.js +32 -0
- package/components/segment/segment.yaml +216 -0
- package/components/segmented/segmented.a2ui.json +106 -0
- package/components/segmented/segmented.css +67 -0
- package/components/segmented/segmented.js +149 -0
- package/components/segmented/segmented.yaml +91 -0
- package/components/select/select.a2ui.json +203 -0
- package/components/select/select.css +277 -0
- package/components/select/select.js +388 -0
- package/components/select/select.yaml +375 -0
- package/components/skeleton/skeleton.a2ui.json +120 -0
- package/components/skeleton/skeleton.css +47 -0
- package/components/skeleton/skeleton.js +43 -0
- package/components/skeleton/skeleton.yaml +153 -0
- package/components/slider/slider.a2ui.json +162 -0
- package/components/slider/slider.css +137 -0
- package/components/slider/slider.js +162 -0
- package/components/slider/slider.yaml +299 -0
- package/components/stack/stack.a2ui.json +62 -0
- package/components/stack/stack.css +28 -0
- package/components/stack/stack.js +18 -0
- package/components/stack/stack.yaml +54 -0
- package/components/stat/stat.a2ui.json +246 -0
- package/components/stat/stat.css +101 -0
- package/components/stat/stat.js +91 -0
- package/components/stat/stat.yaml +206 -0
- package/components/stepper/stepper.a2ui.json +77 -0
- package/components/stepper/stepper.css +243 -0
- package/components/stepper/stepper.js +118 -0
- package/components/stepper/stepper.yaml +73 -0
- package/components/stream/stream.a2ui.json +98 -0
- package/components/stream/stream.css +37 -0
- package/components/stream/stream.js +99 -0
- package/components/stream/stream.yaml +87 -0
- package/components/swiper/swiper.a2ui.json +140 -0
- package/components/swiper/swiper.css +267 -0
- package/components/swiper/swiper.js +285 -0
- package/components/swiper/swiper.yaml +268 -0
- package/components/switch/switch.a2ui.json +134 -0
- package/components/switch/switch.css +104 -0
- package/components/switch/switch.js +53 -0
- package/components/switch/switch.yaml +322 -0
- package/components/table/cell-types.js +296 -0
- package/components/table/table.a2ui.json +458 -0
- package/components/table/table.css +531 -0
- package/components/table/table.js +1392 -0
- package/components/table/table.yaml +528 -0
- package/components/tabs/tab.js +34 -0
- package/components/tabs/tabs.a2ui.json +174 -0
- package/components/tabs/tabs.css +162 -0
- package/components/tabs/tabs.js +226 -0
- package/components/tabs/tabs.yaml +255 -0
- package/components/tag/tag.a2ui.json +148 -0
- package/components/tag/tag.css +118 -0
- package/components/tag/tag.js +88 -0
- package/components/tag/tag.yaml +125 -0
- package/components/text/text.a2ui.json +99 -0
- package/components/text/text.css +65 -0
- package/components/text/text.js +35 -0
- package/components/text/text.yaml +360 -0
- package/components/textarea/textarea.a2ui.json +91 -0
- package/components/textarea/textarea.css +93 -0
- package/components/textarea/textarea.js +114 -0
- package/components/textarea/textarea.yaml +79 -0
- package/components/timeline/timeline.a2ui.json +82 -0
- package/components/timeline/timeline.css +389 -0
- package/components/timeline/timeline.js +171 -0
- package/components/timeline/timeline.yaml +185 -0
- package/components/toast/toast.a2ui.json +199 -0
- package/components/toast/toast.css +211 -0
- package/components/toast/toast.js +146 -0
- package/components/toast/toast.yaml +184 -0
- package/components/toggle-group/toggle-group.a2ui.json +126 -0
- package/components/toggle-group/toggle-group.css +102 -0
- package/components/toggle-group/toggle-group.js +147 -0
- package/components/toggle-group/toggle-group.yaml +98 -0
- package/components/toolbar/toolbar.a2ui.json +131 -0
- package/components/toolbar/toolbar.css +132 -0
- package/components/toolbar/toolbar.js +366 -0
- package/components/toolbar/toolbar.yaml +238 -0
- package/components/tooltip/tooltip.a2ui.json +148 -0
- package/components/tooltip/tooltip.css +39 -0
- package/components/tooltip/tooltip.js +96 -0
- package/components/tooltip/tooltip.yaml +201 -0
- package/components/tree/tree.a2ui.json +119 -0
- package/components/tree/tree.css +133 -0
- package/components/tree/tree.js +253 -0
- package/components/tree/tree.yaml +92 -0
- package/components/upload/upload.a2ui.json +185 -0
- package/components/upload/upload.css +115 -0
- package/components/upload/upload.js +189 -0
- package/components/upload/upload.yaml +302 -0
- package/core/anchor.js +187 -0
- package/core/controller.js +182 -0
- package/core/element.js +257 -0
- package/core/form.js +217 -0
- package/core/icons.js +180 -0
- package/core/markdown.js +95 -0
- package/core/polyfills.js +23 -0
- package/core/provider.js +262 -0
- package/core/signals.js +113 -0
- package/core/template.js +226 -0
- package/core/transport.js +77 -0
- package/package.json +38 -0
- package/patterns/adia-chat/adia-chat.a2ui.json +149 -0
- package/patterns/adia-chat/adia-chat.css +10 -0
- package/patterns/adia-chat/adia-chat.js +297 -0
- package/patterns/adia-chat/adia-chat.yaml +118 -0
- package/patterns/adia-chat/css/adia-chat.empty.css +12 -0
- package/patterns/adia-chat/css/adia-chat.layout.css +60 -0
- package/patterns/adia-chat/css/adia-chat.markdown.css +74 -0
- package/patterns/adia-chat/css/adia-chat.messages.css +87 -0
- package/patterns/adia-chat/css/adia-chat.streaming.css +30 -0
- package/patterns/adia-chat/css/adia-chat.tokens.css +95 -0
- package/patterns/adia-chat/index.html +93 -0
- package/patterns/adia-editor/adia-editor.a2ui.json +58 -0
- package/patterns/adia-editor/adia-editor.css +6 -0
- package/patterns/adia-editor/adia-editor.js +56 -0
- package/patterns/adia-editor/adia-editor.yaml +36 -0
- package/patterns/adia-editor/css/adia-editor.layout.css +86 -0
- package/patterns/adia-editor/css/adia-editor.tokens.css +28 -0
- package/patterns/adia-editor/index.html +179 -0
- package/patterns/app-nav/app-nav.a2ui.json +89 -0
- package/patterns/app-nav/app-nav.css +92 -0
- package/patterns/app-nav/app-nav.js +99 -0
- package/patterns/app-nav/app-nav.yaml +54 -0
- package/patterns/app-nav-group/app-nav-group.a2ui.json +82 -0
- package/patterns/app-nav-group/app-nav-group.css +261 -0
- package/patterns/app-nav-group/app-nav-group.js +116 -0
- package/patterns/app-nav-group/app-nav-group.yaml +59 -0
- package/patterns/app-nav-item/app-nav-item.a2ui.json +83 -0
- package/patterns/app-nav-item/app-nav-item.css +156 -0
- package/patterns/app-nav-item/app-nav-item.js +42 -0
- package/patterns/app-nav-item/app-nav-item.yaml +62 -0
- package/patterns/app-shell/app-shell.a2ui.json +114 -0
- package/patterns/app-shell/app-shell.css +14 -0
- package/patterns/app-shell/app-shell.js +251 -0
- package/patterns/app-shell/app-shell.yaml +66 -0
- package/patterns/app-shell/css/app-shell.collapsed.css +86 -0
- package/patterns/app-shell/css/app-shell.helpers.css +42 -0
- package/patterns/app-shell/css/app-shell.main.css +58 -0
- package/patterns/app-shell/css/app-shell.shell.css +44 -0
- package/patterns/app-shell/css/app-shell.sidebar.css +116 -0
- package/patterns/app-shell/css/app-shell.templates.css +214 -0
- package/patterns/app-shell/css/app-shell.tokens.css +116 -0
- package/patterns/app-shell/index.html +112 -0
- package/patterns/gen-ui/gen-ui.a2ui.json +72 -0
- package/patterns/gen-ui/gen-ui.css +83 -0
- package/patterns/gen-ui/gen-ui.js +136 -0
- package/patterns/gen-ui/gen-ui.yaml +43 -0
- package/patterns/index.js +10 -0
- package/patterns/section-nav/section-nav.a2ui.json +91 -0
- package/patterns/section-nav/section-nav.css +59 -0
- package/patterns/section-nav/section-nav.js +42 -0
- package/patterns/section-nav/section-nav.yaml +58 -0
- package/patterns/section-nav-group/section-nav-group.a2ui.json +95 -0
- package/patterns/section-nav-group/section-nav-group.css +74 -0
- package/patterns/section-nav-group/section-nav-group.js +84 -0
- package/patterns/section-nav-group/section-nav-group.yaml +66 -0
- package/patterns/section-nav-item/section-nav-item.a2ui.json +97 -0
- package/patterns/section-nav-item/section-nav-item.css +96 -0
- package/patterns/section-nav-item/section-nav-item.js +66 -0
- package/patterns/section-nav-item/section-nav-item.yaml +70 -0
- package/styles/colors/index.css +6 -0
- package/styles/colors/parameters.css +52 -0
- package/styles/colors/primitives-accent.css +89 -0
- package/styles/colors/primitives-brand.css +89 -0
- package/styles/colors/primitives-danger.css +89 -0
- package/styles/colors/primitives-info.css +89 -0
- package/styles/colors/primitives-neutral.css +91 -0
- package/styles/colors/primitives-shared.css +57 -0
- package/styles/colors/primitives-success.css +89 -0
- package/styles/colors/primitives-warning.css +89 -0
- package/styles/colors/primitives.css +17 -0
- package/styles/colors/scrims.css +182 -0
- package/styles/colors/semantics.css +595 -0
- package/styles/colors/surfaces.css +43 -0
- package/styles/fonts.css +99 -0
- package/styles/layouts/admin.css +7 -0
- package/styles/prose.css +186 -0
- package/styles/styles.css +193 -0
- package/styles/themes.css +155 -0
- package/styles/tokens.css +304 -0
- package/styles/typography.css +853 -0
- package/traits/active-state.js +24 -0
- package/traits/anchor-positioning.js +66 -0
- package/traits/attention-pulse.js +30 -0
- package/traits/confetti-burst.js +65 -0
- package/traits/confetti.js +57 -0
- package/traits/count-up.js +42 -0
- package/traits/define.js +76 -0
- package/traits/dirty-state.js +38 -0
- package/traits/drag-ghost.js +38 -0
- package/traits/draggable.js +73 -0
- package/traits/fade-presence.js +52 -0
- package/traits/focus-trap.js +63 -0
- package/traits/focusable.js +38 -0
- package/traits/glow-focus.js +33 -0
- package/traits/gradient-shift.js +32 -0
- package/traits/haptic-feedback.js +28 -0
- package/traits/hotkey.js +62 -0
- package/traits/hoverable.js +26 -0
- package/traits/index.js +55 -0
- package/traits/inertia-drag.js +133 -0
- package/traits/intersection-observer.js +33 -0
- package/traits/keyboard-nav.js +36 -0
- package/traits/magnetic-hover.js +37 -0
- package/traits/noise-texture.js +30 -0
- package/traits/parallax.js +42 -0
- package/traits/portal.js +27 -0
- package/traits/pressable.js +75 -0
- package/traits/resizable.js +100 -0
- package/traits/resize-observer.js +31 -0
- package/traits/ripple.js +53 -0
- package/traits/roving-tabindex.js +67 -0
- package/traits/scale-press.js +43 -0
- package/traits/scroll-lock.js +27 -0
- package/traits/shimmer-loading.js +44 -0
- package/traits/snap-to-grid.js +28 -0
- package/traits/sound-feedback.js +30 -0
- package/traits/spring-animate.js +56 -0
- package/traits/tilt-hover.js +37 -0
- package/traits/tossable.js +178 -0
- package/traits/typeahead.js +63 -0
- package/traits/typewriter.js +35 -0
- package/traits/validation.js +118 -0
package/core/form.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdiaFormElement — Form-participating base class.
|
|
3
|
+
*
|
|
4
|
+
* Extends AdiaElement with ElementInternals form participation,
|
|
5
|
+
* constraint validation (required, pattern, minlength, maxlength),
|
|
6
|
+
* and auto-validation UX (submit, blur, input re-validation).
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { AdiaFormElement } from './form.js';
|
|
10
|
+
*
|
|
11
|
+
* class MyField extends AdiaFormElement {
|
|
12
|
+
* static properties = {
|
|
13
|
+
* ...AdiaFormElement.properties,
|
|
14
|
+
* placeholder: { type: String, default: '', reflect: true },
|
|
15
|
+
* };
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* Auto-validation lifecycle:
|
|
19
|
+
* - On form submit: browser fires `invalid` → auto-sets `error` attr
|
|
20
|
+
* - On input (if currently invalid): re-validates to clear as soon as valid
|
|
21
|
+
* - On blur (if dirty): validates
|
|
22
|
+
* - On form reset: clears all validation state
|
|
23
|
+
*
|
|
24
|
+
* Custom error messages via data attributes:
|
|
25
|
+
* data-msg-required="Please enter your name"
|
|
26
|
+
* data-msg-pattern="Invalid format"
|
|
27
|
+
* data-msg-minlength="Too short"
|
|
28
|
+
* data-msg-maxlength="Too long"
|
|
29
|
+
*
|
|
30
|
+
* Manual control:
|
|
31
|
+
* el.validate() → returns boolean, surfaces error
|
|
32
|
+
* el.setInvalid('msg') → custom error
|
|
33
|
+
* el.setValid() → clear error
|
|
34
|
+
* el.syncValue(val) → update form value + run constraints
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
import { AdiaElement } from './element.js';
|
|
38
|
+
|
|
39
|
+
export class AdiaFormElement extends AdiaElement {
|
|
40
|
+
static formAssociated = true;
|
|
41
|
+
|
|
42
|
+
static get properties() {
|
|
43
|
+
return {
|
|
44
|
+
name: { type: String, default: '', reflect: true },
|
|
45
|
+
value: { type: String, default: '', reflect: true },
|
|
46
|
+
disabled: { type: Boolean, default: false, reflect: true },
|
|
47
|
+
required: { type: Boolean, default: false, reflect: true },
|
|
48
|
+
readonly: { type: Boolean, default: false, reflect: true },
|
|
49
|
+
error: { type: String, default: '', reflect: true },
|
|
50
|
+
hint: { type: String, default: '', reflect: true },
|
|
51
|
+
pattern: { type: String, default: '', reflect: true },
|
|
52
|
+
minlength: { type: Number, default: null, reflect: true },
|
|
53
|
+
maxlength: { type: Number, default: null, reflect: true },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#dirty = false;
|
|
58
|
+
|
|
59
|
+
// ── ElementInternals accessors ──
|
|
60
|
+
|
|
61
|
+
get form() { return this.internals.form; }
|
|
62
|
+
get labels() { return this.internals.labels; }
|
|
63
|
+
get validity() { return this.internals.validity; }
|
|
64
|
+
get validationMessage() { return this.internals.validationMessage; }
|
|
65
|
+
get willValidate() { return this.internals.willValidate; }
|
|
66
|
+
|
|
67
|
+
checkValidity() { return this.internals.checkValidity(); }
|
|
68
|
+
reportValidity() { return this.internals.reportValidity(); }
|
|
69
|
+
|
|
70
|
+
// ── Value sync ──
|
|
71
|
+
|
|
72
|
+
/** Update the form value and run constraint validation. */
|
|
73
|
+
syncValue(val) {
|
|
74
|
+
val = val ?? this.value ?? '';
|
|
75
|
+
this.internals.setFormValue(val);
|
|
76
|
+
this.#runConstraints(val);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ── Manual validation control ──
|
|
80
|
+
|
|
81
|
+
/** Clear all validation errors. */
|
|
82
|
+
setValid() {
|
|
83
|
+
this.internals.setValidity({});
|
|
84
|
+
this.removeAttribute('aria-invalid');
|
|
85
|
+
if (this.error) this.error = '';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Set a custom validation error. */
|
|
89
|
+
setInvalid(message, anchor) {
|
|
90
|
+
this.internals.setValidity({ customError: true }, message || 'Invalid', anchor || this);
|
|
91
|
+
this.setAttribute('aria-invalid', 'true');
|
|
92
|
+
this.error = message || 'Invalid';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Run validation and surface errors. Returns boolean. */
|
|
96
|
+
validate() {
|
|
97
|
+
const valid = this.#runConstraints(this.value ?? '');
|
|
98
|
+
if (!valid) {
|
|
99
|
+
this.setAttribute('aria-invalid', 'true');
|
|
100
|
+
this.error = this.validationMessage;
|
|
101
|
+
} else {
|
|
102
|
+
this.removeAttribute('aria-invalid');
|
|
103
|
+
if (this.error) this.error = '';
|
|
104
|
+
}
|
|
105
|
+
return valid;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ── Constraint engine ──
|
|
109
|
+
|
|
110
|
+
#runConstraints(val) {
|
|
111
|
+
val = val ?? this.value ?? '';
|
|
112
|
+
const str = String(val);
|
|
113
|
+
|
|
114
|
+
if (this.required && !str.trim()) {
|
|
115
|
+
this.internals.setValidity(
|
|
116
|
+
{ valueMissing: true },
|
|
117
|
+
this.getAttribute('data-msg-required') || 'This field is required.',
|
|
118
|
+
this,
|
|
119
|
+
);
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (this.pattern && str) {
|
|
124
|
+
try {
|
|
125
|
+
if (!new RegExp(`^(?:${this.pattern})$`).test(str)) {
|
|
126
|
+
this.internals.setValidity(
|
|
127
|
+
{ patternMismatch: true },
|
|
128
|
+
this.getAttribute('data-msg-pattern') || 'Please match the requested format.',
|
|
129
|
+
this,
|
|
130
|
+
);
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
} catch {}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (this.minlength != null && this.minlength > 0 && str.length > 0 && str.length < this.minlength) {
|
|
137
|
+
this.internals.setValidity(
|
|
138
|
+
{ tooShort: true },
|
|
139
|
+
this.getAttribute('data-msg-minlength') || `Please use at least ${this.minlength} characters.`,
|
|
140
|
+
this,
|
|
141
|
+
);
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (this.maxlength != null && this.maxlength > 0 && str.length > this.maxlength) {
|
|
146
|
+
this.internals.setValidity(
|
|
147
|
+
{ tooLong: true },
|
|
148
|
+
this.getAttribute('data-msg-maxlength') || `Please use no more than ${this.maxlength} characters.`,
|
|
149
|
+
this,
|
|
150
|
+
);
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.internals.setValidity({});
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ── Auto-validation listeners ──
|
|
159
|
+
|
|
160
|
+
#onInvalid = (e) => {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
this.setAttribute('aria-invalid', 'true');
|
|
163
|
+
this.error = this.validationMessage;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
#onInput = () => {
|
|
167
|
+
this.#dirty = true;
|
|
168
|
+
if (this.error) this.validate();
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
#onBlur = () => {
|
|
172
|
+
if (this.#dirty) this.validate();
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
connected() {
|
|
176
|
+
super.connected();
|
|
177
|
+
this.syncValue();
|
|
178
|
+
this.addEventListener('invalid', this.#onInvalid);
|
|
179
|
+
this.addEventListener('input', this.#onInput);
|
|
180
|
+
this.addEventListener('blur', this.#onBlur, true);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
disconnected() {
|
|
184
|
+
super.disconnected();
|
|
185
|
+
this.removeEventListener('invalid', this.#onInvalid);
|
|
186
|
+
this.removeEventListener('input', this.#onInput);
|
|
187
|
+
this.removeEventListener('blur', this.#onBlur, true);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// ── Form lifecycle callbacks ──
|
|
191
|
+
|
|
192
|
+
formResetCallback() {
|
|
193
|
+
this.#dirty = false;
|
|
194
|
+
this.setValid();
|
|
195
|
+
this.onFormReset();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
formDisabledCallback(disabled) {
|
|
199
|
+
this.disabled = disabled;
|
|
200
|
+
this.onFormDisabled(disabled);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
formAssociatedCallback(form) {
|
|
204
|
+
this.onFormAssociated(form);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
formStateRestoreCallback(state, reason) {
|
|
208
|
+
this.onFormStateRestore(state, reason);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ── Override points ──
|
|
212
|
+
|
|
213
|
+
onFormReset() {}
|
|
214
|
+
onFormDisabled(_disabled) {}
|
|
215
|
+
onFormAssociated(_form) {}
|
|
216
|
+
onFormStateRestore(_state, _reason) {}
|
|
217
|
+
}
|
package/core/icons.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icon Registry — loads SVGs from @phosphor-icons/core.
|
|
3
|
+
* All icons are loaded on-demand; each weight variant is cached separately.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* <icon-ui name="paper-plane-right"></icon-ui>
|
|
7
|
+
* <icon-ui name="star" weight="fill"></icon-ui>
|
|
8
|
+
* <icon-ui name="heart" weight="bold"></icon-ui>
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const ICON_WEIGHTS = ['regular', 'thin', 'light', 'bold', 'fill', 'duotone'];
|
|
12
|
+
const DEFAULT_WEIGHT = 'regular';
|
|
13
|
+
|
|
14
|
+
/** Composite cache key so `star@regular` and `star@fill` can coexist. */
|
|
15
|
+
const cacheKey = (name, weight) => `${weight}:${name}`;
|
|
16
|
+
|
|
17
|
+
const registry = new Map();
|
|
18
|
+
const pending = new Set();
|
|
19
|
+
|
|
20
|
+
/** Register a single icon. */
|
|
21
|
+
export function registerIcon(name, svg, weight = DEFAULT_WEIGHT) {
|
|
22
|
+
registry.set(cacheKey(name, weight), svg);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Register multiple icons at a given weight. */
|
|
26
|
+
export function registerIcons(icons, weight = DEFAULT_WEIGHT) {
|
|
27
|
+
for (const [name, svg] of Object.entries(icons)) {
|
|
28
|
+
registry.set(cacheKey(name, weight), svg);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Get icon SVG by name + weight. Triggers async load if not cached. */
|
|
33
|
+
export function getIcon(name, weight = DEFAULT_WEIGHT) {
|
|
34
|
+
if (!name) return '';
|
|
35
|
+
const key = cacheKey(name, weight);
|
|
36
|
+
if (registry.has(key)) return registry.get(key);
|
|
37
|
+
|
|
38
|
+
loadIcon(name, weight);
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Check if an icon is registered (sync). */
|
|
43
|
+
export function hasIcon(name, weight = DEFAULT_WEIGHT) {
|
|
44
|
+
return registry.has(cacheKey(name, weight));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Get all registered icon keys. */
|
|
48
|
+
export function listIcons() {
|
|
49
|
+
return [...registry.keys()];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ── Async loader ──
|
|
53
|
+
|
|
54
|
+
// Vite resolves each glob at build time into a map of path → module.
|
|
55
|
+
// One glob per weight so the bundler can tree-shake what isn't referenced.
|
|
56
|
+
const weightModules = {
|
|
57
|
+
regular: import.meta.glob('/node_modules/@phosphor-icons/core/assets/regular/*.svg', { query: '?raw', import: 'default' }),
|
|
58
|
+
thin: import.meta.glob('/node_modules/@phosphor-icons/core/assets/thin/*.svg', { query: '?raw', import: 'default' }),
|
|
59
|
+
light: import.meta.glob('/node_modules/@phosphor-icons/core/assets/light/*.svg', { query: '?raw', import: 'default' }),
|
|
60
|
+
bold: import.meta.glob('/node_modules/@phosphor-icons/core/assets/bold/*.svg', { query: '?raw', import: 'default' }),
|
|
61
|
+
fill: import.meta.glob('/node_modules/@phosphor-icons/core/assets/fill/*.svg', { query: '?raw', import: 'default' }),
|
|
62
|
+
duotone: import.meta.glob('/node_modules/@phosphor-icons/core/assets/duotone/*.svg', { query: '?raw', import: 'default' }),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Phosphor filename convention: `star.svg` for regular, `star-fill.svg` for
|
|
67
|
+
* fill, `star-bold.svg` for bold, etc. (each non-regular weight suffixes the
|
|
68
|
+
* weight to the filename).
|
|
69
|
+
*/
|
|
70
|
+
function filenameFor(name, weight) {
|
|
71
|
+
if (weight === 'regular') return `${name}.svg`;
|
|
72
|
+
return `${name}-${weight}.svg`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function resolveLoader(name, weight = DEFAULT_WEIGHT) {
|
|
76
|
+
const modules = weightModules[weight];
|
|
77
|
+
if (!modules) return null;
|
|
78
|
+
const key = `/node_modules/@phosphor-icons/core/assets/${weight}/${filenameFor(name, weight)}`;
|
|
79
|
+
if (modules[key]) return modules[key];
|
|
80
|
+
|
|
81
|
+
// Back-compat: allow the caller to put the -fill suffix directly in the
|
|
82
|
+
// name (e.g. `name="circle-fill"`) without specifying weight.
|
|
83
|
+
if (weight === DEFAULT_WEIGHT && name.endsWith('-fill')) {
|
|
84
|
+
const fillKey = `/node_modules/@phosphor-icons/core/assets/fill/${name}.svg`;
|
|
85
|
+
if (weightModules.fill[fillKey]) return weightModules.fill[fillKey];
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Sync check: is `name` a loadable icon at the given weight? True if the
|
|
92
|
+
* asset exists in the build-time glob OR has an alias that does. Does NOT
|
|
93
|
+
* trigger loading. Used by components that accept either an icon name or a
|
|
94
|
+
* text label (e.g. input-ui's prefix/suffix) to disambiguate.
|
|
95
|
+
*/
|
|
96
|
+
export function isIconName(name, weight = DEFAULT_WEIGHT) {
|
|
97
|
+
if (!name || typeof name !== 'string') return false;
|
|
98
|
+
if (resolveLoader(name, weight)) return true;
|
|
99
|
+
const alias = ICON_ALIASES[name];
|
|
100
|
+
if (alias && resolveLoader(alias, weight)) return true;
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Common aliases — brand names without -logo suffix
|
|
105
|
+
const ICON_ALIASES = {
|
|
106
|
+
// Brand logos (LLMs often omit -logo suffix)
|
|
107
|
+
'google': 'google-logo', 'github': 'github-logo', 'microsoft': 'windows-logo',
|
|
108
|
+
'apple': 'apple-logo', 'twitter': 'twitter-logo', 'facebook': 'facebook-logo',
|
|
109
|
+
'discord': 'discord-logo', 'slack': 'slack-logo', 'linkedin': 'linkedin-logo',
|
|
110
|
+
'youtube': 'youtube-logo', 'instagram': 'instagram-logo', 'figma': 'figma-logo',
|
|
111
|
+
'dribbble': 'dribbble-logo', 'stripe': 'stripe-logo', 'paypal': 'paypal-logo',
|
|
112
|
+
// Common LLM-generated names that don't match Phosphor
|
|
113
|
+
'alert-circle': 'warning-circle', 'alert': 'warning', 'error': 'x-circle',
|
|
114
|
+
'success': 'check-circle', 'close': 'x', 'delete': 'trash',
|
|
115
|
+
'edit': 'pencil-simple', 'save': 'floppy-disk', 'search': 'magnifying-glass',
|
|
116
|
+
'settings': 'gear', 'home': 'house', 'mail': 'envelope', 'email': 'envelope',
|
|
117
|
+
'phone': 'phone', 'location': 'map-pin', 'calendar': 'calendar-blank',
|
|
118
|
+
'time': 'clock', 'user': 'user', 'users': 'users-three',
|
|
119
|
+
'menu': 'list', 'more': 'dots-three', 'dots-vertical': 'dots-three-vertical', 'filter': 'funnel',
|
|
120
|
+
'sort': 'sort-ascending', 'refresh': 'arrow-clockwise', 'download': 'download-simple',
|
|
121
|
+
'upload': 'upload-simple', 'share': 'share-network', 'copy': 'copy-simple',
|
|
122
|
+
'link': 'link-simple', 'external-link': 'arrow-square-out',
|
|
123
|
+
'chevron-down': 'caret-down', 'chevron-up': 'caret-up',
|
|
124
|
+
'chevron-left': 'caret-left', 'chevron-right': 'caret-right',
|
|
125
|
+
'arrow-left': 'arrow-left', 'arrow-right': 'arrow-right',
|
|
126
|
+
'plus': 'plus', 'minus': 'minus',
|
|
127
|
+
'send': 'paper-plane-right', 'submit': 'paper-plane-right',
|
|
128
|
+
'attachment': 'paperclip', 'attach': 'paperclip',
|
|
129
|
+
'expand': 'arrows-out', 'collapse': 'arrows-in',
|
|
130
|
+
'fullscreen': 'arrows-out', 'exit-fullscreen': 'arrows-in',
|
|
131
|
+
'notification': 'bell', 'notifications': 'bell',
|
|
132
|
+
'bookmark': 'bookmark-simple', 'favorite': 'heart', 'like': 'heart',
|
|
133
|
+
'comment': 'chat-circle', 'chat': 'chat-circle',
|
|
134
|
+
'image': 'image', 'photo': 'image', 'picture': 'image',
|
|
135
|
+
'video': 'video-camera', 'camera': 'camera',
|
|
136
|
+
'file': 'file', 'document': 'file-text', 'folder': 'folder',
|
|
137
|
+
'lock': 'lock-simple', 'unlock': 'lock-simple-open',
|
|
138
|
+
'eye-off': 'eye-slash', 'hide': 'eye-slash', 'show': 'eye',
|
|
139
|
+
'logout': 'sign-out', 'login': 'sign-in',
|
|
140
|
+
// Shape primitives — useful as visual markers (legend dots, status pips,
|
|
141
|
+
// bullet substitutes). Default to filled variants since unfilled circles
|
|
142
|
+
// tend to read as outlined buttons rather than markers.
|
|
143
|
+
'dot': 'circle-fill', 'circle': 'circle-fill', 'marker': 'circle-fill',
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
async function loadIcon(name, weight = DEFAULT_WEIGHT) {
|
|
147
|
+
const key = cacheKey(name, weight);
|
|
148
|
+
if (pending.has(key)) return;
|
|
149
|
+
pending.add(key);
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
let loader = resolveLoader(name, weight);
|
|
153
|
+
|
|
154
|
+
// Try alias if direct name not found
|
|
155
|
+
if (!loader && ICON_ALIASES[name]) {
|
|
156
|
+
loader = resolveLoader(ICON_ALIASES[name], weight);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (!loader) {
|
|
160
|
+
pending.delete(key);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const svg = await loader();
|
|
165
|
+
registry.set(key, svg);
|
|
166
|
+
|
|
167
|
+
// Re-render any icon-ui elements showing this name+weight. Regular has
|
|
168
|
+
// no explicit weight attr, so match both forms.
|
|
169
|
+
const selector = weight === DEFAULT_WEIGHT
|
|
170
|
+
? `icon-ui[name="${name}"]:not([weight]), icon-ui[name="${name}"][weight="regular"]`
|
|
171
|
+
: `icon-ui[name="${name}"][weight="${weight}"]`;
|
|
172
|
+
for (const el of document.querySelectorAll(selector)) {
|
|
173
|
+
el.innerHTML = svg;
|
|
174
|
+
}
|
|
175
|
+
} catch {
|
|
176
|
+
// Icon not found — stays blank
|
|
177
|
+
} finally {
|
|
178
|
+
pending.delete(key);
|
|
179
|
+
}
|
|
180
|
+
}
|
package/core/markdown.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal markdown → HTML for LLM output.
|
|
3
|
+
* Handles: code blocks, inline code, bold, italic, links, lists, headings, paragraphs.
|
|
4
|
+
* No dependencies. ~80 lines.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* import { renderMarkdown } from '@core/markdown.js';
|
|
8
|
+
* element.innerHTML = renderMarkdown(text);
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const ESC = { '&': '&', '<': '<', '>': '>', '"': '"' };
|
|
12
|
+
const esc = (s) => s.replace(/[&<>"]/g, (c) => ESC[c]);
|
|
13
|
+
|
|
14
|
+
export function renderMarkdown(src) {
|
|
15
|
+
const lines = src.split('\n');
|
|
16
|
+
const out = [];
|
|
17
|
+
let i = 0;
|
|
18
|
+
|
|
19
|
+
while (i < lines.length) {
|
|
20
|
+
const line = lines[i];
|
|
21
|
+
|
|
22
|
+
// Fenced code block
|
|
23
|
+
const fence = line.match(/^```(\w*)/);
|
|
24
|
+
if (fence) {
|
|
25
|
+
const lang = fence[1];
|
|
26
|
+
const code = [];
|
|
27
|
+
i++;
|
|
28
|
+
while (i < lines.length && !lines[i].startsWith('```')) {
|
|
29
|
+
code.push(esc(lines[i]));
|
|
30
|
+
i++;
|
|
31
|
+
}
|
|
32
|
+
i++; // skip closing ```
|
|
33
|
+
out.push(`<pre><code${lang ? ` data-lang="${lang}"` : ''}>${code.join('\n')}</code></pre>`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Empty line
|
|
38
|
+
if (!line.trim()) { i++; continue; }
|
|
39
|
+
|
|
40
|
+
// Heading
|
|
41
|
+
const h = line.match(/^(#{1,6})\s+(.+)/);
|
|
42
|
+
if (h) {
|
|
43
|
+
const level = h[1].length;
|
|
44
|
+
out.push(`<h${level}>${inline(h[2])}</h${level}>`);
|
|
45
|
+
i++;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Unordered list
|
|
50
|
+
if (/^[-*]\s/.test(line)) {
|
|
51
|
+
const items = [];
|
|
52
|
+
while (i < lines.length && /^[-*]\s/.test(lines[i])) {
|
|
53
|
+
items.push(`<li>${inline(lines[i].replace(/^[-*]\s/, ''))}</li>`);
|
|
54
|
+
i++;
|
|
55
|
+
}
|
|
56
|
+
out.push(`<ul>${items.join('')}</ul>`);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Ordered list
|
|
61
|
+
if (/^\d+\.\s/.test(line)) {
|
|
62
|
+
const items = [];
|
|
63
|
+
while (i < lines.length && /^\d+\.\s/.test(lines[i])) {
|
|
64
|
+
items.push(`<li>${inline(lines[i].replace(/^\d+\.\s/, ''))}</li>`);
|
|
65
|
+
i++;
|
|
66
|
+
}
|
|
67
|
+
out.push(`<ol>${items.join('')}</ol>`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Paragraph (collect consecutive non-empty, non-special lines)
|
|
72
|
+
const para = [];
|
|
73
|
+
while (i < lines.length && lines[i].trim() && !/^```|^#{1,6}\s|^[-*]\s|^\d+\.\s/.test(lines[i])) {
|
|
74
|
+
para.push(lines[i]);
|
|
75
|
+
i++;
|
|
76
|
+
}
|
|
77
|
+
out.push(`<p>${inline(para.join(' '))}</p>`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return out.join('\n');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function inline(text) {
|
|
84
|
+
return esc(text)
|
|
85
|
+
// Bold **text** or __text__
|
|
86
|
+
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
|
|
87
|
+
.replace(/__(.+?)__/g, '<strong>$1</strong>')
|
|
88
|
+
// Italic *text* or _text_
|
|
89
|
+
.replace(/\*(.+?)\*/g, '<em>$1</em>')
|
|
90
|
+
.replace(/_(.+?)_/g, '<em>$1</em>')
|
|
91
|
+
// Inline code `code`
|
|
92
|
+
.replace(/`([^`]+)`/g, '<code>$1</code>')
|
|
93
|
+
// Links [text](url)
|
|
94
|
+
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
|
|
95
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdiaUI Polyfills — conditional loading for missing platform features.
|
|
3
|
+
* Import BEFORE component registration.
|
|
4
|
+
*
|
|
5
|
+
* Currently polyfills:
|
|
6
|
+
* - Popover API (Firefox < 125)
|
|
7
|
+
* - CSS Anchor Positioning (only Chrome 125+ native)
|
|
8
|
+
*
|
|
9
|
+
* Both are loaded conditionally — browsers with native support skip the download.
|
|
10
|
+
* Packages are optional — if not installed, the import silently fails.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
// Popover API
|
|
15
|
+
if (!('popover' in HTMLElement.prototype)) {
|
|
16
|
+
import('@oddbird/popover-polyfill').catch(() => {});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// CSS Anchor Positioning
|
|
20
|
+
if (!CSS?.supports?.('anchor-name: --x')) {
|
|
21
|
+
import('@oddbird/css-anchor-positioning').catch(() => {});
|
|
22
|
+
}
|
|
23
|
+
}
|