@wardic/core 1.1.0 → 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/unstable/AnimationControls.d.ts +110 -0
- package/dist/unstable/AnimationControls.d.ts.map +1 -0
- package/dist/unstable/AnimationControls.js +107 -0
- package/dist/unstable/AnimationControls.js.map +1 -0
- package/dist/unstable/AppearHandoff.d.ts +53 -0
- package/dist/unstable/AppearHandoff.d.ts.map +1 -0
- package/dist/unstable/AppearHandoff.js +23 -0
- package/dist/unstable/AppearHandoff.js.map +1 -0
- package/dist/unstable/Config.d.ts +285 -0
- package/dist/unstable/Config.d.ts.map +1 -0
- package/dist/unstable/Config.js +3 -0
- package/dist/unstable/Config.js.map +1 -0
- package/dist/unstable/FlushGate.d.ts +222 -0
- package/dist/unstable/FlushGate.d.ts.map +1 -0
- package/dist/unstable/FlushGate.js +567 -0
- package/dist/unstable/FlushGate.js.map +1 -0
- package/dist/unstable/FrameTime.d.ts +21 -0
- package/dist/unstable/FrameTime.d.ts.map +1 -0
- package/dist/unstable/FrameTime.js +45 -0
- package/dist/unstable/FrameTime.js.map +1 -0
- package/dist/unstable/MeasuredPairs.d.ts +51 -0
- package/dist/unstable/MeasuredPairs.d.ts.map +1 -0
- package/dist/unstable/MeasuredPairs.js +20 -0
- package/dist/unstable/MeasuredPairs.js.map +1 -0
- package/dist/unstable/OwnValues.d.ts +29 -0
- package/dist/unstable/OwnValues.d.ts.map +1 -0
- package/dist/unstable/OwnValues.js +22 -0
- package/dist/unstable/OwnValues.js.map +1 -0
- package/dist/unstable/PresenceRecord.d.ts +176 -0
- package/dist/unstable/PresenceRecord.d.ts.map +1 -0
- package/dist/unstable/PresenceRecord.js +26 -0
- package/dist/unstable/PresenceRecord.js.map +1 -0
- package/dist/unstable/Reactivity.d.ts +29 -0
- package/dist/unstable/Reactivity.d.ts.map +1 -0
- package/dist/unstable/Reactivity.js +15 -0
- package/dist/unstable/Reactivity.js.map +1 -0
- package/dist/unstable/Report.d.ts +30 -0
- package/dist/unstable/Report.d.ts.map +1 -0
- package/dist/unstable/Report.js +66 -0
- package/dist/unstable/Report.js.map +1 -0
- package/dist/unstable/RetargetLegs.d.ts +189 -0
- package/dist/unstable/RetargetLegs.d.ts.map +1 -0
- package/dist/unstable/RetargetLegs.js +834 -0
- package/dist/unstable/RetargetLegs.js.map +1 -0
- package/dist/unstable/Spine.d.ts +696 -0
- package/dist/unstable/Spine.d.ts.map +1 -0
- package/dist/unstable/Spine.js +2617 -0
- package/dist/unstable/Spine.js.map +1 -0
- package/dist/unstable/Stops.d.ts +82 -0
- package/dist/unstable/Stops.d.ts.map +1 -0
- package/dist/unstable/Stops.js +149 -0
- package/dist/unstable/Stops.js.map +1 -0
- package/dist/unstable/Subject.d.ts +11 -0
- package/dist/unstable/Subject.d.ts.map +1 -0
- package/dist/unstable/Subject.js +12 -0
- package/dist/unstable/Subject.js.map +1 -0
- package/dist/unstable/Timelines.d.ts +51 -0
- package/dist/unstable/Timelines.d.ts.map +1 -0
- package/dist/unstable/Timelines.js +10 -0
- package/dist/unstable/Timelines.js.map +1 -0
- package/dist/unstable/VariableValues.d.ts +27 -0
- package/dist/unstable/VariableValues.d.ts.map +1 -0
- package/dist/unstable/VariableValues.js +19 -0
- package/dist/unstable/VariableValues.js.map +1 -0
- package/dist/unstable/VariantTarget.d.ts +106 -0
- package/dist/unstable/VariantTarget.d.ts.map +1 -0
- package/dist/unstable/VariantTarget.js +185 -0
- package/dist/unstable/VariantTarget.js.map +1 -0
- package/dist/unstable/VariantTree.d.ts +351 -0
- package/dist/unstable/VariantTree.d.ts.map +1 -0
- package/dist/unstable/VariantTree.js +362 -0
- package/dist/unstable/VariantTree.js.map +1 -0
- package/dist/unstable/WardicConfigValue.d.ts +89 -0
- package/dist/unstable/WardicConfigValue.d.ts.map +1 -0
- package/dist/unstable/WardicConfigValue.js +106 -0
- package/dist/unstable/WardicConfigValue.js.map +1 -0
- package/dist/unstable/WardicServices.d.ts +46 -0
- package/dist/unstable/WardicServices.d.ts.map +1 -0
- package/dist/unstable/WardicServices.js +72 -0
- package/dist/unstable/WardicServices.js.map +1 -0
- package/package.json +1 -1
- package/src/unstable/AnimationControls.ts +199 -0
- package/src/unstable/AppearHandoff.ts +81 -0
- package/src/unstable/Config.ts +326 -0
- package/src/unstable/FlushGate.ts +730 -0
- package/src/unstable/FrameTime.ts +52 -0
- package/src/unstable/MeasuredPairs.ts +56 -0
- package/src/unstable/OwnValues.ts +32 -0
- package/src/unstable/PresenceRecord.ts +201 -0
- package/src/unstable/Reactivity.ts +35 -0
- package/src/unstable/Report.ts +75 -0
- package/src/unstable/RetargetLegs.ts +1062 -0
- package/src/unstable/Spine.ts +3275 -0
- package/src/unstable/Stops.ts +221 -0
- package/src/unstable/Subject.ts +13 -0
- package/src/unstable/Timelines.ts +58 -0
- package/src/unstable/VariableValues.ts +27 -0
- package/src/unstable/VariantTarget.ts +246 -0
- package/src/unstable/VariantTree.ts +643 -0
- package/src/unstable/WardicConfigValue.ts +154 -0
- package/src/unstable/WardicServices.ts +125 -0
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rules of an element's place in variant orchestration (ADR-0007, #50), on every binding: the
|
|
3
|
+
* names an element hands its children and inherits from its parent, the values it starts from, and
|
|
4
|
+
* what a server render builds. Each binding's variant node runs the orchestration over them, with its
|
|
5
|
+
* own reactivity.
|
|
6
|
+
*
|
|
7
|
+
* Motion's rule (CONTEXT.md, **Variant child**):
|
|
8
|
+
* - An element that names its own variants, a name on any variant prop (`initial`, `animate`, the
|
|
9
|
+
* `while*` gestures, `exit`; #618), hands its children its `initial` and `animate` names, and an
|
|
10
|
+
* `initial={false}` with them (#134). Any other passes its parent's through, unless it sets
|
|
11
|
+
* `inherit={false}`, which passes none.
|
|
12
|
+
* - A **Variant child** (`variants`, no names of its own, `inherit` not `false`) inherits its
|
|
13
|
+
* ancestor's names and default transition, takes a stagger slot among the ancestor's variant
|
|
14
|
+
* children, and counts for the ancestor's `when`.
|
|
15
|
+
* - An element with variants of its own (`variants`, or a name) is what its Variant children
|
|
16
|
+
* join: it owns their registry, their stagger and their `when`. Any other element passes its
|
|
17
|
+
* parent's context through, so a Variant child joins its nearest such ancestor; it renders no
|
|
18
|
+
* Provider unless it sets `inherit={false}` ({@link changesContext}).
|
|
19
|
+
*
|
|
20
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
// Unstable: ADR-0071, decision 5. #672: solid's `variant-tree.ts`, moved for the spine to read an
|
|
25
|
+
// element's place in variant orchestration in core.
|
|
26
|
+
import * as Stagger from "../Stagger.js";
|
|
27
|
+
import * as Stops from "./Stops.js";
|
|
28
|
+
import * as Arr from "effect/Array";
|
|
29
|
+
import * as Bool from "effect/Boolean";
|
|
30
|
+
import { constTrue, constUndefined, identity } from "effect/Function";
|
|
31
|
+
import * as Predicate from "effect/Predicate";
|
|
32
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
33
|
+
import * as AnimationControls from "./AnimationControls.js";
|
|
34
|
+
import * as VariantTarget from "./VariantTarget.js";
|
|
35
|
+
/** The gesture layers in Motion's priority, lowest first. */
|
|
36
|
+
export const GESTURE_LAYERS = ["inView", "focused", "hovered", "pressed", "dragged"];
|
|
37
|
+
/** No gesture on: what an element with none active hands down. */
|
|
38
|
+
export const NO_GESTURE_NAMES = {};
|
|
39
|
+
/** Two {@link GestureNames} the same: the same names for each gesture, a list name by name (#297). */
|
|
40
|
+
export const sameGestureNames = (a, b) => GESTURE_LAYERS.every((layer) => VariantTarget.sameLabels(a[layer], b[layer]));
|
|
41
|
+
/** No gesture on. */
|
|
42
|
+
export const NO_GESTURE_STATES = { inView: false, focused: false, hovered: false, pressed: false, dragged: false };
|
|
43
|
+
/** Nothing on, no labels: what an element hands down with no provider and no gesture. */
|
|
44
|
+
export const NO_HAND_DOWN = { on: NO_GESTURE_STATES, names: NO_GESTURE_NAMES };
|
|
45
|
+
/** Two hand-downs the same: each gesture on alike, with the same label. */
|
|
46
|
+
export const sameHandDown = (a, b) => GESTURE_LAYERS.every((layer) => Bool.and(a.on[layer] === b.on[layer], VariantTarget.sameLabels(a.names[layer], b.names[layer])));
|
|
47
|
+
/** What a context hands down, nothing without a context or its gestures. */
|
|
48
|
+
export const handDownFrom = (context) => {
|
|
49
|
+
// Per Retarget, per element: guards, nothing made (most elements have no provider).
|
|
50
|
+
if (Predicate.isUndefined(context))
|
|
51
|
+
return NO_HAND_DOWN;
|
|
52
|
+
const gestures = context.gestures;
|
|
53
|
+
if (Predicate.isUndefined(gestures))
|
|
54
|
+
return NO_HAND_DOWN;
|
|
55
|
+
return gestures();
|
|
56
|
+
};
|
|
57
|
+
/** Each gesture on: its own, or its provider's. */
|
|
58
|
+
export const gesturesOn = (own, above) => ({
|
|
59
|
+
inView: Bool.or(own.inView, above.inView),
|
|
60
|
+
focused: Bool.or(own.focused, above.focused),
|
|
61
|
+
hovered: Bool.or(own.hovered, above.hovered),
|
|
62
|
+
pressed: Bool.or(own.pressed, above.pressed),
|
|
63
|
+
dragged: Bool.or(own.dragged, above.dragged),
|
|
64
|
+
});
|
|
65
|
+
/** A gesture's label (#291): its own `while*`, if a name or a list (#297); with none of its own, the one it took. */
|
|
66
|
+
const labelOf = (own, inherited) => {
|
|
67
|
+
if (Predicate.isNotUndefined(own))
|
|
68
|
+
return nameOf(own);
|
|
69
|
+
return inherited;
|
|
70
|
+
};
|
|
71
|
+
/** What an element hands down (#291), from its config, its own states, and what it takes. */
|
|
72
|
+
export const handDownOf = (config, own, above) => ({
|
|
73
|
+
on: gesturesOn(own, above.on),
|
|
74
|
+
names: {
|
|
75
|
+
inView: labelOf(config.whileInView, above.names.inView),
|
|
76
|
+
focused: labelOf(config.whileFocus, above.names.focused),
|
|
77
|
+
hovered: labelOf(config.whileHover, above.names.hovered),
|
|
78
|
+
pressed: labelOf(config.whileTap, above.names.pressed),
|
|
79
|
+
dragged: labelOf(config.whileDrag, above.names.dragged),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
/** The name each gesture's layer resolves while it's on (#291): its label then; off, none. */
|
|
83
|
+
export const activeNamesOf = (handDown) => ({
|
|
84
|
+
inView: activeName(handDown, "inView"),
|
|
85
|
+
focused: activeName(handDown, "focused"),
|
|
86
|
+
hovered: activeName(handDown, "hovered"),
|
|
87
|
+
pressed: activeName(handDown, "pressed"),
|
|
88
|
+
dragged: activeName(handDown, "dragged"),
|
|
89
|
+
});
|
|
90
|
+
/** A gesture's label while it's on. */
|
|
91
|
+
const activeName = (handDown, layer) => {
|
|
92
|
+
if (Bool.not(handDown.on[layer]))
|
|
93
|
+
return undefined;
|
|
94
|
+
return handDown.names[layer];
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* A key for a variant name and the active gestures' names: what a provider's orchestration snapshots
|
|
98
|
+
* at (#291), a list's names each (#297). A **Controls change** (#433) is one too, to the same name.
|
|
99
|
+
*/
|
|
100
|
+
export const triggerKeyOf = (variant, handDown, change) => [keyOfLabels(variant), ...GESTURE_LAYERS.map((layer) => keyOfLabels(activeName(handDown, layer))), UndefinedOr.match(change, { onUndefined: () => "", onDefined: (c) => `${c.serial}` })].join("|");
|
|
101
|
+
/** {@link ChangeAtTrigger} after a trigger `key` with `change` in effect. */
|
|
102
|
+
export const changeAtTrigger = (change, key, previous) => {
|
|
103
|
+
if (Predicate.isUndefined(previous))
|
|
104
|
+
return { change, key, by: change };
|
|
105
|
+
if (change !== previous.change)
|
|
106
|
+
return { change, key, by: change };
|
|
107
|
+
if (key !== previous.key)
|
|
108
|
+
return { change, key, by: undefined };
|
|
109
|
+
return previous;
|
|
110
|
+
};
|
|
111
|
+
/** Each Controls change's override as a name's orchestration (#433), made once a change. */
|
|
112
|
+
// Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
|
|
113
|
+
const CHANGE_CONFIGS = new WeakMap();
|
|
114
|
+
/**
|
|
115
|
+
* The orchestration every name of a list takes at a trigger a Controls change came with (#433): its
|
|
116
|
+
* override's, or `undefined` for none (each name its own).
|
|
117
|
+
*/
|
|
118
|
+
export const changeConfigOf = (at) => {
|
|
119
|
+
const by = at.by;
|
|
120
|
+
if (Predicate.isUndefined(by))
|
|
121
|
+
return undefined;
|
|
122
|
+
const override = by.override;
|
|
123
|
+
if (Predicate.isUndefined(override))
|
|
124
|
+
return undefined;
|
|
125
|
+
const known = CHANGE_CONFIGS.get(by);
|
|
126
|
+
if (Predicate.isNotUndefined(known))
|
|
127
|
+
return known;
|
|
128
|
+
const made = nameConfigOf(override);
|
|
129
|
+
CHANGE_CONFIGS.set(by, made);
|
|
130
|
+
return made;
|
|
131
|
+
};
|
|
132
|
+
/** A provider's orchestration at a trigger (#433): the override of the change it came with, else its own. */
|
|
133
|
+
export const orchestrationAt = (at, own) => UndefinedOr.match(UndefinedOr.map(at.by, (by) => by.override), { onUndefined: own, onDefined: identity });
|
|
134
|
+
/** Labels as one key: a list's names apart by a character no name has in practice. */
|
|
135
|
+
const keyOfLabels = (labels) => Arr.join(VariantTarget.labelsOf(labels), "\u0001");
|
|
136
|
+
/** The highest-priority active gesture's name, or list (#297), if any hands one down. */
|
|
137
|
+
export const topGestureName = (names) => UndefinedOr.match(names.dragged, {
|
|
138
|
+
onDefined: identity,
|
|
139
|
+
onUndefined: () => UndefinedOr.match(names.pressed, {
|
|
140
|
+
onDefined: identity,
|
|
141
|
+
onUndefined: () => UndefinedOr.match(names.hovered, {
|
|
142
|
+
onDefined: identity,
|
|
143
|
+
onUndefined: () => UndefinedOr.match(names.focused, { onDefined: identity, onUndefined: () => names.inView }),
|
|
144
|
+
}),
|
|
145
|
+
}),
|
|
146
|
+
});
|
|
147
|
+
/** An `initial` an element hands its children: a variant name or list (#297), `false` (#134), or `undefined` for a values map or nothing. */
|
|
148
|
+
export const initialNameOf = (entry) => Bool.match(entry === false, { onTrue: () => false, onFalse: () => nameOf(entry) });
|
|
149
|
+
/** A variant name or a list of names (#297), or `undefined` for a values map or nothing. */
|
|
150
|
+
export const nameOf = (entry) => Bool.match(VariantTarget.isLabels(entry), { onTrue: () => entry, onFalse: constUndefined });
|
|
151
|
+
/**
|
|
152
|
+
* Whether `config` names its own variants: any of its variant props, `initial`, `animate`, the five
|
|
153
|
+
* `while*` and `exit`, is a name or a list, or its `animate` is **Animation controls** (#433), as given
|
|
154
|
+
* or as its binding marks the config it reads (Motion's `isControllingVariants`, `isVariantLabel`).
|
|
155
|
+
*/
|
|
156
|
+
// #618 (decision 8): Motion's `variantProps` (motion-dom 14.6 render/utils/variant-props.mjs); only
|
|
157
|
+
// `initial` and `animate` counted before. Statements, not a loop over the keys: it's read per change.
|
|
158
|
+
export const namesOwnVariants = (config) => config.controlled === true ||
|
|
159
|
+
AnimationControls.isAnimationControls(config.animate) ||
|
|
160
|
+
VariantTarget.isLabels(config.initial) ||
|
|
161
|
+
VariantTarget.isLabels(config.animate) ||
|
|
162
|
+
VariantTarget.isLabels(config.whileInView) ||
|
|
163
|
+
VariantTarget.isLabels(config.whileFocus) ||
|
|
164
|
+
VariantTarget.isLabels(config.whileHover) ||
|
|
165
|
+
VariantTarget.isLabels(config.whileTap) ||
|
|
166
|
+
VariantTarget.isLabels(config.whileDrag) ||
|
|
167
|
+
VariantTarget.isLabels(config.exit);
|
|
168
|
+
/** Whether an element has variants of its own, so Variant children join it (Motion's `isVariantNode`). */
|
|
169
|
+
export const hasOwnVariants = (config) => Predicate.isNotUndefined(config.variants) || namesOwnVariants(config);
|
|
170
|
+
/**
|
|
171
|
+
* Whether an element changes what its children read, so it renders its variant context's
|
|
172
|
+
* Provider (#50): it has variants of its own, or it sets `inherit={false}`. Any other element hands
|
|
173
|
+
* its children its parent's context as it is, so it renders none. Decided once, at setup, from the
|
|
174
|
+
* same props on a server and on the client, so the nesting never changes after mount.
|
|
175
|
+
*/
|
|
176
|
+
export const changesContext = (config) => hasOwnVariants(config) || config.inherit === false;
|
|
177
|
+
/**
|
|
178
|
+
* The **Controls change** in effect for an element (#433): its own controls', else the one the context
|
|
179
|
+
* it inherits from is in, else none. Per mount, for every element (#460): guards, nothing built.
|
|
180
|
+
*/
|
|
181
|
+
export const controlsChangeOf = (controls, inherited) => {
|
|
182
|
+
if (Predicate.isNotUndefined(controls))
|
|
183
|
+
return controls;
|
|
184
|
+
if (Predicate.isUndefined(inherited))
|
|
185
|
+
return constUndefined;
|
|
186
|
+
const change = inherited.change;
|
|
187
|
+
if (Predicate.isUndefined(change))
|
|
188
|
+
return constUndefined;
|
|
189
|
+
return change;
|
|
190
|
+
};
|
|
191
|
+
/** Whether an element is a **Variant child** (CONTEXT.md). */
|
|
192
|
+
export const isVariantChild = (config) => Predicate.isNotUndefined(config.variants) && !namesOwnVariants(config) && config.inherit !== false;
|
|
193
|
+
/** The context an element inherits names and its default transition from: its parent's, for a Variant child. */
|
|
194
|
+
export const inheritedContext = (config, parent) => {
|
|
195
|
+
// Per element at mount (#540): statements.
|
|
196
|
+
if (isVariantChild(config))
|
|
197
|
+
return parent;
|
|
198
|
+
return undefined;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* The `initial` an element's Starting style resolves: its own, else the `initial` name (or `false`) of
|
|
202
|
+
* the context it inherits from (#50, #134). Read once, as every `initial` is.
|
|
203
|
+
*/
|
|
204
|
+
export const initialOf = (config, inherited) => UndefinedOr.match(config.initial, {
|
|
205
|
+
onDefined: (initial) => initial,
|
|
206
|
+
onUndefined: () => UndefinedOr.match(inherited, { onUndefined: constUndefined, onDefined: (context) => context.initial }),
|
|
207
|
+
});
|
|
208
|
+
/** The `animate` an element starts at with `initial={false}`: its own, else the name its context hands down (#134). Read once, untracked. */
|
|
209
|
+
const animateOf = (config, inherited, untrack) => UndefinedOr.match(config.animate, {
|
|
210
|
+
onDefined: (animate) => animate,
|
|
211
|
+
onUndefined: () => UndefinedOr.match(inherited, { onUndefined: constUndefined, onDefined: (context) => untrack(context.variant) }),
|
|
212
|
+
});
|
|
213
|
+
/**
|
|
214
|
+
* Whether an element starts at its `animate`, with nothing animating at mount (#134, Motion's
|
|
215
|
+
* `isInitialAnimationBlocked`): its `initial` (own or inherited) is `false`, or it renders with an
|
|
216
|
+
* `<AnimatePresence initial={false}>`'s first render (`presenceBlocks`).
|
|
217
|
+
*/
|
|
218
|
+
export const startsAtAnimate = (config, inherited, presenceBlocks) => presenceBlocks || initialOf(config, inherited) === false;
|
|
219
|
+
/**
|
|
220
|
+
* Whether an element's mount tells nothing (#448, Motion's `animation-state.ts`): it
|
|
221
|
+
* {@link startsAtAnimate}, or its `initial` (own, else inherited) is the same name, list or values map
|
|
222
|
+
* as its `animate` (own, else inherited). Its first Retarget, landing with nothing to animate, is told
|
|
223
|
+
* to no one. Read once, untracked.
|
|
224
|
+
*/
|
|
225
|
+
export const startsQuiet = (config, inherited, presenceBlocks, untrack) => {
|
|
226
|
+
if (startsAtAnimate(config, inherited, presenceBlocks))
|
|
227
|
+
return true;
|
|
228
|
+
const initial = initialOf(config, inherited);
|
|
229
|
+
if (Predicate.isUndefined(initial))
|
|
230
|
+
return false;
|
|
231
|
+
// The same map is the same entry, as the same name or list is.
|
|
232
|
+
return VariantTarget.sameLabels(initial, animateOf(config, inherited, untrack));
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* The values an element starts from, its Starting style's input (ADR-0003): its `initial` (own, else
|
|
236
|
+
* inherited, #50), or, when it {@link startsAtAnimate}, its `animate` (own, else inherited), as
|
|
237
|
+
* Motion's `initial={false}` (#134). Read once: an inherited name is read through `untrack`.
|
|
238
|
+
*/
|
|
239
|
+
export const startingValuesOf = (config, inherited, presenceBlocks, untrack) => {
|
|
240
|
+
const atAnimate = startsAtAnimate(config, inherited, presenceBlocks);
|
|
241
|
+
const animate = animateOf(config, inherited, untrack);
|
|
242
|
+
const initial = initialOf(config, inherited);
|
|
243
|
+
// Per element at mount (#540): statements. Starting at `animate` resolves as `initial={false}`,
|
|
244
|
+
// and its first target is `animate`.
|
|
245
|
+
let from = initial;
|
|
246
|
+
let first = initial;
|
|
247
|
+
if (atAnimate) {
|
|
248
|
+
from = false;
|
|
249
|
+
first = animate;
|
|
250
|
+
}
|
|
251
|
+
const values = Stops.resolveInitial({
|
|
252
|
+
initial: from,
|
|
253
|
+
animate,
|
|
254
|
+
// Dynamic variants resolved first (#277): `@wardic/dom`'s Starting style reads values maps only.
|
|
255
|
+
variants: VariantTarget.startingVariantsOf(config.variants, config.custom),
|
|
256
|
+
});
|
|
257
|
+
// The first target's Transition end (#428, Motion's `makeLatestValues`): set at once, so a server
|
|
258
|
+
// renders it, and a hydration finds it.
|
|
259
|
+
if (Predicate.isUndefined(first) || first === false)
|
|
260
|
+
return values;
|
|
261
|
+
const end = VariantTarget.resolveTarget(first, config.variants, config.custom, VariantTarget.NO_VARIANT_STATE).transitionEnd;
|
|
262
|
+
if (Predicate.isUndefined(end))
|
|
263
|
+
return values;
|
|
264
|
+
return { ...values, ...end };
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* A name an element hands its children (Motion's `getCurrentTreeVariants`): `own` if it names its own
|
|
268
|
+
* variants, else `fromParent` unless it sets `inherit={false}`.
|
|
269
|
+
*/
|
|
270
|
+
export const handedDown = (config, own, fromParent) => Bool.match(namesOwnVariants(config), {
|
|
271
|
+
onTrue: own,
|
|
272
|
+
onFalse: () => Bool.match(config.inherit === false, { onTrue: constUndefined, onFalse: fromParent }),
|
|
273
|
+
});
|
|
274
|
+
/** An element's own transition, else the one it inherits. */
|
|
275
|
+
export const ownOrInherited = (own, inherited) => UndefinedOr.match(own, { onUndefined: () => UndefinedOr.map(inherited, (context) => context.transition()), onDefined: identity });
|
|
276
|
+
/** The stagger config an element's `transition` gives its Variant children. */
|
|
277
|
+
export const staggerOf = (transition) => UndefinedOr.match(transition, { onUndefined: () => staggerWith({}), onDefined: staggerWith });
|
|
278
|
+
/** A context's stagger config for one of its names (#297): its `staggerFor`'s, else its whole orchestration's. */
|
|
279
|
+
export const staggerOfName = (context, name) => {
|
|
280
|
+
const of = context.staggerFor;
|
|
281
|
+
if (Predicate.isUndefined(of))
|
|
282
|
+
return context.stagger();
|
|
283
|
+
return of(name);
|
|
284
|
+
};
|
|
285
|
+
/** Whether a context lets a Variant child's keys of a list's name start (#297's PR 2): its `mayStartFor`, else always. */
|
|
286
|
+
export const mayStartOf = (context, name) => {
|
|
287
|
+
const of = context.mayStartFor;
|
|
288
|
+
if (Predicate.isUndefined(of))
|
|
289
|
+
return true;
|
|
290
|
+
return of(name);
|
|
291
|
+
};
|
|
292
|
+
/** A child's place in a stagger, turned by its `staggerDirection`: `-1` counts from the last. */
|
|
293
|
+
export const directed = (index, total, direction) => {
|
|
294
|
+
if (direction === -1)
|
|
295
|
+
return total - 1 - index;
|
|
296
|
+
return index;
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* A child's delay in a stagger (ADR-0007): its `delayChildren` plus its place from the origin, turned
|
|
300
|
+
* by its `staggerDirection`. A function `delayChildren` (#436, Motion's `calcChildStagger`) decides it
|
|
301
|
+
* whole, from the child's index and the count. Every stagger, a Variant child's, a presence's exit's
|
|
302
|
+
* and a server's Appear timing, is placed by it.
|
|
303
|
+
*/
|
|
304
|
+
export const childDelayOf = (s, index, total) => {
|
|
305
|
+
if (Predicate.isFunction(s.delayChildren))
|
|
306
|
+
return s.delayChildren(index, total);
|
|
307
|
+
return s.delayChildren + Stagger.make(s.amount, { from: s.from })(directed(index, total, s.direction), total);
|
|
308
|
+
};
|
|
309
|
+
/** A {@link NameConfig} from the transition a name orchestrates on. */
|
|
310
|
+
export const nameConfigOf = (transition) => ({
|
|
311
|
+
stagger: staggerOf(transition),
|
|
312
|
+
when: UndefinedOr.map(transition, (t) => t.when),
|
|
313
|
+
});
|
|
314
|
+
/** The stagger config of a transition's stagger keys, each defaulted. */
|
|
315
|
+
export const staggerWith = ({ staggerChildren = 0, delayChildren = 0, from = "first", staggerDirection = 1 }) => ({
|
|
316
|
+
amount: staggerChildren,
|
|
317
|
+
delayChildren,
|
|
318
|
+
from,
|
|
319
|
+
direction: staggerDirection,
|
|
320
|
+
});
|
|
321
|
+
/**
|
|
322
|
+
* Two stagger configs the same field by field: a memo of one holds while its orchestration changes to
|
|
323
|
+
* a transition with the same stagger (#460: a Variant child with no `press` variant, its parent
|
|
324
|
+
* pressed, made a new, equal config at each press and release, `UNSTABLE_MEMO_OUTPUT`).
|
|
325
|
+
*/
|
|
326
|
+
export const sameStagger = (a, b) => a.amount === b.amount && a.delayChildren === b.delayChildren && a.from === b.from && a.direction === b.direction;
|
|
327
|
+
/** What an element provides when it has no variants of its own: its parent's context, unless `inherit={false}`. */
|
|
328
|
+
export const passedThrough = (config, parent) => Bool.match(config.inherit === false, { onTrue: constUndefined, onFalse: () => parent });
|
|
329
|
+
/** A registration that does nothing: a server render has no orchestration to join. */
|
|
330
|
+
export const INERT_REGISTRATION = Object.freeze({
|
|
331
|
+
index: () => 0,
|
|
332
|
+
total: () => 1,
|
|
333
|
+
setSettled: () => { },
|
|
334
|
+
dispose: () => { },
|
|
335
|
+
});
|
|
336
|
+
/**
|
|
337
|
+
* A binding's variant node during a server render: the same names, read once, and orchestration
|
|
338
|
+
* that does nothing. No runtime, no signals.
|
|
339
|
+
*/
|
|
340
|
+
export const serverVariantNode = (config, parent) => {
|
|
341
|
+
const inherited = inheritedContext(config, parent);
|
|
342
|
+
const own = () => {
|
|
343
|
+
const variant = handedDown(config, () => nameOf(config.animate), () => UndefinedOr.map(parent, (p) => p.variant()));
|
|
344
|
+
const transition = ownOrInherited(config.transition, inherited);
|
|
345
|
+
const stagger = staggerOf(config.transition);
|
|
346
|
+
return {
|
|
347
|
+
variant: () => variant,
|
|
348
|
+
initial: handedDown(config, () => initialNameOf(config.initial), () => UndefinedOr.map(parent, (p) => p.initial)),
|
|
349
|
+
transition: () => transition,
|
|
350
|
+
register: () => INERT_REGISTRATION,
|
|
351
|
+
stagger: () => stagger,
|
|
352
|
+
when: () => UndefinedOr.map(config.transition, (t) => t.when),
|
|
353
|
+
childrenMayStart: constTrue,
|
|
354
|
+
allChildrenSettled: constTrue,
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
return {
|
|
358
|
+
provided: Bool.match(hasOwnVariants(config), { onTrue: own, onFalse: () => passedThrough(config, parent) }),
|
|
359
|
+
inherited,
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
//# sourceMappingURL=VariantTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VariantTree.js","sourceRoot":"","sources":["../../src/unstable/VariantTree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,kGAAkG;AAClG,oDAAoD;AACpD,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAExC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAG3D,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAsEnD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAgC,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AAKjH,kEAAkE;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAiB,EAAE,CAAA;AAEhD,sGAAsG;AACtG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAe,EAAE,CAAe,EAAW,EAAE,CAC5E,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC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AAO,EAAE,CAAC,CAAC,CAAA;QACnH,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;QAC/D,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QAC5C,OAAO;YACL,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO;YACtB,OAAO,EAAE,UAAU,CAAqC,MAAM,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACrJ,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU;YAC5B,QAAQ,EAAE,GAAG,EAAE,CAAC,kBAAkB;YAClC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO;YACtB,IAAI,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;YAC7D,gBAAgB,EAAE,SAAS;YAC3B,kBAAkB,EAAE,SAAS;SAC9B,CAAA;IACH,CAAC,CAAA;IACD,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;QAC3G,SAAS;KACV,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a `WardicConfig` gives the Wardic elements below it (#434, Motion's `MotionConfig`), on
|
|
3
|
+
* every binding: its **Config transition**, its reduced motion and whether its
|
|
4
|
+
* animations are skipped (#468).
|
|
5
|
+
*
|
|
6
|
+
* - **The Config transition is an element's own when it gives none,** as Motion's
|
|
7
|
+
* `{ ...config, ...props }`: whatever reads the element's `transition` reads it, a Variant child's in
|
|
8
|
+
* place of its parent's (Q3).
|
|
9
|
+
* - **Its reduced motion** (ADR-0029) is the element's, over the `WardicProvider`'s (Q2), as Motion
|
|
10
|
+
* reads its `MotionConfig`'s per element.
|
|
11
|
+
* - **`skipAnimations`** (#468) makes every animation of the elements below a **Skipped animation**,
|
|
12
|
+
* Motion's `MotionConfig` `skipAnimations`, whatever their reduced motion.
|
|
13
|
+
* - **`isValidProp`** (#443) keeps the props it says aren't valid from being passed on, Motion's
|
|
14
|
+
* `MotionConfig` `isValidProp`.
|
|
15
|
+
* - **`transformPagePoint`** (#443) maps the points a drag or a pan below it uses, Motion's
|
|
16
|
+
* `MotionConfig` `transformPagePoint`.
|
|
17
|
+
* - **A `WardicConfig` inside another** replaces its transition, or with `inherit: true` lays its own
|
|
18
|
+
* fields over it (Motion's `resolveTransition`); one that gives none passes its parent's on, as one
|
|
19
|
+
* that gives no reduced motion, `skipAnimations`, `isValidProp` or `transformPagePoint` passes its parent's.
|
|
20
|
+
*
|
|
21
|
+
* Unstable, for Wardic's own packages: public, with no semver promise.
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
import type * as ReducedMotion from "../ReducedMotion.ts";
|
|
26
|
+
import * as Option from "effect/Option";
|
|
27
|
+
import type * as Config from "./Config.ts";
|
|
28
|
+
/** What a `WardicConfig` gives below it (#434): one value per config, read where a binding reads it. */
|
|
29
|
+
export interface WardicConfigValue {
|
|
30
|
+
/** Its **Config transition**: read when an element's transition is, so a change starts nothing by itself. */
|
|
31
|
+
readonly transition: () => Config.WardicTransition | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Its reduced motion (ADR-0029): its own, else an enclosing config's, else `undefined` for the
|
|
34
|
+
* `WardicProvider`'s. Read when each animation starts.
|
|
35
|
+
*/
|
|
36
|
+
readonly reducedMotion: () => ReducedMotion.Config | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Whether its animations are skipped (#468): its own, else an enclosing config's, else `undefined`,
|
|
39
|
+
* as `false`. Read when each animation starts.
|
|
40
|
+
*/
|
|
41
|
+
readonly skipAnimations: () => boolean | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Which of an element's own props it passes on (#443, Motion's `MotionConfig` `isValidProp`): its
|
|
44
|
+
* own, else an enclosing config's, else `undefined`, every one. Read as each element is made.
|
|
45
|
+
*/
|
|
46
|
+
readonly isValidProp: () => ((key: string) => boolean) | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Where a drag's or a pan's points are (#443, Motion's `MotionConfig` `transformPagePoint`): its
|
|
49
|
+
* own, else an enclosing config's, else `undefined`, as they are. Read at each drag or pan start.
|
|
50
|
+
*/
|
|
51
|
+
readonly transformPagePoint: () => Config.WardicTransformPoint | undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A `WardicConfig`'s transition (#434): its own, laid over its parent's with `inherit: true` (as a
|
|
55
|
+
* variant's own is over the element's), else its parent's when it gives none.
|
|
56
|
+
*/
|
|
57
|
+
export declare const configTransitionOf: (own: Config.WardicVariantTransition | undefined, parent: WardicConfigValue | undefined) => Config.WardicTransition | undefined;
|
|
58
|
+
/** A `WardicConfig`'s reduced motion (#434): its own, else its parent's, else none (the provider's). */
|
|
59
|
+
export declare const configReducedMotionOf: (own: ReducedMotion.Config | undefined, parent: WardicConfigValue | undefined) => ReducedMotion.Config | undefined;
|
|
60
|
+
/** A `WardicConfig`'s `skipAnimations` (#468): its own, else its parent's, else none. */
|
|
61
|
+
export declare const configSkipAnimationsOf: (own: boolean | undefined, parent: WardicConfigValue | undefined) => boolean | undefined;
|
|
62
|
+
/** A `WardicConfig`'s `isValidProp` (#443): its own, else its parent's, else none. */
|
|
63
|
+
export declare const configIsValidPropOf: (own: ((key: string) => boolean) | undefined, parent: WardicConfigValue | undefined) => ((key: string) => boolean) | undefined;
|
|
64
|
+
/** A `WardicConfig`'s `transformPagePoint` (#443): its own, else its parent's, else none. */
|
|
65
|
+
export declare const configTransformPagePointOf: (own: Config.WardicTransformPoint | undefined, parent: WardicConfigValue | undefined) => Config.WardicTransformPoint | undefined;
|
|
66
|
+
/** The nearest config's `transformPagePoint` (#443), read at each drag or pan start: `undefined` for none. */
|
|
67
|
+
export declare const transformPagePointOf: (config: WardicConfigValue | undefined) => (() => Config.WardicTransformPoint | undefined);
|
|
68
|
+
/**
|
|
69
|
+
* A `transformPagePoint` as core's gestures take it (#618, A1): an `Option`, the same `Some` while the
|
|
70
|
+
* mapping is the same, so a gesture's down allocates nothing.
|
|
71
|
+
*/
|
|
72
|
+
export declare const pointMapOptionOf: (read: () => Config.WardicTransformPoint | undefined) => (() => Option.Option<Config.WardicTransformPoint>);
|
|
73
|
+
/** The nearest config's `isValidProp` (#443), as an element is made: `undefined` for none. */
|
|
74
|
+
export declare const isValidPropOf: (config: WardicConfigValue | undefined) => ((key: string) => boolean) | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Whether an element's animations are skipped (#468), read when each starts: its nearest config's
|
|
77
|
+
* `skipAnimations`. With no config above, never, and nothing made.
|
|
78
|
+
*/
|
|
79
|
+
export declare const skipAnimationsOf: (config: WardicConfigValue | undefined) => (() => boolean);
|
|
80
|
+
/** The reduced motion an element's nearest config sets (#434), now: `undefined` for none, the provider's. */
|
|
81
|
+
export declare const settingOf: (config: WardicConfigValue | undefined) => ReducedMotion.Config | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* `c` with its **Config transition** as its own when it gives none (#434, Motion's spread): `c` as it
|
|
84
|
+
* is when it has its own or the config gives none.
|
|
85
|
+
*/
|
|
86
|
+
export declare const withConfigTransition: <C extends {
|
|
87
|
+
readonly transition?: Config.WardicTransition | undefined;
|
|
88
|
+
}>(c: C, config: WardicConfigValue | undefined) => C;
|
|
89
|
+
//# sourceMappingURL=WardicConfigValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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
|
|
2
|
+
import * as Option from "effect/Option";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
4
|
+
import * as VariantTarget from "./VariantTarget.js";
|
|
5
|
+
/**
|
|
6
|
+
* A `WardicConfig`'s transition (#434): its own, laid over its parent's with `inherit: true` (as a
|
|
7
|
+
* variant's own is over the element's), else its parent's when it gives none.
|
|
8
|
+
*/
|
|
9
|
+
export const configTransitionOf = (own, parent) => VariantTarget.transitionOfTarget(own, parentTransitionOf(parent));
|
|
10
|
+
const parentTransitionOf = (parent) => {
|
|
11
|
+
if (Predicate.isUndefined(parent))
|
|
12
|
+
return undefined;
|
|
13
|
+
return parent.transition();
|
|
14
|
+
};
|
|
15
|
+
/** A `WardicConfig`'s reduced motion (#434): its own, else its parent's, else none (the provider's). */
|
|
16
|
+
export const configReducedMotionOf = (own, parent) => {
|
|
17
|
+
if (Predicate.isNotUndefined(own))
|
|
18
|
+
return own;
|
|
19
|
+
if (Predicate.isUndefined(parent))
|
|
20
|
+
return undefined;
|
|
21
|
+
return parent.reducedMotion();
|
|
22
|
+
};
|
|
23
|
+
/** A `WardicConfig`'s `skipAnimations` (#468): its own, else its parent's, else none. */
|
|
24
|
+
export const configSkipAnimationsOf = (own, parent) => {
|
|
25
|
+
if (Predicate.isNotUndefined(own))
|
|
26
|
+
return own;
|
|
27
|
+
if (Predicate.isUndefined(parent))
|
|
28
|
+
return undefined;
|
|
29
|
+
return parent.skipAnimations();
|
|
30
|
+
};
|
|
31
|
+
/** A `WardicConfig`'s `isValidProp` (#443): its own, else its parent's, else none. */
|
|
32
|
+
export const configIsValidPropOf = (own, parent) => {
|
|
33
|
+
if (Predicate.isNotUndefined(own))
|
|
34
|
+
return own;
|
|
35
|
+
if (Predicate.isUndefined(parent))
|
|
36
|
+
return undefined;
|
|
37
|
+
return parent.isValidProp();
|
|
38
|
+
};
|
|
39
|
+
/** A `WardicConfig`'s `transformPagePoint` (#443): its own, else its parent's, else none. */
|
|
40
|
+
export const configTransformPagePointOf = (own, parent) => {
|
|
41
|
+
if (Predicate.isNotUndefined(own))
|
|
42
|
+
return own;
|
|
43
|
+
if (Predicate.isUndefined(parent))
|
|
44
|
+
return undefined;
|
|
45
|
+
return parent.transformPagePoint();
|
|
46
|
+
};
|
|
47
|
+
/** The nearest config's `transformPagePoint` (#443), read at each drag or pan start: `undefined` for none. */
|
|
48
|
+
export const transformPagePointOf = (config) => {
|
|
49
|
+
if (Predicate.isUndefined(config))
|
|
50
|
+
return constUndefined;
|
|
51
|
+
return () => config.transformPagePoint();
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A `transformPagePoint` as core's gestures take it (#618, A1): an `Option`, the same `Some` while the
|
|
55
|
+
* mapping is the same, so a gesture's down allocates nothing.
|
|
56
|
+
*/
|
|
57
|
+
export const pointMapOptionOf = (read) => {
|
|
58
|
+
let last = Option.none();
|
|
59
|
+
return () => {
|
|
60
|
+
const now = read();
|
|
61
|
+
if (Predicate.isUndefined(now))
|
|
62
|
+
return Option.none();
|
|
63
|
+
if (Option.isSome(last)) {
|
|
64
|
+
if (last.value === now)
|
|
65
|
+
return last;
|
|
66
|
+
}
|
|
67
|
+
last = Option.some(now);
|
|
68
|
+
return last;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/** The nearest config's `isValidProp` (#443), as an element is made: `undefined` for none. */
|
|
72
|
+
export const isValidPropOf = (config) => {
|
|
73
|
+
if (Predicate.isUndefined(config))
|
|
74
|
+
return undefined;
|
|
75
|
+
return config.isValidProp();
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Whether an element's animations are skipped (#468), read when each starts: its nearest config's
|
|
79
|
+
* `skipAnimations`. With no config above, never, and nothing made.
|
|
80
|
+
*/
|
|
81
|
+
export const skipAnimationsOf = (config) => {
|
|
82
|
+
if (Predicate.isUndefined(config))
|
|
83
|
+
return constFalse;
|
|
84
|
+
return () => config.skipAnimations() === true;
|
|
85
|
+
};
|
|
86
|
+
/** The reduced motion an element's nearest config sets (#434), now: `undefined` for none, the provider's. */
|
|
87
|
+
export const settingOf = (config) => {
|
|
88
|
+
if (Predicate.isUndefined(config))
|
|
89
|
+
return undefined;
|
|
90
|
+
return config.reducedMotion();
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* `c` with its **Config transition** as its own when it gives none (#434, Motion's spread): `c` as it
|
|
94
|
+
* is when it has its own or the config gives none.
|
|
95
|
+
*/
|
|
96
|
+
export const withConfigTransition = (c, config) => {
|
|
97
|
+
if (Predicate.isNotUndefined(c.transition))
|
|
98
|
+
return c;
|
|
99
|
+
if (Predicate.isUndefined(config))
|
|
100
|
+
return c;
|
|
101
|
+
const transition = config.transition();
|
|
102
|
+
if (Predicate.isUndefined(transition))
|
|
103
|
+
return c;
|
|
104
|
+
return { ...c, transition };
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=WardicConfigValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WardicConfigValue.js","sourceRoot":"","sources":["../../src/unstable/WardicConfigValue.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAE7C,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AA4BnD;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAA+C,EAAE,MAAqC,EAAuC,EAAE,CAChK,aAAa,CAAC,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAA;AAEnE,MAAM,kBAAkB,GAAG,CAAC,MAAqC,EAAuC,EAAE;IACxG,IAAI,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IACnD,OAAO,MAAM,CAAC,UAAU,EAAE,CAAA;AAC5B,CAAC,CAAA;AA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,SAAS,GAAG,CAAC,MAAqC,EAAoC,EAAE;IACnG,IAAI,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IACnD,OAAO,MAAM,CAAC,aAAa,EAAE,CAAA;AAC/B,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAA0E,CAAI,EAAE,MAAqC,EAAK,EAAE;IAC9J,IAAI,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC;QAAE,OAAO,CAAC,CAAA;IACpD,IAAI,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,CAAA;IAC3C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE,CAAA;IACtC,IAAI,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC;QAAE,OAAO,CAAC,CAAA;IAC/C,OAAO,EAAE,GAAG,CAAC,EAAE,UAAU,EAAE,CAAA;AAC7B,CAAC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import type * as Exit from "effect/Exit";
|
|
3
|
+
import * as Fiber from "effect/Fiber";
|
|
4
|
+
import type * as Layer from "effect/Layer";
|
|
5
|
+
import type * as AtomRegistry from "effect/reactivity/AtomRegistry";
|
|
6
|
+
import * as Scope from "effect/Scope";
|
|
7
|
+
import type * as Announcer from "../Announcer.ts";
|
|
8
|
+
import type * as Clock from "../Clock.ts";
|
|
9
|
+
import type * as DefaultTransition from "../DefaultTransition.ts";
|
|
10
|
+
import type * as FrameLoop from "../FrameLoop.ts";
|
|
11
|
+
import type * as InterpolatorRegistry from "../InterpolatorRegistry.ts";
|
|
12
|
+
import type * as Probe from "../Probe.ts";
|
|
13
|
+
import type * as ReducedMotion from "../ReducedMotion.ts";
|
|
14
|
+
import type * as RefreshFrameSource from "../RefreshFrameSource.ts";
|
|
15
|
+
import type * as Renderer from "../Renderer.ts";
|
|
16
|
+
/**
|
|
17
|
+
* The services an Environment gives: what the provider's `env` must provide, and what a binding's
|
|
18
|
+
* Effects run with.
|
|
19
|
+
*/
|
|
20
|
+
export type WardicServices = Clock.Clock | RefreshFrameSource.RefreshFrameSource | FrameLoop.FrameLoop | Renderer.Renderer | Probe.Probe | InterpolatorRegistry.InterpolatorRegistry | ReducedMotion.PositionalKeys | DefaultTransition.DefaultTransition | Announcer.Announcer | AtomRegistry.AtomRegistry;
|
|
21
|
+
/** The Layer an app hands its provider: an Environment, giving every one of {@link WardicServices}. */
|
|
22
|
+
export type WardicEnv = Layer.Layer<WardicServices, never, never>;
|
|
23
|
+
/** Runs Effects synchronously, and forked into the Scope it was made in. */
|
|
24
|
+
export interface Runner<R> {
|
|
25
|
+
readonly runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
|
|
26
|
+
readonly runFork: <A, E>(effect: Effect.Effect<A, E, R>) => Fiber.Fiber<A, E>;
|
|
27
|
+
/**
|
|
28
|
+
* Run `effect` now, synchronously, to its Exit: its failure, a defect, or an effect that suspends is
|
|
29
|
+
* in the Exit, never thrown. What a binding closes an owner's Scope with (`OwnerScope.close`).
|
|
30
|
+
*/
|
|
31
|
+
readonly runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, E>;
|
|
32
|
+
/**
|
|
33
|
+
* The Scope it was made in: what a service built with it keeps its own fibers in, so closing the
|
|
34
|
+
* Scope ends them, after the service's own cleanup, and awaits them.
|
|
35
|
+
*/
|
|
36
|
+
readonly scope: Scope.Scope;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A runner over the current context, without a sync scheduler, holding its forks in a set of its own
|
|
40
|
+
* until the current Scope closes and interrupts them (#746: what a `FiberSet` held, so an app ships no
|
|
41
|
+
* FiberSet); a fork after that is interrupted at once. It forks with that context itself (`Effect.runForkWith`), not through
|
|
42
|
+
* `FiberSet.runtime`, which reads the context again in the current fiber, where the building call's
|
|
43
|
+
* scheduler still is: `Effect.provideContext` merges into a fiber's context, it doesn't replace it.
|
|
44
|
+
*/
|
|
45
|
+
export declare const makeRunner: <R>() => Effect.Effect<Runner<R>, never, R | Scope.Scope>;
|
|
46
|
+
//# sourceMappingURL=WardicServices.d.ts.map
|