@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,154 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import { unwrap } from '../../ir/lower.js';
|
|
3
|
+
import { childComponent, forwardsElement } from '../shared/handles.js';
|
|
4
|
+
import { templateExpressions } from '../shared/inline.js';
|
|
5
|
+
/** childOfAny over the compiled files: the module the parent component sits in, then its tag there. */
|
|
6
|
+
export function childOfAnyIn(mod, ctx) {
|
|
7
|
+
return (parent, tag) => {
|
|
8
|
+
const home = parent.file === mod.file ? mod : (ctx.moduleOf?.(parent.file) ?? null);
|
|
9
|
+
return home ? childComponent(home, tag, ctx) : null;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/** Whether an element carries `ref={name}`. */
|
|
13
|
+
function carriesRef(n, name) {
|
|
14
|
+
return n.attrs.some((a) => a.kind === 'ref' && t.isIdentifier(unwrap(a.expr), { name }));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The elements the forwarded ref is put on when exactly one of them is rendered whenever the component renders, all
|
|
18
|
+
* of them components; null otherwise.
|
|
19
|
+
*/
|
|
20
|
+
export function exclusiveTargets(comp) {
|
|
21
|
+
const name = comp.forwardRef;
|
|
22
|
+
if (!name)
|
|
23
|
+
return null;
|
|
24
|
+
const targets = [];
|
|
25
|
+
// a render helper's markup is written at each call: a ref inside one is not followed
|
|
26
|
+
if (comp.fragments.some((f) => countIn([f.template], name, []) !== 'none'))
|
|
27
|
+
return null;
|
|
28
|
+
if (countIn([comp.template], name, targets) !== 'one' || !targets.length)
|
|
29
|
+
return null;
|
|
30
|
+
// the ref is read nowhere but on those elements
|
|
31
|
+
const onTargets = new Set(targets.flatMap((n) => n.attrs.filter((a) => a.kind === 'ref').map((a) => a.expr)));
|
|
32
|
+
const roots = [...comp.items.flatMap((i) => nodesOf(i)), ...templateExpressions(comp.template).filter((e) => !onTargets.has(e))];
|
|
33
|
+
let read = false;
|
|
34
|
+
for (const root of roots) {
|
|
35
|
+
t.traverseFast(root, (n) => {
|
|
36
|
+
if (t.isIdentifier(n) && comp.refs.get(n) === name)
|
|
37
|
+
read = true;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return read ? null : targets;
|
|
41
|
+
}
|
|
42
|
+
/** The source nodes a script item holds. */
|
|
43
|
+
function nodesOf(item) {
|
|
44
|
+
const out = [];
|
|
45
|
+
for (const v of Object.values(item)) {
|
|
46
|
+
for (const x of Array.isArray(v) ? v : [v])
|
|
47
|
+
if (x && typeof x === 'object' && t.isNode(x))
|
|
48
|
+
out.push(x);
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
/** How many elements carrying the ref a list of sibling nodes renders: none, exactly one always, or anything else. */
|
|
53
|
+
function countIn(nodes, name, into) {
|
|
54
|
+
let ones = 0;
|
|
55
|
+
for (const n of nodes) {
|
|
56
|
+
const c = countOne(n, name, into);
|
|
57
|
+
if (c === 'bad')
|
|
58
|
+
return 'bad';
|
|
59
|
+
if (c === 'one')
|
|
60
|
+
ones++;
|
|
61
|
+
}
|
|
62
|
+
return ones === 0 ? 'none' : ones === 1 ? 'one' : 'bad';
|
|
63
|
+
}
|
|
64
|
+
function countOne(n, name, into) {
|
|
65
|
+
switch (n.type) {
|
|
66
|
+
case 'element': {
|
|
67
|
+
// markup handed to another component is rendered when that component chooses
|
|
68
|
+
for (const a of n.attrs)
|
|
69
|
+
if (a.kind === 'slotProp' && countIn(a.children, name, []) !== 'none')
|
|
70
|
+
return 'bad';
|
|
71
|
+
if (carriesRef(n, name)) {
|
|
72
|
+
if (!n.component || n.asChild || countIn(n.children, name, []) !== 'none')
|
|
73
|
+
return 'bad';
|
|
74
|
+
into.push(n);
|
|
75
|
+
return 'one';
|
|
76
|
+
}
|
|
77
|
+
return countIn(n.children, name, into);
|
|
78
|
+
}
|
|
79
|
+
case 'if': {
|
|
80
|
+
const counts = n.branches.map((b) => countIn(b.children, name, into));
|
|
81
|
+
if (counts.every((c) => c === 'none'))
|
|
82
|
+
return 'none';
|
|
83
|
+
// every branch renders one, and one of them is the else
|
|
84
|
+
return counts.every((c) => c === 'one') && n.branches.some((b) => b.test === null) ? 'one' : 'bad';
|
|
85
|
+
}
|
|
86
|
+
case 'fragment':
|
|
87
|
+
case 'keyed':
|
|
88
|
+
return countIn(n.children, name, into);
|
|
89
|
+
case 'for':
|
|
90
|
+
case 'presence':
|
|
91
|
+
return countIn(n.children, name, []) === 'none' ? 'none' : 'bad';
|
|
92
|
+
case 'slot':
|
|
93
|
+
return countIn(n.fallback, name, []) === 'none' ? 'none' : 'bad';
|
|
94
|
+
default:
|
|
95
|
+
return 'none';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The names a parent's ref reads on a component: its handle's members (an object literal's, or a typed handle's), or
|
|
100
|
+
* those of the handles it passes on (see passedHandle). Null when they are not known by name, or when one of them
|
|
101
|
+
* shares its name with a prop or value of the component (its Angular member then has another name).
|
|
102
|
+
*/
|
|
103
|
+
export function reachedMembers(comp, childOf, ctx, depth = 0) {
|
|
104
|
+
if (forwardsElement(comp) || depth > 4)
|
|
105
|
+
return null;
|
|
106
|
+
const handles = comp.items.filter((i) => i.kind === 'handle' || i.kind === 'expose');
|
|
107
|
+
if (handles.length > 1)
|
|
108
|
+
return null;
|
|
109
|
+
const [only] = handles;
|
|
110
|
+
let names = null;
|
|
111
|
+
if (only?.kind === 'expose') {
|
|
112
|
+
names = [];
|
|
113
|
+
for (const p of only.object.properties) {
|
|
114
|
+
const key = t.isObjectMember(p) && !p.computed ? (t.isIdentifier(p.key) ? p.key.name : t.isStringLiteral(p.key) ? p.key.value : null) : null;
|
|
115
|
+
if (key === null)
|
|
116
|
+
return null;
|
|
117
|
+
names.push(key);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (only?.kind === 'handle') {
|
|
121
|
+
const type = only.type ?? comp.handleType;
|
|
122
|
+
const typed = only.members || !type ? null : ctx.types.members(type, comp.file);
|
|
123
|
+
names = only.members ? only.members.map((m) => m.name) : typed ? [...typed.keys()] : null;
|
|
124
|
+
if (!names)
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
if (names) {
|
|
128
|
+
const taken = (n) => !/^[A-Za-z_$][\w$]*$/.test(n) || comp.bindings.has(n) || comp.props.some((p) => p.key === n);
|
|
129
|
+
return names.some(taken) ? null : new Set(names);
|
|
130
|
+
}
|
|
131
|
+
const passed = passedHandle(comp, childOf, ctx, depth + 1);
|
|
132
|
+
return passed ? new Set(passed.names) : null;
|
|
133
|
+
}
|
|
134
|
+
/** How a component passes a parent's ref on to the handles of the children it puts the ref on, or null. */
|
|
135
|
+
export function passedHandle(comp, childOf, ctx, depth = 0) {
|
|
136
|
+
if (comp.items.some((i) => i.kind === 'handle' || i.kind === 'expose' || i.kind === 'forward'))
|
|
137
|
+
return null;
|
|
138
|
+
const targets = exclusiveTargets(comp);
|
|
139
|
+
if (!targets)
|
|
140
|
+
return null;
|
|
141
|
+
const members = new Map();
|
|
142
|
+
const names = [];
|
|
143
|
+
for (const target of targets) {
|
|
144
|
+
const child = childOf(comp, target.tag);
|
|
145
|
+
const reached = child ? reachedMembers(child, childOf, ctx, depth) : null;
|
|
146
|
+
if (!reached)
|
|
147
|
+
return null;
|
|
148
|
+
members.set(target, reached);
|
|
149
|
+
for (const n of reached)
|
|
150
|
+
if (!names.includes(n))
|
|
151
|
+
names.push(n);
|
|
152
|
+
}
|
|
153
|
+
return names.length ? { targets, members, names } : null;
|
|
154
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import type { ComponentIR } from '../../ir/model.js';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a component's template renders a node prop's slot only inside a branch whose test reads that prop
|
|
5
|
+
* (`{header !== undefined && <div>{header}</div>}`). A parent's markup projected into it leaves the input unset, so on
|
|
6
|
+
* Angular that test is false and the projected content is never rendered: whole pieces of the page are missing, a wrong
|
|
7
|
+
* render rather than a difference (see the `angular-projected-read` error). Returns the test as written, or null.
|
|
8
|
+
*/
|
|
9
|
+
export declare function slotGuardedByProp(comp: ComponentIR, key: string): t.Expression | null;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a component's template renders a node prop's slot only inside a branch whose test reads that prop
|
|
4
|
+
* (`{header !== undefined && <div>{header}</div>}`). A parent's markup projected into it leaves the input unset, so on
|
|
5
|
+
* Angular that test is false and the projected content is never rendered: whole pieces of the page are missing, a wrong
|
|
6
|
+
* render rather than a difference (see the `angular-projected-read` error). Returns the test as written, or null.
|
|
7
|
+
*/
|
|
8
|
+
export function slotGuardedByProp(comp, key) {
|
|
9
|
+
const prop = comp.props.find((p) => p.key === key);
|
|
10
|
+
if (!prop)
|
|
11
|
+
return null;
|
|
12
|
+
const readsProp = (e) => {
|
|
13
|
+
let found = false;
|
|
14
|
+
t.traverseFast(e, (x) => {
|
|
15
|
+
if (t.isIdentifier(x, { name: prop.local }))
|
|
16
|
+
found = true;
|
|
17
|
+
});
|
|
18
|
+
return found;
|
|
19
|
+
};
|
|
20
|
+
const holdsSlot = (nodes) => nodes.some((n) => {
|
|
21
|
+
if (n.type === 'slot')
|
|
22
|
+
return n.prop === key || holdsSlot(n.fallback);
|
|
23
|
+
if (n.type === 'element')
|
|
24
|
+
return holdsSlot(n.children) || n.attrs.some((a) => a.kind === 'slotProp' && holdsSlot(a.children));
|
|
25
|
+
if (n.type === 'if')
|
|
26
|
+
return n.branches.some((b) => holdsSlot(b.children));
|
|
27
|
+
if (n.type === 'for' || n.type === 'fragment' || n.type === 'keyed' || n.type === 'presence')
|
|
28
|
+
return holdsSlot(n.children);
|
|
29
|
+
return false;
|
|
30
|
+
});
|
|
31
|
+
let guard = null;
|
|
32
|
+
const visit = (nodes) => {
|
|
33
|
+
for (const n of nodes) {
|
|
34
|
+
if (guard)
|
|
35
|
+
return;
|
|
36
|
+
if (n.type === 'if') {
|
|
37
|
+
n.branches.forEach((b, i) => {
|
|
38
|
+
if (guard || !holdsSlot(b.children))
|
|
39
|
+
return;
|
|
40
|
+
// the branch's own test, or a test before it that must be false for it to show
|
|
41
|
+
const tests = n.branches.slice(0, i + 1).flatMap((x) => (x.test ? [x.test] : []));
|
|
42
|
+
const reading = tests.find(readsProp);
|
|
43
|
+
if (reading)
|
|
44
|
+
guard = reading;
|
|
45
|
+
});
|
|
46
|
+
for (const b of n.branches)
|
|
47
|
+
visit(b.children);
|
|
48
|
+
}
|
|
49
|
+
else if (n.type === 'element') {
|
|
50
|
+
visit(n.children);
|
|
51
|
+
for (const a of n.attrs)
|
|
52
|
+
if (a.kind === 'slotProp')
|
|
53
|
+
visit(a.children);
|
|
54
|
+
}
|
|
55
|
+
else if (n.type === 'slot')
|
|
56
|
+
visit(n.fallback);
|
|
57
|
+
else if (n.type === 'for' || n.type === 'fragment' || n.type === 'keyed' || n.type === 'presence')
|
|
58
|
+
visit(n.children);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
visit([comp.template, ...comp.fragments.map((f) => f.template)]);
|
|
62
|
+
return guard;
|
|
63
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radix AlertDialog as standalone Angular directives, over the framework-free presence.ts and modal-layer.ts (written
|
|
3
|
+
* beside it). Root (no element: an `<ng-container>` or a wrapper's `display: contents` host) holds `open` (Radix's
|
|
4
|
+
* useControllableState); Trigger, Title, Description, Action and Cancel sit on Radix's elements; Portal is the
|
|
5
|
+
* structural directive of an `<ng-template>`: while the dialog is open, and until the exit animations of the parts it
|
|
6
|
+
* holds have ended (Radix's Presence on each), it renders its view and moves the view's nodes into `document.body`.
|
|
7
|
+
* Overlay and Content are told when they are shown, when they close and when they leave; the Content then runs Radix's
|
|
8
|
+
* modal layer (focus on Cancel, Tab looping, focus kept inside, Escape, the body's pointer events, the focus guards,
|
|
9
|
+
* aria-hidden on the rest of the body, focus back on the Trigger after it leaves). The parts find their Root through
|
|
10
|
+
* Angular's injector. Children projected into the Portal are made once by the template that declares them, so they
|
|
11
|
+
* keep their state between openings, where Radix makes them again (said where the Portal holds projected content).
|
|
12
|
+
*/
|
|
13
|
+
export declare const NG_ALERT_DIALOG_SOURCE = "import { Directive, ElementRef, EmbeddedViewRef, Injector, TemplateRef, ViewContainerRef, afterNextRender, computed, effect, inject, input, output, signal, untracked, type OnDestroy, type OnInit } from '@angular/core';\nimport { RadixPresence } from './presence';\nimport { RadixModalLayer, lockScroll } from './modal-layer';\n\n/** A part a Portal shows and hides (Overlay, Content). */\ninterface PortalledPart {\n show(): void;\n hide(done: () => void): void;\n reopen(): void;\n gone(): void;\n}\n\nlet ids = 0;\n\n@Directive({ selector: '[morphAlertDialogRoot]', exportAs: 'morphAlertDialogRoot' })\nexport class MorphAlertDialogRoot implements OnInit {\n readonly open = input<boolean | undefined>(undefined);\n readonly defaultOpen = input<boolean | undefined>(undefined);\n readonly onOpenChange = output<boolean>();\n private readonly own = signal(false);\n /** whether the dialog is open: the given open, else its own (Radix's useControllableState) */\n readonly isOpen = computed(() => this.open() ?? this.own());\n private readonly id = 'radix-morph-' + ++ids;\n readonly contentId = this.id + '-content';\n readonly titleId = this.id + '-title';\n readonly descriptionId = this.id + '-description';\n readonly titles = signal(0);\n readonly descriptions = signal(0);\n trigger: HTMLElement | null = null;\n cancel: HTMLElement | null = null;\n readonly parts = new Set<PortalledPart>();\n\n ngOnInit(): void {\n // the default is read once\n this.own.set(this.defaultOpen() ?? false);\n }\n\n setOpen(next: boolean): void {\n const given = this.open();\n if (given !== undefined) {\n if (next !== given) this.onOpenChange.emit(next);\n return;\n }\n if (next === this.own()) return;\n this.own.set(next);\n this.onOpenChange.emit(next);\n }\n}\n\n/** Listens on the element after the template's own listeners, as Radix runs a caller's handler before its own. */\nfunction listenAfter(element: HTMLElement, type: string, listener: (event: Event) => void): () => void {\n element.addEventListener(type, listener);\n return () => element.removeEventListener(type, listener);\n}\n\n@Directive({\n selector: '[morphAlertDialogTrigger]',\n host: {\n type: 'button',\n 'aria-haspopup': 'dialog',\n '[attr.aria-expanded]': 'root.isOpen()',\n '[attr.aria-controls]': 'root.isOpen() ? root.contentId : null',\n '[attr.data-state]': \"root.isOpen() ? 'open' : 'closed'\",\n },\n})\nexport class MorphAlertDialogTrigger implements OnInit, OnDestroy {\n protected readonly root = inject(MorphAlertDialogRoot);\n private readonly element: HTMLElement = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private stop: (() => void) | null = null;\n\n ngOnInit(): void {\n this.root.trigger = this.element;\n this.stop = listenAfter(this.element, 'click', (event) => {\n if (!event.defaultPrevented) this.root.setOpen(!this.root.isOpen());\n });\n }\n\n ngOnDestroy(): void {\n this.stop?.();\n if (this.root.trigger === this.element) this.root.trigger = null;\n }\n}\n\n@Directive({ selector: 'ng-template[morphAlertDialogPortal]' })\nexport class MorphAlertDialogPortal implements OnDestroy {\n private readonly root = inject(MorphAlertDialogRoot);\n private readonly template: TemplateRef<unknown> = inject(TemplateRef);\n private readonly container = inject(ViewContainerRef);\n private readonly injector = inject(Injector);\n private view: EmbeddedViewRef<unknown> | null = null;\n private closing = false;\n\n constructor() {\n effect(() => {\n const open = this.root.isOpen();\n untracked(() => this.sync(open));\n });\n }\n\n private sync(open: boolean): void {\n if (open) {\n if (this.view) {\n // opened again while its parts animate out\n this.closing = false;\n for (const part of this.root.parts) part.reopen();\n return;\n }\n const view = this.container.createEmbeddedView(this.template);\n this.view = view;\n view.detectChanges();\n for (const node of view.rootNodes) if (node instanceof Node) document.body.appendChild(node);\n afterNextRender(() => {\n if (this.view === view && !this.closing) for (const part of this.root.parts) part.show();\n }, { injector: this.injector });\n return;\n }\n if (!this.view || this.closing) return;\n this.closing = true;\n const view = this.view;\n // once the closed state is rendered, each part leaves when its exit animation (if any) has ended\n afterNextRender(() => {\n if (this.view !== view || !this.closing) return;\n let pending = this.root.parts.size;\n const done = (): void => {\n pending -= 1;\n if (pending <= 0) this.finish(view);\n };\n if (!pending) this.finish(view);\n for (const part of [...this.root.parts]) part.hide(done);\n }, { injector: this.injector });\n }\n\n private finish(view: EmbeddedViewRef<unknown>): void {\n if (this.view !== view || !this.closing) return;\n this.closing = false;\n for (const part of this.root.parts) part.gone();\n this.view = null;\n view.destroy();\n }\n\n ngOnDestroy(): void {\n const view = this.view;\n if (!view) return;\n for (const part of this.root.parts) part.gone();\n this.view = null;\n view.destroy();\n }\n}\n\n/** Radix's Presence on a portalled part's element: hide() calls done when it has left (at once, or after its exit animation). */\nclass PartPresence {\n private presence: RadixPresence | null = null;\n private done: (() => void) | null = null;\n\n constructor(private readonly element: HTMLElement) {}\n\n show(): void {\n this.presence?.destroy();\n this.presence = new RadixPresence(true, (present) => {\n if (present || !this.done) return;\n const done = this.done;\n this.done = null;\n done();\n });\n this.presence.attach(this.element);\n }\n\n hide(done: () => void): void {\n const presence = this.presence;\n if (!presence) {\n done();\n return;\n }\n this.done = done;\n // (an unmount at once calls done from the presence's callback)\n presence.update(false);\n if (!presence.isPresent && this.done) {\n this.done = null;\n done();\n }\n }\n\n reopen(): void {\n this.done = null;\n this.presence?.update(true);\n }\n\n gone(): void {\n this.done = null;\n this.presence?.destroy();\n this.presence = null;\n }\n}\n\n@Directive({\n selector: '[morphAlertDialogOverlay]',\n host: { '[attr.data-state]': \"root.isOpen() ? 'open' : 'closed'\", '[style.pointer-events]': \"'auto'\" },\n})\nexport class MorphAlertDialogOverlay implements PortalledPart, OnDestroy {\n protected readonly root = inject(MorphAlertDialogRoot);\n private readonly presence = new PartPresence(inject<ElementRef<HTMLElement>>(ElementRef).nativeElement);\n private unlock: (() => void) | null = null;\n\n constructor() {\n this.root.parts.add(this);\n }\n\n show(): void {\n this.unlock ??= lockScroll();\n this.presence.show();\n }\n\n hide(done: () => void): void {\n this.presence.hide(done);\n }\n\n reopen(): void {\n this.presence.reopen();\n }\n\n gone(): void {\n this.presence.gone();\n this.unlock?.();\n this.unlock = null;\n }\n\n ngOnDestroy(): void {\n this.gone();\n this.root.parts.delete(this);\n }\n}\n\n@Directive({\n selector: '[morphAlertDialogContent]',\n host: {\n tabindex: '-1',\n role: 'alertdialog',\n '[attr.id]': 'root.contentId',\n '[attr.aria-labelledby]': 'root.titles() > 0 ? root.titleId : null',\n '[attr.aria-describedby]': 'root.descriptions() > 0 ? root.descriptionId : null',\n '[attr.data-state]': \"root.isOpen() ? 'open' : 'closed'\",\n '[style.pointer-events]': \"trapped() ? 'auto' : null\",\n },\n})\nexport class MorphAlertDialogContent implements PortalledPart, OnDestroy {\n protected readonly root = inject(MorphAlertDialogRoot);\n private readonly element: HTMLElement = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private readonly presence = new PartPresence(this.element);\n private layer: RadixModalLayer | null = null;\n private stop: (() => void) | null = null;\n protected readonly trapped = signal(false);\n\n constructor() {\n this.root.parts.add(this);\n effect(() => {\n const open = this.root.isOpen();\n untracked(() => {\n this.layer?.setTrapped(open);\n this.trapped.set(!!this.layer && open);\n });\n });\n }\n\n show(): void {\n this.presence.show();\n if (this.layer) return;\n const layer = new RadixModalLayer({\n container: this.element,\n // Radix's AlertDialog: focus on Cancel in place of the first tabbable\n mountAutoFocus: (event) => {\n event.preventDefault();\n this.root.cancel?.focus({ preventScroll: true });\n },\n // a modal dialog: focus back on the Trigger\n unmountAutoFocus: (event) => {\n event.preventDefault();\n this.root.trigger?.focus();\n },\n escapeKeyDown: (event) => {\n event.preventDefault();\n this.root.setOpen(false);\n },\n });\n this.layer = layer;\n layer.mount(this.root.isOpen());\n this.trapped.set(this.root.isOpen());\n this.stop = listenAfter(this.element, 'keydown', (event) => {\n if (event instanceof KeyboardEvent) layer.keydown(event);\n });\n }\n\n hide(done: () => void): void {\n this.presence.hide(done);\n }\n\n reopen(): void {\n this.presence.reopen();\n }\n\n gone(): void {\n this.presence.gone();\n this.stop?.();\n this.stop = null;\n this.layer?.unmount();\n this.layer = null;\n this.trapped.set(false);\n }\n\n ngOnDestroy(): void {\n this.gone();\n this.root.parts.delete(this);\n }\n}\n\n@Directive({ selector: '[morphAlertDialogTitle]', host: { '[attr.id]': 'root.titleId' } })\nexport class MorphAlertDialogTitle implements OnInit, OnDestroy {\n protected readonly root = inject(MorphAlertDialogRoot);\n\n ngOnInit(): void {\n this.root.titles.update((n) => n + 1);\n }\n\n ngOnDestroy(): void {\n this.root.titles.update((n) => n - 1);\n }\n}\n\n@Directive({ selector: '[morphAlertDialogDescription]', host: { '[attr.id]': 'root.descriptionId' } })\nexport class MorphAlertDialogDescription implements OnInit, OnDestroy {\n protected readonly root = inject(MorphAlertDialogRoot);\n\n ngOnInit(): void {\n this.root.descriptions.update((n) => n + 1);\n }\n\n ngOnDestroy(): void {\n this.root.descriptions.update((n) => n - 1);\n }\n}\n\n@Directive({ selector: '[morphAlertDialogAction]', host: { type: 'button' } })\nexport class MorphAlertDialogAction implements OnInit, OnDestroy {\n private readonly root = inject(MorphAlertDialogRoot);\n private readonly element: HTMLElement = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private stop: (() => void) | null = null;\n\n ngOnInit(): void {\n this.stop = listenAfter(this.element, 'click', (event) => {\n if (!event.defaultPrevented) this.root.setOpen(false);\n });\n }\n\n ngOnDestroy(): void {\n this.stop?.();\n }\n}\n\n@Directive({ selector: '[morphAlertDialogCancel]', host: { type: 'button' } })\nexport class MorphAlertDialogCancel implements OnInit, OnDestroy {\n private readonly root = inject(MorphAlertDialogRoot);\n private readonly element: HTMLElement = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private stop: (() => void) | null = null;\n\n ngOnInit(): void {\n this.root.cancel = this.element;\n this.stop = listenAfter(this.element, 'click', (event) => {\n if (!event.defaultPrevented) this.root.setOpen(false);\n });\n }\n\n ngOnDestroy(): void {\n this.stop?.();\n if (this.root.cancel === this.element) this.root.cancel = null;\n }\n}\n";
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Radix AlertDialog as standalone Angular directives, over the framework-free presence.ts and modal-layer.ts (written
|
|
3
|
+
* beside it). Root (no element: an `<ng-container>` or a wrapper's `display: contents` host) holds `open` (Radix's
|
|
4
|
+
* useControllableState); Trigger, Title, Description, Action and Cancel sit on Radix's elements; Portal is the
|
|
5
|
+
* structural directive of an `<ng-template>`: while the dialog is open, and until the exit animations of the parts it
|
|
6
|
+
* holds have ended (Radix's Presence on each), it renders its view and moves the view's nodes into `document.body`.
|
|
7
|
+
* Overlay and Content are told when they are shown, when they close and when they leave; the Content then runs Radix's
|
|
8
|
+
* modal layer (focus on Cancel, Tab looping, focus kept inside, Escape, the body's pointer events, the focus guards,
|
|
9
|
+
* aria-hidden on the rest of the body, focus back on the Trigger after it leaves). The parts find their Root through
|
|
10
|
+
* Angular's injector. Children projected into the Portal are made once by the template that declares them, so they
|
|
11
|
+
* keep their state between openings, where Radix makes them again (said where the Portal holds projected content).
|
|
12
|
+
*/
|
|
13
|
+
export const NG_ALERT_DIALOG_SOURCE = `import { Directive, ElementRef, EmbeddedViewRef, Injector, TemplateRef, ViewContainerRef, afterNextRender, computed, effect, inject, input, output, signal, untracked, type OnDestroy, type OnInit } from '@angular/core';
|
|
14
|
+
import { RadixPresence } from './presence';
|
|
15
|
+
import { RadixModalLayer, lockScroll } from './modal-layer';
|
|
16
|
+
|
|
17
|
+
/** A part a Portal shows and hides (Overlay, Content). */
|
|
18
|
+
interface PortalledPart {
|
|
19
|
+
show(): void;
|
|
20
|
+
hide(done: () => void): void;
|
|
21
|
+
reopen(): void;
|
|
22
|
+
gone(): void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let ids = 0;
|
|
26
|
+
|
|
27
|
+
@Directive({ selector: '[morphAlertDialogRoot]', exportAs: 'morphAlertDialogRoot' })
|
|
28
|
+
export class MorphAlertDialogRoot implements OnInit {
|
|
29
|
+
readonly open = input<boolean | undefined>(undefined);
|
|
30
|
+
readonly defaultOpen = input<boolean | undefined>(undefined);
|
|
31
|
+
readonly onOpenChange = output<boolean>();
|
|
32
|
+
private readonly own = signal(false);
|
|
33
|
+
/** whether the dialog is open: the given open, else its own (Radix's useControllableState) */
|
|
34
|
+
readonly isOpen = computed(() => this.open() ?? this.own());
|
|
35
|
+
private readonly id = 'radix-morph-' + ++ids;
|
|
36
|
+
readonly contentId = this.id + '-content';
|
|
37
|
+
readonly titleId = this.id + '-title';
|
|
38
|
+
readonly descriptionId = this.id + '-description';
|
|
39
|
+
readonly titles = signal(0);
|
|
40
|
+
readonly descriptions = signal(0);
|
|
41
|
+
trigger: HTMLElement | null = null;
|
|
42
|
+
cancel: HTMLElement | null = null;
|
|
43
|
+
readonly parts = new Set<PortalledPart>();
|
|
44
|
+
|
|
45
|
+
ngOnInit(): void {
|
|
46
|
+
// the default is read once
|
|
47
|
+
this.own.set(this.defaultOpen() ?? false);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
setOpen(next: boolean): void {
|
|
51
|
+
const given = this.open();
|
|
52
|
+
if (given !== undefined) {
|
|
53
|
+
if (next !== given) this.onOpenChange.emit(next);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (next === this.own()) return;
|
|
57
|
+
this.own.set(next);
|
|
58
|
+
this.onOpenChange.emit(next);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Listens on the element after the template's own listeners, as Radix runs a caller's handler before its own. */
|
|
63
|
+
function listenAfter(element: HTMLElement, type: string, listener: (event: Event) => void): () => void {
|
|
64
|
+
element.addEventListener(type, listener);
|
|
65
|
+
return () => element.removeEventListener(type, listener);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Directive({
|
|
69
|
+
selector: '[morphAlertDialogTrigger]',
|
|
70
|
+
host: {
|
|
71
|
+
type: 'button',
|
|
72
|
+
'aria-haspopup': 'dialog',
|
|
73
|
+
'[attr.aria-expanded]': 'root.isOpen()',
|
|
74
|
+
'[attr.aria-controls]': 'root.isOpen() ? root.contentId : null',
|
|
75
|
+
'[attr.data-state]': "root.isOpen() ? 'open' : 'closed'",
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
export class MorphAlertDialogTrigger implements OnInit, OnDestroy {
|
|
79
|
+
protected readonly root = inject(MorphAlertDialogRoot);
|
|
80
|
+
private readonly element: HTMLElement = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
|
|
81
|
+
private stop: (() => void) | null = null;
|
|
82
|
+
|
|
83
|
+
ngOnInit(): void {
|
|
84
|
+
this.root.trigger = this.element;
|
|
85
|
+
this.stop = listenAfter(this.element, 'click', (event) => {
|
|
86
|
+
if (!event.defaultPrevented) this.root.setOpen(!this.root.isOpen());
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
ngOnDestroy(): void {
|
|
91
|
+
this.stop?.();
|
|
92
|
+
if (this.root.trigger === this.element) this.root.trigger = null;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@Directive({ selector: 'ng-template[morphAlertDialogPortal]' })
|
|
97
|
+
export class MorphAlertDialogPortal implements OnDestroy {
|
|
98
|
+
private readonly root = inject(MorphAlertDialogRoot);
|
|
99
|
+
private readonly template: TemplateRef<unknown> = inject(TemplateRef);
|
|
100
|
+
private readonly container = inject(ViewContainerRef);
|
|
101
|
+
private readonly injector = inject(Injector);
|
|
102
|
+
private view: EmbeddedViewRef<unknown> | null = null;
|
|
103
|
+
private closing = false;
|
|
104
|
+
|
|
105
|
+
constructor() {
|
|
106
|
+
effect(() => {
|
|
107
|
+
const open = this.root.isOpen();
|
|
108
|
+
untracked(() => this.sync(open));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private sync(open: boolean): void {
|
|
113
|
+
if (open) {
|
|
114
|
+
if (this.view) {
|
|
115
|
+
// opened again while its parts animate out
|
|
116
|
+
this.closing = false;
|
|
117
|
+
for (const part of this.root.parts) part.reopen();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const view = this.container.createEmbeddedView(this.template);
|
|
121
|
+
this.view = view;
|
|
122
|
+
view.detectChanges();
|
|
123
|
+
for (const node of view.rootNodes) if (node instanceof Node) document.body.appendChild(node);
|
|
124
|
+
afterNextRender(() => {
|
|
125
|
+
if (this.view === view && !this.closing) for (const part of this.root.parts) part.show();
|
|
126
|
+
}, { injector: this.injector });
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (!this.view || this.closing) return;
|
|
130
|
+
this.closing = true;
|
|
131
|
+
const view = this.view;
|
|
132
|
+
// once the closed state is rendered, each part leaves when its exit animation (if any) has ended
|
|
133
|
+
afterNextRender(() => {
|
|
134
|
+
if (this.view !== view || !this.closing) return;
|
|
135
|
+
let pending = this.root.parts.size;
|
|
136
|
+
const done = (): void => {
|
|
137
|
+
pending -= 1;
|
|
138
|
+
if (pending <= 0) this.finish(view);
|
|
139
|
+
};
|
|
140
|
+
if (!pending) this.finish(view);
|
|
141
|
+
for (const part of [...this.root.parts]) part.hide(done);
|
|
142
|
+
}, { injector: this.injector });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
private finish(view: EmbeddedViewRef<unknown>): void {
|
|
146
|
+
if (this.view !== view || !this.closing) return;
|
|
147
|
+
this.closing = false;
|
|
148
|
+
for (const part of this.root.parts) part.gone();
|
|
149
|
+
this.view = null;
|
|
150
|
+
view.destroy();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
ngOnDestroy(): void {
|
|
154
|
+
const view = this.view;
|
|
155
|
+
if (!view) return;
|
|
156
|
+
for (const part of this.root.parts) part.gone();
|
|
157
|
+
this.view = null;
|
|
158
|
+
view.destroy();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Radix's Presence on a portalled part's element: hide() calls done when it has left (at once, or after its exit animation). */
|
|
163
|
+
class PartPresence {
|
|
164
|
+
private presence: RadixPresence | null = null;
|
|
165
|
+
private done: (() => void) | null = null;
|
|
166
|
+
|
|
167
|
+
constructor(private readonly element: HTMLElement) {}
|
|
168
|
+
|
|
169
|
+
show(): void {
|
|
170
|
+
this.presence?.destroy();
|
|
171
|
+
this.presence = new RadixPresence(true, (present) => {
|
|
172
|
+
if (present || !this.done) return;
|
|
173
|
+
const done = this.done;
|
|
174
|
+
this.done = null;
|
|
175
|
+
done();
|
|
176
|
+
});
|
|
177
|
+
this.presence.attach(this.element);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
hide(done: () => void): void {
|
|
181
|
+
const presence = this.presence;
|
|
182
|
+
if (!presence) {
|
|
183
|
+
done();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.done = done;
|
|
187
|
+
// (an unmount at once calls done from the presence's callback)
|
|
188
|
+
presence.update(false);
|
|
189
|
+
if (!presence.isPresent && this.done) {
|
|
190
|
+
this.done = null;
|
|
191
|
+
done();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
reopen(): void {
|
|
196
|
+
this.done = null;
|
|
197
|
+
this.presence?.update(true);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
gone(): void {
|
|
201
|
+
this.done = null;
|
|
202
|
+
this.presence?.destroy();
|
|
203
|
+
this.presence = null;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@Directive({
|
|
208
|
+
selector: '[morphAlertDialogOverlay]',
|
|
209
|
+
host: { '[attr.data-state]': "root.isOpen() ? 'open' : 'closed'", '[style.pointer-events]': "'auto'" },
|
|
210
|
+
})
|
|
211
|
+
export class MorphAlertDialogOverlay implements PortalledPart, OnDestroy {
|
|
212
|
+
protected readonly root = inject(MorphAlertDialogRoot);
|
|
213
|
+
private readonly presence = new PartPresence(inject<ElementRef<HTMLElement>>(ElementRef).nativeElement);
|
|
214
|
+
private unlock: (() => void) | null = null;
|
|
215
|
+
|
|
216
|
+
constructor() {
|
|
217
|
+
this.root.parts.add(this);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
show(): void {
|
|
221
|
+
this.unlock ??= lockScroll();
|
|
222
|
+
this.presence.show();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
hide(done: () => void): void {
|
|
226
|
+
this.presence.hide(done);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
reopen(): void {
|
|
230
|
+
this.presence.reopen();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
gone(): void {
|
|
234
|
+
this.presence.gone();
|
|
235
|
+
this.unlock?.();
|
|
236
|
+
this.unlock = null;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
ngOnDestroy(): void {
|
|
240
|
+
this.gone();
|
|
241
|
+
this.root.parts.delete(this);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@Directive({
|
|
246
|
+
selector: '[morphAlertDialogContent]',
|
|
247
|
+
host: {
|
|
248
|
+
tabindex: '-1',
|
|
249
|
+
role: 'alertdialog',
|
|
250
|
+
'[attr.id]': 'root.contentId',
|
|
251
|
+
'[attr.aria-labelledby]': 'root.titles() > 0 ? root.titleId : null',
|
|
252
|
+
'[attr.aria-describedby]': 'root.descriptions() > 0 ? root.descriptionId : null',
|
|
253
|
+
'[attr.data-state]': "root.isOpen() ? 'open' : 'closed'",
|
|
254
|
+
'[style.pointer-events]': "trapped() ? 'auto' : null",
|
|
255
|
+
},
|
|
256
|
+
})
|
|
257
|
+
export class MorphAlertDialogContent implements PortalledPart, OnDestroy {
|
|
258
|
+
protected readonly root = inject(MorphAlertDialogRoot);
|
|
259
|
+
private readonly element: HTMLElement = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
|
|
260
|
+
private readonly presence = new PartPresence(this.element);
|
|
261
|
+
private layer: RadixModalLayer | null = null;
|
|
262
|
+
private stop: (() => void) | null = null;
|
|
263
|
+
protected readonly trapped = signal(false);
|
|
264
|
+
|
|
265
|
+
constructor() {
|
|
266
|
+
this.root.parts.add(this);
|
|
267
|
+
effect(() => {
|
|
268
|
+
const open = this.root.isOpen();
|
|
269
|
+
untracked(() => {
|
|
270
|
+
this.layer?.setTrapped(open);
|
|
271
|
+
this.trapped.set(!!this.layer && open);
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
show(): void {
|
|
277
|
+
this.presence.show();
|
|
278
|
+
if (this.layer) return;
|
|
279
|
+
const layer = new RadixModalLayer({
|
|
280
|
+
container: this.element,
|
|
281
|
+
// Radix's AlertDialog: focus on Cancel in place of the first tabbable
|
|
282
|
+
mountAutoFocus: (event) => {
|
|
283
|
+
event.preventDefault();
|
|
284
|
+
this.root.cancel?.focus({ preventScroll: true });
|
|
285
|
+
},
|
|
286
|
+
// a modal dialog: focus back on the Trigger
|
|
287
|
+
unmountAutoFocus: (event) => {
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
this.root.trigger?.focus();
|
|
290
|
+
},
|
|
291
|
+
escapeKeyDown: (event) => {
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
this.root.setOpen(false);
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
this.layer = layer;
|
|
297
|
+
layer.mount(this.root.isOpen());
|
|
298
|
+
this.trapped.set(this.root.isOpen());
|
|
299
|
+
this.stop = listenAfter(this.element, 'keydown', (event) => {
|
|
300
|
+
if (event instanceof KeyboardEvent) layer.keydown(event);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
hide(done: () => void): void {
|
|
305
|
+
this.presence.hide(done);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
reopen(): void {
|
|
309
|
+
this.presence.reopen();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
gone(): void {
|
|
313
|
+
this.presence.gone();
|
|
314
|
+
this.stop?.();
|
|
315
|
+
this.stop = null;
|
|
316
|
+
this.layer?.unmount();
|
|
317
|
+
this.layer = null;
|
|
318
|
+
this.trapped.set(false);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
ngOnDestroy(): void {
|
|
322
|
+
this.gone();
|
|
323
|
+
this.root.parts.delete(this);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
@Directive({ selector: '[morphAlertDialogTitle]', host: { '[attr.id]': 'root.titleId' } })
|
|
328
|
+
export class MorphAlertDialogTitle implements OnInit, OnDestroy {
|
|
329
|
+
protected readonly root = inject(MorphAlertDialogRoot);
|
|
330
|
+
|
|
331
|
+
ngOnInit(): void {
|
|
332
|
+
this.root.titles.update((n) => n + 1);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
ngOnDestroy(): void {
|
|
336
|
+
this.root.titles.update((n) => n - 1);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@Directive({ selector: '[morphAlertDialogDescription]', host: { '[attr.id]': 'root.descriptionId' } })
|
|
341
|
+
export class MorphAlertDialogDescription implements OnInit, OnDestroy {
|
|
342
|
+
protected readonly root = inject(MorphAlertDialogRoot);
|
|
343
|
+
|
|
344
|
+
ngOnInit(): void {
|
|
345
|
+
this.root.descriptions.update((n) => n + 1);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
ngOnDestroy(): void {
|
|
349
|
+
this.root.descriptions.update((n) => n - 1);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
@Directive({ selector: '[morphAlertDialogAction]', host: { type: 'button' } })
|
|
354
|
+
export class MorphAlertDialogAction implements OnInit, OnDestroy {
|
|
355
|
+
private readonly root = inject(MorphAlertDialogRoot);
|
|
356
|
+
private readonly element: HTMLElement = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
|
|
357
|
+
private stop: (() => void) | null = null;
|
|
358
|
+
|
|
359
|
+
ngOnInit(): void {
|
|
360
|
+
this.stop = listenAfter(this.element, 'click', (event) => {
|
|
361
|
+
if (!event.defaultPrevented) this.root.setOpen(false);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
ngOnDestroy(): void {
|
|
366
|
+
this.stop?.();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
@Directive({ selector: '[morphAlertDialogCancel]', host: { type: 'button' } })
|
|
371
|
+
export class MorphAlertDialogCancel implements OnInit, OnDestroy {
|
|
372
|
+
private readonly root = inject(MorphAlertDialogRoot);
|
|
373
|
+
private readonly element: HTMLElement = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;
|
|
374
|
+
private stop: (() => void) | null = null;
|
|
375
|
+
|
|
376
|
+
ngOnInit(): void {
|
|
377
|
+
this.root.cancel = this.element;
|
|
378
|
+
this.stop = listenAfter(this.element, 'click', (event) => {
|
|
379
|
+
if (!event.defaultPrevented) this.root.setOpen(false);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
ngOnDestroy(): void {
|
|
384
|
+
this.stop?.();
|
|
385
|
+
if (this.root.cancel === this.element) this.root.cancel = null;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EmittedFile } from '../../../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* M3: Radix packages morph writes itself for Angular (headless cores): standalone directives with Radix's props as
|
|
4
|
+
* inputs and its callbacks as outputs, strictly typed, importing nothing but Angular, mapped through the same part
|
|
5
|
+
* tables as radix-ng's (packages.ts), with a directive's `from` naming the core (`morph:slider`). The files are written
|
|
6
|
+
* into the output once per conversion, only when a converted file uses the package (its directives are imported).
|
|
7
|
+
*/
|
|
8
|
+
export declare const NG_CORE_PREFIX = "morph:";
|
|
9
|
+
/** Each core's files, by path in the output (under `radix-cores/`), the first the one its directives come from. */
|
|
10
|
+
export declare const NG_CORES: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
11
|
+
/**
|
|
12
|
+
* Where a directive of a map is imported from in a file written at `outPath`: a core's file (recorded as used), or the
|
|
13
|
+
* package entry point the map names.
|
|
14
|
+
*/
|
|
15
|
+
export declare function angularRadixSource(from: string, outPath: string, conversion: object, helperPath: ((name: string) => string) | undefined): string;
|
|
16
|
+
/** The files of the cores the conversion's files import; nothing when none does. */
|
|
17
|
+
export declare function angularCoreFiles(conversion: object, helperPath: (name: string) => string): EmittedFile[];
|