@wardic/core 1.4.0 → 1.5.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/dist/DragRecognizer.d.ts +3 -2
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +14 -2
- package/dist/DragRecognizer.js.map +1 -1
- package/dist/InputSource.d.ts +6 -0
- package/dist/InputSource.d.ts.map +1 -1
- package/dist/InputSource.js.map +1 -1
- package/dist/Projection.d.ts +1 -12
- package/dist/Projection.d.ts.map +1 -1
- package/dist/Projection.js +3 -19
- package/dist/Projection.js.map +1 -1
- package/dist/Recognizer.d.ts.map +1 -1
- package/dist/Recognizer.js +16 -1
- package/dist/Recognizer.js.map +1 -1
- package/dist/Reorder.d.ts +11 -1
- package/dist/Reorder.d.ts.map +1 -1
- package/dist/Reorder.js +63 -36
- package/dist/Reorder.js.map +1 -1
- package/dist/internal/projectionRest.d.ts +22 -0
- package/dist/internal/projectionRest.d.ts.map +1 -0
- package/dist/internal/projectionRest.js +20 -0
- package/dist/internal/projectionRest.js.map +1 -0
- package/dist/unstable/PresenceRecord.d.ts +5 -1
- package/dist/unstable/PresenceRecord.d.ts.map +1 -1
- package/dist/unstable/PresenceRecord.js.map +1 -1
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +19 -14
- package/dist/unstable/Spine.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +8 -1
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +2 -2
- package/dist/unstable/VariantTree.js.map +1 -1
- package/package.json +1 -1
- package/src/DragRecognizer.ts +24 -7
- package/src/InputSource.ts +7 -0
- package/src/Projection.ts +3 -21
- package/src/Recognizer.ts +17 -1
- package/src/Reorder.ts +81 -36
- package/src/internal/projectionRest.ts +31 -0
- package/src/unstable/PresenceRecord.ts +5 -1
- package/src/unstable/Spine.ts +20 -13
- package/src/unstable/VariantTree.ts +9 -2
package/src/unstable/Spine.ts
CHANGED
|
@@ -1529,6 +1529,9 @@ export const resolutionOf = (
|
|
|
1529
1529
|
): Resolution => {
|
|
1530
1530
|
// The Controls change in effect (#433): its own controls', else its provider's, read here so a new one Retargets.
|
|
1531
1531
|
const change = changeIn(own, parent)
|
|
1532
|
+
// Each key read once (#460, compose once): a binding's config can be a view that works a key out at
|
|
1533
|
+
// each read, a key several of a ward's parts give merged at each (probe: hooks-first), and this
|
|
1534
|
+
// read `animate` up to four times, and `custom` once for the base and once for each gesture.
|
|
1532
1535
|
const variants = c.variants
|
|
1533
1536
|
// Base target resolution priority (ADR-0007):
|
|
1534
1537
|
// (1) local `animate` (a Values map or a variant name) — overrides any
|
|
@@ -1539,18 +1542,21 @@ export const resolutionOf = (
|
|
|
1539
1542
|
// recomputes the memo and retargets;
|
|
1540
1543
|
// (3) else the SSR-seeded `initial`.
|
|
1541
1544
|
// Per Retarget, per Subject (#460, compose once): statements.
|
|
1542
|
-
const
|
|
1545
|
+
const animate = c.animate
|
|
1546
|
+
const variant = variantOf(animate, parent)
|
|
1547
|
+
// Read after `animate`, as it was: a key still loading throws at the first of them read.
|
|
1548
|
+
const custom = c.custom
|
|
1543
1549
|
// A list of names (#297, Motion's `VariantLabels`): a base entry a name, in order, so the last name
|
|
1544
1550
|
// that sets a key drives it. A single name or a values map takes the path below, as before.
|
|
1545
|
-
if (Arr.isArray(
|
|
1546
|
-
const targets = VariantTarget.resolveTargets(variant as ReadonlyArray<string>, variants,
|
|
1551
|
+
if (Arr.isArray(animate) || (Predicate.isUndefined(animate) && Arr.isArray(variant))) {
|
|
1552
|
+
const targets = VariantTarget.resolveTargets(variant as ReadonlyArray<string>, variants, custom, state)
|
|
1547
1553
|
const merged = VariantTarget.mergedOf(targets)
|
|
1548
1554
|
const listLayers: Array<OverrideEntry> = Arr.map(targets, namedLayerOf)
|
|
1549
|
-
return withGestures(c, parent, listLayers, merged.values, variant, active, merged.transition, state, change)
|
|
1555
|
+
return withGestures(c, variants, custom, parent, listLayers, merged.values, variant, active, merged.transition, state, change)
|
|
1550
1556
|
}
|
|
1551
1557
|
// A dynamic variant resolves with this Subject's own `custom` (#277), as Motion's each child's.
|
|
1552
1558
|
// Animation controls never reach here: its binding reads them once, each change its entry (#433).
|
|
1553
|
-
const target = baseTargetOf(
|
|
1559
|
+
const target = baseTargetOf(animate as VariantTarget.Entry | undefined, variant, variants, custom, state, initialLink)
|
|
1554
1560
|
const base = target.values
|
|
1555
1561
|
const baseLayer: OverrideEntry = layerOf(target, variant as string | undefined)
|
|
1556
1562
|
// A Variant child's gestures are on while its provider's are (#291, Motion's `setActive`), each on
|
|
@@ -1562,7 +1568,7 @@ export const resolutionOf = (
|
|
|
1562
1568
|
const { resolved, ends, keyframes } = resolvedOf(alone)
|
|
1563
1569
|
return { resolved, base, dragging: active.dragging, variant, active, transition: target.transition, layers: alone, names: VariantTree.NO_GESTURE_NAMES, layersOn: VariantTree.NO_GESTURE_STATES, ends, keyframes, change }
|
|
1564
1570
|
}
|
|
1565
|
-
return withGestures(c, parent, [baseLayer], base, variant, active, target.transition, state, change)
|
|
1571
|
+
return withGestures(c, variants, custom, parent, [baseLayer], base, variant, active, target.transition, state, change)
|
|
1566
1572
|
}
|
|
1567
1573
|
|
|
1568
1574
|
/** The **Controls change** in effect for a Subject (#433): its own, else its provider's; per Retarget, a guard. */
|
|
@@ -1592,10 +1598,12 @@ const overriddenOf = (resolution: Resolution, override: Config.WardicTransition)
|
|
|
1592
1598
|
/**
|
|
1593
1599
|
* A resolution from its base entries (one, or one a name of a list, #297) and its gesture layers on
|
|
1594
1600
|
* top (#291), each gesture's an entry a name too: the Override stack resolved, and the names its
|
|
1595
|
-
* active gestures resolved.
|
|
1601
|
+
* active gestures resolved. `variants` and `custom` are `c`'s, read once by the caller.
|
|
1596
1602
|
*/
|
|
1597
1603
|
const withGestures = (
|
|
1598
1604
|
c: Config.SpineConfig,
|
|
1605
|
+
variants: Config.SpineConfig["variants"],
|
|
1606
|
+
custom: Config.SpineConfig["custom"],
|
|
1599
1607
|
parent: VariantTree.WardicVariantContextValue | undefined,
|
|
1600
1608
|
layers: Array<OverrideEntry>,
|
|
1601
1609
|
base: Values.Values,
|
|
@@ -1605,7 +1613,6 @@ const withGestures = (
|
|
|
1605
1613
|
state: VariantTarget.VariantState,
|
|
1606
1614
|
change: AnimationControls.ControlsChange | undefined,
|
|
1607
1615
|
): Resolution => {
|
|
1608
|
-
const variants = c.variants
|
|
1609
1616
|
const above = VariantTree.handDownFrom(parent)
|
|
1610
1617
|
if (Bool.and(above === VariantTree.NO_HAND_DOWN, Bool.not(anyOn(active)))) {
|
|
1611
1618
|
const { resolved, ends, keyframes } = resolvedOf(layers)
|
|
@@ -1615,14 +1622,14 @@ const withGestures = (
|
|
|
1615
1622
|
const labels = above.names
|
|
1616
1623
|
// In Motion's priority, lowest first: a literal's fields are evaluated in order.
|
|
1617
1624
|
const layersOn: VariantTree.GestureStates = {
|
|
1618
|
-
inView: gestureLayersInto(layers, c.whileInView, on.inView, labels.inView, variants,
|
|
1619
|
-
focused: gestureLayersInto(layers, c.whileFocus, on.focused, labels.focused, variants,
|
|
1620
|
-
hovered: gestureLayersInto(layers, c.whileHover, on.hovered, labels.hovered, variants,
|
|
1621
|
-
pressed: gestureLayersInto(layers, c.whileTap, on.pressed, labels.pressed, variants,
|
|
1625
|
+
inView: gestureLayersInto(layers, c.whileInView, on.inView, labels.inView, variants, custom, state),
|
|
1626
|
+
focused: gestureLayersInto(layers, c.whileFocus, on.focused, labels.focused, variants, custom, state),
|
|
1627
|
+
hovered: gestureLayersInto(layers, c.whileHover, on.hovered, labels.hovered, variants, custom, state),
|
|
1628
|
+
pressed: gestureLayersInto(layers, c.whileTap, on.pressed, labels.pressed, variants, custom, state),
|
|
1622
1629
|
// whileDrag sits ABOVE tap (highest priority) — driven by the spring,
|
|
1623
1630
|
// NOT stripped, so e.g. `scale: 1.1` animates while held and returns
|
|
1624
1631
|
// after release.
|
|
1625
|
-
dragged: gestureLayersInto(layers, c.whileDrag, on.dragged, labels.dragged, variants,
|
|
1632
|
+
dragged: gestureLayersInto(layers, c.whileDrag, on.dragged, labels.dragged, variants, custom, state),
|
|
1626
1633
|
}
|
|
1627
1634
|
const { resolved, ends, keyframes } = resolvedOf(layers)
|
|
1628
1635
|
const names = activeNamesFor(c, on, labels)
|
|
@@ -361,6 +361,13 @@ export interface VariantConfig extends GestureConfig {
|
|
|
361
361
|
* entry is, as Motion's `isControllingVariants`, so it hands down the names its controls set.
|
|
362
362
|
*/
|
|
363
363
|
readonly controlled?: boolean | undefined
|
|
364
|
+
/**
|
|
365
|
+
* Whether it's a **Variant child** by its own word (probe: hooks-first, the gap grill's Q26): one
|
|
366
|
+
* that names gesture variants of its own is one all the same, joining its nearest ancestor with
|
|
367
|
+
* variants and handing its own gesture names down with the ones it takes. Left out, Motion's rule
|
|
368
|
+
* alone decides, as today.
|
|
369
|
+
*/
|
|
370
|
+
readonly variantChild?: boolean | undefined
|
|
364
371
|
}
|
|
365
372
|
|
|
366
373
|
/** An `initial` a Subject hands its children: a variant name or list (#297), `false` (#134), or `undefined` for a values map or nothing. */
|
|
@@ -417,9 +424,9 @@ export const controlsChangeOf = (
|
|
|
417
424
|
return change
|
|
418
425
|
}
|
|
419
426
|
|
|
420
|
-
/** Whether a Subject is a **Variant child** (CONTEXT.md). */
|
|
427
|
+
/** Whether a Subject is a **Variant child** (CONTEXT.md): by Motion's rule, or by its own word ({@link VariantConfig.variantChild}). */
|
|
421
428
|
export const isVariantChild = (config: VariantConfig): boolean =>
|
|
422
|
-
Predicate.isNotUndefined(config.variants) && !namesOwnVariants(config) && config.inherit !== false
|
|
429
|
+
Predicate.isNotUndefined(config.variants) && (config.variantChild === true || !namesOwnVariants(config)) && config.inherit !== false
|
|
423
430
|
|
|
424
431
|
/** The context a Subject inherits names and its default transition from: its parent's, for a Variant child. */
|
|
425
432
|
export const inheritedContext = (
|