dotquilt 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +64 -2
- package/dist/animations.d.ts +105 -0
- package/dist/animations.js +107 -0
- package/dist/catalog-styles.d.ts +4 -0
- package/dist/catalog-styles.js +12 -0
- package/dist/chart-animations.d.ts +36 -0
- package/dist/chart-animations.js +25 -0
- package/dist/chart-styles.d.ts +3 -0
- package/dist/chart-styles.js +23 -0
- package/dist/chart.css +4 -0
- package/dist/chart.d.ts +73 -0
- package/dist/chart.js +80 -0
- package/dist/circle.css +5 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +9 -0
- package/dist/internal/binding.d.ts +13 -0
- package/dist/internal/binding.js +21 -0
- package/dist/internal/capture.d.ts +4 -0
- package/dist/internal/capture.js +13 -0
- package/dist/internal/chart-appearance.d.ts +12 -0
- package/dist/internal/chart-appearance.js +2 -0
- package/dist/internal/chart-definitions.d.ts +19 -0
- package/dist/internal/chart-definitions.js +149 -0
- package/dist/internal/chart-factory.d.ts +12 -0
- package/dist/internal/chart-factory.js +31 -0
- package/dist/internal/chart-field.d.ts +22 -0
- package/dist/internal/chart-field.js +74 -0
- package/dist/internal/chart-idle.d.ts +3 -0
- package/dist/internal/chart-idle.js +96 -0
- package/dist/internal/chart-math.d.ts +8 -0
- package/dist/internal/chart-math.js +19 -0
- package/dist/internal/chart-participant.d.ts +8 -0
- package/dist/internal/chart-participant.js +4 -0
- package/dist/internal/chart-projection.d.ts +11 -0
- package/dist/internal/chart-projection.js +69 -0
- package/dist/internal/content-box.d.ts +11 -0
- package/dist/internal/content-box.js +36 -0
- package/dist/internal/coordinated-handoff.d.ts +4 -0
- package/dist/internal/coordinated-handoff.js +158 -0
- package/dist/internal/count.d.ts +3 -0
- package/dist/internal/count.js +20 -0
- package/dist/internal/defaults.d.ts +11 -0
- package/dist/internal/defaults.js +11 -0
- package/dist/internal/dense/managed-painter.d.ts +4 -0
- package/dist/internal/dense/managed-painter.js +361 -0
- package/dist/internal/dense/runner.d.ts +2 -0
- package/dist/internal/dense/runner.js +5 -0
- package/dist/internal/dense-loader.d.ts +83 -0
- package/dist/internal/dense-loader.js +331 -0
- package/dist/internal/dissolve.d.ts +27 -0
- package/dist/internal/dissolve.js +216 -0
- package/dist/internal/dom.d.ts +23 -0
- package/dist/internal/dom.js +104 -0
- package/dist/internal/effect.d.ts +2 -0
- package/dist/internal/effect.js +17 -0
- package/dist/internal/element.d.ts +89 -0
- package/dist/internal/element.js +384 -0
- package/dist/internal/event-element.d.ts +8 -0
- package/dist/internal/event-element.js +20 -0
- package/dist/internal/frames.d.ts +1 -0
- package/dist/internal/frames.js +51 -0
- package/dist/internal/handoff.d.ts +56 -0
- package/dist/internal/handoff.js +102 -0
- package/dist/internal/ledger.d.ts +13 -0
- package/dist/internal/ledger.js +78 -0
- package/dist/internal/loading-controller.d.ts +62 -0
- package/dist/internal/loading-controller.js +698 -0
- package/dist/internal/marks.d.ts +153 -0
- package/dist/internal/marks.js +227 -0
- package/dist/internal/math.d.ts +2 -0
- package/dist/internal/math.js +2 -0
- package/dist/internal/morph-marks.d.ts +62 -0
- package/dist/internal/morph-marks.js +205 -0
- package/dist/internal/morph.d.ts +35 -0
- package/dist/internal/morph.js +488 -0
- package/dist/internal/paint.d.ts +29 -0
- package/dist/internal/paint.js +1 -0
- package/dist/internal/painter.d.ts +20 -0
- package/dist/internal/painter.js +155 -0
- package/dist/internal/preset-data.d.ts +12 -0
- package/dist/internal/preset-data.js +31 -0
- package/dist/internal/preset.d.ts +22 -0
- package/dist/internal/preset.js +86 -0
- package/dist/internal/pulse.d.ts +7 -0
- package/dist/internal/pulse.js +74 -0
- package/dist/internal/reveal-effect.d.ts +7 -0
- package/dist/internal/reveal-effect.js +24 -0
- package/dist/internal/reveal.d.ts +5 -0
- package/dist/internal/reveal.js +11 -0
- package/dist/internal/runner.d.ts +9 -0
- package/dist/internal/runner.js +70 -0
- package/dist/internal/services.d.ts +12 -0
- package/dist/internal/services.js +159 -0
- package/dist/internal/skeleton-handoff.d.ts +26 -0
- package/dist/internal/skeleton-handoff.js +6 -0
- package/dist/internal/skeleton-source.d.ts +5 -0
- package/dist/internal/skeleton-source.js +106 -0
- package/dist/internal/surface.d.ts +4 -0
- package/dist/internal/surface.js +21 -0
- package/dist/internal/table-definitions.d.ts +27 -0
- package/dist/internal/table-definitions.js +139 -0
- package/dist/internal/table-factory.d.ts +12 -0
- package/dist/internal/table-factory.js +44 -0
- package/dist/internal/table-field.d.ts +12 -0
- package/dist/internal/table-field.js +75 -0
- package/dist/internal/table-model.d.ts +21 -0
- package/dist/internal/table-model.js +117 -0
- package/dist/internal/table-projection.d.ts +7 -0
- package/dist/internal/table-projection.js +110 -0
- package/dist/internal/target-changes.d.ts +3 -0
- package/dist/internal/target-changes.js +2 -0
- package/dist/internal/target-tracker.d.ts +18 -0
- package/dist/internal/target-tracker.js +33 -0
- package/dist/internal/targets.d.ts +3 -0
- package/dist/internal/targets.js +15 -0
- package/dist/internal/text-definitions.d.ts +141 -0
- package/dist/internal/text-definitions.js +228 -0
- package/dist/internal/text-glyphs.d.ts +4 -0
- package/dist/internal/text-glyphs.js +32 -0
- package/dist/internal/text-morph.d.ts +32 -0
- package/dist/internal/text-morph.js +113 -0
- package/dist/internal/text-playback.d.ts +4 -0
- package/dist/internal/text-playback.js +119 -0
- package/dist/internal/text-scramble.d.ts +18 -0
- package/dist/internal/text-scramble.js +47 -0
- package/dist/internal/time.d.ts +9 -0
- package/dist/internal/time.js +13 -0
- package/dist/internal/unstyled.d.ts +8 -0
- package/dist/internal/unstyled.js +8 -0
- package/dist/line.css +5 -0
- package/dist/region-css.d.ts +1 -0
- package/dist/region-css.js +6 -0
- package/dist/region-styles.d.ts +3 -0
- package/dist/region-styles.js +15 -0
- package/dist/region.css +1 -0
- package/dist/region.d.ts +31 -0
- package/dist/region.js +100 -0
- package/dist/register-all.d.ts +2 -0
- package/dist/register-all.js +33 -0
- package/dist/server.d.ts +63 -0
- package/dist/server.js +141 -0
- package/dist/skeleton-animations.d.ts +10 -0
- package/dist/skeleton-animations.js +35 -0
- package/dist/skeleton-block.d.ts +50 -0
- package/dist/skeleton-block.js +260 -0
- package/dist/skeleton-circle.d.ts +5 -0
- package/dist/skeleton-circle.js +11 -0
- package/dist/skeleton-family.css +13 -0
- package/dist/skeleton-line.d.ts +5 -0
- package/dist/skeleton-line.js +11 -0
- package/dist/skeleton-text.css +5 -0
- package/dist/skeleton-text.d.ts +22 -0
- package/dist/skeleton-text.js +115 -0
- package/dist/skeleton.css +4 -0
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.js +4 -0
- package/dist/static-catalog-styles.d.ts +8 -0
- package/dist/static-catalog-styles.js +44 -0
- package/dist/styles.d.ts +4 -0
- package/dist/styles.js +18 -0
- package/dist/table-animations.d.ts +11 -0
- package/dist/table-animations.js +4 -0
- package/dist/table-styles.d.ts +2 -0
- package/dist/table-styles.js +12 -0
- package/dist/table.css +3 -0
- package/dist/table.d.ts +88 -0
- package/dist/table.js +126 -0
- package/dist/text-animations.d.ts +31 -0
- package/dist/text-animations.js +40 -0
- package/dist/text-styles.d.ts +3 -0
- package/dist/text-styles.js +24 -0
- package/dist/text.css +3 -0
- package/dist/text.d.ts +42 -0
- package/dist/text.js +402 -0
- package/dist/types.d.ts +56 -0
- package/dist/types.js +18 -0
- package/dist/typing-styles.d.ts +1 -0
- package/dist/typing-styles.js +7 -0
- package/dist/typing.css +4 -0
- package/dist/typing.d.ts +35 -0
- package/dist/typing.js +164 -0
- package/package.json +100 -4
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
import { validateBindings } from './binding.js';
|
|
2
|
+
import { activeWithin, ancestors, emit, node, upgradeProperties, } from './dom.js';
|
|
3
|
+
import { ManagedElement, now } from './element.js';
|
|
4
|
+
import { EventElement } from './event-element.js';
|
|
5
|
+
import { runHandoff, } from './handoff.js';
|
|
6
|
+
import { curves, handoff } from './marks.js';
|
|
7
|
+
import { clamp } from './math.js';
|
|
8
|
+
import { regionPreset } from './preset.js';
|
|
9
|
+
import { capturePresetData } from './preset-data.js';
|
|
10
|
+
import { motionLimit } from './time.js';
|
|
11
|
+
export class LoadingController extends EventElement {
|
|
12
|
+
upgrade() {
|
|
13
|
+
upgradeProperties(this, [
|
|
14
|
+
'stylePolicy',
|
|
15
|
+
'preset',
|
|
16
|
+
'animations',
|
|
17
|
+
'revealTargets',
|
|
18
|
+
'timing',
|
|
19
|
+
'state',
|
|
20
|
+
'cycle',
|
|
21
|
+
'motion',
|
|
22
|
+
'delay',
|
|
23
|
+
'minDisplay',
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
placeholderChanged(_placeholder, _state) { }
|
|
27
|
+
/** A built-in cue shown while refreshing, when the app gives none. */
|
|
28
|
+
refreshCue() {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
/** Called once each time refreshing starts with the built-in cue. */
|
|
32
|
+
refreshStarted(_cue) { }
|
|
33
|
+
capturePreset(value) {
|
|
34
|
+
return capturePresetData(value, this.family, () => regionPreset);
|
|
35
|
+
}
|
|
36
|
+
static observedAttributes = [
|
|
37
|
+
...ManagedElement.observedAttributes,
|
|
38
|
+
'state',
|
|
39
|
+
'cycle',
|
|
40
|
+
'tabindex',
|
|
41
|
+
'delay',
|
|
42
|
+
'min-display',
|
|
43
|
+
];
|
|
44
|
+
#revision = 0;
|
|
45
|
+
#serial = 0;
|
|
46
|
+
#batching = false;
|
|
47
|
+
#previous = 'ready';
|
|
48
|
+
#participants;
|
|
49
|
+
#settled = true;
|
|
50
|
+
#work;
|
|
51
|
+
#wrappers;
|
|
52
|
+
#bindings = {};
|
|
53
|
+
#targets = [];
|
|
54
|
+
#clockTiming = {};
|
|
55
|
+
#contentObserver;
|
|
56
|
+
#temporaryTabIndex = false;
|
|
57
|
+
/**
|
|
58
|
+
* Anti-flicker timing. `#shownAt` is when the placeholder became visible;
|
|
59
|
+
* `#timer` ends a delay or a minimum display. A loader upgraded from markup
|
|
60
|
+
* already on the page (server rendering) has its placeholder on screen, so
|
|
61
|
+
* its first render is never delayed.
|
|
62
|
+
*/
|
|
63
|
+
#shownAt;
|
|
64
|
+
#timer;
|
|
65
|
+
#rendered = false;
|
|
66
|
+
#inPlace = this.isConnected;
|
|
67
|
+
get activity() {
|
|
68
|
+
return this.ownActivity;
|
|
69
|
+
}
|
|
70
|
+
get presentation() {
|
|
71
|
+
return this.getAttribute('data-presentation') ?? this.state;
|
|
72
|
+
}
|
|
73
|
+
get state() {
|
|
74
|
+
const value = this.getAttribute('state');
|
|
75
|
+
return value === null || value === 'ready'
|
|
76
|
+
? 'ready'
|
|
77
|
+
: value === 'refreshing'
|
|
78
|
+
? 'refreshing'
|
|
79
|
+
: 'pending';
|
|
80
|
+
}
|
|
81
|
+
set state(value) {
|
|
82
|
+
if (value === undefined)
|
|
83
|
+
this.removeAttribute('state');
|
|
84
|
+
else
|
|
85
|
+
this.setAttribute('state', String(value));
|
|
86
|
+
}
|
|
87
|
+
get cycle() {
|
|
88
|
+
return this.getAttribute('cycle') ?? undefined;
|
|
89
|
+
}
|
|
90
|
+
/** Milliseconds to wait before showing the placeholder (0–10000). */
|
|
91
|
+
get delay() {
|
|
92
|
+
return this.#milliseconds('delay');
|
|
93
|
+
}
|
|
94
|
+
set delay(value) {
|
|
95
|
+
if (value === undefined)
|
|
96
|
+
this.removeAttribute('delay');
|
|
97
|
+
else
|
|
98
|
+
this.setAttribute('delay', String(value));
|
|
99
|
+
}
|
|
100
|
+
/** Milliseconds a placeholder stays once shown (0–10000). */
|
|
101
|
+
get minDisplay() {
|
|
102
|
+
return this.#milliseconds('min-display');
|
|
103
|
+
}
|
|
104
|
+
set minDisplay(value) {
|
|
105
|
+
if (value === undefined)
|
|
106
|
+
this.removeAttribute('min-display');
|
|
107
|
+
else
|
|
108
|
+
this.setAttribute('min-display', String(value));
|
|
109
|
+
}
|
|
110
|
+
#milliseconds(name) {
|
|
111
|
+
const value = Number(this.getAttribute(name) ?? 0);
|
|
112
|
+
return Number.isFinite(value) && value >= 0 ? Math.min(10000, value) : 0;
|
|
113
|
+
}
|
|
114
|
+
set cycle(value) {
|
|
115
|
+
if (value === undefined)
|
|
116
|
+
this.removeAttribute('cycle');
|
|
117
|
+
else
|
|
118
|
+
this.setAttribute('cycle', String(value));
|
|
119
|
+
}
|
|
120
|
+
get timing() {
|
|
121
|
+
return Object.freeze({ ...this.preset?.timing, ...this.#clockTiming });
|
|
122
|
+
}
|
|
123
|
+
set timing(value) {
|
|
124
|
+
const duration = value?.duration;
|
|
125
|
+
const valid = duration !== undefined && Number.isFinite(duration) && duration >= 0;
|
|
126
|
+
let easing = value?.easing ?? 'ease-out';
|
|
127
|
+
if (typeof easing !== 'string' ||
|
|
128
|
+
!/^(linear|ease(-in)?(-out)?|cubic-bezier\([^;{}]+\))$/.test(easing)) {
|
|
129
|
+
easing = 'ease-out';
|
|
130
|
+
this.report('invalid-easing', 'timing.easing');
|
|
131
|
+
}
|
|
132
|
+
else
|
|
133
|
+
this.accept('timing.easing');
|
|
134
|
+
if (duration !== undefined && !valid)
|
|
135
|
+
this.report('invalid-duration', 'timing.duration');
|
|
136
|
+
else
|
|
137
|
+
this.accept('timing.duration');
|
|
138
|
+
this.#clockTiming = Object.freeze({
|
|
139
|
+
...(valid ? { duration } : {}),
|
|
140
|
+
...(value?.easing === undefined ? {} : { easing }),
|
|
141
|
+
});
|
|
142
|
+
this.requestRender();
|
|
143
|
+
}
|
|
144
|
+
get animations() {
|
|
145
|
+
return this.#bindings;
|
|
146
|
+
}
|
|
147
|
+
set animations(value) {
|
|
148
|
+
try {
|
|
149
|
+
if (this.family === 'region' &&
|
|
150
|
+
value?.idle)
|
|
151
|
+
throw new TypeError();
|
|
152
|
+
validateBindings(value, this.family);
|
|
153
|
+
this.#bindings = Object.freeze({ ...value });
|
|
154
|
+
this.accept('animations');
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
this.#bindings = {};
|
|
158
|
+
this.report('invalid-binding', 'animations');
|
|
159
|
+
}
|
|
160
|
+
this.requestRender();
|
|
161
|
+
}
|
|
162
|
+
get revealTargets() {
|
|
163
|
+
return this.#targets;
|
|
164
|
+
}
|
|
165
|
+
set revealTargets(value) {
|
|
166
|
+
if (value?.length === this.#targets.length &&
|
|
167
|
+
value.every((target, i) => target.id === this.#targets[i]?.id &&
|
|
168
|
+
target.element === this.#targets[i]?.element))
|
|
169
|
+
return;
|
|
170
|
+
this.#targets = Object.freeze([...(value ?? [])].slice(0, 100).map((v) => Object.freeze({ ...v })));
|
|
171
|
+
if (value?.length > 100)
|
|
172
|
+
this.report('target-limit', 'revealTargets');
|
|
173
|
+
else
|
|
174
|
+
this.accept('revealTargets');
|
|
175
|
+
this.#settleTargets();
|
|
176
|
+
this.requestRender();
|
|
177
|
+
}
|
|
178
|
+
#settleTargets() {
|
|
179
|
+
if (!this.#batching && this.#work?.driver?.targetsChanged?.(this.#targets))
|
|
180
|
+
this.#finish('end', 'targets-changed');
|
|
181
|
+
}
|
|
182
|
+
update(patch) {
|
|
183
|
+
const priorState = this.state;
|
|
184
|
+
const priorCycle = this.cycle;
|
|
185
|
+
this.#batching = true;
|
|
186
|
+
try {
|
|
187
|
+
this.applyOptions(patch);
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
this.#batching = false;
|
|
191
|
+
}
|
|
192
|
+
if (this.state !== priorState || this.cycle !== priorCycle) {
|
|
193
|
+
this.#revision++;
|
|
194
|
+
this.#finish('cancel', 'superseded');
|
|
195
|
+
ManagedElement.newCycle(this);
|
|
196
|
+
}
|
|
197
|
+
this.#settleTargets();
|
|
198
|
+
this.requestRender();
|
|
199
|
+
}
|
|
200
|
+
get optionNames() {
|
|
201
|
+
return [
|
|
202
|
+
...super.optionNames,
|
|
203
|
+
'state',
|
|
204
|
+
'cycle',
|
|
205
|
+
'timing',
|
|
206
|
+
'animations',
|
|
207
|
+
'revealTargets',
|
|
208
|
+
'delay',
|
|
209
|
+
'minDisplay',
|
|
210
|
+
];
|
|
211
|
+
}
|
|
212
|
+
attributeChangedCallback(name, old, value) {
|
|
213
|
+
if (name === 'tabindex') {
|
|
214
|
+
this.#temporaryTabIndex = false;
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if ((name === 'delay' || name === 'min-display') &&
|
|
218
|
+
value !== null &&
|
|
219
|
+
!(Number.isFinite(Number(value)) && Number(value) >= 0))
|
|
220
|
+
this.invalidOption(name);
|
|
221
|
+
if (!this.#batching &&
|
|
222
|
+
old !== value &&
|
|
223
|
+
(name === 'state' || name === 'cycle')) {
|
|
224
|
+
this.#revision++;
|
|
225
|
+
this.#finish('cancel', 'superseded');
|
|
226
|
+
ManagedElement.newCycle(this);
|
|
227
|
+
}
|
|
228
|
+
super.attributeChangedCallback(name, old, value);
|
|
229
|
+
}
|
|
230
|
+
connectedCallback() {
|
|
231
|
+
super.connectedCallback();
|
|
232
|
+
for (const placeholder of this.querySelectorAll(':scope > [data-dotquilt-placeholder]'))
|
|
233
|
+
placeholder.removeAttribute('hidden');
|
|
234
|
+
if (!this.hasAttribute('role'))
|
|
235
|
+
this.setAttribute('role', 'group');
|
|
236
|
+
if (!this.shadowRoot) {
|
|
237
|
+
// Layers are slots that never receive nodes, so until their stylesheet
|
|
238
|
+
// gives them boxes they render as `display: contents`: the light DOM
|
|
239
|
+
// then lays out exactly as the static markup did.
|
|
240
|
+
const root = this.attachStyledShadow(this.styles, false);
|
|
241
|
+
const layer = (part, className, name) => {
|
|
242
|
+
const element = node(this.ownerDocument, 'slot', {
|
|
243
|
+
name: 'dotquilt-layer',
|
|
244
|
+
part,
|
|
245
|
+
class: className,
|
|
246
|
+
});
|
|
247
|
+
element.append(node(this.ownerDocument, 'slot', name ? { name } : {}));
|
|
248
|
+
if (name) {
|
|
249
|
+
element.inert = true;
|
|
250
|
+
element.setAttribute('aria-hidden', 'true');
|
|
251
|
+
}
|
|
252
|
+
return element;
|
|
253
|
+
};
|
|
254
|
+
const content = layer('content', 'c'), placeholder = layer('placeholder', 'p', 'placeholder'), refresh = layer('refresh-indicator', 'r', 'refresh-indicator');
|
|
255
|
+
// The layers overlap inside their own grid, so the overlay survives app
|
|
256
|
+
// CSS that changes the host's display (e.g. `display: block`).
|
|
257
|
+
const frame = node(this.ownerDocument, 'slot', {
|
|
258
|
+
name: 'dotquilt-layer',
|
|
259
|
+
class: 'f',
|
|
260
|
+
});
|
|
261
|
+
frame.append(content, placeholder, refresh);
|
|
262
|
+
root.append(frame);
|
|
263
|
+
this.#wrappers = [content, placeholder, refresh];
|
|
264
|
+
}
|
|
265
|
+
this.whenStyled(() => {
|
|
266
|
+
for (const style of this.querySelectorAll(':scope > [data-dotquilt-style]'))
|
|
267
|
+
style.remove();
|
|
268
|
+
});
|
|
269
|
+
if (this.#wrappers)
|
|
270
|
+
this.resources?.watch(this.#wrappers[0]);
|
|
271
|
+
this.listen(this, 'focusin', this.#onFocus);
|
|
272
|
+
this.listen(this, 'focusout', this.#onFocus);
|
|
273
|
+
this.listen(this, 'pointerdown', this.#onFocus);
|
|
274
|
+
this.listen(this, 'keydown', this.#onFocus);
|
|
275
|
+
this.listen(this.shadowRoot, 'slotchange', this.#onContentChange);
|
|
276
|
+
this.#contentObserver = new MutationObserver(this.#onContentChange);
|
|
277
|
+
this.#contentObserver.observe(this, {
|
|
278
|
+
childList: true,
|
|
279
|
+
subtree: true,
|
|
280
|
+
characterData: true,
|
|
281
|
+
});
|
|
282
|
+
this.#previous = 'ready';
|
|
283
|
+
this.#participants = undefined;
|
|
284
|
+
this.requestRender();
|
|
285
|
+
}
|
|
286
|
+
disconnectedCallback() {
|
|
287
|
+
super.disconnectedCallback();
|
|
288
|
+
this.#releaseTabIndex();
|
|
289
|
+
this.removeAttribute('data-dotquilt-focus');
|
|
290
|
+
this.#contentObserver?.disconnect();
|
|
291
|
+
this.#contentObserver = undefined;
|
|
292
|
+
this.#finish('cancel', 'removed');
|
|
293
|
+
clearTimeout(this.#timer);
|
|
294
|
+
this.#timer = undefined;
|
|
295
|
+
this.removeAttribute('data-dotquilt-waiting');
|
|
296
|
+
}
|
|
297
|
+
refresh() {
|
|
298
|
+
this.resources?.eligible(true);
|
|
299
|
+
this.#finish('end', 'geometry-changed');
|
|
300
|
+
this.requestRender();
|
|
301
|
+
}
|
|
302
|
+
#onContentChange = (change) => {
|
|
303
|
+
// A simple reveal fades the content wrapper as a whole, so content updates
|
|
304
|
+
// during it (e.g. a framework's follow-up render) must not cut it short.
|
|
305
|
+
// Rich handoffs and row reveals captured content geometry and still settle.
|
|
306
|
+
// The default morph reads geometry once and reveals the whole wrapper, so
|
|
307
|
+
// it carries on like a simple reveal (its marks may land a little off).
|
|
308
|
+
const driver = this.#work?.driver;
|
|
309
|
+
if (this.#work &&
|
|
310
|
+
(driver?.paints || (!driver?.draw && !this.#targets.length)))
|
|
311
|
+
return;
|
|
312
|
+
// Simple wrapper reveals are independent of nested content. Rich/custom
|
|
313
|
+
// plans may capture geometry derived from it, so keep conservative invalidation.
|
|
314
|
+
if (!Array.isArray(change) ||
|
|
315
|
+
this.#work?.driver?.draw ||
|
|
316
|
+
change.some(({ target }) => {
|
|
317
|
+
const element = target.nodeType === 1
|
|
318
|
+
? target
|
|
319
|
+
: target.parentElement;
|
|
320
|
+
return (!element ||
|
|
321
|
+
[element, ...ancestors(element)].find((el) => el.matches('dotquilt-region,dotquilt-text-loader')) === this);
|
|
322
|
+
}))
|
|
323
|
+
this.contentChanged();
|
|
324
|
+
};
|
|
325
|
+
#onFocus = (event) => {
|
|
326
|
+
if (event.type === 'pointerdown')
|
|
327
|
+
this.setAttribute('data-dotquilt-focus', 'pointer');
|
|
328
|
+
else if (event.type === 'keydown')
|
|
329
|
+
this.setAttribute('data-dotquilt-focus', '');
|
|
330
|
+
else if (event.type === 'focusout' &&
|
|
331
|
+
event.relatedTarget !== this) {
|
|
332
|
+
this.removeAttribute('data-dotquilt-focus');
|
|
333
|
+
this.#releaseTabIndex();
|
|
334
|
+
}
|
|
335
|
+
if (event.type === 'focusin' && this.#work && activeWithin(this))
|
|
336
|
+
this.#finish('end', 'focus');
|
|
337
|
+
};
|
|
338
|
+
#releaseTabIndex() {
|
|
339
|
+
if (this.#temporaryTabIndex) {
|
|
340
|
+
this.#temporaryTabIndex = false;
|
|
341
|
+
this.removeAttribute('tabindex');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
refreshParticipants() { }
|
|
345
|
+
render() {
|
|
346
|
+
const w = this.#wrappers;
|
|
347
|
+
if (!w)
|
|
348
|
+
return;
|
|
349
|
+
const [content, placeholder, refresh] = w;
|
|
350
|
+
const revision = this.#revision;
|
|
351
|
+
const requested = this.state;
|
|
352
|
+
const attribute = this.getAttribute('state');
|
|
353
|
+
const invalid = attribute !== null && attribute !== requested;
|
|
354
|
+
const waiting = this.hasAttribute('data-dotquilt-waiting');
|
|
355
|
+
const first = !this.#rendered;
|
|
356
|
+
this.#rendered = true;
|
|
357
|
+
let state = requested;
|
|
358
|
+
// Minimum display: a placeholder that showed stays until min-display.
|
|
359
|
+
if (requested === 'ready' &&
|
|
360
|
+
this.#previous === 'pending' &&
|
|
361
|
+
!waiting &&
|
|
362
|
+
this.#shownAt !== undefined) {
|
|
363
|
+
const left = this.#shownAt + this.minDisplay - now(this);
|
|
364
|
+
if (left > 0) {
|
|
365
|
+
this.#later(left, () => this.requestRender());
|
|
366
|
+
state = 'pending';
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
// Delay: entering pending, the placeholder stays hidden for `delay`; a
|
|
370
|
+
// response inside it skips the placeholder and its handoff altogether.
|
|
371
|
+
let skipHandoff = false;
|
|
372
|
+
if (state === 'pending' && (this.#previous !== 'pending' || first)) {
|
|
373
|
+
if (this.delay > 0 && !(first && this.#inPlace)) {
|
|
374
|
+
this.setAttribute('data-dotquilt-waiting', '');
|
|
375
|
+
this.#shownAt = undefined;
|
|
376
|
+
this.#later(this.delay, () => {
|
|
377
|
+
this.removeAttribute('data-dotquilt-waiting');
|
|
378
|
+
this.#shownAt = now(this);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
else if (!waiting)
|
|
382
|
+
this.#shownAt = now(this);
|
|
383
|
+
}
|
|
384
|
+
else if (state !== 'pending' && waiting) {
|
|
385
|
+
clearTimeout(this.#timer);
|
|
386
|
+
this.removeAttribute('data-dotquilt-waiting');
|
|
387
|
+
skipHandoff = true;
|
|
388
|
+
}
|
|
389
|
+
if (invalid)
|
|
390
|
+
this.invalidOption('state');
|
|
391
|
+
if (revision !== this.#revision)
|
|
392
|
+
return;
|
|
393
|
+
this.toggleAttribute('data-dotquilt-disabled', invalid);
|
|
394
|
+
if (this.#work) {
|
|
395
|
+
if (!this.canAnimate() || this.#work.driver?.restricted?.())
|
|
396
|
+
this.#finish('end', 'restricted');
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (state === 'pending' &&
|
|
400
|
+
this.#previous !== 'pending' &&
|
|
401
|
+
activeWithin(content)) {
|
|
402
|
+
// A permanent negative tabindex also excludes slotted controls from Tab.
|
|
403
|
+
if (!this.hasAttribute('tabindex')) {
|
|
404
|
+
this.setAttribute('tabindex', '0');
|
|
405
|
+
this.#temporaryTabIndex = true;
|
|
406
|
+
}
|
|
407
|
+
this.focus({ preventScroll: true });
|
|
408
|
+
// A before-hide transfer stays visible even when initiated by a pointer.
|
|
409
|
+
if (this.isConnected && this.ownerDocument.activeElement === this)
|
|
410
|
+
this.setAttribute('data-dotquilt-focus', '');
|
|
411
|
+
else {
|
|
412
|
+
this.removeAttribute('data-dotquilt-focus');
|
|
413
|
+
this.#releaseTabIndex();
|
|
414
|
+
}
|
|
415
|
+
if (revision !== this.#revision || !this.isConnected)
|
|
416
|
+
return;
|
|
417
|
+
if (this.ownerDocument.activeElement !== this)
|
|
418
|
+
this.report('focus-fallback-unavailable', 'state');
|
|
419
|
+
}
|
|
420
|
+
if (revision !== this.#revision)
|
|
421
|
+
return;
|
|
422
|
+
const prior = this.#previous;
|
|
423
|
+
this.#previous = state;
|
|
424
|
+
content.inert = state === 'pending';
|
|
425
|
+
content.setAttribute('aria-busy', String(state !== 'ready'));
|
|
426
|
+
if (state === 'pending')
|
|
427
|
+
content.setAttribute('aria-hidden', 'true');
|
|
428
|
+
else
|
|
429
|
+
content.removeAttribute('aria-hidden');
|
|
430
|
+
this.setAttribute('data-presentation', state);
|
|
431
|
+
this.placeholderChanged(placeholder.firstElementChild, state);
|
|
432
|
+
const indicator = refresh.firstElementChild;
|
|
433
|
+
if (state === 'refreshing' &&
|
|
434
|
+
!content.firstElementChild.assignedNodes().length) {
|
|
435
|
+
if (!indicator.firstChild)
|
|
436
|
+
indicator.append(node(this.ownerDocument, 'span', { class: 'fallback' }));
|
|
437
|
+
this.report('missing-content', 'state');
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
// The built-in cue is the slot's fallback: an app's own indicator,
|
|
441
|
+
// slotted in, replaces it.
|
|
442
|
+
const cue = state === 'refreshing' ? this.refreshCue() : undefined;
|
|
443
|
+
if (cue) {
|
|
444
|
+
if (indicator.firstChild !== cue)
|
|
445
|
+
indicator.replaceChildren(cue);
|
|
446
|
+
if (prior !== 'refreshing')
|
|
447
|
+
this.refreshStarted(cue);
|
|
448
|
+
}
|
|
449
|
+
else if (indicator.firstChild)
|
|
450
|
+
indicator.replaceChildren();
|
|
451
|
+
}
|
|
452
|
+
if (revision !== this.#revision)
|
|
453
|
+
return;
|
|
454
|
+
if (state !== 'ready') {
|
|
455
|
+
if (this.#settled) {
|
|
456
|
+
this.ownActivity.started = undefined;
|
|
457
|
+
this.#settled = false;
|
|
458
|
+
}
|
|
459
|
+
// Rich placeholders rebuild when the loading state or cycle changes;
|
|
460
|
+
// other re-renders (e.g. an ancestor class change) leave them alone,
|
|
461
|
+
// since they receive their own size and style notifications.
|
|
462
|
+
const participants = `${state}|${this.cycle ?? ''}`;
|
|
463
|
+
if (participants !== this.#participants) {
|
|
464
|
+
this.#participants = participants;
|
|
465
|
+
this.refreshParticipants();
|
|
466
|
+
}
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
this.#participants = undefined;
|
|
470
|
+
if (prior === 'pending' && !skipHandoff)
|
|
471
|
+
this.#start(revision, w);
|
|
472
|
+
else
|
|
473
|
+
this.#settled = true;
|
|
474
|
+
}
|
|
475
|
+
/** Runs `task` after `ms`, replacing any earlier timer. */
|
|
476
|
+
#later(ms, task) {
|
|
477
|
+
clearTimeout(this.#timer);
|
|
478
|
+
this.#timer = setTimeout(() => {
|
|
479
|
+
this.#timer = undefined;
|
|
480
|
+
task();
|
|
481
|
+
}, ms);
|
|
482
|
+
}
|
|
483
|
+
#start(revision, [content, placeholder]) {
|
|
484
|
+
const timing = this.timing;
|
|
485
|
+
const easing = timing.easing ?? 'ease-out';
|
|
486
|
+
const source = this.handoffSource();
|
|
487
|
+
const binding = this.#bindings.handoff ??
|
|
488
|
+
this.preset?.animations?.handoff ??
|
|
489
|
+
source.binding;
|
|
490
|
+
let duration = 0;
|
|
491
|
+
let driver;
|
|
492
|
+
try {
|
|
493
|
+
driver = runHandoff(source.prepare, binding, {
|
|
494
|
+
host: source.host,
|
|
495
|
+
content,
|
|
496
|
+
placeholder,
|
|
497
|
+
targets: this.#targets,
|
|
498
|
+
duration: timing.duration,
|
|
499
|
+
current: () => this.#work?.revision === revision,
|
|
500
|
+
own: (animation) => {
|
|
501
|
+
if (this.#work?.revision === revision)
|
|
502
|
+
this.#work.animations.push(animation);
|
|
503
|
+
else
|
|
504
|
+
animation.cancel();
|
|
505
|
+
},
|
|
506
|
+
report: (code) => this.report(code, 'animations'),
|
|
507
|
+
});
|
|
508
|
+
duration = driver.duration;
|
|
509
|
+
if (!Number.isFinite(duration) || duration < 0)
|
|
510
|
+
throw new TypeError();
|
|
511
|
+
}
|
|
512
|
+
catch {
|
|
513
|
+
duration = 0;
|
|
514
|
+
driver?.dispose();
|
|
515
|
+
driver = undefined;
|
|
516
|
+
this.report('animation-failed', 'animations');
|
|
517
|
+
}
|
|
518
|
+
if (revision !== this.#revision || !this.isConnected) {
|
|
519
|
+
driver?.dispose();
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
// The handoff ignores the idle's 4-second window: it is short, and it
|
|
523
|
+
// happens because the data arrived (owner decision 3, 2026-11-19). A
|
|
524
|
+
// requested handoff longer than the motion limit is still skipped.
|
|
525
|
+
if (!this.canAnimate() ||
|
|
526
|
+
driver?.restricted?.() ||
|
|
527
|
+
duration > motionLimit ||
|
|
528
|
+
activeWithin(content))
|
|
529
|
+
duration = 0;
|
|
530
|
+
const detail = {
|
|
531
|
+
cycle: this.cycle,
|
|
532
|
+
handoffId: ++this.#serial,
|
|
533
|
+
animation: binding?.id ?? (driver?.paints ? 'dotquilt/morph' : source.animation),
|
|
534
|
+
};
|
|
535
|
+
this.#work = {
|
|
536
|
+
revision,
|
|
537
|
+
detail,
|
|
538
|
+
started: now(this),
|
|
539
|
+
duration,
|
|
540
|
+
animations: [],
|
|
541
|
+
driver,
|
|
542
|
+
};
|
|
543
|
+
this.setAttribute('data-presentation', 'handoff');
|
|
544
|
+
this.refreshParticipants();
|
|
545
|
+
emit(this, 'dotquilt-handoff-start', detail);
|
|
546
|
+
if (!this.#work ||
|
|
547
|
+
this.#work.revision !== revision ||
|
|
548
|
+
revision !== this.#revision ||
|
|
549
|
+
!this.isConnected)
|
|
550
|
+
return;
|
|
551
|
+
if (!duration) {
|
|
552
|
+
this.#finish('end', 'immediate');
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
// Synchronous start handlers may change restrictions.
|
|
556
|
+
if (!this.canAnimate() || driver?.restricted?.()) {
|
|
557
|
+
this.#finish('end', 'restricted');
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
try {
|
|
561
|
+
const { outgoing, incoming, extra } = driver?.paints
|
|
562
|
+
? this.#heldHandoff(placeholder, content, duration)
|
|
563
|
+
: !binding &&
|
|
564
|
+
(source.animation === 'dotquilt/dissolve' ||
|
|
565
|
+
source.animation === 'dotquilt/fade')
|
|
566
|
+
? this.#specHandoff(placeholder, content, duration, source.animation)
|
|
567
|
+
: {
|
|
568
|
+
// Custom and dense sources keep one shared clock: they draw in
|
|
569
|
+
// step with the content's progress. They draw their own marks,
|
|
570
|
+
// and the chart's leave where its line wipes in, so the layer
|
|
571
|
+
// holds at full strength and only lets go at the very end
|
|
572
|
+
// (fading it all the way, marks landed at half strength). The
|
|
573
|
+
// hold is in time, so the easing only shapes the last step.
|
|
574
|
+
outgoing: placeholder.animate({ opacity: [1, 1, 0], offset: [0, 0.9, 1], easing }, { duration, fill: 'both' }),
|
|
575
|
+
incoming: content.animate({ opacity: [0, 1] }, { duration, easing, fill: 'both' }),
|
|
576
|
+
extra: [],
|
|
577
|
+
};
|
|
578
|
+
this.#work.animations.push(outgoing, incoming, ...extra);
|
|
579
|
+
this.#work.incoming = incoming;
|
|
580
|
+
driver?.attach?.(outgoing, incoming);
|
|
581
|
+
outgoing.onfinish = () => {
|
|
582
|
+
if (this.#work?.revision === revision)
|
|
583
|
+
this.#finish('end', 'complete');
|
|
584
|
+
};
|
|
585
|
+
driver?.draw?.(0);
|
|
586
|
+
// A view transition (React's <ViewTransition>, or startViewTransition)
|
|
587
|
+
// shows frozen snapshots while it runs. Hold the handoff's first frame
|
|
588
|
+
// until it finishes, so the reveal plays where people can see it
|
|
589
|
+
// instead of jumping ahead when the snapshots lift.
|
|
590
|
+
const transition = this.ownerDocument.activeViewTransition;
|
|
591
|
+
if (transition) {
|
|
592
|
+
const work = this.#work;
|
|
593
|
+
for (const animation of work.animations)
|
|
594
|
+
animation.pause();
|
|
595
|
+
const go = () => {
|
|
596
|
+
if (this.#work !== work || work.revision !== revision)
|
|
597
|
+
return;
|
|
598
|
+
work.started = now(this);
|
|
599
|
+
for (const animation of work.animations)
|
|
600
|
+
animation.play();
|
|
601
|
+
driver?.activate(() => this.frame());
|
|
602
|
+
};
|
|
603
|
+
transition.finished.then(go, go);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (this.#work?.revision === revision)
|
|
607
|
+
driver?.activate(() => this.frame());
|
|
608
|
+
}
|
|
609
|
+
catch {
|
|
610
|
+
this.report('animation-failed', 'animations');
|
|
611
|
+
this.#finish('end', 'fallback');
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* The driver paints both layers itself (morph.ts); these only keep the
|
|
616
|
+
* handoff's clock, so the layers stay fully opaque under its masks.
|
|
617
|
+
*/
|
|
618
|
+
#heldHandoff(placeholder, content, duration) {
|
|
619
|
+
const timing = { duration, fill: 'both' };
|
|
620
|
+
return {
|
|
621
|
+
outgoing: placeholder.animate({ opacity: [1, 1] }, timing),
|
|
622
|
+
incoming: content.animate({ opacity: [1, 1] }, timing),
|
|
623
|
+
extra: [],
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* design/SPEC.md: content fades in while a slight blur clears and rises
|
|
628
|
+
* into place on a longer settle. Skeleton marks leave by themselves, so
|
|
629
|
+
* their layer holds until the end; other placeholders fade with the content.
|
|
630
|
+
* Every part scales with `duration`, and the handoff ends after the rise.
|
|
631
|
+
*/
|
|
632
|
+
#specHandoff(placeholder, content, duration, animation) {
|
|
633
|
+
const scale = duration / handoff.duration;
|
|
634
|
+
const fade = (handoff.contentFade * scale) / duration;
|
|
635
|
+
const timing = this.timing;
|
|
636
|
+
const outgoing = placeholder.animate(animation === 'dotquilt/dissolve'
|
|
637
|
+
? { opacity: [1, 1, 0], offset: [0, 0.9, 1] }
|
|
638
|
+
: {
|
|
639
|
+
opacity: [1, 0, 0],
|
|
640
|
+
offset: [0, fade, 1],
|
|
641
|
+
easing: timing.easing ?? curves.fade,
|
|
642
|
+
}, { duration, fill: 'both' });
|
|
643
|
+
const incoming = content.animate({
|
|
644
|
+
opacity: [0, 1],
|
|
645
|
+
filter: [`blur(${handoff.blurPx}px)`, 'blur(0px)'],
|
|
646
|
+
}, {
|
|
647
|
+
duration: handoff.contentFade * scale,
|
|
648
|
+
easing: timing.easing ?? curves.fade,
|
|
649
|
+
fill: 'both',
|
|
650
|
+
});
|
|
651
|
+
const rise = content.animate({ translate: [`0 ${handoff.risePx}px`, '0 0'] }, {
|
|
652
|
+
duration: handoff.contentRise * scale,
|
|
653
|
+
easing: timing.easing ?? curves.settle,
|
|
654
|
+
fill: 'both',
|
|
655
|
+
});
|
|
656
|
+
return { outgoing, incoming, extra: [rise] };
|
|
657
|
+
}
|
|
658
|
+
frame() {
|
|
659
|
+
const work = this.#work;
|
|
660
|
+
if (!work)
|
|
661
|
+
return;
|
|
662
|
+
if (!this.canAnimate() || work.driver?.restricted?.()) {
|
|
663
|
+
this.#finish('end', 'restricted');
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
const p = Math.min(1, (now(this) - work.started) / work.duration);
|
|
667
|
+
try {
|
|
668
|
+
work.driver?.draw?.(p, clamp(work.incoming?.effect?.getComputedTiming().progress ?? p));
|
|
669
|
+
}
|
|
670
|
+
catch {
|
|
671
|
+
this.report('animation-failed', 'animations');
|
|
672
|
+
this.#finish('end', 'fallback');
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (p >= 1)
|
|
676
|
+
this.#finish('end', 'complete');
|
|
677
|
+
}
|
|
678
|
+
#finish(outcome, reason) {
|
|
679
|
+
const work = this.#work;
|
|
680
|
+
if (!work)
|
|
681
|
+
return;
|
|
682
|
+
this.#work = undefined;
|
|
683
|
+
work.driver?.dispose();
|
|
684
|
+
for (const animation of work.animations) {
|
|
685
|
+
animation.onfinish = null;
|
|
686
|
+
animation.cancel();
|
|
687
|
+
}
|
|
688
|
+
this.settled();
|
|
689
|
+
if (outcome === 'end' &&
|
|
690
|
+
work.revision === this.#revision &&
|
|
691
|
+
this.state === 'ready') {
|
|
692
|
+
this.setAttribute('data-presentation', 'ready');
|
|
693
|
+
this.#settled = true;
|
|
694
|
+
this.clearDeadline();
|
|
695
|
+
}
|
|
696
|
+
emit(this, `dotquilt-handoff-${outcome}`, { ...work.detail, reason });
|
|
697
|
+
}
|
|
698
|
+
}
|