@wardic/solid 2.2.0 → 3.0.0-next.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/README.md +22 -18
- package/dist/browser/config-view.js +33 -5
- package/dist/browser/config-view.js.map +1 -1
- package/dist/browser/create-batch.js +1 -1
- package/dist/browser/element-style.js +61 -7
- package/dist/browser/element-style.js.map +1 -1
- package/dist/browser/element.js +19 -2
- package/dist/browser/element.js.map +1 -1
- package/dist/browser/feature-section.js +5 -13
- package/dist/browser/feature-section.js.map +1 -1
- package/dist/browser/hooks/auto.js +270 -0
- package/dist/browser/hooks/auto.js.map +1 -0
- package/dist/browser/hooks/config-scope.js +120 -0
- package/dist/browser/hooks/config-scope.js.map +1 -0
- package/dist/browser/hooks/config.js +37 -0
- package/dist/browser/hooks/config.js.map +1 -0
- package/dist/browser/hooks/drag.js +632 -0
- package/dist/browser/hooks/drag.js.map +1 -0
- package/dist/browser/hooks/elements.js +183 -0
- package/dist/browser/hooks/elements.js.map +1 -0
- package/dist/browser/hooks/group.js +28 -0
- package/dist/browser/hooks/group.js.map +1 -0
- package/dist/browser/hooks/index.js +10 -0
- package/dist/browser/hooks/index.js.map +1 -0
- package/dist/browser/hooks/kept.js +32 -0
- package/dist/browser/hooks/kept.js.map +1 -0
- package/dist/browser/hooks/layout-group-of.js +39 -0
- package/dist/browser/hooks/layout-group-of.js.map +1 -0
- package/dist/browser/hooks/layout-group.js +92 -0
- package/dist/browser/hooks/layout-group.js.map +1 -0
- package/dist/browser/hooks/make-ward.js +157 -0
- package/dist/browser/hooks/make-ward.js.map +1 -0
- package/dist/browser/hooks/presence-scope.js +87 -0
- package/dist/browser/hooks/presence-scope.js.map +1 -0
- package/dist/browser/hooks/presence.js +24 -0
- package/dist/browser/hooks/presence.js.map +1 -0
- package/dist/browser/hooks/props.js +148 -0
- package/dist/browser/hooks/props.js.map +1 -0
- package/dist/browser/hooks/reads.js +241 -0
- package/dist/browser/hooks/reads.js.map +1 -0
- package/dist/browser/hooks/refs.js +87 -0
- package/dist/browser/hooks/refs.js.map +1 -0
- package/dist/browser/hooks/reorder-elements.js +268 -0
- package/dist/browser/hooks/reorder-elements.js.map +1 -0
- package/dist/browser/hooks/reorder.js +176 -0
- package/dist/browser/hooks/reorder.js.map +1 -0
- package/dist/browser/hooks/rune.js +799 -0
- package/dist/browser/hooks/rune.js.map +1 -0
- package/dist/browser/hooks/server-features.client.js +2 -0
- package/dist/browser/hooks/server-features.client.js.map +1 -0
- package/dist/browser/hooks/server-features.js +13 -0
- package/dist/browser/hooks/server-features.js.map +1 -0
- package/dist/browser/hooks/settings.js +29 -0
- package/dist/browser/hooks/settings.js.map +1 -0
- package/dist/browser/hooks/setup.js +154 -0
- package/dist/browser/hooks/setup.js.map +1 -0
- package/dist/browser/hooks/stage.js +117 -0
- package/dist/browser/hooks/stage.js.map +1 -0
- package/dist/browser/hooks/ward.js +2193 -0
- package/dist/browser/hooks/ward.js.map +1 -0
- package/dist/browser/hooks/wardic-provider.js +29 -0
- package/dist/browser/hooks/wardic-provider.js.map +1 -0
- package/dist/browser/hooks/wardic-scope.js +68 -0
- package/dist/browser/hooks/wardic-scope.js.map +1 -0
- package/dist/browser/hooks/wards.js +562 -0
- package/dist/browser/hooks/wards.js.map +1 -0
- package/dist/browser/index.js +23 -11
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/layout.js +7 -58
- package/dist/browser/layout.js.map +1 -1
- package/dist/browser/lazy-batch-gestures.js +1 -1
- package/dist/browser/lifecycle.js +37 -0
- package/dist/browser/lifecycle.js.map +1 -1
- package/dist/browser/presence-handle.js +28 -12
- package/dist/browser/presence-handle.js.map +1 -1
- package/dist/browser/presence.js +3 -1
- package/dist/browser/presence.js.map +1 -1
- package/dist/browser/provider.js +85 -70
- package/dist/browser/provider.js.map +1 -1
- package/dist/browser/reorder-components.js +50 -0
- package/dist/browser/reorder-components.js.map +1 -0
- package/dist/browser/reorder.js +46 -274
- package/dist/browser/reorder.js.map +1 -1
- package/dist/browser/stage.js.map +1 -1
- package/dist/browser/unstable/v2/index.js +0 -8
- package/dist/browser/unstable/v2/index.js.map +1 -1
- package/dist/browser/v1/index.js +1 -1
- package/dist/browser/v1/index.js.map +1 -1
- package/dist/browser/variant-node.js +4 -2
- package/dist/browser/variant-node.js.map +1 -1
- package/dist/browser/w.js +33 -3
- package/dist/browser/w.js.map +1 -1
- package/dist/browser/ward.js +576 -49
- package/dist/browser/ward.js.map +1 -1
- package/dist/browser/wardic-config.js +62 -29
- package/dist/browser/wardic-config.js.map +1 -1
- package/dist/browser/wardic-context.js +23 -0
- package/dist/browser/wardic-context.js.map +1 -0
- package/dist/browser/wardic.js +3 -0
- package/dist/browser/wardic.js.map +1 -1
- package/dist/server/config-view.js +33 -5
- package/dist/server/config-view.js.map +1 -1
- package/dist/server/create-batch.js +1 -1
- package/dist/server/element-style.js +61 -7
- package/dist/server/element-style.js.map +1 -1
- package/dist/server/element.js +19 -2
- package/dist/server/element.js.map +1 -1
- package/dist/server/feature-section.js +5 -13
- package/dist/server/feature-section.js.map +1 -1
- package/dist/server/hooks/auto.js +270 -0
- package/dist/server/hooks/auto.js.map +1 -0
- package/dist/server/hooks/config-scope.js +120 -0
- package/dist/server/hooks/config-scope.js.map +1 -0
- package/dist/server/hooks/config.js +37 -0
- package/dist/server/hooks/config.js.map +1 -0
- package/dist/server/hooks/drag.js +632 -0
- package/dist/server/hooks/drag.js.map +1 -0
- package/dist/server/hooks/elements.js +192 -0
- package/dist/server/hooks/elements.js.map +1 -0
- package/dist/server/hooks/group.js +28 -0
- package/dist/server/hooks/group.js.map +1 -0
- package/dist/server/hooks/index.js +10 -0
- package/dist/server/hooks/index.js.map +1 -0
- package/dist/server/hooks/kept.js +32 -0
- package/dist/server/hooks/kept.js.map +1 -0
- package/dist/server/hooks/layout-group-of.js +39 -0
- package/dist/server/hooks/layout-group-of.js.map +1 -0
- package/dist/server/hooks/layout-group.js +109 -0
- package/dist/server/hooks/layout-group.js.map +1 -0
- package/dist/server/hooks/make-ward.js +157 -0
- package/dist/server/hooks/make-ward.js.map +1 -0
- package/dist/server/hooks/presence-scope.js +86 -0
- package/dist/server/hooks/presence-scope.js.map +1 -0
- package/dist/server/hooks/presence.js +24 -0
- package/dist/server/hooks/presence.js.map +1 -0
- package/dist/server/hooks/props.js +148 -0
- package/dist/server/hooks/props.js.map +1 -0
- package/dist/server/hooks/reads.js +241 -0
- package/dist/server/hooks/reads.js.map +1 -0
- package/dist/server/hooks/refs.js +87 -0
- package/dist/server/hooks/refs.js.map +1 -0
- package/dist/server/hooks/reorder-elements.js +308 -0
- package/dist/server/hooks/reorder-elements.js.map +1 -0
- package/dist/server/hooks/reorder.js +176 -0
- package/dist/server/hooks/reorder.js.map +1 -0
- package/dist/server/hooks/rune.js +799 -0
- package/dist/server/hooks/rune.js.map +1 -0
- package/dist/server/hooks/server-features.client.js +2 -0
- package/dist/server/hooks/server-features.client.js.map +1 -0
- package/dist/server/hooks/server-features.js +13 -0
- package/dist/server/hooks/server-features.js.map +1 -0
- package/dist/server/hooks/settings.js +29 -0
- package/dist/server/hooks/settings.js.map +1 -0
- package/dist/server/hooks/setup.js +154 -0
- package/dist/server/hooks/setup.js.map +1 -0
- package/dist/server/hooks/stage.js +117 -0
- package/dist/server/hooks/stage.js.map +1 -0
- package/dist/server/hooks/ward.js +2193 -0
- package/dist/server/hooks/ward.js.map +1 -0
- package/dist/server/hooks/wardic-provider.js +29 -0
- package/dist/server/hooks/wardic-provider.js.map +1 -0
- package/dist/server/hooks/wardic-scope.js +68 -0
- package/dist/server/hooks/wardic-scope.js.map +1 -0
- package/dist/server/hooks/wards.js +562 -0
- package/dist/server/hooks/wards.js.map +1 -0
- package/dist/server/index.js +23 -11
- package/dist/server/index.js.map +1 -1
- package/dist/server/layout.js +7 -75
- package/dist/server/layout.js.map +1 -1
- package/dist/server/lazy-batch-gestures.js +1 -1
- package/dist/server/lifecycle.js +37 -0
- package/dist/server/lifecycle.js.map +1 -1
- package/dist/server/presence-handle.js +28 -12
- package/dist/server/presence-handle.js.map +1 -1
- package/dist/server/presence.js +3 -1
- package/dist/server/presence.js.map +1 -1
- package/dist/server/provider.js +86 -80
- package/dist/server/provider.js.map +1 -1
- package/dist/server/reorder-components.js +50 -0
- package/dist/server/reorder-components.js.map +1 -0
- package/dist/server/reorder.js +46 -344
- package/dist/server/reorder.js.map +1 -1
- package/dist/server/stage.js.map +1 -1
- package/dist/server/unstable/v2/index.js +0 -8
- package/dist/server/unstable/v2/index.js.map +1 -1
- package/dist/server/v1/index.js +1 -1
- package/dist/server/v1/index.js.map +1 -1
- package/dist/server/variant-node.js +4 -2
- package/dist/server/variant-node.js.map +1 -1
- package/dist/server/w.js +33 -3
- package/dist/server/w.js.map +1 -1
- package/dist/server/ward.js +576 -49
- package/dist/server/ward.js.map +1 -1
- package/dist/server/wardic-config.js +63 -30
- package/dist/server/wardic-config.js.map +1 -1
- package/dist/server/wardic-context.js +23 -0
- package/dist/server/wardic-context.js.map +1 -0
- package/dist/server/wardic.js +3 -0
- package/dist/server/wardic.js.map +1 -1
- package/dist/solid/batch-reorder-group.d.ts +1 -1
- package/dist/solid/batch-reorder.d.ts +1 -1
- package/dist/solid/batch-reorder.d.ts.map +1 -1
- package/dist/solid/config-view.d.ts +11 -0
- package/dist/solid/config-view.d.ts.map +1 -1
- package/dist/solid/config-view.js +29 -6
- package/dist/solid/config-view.js.map +1 -1
- package/dist/solid/create-batch.jsx +1 -1
- package/dist/solid/element-style.d.ts +16 -2
- package/dist/solid/element-style.d.ts.map +1 -1
- package/dist/solid/element-style.js +61 -7
- package/dist/solid/element-style.js.map +1 -1
- package/dist/solid/element.d.ts +3 -1
- package/dist/solid/element.d.ts.map +1 -1
- package/dist/solid/element.jsx +21 -2
- package/dist/solid/element.jsx.map +1 -1
- package/dist/solid/feature-section.d.ts +0 -7
- package/dist/solid/feature-section.d.ts.map +1 -1
- package/dist/solid/feature-section.js +5 -13
- package/dist/solid/feature-section.js.map +1 -1
- package/dist/solid/hooks/auto.d.ts +44 -0
- package/dist/solid/hooks/auto.d.ts.map +1 -0
- package/dist/solid/hooks/auto.js +269 -0
- package/dist/solid/hooks/auto.js.map +1 -0
- package/dist/solid/hooks/config-scope.d.ts +84 -0
- package/dist/solid/hooks/config-scope.d.ts.map +1 -0
- package/dist/solid/hooks/config-scope.jsx +128 -0
- package/dist/solid/hooks/config-scope.jsx.map +1 -0
- package/dist/solid/hooks/config.d.ts +28 -0
- package/dist/solid/hooks/config.d.ts.map +1 -0
- package/dist/solid/hooks/config.jsx +37 -0
- package/dist/solid/hooks/config.jsx.map +1 -0
- package/dist/solid/hooks/drag.d.ts +220 -0
- package/dist/solid/hooks/drag.d.ts.map +1 -0
- package/dist/solid/hooks/drag.js +585 -0
- package/dist/solid/hooks/drag.js.map +1 -0
- package/dist/solid/hooks/elements.d.ts +11 -0
- package/dist/solid/hooks/elements.d.ts.map +1 -0
- package/dist/solid/hooks/elements.jsx +218 -0
- package/dist/solid/hooks/elements.jsx.map +1 -0
- package/dist/solid/hooks/group.d.ts +46 -0
- package/dist/solid/hooks/group.d.ts.map +1 -0
- package/dist/solid/hooks/group.jsx +25 -0
- package/dist/solid/hooks/group.jsx.map +1 -0
- package/dist/solid/hooks/index.d.ts +28 -0
- package/dist/solid/hooks/index.d.ts.map +1 -0
- package/dist/solid/hooks/index.js +10 -0
- package/dist/solid/hooks/index.js.map +1 -0
- package/dist/solid/hooks/kept.d.ts +60 -0
- package/dist/solid/hooks/kept.d.ts.map +1 -0
- package/dist/solid/hooks/kept.js +33 -0
- package/dist/solid/hooks/kept.js.map +1 -0
- package/dist/solid/hooks/layout-group-of.d.ts +27 -0
- package/dist/solid/hooks/layout-group-of.d.ts.map +1 -0
- package/dist/solid/hooks/layout-group-of.js +39 -0
- package/dist/solid/hooks/layout-group-of.js.map +1 -0
- package/dist/solid/hooks/layout-group.d.ts +60 -0
- package/dist/solid/hooks/layout-group.d.ts.map +1 -0
- package/dist/solid/hooks/layout-group.jsx +80 -0
- package/dist/solid/hooks/layout-group.jsx.map +1 -0
- package/dist/solid/hooks/make-ward.d.ts +123 -0
- package/dist/solid/hooks/make-ward.d.ts.map +1 -0
- package/dist/solid/hooks/make-ward.js +147 -0
- package/dist/solid/hooks/make-ward.js.map +1 -0
- package/dist/solid/hooks/presence-scope.d.ts +84 -0
- package/dist/solid/hooks/presence-scope.d.ts.map +1 -0
- package/dist/solid/hooks/presence-scope.jsx +62 -0
- package/dist/solid/hooks/presence-scope.jsx.map +1 -0
- package/dist/solid/hooks/presence.d.ts +51 -0
- package/dist/solid/hooks/presence.d.ts.map +1 -0
- package/dist/solid/hooks/presence.jsx +26 -0
- package/dist/solid/hooks/presence.jsx.map +1 -0
- package/dist/solid/hooks/props.d.ts +52 -0
- package/dist/solid/hooks/props.d.ts.map +1 -0
- package/dist/solid/hooks/props.js +140 -0
- package/dist/solid/hooks/props.js.map +1 -0
- package/dist/solid/hooks/reads.d.ts +38 -0
- package/dist/solid/hooks/reads.d.ts.map +1 -0
- package/dist/solid/hooks/reads.js +218 -0
- package/dist/solid/hooks/reads.js.map +1 -0
- package/dist/solid/hooks/refs.d.ts +25 -0
- package/dist/solid/hooks/refs.d.ts.map +1 -0
- package/dist/solid/hooks/refs.js +89 -0
- package/dist/solid/hooks/refs.js.map +1 -0
- package/dist/solid/hooks/reorder-elements.d.ts +23 -0
- package/dist/solid/hooks/reorder-elements.d.ts.map +1 -0
- package/dist/solid/hooks/reorder-elements.jsx +273 -0
- package/dist/solid/hooks/reorder-elements.jsx.map +1 -0
- package/dist/solid/hooks/reorder.d.ts +55 -0
- package/dist/solid/hooks/reorder.d.ts.map +1 -0
- package/dist/solid/hooks/reorder.js +152 -0
- package/dist/solid/hooks/reorder.js.map +1 -0
- package/dist/solid/hooks/rune.d.ts +885 -0
- package/dist/solid/hooks/rune.d.ts.map +1 -0
- package/dist/solid/hooks/rune.js +816 -0
- package/dist/solid/hooks/rune.js.map +1 -0
- package/dist/solid/hooks/server-features.client.d.ts +10 -0
- package/dist/solid/hooks/server-features.client.d.ts.map +1 -0
- package/dist/solid/hooks/server-features.client.js +2 -0
- package/dist/solid/hooks/server-features.client.js.map +1 -0
- package/dist/solid/hooks/server-features.d.ts +10 -0
- package/dist/solid/hooks/server-features.d.ts.map +1 -0
- package/dist/solid/hooks/server-features.js +13 -0
- package/dist/solid/hooks/server-features.js.map +1 -0
- package/dist/solid/hooks/settings.d.ts +11 -0
- package/dist/solid/hooks/settings.d.ts.map +1 -0
- package/dist/solid/hooks/settings.js +31 -0
- package/dist/solid/hooks/settings.js.map +1 -0
- package/dist/solid/hooks/setup.d.ts +31 -0
- package/dist/solid/hooks/setup.d.ts.map +1 -0
- package/dist/solid/hooks/setup.js +155 -0
- package/dist/solid/hooks/setup.js.map +1 -0
- package/dist/solid/hooks/stage.d.ts +187 -0
- package/dist/solid/hooks/stage.d.ts.map +1 -0
- package/dist/solid/hooks/stage.js +117 -0
- package/dist/solid/hooks/stage.js.map +1 -0
- package/dist/solid/hooks/ward.d.ts +394 -0
- package/dist/solid/hooks/ward.d.ts.map +1 -0
- package/dist/solid/hooks/ward.js +2237 -0
- package/dist/solid/hooks/ward.js.map +1 -0
- package/dist/solid/hooks/wardic-provider.d.ts +32 -0
- package/dist/solid/hooks/wardic-provider.d.ts.map +1 -0
- package/dist/solid/hooks/wardic-provider.jsx +29 -0
- package/dist/solid/hooks/wardic-provider.jsx.map +1 -0
- package/dist/solid/hooks/wardic-scope.d.ts +49 -0
- package/dist/solid/hooks/wardic-scope.d.ts.map +1 -0
- package/dist/solid/hooks/wardic-scope.jsx +63 -0
- package/dist/solid/hooks/wardic-scope.jsx.map +1 -0
- package/dist/solid/hooks/wards.d.ts +157 -0
- package/dist/solid/hooks/wards.d.ts.map +1 -0
- package/dist/solid/hooks/wards.js +522 -0
- package/dist/solid/hooks/wards.js.map +1 -0
- package/dist/solid/index.d.ts +21 -14
- package/dist/solid/index.d.ts.map +1 -1
- package/dist/solid/index.jsx +23 -11
- package/dist/solid/index.jsx.map +1 -1
- package/dist/solid/layout.d.ts +2 -44
- package/dist/solid/layout.d.ts.map +1 -1
- package/dist/solid/layout.jsx +7 -49
- package/dist/solid/layout.jsx.map +1 -1
- package/dist/solid/lazy-batch-gestures.js +1 -1
- package/dist/solid/lazy-batch-gestures.js.map +1 -1
- package/dist/solid/lifecycle.d.ts +19 -0
- package/dist/solid/lifecycle.d.ts.map +1 -1
- package/dist/solid/lifecycle.js +40 -0
- package/dist/solid/lifecycle.js.map +1 -1
- package/dist/solid/presence-handle.d.ts +13 -6
- package/dist/solid/presence-handle.d.ts.map +1 -1
- package/dist/solid/presence-handle.js +30 -12
- package/dist/solid/presence-handle.js.map +1 -1
- package/dist/solid/presence.d.ts +3 -1
- package/dist/solid/presence.d.ts.map +1 -1
- package/dist/solid/presence.jsx +3 -1
- package/dist/solid/presence.jsx.map +1 -1
- package/dist/solid/provider.d.ts +25 -32
- package/dist/solid/provider.d.ts.map +1 -1
- package/dist/solid/provider.jsx +86 -62
- package/dist/solid/provider.jsx.map +1 -1
- package/dist/solid/reorder-components.d.ts +32 -0
- package/dist/solid/reorder-components.d.ts.map +1 -0
- package/dist/solid/reorder-components.jsx +49 -0
- package/dist/solid/reorder-components.jsx.map +1 -0
- package/dist/solid/reorder.d.ts +50 -76
- package/dist/solid/reorder.d.ts.map +1 -1
- package/dist/solid/reorder.jsx +40 -202
- package/dist/solid/reorder.jsx.map +1 -1
- package/dist/solid/stage.d.ts +14 -0
- package/dist/solid/stage.d.ts.map +1 -1
- package/dist/solid/stage.js.map +1 -1
- package/dist/solid/unstable/v2/index.d.ts +2 -26
- package/dist/solid/unstable/v2/index.d.ts.map +1 -1
- package/dist/solid/unstable/v2/index.jsx +0 -16
- package/dist/solid/unstable/v2/index.jsx.map +1 -1
- package/dist/solid/v1/index.d.ts +1 -1
- package/dist/solid/v1/index.d.ts.map +1 -1
- package/dist/solid/v1/index.jsx +1 -1
- package/dist/solid/v1/index.jsx.map +1 -1
- package/dist/solid/variant-node.d.ts +6 -0
- package/dist/solid/variant-node.d.ts.map +1 -1
- package/dist/solid/variant-node.js +2 -0
- package/dist/solid/variant-node.js.map +1 -1
- package/dist/solid/w.d.ts +9 -3
- package/dist/solid/w.d.ts.map +1 -1
- package/dist/solid/w.jsx +36 -3
- package/dist/solid/w.jsx.map +1 -1
- package/dist/solid/ward.d.ts +134 -7
- package/dist/solid/ward.d.ts.map +1 -1
- package/dist/solid/ward.jsx +546 -48
- package/dist/solid/ward.jsx.map +1 -1
- package/dist/solid/wardic-config.d.ts +17 -12
- package/dist/solid/wardic-config.d.ts.map +1 -1
- package/dist/solid/wardic-config.jsx +68 -22
- package/dist/solid/wardic-config.jsx.map +1 -1
- package/dist/solid/wardic-context.d.ts +15 -0
- package/dist/solid/wardic-context.d.ts.map +1 -0
- package/dist/solid/wardic-context.js +23 -0
- package/dist/solid/wardic-context.js.map +1 -0
- package/dist/solid/wardic-instance.d.ts +6 -4
- package/dist/solid/wardic-instance.d.ts.map +1 -1
- package/dist/solid/wardic.d.ts +3 -0
- package/dist/solid/wardic.d.ts.map +1 -1
- package/dist/solid/wardic.jsx +3 -0
- package/dist/solid/wardic.jsx.map +1 -1
- package/package.json +26 -6
- package/src/batch-reorder-group.tsx +1 -1
- package/src/batch-reorder.ts +1 -1
- package/src/config-view.ts +30 -6
- package/src/create-batch.tsx +1 -1
- package/src/element-style.ts +77 -9
- package/src/element.tsx +25 -4
- package/src/feature-section.ts +5 -15
- package/src/hooks/auto.ts +303 -0
- package/src/hooks/config-scope.tsx +215 -0
- package/src/hooks/config.tsx +54 -0
- package/src/hooks/drag.ts +740 -0
- package/src/hooks/elements.tsx +234 -0
- package/src/hooks/group.tsx +55 -0
- package/src/hooks/index.ts +41 -0
- package/src/hooks/kept.ts +89 -0
- package/src/hooks/layout-group-of.ts +46 -0
- package/src/hooks/layout-group.tsx +111 -0
- package/src/hooks/make-ward.ts +218 -0
- package/src/hooks/presence-scope.tsx +155 -0
- package/src/hooks/presence.tsx +67 -0
- package/src/hooks/props.ts +190 -0
- package/src/hooks/reads.ts +258 -0
- package/src/hooks/refs.ts +114 -0
- package/src/hooks/reorder-elements.tsx +321 -0
- package/src/hooks/reorder.ts +205 -0
- package/src/hooks/rune.ts +1755 -0
- package/src/hooks/server-features.client.ts +10 -0
- package/src/hooks/server-features.ts +12 -0
- package/src/hooks/settings.ts +44 -0
- package/src/hooks/setup.ts +184 -0
- package/src/hooks/stage.ts +359 -0
- package/src/hooks/ward.ts +2563 -0
- package/src/hooks/wardic-provider.tsx +51 -0
- package/src/hooks/wardic-scope.tsx +112 -0
- package/src/hooks/wards.ts +679 -0
- package/src/index.tsx +27 -15
- package/src/layout.tsx +7 -74
- package/src/lazy-batch-gestures.ts +1 -1
- package/src/lifecycle.ts +40 -0
- package/src/presence-handle.ts +39 -20
- package/src/presence.tsx +3 -1
- package/src/provider.tsx +96 -71
- package/src/reorder-components.tsx +61 -0
- package/src/reorder.tsx +84 -303
- package/src/stage.ts +15 -0
- package/src/unstable/v2/index.tsx +2 -26
- package/src/v1/index.tsx +1 -1
- package/src/variant-node.ts +8 -0
- package/src/w.tsx +38 -5
- package/src/ward.tsx +674 -48
- package/src/wardic-config.tsx +68 -21
- package/src/wardic-context.ts +26 -0
- package/src/wardic-instance.ts +6 -4
- package/src/wardic.tsx +3 -0
- package/dist/browser/create-wardic.js +0 -36
- package/dist/browser/create-wardic.js.map +0 -1
- package/dist/browser/presence-hooks.js +0 -144
- package/dist/browser/presence-hooks.js.map +0 -1
- package/dist/server/create-wardic.js +0 -36
- package/dist/server/create-wardic.js.map +0 -1
- package/dist/server/presence-hooks.js +0 -144
- package/dist/server/presence-hooks.js.map +0 -1
- package/dist/solid/create-wardic.d.ts +0 -25
- package/dist/solid/create-wardic.d.ts.map +0 -1
- package/dist/solid/create-wardic.jsx +0 -34
- package/dist/solid/create-wardic.jsx.map +0 -1
- package/dist/solid/presence-hooks.d.ts +0 -53
- package/dist/solid/presence-hooks.d.ts.map +0 -1
- package/dist/solid/presence-hooks.jsx +0 -117
- package/dist/solid/presence-hooks.jsx.map +0 -1
- package/src/create-wardic.tsx +0 -46
- package/src/presence-hooks.tsx +0 -159
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hooks, and `makeWard` (probe: hooks-first).
|
|
3
|
+
*
|
|
4
|
+
* **The hooks need nothing set up.** `createWard`, `createWards` and `createPresence` are imported and
|
|
5
|
+
* called: the page's Environment is the DOM's, and each ward brings the Features its own config uses,
|
|
6
|
+
* loaded the first time one is asked for (`auto.ts`). No provider, no list of Features.
|
|
7
|
+
*
|
|
8
|
+
* **`makeWard(options)` is for a page that gives its Features at once,** in its own bundle, with
|
|
9
|
+
* nothing loaded later, and with them its own Environment or a setting a `<WardicProvider>` took
|
|
10
|
+
* (`strict`, `reducedMotion`, `appear`, `nonce`, `scaleCorrectors`). It returns `createWard` and
|
|
11
|
+
* `createWards` bringing those Features, the layout hooks with `layout`, and `w` when it's given
|
|
12
|
+
* {@link elements}. `createPresence` brings no Features of its own, so it's imported by name, as the
|
|
13
|
+
* page with nothing set up does.
|
|
14
|
+
*
|
|
15
|
+
* Its Features are asked for, not left out for the hooks' own: a `makeWard` that could be given none
|
|
16
|
+
* would hand back the hooks that load a Feature at its first use, and every app that called one would
|
|
17
|
+
* ship that loading, Features given or not (probe: hooks-first, 4.1 KB gzip).
|
|
18
|
+
*
|
|
19
|
+
* `make*` is called once, in a module, as `Wardic.make` is; `create*` in a component, where Solid's own
|
|
20
|
+
* primitives are. It took the place of the binding's own `createWardic`, deleted from Solid 2 (probe:
|
|
21
|
+
* behaviour-runes, after the scopes round).
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
import { DomLive } from "@wardic/dom"
|
|
26
|
+
import type * as Feature from "@wardic/dom/unstable/Feature"
|
|
27
|
+
import { instanceFeaturesOf } from "@wardic/dom/unstable/InstanceFeatures"
|
|
28
|
+
import { identity } from "effect/Function"
|
|
29
|
+
import * as Predicate from "effect/Predicate"
|
|
30
|
+
import * as UndefinedOr from "effect/UndefinedOr"
|
|
31
|
+
import { createInstantLayoutTransition as instantLayoutTransition, createResetProjection as resetProjection, useAnimateLayout as animateLayout, useInstanceBrought } from "../provider.tsx"
|
|
32
|
+
import { type W, withTags, wOf } from "../w.tsx"
|
|
33
|
+
import { elementsOf } from "./elements.tsx"
|
|
34
|
+
import { SLIM, type WardInternals } from "../ward.tsx"
|
|
35
|
+
import type { WardicInstance } from "../wardic-instance.ts"
|
|
36
|
+
import { bringing } from "./auto.ts"
|
|
37
|
+
import { type PageConfigSettings, type PageOptions, setupDefaultPage, setupPage } from "./setup.ts"
|
|
38
|
+
import { auto, fixed, type HookWardOf, hookWardOf, rawWardOf } from "./ward.ts"
|
|
39
|
+
import { hookPresence, type HookPresenceOf, type HookWardsOf, hookWardsOf } from "./wards.ts"
|
|
40
|
+
|
|
41
|
+
/** What gives a `makeWard` its `w`: {@link elements}, and nothing else. */
|
|
42
|
+
export type Elements = (kind: WardInternals, createWard: HookWardOf) => W
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Today's elements, for a `makeWard` that returns `w` as well: `makeWard({ features, elements })`.
|
|
46
|
+
* A value to import, not a flag, so a page that renders no `w.*` element ships none of their code.
|
|
47
|
+
* Its `w.<tag>` is the hooks' utility (the gap grill's Q27), each element's ward the `makeWard`'s own
|
|
48
|
+
* `createWard`; its `w.create` and `w.ward` are today's, of the `makeWard`'s Features.
|
|
49
|
+
*/
|
|
50
|
+
export const elements: Elements = (kind, createWard) => withTags(wOf(kind), elementsOf(createWard))
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A page's settings as `makeWard` takes them: a provider's, its `env` the DOM's unless given, and its
|
|
54
|
+
* wards' `transition`, `skipAnimations` and `transformPagePoint`, a `WardicConfig`'s for the page.
|
|
55
|
+
*/
|
|
56
|
+
export type MakeWardSettings = Omit<PageOptions, "env"> & { readonly env?: PageOptions["env"] | undefined } & PageConfigSettings
|
|
57
|
+
|
|
58
|
+
/** What `makeWard` takes: a page's settings, the Features its wards bring, and `elements` for a `w`. */
|
|
59
|
+
export type MakeWardOptions<F> = MakeWardSettings & {
|
|
60
|
+
/**
|
|
61
|
+
* The Features every ward, row and element it makes brings, wherever it's made: one, or a list, a
|
|
62
|
+
* load among them (`() => import("./drag.ts").then((m) => m.drag)`). Given at once, they're in the
|
|
63
|
+
* module's own bundle. Always given: the hooks with nothing given are the package's own `createWard`,
|
|
64
|
+
* each ward bringing what its own config uses, so a `makeWard` never ships that loading.
|
|
65
|
+
*/
|
|
66
|
+
readonly features: F
|
|
67
|
+
/** {@link elements}, for a `w` whose elements bring the same Features. */
|
|
68
|
+
readonly elements?: Elements | undefined
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* What `makeWard` returns for Features `F`: the hooks a component calls, the layout hooks when `F` has
|
|
73
|
+
* `layout`, `w` when it was given `elements`, and `with`, the same again with more Features.
|
|
74
|
+
*/
|
|
75
|
+
export type MadeWard<F, E extends boolean = false> = Omit<WardicInstance<F>, "w"> & {
|
|
76
|
+
/** One element's motion, made of runes: spread it on the element. */
|
|
77
|
+
readonly createWard: HookWardOf
|
|
78
|
+
/** A ward for each item of a list, kept until its exit has landed. */
|
|
79
|
+
readonly createWards: HookWardsOf
|
|
80
|
+
/**
|
|
81
|
+
* The same hooks with `features` beside its own, on the same page: for a module only the pages that
|
|
82
|
+
* lay out or drag import, so the rest ship neither.
|
|
83
|
+
*
|
|
84
|
+
* // src/lib/wardic-layout.ts
|
|
85
|
+
* export const { createWard, createWards, useAnimateLayout } = wardic.with(layout)
|
|
86
|
+
*/
|
|
87
|
+
readonly with: <const G extends Feature.InstanceFeaturesProp>(features: G) => MadeWard<readonly [F, G], E>
|
|
88
|
+
} & ElementsFor<F, E>
|
|
89
|
+
|
|
90
|
+
/** `w`, for a `makeWard` given `elements`; else nothing. */
|
|
91
|
+
type ElementsFor<F, E extends boolean> = E extends true ? { readonly w: W<F> } : unknown
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The page's settings out of `options`: its Features are its wards' to bring, not the page's section's.
|
|
95
|
+
* `reducedMotion` stays a read, as a provider's prop is, so a getter given for it is still followed.
|
|
96
|
+
*/
|
|
97
|
+
const pageOf = (options: MakeWardSettings): PageOptions => ({
|
|
98
|
+
env: UndefinedOr.match(options.env, { onUndefined: () => DomLive, onDefined: identity }),
|
|
99
|
+
appear: options.appear,
|
|
100
|
+
nonce: options.nonce,
|
|
101
|
+
scaleCorrectors: options.scaleCorrectors,
|
|
102
|
+
strict: options.strict,
|
|
103
|
+
get reducedMotion() {
|
|
104
|
+
return options.reducedMotion
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
/** The hooks that bring `features`, and `w` when `given` makes one. */
|
|
109
|
+
const madeOf = (features: Feature.InstanceFeaturesProp, given: Elements | undefined): object => {
|
|
110
|
+
const instance = instanceFeaturesOf(features)
|
|
111
|
+
/** `hook`, its instance's Features brought first. */
|
|
112
|
+
const brought =
|
|
113
|
+
<A>(hook: () => A) =>
|
|
114
|
+
(): A => {
|
|
115
|
+
useInstanceBrought(instance)
|
|
116
|
+
return hook()
|
|
117
|
+
}
|
|
118
|
+
// A list's rows are made by `rawWardOf`: only a ward an app is handed is one a presence may take.
|
|
119
|
+
const begin = fixed({ ...SLIM, instance })
|
|
120
|
+
// The layout hooks are there at runtime whatever its Features: its type shows them only with `layout`.
|
|
121
|
+
const hooks = {
|
|
122
|
+
createWard: hookWardOf(begin),
|
|
123
|
+
createWards: hookWardsOf(rawWardOf(begin)),
|
|
124
|
+
useAnimateLayout: brought(animateLayout),
|
|
125
|
+
createInstantLayoutTransition: brought(instantLayoutTransition),
|
|
126
|
+
createResetProjection: brought(resetProjection),
|
|
127
|
+
with: (more: Feature.InstanceFeaturesProp) => madeOf([features, more], given),
|
|
128
|
+
}
|
|
129
|
+
if (Predicate.isUndefined(given)) return hooks
|
|
130
|
+
return { ...hooks, w: given({ instance }, hooks.createWard) }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** What a layout hook brings when nothing lists a page's Features: `layout`, loaded at its first call. */
|
|
134
|
+
const LAYOUT = /*#__PURE__*/ bringing(["layout"])
|
|
135
|
+
|
|
136
|
+
/** `hook`, `layout` brought first: a layout hook, where nothing lists a page's Features. */
|
|
137
|
+
const broughtLayout =
|
|
138
|
+
<A>(hook: () => A) =>
|
|
139
|
+
(): A => {
|
|
140
|
+
useInstanceBrought(LAYOUT)
|
|
141
|
+
return hook()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Makes the hooks for a page that gives its Features at once, with its Environment or a provider's
|
|
146
|
+
* settings beside them. Call it once, in a module of its own; a module that needs more Features asks
|
|
147
|
+
* the one it made, `wardic.with(layout)`.
|
|
148
|
+
*
|
|
149
|
+
* // src/lib/wardic.ts
|
|
150
|
+
* export const wardic = makeWard({ features: domAnimation, strict: true })
|
|
151
|
+
* export const { createWard, createWards } = wardic
|
|
152
|
+
*/
|
|
153
|
+
export function makeWard<const F extends Feature.InstanceFeaturesProp>(options: MakeWardOptions<F> & { readonly elements: Elements }): MadeWard<F, true>
|
|
154
|
+
export function makeWard<const F extends Feature.InstanceFeaturesProp>(options: MakeWardOptions<F>): MadeWard<F>
|
|
155
|
+
export function makeWard(options: MakeWardOptions<Feature.InstanceFeaturesProp>): unknown {
|
|
156
|
+
setupPage(pageOf(options), options)
|
|
157
|
+
return madeOf(options.features, options.elements)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Gives the page its own Environment or a setting a `<WardicProvider>` took, where its wards still
|
|
162
|
+
* bring the Features their own configs use: the hooks imported by name, nothing listed. Call it once,
|
|
163
|
+
* in a module that loads before anything renders, as a `makeWard` is. A page that sets nothing calls
|
|
164
|
+
* nothing; one that gives its Features at once gives them to `makeWard` with its settings instead.
|
|
165
|
+
*
|
|
166
|
+
* // src/lib/wardic.ts
|
|
167
|
+
* setupWard({ strict: true, reducedMotion: "user" })
|
|
168
|
+
*/
|
|
169
|
+
export const setupWard = (settings: MakeWardSettings): void => setupPage(pageOf(settings), settings)
|
|
170
|
+
|
|
171
|
+
// As this module loads: a page that only imports the hooks below has its context, the DOM's
|
|
172
|
+
// Environment. A `setupWard` or a `makeWard` called after it gives the page's own.
|
|
173
|
+
setupDefaultPage()
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The hooks, with nothing to set up: each ward brings the Features its own config uses.
|
|
177
|
+
*
|
|
178
|
+
* import { createWard } from "@wardic/solid/hooks"
|
|
179
|
+
*
|
|
180
|
+
* const card = createWard({ initial: { opacity: 0 }, animate: { opacity: 1 }, whileHover: { y: -4 } })
|
|
181
|
+
* return <article {...card} />
|
|
182
|
+
*
|
|
183
|
+
* **A ward is made where its Subject is drawn:** in a component's body, or a row's callback, beside
|
|
184
|
+
* the markup it's spread on. A ward is one Subject, so a hook that handed one out would fix which
|
|
185
|
+
* elements there are, and the line that says what moves would sit away from what it moves. So an
|
|
186
|
+
* app's hooks hold state and give runes ({@link createRune}): runes that close over that state,
|
|
187
|
+
* functions that make one for each element, and `createRuneWith` values. Never a ward. A follower is
|
|
188
|
+
* written out where it's made, beside its leader:
|
|
189
|
+
*
|
|
190
|
+
* const opens = createRune({ initial: "closed", animate: "open" })
|
|
191
|
+
* const turns = createRune({ variants: { open: { rotate: 180 }, closed: { rotate: 0 } } })
|
|
192
|
+
*
|
|
193
|
+
* // In the component:
|
|
194
|
+
* const panel = createWard(opens)
|
|
195
|
+
* const chevron = createWard({ follow: panel }, turns)
|
|
196
|
+
*
|
|
197
|
+
* Each its own export, so an app ships only the ones it imports: one object of them all, taken apart
|
|
198
|
+
* as they're exported, kept every hook in every app that imported any (probe: hooks-first), a
|
|
199
|
+
* presence's taking and the layout hooks among them.
|
|
200
|
+
*/
|
|
201
|
+
export const createWard: HookWardOf = /*#__PURE__*/ hookWardOf(auto)
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A ward for each item of a list, kept until its exit has landed: {@link createWard}'s, for a list.
|
|
205
|
+
* Made where the list is drawn, as a ward is, from runes made once.
|
|
206
|
+
*/
|
|
207
|
+
export const createWards: HookWardsOf = /*#__PURE__*/ hookWardsOf(/*#__PURE__*/ rawWardOf(auto))
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* One ward at a time, for a value that changes: the last one leaves, then the new one enters. Made
|
|
211
|
+
* where its ward is, in the component that draws it, beside that ward.
|
|
212
|
+
*/
|
|
213
|
+
export const createPresence: HookPresenceOf = hookPresence
|
|
214
|
+
|
|
215
|
+
/** The layout hooks, `layout` brought at the first call of one. */
|
|
216
|
+
export const useAnimateLayout = /*#__PURE__*/ broughtLayout(animateLayout)
|
|
217
|
+
export const createInstantLayoutTransition = /*#__PURE__*/ broughtLayout(instantLayoutTransition)
|
|
218
|
+
export const createResetProjection = /*#__PURE__*/ broughtLayout(resetProjection)
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createPresenceScope(options)` (probe: hooks-first, the gap grill's Q9): the boundary round what its
|
|
3
|
+
* author doesn't take away themselves, a router's page or children handed in, as a value an app holds.
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* const pages = createPresenceScope({ pop: true })
|
|
7
|
+
* // The layout: a navigation ends the page it hands over.
|
|
8
|
+
* pages.within(() => props.children)
|
|
9
|
+
* // Anywhere:
|
|
10
|
+
* createEffect(pages.when("exitComplete"), () => window.scrollTo(0, 0))
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* `within(build)` builds what it's given under the scope, and keeps a child that leaves on the page
|
|
14
|
+
* until the exits of the wards inside it have landed. Each ward made there, at any depth, registers
|
|
15
|
+
* its exit with the scope as it mounts; once its child leaves, the scope runs that exit itself, from
|
|
16
|
+
* what the ward registered, so it runs after Solid has ended the child and the ward with it. Code
|
|
17
|
+
* inside a leaving child can't hear its own leave, then: the scope does, by `exiting()` and its
|
|
18
|
+
* `"exitStart"` and `"exitComplete"`, as a ward hears its own.
|
|
19
|
+
*
|
|
20
|
+
* The value is a presence handle, so it can be a `<Presence>`'s own, or another's `ref`. It's
|
|
21
|
+
* today's presence controller as a hook: `within` is `<AnimatePresence>` round what it builds, its
|
|
22
|
+
* exits told to the scope. `<AnimatePresence>` is internal now, its export deleted (after the scopes
|
|
23
|
+
* round); its body may come here.
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
27
|
+
import type { JSX } from "@solidjs/web"
|
|
28
|
+
import type { PopAnchors, PresenceMode } from "@wardic/dom/unstable/PresenceController"
|
|
29
|
+
import * as Predicate from "effect/Predicate"
|
|
30
|
+
import { DEV, getOwner, onCleanup } from "solid-js"
|
|
31
|
+
import { AnimatePresence } from "../presence.tsx"
|
|
32
|
+
import { createPresence as makeRef, ownPresenceHandle, type Presence as Handle } from "../presence-handle.ts"
|
|
33
|
+
import type { PopCorner } from "./rune.ts"
|
|
34
|
+
import { popAnchorsOf } from "./ward.ts"
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A presence's exits, heard: `exiting()`, and `next`, `each` and `when` of `"exitStart"` and
|
|
38
|
+
* `"exitComplete"`, a ward's own words for its own exit.
|
|
39
|
+
*/
|
|
40
|
+
export type PresenceRef = Handle
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A handle for a `<Presence>`'s `ref`, made before the boundary is: it hears that boundary's exits
|
|
44
|
+
* from then on. A presence scope is one already.
|
|
45
|
+
*/
|
|
46
|
+
export const createPresenceRef: () => PresenceRef = makeRef
|
|
47
|
+
|
|
48
|
+
/** What a presence scope takes, however its children come and go. */
|
|
49
|
+
interface ScopeShared {
|
|
50
|
+
/**
|
|
51
|
+
* `false`: what's there as the boundary is made has no entrance, and starts at its `animate`. What
|
|
52
|
+
* comes later enters from its `initial`. A ward's own `enter: false`, said for everything inside.
|
|
53
|
+
*/
|
|
54
|
+
readonly enter?: false | undefined
|
|
55
|
+
/** What a leaving child's dynamic `exit` resolves with: it has left, and can't be handed anything new. */
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
readonly custom?: any
|
|
58
|
+
/** Inside another boundary's child: as that child leaves, this one's children leave too, each by its exit. */
|
|
59
|
+
readonly propagate?: boolean | undefined
|
|
60
|
+
/** `false`: its children's coming and going moves no `layout` element around them. */
|
|
61
|
+
readonly affectsLayout?: boolean | undefined
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* What {@link createPresenceScope} takes. With neither `pop` nor `wait`, a child enters at once,
|
|
66
|
+
* beside the one leaving. One or the other, not both.
|
|
67
|
+
*/
|
|
68
|
+
export type PresenceScopeOptions = ScopeShared &
|
|
69
|
+
(
|
|
70
|
+
| {
|
|
71
|
+
/**
|
|
72
|
+
* A leaving child is taken out of the flow where it was, so the next is in its place at once: a
|
|
73
|
+
* ward's `pop`, said for whatever leaves here. `true` pins it by its top left; a corner, by that.
|
|
74
|
+
*/
|
|
75
|
+
readonly pop?: boolean | PopCorner | undefined
|
|
76
|
+
readonly wait?: never
|
|
77
|
+
}
|
|
78
|
+
| {
|
|
79
|
+
/** A child enters once the one before it has gone: one thing at a time, `createPresence`'s. */
|
|
80
|
+
readonly wait?: boolean | undefined
|
|
81
|
+
readonly pop?: never
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
/** A presence scope: its exits heard, as a presence handle's, and `within`, the boundary itself. */
|
|
86
|
+
export type PresenceScope = PresenceRef & {
|
|
87
|
+
/**
|
|
88
|
+
* The boundary: `build`'s children, built under this scope, each one that leaves kept on the page
|
|
89
|
+
* until the wards inside it have run their exits. One boundary a scope.
|
|
90
|
+
*/
|
|
91
|
+
readonly within: (build: () => JSX.Element) => JSX.Element
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** How a child enters while another leaves: `wait`, else `pop`, else beside it. */
|
|
95
|
+
const modeOf = (wait: boolean | undefined, anchors: PopAnchors | undefined): PresenceMode => {
|
|
96
|
+
if (wait === true) return "wait"
|
|
97
|
+
if (Predicate.isNotUndefined(anchors)) return "popLayout"
|
|
98
|
+
return "sync"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** The inline edge a popped child is pinned by: none without a `pop`. */
|
|
102
|
+
const xOf = (anchors: PopAnchors | undefined): PopAnchors["x"] | undefined => {
|
|
103
|
+
if (Predicate.isUndefined(anchors)) return undefined
|
|
104
|
+
return anchors.x
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The block edge a popped child is pinned by: none without a `pop`. */
|
|
108
|
+
const yOf = (anchors: PopAnchors | undefined): PopAnchors["y"] | undefined => {
|
|
109
|
+
if (Predicate.isUndefined(anchors)) return undefined
|
|
110
|
+
return anchors.y
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A presence scope, with `options`: what its boundary keeps on the page while it leaves, and what's
|
|
115
|
+
* heard of it. See the module.
|
|
116
|
+
*/
|
|
117
|
+
export const createPresenceScope = (options: PresenceScopeOptions = {}): PresenceScope => {
|
|
118
|
+
const scope = ownPresenceHandle()
|
|
119
|
+
// Its boundaries on the page now, for the warning in development: one a scope (Q9). One made again,
|
|
120
|
+
// its old one ended by its owner, is still one.
|
|
121
|
+
let live = 0
|
|
122
|
+
let warned = false
|
|
123
|
+
const counted = (): void => {
|
|
124
|
+
live += 1
|
|
125
|
+
if (Predicate.isNotNull(getOwner())) onCleanup(() => void (live -= 1))
|
|
126
|
+
if (!DEV || warned || live < 2) return
|
|
127
|
+
warned = true
|
|
128
|
+
console.warn(ONE_BOUNDARY)
|
|
129
|
+
}
|
|
130
|
+
// Read where the boundary reads each: `options` may be a component's props.
|
|
131
|
+
const within = (build: () => JSX.Element): JSX.Element => {
|
|
132
|
+
counted()
|
|
133
|
+
return withinOf(scope, options, build)
|
|
134
|
+
}
|
|
135
|
+
return Object.defineProperty(scope, "within", { value: within }) as PresenceScope
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const ONE_BOUNDARY =
|
|
139
|
+
"createPresenceScope: a scope is one boundary, and this one's `within` is round a second while the first is on the page. Its `exiting()`, `next` and `when` are told of both as one: make a scope for each boundary."
|
|
140
|
+
|
|
141
|
+
/** The boundary `within` puts round what `build` builds: `<AnimatePresence>`'s controller, telling `scope`. */
|
|
142
|
+
const withinOf = (scope: Handle, options: PresenceScopeOptions, build: () => JSX.Element): JSX.Element => (
|
|
143
|
+
<AnimatePresence
|
|
144
|
+
mode={modeOf(options.wait, popAnchorsOf(options.pop))}
|
|
145
|
+
anchorX={xOf(popAnchorsOf(options.pop))}
|
|
146
|
+
anchorY={yOf(popAnchorsOf(options.pop))}
|
|
147
|
+
initial={options.enter !== false}
|
|
148
|
+
custom={options.custom}
|
|
149
|
+
propagate={options.propagate === true}
|
|
150
|
+
presenceAffectsLayout={options.affectsLayout}
|
|
151
|
+
ref={scope}
|
|
152
|
+
>
|
|
153
|
+
{build()}
|
|
154
|
+
</AnimatePresence>
|
|
155
|
+
)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<Presence>` (probe: hooks-first): the hooks' one boundary, for what its author doesn't take away
|
|
3
|
+
* themselves. A hook covers a thing whose coming and going its author writes (`show`, `createWards`,
|
|
4
|
+
* `createPresence(ward, value)`): the ward is made where the decision is. A router's page, children
|
|
5
|
+
* handed to a component, another library's component are ended by someone else, and everything made
|
|
6
|
+
* inside them with it, so what keeps them on the page while they leave has to be above them.
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* // The layout: a navigation ends the page it hands over.
|
|
10
|
+
* <Presence pop>{props.children}</Presence>
|
|
11
|
+
*
|
|
12
|
+
* // A page: its motion is its own, a ward on its own root.
|
|
13
|
+
* const page = createWard(fade)
|
|
14
|
+
* <ul {...page}>…</ul>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* A utility over {@link createPresenceScope}, and built from the hooks' public names alone, as an app
|
|
18
|
+
* could write it (the gap grill's Q6, HU1): its props are the scope's options. A ward under it, a
|
|
19
|
+
* hook's or a component's, leaves by its own `exit`.
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
import type { JSX } from "@solidjs/web"
|
|
24
|
+
import * as Predicate from "effect/Predicate"
|
|
25
|
+
import { untrack } from "solid-js"
|
|
26
|
+
import { createPresenceScope, type PresenceRef, type PresenceScope, type PresenceScopeOptions } from "./presence-scope.tsx"
|
|
27
|
+
|
|
28
|
+
/** {@link Presence}'s props: a presence scope's options, its children, and a `ref` for its exits. */
|
|
29
|
+
export type PresenceProps = PresenceScopeOptions & {
|
|
30
|
+
readonly children?: JSX.Element
|
|
31
|
+
/** Its exits, heard: a `createPresenceRef()` handle, or a callback handed the boundary's own. Read once. */
|
|
32
|
+
readonly ref?: ((presence: PresenceRef) => void) | undefined
|
|
33
|
+
/**
|
|
34
|
+
* A scope made elsewhere, a module's for one: this boundary is its `within`, and its options are its
|
|
35
|
+
* own, so the ones here go unread. Read once.
|
|
36
|
+
*
|
|
37
|
+
* ```tsx
|
|
38
|
+
* // src/lib/pages.ts
|
|
39
|
+
* export const pages = createPresenceScope({ pop: true })
|
|
40
|
+
* // The layout:
|
|
41
|
+
* <Presence scope={pages}>{props.children}</Presence>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
readonly scope?: PresenceScope | undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The scope a `<Presence>` is the boundary of: the one it's given, else one of its own, by its props. */
|
|
48
|
+
const scopeOf = (props: PresenceProps): PresenceScope => {
|
|
49
|
+
const given = untrack(() => props.scope)
|
|
50
|
+
if (Predicate.isNotUndefined(given)) return given
|
|
51
|
+
return createPresenceScope(props)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The boundary round what its author doesn't take away: each child that leaves stays until its
|
|
56
|
+
* wards' exits have landed. See the module.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* <Presence pop>{props.children}</Presence>
|
|
60
|
+
*/
|
|
61
|
+
export function Presence(props: PresenceProps): JSX.Element {
|
|
62
|
+
const scope = scopeOf(props)
|
|
63
|
+
const ref = untrack(() => props.ref)
|
|
64
|
+
if (Predicate.isNotUndefined(ref)) ref(scope)
|
|
65
|
+
// eslint-disable-next-line solid/reactivity -- its children read under the scope as they're made, which Solid tracks as any children
|
|
66
|
+
return scope.within(() => props.children)
|
|
67
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rune's `props` at work (probe: hooks-first): what a ward's runes set on its Subject beside moving
|
|
3
|
+
* it, carried on the ward's own spread (`RuneProps`, `rune.ts`). The page's alone: a Stage's Subject
|
|
4
|
+
* is its app's own object, with no markup to spread into.
|
|
5
|
+
*
|
|
6
|
+
* - **Each name is one key of the ward's spread, and of the ward,** a getter over the runes that give
|
|
7
|
+
* it, read where the element reads it: so a value that's an accessor is followed there, by Solid's
|
|
8
|
+
* own spread. On the ward itself as its `style` is, for a component it's spread on, which is handed
|
|
9
|
+
* the ward as its props. No attribute's name is one of a ward's own members (T12 pins it).
|
|
10
|
+
* - **A later rune's wins a name two give,** as every other key of a rune's does: its `undefined`
|
|
11
|
+
* says nothing of the name, and its `false` says none. But a list of ids ({@link ID_LISTS}) joins,
|
|
12
|
+
* in the runes' order: one rune describing its Subject doesn't take another's description away.
|
|
13
|
+
* - **Where the binding sets a name itself, it keeps it** ({@link addedTo}): a ward that drags is
|
|
14
|
+
* `draggable="false"`, which its drag needs. A Reorder row's `tabindex` and `aria-describedby` are
|
|
15
|
+
* the binding's too, and take a rune's the way they take the row's own: handed to its config
|
|
16
|
+
* (`reorder.ts`).
|
|
17
|
+
* - **A ward's spread is one object, made at its first spread and kept** (`ward.tsx`'s, #495): Solid
|
|
18
|
+
* calls the ward for it, wherever it's spread. The names are added to that object, so nothing of
|
|
19
|
+
* the binding's own changes; a ward whose runes give no `props` is left as it was, its spread not
|
|
20
|
+
* made until something spreads it.
|
|
21
|
+
* - **A server's too:** its ward has a spread of the same kind, read as its markup is rendered, and
|
|
22
|
+
* its `ward.with()` carries them as a browser's does ({@link withCarrying}).
|
|
23
|
+
* - **A ward given its Subject has them written by the hooks,** not by a spread
|
|
24
|
+
* ({@link settingOn}): Solid's writes no attribute on a server's element as the page hydrates.
|
|
25
|
+
*
|
|
26
|
+
* Nothing here runs per frame, and nothing writes a signal.
|
|
27
|
+
*
|
|
28
|
+
* @module
|
|
29
|
+
*/
|
|
30
|
+
import * as Arr from "effect/Array"
|
|
31
|
+
import * as Bool from "effect/Boolean"
|
|
32
|
+
import { constUndefined } from "effect/Function"
|
|
33
|
+
import * as Option from "effect/Option"
|
|
34
|
+
import * as Predicate from "effect/Predicate"
|
|
35
|
+
import * as Rec from "effect/Record"
|
|
36
|
+
import * as Str from "effect/String"
|
|
37
|
+
import { createRenderEffect, onCleanup } from "solid-js"
|
|
38
|
+
import { CLIENT_ONLY } from "../solid-reactivity.ts"
|
|
39
|
+
|
|
40
|
+
/** One rune's `props` as it was written, read loosely: each name's value, or an accessor of it. Typed where it's written (`RuneProps`, `rune.ts`). */
|
|
41
|
+
type Written = Readonly<Record<string, unknown>>
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The names a ward's runes set on its Subject, as the keys a spread reads: each a getter over the
|
|
45
|
+
* runes that give it, enumerable. What a ward carries ({@link carrying}).
|
|
46
|
+
*/
|
|
47
|
+
export type PropKeys = PropertyDescriptorMap
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* ARIA's attributes whose value is a list of ids, by its spec: what describes an element, labels it,
|
|
51
|
+
* or is controlled, owned or followed by it. Several runes' join, where any other name is the last's.
|
|
52
|
+
*/
|
|
53
|
+
const ID_LISTS: ReadonlySet<string> = new Set(["aria-describedby", "aria-labelledby", "aria-controls", "aria-owns", "aria-flowto", "aria-details"])
|
|
54
|
+
|
|
55
|
+
/** Every rune's `props` among a ward's `configs`, in the order its runes were given. */
|
|
56
|
+
export const runePropsOf = (configs: ReadonlyArray<object>): ReadonlyArray<Written> =>
|
|
57
|
+
Arr.filter(
|
|
58
|
+
Arr.map(configs, (config) => (config as { readonly props?: unknown }).props),
|
|
59
|
+
Predicate.isReadonlyObject,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
/** A prop as it's read: an accessor called, where its element reads it. */
|
|
63
|
+
const valueOf = (given: unknown): unknown =>
|
|
64
|
+
Bool.match(Predicate.isFunction(given), {
|
|
65
|
+
onTrue: () => (given as () => unknown)(),
|
|
66
|
+
onFalse: () => given,
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
/** Each rune's value for `name`, in the runes' order, as it reads now. */
|
|
70
|
+
const valuesOf = (runes: ReadonlyArray<Written>, name: string): ReadonlyArray<unknown> => Arr.map(runes, (each) => valueOf(each[name]))
|
|
71
|
+
|
|
72
|
+
/** `name` across the runes: the last one's that says anything of it, `undefined` saying nothing. */
|
|
73
|
+
const lastOf = (runes: ReadonlyArray<Written>, name: string) => (): unknown => Option.getOrUndefined(Arr.findLast(valuesOf(runes, name), Predicate.isNotUndefined))
|
|
74
|
+
|
|
75
|
+
/** `name` across the runes, a list of ids: every rune's, in order, and none where no rune gives one. */
|
|
76
|
+
const idsOf = (runes: ReadonlyArray<Written>, name: string) => (): string | undefined => {
|
|
77
|
+
const ids = Arr.filter(Arr.filter(valuesOf(runes, name), Predicate.isString), Str.isNonEmpty)
|
|
78
|
+
return Bool.match(Arr.isReadonlyArrayEmpty(ids), { onTrue: constUndefined, onFalse: () => Arr.join(ids, " ") })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const readerOf = (runes: ReadonlyArray<Written>, name: string): (() => unknown) =>
|
|
82
|
+
Bool.match(ID_LISTS.has(name), {
|
|
83
|
+
onTrue: () => idsOf(runes, name),
|
|
84
|
+
onFalse: () => lastOf(runes, name),
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
/** Every rune's `props` as one set of keys: each name a getter over the runes that give it. None for a ward whose runes give no `props`. */
|
|
88
|
+
export const propKeysOf = (runes: ReadonlyArray<Written>): PropKeys =>
|
|
89
|
+
Rec.fromIterableWith(Arr.dedupe(Arr.flatMap(runes, (each) => Rec.keys(each))), (name) => [name, { get: readerOf(runes, name), enumerable: true }])
|
|
90
|
+
|
|
91
|
+
const none = (keys: PropKeys): boolean => Rec.isEmptyRecord(keys)
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The names among `keys` that `ward` doesn't have already: what the hooks add to it. One it has is
|
|
95
|
+
* the binding's own to set (a drag's `draggable`, a Reorder row's two) or a member of the ward's,
|
|
96
|
+
* and a rune's of that name is left out. Called before anything else of the hooks' is put on the ward.
|
|
97
|
+
*/
|
|
98
|
+
export const addedTo = (ward: object, keys: PropKeys): PropKeys => Rec.filter(keys, (_, name) => !(name in ward))
|
|
99
|
+
|
|
100
|
+
/** The ward's own spread: what Solid reads wherever it's spread on an element, a function source being called for it. */
|
|
101
|
+
const spreadOf = (ward: object): object => (ward as () => object)()
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* `ward` carrying `keys` ({@link addedTo}'s): on its spread, what a spread of it sets on its element
|
|
105
|
+
* beside its `ref` and `style`; and on itself, as its `style` and Starting attributes are, which is
|
|
106
|
+
* what a component the ward is spread on reads as its props.
|
|
107
|
+
*/
|
|
108
|
+
export const carrying = <W extends object>(ward: W, keys: PropKeys): W => {
|
|
109
|
+
if (none(keys)) return ward
|
|
110
|
+
Object.defineProperties(spreadOf(ward), keys)
|
|
111
|
+
return Object.defineProperties(ward, keys)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** A ward's `with`: the element's own `ref` and `style` in, a spread out. */
|
|
115
|
+
type With = (own: unknown) => object
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* `ward.with(own)` carrying `keys` too ({@link addedTo}'s): its own `with`, over the binding's, whose
|
|
119
|
+
* spread is made anew at each call with the ward's `ref`, `style` and Starting attributes alone.
|
|
120
|
+
*
|
|
121
|
+
* On a server as in a browser. A browser's `with` is a member every ward shares, which a key of the
|
|
122
|
+
* ward's own goes over; a server's is a key of its own, left configurable for this (`ward.tsx`). It
|
|
123
|
+
* matters most there: Solid takes a server's attributes as they are when it hydrates, so one left
|
|
124
|
+
* out of a server's markup would stay out.
|
|
125
|
+
*
|
|
126
|
+
* A Reorder row's two attributes aren't among `keys`, being the binding's, and its `with` leaves
|
|
127
|
+
* them out: a rune's go where the row's own do, with or without them.
|
|
128
|
+
*/
|
|
129
|
+
export const withCarrying = <W extends object>(ward: W, keys: PropKeys): W => {
|
|
130
|
+
if (none(keys)) return ward
|
|
131
|
+
// The binding's own, read once: a browser's off what every ward shares, a server's off the ward.
|
|
132
|
+
const binding = (ward as { readonly with: With }).with
|
|
133
|
+
// Not enumerable, so a spread never sees it.
|
|
134
|
+
return Object.defineProperty(ward, "with", { value: (own: unknown): object => Object.defineProperties(binding(own), keys) })
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Whether `name` is one of `keys`: what Solid's spread of a ward given its Subject is told to leave to the hooks. */
|
|
138
|
+
export const isOneOf =
|
|
139
|
+
(keys: PropKeys) =>
|
|
140
|
+
(name: string): boolean =>
|
|
141
|
+
Rec.has(keys, name)
|
|
142
|
+
|
|
143
|
+
/** One attribute of an element's: its name, and a value for it. */
|
|
144
|
+
type Attribute<Value> = readonly [name: string, value: Value]
|
|
145
|
+
|
|
146
|
+
/** What Solid writes for a value: none for `false` and for nothing, an empty attribute for `true`. */
|
|
147
|
+
const isOff = (value: unknown): boolean => Bool.or(value === false, Predicate.isNullish(value))
|
|
148
|
+
|
|
149
|
+
const textOf = (value: unknown): string => Bool.match(value === true, { onTrue: () => "", onFalse: () => String(value) })
|
|
150
|
+
|
|
151
|
+
const write =
|
|
152
|
+
(el: Element) =>
|
|
153
|
+
([name, value]: Attribute<unknown>): void =>
|
|
154
|
+
Bool.match(isOff(value), {
|
|
155
|
+
onTrue: () => el.removeAttribute(name),
|
|
156
|
+
onFalse: () => el.setAttribute(name, textOf(value)),
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
/** What an element had under a name before a ward set it, put back: its value, or none. */
|
|
160
|
+
const putBack =
|
|
161
|
+
(el: Element) =>
|
|
162
|
+
([name, was]: Attribute<string | null>): void =>
|
|
163
|
+
Option.match(Option.fromNullOr(was), {
|
|
164
|
+
onNone: () => el.removeAttribute(name),
|
|
165
|
+
onSome: (value) => el.setAttribute(name, value),
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* `keys` set on `el`, the Subject a ward was given: an element another renders, which the ward is
|
|
170
|
+
* never spread on and which outlives it. Each name written as any of them changes, and what `el` had
|
|
171
|
+
* under each put back once the owner this is called under ends.
|
|
172
|
+
*
|
|
173
|
+
* By the hooks themselves, where a spread ward's are Solid's to write. Solid's spread writes no
|
|
174
|
+
* attribute on a connected element while the page hydrates, taking a server's markup as it is, and a
|
|
175
|
+
* ward given its Subject put nothing in that markup: its runes' attributes were never set. What
|
|
176
|
+
* `el` had is read as this is called; changed since by whoever renders it, it's that older value
|
|
177
|
+
* that's put back.
|
|
178
|
+
*/
|
|
179
|
+
export const settingOn = (el: Element, keys: PropKeys): void => {
|
|
180
|
+
if (none(keys)) return
|
|
181
|
+
const names = Rec.keys(keys)
|
|
182
|
+
const before = Arr.map(names, (name): Attribute<string | null> => [name, el.getAttribute(name)])
|
|
183
|
+
const now = Object.defineProperties({}, keys) as Readonly<Record<string, unknown>>
|
|
184
|
+
createRenderEffect(
|
|
185
|
+
() => Arr.map(names, (name): Attribute<unknown> => [name, now[name]]),
|
|
186
|
+
(attributes) => Arr.forEach(attributes, write(el)),
|
|
187
|
+
CLIENT_ONLY,
|
|
188
|
+
)
|
|
189
|
+
onCleanup(() => Arr.forEach(before, putBack(el)))
|
|
190
|
+
}
|