@wardic/dom 1.0.1 → 1.1.1
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/dist/Appear.d.ts +3 -2
- package/dist/Appear.d.ts.map +1 -1
- package/dist/Appear.js +4 -3
- package/dist/Appear.js.map +1 -1
- package/dist/DomProjectionSystem.js +3 -3
- package/dist/DomProjectionSystem.js.map +1 -1
- package/dist/FlushGate.d.ts +6 -6
- package/dist/FlushGate.d.ts.map +1 -1
- package/dist/FlushGate.js +11 -8
- package/dist/FlushGate.js.map +1 -1
- package/dist/ReorderController.js +3 -3
- package/dist/ReorderController.js.map +1 -1
- package/dist/Report.d.ts +1 -1
- package/dist/Report.d.ts.map +1 -1
- package/dist/Report.js +3 -2
- package/dist/Report.js.map +1 -1
- package/dist/Style.d.ts +2 -1
- package/dist/Style.d.ts.map +1 -1
- package/dist/Style.js +3 -1
- package/dist/Style.js.map +1 -1
- package/dist/TimelineValue.d.ts +18 -0
- package/dist/TimelineValue.d.ts.map +1 -0
- package/dist/TimelineValue.js +20 -0
- package/dist/TimelineValue.js.map +1 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/appear.d.ts +10 -4
- package/dist/internal/appear.d.ts.map +1 -1
- package/dist/internal/appear.js +18 -8
- package/dist/internal/appear.js.map +1 -1
- package/dist/internal/batch-handoff.d.ts +25 -0
- package/dist/internal/batch-handoff.d.ts.map +1 -0
- package/dist/internal/batch-handoff.js +64 -0
- package/dist/internal/batch-handoff.js.map +1 -0
- package/dist/internal/drag-defaults.js +4 -1
- package/dist/internal/drag-defaults.js.map +1 -1
- package/dist/internal/gate-environment.d.ts +4 -0
- package/dist/internal/gate-environment.d.ts.map +1 -0
- package/dist/internal/gate-environment.js +21 -0
- package/dist/internal/gate-environment.js.map +1 -0
- package/dist/internal/projection.d.ts.map +1 -1
- package/dist/internal/projection.js +22 -21
- package/dist/internal/projection.js.map +1 -1
- package/dist/internal/renderer.d.ts +13 -0
- package/dist/internal/renderer.d.ts.map +1 -1
- package/dist/internal/renderer.js +21 -0
- package/dist/internal/renderer.js.map +1 -1
- package/dist/internal/reorder.d.ts +2 -2
- package/dist/internal/reorder.d.ts.map +1 -1
- package/dist/internal/reorder.js +2 -2
- package/dist/internal/reorder.js.map +1 -1
- package/dist/internal/scroll.d.ts +17 -0
- package/dist/internal/scroll.d.ts.map +1 -1
- package/dist/internal/scroll.js +23 -15
- package/dist/internal/scroll.js.map +1 -1
- package/dist/internal/starting-style.d.ts +0 -83
- package/dist/internal/starting-style.d.ts.map +1 -1
- package/dist/internal/starting-style.js +16 -143
- package/dist/internal/starting-style.js.map +1 -1
- package/dist/internal/timeline.d.ts +56 -0
- package/dist/internal/timeline.d.ts.map +1 -0
- package/dist/internal/timeline.js +389 -0
- package/dist/internal/timeline.js.map +1 -0
- package/dist/unstable/AppearAnimations.d.ts +191 -0
- package/dist/unstable/AppearAnimations.d.ts.map +1 -0
- package/dist/unstable/AppearAnimations.js +561 -0
- package/dist/unstable/AppearAnimations.js.map +1 -0
- package/dist/unstable/BatchMembers.d.ts +513 -0
- package/dist/unstable/BatchMembers.d.ts.map +1 -0
- package/dist/unstable/BatchMembers.js +2490 -0
- package/dist/unstable/BatchMembers.js.map +1 -0
- package/dist/unstable/DomValues.d.ts +25 -0
- package/dist/unstable/DomValues.d.ts.map +1 -0
- package/dist/unstable/DomValues.js +45 -0
- package/dist/unstable/DomValues.js.map +1 -0
- package/dist/unstable/DragConstraints.d.ts +48 -0
- package/dist/unstable/DragConstraints.d.ts.map +1 -0
- package/dist/unstable/DragConstraints.js +49 -0
- package/dist/unstable/DragConstraints.js.map +1 -0
- package/dist/unstable/DragControls.d.ts +50 -0
- package/dist/unstable/DragControls.d.ts.map +1 -0
- package/dist/unstable/DragControls.js +55 -0
- package/dist/unstable/DragControls.js.map +1 -0
- package/dist/unstable/DragDefaults.d.ts +34 -0
- package/dist/unstable/DragDefaults.d.ts.map +1 -0
- package/dist/unstable/DragDefaults.js +47 -0
- package/dist/unstable/DragDefaults.js.map +1 -0
- package/dist/unstable/DragTrack.d.ts +236 -0
- package/dist/unstable/DragTrack.d.ts.map +1 -0
- package/dist/unstable/DragTrack.js +646 -0
- package/dist/unstable/DragTrack.js.map +1 -0
- package/dist/unstable/DragTransition.d.ts +22 -0
- package/dist/unstable/DragTransition.d.ts.map +1 -0
- package/dist/unstable/DragTransition.js +31 -0
- package/dist/unstable/DragTransition.js.map +1 -0
- package/dist/unstable/ElementSetup.d.ts +144 -0
- package/dist/unstable/ElementSetup.d.ts.map +1 -0
- package/dist/unstable/ElementSetup.js +297 -0
- package/dist/unstable/ElementSetup.js.map +1 -0
- package/dist/unstable/Feature.d.ts +221 -0
- package/dist/unstable/Feature.d.ts.map +1 -0
- package/dist/unstable/Feature.js +281 -0
- package/dist/unstable/Feature.js.map +1 -0
- package/dist/unstable/GestureFeatures.d.ts +30 -0
- package/dist/unstable/GestureFeatures.d.ts.map +1 -0
- package/dist/unstable/GestureFeatures.js +32 -0
- package/dist/unstable/GestureFeatures.js.map +1 -0
- package/dist/unstable/GestureInfo.d.ts +61 -0
- package/dist/unstable/GestureInfo.d.ts.map +1 -0
- package/dist/unstable/GestureInfo.js +23 -0
- package/dist/unstable/GestureInfo.js.map +1 -0
- package/dist/unstable/Imperative.d.ts +214 -0
- package/dist/unstable/Imperative.d.ts.map +1 -0
- package/dist/unstable/Imperative.js +768 -0
- package/dist/unstable/Imperative.js.map +1 -0
- package/dist/unstable/Instant.d.ts +46 -0
- package/dist/unstable/Instant.d.ts.map +1 -0
- package/dist/unstable/Instant.js +49 -0
- package/dist/unstable/Instant.js.map +1 -0
- package/dist/unstable/LayoutGroup.d.ts +14 -0
- package/dist/unstable/LayoutGroup.d.ts.map +1 -0
- package/dist/unstable/LayoutGroup.js +31 -0
- package/dist/unstable/LayoutGroup.js.map +1 -0
- package/dist/unstable/LayoutMember.d.ts +127 -0
- package/dist/unstable/LayoutMember.d.ts.map +1 -0
- package/dist/unstable/LayoutMember.js +176 -0
- package/dist/unstable/LayoutMember.js.map +1 -0
- package/dist/unstable/LiveStyle.d.ts +171 -0
- package/dist/unstable/LiveStyle.d.ts.map +1 -0
- package/dist/unstable/LiveStyle.js +329 -0
- package/dist/unstable/LiveStyle.js.map +1 -0
- package/dist/unstable/MemberHold.d.ts +3 -0
- package/dist/unstable/MemberHold.d.ts.map +1 -0
- package/dist/unstable/MemberHold.js +223 -0
- package/dist/unstable/MemberHold.js.map +1 -0
- package/dist/unstable/OwnerScope.d.ts +16 -0
- package/dist/unstable/OwnerScope.d.ts.map +1 -0
- package/dist/unstable/OwnerScope.js +35 -0
- package/dist/unstable/OwnerScope.js.map +1 -0
- package/dist/unstable/PresenceController.d.ts +128 -0
- package/dist/unstable/PresenceController.d.ts.map +1 -0
- package/dist/unstable/PresenceController.js +1427 -0
- package/dist/unstable/PresenceController.js.map +1 -0
- package/dist/unstable/Press.d.ts +26 -0
- package/dist/unstable/Press.d.ts.map +1 -0
- package/dist/unstable/Press.js +19 -0
- package/dist/unstable/Press.js.map +1 -0
- package/dist/unstable/ServerInterpolators.d.ts +17 -0
- package/dist/unstable/ServerInterpolators.d.ts.map +1 -0
- package/dist/unstable/ServerInterpolators.js +20 -0
- package/dist/unstable/ServerInterpolators.js.map +1 -0
- package/dist/unstable/WardConfig.d.ts +567 -0
- package/dist/unstable/WardConfig.d.ts.map +1 -0
- package/dist/unstable/WardConfig.js +2 -0
- package/dist/unstable/WardConfig.js.map +1 -0
- package/dist/unstable/features/All.d.ts +24 -0
- package/dist/unstable/features/All.d.ts.map +1 -0
- package/dist/unstable/features/All.js +20 -0
- package/dist/unstable/features/All.js.map +1 -0
- package/dist/unstable/features/Colors.d.ts +12 -0
- package/dist/unstable/features/Colors.d.ts.map +1 -0
- package/dist/unstable/features/Colors.js +38 -0
- package/dist/unstable/features/Colors.js.map +1 -0
- package/dist/unstable/features/DomAnimation.d.ts +16 -0
- package/dist/unstable/features/DomAnimation.d.ts.map +1 -0
- package/dist/unstable/features/DomAnimation.js +19 -0
- package/dist/unstable/features/DomAnimation.js.map +1 -0
- package/dist/unstable/features/DomMax.d.ts +12 -0
- package/dist/unstable/features/DomMax.d.ts.map +1 -0
- package/dist/unstable/features/DomMax.js +14 -0
- package/dist/unstable/features/DomMax.js.map +1 -0
- package/dist/unstable/features/Drag.d.ts +5 -0
- package/dist/unstable/features/Drag.d.ts.map +1 -0
- package/dist/unstable/features/Drag.js +32 -0
- package/dist/unstable/features/Drag.js.map +1 -0
- package/dist/unstable/features/Focus.d.ts +5 -0
- package/dist/unstable/features/Focus.d.ts.map +1 -0
- package/dist/unstable/features/Focus.js +20 -0
- package/dist/unstable/features/Focus.js.map +1 -0
- package/dist/unstable/features/Hover.d.ts +5 -0
- package/dist/unstable/features/Hover.d.ts.map +1 -0
- package/dist/unstable/features/Hover.js +20 -0
- package/dist/unstable/features/Hover.js.map +1 -0
- package/dist/unstable/features/InView.d.ts +5 -0
- package/dist/unstable/features/InView.d.ts.map +1 -0
- package/dist/unstable/features/InView.js +20 -0
- package/dist/unstable/features/InView.js.map +1 -0
- package/dist/unstable/features/Input.d.ts +28 -0
- package/dist/unstable/features/Input.d.ts.map +1 -0
- package/dist/unstable/features/Input.js +31 -0
- package/dist/unstable/features/Input.js.map +1 -0
- package/dist/unstable/features/Keys.d.ts +95 -0
- package/dist/unstable/features/Keys.d.ts.map +1 -0
- package/dist/unstable/features/Keys.js +44 -0
- package/dist/unstable/features/Keys.js.map +1 -0
- package/dist/unstable/features/Layout.d.ts +43 -0
- package/dist/unstable/features/Layout.d.ts.map +1 -0
- package/dist/unstable/features/Layout.js +44 -0
- package/dist/unstable/features/Layout.js.map +1 -0
- package/dist/unstable/features/Pan.d.ts +5 -0
- package/dist/unstable/features/Pan.d.ts.map +1 -0
- package/dist/unstable/features/Pan.js +20 -0
- package/dist/unstable/features/Pan.js.map +1 -0
- package/dist/unstable/features/Press.d.ts +13 -0
- package/dist/unstable/features/Press.d.ts.map +1 -0
- package/dist/unstable/features/Press.js +10 -0
- package/dist/unstable/features/Press.js.map +1 -0
- package/dist/unstable/features/Scroll.d.ts +20 -0
- package/dist/unstable/features/Scroll.d.ts.map +1 -0
- package/dist/unstable/features/Scroll.js +34 -0
- package/dist/unstable/features/Scroll.js.map +1 -0
- package/dist/unstable/features/TimelineKeys.d.ts +7 -0
- package/dist/unstable/features/TimelineKeys.d.ts.map +1 -0
- package/dist/unstable/features/TimelineKeys.js +103 -0
- package/dist/unstable/features/TimelineKeys.js.map +1 -0
- package/package.json +4 -3
- package/src/Appear.ts +4 -2
- package/src/DomProjectionSystem.ts +3 -3
- package/src/FlushGate.ts +15 -12
- package/src/ReorderController.ts +3 -3
- package/src/Report.ts +3 -7
- package/src/Style.ts +4 -1
- package/src/TimelineValue.ts +19 -0
- package/src/index.ts +15 -5
- package/src/internal/appear.ts +20 -8
- package/src/internal/batch-handoff.ts +75 -0
- package/src/internal/drag-defaults.ts +4 -4
- package/src/internal/gate-environment.ts +21 -0
- package/src/internal/projection.ts +22 -21
- package/src/internal/renderer.ts +22 -0
- package/src/internal/reorder.ts +4 -4
- package/src/internal/scroll.ts +32 -15
- package/src/internal/starting-style.ts +5 -204
- package/src/internal/timeline.ts +480 -0
- package/src/unstable/AppearAnimations.ts +837 -0
- package/src/unstable/BatchMembers.ts +3085 -0
- package/src/unstable/DomValues.ts +53 -0
- package/src/unstable/DragConstraints.ts +107 -0
- package/src/unstable/DragControls.ts +98 -0
- package/src/unstable/DragDefaults.ts +57 -0
- package/src/unstable/DragTrack.ts +959 -0
- package/src/unstable/DragTransition.ts +46 -0
- package/src/unstable/ElementSetup.ts +411 -0
- package/src/unstable/Feature.ts +494 -0
- package/src/unstable/GestureFeatures.ts +38 -0
- package/src/unstable/GestureInfo.ts +85 -0
- package/src/unstable/Imperative.ts +1037 -0
- package/src/unstable/Instant.ts +93 -0
- package/src/unstable/LayoutGroup.ts +36 -0
- package/src/unstable/LayoutMember.ts +319 -0
- package/src/unstable/LiveStyle.ts +497 -0
- package/src/unstable/MemberHold.ts +211 -0
- package/src/unstable/OwnerScope.ts +35 -0
- package/src/unstable/PresenceController.ts +1747 -0
- package/src/unstable/Press.ts +43 -0
- package/src/unstable/ServerInterpolators.ts +39 -0
- package/src/unstable/WardConfig.ts +704 -0
- package/src/unstable/features/All.ts +39 -0
- package/src/unstable/features/Colors.ts +40 -0
- package/src/unstable/features/DomAnimation.ts +19 -0
- package/src/unstable/features/DomMax.ts +14 -0
- package/src/unstable/features/Drag.ts +34 -0
- package/src/unstable/features/Focus.ts +21 -0
- package/src/unstable/features/Hover.ts +21 -0
- package/src/unstable/features/InView.ts +21 -0
- package/src/unstable/features/Input.ts +37 -0
- package/src/unstable/features/Keys.ts +124 -0
- package/src/unstable/features/Layout.ts +75 -0
- package/src/unstable/features/Pan.ts +21 -0
- package/src/unstable/features/Press.ts +21 -0
- package/src/unstable/features/Scroll.ts +35 -0
- package/src/unstable/features/TimelineKeys.ts +115 -0
- package/dist/internal/gate.d.ts +0 -188
- package/dist/internal/gate.d.ts.map +0 -1
- package/dist/internal/gate.js +0 -458
- package/dist/internal/gate.js.map +0 -1
- package/dist/internal/report.d.ts +0 -30
- package/dist/internal/report.d.ts.map +0 -1
- package/dist/internal/report.js +0 -60
- package/dist/internal/report.js.map +0 -1
- package/dist/internal/runner.d.ts +0 -21
- package/dist/internal/runner.d.ts.map +0 -1
- package/dist/internal/runner.js +0 -48
- package/dist/internal/runner.js.map +0 -1
- package/src/internal/gate.ts +0 -598
- package/src/internal/report.ts +0 -69
- package/src/internal/runner.ts +0 -64
|
@@ -6,219 +6,20 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Framework-free, so every binding renders it the same way on a server and on the client
|
|
8
8
|
* (the thin-bindings rule): a binding reads its config, calls these, and casts the style to
|
|
9
|
-
* its own JSX type.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* its own JSX type. The merge `over` does moved here from @wardic/solid with its behaviour
|
|
10
|
+
* unchanged; `over` and `without` are `dual` (#132's PR 3, ADR-0041 decision 5). Tier 2, for
|
|
11
|
+
* binding authors.
|
|
12
12
|
*
|
|
13
13
|
* Observability: pure and per element, so quiet (no span, no log).
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
// #672: its pure half (`toValues`, `resolveInitial`, the Keyframes' stops) is core's
|
|
16
|
+
// `unstable/Stops` now, which `Style` re-exports.
|
|
16
17
|
import * as Arr from "effect/Array"
|
|
17
|
-
import * as Bool from "effect/Boolean"
|
|
18
18
|
import { dual } from "effect/Function"
|
|
19
|
-
import * as Match from "effect/Match"
|
|
20
|
-
import * as Option from "effect/Option"
|
|
21
19
|
import * as Predicate from "effect/Predicate"
|
|
22
|
-
import * as Rec from "effect/Record"
|
|
23
|
-
import * as UndefinedOr from "effect/UndefinedOr"
|
|
24
20
|
import { project } from "./renderer.ts"
|
|
25
21
|
import { dashCase, type SplitPatch, splitPatchForTag } from "./svg.ts"
|
|
26
22
|
|
|
27
|
-
/**
|
|
28
|
-
* A values map with only the keys an animation can take: numbers and strings (custom
|
|
29
|
-
* properties included). `undefined` and anything else drop out, so the engine never sees
|
|
30
|
-
* them.
|
|
31
|
-
*/
|
|
32
|
-
export const toValues = (v: object | undefined): Values.Values =>
|
|
33
|
-
UndefinedOr.match(v, {
|
|
34
|
-
onUndefined: (): Values.Values => ({}),
|
|
35
|
-
onDefined: (values) => Rec.filter(values as Readonly<Record<string, unknown>>, isAnimatable),
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
/** Whether a value is one an animation can take: a number or a string. */
|
|
39
|
-
const isAnimatable = Predicate.or(Predicate.isNumber, Predicate.isString)
|
|
40
|
-
|
|
41
|
-
/** A keyframes value's stops, as Motion's: each a value, or `null`, for where the key is (the first) or the stop before (a later one). */
|
|
42
|
-
// **Keyframes** (#429).
|
|
43
|
-
export type Stops = ReadonlyArray<number | string | null>
|
|
44
|
-
|
|
45
|
-
/** Where a keyframes value is read: `initial`'s at its first stop, a target's at its last. */
|
|
46
|
-
// **Keyframes** (#429).
|
|
47
|
-
export type StopAt = "first" | "last"
|
|
48
|
-
|
|
49
|
-
/** Whether a stop is one an animation can take, or `null`. */
|
|
50
|
-
const isStop = Predicate.or(isAnimatable, Predicate.isNull)
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* A Keyframes value's stop (#429): its first, as Motion's `initial` reads it (`use-visual-state.ts`),
|
|
54
|
-
* or its last that isn't `null`, where it rests (Motion's final keyframe, `fill-wildcards.ts`'s).
|
|
55
|
-
* `null` or `undefined` when it has none.
|
|
56
|
-
*/
|
|
57
|
-
const stopOf = (stops: ReadonlyArray<unknown>, at: StopAt): unknown =>
|
|
58
|
-
Bool.match(at === "first", { onTrue: () => stops[0], onFalse: () => Option.getOrUndefined(Arr.findLast(stops, Predicate.isNotNull)) })
|
|
59
|
-
|
|
60
|
-
/** Whether a value is Keyframes an animation can take (#429): an array of stops, one of them not `null`. */
|
|
61
|
-
const isStops = (value: unknown): value is Stops => {
|
|
62
|
-
if (Bool.not(Arr.isArray(value))) return false
|
|
63
|
-
const stops = value as ReadonlyArray<unknown>
|
|
64
|
-
return Bool.and(Arr.every(stops, isStop), Arr.some(stops, Predicate.isNotNull))
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* The Keyframes {@link keepAnimatable} set aside while it filtered a values map (#452): written by it,
|
|
69
|
-
* read and cleared right after, never across a call. A target with none leaves it `undefined`.
|
|
70
|
-
*/
|
|
71
|
-
// Module state (#460, Q7): scratch within one synchronous call, never held across one.
|
|
72
|
-
let setAside: Record<string, Stops> | undefined
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* A values map's filter (#452): a value an animation can take stays, and Keyframes go aside, into
|
|
76
|
-
* {@link setAside}, so one pass over the keys finds both. Built once, at module load.
|
|
77
|
-
*/
|
|
78
|
-
const keepAnimatable = (value: unknown, key: string): boolean => {
|
|
79
|
-
if (Bool.not(Arr.isArray(value))) return isAnimatable(value)
|
|
80
|
-
if (isStops(value)) {
|
|
81
|
-
if (Predicate.isUndefined(setAside)) setAside = {}
|
|
82
|
-
setAside[key] = value
|
|
83
|
-
}
|
|
84
|
-
return false
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** A values map's numbers and strings, its Keyframes set aside (#452, {@link keepAnimatable}): {@link toValues}' one pass. */
|
|
88
|
-
const filtered = (v: object | undefined): Values.Values => {
|
|
89
|
-
// Per element at mount (#540): statements and a loop.
|
|
90
|
-
setAside = undefined
|
|
91
|
-
const out: Record<string, number | string> = {}
|
|
92
|
-
if (Predicate.isUndefined(v)) return out
|
|
93
|
-
const values = v as Readonly<Record<string, unknown>>
|
|
94
|
-
for (const key of Object.keys(values)) {
|
|
95
|
-
const value = values[key]
|
|
96
|
-
// `keepAnimatable` keeps numbers and strings alone, as `isAnimatable` does.
|
|
97
|
-
if (keepAnimatable(value, key)) out[key] = value as number | string
|
|
98
|
-
}
|
|
99
|
-
return out
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** The Keyframes the last {@link filtered} set aside, taken: `undefined` with none. */
|
|
103
|
-
const takeSetAside = (): Readonly<Record<string, Stops>> | undefined => {
|
|
104
|
-
const taken = setAside
|
|
105
|
-
setAside = undefined
|
|
106
|
-
return taken
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** `values` with each of `keyframes` at one of its stops (#429), one with no such stop left out. */
|
|
110
|
-
const withStops = (values: Values.Values, keyframes: Readonly<Record<string, Stops>>, at: StopAt): Values.Values => ({
|
|
111
|
-
...values,
|
|
112
|
-
...toValues(Rec.map(keyframes, (stops) => stopOf(stops, at))),
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
/** A values map's own values and its keyframes: `splitValues`' result. */
|
|
116
|
-
// #452.
|
|
117
|
-
export interface SplitValues {
|
|
118
|
-
/** Its numbers and strings, each Keyframes value at one of its stops. */
|
|
119
|
-
readonly values: Values.Values
|
|
120
|
-
/** Its Keyframes, if it has any. */
|
|
121
|
-
// An `Option` (#618, A1): none is Effect's one `None`, so a target with no Keyframes allocates nothing.
|
|
122
|
-
readonly keyframes: Option.Option<Readonly<Record<string, Stops>>>
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* A values map's values, each keyframes value read at one of its stops, and its keyframes, in one pass
|
|
127
|
-
* over its keys: a target's resolution reads both, and a target with no keyframes makes nothing
|
|
128
|
-
* `toValues` doesn't.
|
|
129
|
-
*/
|
|
130
|
-
// **Keyframes** (#429); one pass (#452).
|
|
131
|
-
export const splitValues = (v: object | undefined, at: StopAt): SplitValues => {
|
|
132
|
-
const values = filtered(v)
|
|
133
|
-
const keyframes = takeSetAside()
|
|
134
|
-
if (Predicate.isUndefined(keyframes)) return { values, keyframes: Option.none() }
|
|
135
|
-
return { values: withStops(values, keyframes, at), keyframes: Option.some(keyframes) }
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* A values map with only the keys an animation can take, each keyframes value read at one of its stops:
|
|
140
|
-
* `initial`'s first, a target's last. A keyframes value with no such stop drops out, as does an array
|
|
141
|
-
* `keyframesOf` doesn't take, and anything that isn't a number or a string. One pass over its keys, as
|
|
142
|
-
* `toValues`'.
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* Style.valuesAt({ opacity: [0, 0.5, 1], x: 10 }, "first") // { x: 10, opacity: 0 }
|
|
146
|
-
*/
|
|
147
|
-
// **Keyframes** (#429); one pass (#452).
|
|
148
|
-
export const valuesAt = (v: object | undefined, at: StopAt): Values.Values => {
|
|
149
|
-
const values = filtered(v)
|
|
150
|
-
const keyframes = takeSetAside()
|
|
151
|
-
if (Predicate.isUndefined(keyframes)) return values
|
|
152
|
-
return withStops(values, keyframes, at)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* A values map's keyframes values: each array of stops an animation can take, one with a stop that isn't
|
|
157
|
-
* `null`. None when it has none, so a target without any makes nothing.
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* Style.keyframesOf({ opacity: [0, 0.5, 1], x: 10 }) // { opacity: [0, 0.5, 1] }
|
|
161
|
-
*/
|
|
162
|
-
// **Keyframes** (#429).
|
|
163
|
-
export const keyframesOf = (v: object | undefined): Option.Option<Readonly<Record<string, Stops>>> => splitValues(v, "last").keyframes
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* What of an element's config its starting style is read from. Its values are typed `object`, so a
|
|
167
|
-
* binding's own value types fit as they are.
|
|
168
|
-
*/
|
|
169
|
-
export interface InitialConfig {
|
|
170
|
-
/**
|
|
171
|
-
* Its start: values used as they are, the name of a `variants` entry, a list of names merged in order,
|
|
172
|
-
* a later one's winning, or `false`, to start at `animate`, as Motion's `initial={false}`.
|
|
173
|
-
*/
|
|
174
|
-
// #297 (lists); #134 (`false`).
|
|
175
|
-
readonly initial?: object | string | ReadonlyArray<string> | false | undefined
|
|
176
|
-
/** What `initial: false` starts at: a values map, the name of a `variants` entry, or a list of names. */
|
|
177
|
-
readonly animate?: object | string | ReadonlyArray<string> | undefined
|
|
178
|
-
/** Its variants: the values each name stands for. */
|
|
179
|
-
readonly variants?: Readonly<Record<string, object | undefined>> | undefined
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/** One values entry, the variants a name in it would name, and the stop its Keyframes values are read at (#429). */
|
|
183
|
-
interface Entry {
|
|
184
|
-
readonly entry: object | string | ReadonlyArray<string> | undefined
|
|
185
|
-
readonly variants: InitialConfig["variants"]
|
|
186
|
-
readonly at: StopAt
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/** Whether an entry is a list of names (#297): an array, which a values map never is. */
|
|
190
|
-
const isList = (entry: unknown): entry is ReadonlyArray<string> => Arr.isArray(entry)
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* A values map, or the `variants` entry a name names (an unknown name is empty), or nothing.
|
|
194
|
-
* Built once, at module load: every element reads its own at setup (#69).
|
|
195
|
-
*/
|
|
196
|
-
const entryOf: (entry: Entry) => Values.Values = Match.type<Entry>().pipe(
|
|
197
|
-
Match.when({ entry: Match.undefined }, (): Values.Values => ({})),
|
|
198
|
-
Match.when({ entry: Match.string }, ({ entry, variants, at }) => valuesAt(UndefinedOr.map(variants, (byName) => byName[entry]), at)),
|
|
199
|
-
// A list's names merged in order, a later one's winning a key both set (#297, Motion's).
|
|
200
|
-
Match.when({ entry: isList }, ({ entry, variants, at }) =>
|
|
201
|
-
Arr.reduce(entry, {} as Values.Values, (merged, name) => ({ ...merged, ...valuesAt(UndefinedOr.map(variants, (byName) => byName[name]), at) }))),
|
|
202
|
-
Match.orElse(({ entry, at }) => valuesAt(entry as object, at)),
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* The values an element starts from: its `initial` values, or the `variants` entries its `initial` names,
|
|
207
|
-
* an unknown name empty, or nothing. With `initial: false`, its `animate`, resolved the same way, so it
|
|
208
|
-
* starts at its target and nothing animates at mount, as Motion's. A keyframes value starts at its first
|
|
209
|
-
* stop, or, with `initial: false`, at `animate`'s last, where the animation it skips would end. Read once,
|
|
210
|
-
* at setup: the starting style is where it starts, never a live target.
|
|
211
|
-
*
|
|
212
|
-
* @example
|
|
213
|
-
* Style.resolveInitial({ initial: false, animate: { opacity: 1 } }) // { opacity: 1 }
|
|
214
|
-
*/
|
|
215
|
-
// #134, Motion's `initial={false}`; **Keyframes** (#429, Motion's `use-visual-state.ts`).
|
|
216
|
-
export const resolveInitial = (config: InitialConfig): Values.Values => {
|
|
217
|
-
// Per element at mount (#540): statements.
|
|
218
|
-
if (config.initial === false) return entryOf({ entry: config.animate, variants: config.variants, at: "last" })
|
|
219
|
-
return entryOf({ entry: config.initial as object | string | ReadonlyArray<string> | undefined, variants: config.variants, at: "first" })
|
|
220
|
-
}
|
|
221
|
-
|
|
222
23
|
/**
|
|
223
24
|
* A CSS declaration list (`"color: red; background: url(a;b)"`) as `{ property: value }`.
|
|
224
25
|
* A `;` inside parentheses or quotes doesn't end a declaration. Internal (not in the
|