@wardic/foldkit 0.0.0-stage → 1.2.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/LICENSE +21 -0
- package/README.md +59 -2
- package/THIRD_PARTY_NOTICES.md +145 -0
- package/dist/AnimationControls.d.ts +37 -0
- package/dist/AnimationControls.d.ts.map +1 -0
- package/dist/AnimationControls.js +37 -0
- package/dist/AnimationControls.js.map +1 -0
- package/dist/AnimationScope.d.ts +20 -0
- package/dist/AnimationScope.d.ts.map +1 -0
- package/dist/AnimationScope.js +20 -0
- package/dist/AnimationScope.js.map +1 -0
- package/dist/DragControls.d.ts +25 -0
- package/dist/DragControls.d.ts.map +1 -0
- package/dist/DragControls.js +21 -0
- package/dist/DragControls.js.map +1 -0
- package/dist/Features.d.ts +36 -0
- package/dist/Features.d.ts.map +1 -0
- package/dist/Features.js +44 -0
- package/dist/Features.js.map +1 -0
- package/dist/Ward.d.ts +301 -0
- package/dist/Ward.d.ts.map +1 -0
- package/dist/Ward.js +6 -0
- package/dist/Ward.js.map +1 -0
- package/dist/Wardic.d.ts +363 -0
- package/dist/Wardic.d.ts.map +1 -0
- package/dist/Wardic.js +85 -0
- package/dist/Wardic.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/builder.d.ts +8 -0
- package/dist/internal/builder.d.ts.map +1 -0
- package/dist/internal/builder.js +242 -0
- package/dist/internal/builder.js.map +1 -0
- package/dist/internal/commands.d.ts +143 -0
- package/dist/internal/commands.d.ts.map +1 -0
- package/dist/internal/commands.js +242 -0
- package/dist/internal/commands.js.map +1 -0
- package/dist/internal/delivery.d.ts +44 -0
- package/dist/internal/delivery.d.ts.map +1 -0
- package/dist/internal/delivery.js +85 -0
- package/dist/internal/delivery.js.map +1 -0
- package/dist/internal/dev.d.ts +10 -0
- package/dist/internal/dev.d.ts.map +1 -0
- package/dist/internal/dev.js +10 -0
- package/dist/internal/dev.js.map +1 -0
- package/dist/internal/dev.production.d.ts +8 -0
- package/dist/internal/dev.production.d.ts.map +1 -0
- package/dist/internal/dev.production.js +8 -0
- package/dist/internal/dev.production.js.map +1 -0
- package/dist/internal/drag.d.ts +66 -0
- package/dist/internal/drag.d.ts.map +1 -0
- package/dist/internal/drag.js +71 -0
- package/dist/internal/drag.js.map +1 -0
- package/dist/internal/element.d.ts +59 -0
- package/dist/internal/element.d.ts.map +1 -0
- package/dist/internal/element.js +582 -0
- package/dist/internal/element.js.map +1 -0
- package/dist/internal/gestures.d.ts +62 -0
- package/dist/internal/gestures.d.ts.map +1 -0
- package/dist/internal/gestures.js +109 -0
- package/dist/internal/gestures.js.map +1 -0
- package/dist/internal/hydrate.d.ts +5 -0
- package/dist/internal/hydrate.d.ts.map +1 -0
- package/dist/internal/hydrate.js +27 -0
- package/dist/internal/hydrate.js.map +1 -0
- package/dist/internal/keys.d.ts +21 -0
- package/dist/internal/keys.d.ts.map +1 -0
- package/dist/internal/keys.js +12 -0
- package/dist/internal/keys.js.map +1 -0
- package/dist/internal/layout.d.ts +29 -0
- package/dist/internal/layout.d.ts.map +1 -0
- package/dist/internal/layout.js +88 -0
- package/dist/internal/layout.js.map +1 -0
- package/dist/internal/mount.d.ts +22 -0
- package/dist/internal/mount.d.ts.map +1 -0
- package/dist/internal/mount.js +100 -0
- package/dist/internal/mount.js.map +1 -0
- package/dist/internal/presence.d.ts +33 -0
- package/dist/internal/presence.d.ts.map +1 -0
- package/dist/internal/presence.js +338 -0
- package/dist/internal/presence.js.map +1 -0
- package/dist/internal/reactivity.d.ts +15 -0
- package/dist/internal/reactivity.d.ts.map +1 -0
- package/dist/internal/reactivity.js +26 -0
- package/dist/internal/reactivity.js.map +1 -0
- package/dist/internal/reorder.d.ts +47 -0
- package/dist/internal/reorder.d.ts.map +1 -0
- package/dist/internal/reorder.js +250 -0
- package/dist/internal/reorder.js.map +1 -0
- package/dist/internal/scope.d.ts +28 -0
- package/dist/internal/scope.d.ts.map +1 -0
- package/dist/internal/scope.js +44 -0
- package/dist/internal/scope.js.map +1 -0
- package/dist/internal/server.d.ts +13 -0
- package/dist/internal/server.d.ts.map +1 -0
- package/dist/internal/server.js +13 -0
- package/dist/internal/server.js.map +1 -0
- package/dist/internal/server.node.d.ts +8 -0
- package/dist/internal/server.node.d.ts.map +1 -0
- package/dist/internal/server.node.js +8 -0
- package/dist/internal/server.node.js.map +1 -0
- package/dist/internal/services.d.ts +222 -0
- package/dist/internal/services.d.ts.map +1 -0
- package/dist/internal/services.js +338 -0
- package/dist/internal/services.js.map +1 -0
- package/dist/internal/tree.d.ts +71 -0
- package/dist/internal/tree.d.ts.map +1 -0
- package/dist/internal/tree.js +207 -0
- package/dist/internal/tree.js.map +1 -0
- package/dist/internal/variant-node.d.ts +62 -0
- package/dist/internal/variant-node.d.ts.map +1 -0
- package/dist/internal/variant-node.js +279 -0
- package/dist/internal/variant-node.js.map +1 -0
- package/dist/internal/view-transition.d.ts +10 -0
- package/dist/internal/view-transition.d.ts.map +1 -0
- package/dist/internal/view-transition.js +36 -0
- package/dist/internal/view-transition.js.map +1 -0
- package/dist/internal/walk.d.ts +26 -0
- package/dist/internal/walk.d.ts.map +1 -0
- package/dist/internal/walk.js +162 -0
- package/dist/internal/walk.js.map +1 -0
- package/package.json +99 -4
- package/src/AnimationControls.ts +46 -0
- package/src/AnimationScope.ts +19 -0
- package/src/DragControls.ts +27 -0
- package/src/Features.ts +45 -0
- package/src/Ward.ts +434 -0
- package/src/Wardic.ts +410 -0
- package/src/index.ts +20 -0
- package/src/internal/builder.ts +262 -0
- package/src/internal/commands.ts +359 -0
- package/src/internal/delivery.ts +116 -0
- package/src/internal/dev.production.ts +7 -0
- package/src/internal/dev.ts +9 -0
- package/src/internal/drag.ts +136 -0
- package/src/internal/element.ts +668 -0
- package/src/internal/gestures.ts +184 -0
- package/src/internal/hydrate.ts +29 -0
- package/src/internal/keys.ts +19 -0
- package/src/internal/layout.ts +109 -0
- package/src/internal/mount.ts +124 -0
- package/src/internal/presence.ts +362 -0
- package/src/internal/reactivity.ts +45 -0
- package/src/internal/reorder.ts +313 -0
- package/src/internal/scope.ts +60 -0
- package/src/internal/server.node.ts +7 -0
- package/src/internal/server.ts +12 -0
- package/src/internal/services.ts +486 -0
- package/src/internal/tree.ts +230 -0
- package/src/internal/variant-node.ts +352 -0
- package/src/internal/view-transition.ts +43 -0
- package/src/internal/walk.ts +211 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How Commands get Wardic's services (ADR-0071, decisions 9, 26 and 31; *Amendment (#791)*, PR 3): the
|
|
3
|
+
* seam that differs on Foldkit's preview. On 0.170, the `Wardic` service is the **Handle**, which
|
|
4
|
+
* `wardic.resources` gives a program's Commands, and the two Effects over it: `animate`, an
|
|
5
|
+
* **Imperative animation** of an element or a **Sequence**, under an **Animation scope** when given
|
|
6
|
+
* (#798), and `provide`, which runs an Effect on the Provider's services. Either builds the Provider when none is live, and counts itself in as a member while it
|
|
7
|
+
* runs, so the Provider doesn't close under it.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import * as LiveValue from "@wardic/core/LiveValue";
|
|
12
|
+
import * as ScrollSource from "@wardic/core/ScrollSource";
|
|
13
|
+
import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue";
|
|
14
|
+
import * as Imperative from "@wardic/dom/unstable/Imperative";
|
|
15
|
+
import * as DomPointer from "@wardic/dom/unstable/PointerValues";
|
|
16
|
+
import * as Arr from "effect/Array";
|
|
17
|
+
import * as Bool from "effect/Boolean";
|
|
18
|
+
import * as Context from "effect/Context";
|
|
19
|
+
import * as Data from "effect/Data";
|
|
20
|
+
import * as Effect from "effect/Effect";
|
|
21
|
+
import { constVoid } from "effect/Function";
|
|
22
|
+
import * as Layer from "effect/Layer";
|
|
23
|
+
import * as MutableRef from "effect/MutableRef";
|
|
24
|
+
import * as Option from "effect/Option";
|
|
25
|
+
import * as Predicate from "effect/Predicate";
|
|
26
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
27
|
+
import * as Render from "foldkit/render";
|
|
28
|
+
import { hintFrameUnless } from "./delivery.js";
|
|
29
|
+
import { layoutOf } from "./layout.js";
|
|
30
|
+
import { watchOf } from "./scope.js";
|
|
31
|
+
import { featureIn, joined, providerFor, reducedMotionUnder, stateOf } from "./services.js";
|
|
32
|
+
/** The mark of a Handle, as the `Wardic` service carries it: what its Effects reach the Handle's state through. */
|
|
33
|
+
export const HANDLE = Symbol.for("@wardic/foldkit/Handle");
|
|
34
|
+
/** The Wardic service: a program's **Handle**, which `wardic.resources` gives its Commands. */
|
|
35
|
+
export class Wardic extends Context.Service()("@wardic/foldkit/Wardic") {
|
|
36
|
+
}
|
|
37
|
+
/** The Layer a program's `resources` takes, giving its Commands the Handle (decision 9): read when built, so the Handle can hold it. */
|
|
38
|
+
export const resourcesOf = (handle) => Layer.sync(Wardic)(handle);
|
|
39
|
+
/** `animate` found nothing to animate: a selector matching no element under the root, or an empty list. */
|
|
40
|
+
export class AnimationFailed extends Data.TaggedError("AnimationFailed") {
|
|
41
|
+
}
|
|
42
|
+
/** `animateLayout` found no layout to animate: the Handle has no `layout` Feature (`Features.layout`). */
|
|
43
|
+
export class LayoutFailed extends Data.TaggedError("LayoutFailed") {
|
|
44
|
+
}
|
|
45
|
+
/** What a Command's Effect is a member of: the Handle's Provider, built when none is live, and the count out. */
|
|
46
|
+
const member = Effect.fnUntraced(function* () {
|
|
47
|
+
const handle = yield* Wardic;
|
|
48
|
+
const state = stateOf(handle);
|
|
49
|
+
const provider = yield* providerFor(state, undefined, undefined);
|
|
50
|
+
// A member while it runs: the Provider stays up until it ends.
|
|
51
|
+
return { state, provider, left: joined(state, provider, undefined) };
|
|
52
|
+
});
|
|
53
|
+
/** No options: a change animated from the last pass's boxes. */
|
|
54
|
+
const FROM_LAST_PASS = { from: "lastPass" };
|
|
55
|
+
/**
|
|
56
|
+
* A **Declared layout change** (ADR-0071, decision 26; ADR-0038; Motion's `animateLayout`): what a
|
|
57
|
+
* Command runs after the Model change that moved the layout elements, under either trigger, and the
|
|
58
|
+
* only trigger beside `w.LayoutDependency` under `layoutTrigger: "declared"`. It waits for the
|
|
59
|
+
* render's commit (Foldkit's `Render.afterCommit`), then asks for a Measure pass from the boxes the
|
|
60
|
+
* last pass kept (`from: "lastPass"`, the default: the change is on the page by then), and succeeds
|
|
61
|
+
* once every layout animation the pass started has ended, at once if none. Fails with
|
|
62
|
+
* {@link LayoutFailed} when the Handle has no `layout` Feature. Wrap it in `Command.define`, with
|
|
63
|
+
* `resources: wardic.resources` on the program.
|
|
64
|
+
*/
|
|
65
|
+
export const animateLayout = Effect.fnUntraced(function* (options) {
|
|
66
|
+
const { state, provider, left } = yield* member();
|
|
67
|
+
const layout = layoutOf(provider, state);
|
|
68
|
+
if (Predicate.isUndefined(layout)) {
|
|
69
|
+
left();
|
|
70
|
+
return yield* Effect.fail(new LayoutFailed({ reason: "no-layout-feature" }));
|
|
71
|
+
}
|
|
72
|
+
yield* Render.afterCommit;
|
|
73
|
+
return yield* settling(state, provider, layout, left, { ...FROM_LAST_PASS, ...options });
|
|
74
|
+
});
|
|
75
|
+
/** The change's pass, and its settling as the Effect's success; its interruption leaves the member. */
|
|
76
|
+
const settling = (state, provider, layout, left, options) => Effect.callback((resume) => {
|
|
77
|
+
const run = () => {
|
|
78
|
+
layout.projection.animateLayout(constVoid, {
|
|
79
|
+
...options,
|
|
80
|
+
onSettled: () => {
|
|
81
|
+
left();
|
|
82
|
+
resume(Effect.void);
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
// A View Transition's render (decision 33): the change lands as an Instant change of the layout, settled at once.
|
|
87
|
+
if (state.transitioning) {
|
|
88
|
+
state.transitioning = false;
|
|
89
|
+
layout.projection.instant(run);
|
|
90
|
+
return Effect.sync(left);
|
|
91
|
+
}
|
|
92
|
+
// The pass's first step paints in this frame (decision 32): the Command resumed inside it, after the commit.
|
|
93
|
+
hintFrameUnless(provider.loop, provider.paused);
|
|
94
|
+
run();
|
|
95
|
+
return Effect.sync(left);
|
|
96
|
+
});
|
|
97
|
+
/** How many elements `subject` names, under `root`: a selector's matches, an element, or a list's members. */
|
|
98
|
+
const countOf = (subject, root) => {
|
|
99
|
+
if (Predicate.isNullish(subject))
|
|
100
|
+
return 0;
|
|
101
|
+
if (Predicate.isString(subject))
|
|
102
|
+
return UndefinedOr.match(root, { onUndefined: () => document, onDefined: (el) => el }).querySelectorAll(subject).length;
|
|
103
|
+
if (Predicate.hasProperty(subject, "nodeType"))
|
|
104
|
+
return 1;
|
|
105
|
+
if (Predicate.isIterable(subject))
|
|
106
|
+
return Arr.fromIterable(subject).length;
|
|
107
|
+
return subject.length;
|
|
108
|
+
};
|
|
109
|
+
/** `subject` as an error names it. */
|
|
110
|
+
const nameOf = (subject) => {
|
|
111
|
+
if (Predicate.isString(subject))
|
|
112
|
+
return subject;
|
|
113
|
+
if (Predicate.isNullish(subject))
|
|
114
|
+
return String(subject);
|
|
115
|
+
return "an element list";
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* What a Command's animations run on: the Provider's services, as a Solid animation scope's, under the
|
|
119
|
+
* Handle's `config` (decision 22): its `reducedMotion` and `skipAnimations`, read as each animation starts.
|
|
120
|
+
*/
|
|
121
|
+
const envOf = (state, provider) => ({
|
|
122
|
+
runtime: provider.runtime,
|
|
123
|
+
gate: provider.gate,
|
|
124
|
+
reducedMotion: reducedMotionUnder(provider, state.rootConfig),
|
|
125
|
+
skipAnimations: WardicConfigValue.skipAnimationsOf(state.rootConfig),
|
|
126
|
+
positionalKeys: provider.positionalKeys,
|
|
127
|
+
defaultTransition: provider.defaultTransition,
|
|
128
|
+
ownValues: provider.valueReads.ownValues,
|
|
129
|
+
measuredPairs: provider.valueReads.measuredPairs,
|
|
130
|
+
variableValues: provider.valueReads.variableValues,
|
|
131
|
+
});
|
|
132
|
+
/** `AnimationFailed`'s subject for a sequence none of whose Segments found anything (#798, Q15). */
|
|
133
|
+
const SEQUENCE = "a sequence";
|
|
134
|
+
/** The scope `options` name, or none. */
|
|
135
|
+
const scopeIn = (options) => UndefinedOr.map(options, (given) => given.scope);
|
|
136
|
+
/** `options` as dom takes them: the scope, the binding's own, left out. Typed loosely, since dom's option types are unions `Omit` spreads past what TypeScript represents. */
|
|
137
|
+
const withoutScope = (options) => {
|
|
138
|
+
const { scope: _scope, ...rest } = options;
|
|
139
|
+
return rest;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Where a Command's selectors resolve (#798, Q8): under the scope's element; with no scope, under the
|
|
143
|
+
* `w.Provider()` element, else the document (`undefined`); none for a scope whose element isn't
|
|
144
|
+
* mounted, which finds nothing before any element is looked at.
|
|
145
|
+
*/
|
|
146
|
+
const insideOf = (provider, scope) => UndefinedOr.match(scope, { onUndefined: () => Option.some(provider.root), onDefined: (given) => Option.fromUndefinedOr(given.element()) });
|
|
147
|
+
/** `animate` (above): the form told by what it's given, as dom's own `animate` tells it. */
|
|
148
|
+
export const animate = ((first, second, third) => {
|
|
149
|
+
if (Imperative.isSequence(first)) {
|
|
150
|
+
const options = second;
|
|
151
|
+
return commanded(scopeIn(options), (under) => Arr.some(first, (segment) => Imperative.segmentAnimates(segment, under)), SEQUENCE, (run) => run(first, UndefinedOr.map(options, withoutScope)));
|
|
152
|
+
}
|
|
153
|
+
return commanded(scopeIn(third), (under) => countOf(first, under) > 0, nameOf(first), (run) => run(first, second, UndefinedOr.map(third, withoutScope)));
|
|
154
|
+
});
|
|
155
|
+
/**
|
|
156
|
+
* A Command's animation of either form: a member of the Handle's Provider while it runs (a member
|
|
157
|
+
* from before anything is looked at, so a Provider built for one that finds nothing is left again at
|
|
158
|
+
* once), its selectors' root under `scope`, `finds` asked of that root, nothing found failing as
|
|
159
|
+
* `named`, and `start` run on dom's scoped `animate`.
|
|
160
|
+
*/
|
|
161
|
+
const commanded = Effect.fnUntraced(function* (scope, finds, named, start) {
|
|
162
|
+
const held = yield* member();
|
|
163
|
+
const inside = insideOf(held.provider, scope);
|
|
164
|
+
if (Option.isNone(inside)) {
|
|
165
|
+
held.left();
|
|
166
|
+
return yield* Effect.fail(new AnimationFailed({ subject: named }));
|
|
167
|
+
}
|
|
168
|
+
if (Bool.not(finds(inside.value))) {
|
|
169
|
+
held.left();
|
|
170
|
+
return yield* Effect.fail(new AnimationFailed({ subject: named }));
|
|
171
|
+
}
|
|
172
|
+
return yield* running(held, inside.value, scope, start);
|
|
173
|
+
});
|
|
174
|
+
/**
|
|
175
|
+
* The animation `start` runs on dom's scoped `animate`, until it ends: its end as the Effect's success,
|
|
176
|
+
* its interruption as its stop. With a `scope`, the scope's watch is told each start and end too
|
|
177
|
+
* (Q7): what its element's release stops, each then ending with `landed: false` (Q19).
|
|
178
|
+
*/
|
|
179
|
+
const running = (held, under, scope, start) => Effect.callback((resume) => {
|
|
180
|
+
const controls = MutableRef.make(Option.none());
|
|
181
|
+
const watch = Imperative.alsoTold({
|
|
182
|
+
started: (made) => {
|
|
183
|
+
MutableRef.set(controls, Option.some(made));
|
|
184
|
+
},
|
|
185
|
+
ended: (_made, landed) => {
|
|
186
|
+
held.left();
|
|
187
|
+
resume(Effect.succeed({ landed }));
|
|
188
|
+
},
|
|
189
|
+
}, UndefinedOr.map(scope, watchOf));
|
|
190
|
+
start(Imperative.scopedAnimate(envOf(held.state, held.provider), () => under, watch));
|
|
191
|
+
return Effect.sync(() => {
|
|
192
|
+
Option.map(MutableRef.get(controls), (made) => made.stop());
|
|
193
|
+
held.left();
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
/**
|
|
197
|
+
* `effect` run on the Provider's services (ADR-0071, the grill's Q23): how a Command makes a derived
|
|
198
|
+
* Live value (`LiveValue.spring`, `follow`, `velocity`, `scroll`). The Scope is the caller's: a
|
|
199
|
+
* `ManagedResource`'s `acquire`, whose Scope Foldkit closes when its Model condition drops, or an
|
|
200
|
+
* `Effect.scoped` that ends with the Command. The Provider is held while that Scope lives.
|
|
201
|
+
*/
|
|
202
|
+
export const provide = Effect.fnUntraced(function* (effect) {
|
|
203
|
+
const { provider, left } = yield* member();
|
|
204
|
+
yield* Effect.addFinalizer(() => Effect.sync(left));
|
|
205
|
+
return yield* Effect.provideContext(effect, provider.context);
|
|
206
|
+
});
|
|
207
|
+
/** `scroll` found no scroll to read: the Handle wasn't given `Features.scroll`, or a load of it hasn't arrived. */
|
|
208
|
+
export class ScrollFailed extends Data.TaggedError("ScrollFailed") {
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* A container's scroll as **Live values** (Motion's `useScroll`): how far it's scrolled on each axis,
|
|
212
|
+
* and the progress through its range, or through the offsets a `target` passes, each an Atom a view
|
|
213
|
+
* binds, set within the scroll's own event. Its listeners are held while the caller's Scope lives, as
|
|
214
|
+
* a Live value made under `provide` is. Fails with {@link ScrollFailed} when the Handle has no `scroll`
|
|
215
|
+
* Feature: name it, `Wardic.make({ env, features: [Features.scroll] })`.
|
|
216
|
+
*/
|
|
217
|
+
// #795 (the storefront's part 2): core's `LiveValue.scroll` on the `scroll` Feature's `ScrollSource`, which
|
|
218
|
+
// Solid's `createScroll` brings by itself and a Foldkit Handle names; typed as `animateLayout` is without
|
|
219
|
+
// its Feature (decision 13), not Effect's own missing-service defect.
|
|
220
|
+
export const scroll = Effect.fnUntraced(function* (options) {
|
|
221
|
+
const { provider, left } = yield* member();
|
|
222
|
+
const source = featureIn(provider, ScrollSource.ScrollSource);
|
|
223
|
+
if (Predicate.isUndefined(source)) {
|
|
224
|
+
left();
|
|
225
|
+
return yield* Effect.fail(new ScrollFailed({ reason: "no-scroll-feature" }));
|
|
226
|
+
}
|
|
227
|
+
yield* Effect.addFinalizer(() => Effect.sync(left));
|
|
228
|
+
return yield* Effect.provideContext(LiveValue.scroll(options), Context.add(provider.context, ScrollSource.ScrollSource, source));
|
|
229
|
+
});
|
|
230
|
+
/**
|
|
231
|
+
* The pointer over an element as **Live values**: where it is in the element's pixels, from the box's
|
|
232
|
+
* top left; its progress across the box, from 0 to 1 each way; the box's size; and whether it's
|
|
233
|
+
* inside, each an Atom a view binds, set within the pointer's own events (`pointerenter`,
|
|
234
|
+
* `pointermove`, `pointerdown`, `pointerleave`). A leave keeps the place: what returns to rest with
|
|
235
|
+
* it is a derived Atom over `inside`. Its listeners are held while the caller's Scope lives, as a
|
|
236
|
+
* Live value made under `provide` is. A mouse and a pen count unless `types` says; a finger never
|
|
237
|
+
* hovers. Plain pointer events, not the hover gesture: no Feature to name, nothing to fail.
|
|
238
|
+
*/
|
|
239
|
+
// #833 (found as #795's storefront was reviewed): dom's `PointerValues` under `provide`, where the spotlight
|
|
240
|
+
// and the magnifier each listened and did the arithmetic themselves.
|
|
241
|
+
export const pointer = (element, options) => provide(DomPointer.pointer(element, options));
|
|
242
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/internal/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,YAAY,MAAM,2BAA2B,CAAA;AACzD,OAAO,KAAK,iBAAiB,MAAM,yCAAyC,CAAA;AAE5E,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAC7D,OAAO,KAAK,UAAU,MAAM,oCAAoC,CAAA;AAChE,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK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decision 20): how each render's config reaches a mounted element. A `w.*`
|
|
3
|
+
* element renders its folded config as one `wardic` property, minted by a `CustomElement.define`
|
|
4
|
+
* spec's property factory, the public way to a `Prop` attribute (P6). Foldkit's props module writes
|
|
5
|
+
* the property at `create` and again on each render whose value is a fresh reference, parent first.
|
|
6
|
+
* At mount, the element's Mount puts an accessor on the property, so each later write is a setter call
|
|
7
|
+
* inside the patch, where the element Retargets (#791, Q14).
|
|
8
|
+
*
|
|
9
|
+
* The patch's microtask (#791, Q25): the first setter call of a patch, or its first Mount insert,
|
|
10
|
+
* queues one microtask, which runs after the whole patch and before paint: the `Reactivity` port's
|
|
11
|
+
* watches re-read there (decision 17), then slice 1's PR 3 adds the held-frame hint.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type * as FrameLoop from "@wardic/core/FrameLoop";
|
|
16
|
+
import type { Attribute, HtmlBuilder } from "foldkit/html";
|
|
17
|
+
/** The `wardic` property attribute carrying `config`, for a view built with `h`. */
|
|
18
|
+
export declare const propertyOf: <Message>(h: HtmlBuilder<Message>, config: object) => Attribute<Message>;
|
|
19
|
+
/** The config last delivered to `element`: what the props module wrote at `create`, or a setter took since. */
|
|
20
|
+
export declare const deliveredTo: (element: Element) => unknown;
|
|
21
|
+
/** The config a view node carries for its element, before any delivery: its `wardic` property among `props` (#794's walk). */
|
|
22
|
+
export declare const carriedBy: (props: Record<string, unknown> | undefined) => unknown;
|
|
23
|
+
/**
|
|
24
|
+
* An accessor for the `wardic` property on `element`, over the value the props module wrote at
|
|
25
|
+
* `create`: every later write calls `onSet`, inside the patch. Returns the release, which puts the
|
|
26
|
+
* plain property back with its last value.
|
|
27
|
+
*/
|
|
28
|
+
export declare const installSetter: (element: Element, onSet: (value: unknown) => void) => (() => void);
|
|
29
|
+
/**
|
|
30
|
+
* A patch touched the page: a setter call, or a Mount's insert. Queues the patch's microtask, once per
|
|
31
|
+
* patch, however many elements say so. A plain `queueMicrotask`: core's end-of-task checkpoint.
|
|
32
|
+
*/
|
|
33
|
+
export declare const patchTouched: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* The binding's hint (ADR-0071, decision 32; #673's deferred rule): a setter runs inside Foldkit's
|
|
36
|
+
* patch, a Refresh frame callback after Wardic's tick, so the Frame loop opens its Late window for the
|
|
37
|
+
* Retargets the patch makes, and they paint in this frame rather than the next. Called before the
|
|
38
|
+
* Retarget, after {@link patchTouched}, so the window's microtask runs after the patch's. Not for a
|
|
39
|
+
* replay's patch, which runs in a task (P6): the time read there is a past frame's.
|
|
40
|
+
*/
|
|
41
|
+
export declare const hintFrame: (loop: FrameLoop.FrameLoop["Service"]) => void;
|
|
42
|
+
/** The hint (above), unless DevTools replay has the view (decision 34), whose patch runs in a task and lands everything at once. */
|
|
43
|
+
export declare const hintFrameUnless: (loop: FrameLoop.FrameLoop["Service"], paused: () => boolean) => void;
|
|
44
|
+
//# sourceMappingURL=delivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../../src/internal/delivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,KAAK,SAAS,MAAM,wBAAwB,CAAA;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAkB1D,oFAAoF;AACpF,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,WAAW,CAAC,OAAO,CAAC,UAAU,MAAM,KAAG,SAAS,CAAC,OAAO,CAO9F,CAAA;AAOD,+GAA+G;AAC/G,eAAO,MAAM,WAAW,YAAa,OAAO,KAAG,OAAsC,CAAA;AAErF,8HAA8H;AAC9H,eAAO,MAAM,SAAS,UAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,KAAG,OAAwD,CAAA;AAE/H;;;;GAIG;AACH,eAAO,MAAM,aAAa,YAAa,OAAO,SAAS,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,KAAG,CAAC,MAAM,IAAI,CAgB5F,CAAA;AAWD;;;GAGG;AACH,eAAO,MAAM,YAAY,QAAO,IAI/B,CAAA;AAKD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,SAAU,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,KAAG,IAEhE,CAAA;AAED,oIAAoI;AACpI,eAAO,MAAM,eAAe,SAAU,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU,MAAM,OAAO,KAAG,IAG7F,CAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as CustomElement from "foldkit/customElement";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
4
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
5
|
+
import { recheck } from "./reactivity.js";
|
|
6
|
+
/** The property an element's config is delivered through. */
|
|
7
|
+
const KEY = "wardic";
|
|
8
|
+
// Schema, where Foldkit's API asks for it (ADR-0071, decision 14): a `CustomElement.define` spec types
|
|
9
|
+
// each property with one. Its value is never decoded: the config is Wardic's own, checked by hand.
|
|
10
|
+
/** The spec whose `Wardic` factory builds the `wardic` property attribute, for any element. */
|
|
11
|
+
const spec = /*#__PURE__*/ CustomElement.define({ tag: "wardic-element", properties: { [KEY]: Schema.Unknown }, events: {} });
|
|
12
|
+
/** The factory for `h`'s Message: `withMessage` is a type witness, minted once per builder. */
|
|
13
|
+
// Module state (#460, Q7): a cache keyed by the builder it's minted for.
|
|
14
|
+
const factories = new WeakMap();
|
|
15
|
+
/** The `wardic` property attribute carrying `config`, for a view built with `h`. */
|
|
16
|
+
export const propertyOf = (h, config) => {
|
|
17
|
+
let factory = factories.get(h);
|
|
18
|
+
if (Predicate.isUndefined(factory)) {
|
|
19
|
+
factory = spec.withMessage(h).Wardic;
|
|
20
|
+
factories.set(h, factory);
|
|
21
|
+
}
|
|
22
|
+
return factory(config);
|
|
23
|
+
};
|
|
24
|
+
/** The config last delivered to `element`: what the props module wrote at `create`, or a setter took since. */
|
|
25
|
+
export const deliveredTo = (element) => element[KEY];
|
|
26
|
+
/** The config a view node carries for its element, before any delivery: its `wardic` property among `props` (#794's walk). */
|
|
27
|
+
export const carriedBy = (props) => UndefinedOr.map(props, (given) => given[KEY]);
|
|
28
|
+
/**
|
|
29
|
+
* An accessor for the `wardic` property on `element`, over the value the props module wrote at
|
|
30
|
+
* `create`: every later write calls `onSet`, inside the patch. Returns the release, which puts the
|
|
31
|
+
* plain property back with its last value.
|
|
32
|
+
*/
|
|
33
|
+
export const installSetter = (element, onSet) => {
|
|
34
|
+
const target = element;
|
|
35
|
+
let value = target[KEY];
|
|
36
|
+
Object.defineProperty(target, KEY, {
|
|
37
|
+
configurable: true,
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: () => value,
|
|
40
|
+
set: (next) => {
|
|
41
|
+
value = next;
|
|
42
|
+
onSet(next);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
return () => {
|
|
46
|
+
delete target[KEY];
|
|
47
|
+
target[KEY] = value;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
// Module state (#460, Q7): whether this patch's microtask is queued, cleared when it runs.
|
|
51
|
+
let queued = false;
|
|
52
|
+
/** What the patch's microtask does: the watches, then (PR 3) the held-frame hint. */
|
|
53
|
+
const afterPatch = () => {
|
|
54
|
+
queued = false;
|
|
55
|
+
recheck();
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A patch touched the page: a setter call, or a Mount's insert. Queues the patch's microtask, once per
|
|
59
|
+
* patch, however many elements say so. A plain `queueMicrotask`: core's end-of-task checkpoint.
|
|
60
|
+
*/
|
|
61
|
+
export const patchTouched = () => {
|
|
62
|
+
if (queued)
|
|
63
|
+
return;
|
|
64
|
+
queued = true;
|
|
65
|
+
queueMicrotask(afterPatch);
|
|
66
|
+
};
|
|
67
|
+
/** The frame's time, as every rAF callback of a frame sees it: what the hint compares the last tick's with. */
|
|
68
|
+
const frameTime = () => Number(document.timeline.currentTime);
|
|
69
|
+
/**
|
|
70
|
+
* The binding's hint (ADR-0071, decision 32; #673's deferred rule): a setter runs inside Foldkit's
|
|
71
|
+
* patch, a Refresh frame callback after Wardic's tick, so the Frame loop opens its Late window for the
|
|
72
|
+
* Retargets the patch makes, and they paint in this frame rather than the next. Called before the
|
|
73
|
+
* Retarget, after {@link patchTouched}, so the window's microtask runs after the patch's. Not for a
|
|
74
|
+
* replay's patch, which runs in a task (P6): the time read there is a past frame's.
|
|
75
|
+
*/
|
|
76
|
+
export const hintFrame = (loop) => {
|
|
77
|
+
loop.hint(frameTime());
|
|
78
|
+
};
|
|
79
|
+
/** The hint (above), unless DevTools replay has the view (decision 34), whose patch runs in a task and lands everything at once. */
|
|
80
|
+
export const hintFrameUnless = (loop, paused) => {
|
|
81
|
+
if (paused())
|
|
82
|
+
return;
|
|
83
|
+
hintFrame(loop);
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=delivery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery.js","sourceRoot":"","sources":["../../src/internal/delivery.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,aAAa,MAAM,uBAAuB,CAAA;AAEtD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,6DAA6D;AAC7D,MAAM,GAAG,GAAG,QAAQ,CAAA;AAEpB,uGAAuG;AACvG,mGAAmG;AACnG,+FAA+F;AAC/F,MAAM,IAAI,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,gBAAgB,EAAE,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,E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ACZ,KAAK,CAAC,IAAI,CAAC,CAAA;QACb,CAAC;KACF,CAAC,CAAA;IACF,OAAO,GAAG,EAAE;QACV,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;QAClB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACrB,CAAC,CAAA;AACH,CAAC,CAAA;AAED,2FAA2F;AAC3F,IAAI,MAAM,GAAG,KAAK,CAAA;AAElB,qFAAqF;AACrF,MAAM,UAAU,GAAG,GAAS,EAAE;IAC5B,MAAM,GAAG,KAAK,CAAA;IACd,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAS,EAAE;IACrC,IAAI,MAAM;QAAE,OAAM;IAClB,MAAM,GAAG,IAAI,CAAA;IACb,cAAc,CAAC,UAAU,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,+GAA+G;AAC/G,MAAM,SAAS,GAAG,GAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AAErE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAoC,EAAQ,EAAE;IACtE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAA;AACxB,CAAC,CAAA;AAED,oIAAoI;AACpI,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAoC,EAAE,MAAqB,EAAQ,EAAE;IACnG,IAAI,MAAM,EAAE;QAAE,OAAM;IACpB,SAAS,CAAC,IAAI,CAAC,CAAA;AACjB,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development: on. The package's `development` export condition resolves this module, as Solid's
|
|
3
|
+
* `DEV` is Solid's own condition (#791, Q10); a production build resolves `dev.production.ts`, so a
|
|
4
|
+
* check under `DEV` and what it calls are dropped from it. Tested in a plain `if` or `&&`, never through
|
|
5
|
+
* `Bool`, as a build-time flag is (`docs/agents/effect-first.md`, *Pitfalls*).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEV = true;
|
|
10
|
+
//# sourceMappingURL=dev.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/internal/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,OAAO,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development: on. The package's `development` export condition resolves this module, as Solid's
|
|
3
|
+
* `DEV` is Solid's own condition (#791, Q10); a production build resolves `dev.production.ts`, so a
|
|
4
|
+
* check under `DEV` and what it calls are dropped from it. Tested in a plain `if` or `&&`, never through
|
|
5
|
+
* `Bool`, as a build-time flag is (`docs/agents/effect-first.md`, *Pitfalls*).
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export const DEV = true;
|
|
10
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/internal/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development: off. What a build that doesn't resolve the `development` export condition gets for
|
|
3
|
+
* `@wardic/foldkit/internal/dev` (#791, Q10): `dev.ts` is the other half.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEV = false;
|
|
8
|
+
//# sourceMappingURL=dev.production.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.production.d.ts","sourceRoot":"","sources":["../../src/internal/dev.production.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,GAAG,QAAQ,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Development: off. What a build that doesn't resolve the `development` export condition gets for
|
|
3
|
+
* `@wardic/foldkit/internal/dev` (#791, Q10): `dev.ts` is the other half.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export const DEV = false;
|
|
8
|
+
//# sourceMappingURL=dev.production.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.production.js","sourceRoot":"","sources":["../../src/internal/dev.production.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `w.*` element's drag (#793, PR 2; ADR-0004; ADR-0071 decision 23): dom's drag track, driven by the
|
|
3
|
+
* binding (the `drag` Feature's `drive`), started the first time a delivery wants it (`w.Drag` while
|
|
4
|
+
* `Features.drag` is built) and kept, in a Scope of the element's own on the provider, closed at the
|
|
5
|
+
* release. Its options are read as it starts (Q6): a changed one wants a new key. Its defaults are
|
|
6
|
+
* written then (Q10; ADR-0019 *Amendment (Reorder)*), under the element's own inline style, and it
|
|
7
|
+
* drives the layout node the element has then (ADR-0016). What the spine reads of it (its axis, its
|
|
8
|
+
* track, whether it drives a projection) sits on the spine's options, written as the track starts: the
|
|
9
|
+
* spine reads each where it uses it. A drag wanted without its Feature is inert, and warned once in
|
|
10
|
+
* development.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type * as Drag from "@wardic/core/Drag";
|
|
15
|
+
import type * as Spine from "@wardic/core/unstable/Spine";
|
|
16
|
+
import type * as Values from "@wardic/core/Values";
|
|
17
|
+
import type * as ProjectionSystem from "@wardic/dom/ProjectionSystem";
|
|
18
|
+
import * as DragTrack from "@wardic/dom/unstable/DragTrack";
|
|
19
|
+
import type * as LiveStyle from "@wardic/dom/unstable/LiveStyle";
|
|
20
|
+
import type * as WardConfig from "@wardic/dom/unstable/WardConfig";
|
|
21
|
+
import type { View } from "./element.ts";
|
|
22
|
+
import { type Provider } from "./services.ts";
|
|
23
|
+
/** What the spine reads of an element's drag (ADR-0004, #340): on its options, written as the track starts. */
|
|
24
|
+
export interface SpineDragOptions {
|
|
25
|
+
dragAxis: boolean | "x" | "y" | undefined;
|
|
26
|
+
drag: Spine.SpineDrag | undefined;
|
|
27
|
+
projected: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** What an element's drag is made with. */
|
|
30
|
+
export interface DragOptions {
|
|
31
|
+
readonly provider: Provider;
|
|
32
|
+
readonly element: HTMLElement;
|
|
33
|
+
/** The element's id, for a report. */
|
|
34
|
+
readonly id: string;
|
|
35
|
+
/** The element's config now, as its last delivery gave it: the drag's options read as the track starts, the measure's function at each measure. */
|
|
36
|
+
readonly config: () => Pick<View, "drag" | "dragListener" | "dragConstraints" | "dragControls" | "onMeasureDragConstraints" | keyof DragTrack.DragOptions | "dragTransition">;
|
|
37
|
+
/** The spine's Snapshot, which the drag reads and writes `x`/`y` through. */
|
|
38
|
+
readonly snapshot: Spine.Snapshot;
|
|
39
|
+
readonly recordFrame: (value: Values.Values) => void;
|
|
40
|
+
readonly live: LiveStyle.LiveStyle;
|
|
41
|
+
/** The element's spine options: what the spine reads of the drag. */
|
|
42
|
+
readonly spine: SpineDragOptions;
|
|
43
|
+
/** The element's layout node now: the track's projection as it starts (ADR-0016). */
|
|
44
|
+
readonly layoutNode: () => ProjectionSystem.DragHandle | undefined;
|
|
45
|
+
/** A Reorder item's axis, read at each gesture's start in place of `Drag`'s (ADR-0020): the group's, once the item has joined it; `undefined` for any other element. Read as the track starts. */
|
|
46
|
+
readonly itemAxis: () => (() => true | "x" | "y") | undefined;
|
|
47
|
+
/** The nearest `w.Config`'s `transformPagePoint` (Q9), read at each down. */
|
|
48
|
+
readonly pagePoint: () => WardConfig.WardicTransformPoint | undefined;
|
|
49
|
+
readonly skipAnimations: () => boolean;
|
|
50
|
+
/** Told as the drag takes `x`/`y`, and as it hands them back. */
|
|
51
|
+
readonly onDragging: (on: boolean) => void;
|
|
52
|
+
/** Each sample, after the track's write: the element's drag callbacks. */
|
|
53
|
+
readonly onSample: (sample: Drag.Sample) => void;
|
|
54
|
+
/** The release came to rest on its own. */
|
|
55
|
+
readonly onReleaseEnd: () => void;
|
|
56
|
+
}
|
|
57
|
+
/** An element's drag (above). */
|
|
58
|
+
export interface ElementDrag {
|
|
59
|
+
/** Start the track if the config wants it and the Feature is here, once: at mount, at each delivery, and as a Feature arrives. */
|
|
60
|
+
readonly check: () => void;
|
|
61
|
+
/** Close the track's Scope: at the element's release. */
|
|
62
|
+
readonly dispose: () => void;
|
|
63
|
+
}
|
|
64
|
+
/** An element's drag (above): nothing started until `check` wants it. */
|
|
65
|
+
export declare const dragOf: (opts: DragOptions) => ElementDrag;
|
|
66
|
+
//# sourceMappingURL=drag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drag.d.ts","sourceRoot":"","sources":["../../src/internal/drag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,KAAK,IAAI,MAAM,mBAAmB,CAAA;AAE9C,OAAO,KAAK,KAAK,KAAK,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,KAAK,gBAAgB,MAAM,8BAA8B,CAAA;AAErE,OAAO,KAAK,SAAS,MAAM,gCAAgC,CAAA;AAI3D,OAAO,KAAK,KAAK,SAAS,MAAM,gCAAgC,CAAA;AAEhE,OAAO,KAAK,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAMlE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAa,KAAK,QAAQ,EAA2B,MAAM,eAAe,CAAA;AAEjF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,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,IAAI,CAAA;IAC1C,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,KAAK,IAAI,CAAA;IAChD,2CAA2C;IAC3C,QAAQ,CAAC,YAAY,EAAE,MAAM,IAAI,CAAA;CAClC;AAED,iCAAiC;AACjC,MAAM,WAAW,WAAW;IAC1B,kIAAkI;IAClI,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAC7B;AAQD,yEAAyE;AACzE,eAAO,MAAM,MAAM,SAAU,WAAW,KAAG,WAkD1C,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as DragDefaults from "@wardic/dom/unstable/DragDefaults";
|
|
2
|
+
import * as DragTrack from "@wardic/dom/unstable/DragTrack";
|
|
3
|
+
import * as DragTransition from "@wardic/dom/unstable/DragTransition";
|
|
4
|
+
import * as ElementSetup from "@wardic/dom/unstable/ElementSetup";
|
|
5
|
+
import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures";
|
|
6
|
+
import * as OwnerScope from "@wardic/dom/unstable/OwnerScope";
|
|
7
|
+
import * as Keys from "@wardic/dom/unstable/features/Keys";
|
|
8
|
+
import * as MutableRef from "effect/MutableRef";
|
|
9
|
+
import * as Predicate from "effect/Predicate";
|
|
10
|
+
import * as Scope from "effect/Scope";
|
|
11
|
+
import * as UndefinedOr from "effect/UndefinedOr";
|
|
12
|
+
import { featureIn, reporterOf, warnMissing } from "./services.js";
|
|
13
|
+
/** The track's end that failed, at the element's release. */
|
|
14
|
+
const END_FAILED = "wardic.drag: the track's end failed";
|
|
15
|
+
/** A watch's own handler threw, dom's, past the app's callbacks. */
|
|
16
|
+
const WATCH_FAILED = "wardic.drag: a watch's handler failed";
|
|
17
|
+
/** An element's drag (above): nothing started until `check` wants it. */
|
|
18
|
+
export const dragOf = (opts) => {
|
|
19
|
+
const { provider, element, id, spine, config } = opts;
|
|
20
|
+
const scope = MutableRef.make(undefined);
|
|
21
|
+
const report = reporterOf(provider, id);
|
|
22
|
+
const onDefect = (cause) => report(WATCH_FAILED, cause);
|
|
23
|
+
/** The track, from this delivery's options: its defaults written first, its Scope the element's own. */
|
|
24
|
+
const start = (service, axis, axisAt) => {
|
|
25
|
+
const c = config();
|
|
26
|
+
UndefinedOr.map(DragDefaults.dragDefaultsOf(c, { dragAxis: axisAt }), (defaults) => DragDefaults.applyDragDefaults(element, defaults));
|
|
27
|
+
const constraints = service.constraintsOf(c.dragConstraints, element, () => config().onMeasureDragConstraints, opts.pagePoint);
|
|
28
|
+
const projection = opts.layoutNode();
|
|
29
|
+
const owner = OwnerScope.open(provider.runtime);
|
|
30
|
+
MutableRef.set(scope, owner);
|
|
31
|
+
const track = service.drive({
|
|
32
|
+
watch: (track) => provider.runtime.runSync(track(onDefect).pipe(Scope.provide(owner))),
|
|
33
|
+
fork: (response) => void provider.runtime.runFork(response),
|
|
34
|
+
gate: provider.gate,
|
|
35
|
+
id,
|
|
36
|
+
element,
|
|
37
|
+
snapshot: opts.snapshot,
|
|
38
|
+
recordFrame: opts.recordFrame,
|
|
39
|
+
// A drag's start turns its `style`'s will-change value on (#443).
|
|
40
|
+
setDragging: ElementSetup.draggingWithWillChange(opts.live, opts.onDragging, element),
|
|
41
|
+
claim: ElementSetup.claimForDrag(element),
|
|
42
|
+
config: DragTrack.trackConfigOf(c, axis, constraints.constraints, DragTransition.dragTransitionOf(c.dragElastic, c.dragTransition)),
|
|
43
|
+
// A drag on a layout node feeds the projection (ADR-0016): it follows the pointer and FLIPs to its slot on release.
|
|
44
|
+
projection,
|
|
45
|
+
axisAt,
|
|
46
|
+
onSample: opts.onSample,
|
|
47
|
+
onReleaseEnd: opts.onReleaseEnd,
|
|
48
|
+
skipAnimations: opts.skipAnimations,
|
|
49
|
+
container: constraints.container,
|
|
50
|
+
controls: c.dragControls,
|
|
51
|
+
mapPoint: opts.pagePoint,
|
|
52
|
+
});
|
|
53
|
+
spine.dragAxis = axis;
|
|
54
|
+
spine.drag = track;
|
|
55
|
+
spine.projected = Predicate.isNotUndefined(projection);
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
check: () => {
|
|
59
|
+
if (Predicate.isNotUndefined(MutableRef.get(scope)))
|
|
60
|
+
return;
|
|
61
|
+
// A Reorder item drags on its group's axis, read at each gesture's start: `true` to the spine (ADR-0020).
|
|
62
|
+
const axisAt = opts.itemAxis();
|
|
63
|
+
const axis = DragDefaults.dragAxisOf(config(), { dragAxis: axisAt });
|
|
64
|
+
if (Predicate.isUndefined(axis))
|
|
65
|
+
return;
|
|
66
|
+
UndefinedOr.match(featureIn(provider, Keys.DragGesture), { onUndefined: () => warnMissing(provider, "drag", GestureFeatures.GESTURE_WORDS.drag), onDefined: (service) => start(service, axis, axisAt) });
|
|
67
|
+
},
|
|
68
|
+
dispose: () => UndefinedOr.map(MutableRef.get(scope), (owner) => OwnerScope.close(provider.runtime, owner, END_FAILED)),
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=drag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drag.js","sourceRoot":"","sources":["../../src/internal/drag.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,YAAY,MAAM,mCAAmC,CAAA;AACjE,OAAO,KAAK,SAAS,MAAM,gCAAgC,CAAA;AAC3D,OAAO,KAAK,cAAc,MAAM,qCAAqC,CAAA;AACrE,OAAO,KAAK,YAAY,MAAM,mCAAmC,CAAA;AACjE,OAAO,KAAK,eAAe,MAAM,sCAAsC,CAAA;AAEvE,OAAO,KAAK,UAAU,MAAM,iCAAiC,CAAA;AAE7D,OAAO,KAAK,IAAI,MAAM,oCAAoC,CAAA;AAC1D,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAA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