@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,740 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A behaviour's drag (probe: behaviour-runes): what a function rune's ward hears of the drag of the ward
|
|
3
|
+
* it's given to, `ward.drag`. A behaviour is a rune (the grill's Q1, Q5): it gives its ward `drag`,
|
|
4
|
+
* `layout` and `lifted`, as any rune gives keys, and listens here, with nothing of Effect in what it's
|
|
5
|
+
* handed, so another library's behaviour can stand where Wardic's Reorder does.
|
|
6
|
+
*
|
|
7
|
+
* - **`onSample(fn)`**: each sample of the ward's drag, as the drag delivers it, after its projection
|
|
8
|
+
* write: its `phase` (`"start"`, `"move"`, `"end"`), `point`, `offset`, `delta` and `velocity`.
|
|
9
|
+
* - **`onKey(fn, { describedBy })`**, **`onBlur(fn)`**, **`onPress(fn)`**: its keys, as core's
|
|
10
|
+
* `KeyboardLikeEvent`, inside their dispatch; focus leaving it, judged after the task's own work; a
|
|
11
|
+
* press on it. Given `onKey`, its Subject is a tab stop (`tabindex="0"`, an app's own winning),
|
|
12
|
+
* described by `describedBy`, a server's render too. Focus a key's handling took is put back.
|
|
13
|
+
* - **`measured()`**: its layout box, how far it's dragged, and its box's version, a projection node's.
|
|
14
|
+
*
|
|
15
|
+
* Each listener ends with the owner it's made under (Q18). Typed on a function rune's ward alone
|
|
16
|
+
* (Q34): the ward `createWard` hands back has none. A rune that listens on a ward that nothing gives a
|
|
17
|
+
* `drag` is told so in development, once (Q19).
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import type * as Box from "@wardic/core/Box"
|
|
22
|
+
import type * as Drag from "@wardic/core/Drag"
|
|
23
|
+
import * as InputFeed from "@wardic/core/InputFeed"
|
|
24
|
+
import * as InputSource from "@wardic/core/InputSource"
|
|
25
|
+
import type * as Point from "@wardic/core/Point"
|
|
26
|
+
import type * as ProjectionSystem from "@wardic/dom/ProjectionSystem"
|
|
27
|
+
import * as Style from "@wardic/dom/Style"
|
|
28
|
+
import type { WardicServices } from "../runtime.ts"
|
|
29
|
+
import * as Bool from "effect/Boolean"
|
|
30
|
+
import * as Effect from "effect/Effect"
|
|
31
|
+
import * as Arr from "effect/Array"
|
|
32
|
+
import { constFalse, constTrue, constUndefined, constVoid, identity } from "effect/Function"
|
|
33
|
+
import { isServer } from "@solidjs/web"
|
|
34
|
+
import * as Option from "effect/Option"
|
|
35
|
+
import * as Predicate from "effect/Predicate"
|
|
36
|
+
import * as Iter from "effect/Iterable"
|
|
37
|
+
import * as Scope from "effect/Scope"
|
|
38
|
+
import * as UndefinedOr from "effect/UndefinedOr"
|
|
39
|
+
import * as Report from "@wardic/dom/Report"
|
|
40
|
+
import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
|
|
41
|
+
import { type Accessor, createEffect, createSignal, DEV, getOwner, onCleanup, untrack } from "solid-js"
|
|
42
|
+
import type { WardicRuntime } from "../runtime.ts"
|
|
43
|
+
import { CLIENT_ONLY_DEFERRED } from "../solid-reactivity.ts"
|
|
44
|
+
import type { WardInternals } from "../ward.tsx"
|
|
45
|
+
import type { RuneConfig, RuneWard } from "./rune.ts"
|
|
46
|
+
import type { HookWard } from "./ward.ts"
|
|
47
|
+
|
|
48
|
+
/** `onKey`'s options. */
|
|
49
|
+
export interface KeyOptions {
|
|
50
|
+
/** The ids of what describes the ward to a screen reader, its instructions: its `aria-describedby`. */
|
|
51
|
+
readonly describedBy?: Accessor<string | undefined> | undefined
|
|
52
|
+
/**
|
|
53
|
+
* Whether its Subject is a tab stop now: true when left out. A Reorder group's with its keyboard off
|
|
54
|
+
* is none (probe: behaviour-runes, found rebuilding `<Reorder.*>`: ADR-0037's "no tab stop").
|
|
55
|
+
*/
|
|
56
|
+
readonly tabStop?: Accessor<boolean> | undefined
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A ward's box as its projection node measures it. */
|
|
60
|
+
export interface Measured {
|
|
61
|
+
/** Its layout box, its place: `undefined` before it's measured. Plain, as the whole contract is (Q1). */
|
|
62
|
+
readonly box: () => Box.Box | undefined
|
|
63
|
+
/** How far it's dragged from its place. */
|
|
64
|
+
readonly offset: () => Point.Point
|
|
65
|
+
/** A count that rises each time its box is measured. */
|
|
66
|
+
readonly version: () => number
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** What a function rune's ward hears of its ward's drag: `ward.drag`. */
|
|
70
|
+
export interface WardDrag {
|
|
71
|
+
/** Each sample of the ward's drag, as the drag delivers it. Until the owner it's made under ends. */
|
|
72
|
+
readonly onSample: (listener: (sample: Drag.Sample) => void) => void
|
|
73
|
+
/** Its keys, inside their dispatch. Its Subject is a tab stop, described by `describedBy`. */
|
|
74
|
+
readonly onKey: (listener: (event: InputSource.KeyboardLikeEvent) => void, options?: KeyOptions) => void
|
|
75
|
+
/** Focus leaving it, judged after the task's own work: one a key's handling put back isn't heard. */
|
|
76
|
+
readonly onBlur: (listener: () => void) => void
|
|
77
|
+
/** A press on it, its primary pointer's down. */
|
|
78
|
+
readonly onPress: (listener: () => void) => void
|
|
79
|
+
/** Its box as its projection node measures it: a `layout` ward's. */
|
|
80
|
+
readonly measured: () => Measured
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** One ward's drag site: what its behaviours listen with, and what it's measured by. Internal. */
|
|
84
|
+
interface Site {
|
|
85
|
+
readonly samples: Set<(sample: Drag.Sample) => void>
|
|
86
|
+
readonly keys: Set<(event: InputSource.KeyboardLikeEvent) => void>
|
|
87
|
+
readonly blurs: Set<() => void>
|
|
88
|
+
readonly presses: Set<() => void>
|
|
89
|
+
/** What its last `onKey` was told of its Subject as a tab stop. */
|
|
90
|
+
keyOptions: KeyOptions | undefined
|
|
91
|
+
node: ProjectionSystem.NodeHandle | undefined
|
|
92
|
+
/** Whether anything listened, for development's word on a ward with no drag (Q19). */
|
|
93
|
+
listened: boolean
|
|
94
|
+
/** Its grips, a ward's that drags (Q14): none for one that doesn't. */
|
|
95
|
+
grips: Grips | undefined
|
|
96
|
+
/** Its ward's element and its input, once it's mounted: what a grip's keys are watched with. */
|
|
97
|
+
at: InputAt | undefined
|
|
98
|
+
readonly api: WardDrag
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A ward's grips (Q14, Q15): how many are on the page, and those its `ref`s were handed. A press on one
|
|
103
|
+
* reaches the ward's own drag, as a press inside its element does, so a grip needs no drag controls: the
|
|
104
|
+
* ward's drag hears it, and no other press while it has one on the page (the glossary's Grip).
|
|
105
|
+
*/
|
|
106
|
+
interface Grips {
|
|
107
|
+
/** How many are on the page: in a browser, those whose elements are; on a server, each counted as it's made. */
|
|
108
|
+
readonly count: Accessor<number>
|
|
109
|
+
readonly setCount: (count: number) => void
|
|
110
|
+
/** Each grip its `ref` was handed, with how its watch closes: none until its ward has mounted and its input is there. */
|
|
111
|
+
readonly on: Map<HTMLElement, (() => void) | undefined>
|
|
112
|
+
/** The ward's drag axis now, for a grip's touch-action. */
|
|
113
|
+
readonly axis: () => boolean | "x" | "y"
|
|
114
|
+
/**
|
|
115
|
+
* What watches the ward's element for a grip taken off the page or put back, while it has a grip: the app
|
|
116
|
+
* takes one off with a `<Show>` and tells its `ref` nothing (HR16). A browser's alone.
|
|
117
|
+
*/
|
|
118
|
+
watcher: { readonly observer: MutationObserver; readonly element: HTMLElement } | undefined
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A mounted ward's element, its input, and how to run a watch and fork a response with them. */
|
|
122
|
+
interface InputAt {
|
|
123
|
+
readonly element: HTMLElement
|
|
124
|
+
readonly input: InputSource.InputSource["Service"]
|
|
125
|
+
readonly watch: (make: (onDefect: InputFeed.OnDefect) => Effect.Effect<void, never, Scope.Scope | WardicServices>) => void
|
|
126
|
+
readonly fork: (effect: Effect.Effect<void>) => void
|
|
127
|
+
/** Its runtime, for a grip's watch in a Scope of its own. */
|
|
128
|
+
readonly runtime: WardicRuntime
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Each function rune's ward's site, made the first time it reads `ward.drag`. */
|
|
132
|
+
// Module state (#460, Q7): each ward's own, held weakly by it, so a page's wards share nothing.
|
|
133
|
+
const SITES = new WeakMap<object, Site>()
|
|
134
|
+
|
|
135
|
+
const ORIGIN: Point.Point = { x: 0, y: 0 }
|
|
136
|
+
|
|
137
|
+
/** `listener` in `set` until the owner it's made under ends; for good with none. */
|
|
138
|
+
const heard = <A>(site: Site, set: Set<A>, listener: A): void => {
|
|
139
|
+
set.add(listener)
|
|
140
|
+
site.listened = true
|
|
141
|
+
if (Predicate.isNotNull(getOwner())) onCleanup(() => void set.delete(listener))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Each of `set`'s listeners called, the Set walked as it is, with no copy at each sample: one that leaves
|
|
146
|
+
* before it's reached isn't called, and one added meanwhile is.
|
|
147
|
+
*/
|
|
148
|
+
const tellEach = <A>(set: Set<A>, call: (listener: A) => void): void => Iter.forEach(set, call)
|
|
149
|
+
|
|
150
|
+
/** A ward's drag site, empty: a function rune's ward's at its first `ward.drag`, or a dragging ward's for its grips. */
|
|
151
|
+
export const makeSite = (): Site => {
|
|
152
|
+
const state: Omit<Site, "api"> = {
|
|
153
|
+
samples: new Set(),
|
|
154
|
+
keys: new Set(),
|
|
155
|
+
blurs: new Set(),
|
|
156
|
+
presses: new Set(),
|
|
157
|
+
keyOptions: undefined,
|
|
158
|
+
node: undefined,
|
|
159
|
+
listened: false,
|
|
160
|
+
grips: undefined,
|
|
161
|
+
at: undefined,
|
|
162
|
+
}
|
|
163
|
+
return Object.assign(state, { api: apiOf(state as Site) })
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Whether `site`'s ward has a grip in use: its own presses and keys are then its grips' (Q15, Q27). */
|
|
167
|
+
const gripsInUse = (site: Site): boolean => UndefinedOr.match(site.grips, { onUndefined: constFalse, onDefined: (grips) => untrack(grips.count) > 0 })
|
|
168
|
+
|
|
169
|
+
/** Whether focus is on one of `site`'s key sources: its ward's element with no grip in use, or a grip. */
|
|
170
|
+
const sourceFocused = (site: Site, doc: Document): boolean => {
|
|
171
|
+
const active = doc.activeElement
|
|
172
|
+
if (gripsInUse(site)) return UndefinedOr.match(site.grips, { onUndefined: constFalse, onDefined: (grips) => grips.on.has(active as HTMLElement) })
|
|
173
|
+
return UndefinedOr.match(site.at, { onUndefined: constFalse, onDefined: (at) => at.element === active })
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Each `measured()`'s site: what {@link layoutBoxOf} reads through. */
|
|
177
|
+
// Module state (#460, Q7): each ward's own, held weakly by it, so a page's wards share nothing.
|
|
178
|
+
const MEASURED = new WeakMap<Measured, Site>()
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* `measured`'s box as core's Reorder group reads it, an Option, its node's as it is: Wardic's own
|
|
182
|
+
* behaviour's way past the plain `box()`, which a reorder's drag reads for every item at every sample, so
|
|
183
|
+
* it would make a second Option each read (the profile: a drag's allocations under core's `layoutOf`
|
|
184
|
+
* doubled). Another library's behaviour reads `box()`.
|
|
185
|
+
*/
|
|
186
|
+
export const layoutBoxOf = (measured: Measured): (() => Option.Option<Box.Box>) => {
|
|
187
|
+
const site = MEASURED.get(measured)
|
|
188
|
+
if (Predicate.isUndefined(site)) return () => Option.fromUndefinedOr(measured.box())
|
|
189
|
+
return () => {
|
|
190
|
+
const node = site.node
|
|
191
|
+
if (Predicate.isUndefined(node)) return Option.none()
|
|
192
|
+
return node.layoutBox()
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** The `ward.drag` of `site`. */
|
|
197
|
+
const apiOf = (site: Site): WardDrag => {
|
|
198
|
+
const measured: Measured = {
|
|
199
|
+
// Read for every item at every sample of a reorder's drag: plain guards, no match made at each read.
|
|
200
|
+
box: () => {
|
|
201
|
+
const node = site.node
|
|
202
|
+
if (Predicate.isUndefined(node)) return undefined
|
|
203
|
+
return Option.getOrUndefined(node.layoutBox())
|
|
204
|
+
},
|
|
205
|
+
offset: () => {
|
|
206
|
+
const node = site.node
|
|
207
|
+
if (Predicate.isUndefined(node)) return ORIGIN
|
|
208
|
+
return node.dragOffset()
|
|
209
|
+
},
|
|
210
|
+
version: () => {
|
|
211
|
+
const node = site.node
|
|
212
|
+
if (Predicate.isUndefined(node)) return 0
|
|
213
|
+
return node.layoutVersion()
|
|
214
|
+
},
|
|
215
|
+
}
|
|
216
|
+
MEASURED.set(measured, site)
|
|
217
|
+
return {
|
|
218
|
+
onSample: (listener) => heard(site, site.samples, listener),
|
|
219
|
+
onKey: (listener, options) => {
|
|
220
|
+
heard(site, site.keys, listener)
|
|
221
|
+
UndefinedOr.map(options, (given) => {
|
|
222
|
+
site.keyOptions = given
|
|
223
|
+
})
|
|
224
|
+
},
|
|
225
|
+
onBlur: (listener) => heard(site, site.blurs, listener),
|
|
226
|
+
onPress: (listener) => heard(site, site.presses, listener),
|
|
227
|
+
measured: () => measured,
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** `ward`'s site, made at its first read: the `drag` a function rune's ward is given (`ward.ts`). */
|
|
232
|
+
export const siteOf = (ward: object): Site => {
|
|
233
|
+
const had = SITES.get(ward)
|
|
234
|
+
if (Predicate.isNotUndefined(had)) return had
|
|
235
|
+
const site = makeSite()
|
|
236
|
+
SITES.set(ward, site)
|
|
237
|
+
return site
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** `ward`'s site, if a rune read its `drag`. */
|
|
241
|
+
export const siteIfAny = (ward: object): Site | undefined => SITES.get(ward)
|
|
242
|
+
|
|
243
|
+
/** Gives a function rune's ward its `drag`, made the first time it's read. */
|
|
244
|
+
export const withDrag = <W extends object>(ward: W): W =>
|
|
245
|
+
Object.defineProperty(ward, "drag", { get: () => siteOf(ward).api, configurable: true }) as W
|
|
246
|
+
|
|
247
|
+
/** The function runes that read nothing of their ward but its `drag`: Wardic's own behaviours'. */
|
|
248
|
+
// Module state (#460, Q7): each rune's own, held weakly by it.
|
|
249
|
+
const DRAG_ONLY = new WeakSet<object>()
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Marks `rune` as one that reads nothing of its ward but its `drag`, so its ward can be a stand-in
|
|
253
|
+
* (`runeWardOf`). Internal: Wardic's `list.item` alone (the ward split's Q12, (b)). A holder costs a
|
|
254
|
+
* row about 0.5 KB more than this stand-in, which a Reorder pays at every row.
|
|
255
|
+
*/
|
|
256
|
+
export const dragOnly = <R extends object>(rune: R): R => {
|
|
257
|
+
DRAG_ONLY.add(rune)
|
|
258
|
+
return rune
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Whether `rune` reads nothing of its ward but its `drag`. */
|
|
262
|
+
export const isDragOnly = (rune: unknown): boolean => {
|
|
263
|
+
if (Predicate.isObject(rune)) return DRAG_ONLY.has(rune)
|
|
264
|
+
return false
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** What a function rune's ward stands in front of: nothing of its own. */
|
|
268
|
+
const STAND_IN = Object.freeze({})
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* A function rune's ward (Q5, Q34): its `drag` its own, made at its first read, and every other member
|
|
272
|
+
* the ward `of` gives as it's read, a holder made for it, or the finished ward once that's made. A
|
|
273
|
+
* stand-in, so a rune that reads only its drag, Wardic's own behaviour's, costs its row no holder
|
|
274
|
+
* (probe: behaviour-runes, the profile; the ward split's Q12). A member that's a function is handed
|
|
275
|
+
* bound to its ward.
|
|
276
|
+
*/
|
|
277
|
+
export const runeWardOf = (of: () => object): RuneWard => {
|
|
278
|
+
const ward: RuneWard = new Proxy(STAND_IN, {
|
|
279
|
+
get: (_, key) => {
|
|
280
|
+
if (key === "drag") return siteOf(ward).api
|
|
281
|
+
const to = of()
|
|
282
|
+
const value: unknown = Reflect.get(to, key, to)
|
|
283
|
+
if (Predicate.isFunction(value)) return value.bind(to)
|
|
284
|
+
return value
|
|
285
|
+
},
|
|
286
|
+
// Its drag without the ward behind it, which `of()` may have to make.
|
|
287
|
+
has: (_, key) => {
|
|
288
|
+
if (key === "drag") return true
|
|
289
|
+
return Reflect.has(of(), key)
|
|
290
|
+
},
|
|
291
|
+
}) as unknown as RuneWard
|
|
292
|
+
return ward
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const isPress = (event: InputSource.PointerLikeEvent): boolean => Bool.and(event.type === "down", InputSource.isPrimaryPointer(event))
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* A key heard at `el`, inside its dispatch: each listener told, then focus its handling took from `el`
|
|
299
|
+
* put back without a scroll, as a reorder that moves a focused node blurs it.
|
|
300
|
+
*/
|
|
301
|
+
const keyAt = (site: Site, el: HTMLElement, event: InputSource.KeyboardLikeEvent): void => {
|
|
302
|
+
const had = el.ownerDocument.activeElement === el
|
|
303
|
+
tellEach(site.keys, (listener) => listener(event))
|
|
304
|
+
if (Bool.and(had, Bool.and(el.ownerDocument.activeElement !== el, el.isConnected))) el.focus({ preventScroll: true })
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** A blur of a key source, judged a hop on: heard unless focus is on one of them again. */
|
|
308
|
+
const blurOf = (site: Site, el: HTMLElement): Effect.Effect<void> =>
|
|
309
|
+
Effect.andThen(
|
|
310
|
+
Effect.yieldNow,
|
|
311
|
+
Effect.sync(() => {
|
|
312
|
+
if (sourceFocused(site, el.ownerDocument)) return
|
|
313
|
+
tellEach(site.blurs, (listener) => listener())
|
|
314
|
+
}),
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Watch `el`'s keys, blur and presses for `site`'s listeners, those it has, while the Scope is open: its
|
|
319
|
+
* ward's own element's only while no grip is in use (Q27), a grip's always.
|
|
320
|
+
*/
|
|
321
|
+
const watchInput = (site: Site, el: HTMLElement, grip: boolean, fork: (effect: Effect.Effect<void>) => void, onDefect: InputFeed.OnDefect) =>
|
|
322
|
+
Effect.gen(function* () {
|
|
323
|
+
const input = yield* InputSource.InputSource
|
|
324
|
+
const heardHere = (): boolean => {
|
|
325
|
+
if (grip) return true
|
|
326
|
+
return Bool.not(gripsInUse(site))
|
|
327
|
+
}
|
|
328
|
+
if (site.keys.size > 0) {
|
|
329
|
+
yield* InputFeed.watch(input.keyboard(el), {
|
|
330
|
+
on: (event) => {
|
|
331
|
+
if (heardHere()) keyAt(site, el, event)
|
|
332
|
+
},
|
|
333
|
+
onDefect,
|
|
334
|
+
})
|
|
335
|
+
}
|
|
336
|
+
if (site.blurs.size > 0) {
|
|
337
|
+
yield* InputFeed.watch(input.focus(el), {
|
|
338
|
+
on: (event) => {
|
|
339
|
+
// Its own blur: one inside it leaves it focused.
|
|
340
|
+
if (Bool.and(heardHere(), Bool.and(event.type === "blur", event.fromTarget !== false))) fork(blurOf(site, el))
|
|
341
|
+
},
|
|
342
|
+
onDefect,
|
|
343
|
+
})
|
|
344
|
+
}
|
|
345
|
+
if (site.presses.size > 0) {
|
|
346
|
+
yield* InputFeed.watch(input.pointer(el), {
|
|
347
|
+
on: (event) => {
|
|
348
|
+
if (Bool.and(heardHere(), isPress(event))) tellEach(site.presses, (listener) => listener())
|
|
349
|
+
},
|
|
350
|
+
onDefect,
|
|
351
|
+
})
|
|
352
|
+
}
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
/** Watch `el`'s input for `site`, with its ward's input, in its ward's watch Scope: its ward's own element's. */
|
|
356
|
+
const watchSource = (site: Site, at: InputAt, el: HTMLElement): void =>
|
|
357
|
+
at.watch((onDefect) => Effect.provideService(watchInput(site, el, false, at.fork, onDefect), InputSource.InputSource, at.input))
|
|
358
|
+
|
|
359
|
+
/** What a grip's watch is reported as, when one of its finalizers fails. */
|
|
360
|
+
const GRIP_CLOSE = "wardic.createGrip: a finalizer failed"
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Watch grip `el`'s input for `site` in a Scope of its own, closed as the grip goes (Q18): a grip shown
|
|
364
|
+
* and hidden again leaves nothing watching behind it, where its ward's own Scope would keep them all.
|
|
365
|
+
*/
|
|
366
|
+
const watchGrip = (site: Site, at: InputAt, el: HTMLElement): (() => void) => {
|
|
367
|
+
const scope = OwnerScope.open(at.runtime)
|
|
368
|
+
at.runtime.runSync(Effect.provideService(watchInput(site, el, true, at.fork, reportOf(at)), InputSource.InputSource, at.input).pipe(Scope.provide(scope)))
|
|
369
|
+
return () => OwnerScope.close(at.runtime, scope, GRIP_CLOSE)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** How a grip's watch reports a defect: as its ward's own watches do, on its runtime. */
|
|
373
|
+
const reportOf = (at: InputAt): InputFeed.OnDefect => (cause) => at.fork(Report.failure("wardic.createGrip: a grip's input failed", cause))
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* What a ward with a grip in use lays over its drag defaults: its `touch-action` taken away, so it scrolls
|
|
377
|
+
* by touch (Q22) and an app's stylesheet still says what it does, where an inline `auto` beat it.
|
|
378
|
+
*/
|
|
379
|
+
const WITH_GRIPS = { "touch-action": undefined } as const
|
|
380
|
+
|
|
381
|
+
/** A drag axis's `touch-action`: none for a free drag, the other axis's panning for one locked to an axis. */
|
|
382
|
+
const touchActionOf = (axis: boolean | "x" | "y"): string => Style.dragDefaults(axis)["touch-action"] as string
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Gives `site` grips, for a ward that drags along `axis` (Q14): its own drag controls, and a count of
|
|
386
|
+
* its grips, counted as a grip is made, in a component's body, so a server's render has it too.
|
|
387
|
+
*/
|
|
388
|
+
export const withGrips = (site: Site, axis: () => boolean | "x" | "y"): void => {
|
|
389
|
+
site.grips = { ...gripCountOf(), on: new Map(), axis, watcher: undefined }
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* A ward's count of its grips on the page. A signal's in a browser, where a grip that comes or goes after
|
|
394
|
+
* its row has rendered changes what the row renders. A plain number on a server, whose render writes no
|
|
395
|
+
* signal (Solid's SERVER_WRITE, GP8): there each grip is counted as it's made, before its row's spread is read.
|
|
396
|
+
*/
|
|
397
|
+
const gripCountOf = (): Pick<Grips, "count" | "setCount"> => {
|
|
398
|
+
if (isServer) {
|
|
399
|
+
let onThePage = 0
|
|
400
|
+
return {
|
|
401
|
+
count: () => onThePage,
|
|
402
|
+
setCount: (count) => {
|
|
403
|
+
onThePage = count
|
|
404
|
+
},
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const [count, setCount] = createSignal(0, { ownedWrite: true })
|
|
408
|
+
return { count, setCount: (to) => void setCount(to) }
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* `grips` counted again from the page, and their ward's element watched while it has any: a grip the app
|
|
413
|
+
* takes off the page with a `<Show>` tells its `ref` nothing (HR16), so the element it was in is watched
|
|
414
|
+
* for it leaving and coming back (GP9). A browser's alone: a server puts nothing on a page.
|
|
415
|
+
*/
|
|
416
|
+
const gripsWatched = (site: Site, grips: Grips): void => {
|
|
417
|
+
grips.setCount(onThePage(grips))
|
|
418
|
+
if (grips.on.size === 0) {
|
|
419
|
+
unwatched(grips)
|
|
420
|
+
return
|
|
421
|
+
}
|
|
422
|
+
UndefinedOr.map(site.at, (at) => watchedOn(grips, at.element))
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** How many of `grips` are on the page now. */
|
|
426
|
+
const onThePage = (grips: Grips): number => Arr.filter(Arr.fromIterable(grips.on.keys()), isOnThePage).length
|
|
427
|
+
|
|
428
|
+
const isOnThePage = (element: HTMLElement): boolean => element.isConnected
|
|
429
|
+
|
|
430
|
+
/** `grips` watched on `element`, their ward's: a grip taken off it or put back counts them again. One watcher, moved with the ward. */
|
|
431
|
+
const watchedOn = (grips: Grips, element: HTMLElement): void => {
|
|
432
|
+
const watcher = grips.watcher
|
|
433
|
+
if (Predicate.isNotUndefined(watcher) && watcher.element === element) return
|
|
434
|
+
unwatched(grips)
|
|
435
|
+
const observer = new MutationObserver(() => grips.setCount(onThePage(grips)))
|
|
436
|
+
observer.observe(element, { childList: true, subtree: true })
|
|
437
|
+
grips.watcher = { observer, element }
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** `grips` watched no more: their ward has none. */
|
|
441
|
+
const unwatched = (grips: Grips): void => {
|
|
442
|
+
UndefinedOr.map(grips.watcher, (watcher) => watcher.observer.disconnect())
|
|
443
|
+
grips.watcher = undefined
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* What the finished ward takes of `site`: its samples, its node, its input and its keys; with grips, its
|
|
448
|
+
* drag started by them alone while one's in use (Q15) and no `touch-action` then (Q22). Its keys' Enter
|
|
449
|
+
* and Space are its listeners', so its press hears none, as a Reorder item's are (#427).
|
|
450
|
+
*/
|
|
451
|
+
export const siteInternalsOf = (site: Site): Partial<WardInternals> => ({
|
|
452
|
+
onDragSample: (sample) => tellEach(site.samples, (listener) => listener(sample)),
|
|
453
|
+
onLayoutHandle: (node) => {
|
|
454
|
+
site.node = node
|
|
455
|
+
return () => {
|
|
456
|
+
if (site.node === node) site.node = undefined
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
onInput: (element, input, watch, fork, runtime) => {
|
|
460
|
+
const at: InputAt = { element, input, watch, fork, runtime }
|
|
461
|
+
site.at = at
|
|
462
|
+
watchSource(site, at, element)
|
|
463
|
+
// The grips on show before it mounted: each watched now, in a Scope of its own, and its element watched
|
|
464
|
+
// for them leaving the page. Nothing for a ward with no grip: a Reorder list's thousand rows.
|
|
465
|
+
UndefinedOr.map(site.grips, (grips) => {
|
|
466
|
+
if (grips.on.size === 0) return
|
|
467
|
+
Iter.forEach(grips.on, ([grip, close]) => {
|
|
468
|
+
if (Predicate.isNotUndefined(close)) return
|
|
469
|
+
warnIfOutside(site, grip)
|
|
470
|
+
grips.on.set(grip, watchGrip(site, at, grip))
|
|
471
|
+
})
|
|
472
|
+
gripsWatched(site, grips)
|
|
473
|
+
})
|
|
474
|
+
},
|
|
475
|
+
...Bool.match(site.keys.size > 0, { onTrue: () => ({ keysTaken: true }), onFalse: () => ({}) }),
|
|
476
|
+
...UndefinedOr.match(site.grips, {
|
|
477
|
+
onUndefined: () => ({}),
|
|
478
|
+
onDefined: (grips): Partial<WardInternals> => ({
|
|
479
|
+
dragListen: (down) => {
|
|
480
|
+
if (untrack(grips.count) === 0) return true
|
|
481
|
+
return onAGrip(grips, targetOf(down), UndefinedOr.map(site.at, (at) => at.element))
|
|
482
|
+
},
|
|
483
|
+
baseStyle: () => Bool.match(grips.count() > 0, { onTrue: () => WITH_GRIPS, onFalse: () => ({ "touch-action": touchActionOf(grips.axis()) }) }),
|
|
484
|
+
}),
|
|
485
|
+
}),
|
|
486
|
+
})
|
|
487
|
+
|
|
488
|
+
/** Each ward's site, by the ward `createWard` hands back: what `createGrip(row)` finds `row`'s by. */
|
|
489
|
+
// Module state (#460, Q7): each ward's own, held weakly by it, so a page's wards share nothing.
|
|
490
|
+
const WARD_SITES = new WeakMap<object, Site>()
|
|
491
|
+
|
|
492
|
+
/** Keeps `site` as `ward`'s, for its grips. */
|
|
493
|
+
export const siteKeptFor = (ward: object, site: Site): void => void WARD_SITES.set(ward, site)
|
|
494
|
+
|
|
495
|
+
/** What development says of a grip of a ward that doesn't drag (Q14). */
|
|
496
|
+
export const NOT_DRAGGING = "createGrip(row): row doesn't drag; give it `drag`, or a behaviour that does."
|
|
497
|
+
|
|
498
|
+
/** What a ward that drags carries in its type alone (Q20). */
|
|
499
|
+
declare const DRAGS: unique symbol
|
|
500
|
+
|
|
501
|
+
/** The mark of a ward one of whose runes gives a `drag`, in its type alone (Q20). */
|
|
502
|
+
export interface Drags {
|
|
503
|
+
readonly [DRAGS]: true
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** A ward that drags: any ward one of whose runes gives a `drag`, a function rune's as its function gives it (Q20). */
|
|
507
|
+
export type DraggingWard = HookWard & Drags
|
|
508
|
+
|
|
509
|
+
/** The rune of a grip that drives nothing. */
|
|
510
|
+
const NO_GRIP: RuneConfig = {}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* A grip for `row`, as a rune (Q14, Q21, Q22): a press on its Subject starts `row`'s drag, and while it's
|
|
514
|
+
* in use `row` drags from its grips alone (Q15) and hears its keys from them (Q27), each grip a tab stop
|
|
515
|
+
* described as `row`'s behaviour says (Q28). It writes the `touch-action` of `row`'s axis on its Subject,
|
|
516
|
+
* and nothing else: a cursor, a `role` or a label are the app's. It ends with the owner it's made under.
|
|
517
|
+
* It goes inside its row's element: a press on it reaches the row's own drag, as any press inside the row
|
|
518
|
+
* does (development says so of one outside).
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* const row = createWard(list.item(value), lift)
|
|
522
|
+
* const grip = createWard(createGrip(row), gripLook)
|
|
523
|
+
* <li {...row}><button {...grip}>⋮⋮</button>{value}</li>
|
|
524
|
+
*/
|
|
525
|
+
export const createGrip = (row: DraggingWard): RuneConfig => {
|
|
526
|
+
const site = WARD_SITES.get(row)
|
|
527
|
+
if (Predicate.isUndefined(site)) return notDragging()
|
|
528
|
+
const grips = site.grips
|
|
529
|
+
if (Predicate.isUndefined(grips)) return notDragging()
|
|
530
|
+
// A server puts nothing on a page: there each grip counts as it's made, before its row's spread is read
|
|
531
|
+
// (GP2). A browser counts those on the page, as each grip's `ref` runs and as the page changes (GP9).
|
|
532
|
+
if (isServer) {
|
|
533
|
+
grips.setCount(untrack(grips.count) + 1)
|
|
534
|
+
if (Predicate.isNotNull(getOwner())) onCleanup(() => grips.setCount(untrack(grips.count) - 1))
|
|
535
|
+
}
|
|
536
|
+
// A tab stop where its ward's behaviour hears keys, and as long as it says (Q28).
|
|
537
|
+
const keyed = (): boolean => {
|
|
538
|
+
if (site.keys.size === 0) return false
|
|
539
|
+
return keyTabStop(site)()
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
ref: (subject: HTMLElement) => gripOn(site, grips, subject),
|
|
543
|
+
props: {
|
|
544
|
+
tabindex: () => Bool.match(keyed(), { onTrue: () => 0, onFalse: constUndefined }),
|
|
545
|
+
"aria-describedby": () => Bool.match(keyed(), { onTrue: keyDescribedBy(site), onFalse: constUndefined }),
|
|
546
|
+
},
|
|
547
|
+
style: { "touch-action": () => touchActionOf(grips.axis()) },
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/** A grip of a ward that doesn't drag: development says so, and it drives nothing (Q14, Q20). */
|
|
552
|
+
const notDragging = (): RuneConfig => {
|
|
553
|
+
if (DEV) console.warn(NOT_DRAGGING)
|
|
554
|
+
return NO_GRIP
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* `subject` a grip of `site`'s ward while it's on show: a press on it is one the ward's drag hears, and its
|
|
559
|
+
* keys are watched, in a Scope of its own that closes as it goes (Q18).
|
|
560
|
+
*/
|
|
561
|
+
const gripOn = (site: Site, grips: Grips, subject: HTMLElement): (() => void) => {
|
|
562
|
+
warnIfOutside(site, subject)
|
|
563
|
+
grips.on.set(subject, UndefinedOr.map(site.at, (at) => watchGrip(site, at, subject)))
|
|
564
|
+
gripsWatched(site, grips)
|
|
565
|
+
return () => {
|
|
566
|
+
UndefinedOr.map(grips.on.get(subject), (close) => close())
|
|
567
|
+
grips.on.delete(subject)
|
|
568
|
+
gripsWatched(site, grips)
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/** Where a down landed: its platform event's target, on the page. */
|
|
573
|
+
const targetOf = (down: InputSource.PointerLikeEvent): unknown => {
|
|
574
|
+
if (Predicate.hasProperty(down.raw, "target")) return down.raw.target
|
|
575
|
+
return undefined
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Whether `node` is one of `grips` on show, or inside one: a press there is the ward's drag's. Walked up
|
|
580
|
+
* to the ward's own element, `row`, where it stops: a grip is inside its row.
|
|
581
|
+
*/
|
|
582
|
+
const onAGrip = (grips: Grips, node: unknown, row: unknown): boolean => {
|
|
583
|
+
if (Bool.not(Predicate.hasProperty(node, "parentNode"))) return false
|
|
584
|
+
if (grips.on.has(node as HTMLElement)) return true
|
|
585
|
+
if (node === row) return false
|
|
586
|
+
return onAGrip(grips, (node as Node).parentNode, row)
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/** What development says of a grip outside its row (probe: behaviour-runes, the performance round's review). */
|
|
590
|
+
export const GRIP_OUTSIDE = "createGrip(row): this grip isn't inside its row's element: a press on it can't reach the row's drag, and while it's there the row drags from its grips alone, so it can't be dragged. Render the grip inside the row."
|
|
591
|
+
|
|
592
|
+
/** Development's word on `subject`, a grip, where its ward's element is known and doesn't hold it. */
|
|
593
|
+
const warnIfOutside = (site: Site, subject: HTMLElement): void => {
|
|
594
|
+
if (DEV) {
|
|
595
|
+
UndefinedOr.map(site.at, (at) => {
|
|
596
|
+
if (Bool.not(at.element.contains(subject))) console.warn(GRIP_OUTSIDE)
|
|
597
|
+
})
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/** Whether `site`'s ward's key source is a tab stop now, as its behaviour's `onKey` said. */
|
|
602
|
+
const keyTabStop = (site: Site): Accessor<boolean> =>
|
|
603
|
+
UndefinedOr.match(UndefinedOr.map(site.keyOptions, (options) => options.tabStop), { onUndefined: () => constTrue, onDefined: identity })
|
|
604
|
+
|
|
605
|
+
/** What describes `site`'s ward's key source, as its behaviour's `onKey` said. */
|
|
606
|
+
const keyDescribedBy = (site: Site): Accessor<string | undefined> =>
|
|
607
|
+
UndefinedOr.match(UndefinedOr.map(site.keyOptions, (options) => options.describedBy), { onUndefined: () => constUndefined, onDefined: identity })
|
|
608
|
+
|
|
609
|
+
/** A `props` value as a rune gives it: plain, or an accessor of it. */
|
|
610
|
+
const readProp = (value: unknown): unknown => {
|
|
611
|
+
if (Predicate.isFunction(value)) return (value as () => unknown)()
|
|
612
|
+
return value
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/** The last of `configs` to give `name` in its `props`, read where it's read: the app's own. */
|
|
616
|
+
const ownProp = (configs: ReadonlyArray<RuneConfig>, name: string) => (): unknown =>
|
|
617
|
+
Option.match(Arr.findLast(configs, (config) => Predicate.hasProperty(config.props, name)), {
|
|
618
|
+
onNone: constUndefined,
|
|
619
|
+
onSome: (config) => readProp((config.props as Readonly<Record<string, unknown>>)[name]),
|
|
620
|
+
})
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* The rune that makes a ward whose behaviour hears keys a tab stop described by what it's given, put
|
|
624
|
+
* after the ward's own `configs`: an app's own `tabindex`, read from them, wins, and its own ids come
|
|
625
|
+
* before what the behaviour's describedBy gives, an id list joining across runes in their order, as a
|
|
626
|
+
* Reorder item's did (#209 PR 3b's R2). None for a
|
|
627
|
+
* ward with no key listener.
|
|
628
|
+
*/
|
|
629
|
+
export const keysRuneOf = (site: Site, configs: ReadonlyArray<RuneConfig>): RuneConfig | undefined => {
|
|
630
|
+
if (site.keys.size === 0) return undefined
|
|
631
|
+
const options = UndefinedOr.match(site.keyOptions, { onUndefined: (): KeyOptions => ({}), onDefined: identity })
|
|
632
|
+
const describedBy = UndefinedOr.match(options.describedBy, { onUndefined: () => constUndefined, onDefined: identity })
|
|
633
|
+
// Not while a grip is in use: its grips are the tab stops then (Q27, Q28).
|
|
634
|
+
const asked = UndefinedOr.match(options.tabStop, { onUndefined: () => constTrue, onDefined: identity })
|
|
635
|
+
const noGrip = (): boolean => UndefinedOr.match(site.grips, { onUndefined: constTrue, onDefined: (grips) => grips.count() === 0 })
|
|
636
|
+
const tabStop = (): boolean => {
|
|
637
|
+
if (Bool.not(asked())) return false
|
|
638
|
+
return noGrip()
|
|
639
|
+
}
|
|
640
|
+
const ownTabindex = ownProp(configs, "tabindex")
|
|
641
|
+
const tabindex = (): number | string | undefined =>
|
|
642
|
+
UndefinedOr.match(ownTabindex() as number | string | undefined, { onDefined: identity, onUndefined: () => Bool.match(tabStop(), { onTrue: () => 0, onFalse: constUndefined }) })
|
|
643
|
+
// An id list joins across runes in their order (`props.ts`): the app's own first, then this.
|
|
644
|
+
const described = (): string | undefined => Bool.match(tabStop(), { onTrue: describedBy, onFalse: constUndefined })
|
|
645
|
+
return { props: { tabindex, "aria-describedby": described } }
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** Whether development has said a ward's `drag` is listened to with none to hear: once a page (Q19). */
|
|
649
|
+
// Module state (#460, Q7): a development warning's once, for every page and request, as `warnOnce`'s.
|
|
650
|
+
let warned = false
|
|
651
|
+
|
|
652
|
+
/** What development says of a rune listening to `ward.drag` on a ward with no `drag` (Q19). */
|
|
653
|
+
export const NO_DRAG = "createWard(...runes): a rune listens to `ward.drag`, but nothing gives this ward a `drag`: give it `drag`, or a behaviour that does."
|
|
654
|
+
|
|
655
|
+
/** Development's word on `site`, its ward given `drag` or not, once a page (Q19). */
|
|
656
|
+
export const warnIfUndragged = (site: Site, drags: boolean): void => {
|
|
657
|
+
if (Bool.or(warned, Bool.or(drags, Bool.not(site.listened)))) return
|
|
658
|
+
warned = true
|
|
659
|
+
console.warn(NO_DRAG)
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/** A `drag` value as a drag's axis: `"x"`, `"y"`, or whether it drags freely. */
|
|
663
|
+
const axisOfDrag = (value: unknown): boolean | "x" | "y" => {
|
|
664
|
+
if (Bool.or(value === "x", value === "y")) return value as "x" | "y"
|
|
665
|
+
return value === true
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/** A `drag` a rune gives as an accessor, as a gesture's axis: read at each one's start (Q6). */
|
|
669
|
+
export const dragAxisAt = (drag: Accessor<unknown>) => (): boolean | "x" | "y" => axisOfDrag(untrack(drag))
|
|
670
|
+
|
|
671
|
+
/** A `drag` read where it's read, as an axis: what a ward's `touch-action` follows. */
|
|
672
|
+
export const dragAxisOf = (drag: Accessor<unknown>) => (): boolean | "x" | "y" => axisOfDrag(drag())
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* The `drag` the last of `configs` to give one gives, where it's an accessor (Q6, Q7): runes join and the
|
|
676
|
+
* later wins, so a later `{ drag: "x" }` or `{ drag: false }` leaves no accessor to read per gesture.
|
|
677
|
+
*/
|
|
678
|
+
export const dragAccessorOf = (configs: ReadonlyArray<RuneConfig>): Accessor<unknown> | undefined =>
|
|
679
|
+
Option.match(Arr.findLast(configs, (config) => Predicate.hasProperty(config, "drag")), {
|
|
680
|
+
onNone: constUndefined,
|
|
681
|
+
onSome: (config) => {
|
|
682
|
+
const drag = (config as { readonly drag?: unknown }).drag
|
|
683
|
+
if (Predicate.isFunction(drag)) return drag as Accessor<unknown>
|
|
684
|
+
return undefined
|
|
685
|
+
},
|
|
686
|
+
})
|
|
687
|
+
|
|
688
|
+
/** Whether a rune written as a config gives a `drag`: an accessor of one, or one that's on. */
|
|
689
|
+
export const givesDrag = (rune: RuneConfig): boolean => {
|
|
690
|
+
const drag = (rune as { readonly drag?: unknown }).drag
|
|
691
|
+
return Bool.or(Predicate.isFunction(drag), axisOfDrag(drag) !== false)
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/** `lifted` as a rune gives it, a value or an accessor, as an accessor. */
|
|
695
|
+
export const liftedOf = (given: unknown): Accessor<boolean> | undefined => {
|
|
696
|
+
if (Predicate.isFunction(given)) return given as Accessor<boolean>
|
|
697
|
+
if (given === true) return constTrue
|
|
698
|
+
return undefined
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* A `lifted` ward's raise (Q9): its projection node lifted while `lifted` is, raised over the rest, and
|
|
703
|
+
* from its letting down until its last layout animation lands, as a keyboard lift's is. Made with its
|
|
704
|
+
* ward, under its owner: an effect over `lifted`, and the node kept as the ward's mount hands it over.
|
|
705
|
+
*/
|
|
706
|
+
export const raiseOf = (lifted: Accessor<boolean>): NonNullable<WardInternals["onLayoutHandle"]> => {
|
|
707
|
+
// Nothing is raised on a server, and its effect would take a hydration id the client's doesn't (KH9).
|
|
708
|
+
if (isServer) return NO_NODE
|
|
709
|
+
let node: ProjectionSystem.NodeHandle | undefined
|
|
710
|
+
createEffect(lifted, (on) => {
|
|
711
|
+
UndefinedOr.map(node, (handle) => handle.setLifted(on))
|
|
712
|
+
}, CLIENT_ONLY_DEFERRED)
|
|
713
|
+
return (handle) => {
|
|
714
|
+
node = handle
|
|
715
|
+
if (untrack(lifted)) handle.setLifted(true)
|
|
716
|
+
return () => {
|
|
717
|
+
if (node === handle) node = undefined
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/** A layout handle's taker that keeps nothing: a server's. */
|
|
723
|
+
const NO_NODE = (): (() => void) => constVoid
|
|
724
|
+
|
|
725
|
+
/** Joins two `onLayoutHandle`s: each told the node, and each release called. */
|
|
726
|
+
export const bothHandles = (
|
|
727
|
+
a: WardInternals["onLayoutHandle"],
|
|
728
|
+
b: WardInternals["onLayoutHandle"],
|
|
729
|
+
): WardInternals["onLayoutHandle"] => {
|
|
730
|
+
if (Predicate.isUndefined(a)) return b
|
|
731
|
+
if (Predicate.isUndefined(b)) return a
|
|
732
|
+
return (node) => {
|
|
733
|
+
const first = a(node)
|
|
734
|
+
const second = b(node)
|
|
735
|
+
return () => {
|
|
736
|
+
first()
|
|
737
|
+
second()
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|