@antheo/morph 0.0.0-stage → 0.3.0
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/LICENSE +21 -0
- package/README.md +266 -2
- package/SKILL.md +61 -0
- package/dist/ai/cli-provider.d.ts +80 -0
- package/dist/ai/cli-provider.js +250 -0
- package/dist/ai/gate.d.ts +39 -0
- package/dist/ai/gate.js +124 -0
- package/dist/ai/provider.d.ts +36 -0
- package/dist/ai/provider.js +168 -0
- package/dist/ai/repair.d.ts +90 -0
- package/dist/ai/repair.js +172 -0
- package/dist/analyzer/deps.d.ts +30 -0
- package/dist/analyzer/deps.js +265 -0
- package/dist/analyzer/manifest.d.ts +5 -0
- package/dist/analyzer/manifest.js +119 -0
- package/dist/analyzer/parse.d.ts +21 -0
- package/dist/analyzer/parse.js +29 -0
- package/dist/batch-worker.d.ts +16 -0
- package/dist/batch-worker.js +10 -0
- package/dist/batch.d.ts +26 -0
- package/dist/batch.js +227 -0
- package/dist/bridge/index.d.ts +26 -0
- package/dist/bridge/index.js +138 -0
- package/dist/bridge/props.d.ts +56 -0
- package/dist/bridge/props.js +191 -0
- package/dist/bridge/wrappers.d.ts +24 -0
- package/dist/bridge/wrappers.js +276 -0
- package/dist/cli/format.d.ts +7 -0
- package/dist/cli/format.js +30 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +492 -0
- package/dist/fonts/carry.d.ts +34 -0
- package/dist/fonts/carry.js +113 -0
- package/dist/fonts/fallback.d.ts +11 -0
- package/dist/fonts/fallback.js +21 -0
- package/dist/fonts/google.d.ts +65 -0
- package/dist/fonts/google.js +343 -0
- package/dist/fonts/index.d.ts +27 -0
- package/dist/fonts/index.js +48 -0
- package/dist/fonts/local.d.ts +46 -0
- package/dist/fonts/local.js +150 -0
- package/dist/fonts/sfnt.d.ts +19 -0
- package/dist/fonts/sfnt.js +174 -0
- package/dist/fonts/shim.d.ts +14 -0
- package/dist/fonts/shim.js +96 -0
- package/dist/gate.d.ts +105 -0
- package/dist/gate.js +157 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +74 -0
- package/dist/ir/annotate.d.ts +16 -0
- package/dist/ir/annotate.js +145 -0
- package/dist/ir/as-child.d.ts +18 -0
- package/dist/ir/as-child.js +239 -0
- package/dist/ir/compounds.d.ts +27 -0
- package/dist/ir/compounds.js +183 -0
- package/dist/ir/contexts.d.ts +26 -0
- package/dist/ir/contexts.js +185 -0
- package/dist/ir/dom.d.ts +11 -0
- package/dist/ir/dom.js +60 -0
- package/dist/ir/effect-returns.d.ts +10 -0
- package/dist/ir/effect-returns.js +25 -0
- package/dist/ir/extract-ui-types.d.ts +33 -0
- package/dist/ir/extract-ui-types.js +224 -0
- package/dist/ir/extract-ui.d.ts +34 -0
- package/dist/ir/extract-ui.js +567 -0
- package/dist/ir/falsy.d.ts +13 -0
- package/dist/ir/falsy.js +66 -0
- package/dist/ir/forward-refs.d.ts +11 -0
- package/dist/ir/forward-refs.js +155 -0
- package/dist/ir/fragment-source.d.ts +4 -0
- package/dist/ir/fragment-source.js +13 -0
- package/dist/ir/fragments.d.ts +32 -0
- package/dist/ir/fragments.js +192 -0
- package/dist/ir/helper-snippets.d.ts +30 -0
- package/dist/ir/helper-snippets.js +550 -0
- package/dist/ir/latest-refs.d.ts +11 -0
- package/dist/ir/latest-refs.js +187 -0
- package/dist/ir/live-args.d.ts +26 -0
- package/dist/ir/live-args.js +335 -0
- package/dist/ir/lower.d.ts +83 -0
- package/dist/ir/lower.js +6016 -0
- package/dist/ir/markup-values.d.ts +16 -0
- package/dist/ir/markup-values.js +188 -0
- package/dist/ir/model.d.ts +605 -0
- package/dist/ir/model.js +1 -0
- package/dist/ir/oracle.d.ts +91 -0
- package/dist/ir/oracle.js +610 -0
- package/dist/ir/radix.d.ts +122 -0
- package/dist/ir/radix.js +344 -0
- package/dist/ir/rename.d.ts +15 -0
- package/dist/ir/rename.js +151 -0
- package/dist/ir/render-props.d.ts +31 -0
- package/dist/ir/render-props.js +67 -0
- package/dist/ir/rewrite.d.ts +44 -0
- package/dist/ir/rewrite.js +381 -0
- package/dist/ir/running-index.d.ts +11 -0
- package/dist/ir/running-index.js +217 -0
- package/dist/ir/snapshots.d.ts +12 -0
- package/dist/ir/snapshots.js +140 -0
- package/dist/ir/style.d.ts +19 -0
- package/dist/ir/style.js +76 -0
- package/dist/ir/types.d.ts +42 -0
- package/dist/ir/types.js +271 -0
- package/dist/ir/walk.d.ts +11 -0
- package/dist/ir/walk.js +18 -0
- package/dist/mcp/server.d.ts +81 -0
- package/dist/mcp/server.js +518 -0
- package/dist/pipeline.d.ts +26 -0
- package/dist/pipeline.js +750 -0
- package/dist/registry/add.d.ts +91 -0
- package/dist/registry/add.js +273 -0
- package/dist/registry/fetch.d.ts +40 -0
- package/dist/registry/fetch.js +186 -0
- package/dist/registry/ip.d.ts +18 -0
- package/dist/registry/ip.js +153 -0
- package/dist/registry/item.d.ts +39 -0
- package/dist/registry/item.js +131 -0
- package/dist/registry/load.d.ts +35 -0
- package/dist/registry/load.js +106 -0
- package/dist/registry/paths.d.ts +8 -0
- package/dist/registry/paths.js +43 -0
- package/dist/registry/publish.d.ts +119 -0
- package/dist/registry/publish.js +439 -0
- package/dist/targets/angular/bank/bank.d.ts +39 -0
- package/dist/targets/angular/bank/bank.js +61 -0
- package/dist/targets/angular/bank/helpers.d.ts +64 -0
- package/dist/targets/angular/bank/helpers.js +246 -0
- package/dist/targets/angular/bank/kept.d.ts +98 -0
- package/dist/targets/angular/bank/kept.js +791 -0
- package/dist/targets/angular/bank/plan-helpers.d.ts +17 -0
- package/dist/targets/angular/bank/plan-helpers.js +286 -0
- package/dist/targets/angular/bank/plan.d.ts +22 -0
- package/dist/targets/angular/bank/plan.js +152 -0
- package/dist/targets/angular/bank/receivers.d.ts +66 -0
- package/dist/targets/angular/bank/receivers.js +293 -0
- package/dist/targets/angular/bank/runtime.d.ts +14 -0
- package/dist/targets/angular/bank/runtime.js +152 -0
- package/dist/targets/angular/controlled.d.ts +7 -0
- package/dist/targets/angular/controlled.js +37 -0
- package/dist/targets/angular/dynamic-tags.d.ts +34 -0
- package/dist/targets/angular/dynamic-tags.js +192 -0
- package/dist/targets/angular/emit.d.ts +41 -0
- package/dist/targets/angular/emit.js +5970 -0
- package/dist/targets/angular/exports.d.ts +48 -0
- package/dist/targets/angular/exports.js +243 -0
- package/dist/targets/angular/helpers.d.ts +15 -0
- package/dist/targets/angular/helpers.js +33 -0
- package/dist/targets/angular/host-boundary.d.ts +5 -0
- package/dist/targets/angular/host-boundary.js +166 -0
- package/dist/targets/angular/host-form.d.ts +150 -0
- package/dist/targets/angular/host-form.js +727 -0
- package/dist/targets/angular/markup-values.d.ts +58 -0
- package/dist/targets/angular/markup-values.js +661 -0
- package/dist/targets/angular/motion-directive.d.ts +12 -0
- package/dist/targets/angular/motion-directive.js +257 -0
- package/dist/targets/angular/motion-hooks.d.ts +73 -0
- package/dist/targets/angular/motion-hooks.js +293 -0
- package/dist/targets/angular/motion-layout.d.ts +14 -0
- package/dist/targets/angular/motion-layout.js +74 -0
- package/dist/targets/angular/motion-templates.d.ts +10 -0
- package/dist/targets/angular/motion-templates.js +65 -0
- package/dist/targets/angular/motion.d.ts +57 -0
- package/dist/targets/angular/motion.js +202 -0
- package/dist/targets/angular/narrowing.d.ts +24 -0
- package/dist/targets/angular/narrowing.js +205 -0
- package/dist/targets/angular/ngc.d.ts +23 -0
- package/dist/targets/angular/ngc.js +134 -0
- package/dist/targets/angular/passed-handle.d.ts +39 -0
- package/dist/targets/angular/passed-handle.js +154 -0
- package/dist/targets/angular/projected.d.ts +9 -0
- package/dist/targets/angular/projected.js +63 -0
- package/dist/targets/angular/radix/cores/alert-dialog.d.ts +13 -0
- package/dist/targets/angular/radix/cores/alert-dialog.js +388 -0
- package/dist/targets/angular/radix/cores/index.d.ts +17 -0
- package/dist/targets/angular/radix/cores/index.js +50 -0
- package/dist/targets/angular/radix/cores/slider.d.ts +8 -0
- package/dist/targets/angular/radix/cores/slider.js +202 -0
- package/dist/targets/angular/radix/index.d.ts +21 -0
- package/dist/targets/angular/radix/index.js +35 -0
- package/dist/targets/angular/radix/packages.d.ts +3 -0
- package/dist/targets/angular/radix/packages.js +558 -0
- package/dist/targets/angular/radix/part.d.ts +236 -0
- package/dist/targets/angular/radix/part.js +71 -0
- package/dist/targets/angular/radix/prepare.d.ts +66 -0
- package/dist/targets/angular/radix/prepare.js +548 -0
- package/dist/targets/angular/radix/template.d.ts +43 -0
- package/dist/targets/angular/radix/template.js +172 -0
- package/dist/targets/angular/refs.d.ts +68 -0
- package/dist/targets/angular/refs.js +443 -0
- package/dist/targets/angular/slots.d.ts +22 -0
- package/dist/targets/angular/slots.js +60 -0
- package/dist/targets/angular/source-types.d.ts +10 -0
- package/dist/targets/angular/source-types.js +45 -0
- package/dist/targets/angular/spread-forward.d.ts +24 -0
- package/dist/targets/angular/spread-forward.js +72 -0
- package/dist/targets/angular/spread.d.ts +32 -0
- package/dist/targets/angular/spread.js +182 -0
- package/dist/targets/angular/svg-hosts.d.ts +25 -0
- package/dist/targets/angular/svg-hosts.js +107 -0
- package/dist/targets/angular/template-expr.d.ts +36 -0
- package/dist/targets/angular/template-expr.js +287 -0
- package/dist/targets/angular/types.d.ts +9 -0
- package/dist/targets/angular/types.js +63 -0
- package/dist/targets/angular/walk.d.ts +11 -0
- package/dist/targets/angular/walk.js +26 -0
- package/dist/targets/react-native/emit.d.ts +14 -0
- package/dist/targets/react-native/emit.js +585 -0
- package/dist/targets/react-native/fidelity.d.ts +5 -0
- package/dist/targets/react-native/fidelity.js +43 -0
- package/dist/targets/react-native/motion.d.ts +10 -0
- package/dist/targets/react-native/motion.js +290 -0
- package/dist/targets/react-native/skia.d.ts +30 -0
- package/dist/targets/react-native/skia.js +358 -0
- package/dist/targets/shared/context.d.ts +47 -0
- package/dist/targets/shared/context.js +195 -0
- package/dist/targets/shared/foreign.d.ts +10 -0
- package/dist/targets/shared/foreign.js +72 -0
- package/dist/targets/shared/fragments.d.ts +21 -0
- package/dist/targets/shared/fragments.js +309 -0
- package/dist/targets/shared/handles.d.ts +65 -0
- package/dist/targets/shared/handles.js +299 -0
- package/dist/targets/shared/inline.d.ts +53 -0
- package/dist/targets/shared/inline.js +524 -0
- package/dist/targets/shared/layout.d.ts +70 -0
- package/dist/targets/shared/layout.js +224 -0
- package/dist/targets/shared/markup.d.ts +26 -0
- package/dist/targets/shared/markup.js +65 -0
- package/dist/targets/shared/module.d.ts +84 -0
- package/dist/targets/shared/module.js +468 -0
- package/dist/targets/shared/motion-hooks.d.ts +37 -0
- package/dist/targets/shared/motion-hooks.js +87 -0
- package/dist/targets/shared/motion-layout.d.ts +70 -0
- package/dist/targets/shared/motion-layout.js +392 -0
- package/dist/targets/shared/portal.d.ts +10 -0
- package/dist/targets/shared/portal.js +23 -0
- package/dist/targets/shared/prop-writes.d.ts +11 -0
- package/dist/targets/shared/prop-writes.js +32 -0
- package/dist/targets/shared/prune.d.ts +54 -0
- package/dist/targets/shared/prune.js +405 -0
- package/dist/targets/shared/react-libs.d.ts +25 -0
- package/dist/targets/shared/react-libs.js +142 -0
- package/dist/targets/shared/react-types.d.ts +16 -0
- package/dist/targets/shared/react-types.js +374 -0
- package/dist/targets/shared/react-values.d.ts +20 -0
- package/dist/targets/shared/react-values.js +145 -0
- package/dist/targets/shared/ref-callback.d.ts +16 -0
- package/dist/targets/shared/ref-callback.js +114 -0
- package/dist/targets/shared/script.d.ts +65 -0
- package/dist/targets/shared/script.js +406 -0
- package/dist/targets/shared/unused.d.ts +12 -0
- package/dist/targets/shared/unused.js +146 -0
- package/dist/targets/svelte/dom-spread.d.ts +27 -0
- package/dist/targets/svelte/dom-spread.js +146 -0
- package/dist/targets/svelte/emit.d.ts +15 -0
- package/dist/targets/svelte/emit.js +3784 -0
- package/dist/targets/svelte/handle-branches.d.ts +22 -0
- package/dist/targets/svelte/handle-branches.js +146 -0
- package/dist/targets/svelte/html-keys.d.ts +9 -0
- package/dist/targets/svelte/html-keys.js +40 -0
- package/dist/targets/svelte/markup-data/data.d.ts +51 -0
- package/dist/targets/svelte/markup-data/data.js +305 -0
- package/dist/targets/svelte/markup-data/helper.d.ts +12 -0
- package/dist/targets/svelte/markup-data/helper.js +81 -0
- package/dist/targets/svelte/markup-data/module-data.d.ts +21 -0
- package/dist/targets/svelte/markup-data/module-data.js +473 -0
- package/dist/targets/svelte/markup-data/sites.d.ts +52 -0
- package/dist/targets/svelte/markup-data/sites.js +303 -0
- package/dist/targets/svelte/motion-layout.d.ts +13 -0
- package/dist/targets/svelte/motion-layout.js +70 -0
- package/dist/targets/svelte/motion-table.d.ts +14 -0
- package/dist/targets/svelte/motion-table.js +308 -0
- package/dist/targets/svelte/motion.d.ts +46 -0
- package/dist/targets/svelte/motion.js +405 -0
- package/dist/targets/svelte/presence.d.ts +71 -0
- package/dist/targets/svelte/presence.js +318 -0
- package/dist/targets/svelte/radix/accordion.d.ts +9 -0
- package/dist/targets/svelte/radix/accordion.js +24 -0
- package/dist/targets/svelte/radix/aspect-ratio.d.ts +6 -0
- package/dist/targets/svelte/radix/aspect-ratio.js +8 -0
- package/dist/targets/svelte/radix/avatar.d.ts +6 -0
- package/dist/targets/svelte/radix/avatar.js +10 -0
- package/dist/targets/svelte/radix/checkbox.d.ts +10 -0
- package/dist/targets/svelte/radix/checkbox.js +24 -0
- package/dist/targets/svelte/radix/collapsible.d.ts +7 -0
- package/dist/targets/svelte/radix/collapsible.js +16 -0
- package/dist/targets/svelte/radix/context-menu.d.ts +8 -0
- package/dist/targets/svelte/radix/context-menu.js +49 -0
- package/dist/targets/svelte/radix/cores/alert-dialog.d.ts +17 -0
- package/dist/targets/svelte/radix/cores/alert-dialog.js +449 -0
- package/dist/targets/svelte/radix/cores/collapsible.d.ts +12 -0
- package/dist/targets/svelte/radix/cores/collapsible.js +214 -0
- package/dist/targets/svelte/radix/cores/core.d.ts +32 -0
- package/dist/targets/svelte/radix/cores/core.js +80 -0
- package/dist/targets/svelte/radix/cores/direction.d.ts +10 -0
- package/dist/targets/svelte/radix/cores/direction.js +64 -0
- package/dist/targets/svelte/radix/cores/index.d.ts +19 -0
- package/dist/targets/svelte/radix/cores/index.js +85 -0
- package/dist/targets/svelte/radix/cores/modal-layer.d.ts +11 -0
- package/dist/targets/svelte/radix/cores/modal-layer.js +244 -0
- package/dist/targets/svelte/radix/cores/presence.d.ts +12 -0
- package/dist/targets/svelte/radix/cores/presence.js +129 -0
- package/dist/targets/svelte/radix/cores/slider-logic.d.ts +10 -0
- package/dist/targets/svelte/radix/cores/slider-logic.js +287 -0
- package/dist/targets/svelte/radix/cores/slider.d.ts +13 -0
- package/dist/targets/svelte/radix/cores/slider.js +267 -0
- package/dist/targets/svelte/radix/dialog.d.ts +8 -0
- package/dist/targets/svelte/radix/dialog.js +20 -0
- package/dist/targets/svelte/radix/dropdown-menu.d.ts +9 -0
- package/dist/targets/svelte/radix/dropdown-menu.js +38 -0
- package/dist/targets/svelte/radix/emit.d.ts +12 -0
- package/dist/targets/svelte/radix/emit.js +1339 -0
- package/dist/targets/svelte/radix/hover-card.d.ts +7 -0
- package/dist/targets/svelte/radix/hover-card.js +22 -0
- package/dist/targets/svelte/radix/index.d.ts +12 -0
- package/dist/targets/svelte/radix/index.js +28 -0
- package/dist/targets/svelte/radix/label.d.ts +3 -0
- package/dist/targets/svelte/radix/label.js +5 -0
- package/dist/targets/svelte/radix/menubar.d.ts +7 -0
- package/dist/targets/svelte/radix/menubar.js +34 -0
- package/dist/targets/svelte/radix/navigation-menu.d.ts +8 -0
- package/dist/targets/svelte/radix/navigation-menu.js +25 -0
- package/dist/targets/svelte/radix/packages.d.ts +34 -0
- package/dist/targets/svelte/radix/packages.js +100 -0
- package/dist/targets/svelte/radix/part.d.ts +161 -0
- package/dist/targets/svelte/radix/part.js +85 -0
- package/dist/targets/svelte/radix/popover.d.ts +7 -0
- package/dist/targets/svelte/radix/popover.js +15 -0
- package/dist/targets/svelte/radix/progress.d.ts +11 -0
- package/dist/targets/svelte/radix/progress.js +27 -0
- package/dist/targets/svelte/radix/radio-group.d.ts +9 -0
- package/dist/targets/svelte/radix/radio-group.js +26 -0
- package/dist/targets/svelte/radix/scroll-area.d.ts +7 -0
- package/dist/targets/svelte/radix/scroll-area.js +19 -0
- package/dist/targets/svelte/radix/select.d.ts +13 -0
- package/dist/targets/svelte/radix/select.js +81 -0
- package/dist/targets/svelte/radix/separator.d.ts +3 -0
- package/dist/targets/svelte/radix/separator.js +5 -0
- package/dist/targets/svelte/radix/slider.d.ts +6 -0
- package/dist/targets/svelte/radix/slider.js +8 -0
- package/dist/targets/svelte/radix/switch.d.ts +6 -0
- package/dist/targets/svelte/radix/switch.js +10 -0
- package/dist/targets/svelte/radix/tabs.d.ts +8 -0
- package/dist/targets/svelte/radix/tabs.js +15 -0
- package/dist/targets/svelte/radix/toggle-group.d.ts +9 -0
- package/dist/targets/svelte/radix/toggle-group.js +17 -0
- package/dist/targets/svelte/radix/toggle.d.ts +6 -0
- package/dist/targets/svelte/radix/toggle.js +9 -0
- package/dist/targets/svelte/radix/tooltip.d.ts +6 -0
- package/dist/targets/svelte/radix/tooltip.js +24 -0
- package/dist/targets/svelte/strip.d.ts +2 -0
- package/dist/targets/svelte/strip.js +5 -0
- package/dist/targets/vue/emit.d.ts +15 -0
- package/dist/targets/vue/emit.js +4092 -0
- package/dist/targets/vue/events.d.ts +11 -0
- package/dist/targets/vue/events.js +13 -0
- package/dist/targets/vue/module-builders.d.ts +28 -0
- package/dist/targets/vue/module-builders.js +258 -0
- package/dist/targets/vue/motion-layout.d.ts +19 -0
- package/dist/targets/vue/motion-layout.js +79 -0
- package/dist/targets/vue/motion.d.ts +12 -0
- package/dist/targets/vue/motion.js +46 -0
- package/dist/targets/vue/radix/accordion.d.ts +3 -0
- package/dist/targets/vue/radix/accordion.js +12 -0
- package/dist/targets/vue/radix/alert-dialog.d.ts +6 -0
- package/dist/targets/vue/radix/alert-dialog.js +18 -0
- package/dist/targets/vue/radix/aspect-ratio.d.ts +6 -0
- package/dist/targets/vue/radix/aspect-ratio.js +8 -0
- package/dist/targets/vue/radix/avatar.d.ts +3 -0
- package/dist/targets/vue/radix/avatar.js +7 -0
- package/dist/targets/vue/radix/checkbox.d.ts +3 -0
- package/dist/targets/vue/radix/checkbox.js +9 -0
- package/dist/targets/vue/radix/collapsible.d.ts +7 -0
- package/dist/targets/vue/radix/collapsible.js +11 -0
- package/dist/targets/vue/radix/context-menu.d.ts +3 -0
- package/dist/targets/vue/radix/context-menu.js +30 -0
- package/dist/targets/vue/radix/dialog.d.ts +3 -0
- package/dist/targets/vue/radix/dialog.js +12 -0
- package/dist/targets/vue/radix/direction.d.ts +7 -0
- package/dist/targets/vue/radix/direction.js +9 -0
- package/dist/targets/vue/radix/dropdown-menu.d.ts +3 -0
- package/dist/targets/vue/radix/dropdown-menu.js +29 -0
- package/dist/targets/vue/radix/hover-card.d.ts +3 -0
- package/dist/targets/vue/radix/hover-card.js +11 -0
- package/dist/targets/vue/radix/index.d.ts +65 -0
- package/dist/targets/vue/radix/index.js +225 -0
- package/dist/targets/vue/radix/label.d.ts +3 -0
- package/dist/targets/vue/radix/label.js +5 -0
- package/dist/targets/vue/radix/menubar.d.ts +6 -0
- package/dist/targets/vue/radix/menubar.js +29 -0
- package/dist/targets/vue/radix/navigation-menu.d.ts +6 -0
- package/dist/targets/vue/radix/navigation-menu.js +21 -0
- package/dist/targets/vue/radix/part.d.ts +41 -0
- package/dist/targets/vue/radix/part.js +46 -0
- package/dist/targets/vue/radix/popover.d.ts +3 -0
- package/dist/targets/vue/radix/popover.js +11 -0
- package/dist/targets/vue/radix/progress.d.ts +3 -0
- package/dist/targets/vue/radix/progress.js +6 -0
- package/dist/targets/vue/radix/radio-group.d.ts +3 -0
- package/dist/targets/vue/radix/radio-group.js +10 -0
- package/dist/targets/vue/radix/scroll-area.d.ts +3 -0
- package/dist/targets/vue/radix/scroll-area.js +11 -0
- package/dist/targets/vue/radix/select.d.ts +3 -0
- package/dist/targets/vue/radix/select.js +29 -0
- package/dist/targets/vue/radix/separator.d.ts +3 -0
- package/dist/targets/vue/radix/separator.js +5 -0
- package/dist/targets/vue/radix/slider.d.ts +3 -0
- package/dist/targets/vue/radix/slider.js +13 -0
- package/dist/targets/vue/radix/switch.d.ts +3 -0
- package/dist/targets/vue/radix/switch.js +9 -0
- package/dist/targets/vue/radix/tabs.d.ts +3 -0
- package/dist/targets/vue/radix/tabs.js +12 -0
- package/dist/targets/vue/radix/toggle-group.d.ts +3 -0
- package/dist/targets/vue/radix/toggle-group.js +10 -0
- package/dist/targets/vue/radix/toggle.d.ts +3 -0
- package/dist/targets/vue/radix/toggle.js +8 -0
- package/dist/targets/vue/radix/tooltip.d.ts +3 -0
- package/dist/targets/vue/radix/tooltip.js +14 -0
- package/dist/targets/vue/render-fn/h.d.ts +52 -0
- package/dist/targets/vue/render-fn/h.js +442 -0
- package/dist/targets/vue/render-fn.d.ts +21 -0
- package/dist/targets/vue/render-fn.js +357 -0
- package/dist/targets/vue/slot.d.ts +9 -0
- package/dist/targets/vue/slot.js +57 -0
- package/dist/typecheck/host.d.ts +45 -0
- package/dist/typecheck/host.js +309 -0
- package/dist/typecheck/index.d.ts +16 -0
- package/dist/typecheck/index.js +17 -0
- package/dist/typecheck/lucide.d.ts +8 -0
- package/dist/typecheck/lucide.js +45 -0
- package/dist/typecheck/sourcemap.d.ts +9 -0
- package/dist/typecheck/sourcemap.js +54 -0
- package/dist/typecheck/svelte.d.ts +9 -0
- package/dist/typecheck/svelte.js +116 -0
- package/dist/typecheck/vue.d.ts +8 -0
- package/dist/typecheck/vue.js +78 -0
- package/dist/types.d.ts +446 -0
- package/dist/types.js +11 -0
- package/dist/utils/cleanup.d.ts +32 -0
- package/dist/utils/cleanup.js +119 -0
- package/dist/utils/errors.d.ts +7 -0
- package/dist/utils/errors.js +15 -0
- package/dist/utils/fs-safe.d.ts +14 -0
- package/dist/utils/fs-safe.js +64 -0
- package/dist/validate.d.ts +16 -0
- package/dist/validate.js +204 -0
- package/dist/verify/auto-steps.d.ts +107 -0
- package/dist/verify/auto-steps.js +471 -0
- package/dist/verify/bundle.d.ts +68 -0
- package/dist/verify/bundle.js +548 -0
- package/dist/verify/diff.d.ts +31 -0
- package/dist/verify/diff.js +133 -0
- package/dist/verify/leaks.d.ts +25 -0
- package/dist/verify/leaks.js +261 -0
- package/dist/verify/link-worker.d.ts +1 -0
- package/dist/verify/link-worker.js +27 -0
- package/dist/verify/runner.d.ts +57 -0
- package/dist/verify/runner.js +867 -0
- package/dist/verify/sandbox.d.ts +40 -0
- package/dist/verify/sandbox.js +496 -0
- package/dist/verify/steps.d.ts +42 -0
- package/dist/verify/steps.js +475 -0
- package/dist/verify/verdict.d.ts +15 -0
- package/dist/verify/verdict.js +19 -0
- package/package.json +118 -4
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radix's Presence (`@radix-ui/react-presence`, read from its installed source), as plain TypeScript with no framework:
|
|
3
|
+
* the state machine that keeps a part mounted while its exit animation runs. Written into the output by the Svelte and
|
|
4
|
+
* the Angular cores that need it (collapsible, alert-dialog), once per conversion.
|
|
5
|
+
*
|
|
6
|
+
* Radix: `mounted` --UNMOUNT--> `unmounted`, `mounted` --ANIMATION_OUT--> `unmountSuspended`, `unmountSuspended`
|
|
7
|
+
* --MOUNT--> `mounted` / --ANIMATION_END--> `unmounted`, `unmounted` --MOUNT--> `mounted`. When `present` turns false:
|
|
8
|
+
* no animation (`animation-name: none`) or a `display: none` node unmounts at once; an animation name other than the one
|
|
9
|
+
* the node mounted with (the exit animation the closed state's classes start) suspends the unmount until that animation
|
|
10
|
+
* ends or is cancelled; anything else unmounts.
|
|
11
|
+
*/
|
|
12
|
+
export const PRESENCE_SOURCE = `/**
|
|
13
|
+
* Radix's Presence as plain TypeScript: a part stays mounted while its exit animation runs. \`update(present)\` after the
|
|
14
|
+
* element shows the new state; \`attach(node)\` when the element mounts (null when it leaves); \`destroy()\` on unmount.
|
|
15
|
+
*/
|
|
16
|
+
export class RadixPresence {
|
|
17
|
+
private state: 'mounted' | 'unmountSuspended' | 'unmounted';
|
|
18
|
+
private node: HTMLElement | null = null;
|
|
19
|
+
private styles: CSSStyleDeclaration | null = null;
|
|
20
|
+
private prevPresent: boolean;
|
|
21
|
+
private prevAnimationName = 'none';
|
|
22
|
+
private mountAnimationName: string | undefined = undefined;
|
|
23
|
+
private timeout: ReturnType<typeof setTimeout> | undefined = undefined;
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
present: boolean,
|
|
27
|
+
private readonly changed: (isPresent: boolean) => void,
|
|
28
|
+
) {
|
|
29
|
+
this.state = present ? 'mounted' : 'unmounted';
|
|
30
|
+
this.prevPresent = present;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Whether the part is mounted (shown, or running its exit animation). */
|
|
34
|
+
get isPresent(): boolean {
|
|
35
|
+
return this.state !== 'unmounted';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private send(event: 'MOUNT' | 'UNMOUNT' | 'ANIMATION_OUT' | 'ANIMATION_END'): void {
|
|
39
|
+
const before = this.state;
|
|
40
|
+
let next = before;
|
|
41
|
+
if (before === 'mounted' && event === 'UNMOUNT') next = 'unmounted';
|
|
42
|
+
else if (before === 'mounted' && event === 'ANIMATION_OUT') next = 'unmountSuspended';
|
|
43
|
+
else if (before === 'unmountSuspended' && event === 'MOUNT') next = 'mounted';
|
|
44
|
+
else if (before === 'unmountSuspended' && event === 'ANIMATION_END') next = 'unmounted';
|
|
45
|
+
else if (before === 'unmounted' && event === 'MOUNT') next = 'mounted';
|
|
46
|
+
if (next === before) return;
|
|
47
|
+
this.state = next;
|
|
48
|
+
if (next === 'mounted') {
|
|
49
|
+
this.prevAnimationName = this.mountAnimationName ?? animationName(this.styles);
|
|
50
|
+
this.mountAnimationName = undefined;
|
|
51
|
+
} else this.prevAnimationName = 'none';
|
|
52
|
+
if ((before === 'unmounted') !== (next === 'unmounted')) this.changed(this.isPresent);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The present prop changed (or may have): called after the element shows the new state. */
|
|
56
|
+
update(present: boolean): void {
|
|
57
|
+
const wasPresent = this.prevPresent;
|
|
58
|
+
if (wasPresent === present) return;
|
|
59
|
+
const current = animationName(this.styles);
|
|
60
|
+
this.prevPresent = present;
|
|
61
|
+
if (present) {
|
|
62
|
+
this.mountAnimationName = current;
|
|
63
|
+
this.send('MOUNT');
|
|
64
|
+
} else if (current === 'none' || this.styles?.display === 'none') this.send('UNMOUNT');
|
|
65
|
+
else if (wasPresent && this.prevAnimationName !== current) this.send('ANIMATION_OUT');
|
|
66
|
+
else this.send('UNMOUNT');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private readonly onStart = (event: AnimationEvent): void => {
|
|
70
|
+
if (event.target === this.node) this.prevAnimationName = animationName(this.styles);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
private readonly onEnd = (event: AnimationEvent): void => {
|
|
74
|
+
const node = this.node;
|
|
75
|
+
if (!node || event.target !== node || !animationName(this.styles).includes(CSS.escape(event.animationName))) return;
|
|
76
|
+
this.send('ANIMATION_END');
|
|
77
|
+
if (this.prevPresent) return;
|
|
78
|
+
// Radix holds the last frame until the node is gone, so it does not flash back to its resting style
|
|
79
|
+
const fill = node.style.animationFillMode;
|
|
80
|
+
node.style.animationFillMode = 'forwards';
|
|
81
|
+
clearTimeout(this.timeout);
|
|
82
|
+
this.timeout = setTimeout(() => {
|
|
83
|
+
if (node.style.animationFillMode === 'forwards') node.style.animationFillMode = fill;
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** The element mounted (or left: null). */
|
|
88
|
+
attach(node: HTMLElement | null): void {
|
|
89
|
+
if (node === this.node) return;
|
|
90
|
+
this.detach();
|
|
91
|
+
this.node = node;
|
|
92
|
+
if (!node) {
|
|
93
|
+
this.styles = null;
|
|
94
|
+
this.send('ANIMATION_END');
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.styles = getComputedStyle(node);
|
|
98
|
+
this.mountAnimationName = animationName(this.styles);
|
|
99
|
+
if (this.state === 'mounted') {
|
|
100
|
+
this.prevAnimationName = this.mountAnimationName;
|
|
101
|
+
this.mountAnimationName = undefined;
|
|
102
|
+
}
|
|
103
|
+
node.addEventListener('animationstart', this.onStart);
|
|
104
|
+
node.addEventListener('animationcancel', this.onEnd);
|
|
105
|
+
node.addEventListener('animationend', this.onEnd);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private detach(): void {
|
|
109
|
+
clearTimeout(this.timeout);
|
|
110
|
+
this.timeout = undefined;
|
|
111
|
+
const node = this.node;
|
|
112
|
+
if (!node) return;
|
|
113
|
+
node.removeEventListener('animationstart', this.onStart);
|
|
114
|
+
node.removeEventListener('animationcancel', this.onEnd);
|
|
115
|
+
node.removeEventListener('animationend', this.onEnd);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The part is gone: no listener or timer is left. */
|
|
119
|
+
destroy(): void {
|
|
120
|
+
this.detach();
|
|
121
|
+
this.node = null;
|
|
122
|
+
this.styles = null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function animationName(styles: CSSStyleDeclaration | null): string {
|
|
127
|
+
return styles?.animationName || 'none';
|
|
128
|
+
}
|
|
129
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radix Slider's behaviour (`@radix-ui/react-slider`, read from its installed source) as plain TypeScript with no
|
|
3
|
+
* framework, written into the output by the Svelte and the Angular slider cores (once per conversion that uses the
|
|
4
|
+
* package). It holds what Radix's Slider root holds: the values (controlled while `value` is given, else its own from
|
|
5
|
+
* `defaultValue`, read once), the thumb a key or a drag moves, the keys (Arrow ±step, PageUp / PageDown and Shift+Arrow
|
|
6
|
+
* ±10 steps, Home min, End max, the back keys flipped for right to left and `inverted`), the pointer (a press on the
|
|
7
|
+
* track moves the nearest thumb there and focuses it, a drag follows the pointer under capture, the release commits),
|
|
8
|
+
* and the geometry each part renders (the range's edges, each thumb's place kept inside the track by its size).
|
|
9
|
+
*/
|
|
10
|
+
export declare const SLIDER_LOGIC_SOURCE = "export type SliderOrientation = 'horizontal' | 'vertical';\nexport type SliderDirection = 'ltr' | 'rtl';\n\n/** The root's props as Radix reads them (its defaults applied). */\nexport interface SliderSettings {\n value: number[] | undefined;\n min: number;\n max: number;\n step: number;\n orientation: SliderOrientation;\n disabled: boolean;\n minStepsBetweenThumbs: number;\n inverted: boolean;\n /** the direction (the root's dir, else a DirectionProvider's, else ltr) */\n dir: SliderDirection;\n}\n\n/** Where a part's place is measured from, as Radix's orientation context gives it. */\nexport interface SliderEdges {\n startEdge: 'left' | 'right' | 'bottom' | 'top';\n endEdge: 'left' | 'right' | 'bottom' | 'top';\n size: 'width' | 'height';\n direction: 1 | -1;\n}\n\n/** What the framework gives the slider: its settings, its own values, and the callbacks. */\nexport interface SliderHost {\n settings(): SliderSettings;\n own(): number[];\n setOwn(values: number[]): void;\n valueChange(values: number[]): void;\n valueCommit(values: number[]): void;\n root(): HTMLElement | null;\n}\n\nconst PAGE_KEYS = ['PageUp', 'PageDown'];\nconst ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];\nconst BACK_KEYS: Record<string, string[]> = {\n 'from-left': ['Home', 'PageDown', 'ArrowDown', 'ArrowLeft'],\n 'from-right': ['Home', 'PageDown', 'ArrowDown', 'ArrowRight'],\n 'from-bottom': ['Home', 'PageDown', 'ArrowDown', 'ArrowLeft'],\n 'from-top': ['Home', 'PageDown', 'ArrowUp', 'ArrowLeft'],\n};\n\nexport class RadixSliderCore {\n /** the thumb a key or a drag moves (the focused one, or the one nearest a press) */\n valueIndexToChange = 0;\n private keyboard = false;\n private before: number[] = [];\n private rect: DOMRect | undefined = undefined;\n /** the thumbs' elements, in the page's order */\n private thumbs: HTMLElement[] = [];\n\n constructor(private readonly host: SliderHost) {}\n\n get values(): number[] {\n const given = this.host.settings().value;\n return given !== undefined ? given : this.host.own();\n }\n\n /** A thumb's element mounted (Radix's collection): its index is its place in the page. */\n addThumb(thumb: HTMLElement): void {\n if (!this.thumbs.includes(thumb)) this.thumbs = [...this.thumbs, thumb].sort((a, b) => (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1));\n }\n\n removeThumb(thumb: HTMLElement): void {\n this.thumbs = this.thumbs.filter((t) => t !== thumb);\n }\n\n indexOf(thumb: HTMLElement | null): number {\n return thumb ? this.thumbs.indexOf(thumb) : -1;\n }\n\n edges(): SliderEdges {\n const s = this.host.settings();\n if (s.orientation === 'vertical') {\n const fromBottom = !s.inverted;\n return { startEdge: fromBottom ? 'bottom' : 'top', endEdge: fromBottom ? 'top' : 'bottom', size: 'height', direction: fromBottom ? 1 : -1 };\n }\n const ltr = s.dir === 'ltr';\n const fromLeft = (ltr && !s.inverted) || (!ltr && s.inverted);\n return { startEdge: fromLeft ? 'left' : 'right', endEdge: fromLeft ? 'right' : 'left', size: 'width', direction: fromLeft ? 1 : -1 };\n }\n\n percent(value: number): number {\n const s = this.host.settings();\n return clamp((100 / (s.max - s.min)) * (value - s.min), 0, 100);\n }\n\n /** The range's start and end offsets, in percent of the track. */\n range(): { start: number; end: number } {\n const values = this.values;\n const percentages = values.map((v) => this.percent(v));\n return { start: values.length > 1 ? Math.min(...percentages) : 0, end: 100 - Math.max(...percentages) };\n }\n\n /** How far a thumb of this size is moved so it stays inside the track (Radix's getThumbInBoundsOffset). */\n thumbOffset(size: number | undefined, percent: number): number {\n if (!size) return 0;\n const direction = this.edges().direction;\n const half = size / 2;\n const offset = linear([0, 50], [0, half]);\n return (half - offset(percent) * direction) * direction;\n }\n\n label(index: number): string | undefined {\n const count = this.values.length;\n if (count > 2) return 'Value ' + (index + 1) + ' of ' + count;\n if (count === 2) return ['Minimum', 'Maximum'][index];\n return undefined;\n }\n\n private setValues(next: (prev: number[]) => number[]): void {\n const given = this.host.settings().value;\n if (given !== undefined) {\n const value = next(given);\n if (value !== given) this.changed(value);\n return;\n }\n const prev = this.host.own();\n const value = next(prev);\n if (value === prev) return;\n this.host.setOwn(value);\n this.changed(value);\n }\n\n /** Radix's onChange: the changed thumb takes focus (shown as keyboard focus after a key), then the callback. */\n private changed(values: number[]): void {\n this.thumbs[this.valueIndexToChange]?.focus({ preventScroll: true, focusVisible: this.keyboard } as FocusOptions);\n this.keyboard = false;\n this.host.valueChange(values);\n }\n\n private update(value: number, atIndex: number, commit: boolean): void {\n const s = this.host.settings();\n const decimals = decimalCount(s.step);\n const snapped = round(Math.round((value - s.min) / s.step) * s.step + s.min, decimals);\n const nextValue = clamp(snapped, s.min, s.max);\n const distance = s.minStepsBetweenThumbs * s.step;\n this.setValues((prev) => {\n const nextValues = [...prev];\n nextValues[atIndex] = nextValue;\n nextValues.sort((a, b) => a - b);\n if (!hasMinSteps(nextValues, distance)) return prev;\n this.valueIndexToChange = nextValues.indexOf(nextValue);\n const changed = String(nextValues) !== String(prev);\n if (changed && commit) this.host.valueCommit(nextValues);\n return changed ? nextValues : prev;\n });\n }\n\n private fromPointer(event: PointerEvent): number {\n const s = this.host.settings();\n const root = this.host.root();\n const rect = this.rect ?? root?.getBoundingClientRect();\n if (!rect) return s.min;\n this.rect = rect;\n if (s.orientation === 'vertical') {\n const output: [number, number] = !s.inverted ? [s.max, s.min] : [s.min, s.max];\n return linear([0, rect.height], output)(event.clientY - rect.top);\n }\n const fromLeft = this.edges().startEdge === 'left';\n return linear([0, rect.width], fromLeft ? [s.min, s.max] : [s.max, s.min])(event.clientX - rect.left);\n }\n\n /** The root's keydown, after the caller's own handler. */\n keydown(event: KeyboardEvent): void {\n const s = this.host.settings();\n if (event.key === 'Home') {\n if (!s.disabled) {\n this.keyboard = true;\n this.update(s.min, 0, true);\n }\n event.preventDefault();\n } else if (event.key === 'End') {\n if (!s.disabled) {\n this.keyboard = true;\n this.update(s.max, this.values.length - 1, true);\n }\n event.preventDefault();\n } else if (PAGE_KEYS.concat(ARROW_KEYS).includes(event.key)) {\n if (!s.disabled) {\n const edges = this.edges();\n const slide = s.orientation === 'vertical' ? (edges.direction === 1 ? 'from-bottom' : 'from-top') : edges.direction === 1 ? 'from-left' : 'from-right';\n const back = (BACK_KEYS[slide] ?? []).includes(event.key);\n this.keyboard = true;\n const skip = PAGE_KEYS.includes(event.key) || (event.shiftKey && ARROW_KEYS.includes(event.key));\n const atIndex = this.valueIndexToChange;\n const current = this.values[atIndex] ?? s.min;\n this.update(nextStep(current, s.min, s.step, back ? -1 : 1, skip ? 10 : 1), atIndex, true);\n }\n event.preventDefault();\n }\n }\n\n /** The root's pointerdown, after the caller's own handler. */\n pointerdown(event: PointerEvent): void {\n const s = this.host.settings();\n if (!s.disabled) {\n this.before = this.values;\n this.keyboard = false;\n }\n if (event.defaultPrevented) return;\n const target = event.target;\n if (!(target instanceof HTMLElement || target instanceof SVGElement)) return;\n target.setPointerCapture(event.pointerId);\n event.preventDefault();\n if (target instanceof HTMLElement && this.thumbs.includes(target)) target.focus({ preventScroll: true, focusVisible: false } as FocusOptions);\n else if (!s.disabled) {\n const value = this.fromPointer(event);\n const values = this.values;\n let closest = 0;\n if (values.length > 1) {\n const distances = values.map((v) => Math.abs(v - value));\n closest = distances.indexOf(Math.min(...distances));\n }\n this.update(value, closest, false);\n }\n }\n\n pointermove(event: PointerEvent): void {\n const target = event.target;\n if ((target instanceof HTMLElement || target instanceof SVGElement) && target.hasPointerCapture(event.pointerId) && !this.host.settings().disabled) this.update(this.fromPointer(event), this.valueIndexToChange, false);\n }\n\n pointerup(event: PointerEvent): void {\n const target = event.target;\n if (!(target instanceof HTMLElement || target instanceof SVGElement) || !target.hasPointerCapture(event.pointerId)) return;\n target.releasePointerCapture(event.pointerId);\n if (this.host.settings().disabled) return;\n this.rect = undefined;\n const values = this.values;\n if (String(values) !== String(this.before)) this.host.valueCommit(values);\n }\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction linear(input: [number, number], output: [number, number]): (value: number) => number {\n return (value) => {\n if (input[0] === input[1] || output[0] === output[1]) return output[0];\n const ratio = (output[1] - output[0]) / (input[1] - input[0]);\n return output[0] + ratio * (value - input[0]);\n };\n}\n\nfunction decimalCount(value: number): number {\n if (!Number.isFinite(value)) return 0;\n const text = value.toString();\n if (text.includes('e')) {\n const [coefficient = '', exponent = '0'] = text.split('e');\n return Math.max(0, (coefficient.split('.')[1] ?? '').length - Number(exponent));\n }\n return (text.split('.')[1] ?? '').length;\n}\n\nfunction round(value: number, decimals: number): number {\n const rounder = Math.pow(10, decimals);\n return Math.round(value * rounder) / rounder;\n}\n\nfunction hasMinSteps(values: number[], distance: number): boolean {\n if (distance <= 0) return true;\n const steps = values.slice(0, -1).map((v, i) => (values[i + 1] ?? v) - v);\n return Math.min(...steps) >= distance;\n}\n\nfunction nextStep(value: number, min: number, step: number, direction: 1 | -1, multiplier: number): number {\n const decimals = decimalCount(step);\n const fromMin = (value - min) / step;\n const nearest = Math.round(fromMin);\n const aligned = round(nearest * step + min, decimals) === round(value, decimals);\n const steps = aligned ? nearest + multiplier * direction : direction > 0 ? Math.ceil(fromMin) : Math.floor(fromMin);\n return round(steps * step + min, decimals);\n}\n";
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radix Slider's behaviour (`@radix-ui/react-slider`, read from its installed source) as plain TypeScript with no
|
|
3
|
+
* framework, written into the output by the Svelte and the Angular slider cores (once per conversion that uses the
|
|
4
|
+
* package). It holds what Radix's Slider root holds: the values (controlled while `value` is given, else its own from
|
|
5
|
+
* `defaultValue`, read once), the thumb a key or a drag moves, the keys (Arrow ±step, PageUp / PageDown and Shift+Arrow
|
|
6
|
+
* ±10 steps, Home min, End max, the back keys flipped for right to left and `inverted`), the pointer (a press on the
|
|
7
|
+
* track moves the nearest thumb there and focuses it, a drag follows the pointer under capture, the release commits),
|
|
8
|
+
* and the geometry each part renders (the range's edges, each thumb's place kept inside the track by its size).
|
|
9
|
+
*/
|
|
10
|
+
export const SLIDER_LOGIC_SOURCE = `export type SliderOrientation = 'horizontal' | 'vertical';
|
|
11
|
+
export type SliderDirection = 'ltr' | 'rtl';
|
|
12
|
+
|
|
13
|
+
/** The root's props as Radix reads them (its defaults applied). */
|
|
14
|
+
export interface SliderSettings {
|
|
15
|
+
value: number[] | undefined;
|
|
16
|
+
min: number;
|
|
17
|
+
max: number;
|
|
18
|
+
step: number;
|
|
19
|
+
orientation: SliderOrientation;
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
minStepsBetweenThumbs: number;
|
|
22
|
+
inverted: boolean;
|
|
23
|
+
/** the direction (the root's dir, else a DirectionProvider's, else ltr) */
|
|
24
|
+
dir: SliderDirection;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Where a part's place is measured from, as Radix's orientation context gives it. */
|
|
28
|
+
export interface SliderEdges {
|
|
29
|
+
startEdge: 'left' | 'right' | 'bottom' | 'top';
|
|
30
|
+
endEdge: 'left' | 'right' | 'bottom' | 'top';
|
|
31
|
+
size: 'width' | 'height';
|
|
32
|
+
direction: 1 | -1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** What the framework gives the slider: its settings, its own values, and the callbacks. */
|
|
36
|
+
export interface SliderHost {
|
|
37
|
+
settings(): SliderSettings;
|
|
38
|
+
own(): number[];
|
|
39
|
+
setOwn(values: number[]): void;
|
|
40
|
+
valueChange(values: number[]): void;
|
|
41
|
+
valueCommit(values: number[]): void;
|
|
42
|
+
root(): HTMLElement | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const PAGE_KEYS = ['PageUp', 'PageDown'];
|
|
46
|
+
const ARROW_KEYS = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
|
|
47
|
+
const BACK_KEYS: Record<string, string[]> = {
|
|
48
|
+
'from-left': ['Home', 'PageDown', 'ArrowDown', 'ArrowLeft'],
|
|
49
|
+
'from-right': ['Home', 'PageDown', 'ArrowDown', 'ArrowRight'],
|
|
50
|
+
'from-bottom': ['Home', 'PageDown', 'ArrowDown', 'ArrowLeft'],
|
|
51
|
+
'from-top': ['Home', 'PageDown', 'ArrowUp', 'ArrowLeft'],
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export class RadixSliderCore {
|
|
55
|
+
/** the thumb a key or a drag moves (the focused one, or the one nearest a press) */
|
|
56
|
+
valueIndexToChange = 0;
|
|
57
|
+
private keyboard = false;
|
|
58
|
+
private before: number[] = [];
|
|
59
|
+
private rect: DOMRect | undefined = undefined;
|
|
60
|
+
/** the thumbs' elements, in the page's order */
|
|
61
|
+
private thumbs: HTMLElement[] = [];
|
|
62
|
+
|
|
63
|
+
constructor(private readonly host: SliderHost) {}
|
|
64
|
+
|
|
65
|
+
get values(): number[] {
|
|
66
|
+
const given = this.host.settings().value;
|
|
67
|
+
return given !== undefined ? given : this.host.own();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** A thumb's element mounted (Radix's collection): its index is its place in the page. */
|
|
71
|
+
addThumb(thumb: HTMLElement): void {
|
|
72
|
+
if (!this.thumbs.includes(thumb)) this.thumbs = [...this.thumbs, thumb].sort((a, b) => (a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
removeThumb(thumb: HTMLElement): void {
|
|
76
|
+
this.thumbs = this.thumbs.filter((t) => t !== thumb);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
indexOf(thumb: HTMLElement | null): number {
|
|
80
|
+
return thumb ? this.thumbs.indexOf(thumb) : -1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
edges(): SliderEdges {
|
|
84
|
+
const s = this.host.settings();
|
|
85
|
+
if (s.orientation === 'vertical') {
|
|
86
|
+
const fromBottom = !s.inverted;
|
|
87
|
+
return { startEdge: fromBottom ? 'bottom' : 'top', endEdge: fromBottom ? 'top' : 'bottom', size: 'height', direction: fromBottom ? 1 : -1 };
|
|
88
|
+
}
|
|
89
|
+
const ltr = s.dir === 'ltr';
|
|
90
|
+
const fromLeft = (ltr && !s.inverted) || (!ltr && s.inverted);
|
|
91
|
+
return { startEdge: fromLeft ? 'left' : 'right', endEdge: fromLeft ? 'right' : 'left', size: 'width', direction: fromLeft ? 1 : -1 };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
percent(value: number): number {
|
|
95
|
+
const s = this.host.settings();
|
|
96
|
+
return clamp((100 / (s.max - s.min)) * (value - s.min), 0, 100);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The range's start and end offsets, in percent of the track. */
|
|
100
|
+
range(): { start: number; end: number } {
|
|
101
|
+
const values = this.values;
|
|
102
|
+
const percentages = values.map((v) => this.percent(v));
|
|
103
|
+
return { start: values.length > 1 ? Math.min(...percentages) : 0, end: 100 - Math.max(...percentages) };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** How far a thumb of this size is moved so it stays inside the track (Radix's getThumbInBoundsOffset). */
|
|
107
|
+
thumbOffset(size: number | undefined, percent: number): number {
|
|
108
|
+
if (!size) return 0;
|
|
109
|
+
const direction = this.edges().direction;
|
|
110
|
+
const half = size / 2;
|
|
111
|
+
const offset = linear([0, 50], [0, half]);
|
|
112
|
+
return (half - offset(percent) * direction) * direction;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
label(index: number): string | undefined {
|
|
116
|
+
const count = this.values.length;
|
|
117
|
+
if (count > 2) return 'Value ' + (index + 1) + ' of ' + count;
|
|
118
|
+
if (count === 2) return ['Minimum', 'Maximum'][index];
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private setValues(next: (prev: number[]) => number[]): void {
|
|
123
|
+
const given = this.host.settings().value;
|
|
124
|
+
if (given !== undefined) {
|
|
125
|
+
const value = next(given);
|
|
126
|
+
if (value !== given) this.changed(value);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const prev = this.host.own();
|
|
130
|
+
const value = next(prev);
|
|
131
|
+
if (value === prev) return;
|
|
132
|
+
this.host.setOwn(value);
|
|
133
|
+
this.changed(value);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Radix's onChange: the changed thumb takes focus (shown as keyboard focus after a key), then the callback. */
|
|
137
|
+
private changed(values: number[]): void {
|
|
138
|
+
this.thumbs[this.valueIndexToChange]?.focus({ preventScroll: true, focusVisible: this.keyboard } as FocusOptions);
|
|
139
|
+
this.keyboard = false;
|
|
140
|
+
this.host.valueChange(values);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
private update(value: number, atIndex: number, commit: boolean): void {
|
|
144
|
+
const s = this.host.settings();
|
|
145
|
+
const decimals = decimalCount(s.step);
|
|
146
|
+
const snapped = round(Math.round((value - s.min) / s.step) * s.step + s.min, decimals);
|
|
147
|
+
const nextValue = clamp(snapped, s.min, s.max);
|
|
148
|
+
const distance = s.minStepsBetweenThumbs * s.step;
|
|
149
|
+
this.setValues((prev) => {
|
|
150
|
+
const nextValues = [...prev];
|
|
151
|
+
nextValues[atIndex] = nextValue;
|
|
152
|
+
nextValues.sort((a, b) => a - b);
|
|
153
|
+
if (!hasMinSteps(nextValues, distance)) return prev;
|
|
154
|
+
this.valueIndexToChange = nextValues.indexOf(nextValue);
|
|
155
|
+
const changed = String(nextValues) !== String(prev);
|
|
156
|
+
if (changed && commit) this.host.valueCommit(nextValues);
|
|
157
|
+
return changed ? nextValues : prev;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private fromPointer(event: PointerEvent): number {
|
|
162
|
+
const s = this.host.settings();
|
|
163
|
+
const root = this.host.root();
|
|
164
|
+
const rect = this.rect ?? root?.getBoundingClientRect();
|
|
165
|
+
if (!rect) return s.min;
|
|
166
|
+
this.rect = rect;
|
|
167
|
+
if (s.orientation === 'vertical') {
|
|
168
|
+
const output: [number, number] = !s.inverted ? [s.max, s.min] : [s.min, s.max];
|
|
169
|
+
return linear([0, rect.height], output)(event.clientY - rect.top);
|
|
170
|
+
}
|
|
171
|
+
const fromLeft = this.edges().startEdge === 'left';
|
|
172
|
+
return linear([0, rect.width], fromLeft ? [s.min, s.max] : [s.max, s.min])(event.clientX - rect.left);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** The root's keydown, after the caller's own handler. */
|
|
176
|
+
keydown(event: KeyboardEvent): void {
|
|
177
|
+
const s = this.host.settings();
|
|
178
|
+
if (event.key === 'Home') {
|
|
179
|
+
if (!s.disabled) {
|
|
180
|
+
this.keyboard = true;
|
|
181
|
+
this.update(s.min, 0, true);
|
|
182
|
+
}
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
} else if (event.key === 'End') {
|
|
185
|
+
if (!s.disabled) {
|
|
186
|
+
this.keyboard = true;
|
|
187
|
+
this.update(s.max, this.values.length - 1, true);
|
|
188
|
+
}
|
|
189
|
+
event.preventDefault();
|
|
190
|
+
} else if (PAGE_KEYS.concat(ARROW_KEYS).includes(event.key)) {
|
|
191
|
+
if (!s.disabled) {
|
|
192
|
+
const edges = this.edges();
|
|
193
|
+
const slide = s.orientation === 'vertical' ? (edges.direction === 1 ? 'from-bottom' : 'from-top') : edges.direction === 1 ? 'from-left' : 'from-right';
|
|
194
|
+
const back = (BACK_KEYS[slide] ?? []).includes(event.key);
|
|
195
|
+
this.keyboard = true;
|
|
196
|
+
const skip = PAGE_KEYS.includes(event.key) || (event.shiftKey && ARROW_KEYS.includes(event.key));
|
|
197
|
+
const atIndex = this.valueIndexToChange;
|
|
198
|
+
const current = this.values[atIndex] ?? s.min;
|
|
199
|
+
this.update(nextStep(current, s.min, s.step, back ? -1 : 1, skip ? 10 : 1), atIndex, true);
|
|
200
|
+
}
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** The root's pointerdown, after the caller's own handler. */
|
|
206
|
+
pointerdown(event: PointerEvent): void {
|
|
207
|
+
const s = this.host.settings();
|
|
208
|
+
if (!s.disabled) {
|
|
209
|
+
this.before = this.values;
|
|
210
|
+
this.keyboard = false;
|
|
211
|
+
}
|
|
212
|
+
if (event.defaultPrevented) return;
|
|
213
|
+
const target = event.target;
|
|
214
|
+
if (!(target instanceof HTMLElement || target instanceof SVGElement)) return;
|
|
215
|
+
target.setPointerCapture(event.pointerId);
|
|
216
|
+
event.preventDefault();
|
|
217
|
+
if (target instanceof HTMLElement && this.thumbs.includes(target)) target.focus({ preventScroll: true, focusVisible: false } as FocusOptions);
|
|
218
|
+
else if (!s.disabled) {
|
|
219
|
+
const value = this.fromPointer(event);
|
|
220
|
+
const values = this.values;
|
|
221
|
+
let closest = 0;
|
|
222
|
+
if (values.length > 1) {
|
|
223
|
+
const distances = values.map((v) => Math.abs(v - value));
|
|
224
|
+
closest = distances.indexOf(Math.min(...distances));
|
|
225
|
+
}
|
|
226
|
+
this.update(value, closest, false);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
pointermove(event: PointerEvent): void {
|
|
231
|
+
const target = event.target;
|
|
232
|
+
if ((target instanceof HTMLElement || target instanceof SVGElement) && target.hasPointerCapture(event.pointerId) && !this.host.settings().disabled) this.update(this.fromPointer(event), this.valueIndexToChange, false);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
pointerup(event: PointerEvent): void {
|
|
236
|
+
const target = event.target;
|
|
237
|
+
if (!(target instanceof HTMLElement || target instanceof SVGElement) || !target.hasPointerCapture(event.pointerId)) return;
|
|
238
|
+
target.releasePointerCapture(event.pointerId);
|
|
239
|
+
if (this.host.settings().disabled) return;
|
|
240
|
+
this.rect = undefined;
|
|
241
|
+
const values = this.values;
|
|
242
|
+
if (String(values) !== String(this.before)) this.host.valueCommit(values);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function clamp(value: number, min: number, max: number): number {
|
|
247
|
+
return Math.min(max, Math.max(min, value));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function linear(input: [number, number], output: [number, number]): (value: number) => number {
|
|
251
|
+
return (value) => {
|
|
252
|
+
if (input[0] === input[1] || output[0] === output[1]) return output[0];
|
|
253
|
+
const ratio = (output[1] - output[0]) / (input[1] - input[0]);
|
|
254
|
+
return output[0] + ratio * (value - input[0]);
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function decimalCount(value: number): number {
|
|
259
|
+
if (!Number.isFinite(value)) return 0;
|
|
260
|
+
const text = value.toString();
|
|
261
|
+
if (text.includes('e')) {
|
|
262
|
+
const [coefficient = '', exponent = '0'] = text.split('e');
|
|
263
|
+
return Math.max(0, (coefficient.split('.')[1] ?? '').length - Number(exponent));
|
|
264
|
+
}
|
|
265
|
+
return (text.split('.')[1] ?? '').length;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function round(value: number, decimals: number): number {
|
|
269
|
+
const rounder = Math.pow(10, decimals);
|
|
270
|
+
return Math.round(value * rounder) / rounder;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function hasMinSteps(values: number[], distance: number): boolean {
|
|
274
|
+
if (distance <= 0) return true;
|
|
275
|
+
const steps = values.slice(0, -1).map((v, i) => (values[i + 1] ?? v) - v);
|
|
276
|
+
return Math.min(...steps) >= distance;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function nextStep(value: number, min: number, step: number, direction: 1 | -1, multiplier: number): number {
|
|
280
|
+
const decimals = decimalCount(step);
|
|
281
|
+
const fromMin = (value - min) / step;
|
|
282
|
+
const nearest = Math.round(fromMin);
|
|
283
|
+
const aligned = round(nearest * step + min, decimals) === round(value, decimals);
|
|
284
|
+
const steps = aligned ? nearest + multiplier * direction : direction > 0 ? Math.ceil(fromMin) : Math.floor(fromMin);
|
|
285
|
+
return round(steps * step + min, decimals);
|
|
286
|
+
}
|
|
287
|
+
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SvelteCore } from './core.js';
|
|
2
|
+
/**
|
|
3
|
+
* Radix Slider (`@radix-ui/react-slider`, read from its installed source) as Svelte 5, over the framework-free logic of
|
|
4
|
+
* slider-logic.ts: Root `<span dir data-orientation aria-disabled data-disabled>` (Radix's horizontal root writes its
|
|
5
|
+
* direction as `dir`; `--radix-slider-thumb-transform` set in its style), Track `<span data-disabled data-orientation>`,
|
|
6
|
+
* Range `<span data-orientation data-disabled>` placed by its start and end edges, and each Thumb as Radix renders it:
|
|
7
|
+
* a positioning `<span>` (`transform: var(--radix-slider-thumb-transform); position: absolute; <start edge>:
|
|
8
|
+
* calc(<percent>% + <in-bounds offset>px)`) around the `<span role="slider">` with aria-valuemin / -valuenow / -valuemax,
|
|
9
|
+
* aria-orientation, data-orientation, data-disabled and tabindex 0; hidden (`display: none`) until it knows its index,
|
|
10
|
+
* as Radix's is on its first render. Inside a form a hidden input carries each value under the thumb's name. The
|
|
11
|
+
* direction is the root's dir, else a DirectionProvider's (the direction core's context), else ltr.
|
|
12
|
+
*/
|
|
13
|
+
export declare const sliderCore: SvelteCore;
|