@wardic/solid 2.1.2 → 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/batch-reorder-places.js +3 -3
- package/dist/browser/batch-reorder.js +8 -5
- package/dist/browser/batch-reorder.js.map +1 -1
- package/dist/browser/config-view.js +33 -5
- package/dist/browser/config-view.js.map +1 -1
- package/dist/browser/create-animation-controls.js +22 -0
- package/dist/browser/create-animation-controls.js.map +1 -0
- 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/gesture-callbacks.js +3 -1
- package/dist/browser/gesture-callbacks.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 +24 -12
- 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 +59 -13
- package/dist/browser/lifecycle.js.map +1 -1
- package/dist/browser/motion-props.js +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-ward.js +2 -2
- package/dist/browser/stage-ward.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/batch-reorder-group.js +4 -4
- package/dist/browser/v1/create-ward.js +3 -3
- package/dist/browser/v1/create-ward.js.map +1 -1
- package/dist/browser/v1/index.js +1 -1
- package/dist/browser/v1/index.js.map +1 -1
- package/dist/browser/v1/presence.js +1 -1
- package/dist/browser/v1/presence.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 +579 -52
- 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/batch-reorder-places.js +3 -3
- package/dist/server/batch-reorder.js +8 -5
- package/dist/server/batch-reorder.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-animation-controls.js +22 -0
- package/dist/server/create-animation-controls.js.map +1 -0
- 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/gesture-callbacks.js +3 -1
- package/dist/server/gesture-callbacks.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 +24 -12
- 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 +59 -13
- package/dist/server/lifecycle.js.map +1 -1
- package/dist/server/motion-props.js +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-ward.js +2 -2
- package/dist/server/stage-ward.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/batch-reorder-group.js +4 -4
- package/dist/server/v1/create-ward.js +3 -3
- package/dist/server/v1/create-ward.js.map +1 -1
- package/dist/server/v1/index.js +1 -1
- package/dist/server/v1/index.js.map +1 -1
- package/dist/server/v1/presence.js +1 -1
- package/dist/server/v1/presence.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 +579 -52
- 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-places.js +3 -3
- package/dist/solid/batch-reorder.d.ts +1 -1
- package/dist/solid/batch-reorder.d.ts.map +1 -1
- package/dist/solid/batch-reorder.js +8 -5
- package/dist/solid/batch-reorder.js.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-animation-controls.d.ts +20 -0
- package/dist/solid/create-animation-controls.d.ts.map +1 -0
- package/dist/solid/create-animation-controls.js +22 -0
- package/dist/solid/create-animation-controls.js.map +1 -0
- 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/gesture-callbacks.d.ts.map +1 -1
- package/dist/solid/gesture-callbacks.js +2 -0
- package/dist/solid/gesture-callbacks.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 +25 -17
- package/dist/solid/index.d.ts.map +1 -1
- package/dist/solid/index.jsx +24 -12
- 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 +32 -5
- package/dist/solid/lifecycle.d.ts.map +1 -1
- package/dist/solid/lifecycle.js +60 -21
- package/dist/solid/lifecycle.js.map +1 -1
- package/dist/solid/motion-props.js +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-ward.jsx +2 -2
- package/dist/solid/stage-ward.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 +6 -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/batch-reorder-group.jsx +4 -4
- package/dist/solid/v1/create-ward.jsx +3 -3
- package/dist/solid/v1/create-ward.jsx.map +1 -1
- package/dist/solid/v1/index.d.ts +3 -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/v1/presence.jsx +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 +549 -51
- 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-places.ts +3 -3
- package/src/batch-reorder.ts +9 -6
- package/src/config-view.ts +30 -6
- package/src/create-animation-controls.ts +22 -0
- 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/gesture-callbacks.ts +2 -0
- 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 +31 -17
- package/src/layout.tsx +7 -74
- package/src/lazy-batch-gestures.ts +1 -1
- package/src/lifecycle.ts +72 -24
- package/src/motion-props.ts +1 -1
- 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-ward.tsx +3 -3
- package/src/stage.ts +15 -0
- package/src/unstable/v2/index.tsx +6 -26
- package/src/v1/batch-reorder-group.tsx +4 -4
- package/src/v1/create-ward.tsx +4 -4
- package/src/v1/index.tsx +3 -1
- package/src/v1/presence.tsx +1 -1
- package/src/variant-node.ts +8 -0
- package/src/w.tsx +38 -5
- package/src/ward.tsx +679 -53
- 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,679 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createWards(list, ...runes)` and `createPresence(ward, value)` (probe: hooks-first): wards made by a
|
|
3
|
+
* hook for what comes and goes, and not by the `<For>` or `<Show>` that renders them, so a ward
|
|
4
|
+
* outlives its item's place on the page. No `<AnimatePresence>`.
|
|
5
|
+
*
|
|
6
|
+
* **`createWards`**: a ward for each item of a list. An item that leaves the list stays in what it
|
|
7
|
+
* returns, at its index, until its ward's exit has landed; one that comes back first carries on from
|
|
8
|
+
* where it is.
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function Posts(props: { posts: ReadonlyArray<{ title: string }> }) {
|
|
12
|
+
* const rows = createWards(() => props.posts, { initial: { opacity: 0 }, animate: { opacity: 1 } })
|
|
13
|
+
* return <For each={rows()}>{(row) => <li {...row}>{row.item.title}</li>}</For>
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* **`createPresence`**: one ward at a time, for a value that changes. Its motion is a ward's, made by
|
|
18
|
+
* `createWard` as any other, and given first. The ward of the value that was leaves, and only once it
|
|
19
|
+
* has gone does the new value's ward enter. A value of `undefined`, `null` or `false` shows nothing.
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const panel = createWard({ initial: { opacity: 0 }, animate: { opacity: 1 } })
|
|
23
|
+
* const shown = createPresence(panel, tab)
|
|
24
|
+
* <Show when={shown()} keyed>{(tab) => <div {...panel}><Panel tab={tab} /></div>}</Show>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The ward given is what's spread, and `shown()` is the value on the page. It's the one ward
|
|
28
|
+
* throughout: the presence takes it (`ward.ts`'s `takenOf`) and says when its value is on the page, so
|
|
29
|
+
* it leaves as a `show` ward does, and the next value's element, a new one, enters afresh from its
|
|
30
|
+
* `initial`. A sensor or a listener made on it hears every value's element.
|
|
31
|
+
*
|
|
32
|
+
* - **The list or the value** is an accessor; or `{ each, key, initial }` (`{ value, key }` for
|
|
33
|
+
* `createPresence`). Items match by identity, as `<For>`'s, or by `key` for items made again (a
|
|
34
|
+
* refetch). `initial: false`: the list's first rows have no entrance, and what comes later enters from
|
|
35
|
+
* its `initial`. A presence's ward says the same of itself, with `enter: false`: it's made before its
|
|
36
|
+
* presence is, and a ward decides how it starts as it's made.
|
|
37
|
+
* - **Each ward** is `createWard({ show }, ...runes)`, its `show` whether its item is there, with `item`
|
|
38
|
+
* (reactive: the latest under its key, and the last once it has gone) and `index()` (its place among
|
|
39
|
+
* what's rendered).
|
|
40
|
+
* - **A row that pops** (`pop` in its runes) is measured before the change that takes it out reaches
|
|
41
|
+
* the page, with every other row leaving then, as a presence measures its leavers ahead.
|
|
42
|
+
* - **A function among the runes** is called for each row, with its `item` and `index`, and gives that
|
|
43
|
+
* row's rune.
|
|
44
|
+
*
|
|
45
|
+
* @module
|
|
46
|
+
*/
|
|
47
|
+
import { type PopAnchors, type PopBox, popBoxOf } from "@wardic/dom/unstable/PresenceController"
|
|
48
|
+
import * as Arr from "effect/Array"
|
|
49
|
+
import * as Bool from "effect/Boolean"
|
|
50
|
+
import { constFalse, constTrue, constVoid, identity } from "effect/Function"
|
|
51
|
+
import * as Iter from "effect/Iterable"
|
|
52
|
+
import * as Predicate from "effect/Predicate"
|
|
53
|
+
import * as UndefinedOr from "effect/UndefinedOr"
|
|
54
|
+
import { type Accessor, createEffect, createMemo, createRoot, createSignal, getOwner, runWithOwner, untrack } from "solid-js"
|
|
55
|
+
import { makePresenceHandle } from "../presence-handle.ts"
|
|
56
|
+
import { sensedOf } from "../ward.tsx"
|
|
57
|
+
import { type DragIn, type FitRune, type FitTaggedRune, isFunctionRune, type OnThePage, type Rune, type RuneIn, type RunesTaken, type TagIn } from "./rune.ts"
|
|
58
|
+
import type { Drags } from "./drag.ts"
|
|
59
|
+
import { type ExitEvent, type ExitEvents, exitsNow, type HookWard, type HookWardOf, leaveCommitted, leavesNow, letGo, popAnchorsFor, rowInLayout, type TaggedWard, takenOf, tellingExits, whenLeft } from "./ward.ts"
|
|
60
|
+
|
|
61
|
+
/** A list for `createWards`, with how its items match. */
|
|
62
|
+
export interface WardsSource<T> {
|
|
63
|
+
/** The list. */
|
|
64
|
+
readonly each: Accessor<ReadonlyArray<T>>
|
|
65
|
+
/** What an item is matched by, when the list's items are made again; left out, the item itself. */
|
|
66
|
+
readonly key?: ((item: T) => unknown) | undefined
|
|
67
|
+
/** `false`: the rows of the first list have no entrance. */
|
|
68
|
+
readonly initial?: false | undefined
|
|
69
|
+
/**
|
|
70
|
+
* `true`: while a row is leaving, a new item waits off the page, and comes once the last has gone:
|
|
71
|
+
* a set swapped for another, the old rows leaving before the new ones enter (the gap grill's Q10).
|
|
72
|
+
* `createPresence`'s, for a list. Left out, a new item enters at once, beside the rows leaving.
|
|
73
|
+
*/
|
|
74
|
+
readonly wait?: boolean | undefined
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* One value for `createWards`, as the list of what's on the page for it: the value now, and the one
|
|
79
|
+
* it took the place of until that one has gone. Both are there at once, as a list's rows are, where a
|
|
80
|
+
* `createPresence` has its value wait for the last to go.
|
|
81
|
+
*/
|
|
82
|
+
export interface WardsValue<T> {
|
|
83
|
+
/** The value, `T` when there is one: `undefined`, `null` or `false` is nothing on the page. */
|
|
84
|
+
readonly value: Accessor<T | undefined | null | false>
|
|
85
|
+
/** What a value is matched by, when it's made again; left out, the value itself. */
|
|
86
|
+
readonly key?: ((value: T) => unknown) | undefined
|
|
87
|
+
/** `false`: the value there at first has no entrance. */
|
|
88
|
+
readonly initial?: false | undefined
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A value for `createPresence`, with how it's matched. */
|
|
92
|
+
export interface PresenceSource<T> {
|
|
93
|
+
/** The value: `undefined`, `null` or `false` shows nothing. */
|
|
94
|
+
readonly value: Accessor<T>
|
|
95
|
+
/** What a value is matched by, when it's made again; left out, the value itself. */
|
|
96
|
+
readonly key?: ((value: NonNullable<T>) => unknown) | undefined
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* What a list or a presence on the page says of the layout around it: a Stage has no layout to move.
|
|
101
|
+
* `<Presence>`'s `affectsLayout`.
|
|
102
|
+
*/
|
|
103
|
+
export interface AffectsLayout {
|
|
104
|
+
/**
|
|
105
|
+
* `false`: a `layout` element beside it moves at once as what it shows comes, pops and goes, where it
|
|
106
|
+
* would move into the space by animation (the gap grill's Q14). Left out, or `true`, it animates.
|
|
107
|
+
*/
|
|
108
|
+
readonly affectsLayout?: boolean | undefined
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A value for a Stage's `createPresence`, which makes a ward for each value and so can say how the first starts. */
|
|
112
|
+
export interface StagePresenceSource<T> extends PresenceSource<T> {
|
|
113
|
+
/** `false`: the value there at first has no entrance. */
|
|
114
|
+
readonly initial?: false | undefined
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** What a row's function is handed: its item, and its place. */
|
|
118
|
+
export interface Row<T> {
|
|
119
|
+
/** The row's item: the latest under its key, and its last once it has left the list. */
|
|
120
|
+
readonly item: T
|
|
121
|
+
/** Its place among the rows rendered, leaving ones counted. */
|
|
122
|
+
readonly index: Accessor<number>
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** One row's ward. */
|
|
126
|
+
export type RowWard<T, Tag = undefined> = TaggedWard<Tag> & Row<T>
|
|
127
|
+
|
|
128
|
+
/** The tag one of a list's runes names: a function of the row's, as what it gives. */
|
|
129
|
+
type RowTagIn<X> = X extends (...args: never) => infer Gives ? TagIn<Gives> : TagIn<X>
|
|
130
|
+
|
|
131
|
+
/** The tag a list's runes `A` name, which its rows' spreads are typed for, read over them as one union as a ward's is (`TagGiven`): none where none does. */
|
|
132
|
+
export type RowTagGiven<A extends ReadonlyArray<unknown>> = [RowTagIn<A[number]>] extends [never] ? undefined : RowTagIn<A[number]>
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* A rune for every row, or a function of each row that gives its rune, before any check: what a
|
|
136
|
+
* hook of an app's own takes to pass on to a list. `P` is a rune where its wards are: the page's,
|
|
137
|
+
* unless a Stage's hooks say theirs.
|
|
138
|
+
*/
|
|
139
|
+
export type RowRune<T, P = Rune> = P | ((row: Row<T>) => P)
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* One of a list's runes as it's given, where `Taken` is: a function of the row checked by the rune it
|
|
143
|
+
* gives, and anything else as a ward's own rune is ({@link FitRune}). So a key its ward doesn't take
|
|
144
|
+
* is an error here that names it, in a constant and in what a row's function gives, and so is a
|
|
145
|
+
* value its ward doesn't animate, by its name. A transition's keys are checked by name there too:
|
|
146
|
+
* the checker itself has no error for what's extra inside a transition a function gives back.
|
|
147
|
+
*
|
|
148
|
+
* Before the rune's own type is known it's the plain {@link RowRune}, which is where a row's function
|
|
149
|
+
* gets its `row` from and an editor a rune's keys: both are asked for first.
|
|
150
|
+
*/
|
|
151
|
+
export type FitRowRune<T, X, Taken extends RunesTaken> = unknown extends X
|
|
152
|
+
? RowRune<T, RuneIn<Taken>>
|
|
153
|
+
: X extends (...args: never) => infer Gives
|
|
154
|
+
? (row: Row<T>) => FitTaggedRune<Gives, Taken>
|
|
155
|
+
: FitTaggedRune<X, Taken>
|
|
156
|
+
|
|
157
|
+
/** The runes a list is given, each checked as {@link FitRowRune}. */
|
|
158
|
+
export type RowRunesGiven<T, A extends ReadonlyArray<unknown>, Taken extends RunesTaken> = { readonly [I in keyof A]: FitRowRune<T, A[I], Taken> }
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* `createWards(list, ...runes)`, its rows' runes checked as a ward's are where `Taken` is: the page,
|
|
162
|
+
* unless a Stage's hooks say theirs. Over a list, or over one value (`{ value }`): a row for the value
|
|
163
|
+
* now, and one for the value it replaced until that has gone.
|
|
164
|
+
*
|
|
165
|
+
* One signature for both. With an overload for each, the checker told only the last one's error, and
|
|
166
|
+
* a key a row's ward doesn't take read as the list not being a `{ value }`.
|
|
167
|
+
*/
|
|
168
|
+
export type HookWardsOf<Taken extends RunesTaken = OnThePage> = <T, A extends ReadonlyArray<unknown>>(
|
|
169
|
+
source: Accessor<ReadonlyArray<T>> | (WardsSource<T> & AffectsLayout) | (WardsValue<T> & AffectsLayout),
|
|
170
|
+
...runes: RowRunesGiven<T, A, Taken>
|
|
171
|
+
) => Accessor<ReadonlyArray<RowWard<T, RowTagGiven<A>> & RowDragsGiven<A>>> & Leaving
|
|
172
|
+
|
|
173
|
+
/** Whether one of a list's runes gives a `drag`: a function of the row's, as what it gives (probe: behaviour-runes, Q20). */
|
|
174
|
+
type RowDragIn<X> = X extends (...args: never) => infer Gives ? DragIn<Gives> : DragIn<X>
|
|
175
|
+
|
|
176
|
+
/** The mark of rows that drag, where one of `A`'s runes gives a `drag` (Q20). */
|
|
177
|
+
type RowDragsGiven<A extends ReadonlyArray<unknown>> = [RowDragIn<A[number]>] extends [never] ? unknown : Drags
|
|
178
|
+
|
|
179
|
+
/** `createPresence(ward, value)`: the value on the page, the one leaving until it has gone. */
|
|
180
|
+
export type HookPresenceOf = <T>(ward: HookWard, source: Accessor<T> | (PresenceSource<T> & AffectsLayout)) => Accessor<NonNullable<T> | undefined> & Leaving
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* What a list or a presence says of its own leaving (the gap grill's Q13), in a ward's words for its
|
|
184
|
+
* own exit: `"exitStart"` as something starts to leave with nothing leaving before, and
|
|
185
|
+
* `"exitComplete"` once the last of what was leaving has gone, rows that left together counted as one
|
|
186
|
+
* leave. A row hears its own beside it, through its ward or a function rune.
|
|
187
|
+
*
|
|
188
|
+
* ```tsx
|
|
189
|
+
* const rows = createWards(items, fade)
|
|
190
|
+
* createEffect(rows.when("exitComplete"), () => restoreFocus())
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
export interface Leaving {
|
|
194
|
+
/** The next `name`, from the call on. */
|
|
195
|
+
next<E extends ExitEvent>(name: E): Promise<ExitEvents[E]>
|
|
196
|
+
/** Every `name`, as a memo for an effect: pending until the first. */
|
|
197
|
+
when<E extends ExitEvent>(name: E): Accessor<ExitEvents[E]>
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const VERSION_SIGNAL = { equals: false } as const
|
|
201
|
+
|
|
202
|
+
interface Kept<T> {
|
|
203
|
+
readonly key: unknown
|
|
204
|
+
readonly ward: RowWard<T>
|
|
205
|
+
readonly dispose: () => void
|
|
206
|
+
/** Where it was as it started to leave, measured before the list's change reached the page: its pop's place. */
|
|
207
|
+
readonly popped: { box: PopBox | undefined; leaving: boolean }
|
|
208
|
+
/** Whether it has been out of the list, whether it's leaving with no way back, and whether its exit has landed: it's the list's no longer. */
|
|
209
|
+
readonly fate: { away: boolean; over: boolean; gone: boolean }
|
|
210
|
+
/**
|
|
211
|
+
* Whether it's shown, for whether its item is in the list now. Asked by its own ward and by the list,
|
|
212
|
+
* in whichever order Solid runs them: the same answer either way.
|
|
213
|
+
*/
|
|
214
|
+
readonly shownFor: (here: boolean) => boolean
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** How a list's rows are kept: how they match, whether the first have an entrance, and whether a new one waits. */
|
|
218
|
+
export interface Keeping<T> {
|
|
219
|
+
readonly key: (item: T) => unknown
|
|
220
|
+
readonly initial: false | undefined
|
|
221
|
+
/** A new item stays out while a row is still leaving: one thing at a time, `createPresence`'s. */
|
|
222
|
+
readonly waits: boolean
|
|
223
|
+
/** `false`: its rows coming and going tell the layout projection nothing ({@link AffectsLayout}). */
|
|
224
|
+
readonly affectsLayout?: boolean | undefined
|
|
225
|
+
/** What makes one item's ward, where a row's is made of its item: a Reorder group's item. Left out, `ward` for all. */
|
|
226
|
+
readonly wardFor?: ((item: T) => HookWardOf) | undefined
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** A row's own rune: what a function among the runes gives of it, or the rune as it is. A Reorder list's row made by hand takes its runes so too (`createReorder`'s `row`). */
|
|
230
|
+
export const runeFor = <T>(rune: RowRune<T>, row: Row<T>): Rune => {
|
|
231
|
+
if (Predicate.isFunction(rune)) return rune(row)
|
|
232
|
+
return rune
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Whether a list's rune may give its rows a `show` of their own, over the list's: it does, written
|
|
237
|
+
* plainly, or it's a function, of the row or of its ward, which may.
|
|
238
|
+
*/
|
|
239
|
+
const mayShow = <T>(rune: RowRune<T>): boolean => {
|
|
240
|
+
if (Predicate.isFunction(rune)) return true
|
|
241
|
+
if (isFunctionRune(rune)) return true
|
|
242
|
+
return "show" in rune
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** The rows of `each`, a ward apiece from `ward`, a leaving one kept until its exit has landed. */
|
|
246
|
+
export const rowsOf = <T>(ward: HookWardOf, each: Accessor<ReadonlyArray<T>>, keeping: Keeping<T>, runes: ReadonlyArray<RowRune<T>>): Accessor<ReadonlyArray<RowWard<T>>> => {
|
|
247
|
+
// Known once for the list: whether any of its rows can be hidden with its item still in the list.
|
|
248
|
+
const ownShow = Arr.some(runes, mayShow)
|
|
249
|
+
/** The function a row's ward is made by: the list's, or its item's own. */
|
|
250
|
+
const makerOf = (item: T): HookWardOf => {
|
|
251
|
+
const own = keeping.wardFor
|
|
252
|
+
if (Predicate.isUndefined(own)) return ward
|
|
253
|
+
return own(item)
|
|
254
|
+
}
|
|
255
|
+
/** What every row's ward takes of the list's own: where it was, if it pops, and no entrance for the first list's. */
|
|
256
|
+
const listRune = (first: boolean, popped: Kept<T>["popped"]): Rune => {
|
|
257
|
+
const own: { enter?: false; popBox: () => PopBox | undefined } = { popBox: () => popped.box }
|
|
258
|
+
if (first && keeping.initial === false) own.enter = false
|
|
259
|
+
return own
|
|
260
|
+
}
|
|
261
|
+
// Each row's place among the rows rendered, made once the rows are (below): none while the first are made.
|
|
262
|
+
let positions: Accessor<ReadonlyMap<object, number>> | undefined
|
|
263
|
+
// The first list's rows: made before anything has been rendered.
|
|
264
|
+
let started = false
|
|
265
|
+
// The rows' owner: a root made here, where the hook is called, so each row's own root is its child
|
|
266
|
+
// and none is the component's. A row made under the component's owner would take one of its
|
|
267
|
+
// hydration ids, at whatever moment the list is first read, and a server and a client read it at
|
|
268
|
+
// different moments: every key after it would miss.
|
|
269
|
+
const owner = createRoot(() => getOwner())
|
|
270
|
+
/** The list's items by key, as it is now. */
|
|
271
|
+
const present = createMemo(() => {
|
|
272
|
+
const byKey = new Map<unknown, T>()
|
|
273
|
+
Arr.forEach(each(), (item) => void byKey.set(keeping.key(item), item))
|
|
274
|
+
return byKey
|
|
275
|
+
})
|
|
276
|
+
const kept = new Map<unknown, Kept<T>>()
|
|
277
|
+
let order: ReadonlyArray<Kept<T>> = []
|
|
278
|
+
// Whether a row has landed since the order was last read: it's still in it, marked gone.
|
|
279
|
+
let landed = false
|
|
280
|
+
// Written as a row's exit lands, from an effect's apply: the list is read again without it.
|
|
281
|
+
const [dropped, drop] = createSignal(0, VERSION_SIGNAL)
|
|
282
|
+
|
|
283
|
+
/** A row's item: the list's under its key, and the last one it had once it has left. */
|
|
284
|
+
const itemOf = (key: unknown, first: T): Accessor<T> => {
|
|
285
|
+
// Matched by identity, it's the item its row was made for, always: no memo follows the list for it.
|
|
286
|
+
if (keeping.key === identity) return () => first
|
|
287
|
+
let last = first
|
|
288
|
+
return createMemo<T>(() => {
|
|
289
|
+
const now = present()
|
|
290
|
+
if (now.has(key)) last = now.get(key) as T
|
|
291
|
+
return last
|
|
292
|
+
})
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** A row for `key`, made at `startAt` among the rows: its ward under a root of its own, owned where the hook was called. */
|
|
296
|
+
const rowFor = (key: unknown, first: T, inFirstList: boolean, startAt: number): Kept<T> =>
|
|
297
|
+
runWithOwner(owner, () =>
|
|
298
|
+
createRoot((dispose) => {
|
|
299
|
+
const item = itemOf(key, first)
|
|
300
|
+
// Its ward once it's made: read as the row is made, by its row's function or by what reads its
|
|
301
|
+
// accessors for their Features, its place is where it's being made, the list's places not yet there.
|
|
302
|
+
let ward: object | undefined
|
|
303
|
+
// By its ward, not its key: an item back beside the row it left has two rows under one key.
|
|
304
|
+
const index = (): number => {
|
|
305
|
+
const places = positions
|
|
306
|
+
if (Predicate.isUndefined(places) || Predicate.isUndefined(ward)) return startAt
|
|
307
|
+
const at = places().get(ward)
|
|
308
|
+
if (Predicate.isUndefined(at)) return -1
|
|
309
|
+
return at
|
|
310
|
+
}
|
|
311
|
+
const row: Row<T> = {
|
|
312
|
+
get item() {
|
|
313
|
+
return item()
|
|
314
|
+
},
|
|
315
|
+
index,
|
|
316
|
+
}
|
|
317
|
+
const popped: Kept<T>["popped"] = { box: undefined, leaving: false }
|
|
318
|
+
const fate: Kept<T>["fate"] = { away: false, over: false, gone: false }
|
|
319
|
+
// Read late: its ward isn't made yet as its `show` is.
|
|
320
|
+
let committed: () => boolean = constFalse
|
|
321
|
+
let release: () => void = constVoid
|
|
322
|
+
// An item that comes back while its row leaves turns the row round, unless what the row held as
|
|
323
|
+
// it left has ended, the twins it handed home: those don't come back on its element. That row
|
|
324
|
+
// goes on leaving, shown no more, and the list makes the item a row of its own. The new row's
|
|
325
|
+
// twins are the ones on the page from then on, so the old row waits for no handover: it's gone
|
|
326
|
+
// as its own exit lands, and doesn't lie unseen over the row that took its place.
|
|
327
|
+
const shownFor = (here: boolean): boolean => {
|
|
328
|
+
if (fate.over) return false
|
|
329
|
+
if (!here) {
|
|
330
|
+
fate.away = true
|
|
331
|
+
return false
|
|
332
|
+
}
|
|
333
|
+
if (fate.away && committed()) {
|
|
334
|
+
fate.over = true
|
|
335
|
+
// After this read: it may be a memo's, and letting go writes.
|
|
336
|
+
queueMicrotask(release)
|
|
337
|
+
return false
|
|
338
|
+
}
|
|
339
|
+
fate.away = false
|
|
340
|
+
return true
|
|
341
|
+
}
|
|
342
|
+
const given = runes.map((rune) => runeFor(rune, row))
|
|
343
|
+
const made = makerOf(first)({ show: () => shownFor(present().has(key)) }, ...given, listRune(inFirstList, popped))
|
|
344
|
+
ward = made
|
|
345
|
+
// A row that comes later pushes what's after it; the first are laid out with the page.
|
|
346
|
+
const affects = keeping.affectsLayout !== false
|
|
347
|
+
if (!inFirstList || !affects) rowInLayout(made, !inFirstList, affects)
|
|
348
|
+
// Whether a function rune is among its runes: what it made of its own is under this root, and
|
|
349
|
+
// hears its row's end only if the root outlasts the flush that end is told in (below).
|
|
350
|
+
const listens = Arr.some(given, isFunctionRune)
|
|
351
|
+
committed = () => leaveCommitted(made)
|
|
352
|
+
release = () => letGo(made)
|
|
353
|
+
Object.defineProperty(made, "item", { get: item })
|
|
354
|
+
Object.defineProperty(made, "index", { value: index })
|
|
355
|
+
const entry: Kept<T> = { key, ward: made as unknown as RowWard<T>, dispose, popped, fate, shownFor }
|
|
356
|
+
// Its exit landed: it leaves what's rendered, and its ward goes with it.
|
|
357
|
+
const left = (): void => {
|
|
358
|
+
// Hidden with its item still in the list isn't gone, unless it's the row that went on leaving.
|
|
359
|
+
if (!fate.over && untrack(present).has(key)) return
|
|
360
|
+
if (kept.get(key) === entry) kept.delete(key)
|
|
361
|
+
// Left out by the list in the change that took its item out (`goneAtOnce`): its ward ends, and
|
|
362
|
+
// nothing is written for the list, which has it out already.
|
|
363
|
+
const already = fate.gone
|
|
364
|
+
// Marked, not taken out of the order here: the list's next read leaves it out, once for
|
|
365
|
+
// every row that landed with it. Filtered out one row at a time, a list's leaving grew
|
|
366
|
+
// with the square of its rows.
|
|
367
|
+
fate.gone = true
|
|
368
|
+
if (!already) landed = true
|
|
369
|
+
// Its exit's end is told while it can still be heard: its ward ends with this root. Where a
|
|
370
|
+
// function rune is among its runes, the root ends once this flush is done, not in it: what
|
|
371
|
+
// the rune made of its own, an effect over `ward.mounted()` or `ward.when("exitComplete")`,
|
|
372
|
+
// is under this root too, and ended here it never ran for the end it was made to hear.
|
|
373
|
+
exitsNow(made)
|
|
374
|
+
Bool.match(listens, { onTrue: () => queueMicrotask(dispose), onFalse: dispose })
|
|
375
|
+
if (!already) drop(1)
|
|
376
|
+
}
|
|
377
|
+
// Told by its ward, in the effect that ward has already for whether it's mounted: a row had
|
|
378
|
+
// one of its own for it. Watched here for a ward that tells no such thing, a Stage's.
|
|
379
|
+
// Whether it ends as it goes, with nowhere to rest: what its `animate` and its `style` ask as
|
|
380
|
+
// they're read. A row whose only `show` is the list's always does: hidden, its item has left
|
|
381
|
+
// or it went on leaving. Asked each time, a row read whether it's mounted for its style as
|
|
382
|
+
// it was made, and the list every row's item, where nothing of either is wanted while the
|
|
383
|
+
// row is shown: a list's first frame cost a tenth more for it. One with a `show` of its own
|
|
384
|
+
// may be hidden with its item still there, and rests and is hidden then: that one is asked.
|
|
385
|
+
let ends: () => boolean = constTrue
|
|
386
|
+
if (ownShow) ends = () => fate.over || !untrack(present).has(key)
|
|
387
|
+
if (!whenLeft(made, left, ends)) {
|
|
388
|
+
createEffect(
|
|
389
|
+
() => made.mounted(),
|
|
390
|
+
(mounted) => {
|
|
391
|
+
if (mounted) return
|
|
392
|
+
left()
|
|
393
|
+
},
|
|
394
|
+
)
|
|
395
|
+
}
|
|
396
|
+
return entry
|
|
397
|
+
}),
|
|
398
|
+
) as Kept<T>
|
|
399
|
+
|
|
400
|
+
// How many rows have gone at once, as their items left: what the list's own exits are told of, start
|
|
401
|
+
// and end together, where no row stays to leave. Counted up only, so a reader compares it.
|
|
402
|
+
let goneAtOnceCount = 0
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* A row gone in the change that took its item out: it has nowhere to leave to and nothing inside it
|
|
406
|
+
* or following it to wait for (`leavesNow`). Left to its own effect, it was dropped by a write in the
|
|
407
|
+
* flush that took its item out, and the list read again in that flush: Solid's tear.
|
|
408
|
+
*/
|
|
409
|
+
const goneAtOnce = (entry: Kept<T>): void => {
|
|
410
|
+
entry.fate.gone = true
|
|
411
|
+
if (kept.get(entry.key) === entry) kept.delete(entry.key)
|
|
412
|
+
goneAtOnceCount += 1
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** Whether `entry` is on its way out: its item out of the list, or back in it with a row of its own. */
|
|
416
|
+
const leavingIn = (entry: Kept<T>, now: ReadonlyMap<unknown, T>): boolean => {
|
|
417
|
+
if (entry.fate.gone) return false
|
|
418
|
+
if (entry.fate.over) return true
|
|
419
|
+
return !now.has(entry.key) && kept.get(entry.key) === entry
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const rows = createMemo<ReadonlyArray<Kept<T>>>(() => {
|
|
423
|
+
dropped()
|
|
424
|
+
const now = present()
|
|
425
|
+
// The rows that have landed leave the order here, once for all of them, before anything goes by
|
|
426
|
+
// it: a row still leaving goes back by its place in the order, and a landed row left in it
|
|
427
|
+
// moved every leaving row after it a place down the list.
|
|
428
|
+
if (landed) {
|
|
429
|
+
order = Arr.filter(order, (entry) => !entry.fate.gone)
|
|
430
|
+
landed = false
|
|
431
|
+
}
|
|
432
|
+
// A row whose item is back, and which can't turn round: it's the list's no longer under that key,
|
|
433
|
+
// so the item gets a row of its own below. It stays among the rows until it has gone.
|
|
434
|
+
Iter.forEach(now.keys(), (key) => {
|
|
435
|
+
const back = kept.get(key)
|
|
436
|
+
if (Predicate.isNotUndefined(back) && !back.shownFor(true)) kept.delete(key)
|
|
437
|
+
})
|
|
438
|
+
// The rows this change takes out, measured now, while the page is still as it was and every one
|
|
439
|
+
// of them is in the flow: each that pops is then pinned where it was, however many leave together
|
|
440
|
+
// and whatever comes in beside them (a presence measures its leavers ahead the same way).
|
|
441
|
+
Arr.forEach(order, (entry) => {
|
|
442
|
+
const leaving = leavingIn(entry, now)
|
|
443
|
+
const anchors = popAnchorsFor(entry.ward)
|
|
444
|
+
if (leaving && !entry.popped.leaving && Predicate.isNotUndefined(anchors)) entry.popped.box = popBoxNow(entry.ward, anchors)
|
|
445
|
+
if (!leaving) entry.popped.box = undefined
|
|
446
|
+
entry.popped.leaving = leaving
|
|
447
|
+
})
|
|
448
|
+
const next: Array<Kept<T>> = []
|
|
449
|
+
// Waiting: while a row is still leaving, a new item stays out, and comes once the last has gone.
|
|
450
|
+
const held = keeping.waits && order.some((entry) => leavingIn(entry, now))
|
|
451
|
+
const inFirstList = !started
|
|
452
|
+
started = true
|
|
453
|
+
Iter.forEach(now, ([key, item]) => {
|
|
454
|
+
const known = kept.get(key)
|
|
455
|
+
if (Predicate.isNotUndefined(known)) {
|
|
456
|
+
next.push(known)
|
|
457
|
+
return
|
|
458
|
+
}
|
|
459
|
+
if (held) return
|
|
460
|
+
const startAt = next.length
|
|
461
|
+
const made = untrack(() => rowFor(key, item, inFirstList, startAt))
|
|
462
|
+
kept.set(key, made)
|
|
463
|
+
next.push(made)
|
|
464
|
+
})
|
|
465
|
+
// The rows still leaving go back where they were, among the rows that stay. One with nowhere to
|
|
466
|
+
// leave to and nothing to wait for goes at once, here.
|
|
467
|
+
Arr.forEach(order, (entry, at) => {
|
|
468
|
+
if (!leavingIn(entry, now)) return
|
|
469
|
+
if (!leavesNow(entry.ward)) {
|
|
470
|
+
goneAtOnce(entry)
|
|
471
|
+
return
|
|
472
|
+
}
|
|
473
|
+
next.splice(Math.min(at, next.length), 0, entry)
|
|
474
|
+
})
|
|
475
|
+
order = next
|
|
476
|
+
return next
|
|
477
|
+
})
|
|
478
|
+
// eslint-disable-next-line solid/reactivity -- made once, after the rows' memo it reads; `index` reads it late
|
|
479
|
+
positions = createMemo(() => {
|
|
480
|
+
const places = new Map<object, number>()
|
|
481
|
+
Arr.forEach(rows(), (entry, at) => places.set(entry.ward, at))
|
|
482
|
+
return places
|
|
483
|
+
})
|
|
484
|
+
// Its own exits (Q13): told as its rows leaving go from none to some, and back to none. Rows gone at
|
|
485
|
+
// once with none leaving are a leave begun and ended together, as a ward's with nowhere to leave to.
|
|
486
|
+
const { handle, events } = makePresenceHandle()
|
|
487
|
+
const leavingNow = createMemo(
|
|
488
|
+
() => {
|
|
489
|
+
const now = present()
|
|
490
|
+
return { leaving: Arr.filter(rows(), (entry) => leavingIn(entry, now)).length, goneAtOnce: goneAtOnceCount }
|
|
491
|
+
},
|
|
492
|
+
{ equals: (a, b) => a.leaving === b.leaving && a.goneAtOnce === b.goneAtOnce },
|
|
493
|
+
)
|
|
494
|
+
let leavingBefore = 0
|
|
495
|
+
let goneAtOnceBefore = 0
|
|
496
|
+
createEffect(leavingNow, (now) => {
|
|
497
|
+
const atOnce = now.goneAtOnce !== goneAtOnceBefore
|
|
498
|
+
goneAtOnceBefore = now.goneAtOnce
|
|
499
|
+
if (leavingBefore === 0 && (now.leaving > 0 || atOnce)) {
|
|
500
|
+
events.exitStart()
|
|
501
|
+
events.exiting(true)
|
|
502
|
+
}
|
|
503
|
+
if (now.leaving === 0 && (leavingBefore > 0 || atOnce)) {
|
|
504
|
+
events.exiting(false)
|
|
505
|
+
events.exitComplete()
|
|
506
|
+
}
|
|
507
|
+
leavingBefore = now.leaving
|
|
508
|
+
})
|
|
509
|
+
const list = createMemo<ReadonlyArray<RowWard<T>>>(() => rows().map((entry) => entry.ward))
|
|
510
|
+
// eslint-disable-next-line solid/reactivity -- the accessor itself handed back, read where the app reads it
|
|
511
|
+
return Object.defineProperties(list, { next: { value: handle.next }, when: { value: handle.when } }) as unknown as Accessor<ReadonlyArray<RowWard<T>>> & Leaving
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/** `createWards` over a `createWard`: each row's ward is that function's. `Taken` is where its wards are, for its rows' types. */
|
|
515
|
+
/** How a source's items are matched: by its `key`, or each by itself. */
|
|
516
|
+
const keyOf = <T>(key: ((item: T) => unknown) | undefined): ((item: T) => unknown) => {
|
|
517
|
+
if (Predicate.isUndefined(key)) return identity
|
|
518
|
+
return key
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/** Where `ward`'s element is now, pinned by `anchors`, as a list measures a row that pops: nowhere for one on none. */
|
|
522
|
+
const popBoxNow = (ward: Parameters<typeof sensedOf>[0], anchors: PopAnchors): PopBox | undefined => {
|
|
523
|
+
const el = untrack(() => UndefinedOr.map(sensedOf(ward), (sensed) => sensed.element()))
|
|
524
|
+
if (Predicate.isUndefined(el)) return undefined
|
|
525
|
+
return popBoxOf(el, anchors, undefined)
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export const hookWardsOf = <Taken extends RunesTaken = OnThePage>(ward: HookWardOf): HookWardsOf<Taken> => {
|
|
529
|
+
const wards = <T>(source: Accessor<ReadonlyArray<T>> | (WardsSource<T> & AffectsLayout) | (WardsValue<T> & AffectsLayout), ...runes: ReadonlyArray<RowRune<T>>): Accessor<ReadonlyArray<RowWard<T>>> => {
|
|
530
|
+
if (Predicate.isFunction(source)) return rowsOf(ward, source, { key: identity, initial: undefined, waits: false }, runes)
|
|
531
|
+
const affectsLayout = source.affectsLayout
|
|
532
|
+
// One value: the list of it alone, so the value it replaces is a row that leaves beside the one that comes.
|
|
533
|
+
if ("value" in source) return rowsOf(ward, listOfOne(source.value) as Accessor<ReadonlyArray<T>>, { key: keyOf(source.key), initial: source.initial, waits: false, affectsLayout }, runes)
|
|
534
|
+
return rowsOf(ward, source.each, { key: keyOf(source.key), initial: source.initial, waits: source.wait === true, affectsLayout }, runes)
|
|
535
|
+
}
|
|
536
|
+
return wards as HookWardsOf<Taken>
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/** Whether `value` is something to show: not `undefined`, `null` or `false`. */
|
|
540
|
+
const isShown = <T>(value: T): value is NonNullable<T> => Predicate.isNotNullish(value) && value !== false
|
|
541
|
+
|
|
542
|
+
/** `value` as a list: itself alone, or nothing for `undefined`, `null` or `false`. */
|
|
543
|
+
const listOfOne =
|
|
544
|
+
<T>(value: Accessor<T>): Accessor<ReadonlyArray<NonNullable<T>>> =>
|
|
545
|
+
() => {
|
|
546
|
+
const now = value()
|
|
547
|
+
if (isShown(now)) return [now]
|
|
548
|
+
return []
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* `source`'s value as a list of one, over the wards `ward` makes of `runes`: each new value's row waits
|
|
553
|
+
* for the last one's to go. A Stage's presence (`stage.ts`), whose ward moves its Subject from the
|
|
554
|
+
* moment it's made, so each value has a ward of its own. The page's presence takes one ward instead
|
|
555
|
+
* ({@link hookPresence}).
|
|
556
|
+
*/
|
|
557
|
+
export const oneAtATime = <T>(ward: HookWardOf, source: Accessor<T> | StagePresenceSource<T>, runes: ReadonlyArray<RowRune<NonNullable<T>>>): Accessor<ReadonlyArray<RowWard<NonNullable<T>>>> => {
|
|
558
|
+
const { options, value } = stagePresenceOf(source)
|
|
559
|
+
return rowsOf(ward, listOfOne(value), { key: keyOf(options.key), initial: options.initial, waits: true }, runes)
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/** A Stage's presence source as its options and its value: none of the first for one given as its value alone. */
|
|
563
|
+
const stagePresenceOf = <T>(source: Accessor<T> | StagePresenceSource<T>): { readonly options: Partial<StagePresenceSource<T>>; readonly value: Accessor<T> } => {
|
|
564
|
+
if (Predicate.isFunction(source)) return { options: {}, value: source }
|
|
565
|
+
return { options: source, value: source.value }
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const NOT_MADE = "createPresence(ward, value): its ward is one `createWard` made, with no `show` of its own, and not a list's row."
|
|
569
|
+
|
|
570
|
+
/** What's on the page: what its value is matched by, and the latest value seen under that. */
|
|
571
|
+
interface On<T> {
|
|
572
|
+
readonly key: unknown
|
|
573
|
+
last: T
|
|
574
|
+
/** Whether it's leaving with no way back: its value came back after what it held had ended. */
|
|
575
|
+
over?: boolean
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/** A presence's source as its value, and what a value is matched by: itself, with no `key`. */
|
|
579
|
+
const sourceOf = <T>(source: Accessor<T> | PresenceSource<T>): { readonly value: Accessor<T>; readonly key: (value: NonNullable<T>) => unknown } => {
|
|
580
|
+
if (Predicate.isFunction(source)) return { value: source, key: identity }
|
|
581
|
+
if (Predicate.isUndefined(source.key)) return { value: source.value, key: identity }
|
|
582
|
+
return { value: source.value, key: source.key }
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* `createPresence(ward, value)`: one value on the page at a time, on the one ward given. A new value
|
|
587
|
+
* waits for the last one's exit to land; then it takes its place, on an element of its own, which the
|
|
588
|
+
* ward enters afresh. A value that comes back before its exit has landed turns the ward round.
|
|
589
|
+
*
|
|
590
|
+
* All of it is derived, as Solid 2 would have it: what's on the page is a memo of the value and of the
|
|
591
|
+
* last exit to land, and the ward's word a memo of that. The one write is the landing itself, made
|
|
592
|
+
* where the ward's own is, as it settles. An effect that set these one from another re-ran on its own
|
|
593
|
+
* writes, and took two flushes for one landing.
|
|
594
|
+
*/
|
|
595
|
+
export const hookPresence: HookPresenceOf = <T>(given: HookWard, source: Accessor<T> | (PresenceSource<T> & AffectsLayout)): Accessor<NonNullable<T> | undefined> & Leaving => {
|
|
596
|
+
const taken = takenOf(given)
|
|
597
|
+
if (Predicate.isUndefined(taken)) throw new Error(NOT_MADE)
|
|
598
|
+
const { value, key } = sourceOf(source)
|
|
599
|
+
const state = taken.state
|
|
600
|
+
if (!Predicate.isFunction(source) && source.affectsLayout === false) state.affectsLayout = false
|
|
601
|
+
/** The value now, as what would be on the page: none for `undefined`, `null` or `false`. */
|
|
602
|
+
const wanted = (): On<NonNullable<T>> | undefined => {
|
|
603
|
+
const now = value()
|
|
604
|
+
if (isShown(now)) return { key: key(now), last: now }
|
|
605
|
+
return undefined
|
|
606
|
+
}
|
|
607
|
+
// A value that isn't there as the page opens enters when it comes, whatever `enter: false` says of the first.
|
|
608
|
+
if (Predicate.isUndefined(untrack(wanted))) taken.fresh()
|
|
609
|
+
// The one whose exit has landed: what lets the next take its place.
|
|
610
|
+
const [left, setLeft] = createSignal<On<NonNullable<T>> | undefined>(undefined)
|
|
611
|
+
// Bumped a flush after a value that came back has been taken off the page: its turn to come on again.
|
|
612
|
+
const [again, setAgain] = createSignal(0)
|
|
613
|
+
/** What's on the page: the value there, until another's turn comes and its own exit has landed. */
|
|
614
|
+
const on = createMemo<On<NonNullable<T>> | undefined>((last) => {
|
|
615
|
+
again()
|
|
616
|
+
const next = wanted()
|
|
617
|
+
if (Predicate.isUndefined(last)) return next
|
|
618
|
+
const same = Predicate.isNotUndefined(next) && next.key === last.key
|
|
619
|
+
// The same value, made again or come back before its exit landed: it stays, and the ward turns
|
|
620
|
+
// round on the element it's on. Unless what it held as it left has ended, the twins it handed
|
|
621
|
+
// home: those don't come back on these elements, and it turned round to a backdrop with no view
|
|
622
|
+
// in it. Decided once for this leave, whatever the ward says later.
|
|
623
|
+
if (same && !last.over && !state.committed) return last
|
|
624
|
+
if (same) last.over = true
|
|
625
|
+
// Another value, or none, or the same one with no way back: what's on the page leaves, and whatever
|
|
626
|
+
// comes after it enters afresh.
|
|
627
|
+
taken.fresh()
|
|
628
|
+
if (state.leaves()) {
|
|
629
|
+
if (left() !== last) return last
|
|
630
|
+
if (!state.followersLanded()) return last
|
|
631
|
+
}
|
|
632
|
+
// Gone: what comes next, this value again included, can turn round as any other.
|
|
633
|
+
state.committed = false
|
|
634
|
+
if (!same) return next
|
|
635
|
+
// The same value again: off the page for a flush, so the `<Show>` it's rendered by, keyed by a value
|
|
636
|
+
// it has already, makes it a new element. It comes back on the bump.
|
|
637
|
+
queueMicrotask(() => setAgain((turn) => turn + 1))
|
|
638
|
+
return undefined
|
|
639
|
+
})
|
|
640
|
+
/** The ward's word: whether the value on the page is the one wanted. False from the moment it starts to leave. */
|
|
641
|
+
const shown = createMemo<boolean>(() => {
|
|
642
|
+
const now = on()
|
|
643
|
+
if (Predicate.isUndefined(now)) return false
|
|
644
|
+
// Leaving with no way back: it isn't shown again, though its value is wanted again.
|
|
645
|
+
if (now.over === true) return false
|
|
646
|
+
const next = wanted()
|
|
647
|
+
return Predicate.isNotUndefined(next) && next.key === now.key
|
|
648
|
+
})
|
|
649
|
+
// The ward tells when it's gone: its exit landed, and the twins it gave back flown home. The one
|
|
650
|
+
// write a value's leaving makes, in the same call as the ward's own.
|
|
651
|
+
state.gone = () => {
|
|
652
|
+
if (untrack(shown)) return
|
|
653
|
+
setLeft(untrack(on))
|
|
654
|
+
}
|
|
655
|
+
// eslint-disable-next-line solid/reactivity -- the accessor handed to the ward, which reads it where it's tracked
|
|
656
|
+
taken.drive(shown)
|
|
657
|
+
state.shown = shown
|
|
658
|
+
// eslint-disable-next-line solid/reactivity -- an accessor, read where the ward's `mounted` is, which tracks it
|
|
659
|
+
state.mounted = () => Predicate.isNotUndefined(on())
|
|
660
|
+
// What's on the page is the value itself: one that takes another's place leaves `mounted` as it was.
|
|
661
|
+
state.onPage = on
|
|
662
|
+
// Its exits, told by the presence's own word and value: after both are the state's.
|
|
663
|
+
tellingExits(given, state)
|
|
664
|
+
const onThePage = createMemo(() => {
|
|
665
|
+
const now = on()
|
|
666
|
+
if (Predicate.isUndefined(now)) return undefined
|
|
667
|
+
// The latest value under its key: one made again (a refetch) is shown without leaving, and is
|
|
668
|
+
// what's shown still as it leaves.
|
|
669
|
+
const latest = wanted()
|
|
670
|
+
if (Predicate.isNotUndefined(latest) && latest.key === now.key) now.last = latest.last
|
|
671
|
+
return now.last
|
|
672
|
+
})
|
|
673
|
+
// Its own exits (Q13) are its one ward's: the value leaving is that ward's to leave by.
|
|
674
|
+
// eslint-disable-next-line solid/reactivity -- the accessor itself handed back, read where the app reads it
|
|
675
|
+
return Object.defineProperties(onThePage, {
|
|
676
|
+
next: { value: <E extends ExitEvent>(name: E) => given.next(name) },
|
|
677
|
+
when: { value: <E extends ExitEvent>(name: E) => given.when(name) },
|
|
678
|
+
}) as unknown as Accessor<NonNullable<T> | undefined> & Leaving
|
|
679
|
+
}
|