panelui-native 0.78.0 → 0.79.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/lib/module/components/accordion/index.js +13 -1
- package/lib/module/components/accordion/index.js.map +1 -1
- package/lib/module/components/map/index.js +63 -39
- package/lib/module/components/map/index.js.map +1 -1
- package/lib/module/components/map/map-children.js +54 -0
- package/lib/module/components/map/map-children.js.map +1 -0
- package/lib/module/components/map/maplibre.js +31 -3
- package/lib/module/components/map/maplibre.js.map +1 -1
- package/lib/module/components/markdown-editor/index.js +288 -34
- package/lib/module/components/markdown-editor/index.js.map +1 -1
- package/lib/module/components/markdown-editor/markdown-transforms.js +272 -9
- package/lib/module/components/markdown-editor/markdown-transforms.js.map +1 -1
- package/lib/module/components/marquee/index.js +119 -46
- package/lib/module/components/marquee/index.js.map +1 -1
- package/lib/module/components/panelside/index.js +162 -34
- package/lib/module/components/panelside/index.js.map +1 -1
- package/lib/module/components/progress-button/index.js +279 -52
- package/lib/module/components/progress-button/index.js.map +1 -1
- package/lib/module/components/progress-button/progress-button-hold.js +40 -6
- package/lib/module/components/progress-button/progress-button-hold.js.map +1 -1
- package/lib/module/components/theme-selector/index.js +239 -0
- package/lib/module/components/theme-selector/index.js.map +1 -0
- package/lib/module/components/theme-selector/theme-preview.js +320 -0
- package/lib/module/components/theme-selector/theme-preview.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/components/accordion/index.d.ts.map +1 -1
- package/lib/typescript/src/components/map/index.d.ts +8 -4
- package/lib/typescript/src/components/map/index.d.ts.map +1 -1
- package/lib/typescript/src/components/map/map-children.d.ts +41 -0
- package/lib/typescript/src/components/map/map-children.d.ts.map +1 -0
- package/lib/typescript/src/components/map/maplibre.d.ts +8 -4
- package/lib/typescript/src/components/map/maplibre.d.ts.map +1 -1
- package/lib/typescript/src/components/markdown-editor/index.d.ts +64 -5
- package/lib/typescript/src/components/markdown-editor/index.d.ts.map +1 -1
- package/lib/typescript/src/components/markdown-editor/markdown-transforms.d.ts +33 -5
- package/lib/typescript/src/components/markdown-editor/markdown-transforms.d.ts.map +1 -1
- package/lib/typescript/src/components/marquee/index.d.ts.map +1 -1
- package/lib/typescript/src/components/panelside/index.d.ts +79 -4
- package/lib/typescript/src/components/panelside/index.d.ts.map +1 -1
- package/lib/typescript/src/components/progress-button/index.d.ts +29 -13
- package/lib/typescript/src/components/progress-button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/progress-button/progress-button-hold.d.ts +26 -6
- package/lib/typescript/src/components/progress-button/progress-button-hold.d.ts.map +1 -1
- package/lib/typescript/src/components/theme-selector/index.d.ts +107 -0
- package/lib/typescript/src/components/theme-selector/index.d.ts.map +1 -0
- package/lib/typescript/src/components/theme-selector/theme-preview.d.ts +32 -0
- package/lib/typescript/src/components/theme-selector/theme-preview.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/accordion/index.tsx +13 -0
- package/src/components/map/index.tsx +63 -36
- package/src/components/map/map-children.ts +66 -0
- package/src/components/map/maplibre.ts +32 -4
- package/src/components/markdown-editor/index.tsx +413 -35
- package/src/components/markdown-editor/markdown-transforms.ts +274 -10
- package/src/components/marquee/index.tsx +128 -55
- package/src/components/panelside/index.tsx +179 -40
- package/src/components/progress-button/index.tsx +264 -45
- package/src/components/progress-button/progress-button-hold.ts +37 -6
- package/src/components/theme-selector/index.tsx +281 -0
- package/src/components/theme-selector/theme-preview.tsx +205 -0
- package/src/index.ts +15 -0
|
@@ -42,17 +42,49 @@
|
|
|
42
42
|
* still has to be legible — a control that asks you to wait and shows nothing
|
|
43
43
|
* is a broken button — so this is a coarser indicator, not the absence of one.
|
|
44
44
|
*/
|
|
45
|
-
import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
45
|
+
import { Children, createContext, forwardRef, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
46
46
|
import { Pressable, View } from 'react-native';
|
|
47
|
-
import Animated, { Easing, cancelAnimation, runOnJS, useAnimatedReaction, useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
47
|
+
import Animated, { Easing, cancelAnimation, runOnJS, runOnUI, useAnimatedReaction, useAnimatedStyle, useReducedMotion, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
|
|
48
48
|
import { tv } from 'tailwind-variants';
|
|
49
|
+
import { useCSSVariable } from 'uniwind';
|
|
50
|
+
import { CheckIcon, IconColorProvider } from "../../icons/index.js";
|
|
49
51
|
import { Text, textChildren } from "../../primitives/text.js";
|
|
50
52
|
import { impactKnock, selectionTick } from "../../utils/haptics.js";
|
|
51
|
-
import { DEFAULT_AUTO_RESET_DELAY,
|
|
53
|
+
import { DEFAULT_AUTO_RESET_DELAY, fillDuration, releaseDuration, resolveHoldDuration } from "./progress-button-hold.js";
|
|
52
54
|
|
|
53
55
|
/** How many steps the reduced-motion fill advances in. */
|
|
54
56
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
55
57
|
const REDUCED_STEPS = 5;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The arrival of the completed drawing.
|
|
61
|
+
*
|
|
62
|
+
* A spring rather than a timing, and slightly overshooting: the fill has just
|
|
63
|
+
* spent two seconds moving at a constant rate, and something that lands with a
|
|
64
|
+
* little weight is what tells the reader the waiting part is over.
|
|
65
|
+
*/
|
|
66
|
+
const DONE_SPRING = {
|
|
67
|
+
damping: 14,
|
|
68
|
+
stiffness: 220,
|
|
69
|
+
mass: 0.6
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** How long the completed drawing takes to leave again on a reset. */
|
|
73
|
+
const DONE_EXIT = 140;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Which token the tick is drawn in, per variant.
|
|
77
|
+
*
|
|
78
|
+
* It sits on the finished fill, so it takes that fill's own foreground rather
|
|
79
|
+
* than the button's — the same pairing `fillLabel` uses, which is what keeps
|
|
80
|
+
* the contrast right in both themes without a hardcoded colour.
|
|
81
|
+
*/
|
|
82
|
+
const DONE_TINT = {
|
|
83
|
+
primary: '--color-primary-foreground',
|
|
84
|
+
secondary: '--color-background',
|
|
85
|
+
destructive: '--color-destructive-solid-foreground',
|
|
86
|
+
success: '--color-success-solid-foreground'
|
|
87
|
+
};
|
|
56
88
|
const progressButtonVariants = tv({
|
|
57
89
|
slots: {
|
|
58
90
|
/*
|
|
@@ -64,7 +96,22 @@ const progressButtonVariants = tv({
|
|
|
64
96
|
* a rectangle sliding out from under the button rather than as the button
|
|
65
97
|
* filling up.
|
|
66
98
|
*/
|
|
67
|
-
|
|
99
|
+
/*
|
|
100
|
+
* Every variant rests on the same secondary surface, and `variant` decides
|
|
101
|
+
* only what colour comes across it.
|
|
102
|
+
*
|
|
103
|
+
* Drawn as outlines they were four different buttons before anything had
|
|
104
|
+
* happened, and the one thing they all do — wait to be held — was the
|
|
105
|
+
* thing the drawing did not say. A solid ground says it: the button is
|
|
106
|
+
* unfilled, and the fill is what the hold produces.
|
|
107
|
+
*
|
|
108
|
+
* The variant is still legible at rest, because the label carries its
|
|
109
|
+
* colour. That is the half worth keeping — a destructive hold should not
|
|
110
|
+
* look like an ordinary one before it is touched — and it is also the half
|
|
111
|
+
* that survives the wipe, since the fill covers the ground the label was
|
|
112
|
+
* standing on and the second copy takes over.
|
|
113
|
+
*/
|
|
114
|
+
root: 'relative overflow-hidden rounded-full border border-transparent bg-secondary',
|
|
68
115
|
/*
|
|
69
116
|
* The row inside the button. It is separate from `root` because the fill
|
|
70
117
|
* has to sit over the whole button including its padding — a wipe that
|
|
@@ -80,25 +127,21 @@ const progressButtonVariants = tv({
|
|
|
80
127
|
variants: {
|
|
81
128
|
variant: {
|
|
82
129
|
primary: {
|
|
83
|
-
root: 'border-primary bg-transparent',
|
|
84
130
|
label: 'text-primary',
|
|
85
131
|
fill: 'bg-primary',
|
|
86
132
|
fillLabel: 'text-primary-foreground'
|
|
87
133
|
},
|
|
88
134
|
secondary: {
|
|
89
|
-
root: 'border-transparent bg-secondary',
|
|
90
135
|
label: 'text-secondary-foreground',
|
|
91
136
|
fill: 'bg-foreground',
|
|
92
137
|
fillLabel: 'text-background'
|
|
93
138
|
},
|
|
94
139
|
destructive: {
|
|
95
|
-
root: 'border-destructive bg-transparent',
|
|
96
140
|
label: 'text-destructive',
|
|
97
141
|
fill: 'bg-destructive',
|
|
98
142
|
fillLabel: 'text-destructive-solid-foreground'
|
|
99
143
|
},
|
|
100
144
|
success: {
|
|
101
|
-
root: 'border-success bg-transparent',
|
|
102
145
|
label: 'text-success',
|
|
103
146
|
fill: 'bg-success',
|
|
104
147
|
fillLabel: 'text-success-solid-foreground'
|
|
@@ -195,12 +238,25 @@ const ProgressButtonRoot = /*#__PURE__*/forwardRef(function ProgressButtonRoot({
|
|
|
195
238
|
const duration = resolveHoldDuration(holdDuration);
|
|
196
239
|
const reducedMotion = useReducedMotion();
|
|
197
240
|
const progress = useSharedValue(0);
|
|
241
|
+
const done = useSharedValue(0);
|
|
198
242
|
const [width, setWidth] = useState(0);
|
|
199
243
|
const [internalCompleted, setInternalCompleted] = useState(false);
|
|
200
244
|
const resetTimer = useRef(null);
|
|
201
245
|
const isControlled = completedProp !== undefined;
|
|
202
246
|
const completed = isControlled ? completedProp : internalCompleted;
|
|
247
|
+
|
|
248
|
+
/*
|
|
249
|
+
* The reaction below watches a shared value, and a shared value can reach the
|
|
250
|
+
* end for reasons other than a hold — a controlled button being told it is
|
|
251
|
+
* complete fills instantly. Read from a ref rather than from `completed` so
|
|
252
|
+
* the guard sees the current answer without the reaction being rebuilt.
|
|
253
|
+
*/
|
|
254
|
+
const completedRef = useRef(completed);
|
|
255
|
+
completedRef.current = completed;
|
|
203
256
|
const finish = useCallback(() => {
|
|
257
|
+
// Already complete: the fill was set from outside, and firing the action
|
|
258
|
+
// again would run it a second time for something the reader did not do.
|
|
259
|
+
if (completedRef.current) return;
|
|
204
260
|
if (!isControlled) setInternalCompleted(true);
|
|
205
261
|
onCompletedChange?.(true);
|
|
206
262
|
onComplete?.();
|
|
@@ -219,46 +275,92 @@ const ProgressButtonRoot = /*#__PURE__*/forwardRef(function ProgressButtonRoot({
|
|
|
219
275
|
useAnimatedReaction(() => progress.value >= 1, (full, was) => {
|
|
220
276
|
if (full && !was) runOnJS(finish)();
|
|
221
277
|
});
|
|
278
|
+
|
|
279
|
+
/*
|
|
280
|
+
* Both directions are started on the UI thread, and that is not a detail.
|
|
281
|
+
*
|
|
282
|
+
* A shared value animated on the UI thread does not report back to
|
|
283
|
+
* JavaScript, so `progress.value` read from a press handler is the value
|
|
284
|
+
* from before the hold began — zero. The release computed from it either did
|
|
285
|
+
* nothing or, worse, `cancelAnimation` wrote that stale zero back and the
|
|
286
|
+
* fill vanished on touch-up instead of travelling home.
|
|
287
|
+
*
|
|
288
|
+
* `runOnUI` puts the read where the value actually lives.
|
|
289
|
+
*/
|
|
222
290
|
const begin = useCallback(() => {
|
|
223
291
|
if (disabled || completed) return;
|
|
224
292
|
if (haptics) selectionTick();
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
* with nothing on screen to say why.
|
|
232
|
-
*/
|
|
293
|
+
runOnUI(() => {
|
|
294
|
+
'worklet';
|
|
295
|
+
|
|
296
|
+
cancelAnimation(progress);
|
|
297
|
+
const from = progress.value;
|
|
298
|
+
if (from >= 1) return;
|
|
233
299
|
progress.value = withTiming(1, {
|
|
234
|
-
|
|
235
|
-
|
|
300
|
+
// The distance still ahead, at the fill's own rate — so a press that
|
|
301
|
+
// catches the fill on its way back carries on from there rather than
|
|
302
|
+
// restarting the clock.
|
|
303
|
+
duration: fillDuration(from, duration),
|
|
304
|
+
/*
|
|
305
|
+
* Linear. A fill is constant motion, and an eased one misreports the
|
|
306
|
+
* wait: it races the first half and crawls the second, or the reverse.
|
|
307
|
+
*
|
|
308
|
+
* Under reduced motion it steps instead, and is still a real
|
|
309
|
+
* indicator — what that setting is about is continuous movement, not
|
|
310
|
+
* the button saying how much longer to wait. Take that away and the
|
|
311
|
+
* control asks for a hold with nothing on screen to say why.
|
|
312
|
+
*/
|
|
313
|
+
easing: reducedMotion ? Easing.steps(REDUCED_STEPS, true) : Easing.linear
|
|
236
314
|
});
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
// Linear. A fill is constant motion, and an eased one misreports the wait:
|
|
240
|
-
// it races the first half and crawls the second, or the reverse.
|
|
241
|
-
progress.value = withTiming(1, {
|
|
242
|
-
duration,
|
|
243
|
-
easing: Easing.linear
|
|
244
|
-
});
|
|
315
|
+
})();
|
|
245
316
|
}, [disabled, completed, haptics, progress, reducedMotion, duration]);
|
|
317
|
+
|
|
318
|
+
/*
|
|
319
|
+
* The fill, played backwards.
|
|
320
|
+
*
|
|
321
|
+
* Same rate, same easing, same stepping under reduced motion — only the
|
|
322
|
+
* direction differs. Let go at nine tenths of a two-second hold and the fill
|
|
323
|
+
* takes 1.8 seconds to travel home, which is the 1.8 seconds it took to get
|
|
324
|
+
* there. A fill that vanishes has been deleted; a fill that travels back has
|
|
325
|
+
* been let go, and telling those apart is the whole reason the wait is drawn
|
|
326
|
+
* on the button.
|
|
327
|
+
*
|
|
328
|
+
* Every path that empties the fill goes through here — a hold let go, an
|
|
329
|
+
* `autoReset` landing, a controlled button told it is no longer complete.
|
|
330
|
+
* They were three separate assignments and two of them snapped.
|
|
331
|
+
*/
|
|
332
|
+
const rewind = useCallback(() => {
|
|
333
|
+
runOnUI(() => {
|
|
334
|
+
'worklet';
|
|
335
|
+
|
|
336
|
+
cancelAnimation(progress);
|
|
337
|
+
const from = progress.value;
|
|
338
|
+
if (from <= 0) {
|
|
339
|
+
progress.value = 0;
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
progress.value = withTiming(0, {
|
|
343
|
+
duration: releaseDuration(from, duration),
|
|
344
|
+
easing: reducedMotion ? Easing.steps(REDUCED_STEPS, true) : Easing.linear
|
|
345
|
+
});
|
|
346
|
+
})();
|
|
347
|
+
}, [progress, duration, reducedMotion]);
|
|
246
348
|
const abandon = useCallback(() => {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
349
|
+
/*
|
|
350
|
+
* A completed hold has nothing to abandon. Without this the fill drains on
|
|
351
|
+
* the release that follows a successful hold — the button empties, looks
|
|
352
|
+
* untouched, and then refuses every press after it, because `begin` bails
|
|
353
|
+
* on a completed button. That combination is a control that has silently
|
|
354
|
+
* stopped working.
|
|
355
|
+
*/
|
|
356
|
+
if (completedRef.current) return;
|
|
357
|
+
rewind();
|
|
358
|
+
}, [rewind]);
|
|
256
359
|
const reset = useCallback(() => {
|
|
257
|
-
|
|
258
|
-
progress.value = 0;
|
|
360
|
+
rewind();
|
|
259
361
|
if (!isControlled) setInternalCompleted(false);
|
|
260
362
|
onCompletedChange?.(false);
|
|
261
|
-
}, [
|
|
363
|
+
}, [rewind, isControlled, onCompletedChange]);
|
|
262
364
|
useEffect(() => {
|
|
263
365
|
if (!completed || !autoReset) return;
|
|
264
366
|
resetTimer.current = setTimeout(reset, autoResetDelay);
|
|
@@ -268,33 +370,77 @@ const ProgressButtonRoot = /*#__PURE__*/forwardRef(function ProgressButtonRoot({
|
|
|
268
370
|
};
|
|
269
371
|
}, [completed, autoReset, autoResetDelay, reset]);
|
|
270
372
|
|
|
271
|
-
|
|
272
|
-
|
|
373
|
+
/*
|
|
374
|
+
* The fill follows the completed state, in both directions.
|
|
375
|
+
*
|
|
376
|
+
* A controlled button told it is complete fills without a hold, and one told
|
|
377
|
+
* it is no longer complete empties — otherwise the next hold would start from
|
|
378
|
+
* a bar that is already full.
|
|
379
|
+
*/
|
|
273
380
|
useEffect(() => {
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
381
|
+
if (completed) {
|
|
382
|
+
cancelAnimation(progress);
|
|
383
|
+
progress.value = 1;
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
rewind();
|
|
387
|
+
}, [completed, progress, rewind]);
|
|
388
|
+
|
|
389
|
+
/*
|
|
390
|
+
* And the completed drawing follows it too. Under reduced motion it is a
|
|
391
|
+
* swap: what that setting is about is movement, and a tick that grows is
|
|
392
|
+
* movement with nothing to report.
|
|
393
|
+
*/
|
|
394
|
+
useEffect(() => {
|
|
395
|
+
if (reducedMotion) {
|
|
396
|
+
done.value = completed ? 1 : 0;
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
done.value = completed ? withSpring(1, DONE_SPRING) : withTiming(0, {
|
|
400
|
+
duration: DONE_EXIT
|
|
401
|
+
});
|
|
402
|
+
}, [completed, done, reducedMotion]);
|
|
277
403
|
useEffect(() => () => {
|
|
278
404
|
cancelAnimation(progress);
|
|
405
|
+
cancelAnimation(done);
|
|
279
406
|
if (resetTimer.current) clearTimeout(resetTimer.current);
|
|
280
|
-
}, [progress]);
|
|
407
|
+
}, [progress, done]);
|
|
281
408
|
const onLayout = event => {
|
|
282
409
|
const next = Math.round(event.nativeEvent.layout.width);
|
|
283
410
|
setWidth(current => current === next ? current : next);
|
|
284
411
|
props.onLayout?.(event);
|
|
285
412
|
};
|
|
413
|
+
|
|
414
|
+
/*
|
|
415
|
+
* `slots` is rebuilt every render, so it is deliberately not a dependency —
|
|
416
|
+
* including it would make this memo re-run every time and hand every consumer
|
|
417
|
+
* a new object for no change. The variant and size it is derived from are the
|
|
418
|
+
* dependencies instead.
|
|
419
|
+
*/
|
|
286
420
|
const context = useMemo(() => ({
|
|
287
421
|
progress,
|
|
422
|
+
done,
|
|
288
423
|
width,
|
|
289
424
|
completed,
|
|
290
425
|
variant,
|
|
291
426
|
size,
|
|
292
427
|
slots
|
|
293
|
-
}),
|
|
294
|
-
|
|
295
|
-
|
|
428
|
+
}),
|
|
429
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
430
|
+
[progress, done, width, completed, variant, size]);
|
|
431
|
+
|
|
432
|
+
/*
|
|
433
|
+
* The completed drawing is part of the button rather than something every
|
|
434
|
+
* call site has to remember, so one is added unless the caller wrote their
|
|
435
|
+
* own. A hold that lands and shows nothing is the reader wondering whether it
|
|
436
|
+
* worked, which is the thing this control exists to remove.
|
|
437
|
+
*/
|
|
438
|
+
const written = Children.toArray(children);
|
|
439
|
+
const hasDone = written.some(child => /*#__PURE__*/isValidElement(child) && child.type === ProgressButtonDone);
|
|
440
|
+
const body = /*#__PURE__*/_jsxs(_Fragment, {
|
|
441
|
+
children: [written.length > 0 ? written : /*#__PURE__*/_jsx(ProgressButtonLabel, {
|
|
296
442
|
children: "Hold to confirm"
|
|
297
|
-
})
|
|
443
|
+
}), hasDone ? null : /*#__PURE__*/_jsx(ProgressButtonDone, {})]
|
|
298
444
|
});
|
|
299
445
|
return /*#__PURE__*/_jsx(ProgressButtonContext.Provider, {
|
|
300
446
|
value: context,
|
|
@@ -313,14 +459,20 @@ const ProgressButtonRoot = /*#__PURE__*/forwardRef(function ProgressButtonRoot({
|
|
|
313
459
|
disabled,
|
|
314
460
|
checked: completed
|
|
315
461
|
},
|
|
316
|
-
disabled: disabled
|
|
462
|
+
disabled: disabled
|
|
463
|
+
/*
|
|
464
|
+
* The spread sits above the hold rather than below it. Underneath, a
|
|
465
|
+
* caller passing `onPressIn` — reasonably, to log a tap — would replace
|
|
466
|
+
* the gesture the whole control is, and the button would simply never
|
|
467
|
+
* fill.
|
|
468
|
+
*/,
|
|
469
|
+
...props,
|
|
317
470
|
onPressIn: begin,
|
|
318
471
|
onPressOut: abandon
|
|
319
472
|
// A few points of drift should not abandon a hold the reader is
|
|
320
473
|
// still making. Fingers move.
|
|
321
474
|
,
|
|
322
475
|
pressRetentionOffset: 16,
|
|
323
|
-
...props,
|
|
324
476
|
onLayout: onLayout,
|
|
325
477
|
className: slots.root({
|
|
326
478
|
className
|
|
@@ -382,9 +534,84 @@ function ProgressButtonLabel({
|
|
|
382
534
|
});
|
|
383
535
|
}
|
|
384
536
|
ProgressButtonLabel.displayName = 'ProgressButton.Label';
|
|
537
|
+
/**
|
|
538
|
+
* The drawing the button lands on.
|
|
539
|
+
*
|
|
540
|
+
* It sits over the finished fill rather than beside the label, so the button
|
|
541
|
+
* does not change width at the moment it completes — a control that resizes as
|
|
542
|
+
* it succeeds moves everything under it, and the reader's eye is on the button.
|
|
543
|
+
*
|
|
544
|
+
* One is added for you unless you write your own, because a hold that lands and
|
|
545
|
+
* shows nothing leaves the reader checking whether it worked.
|
|
546
|
+
*/
|
|
547
|
+
function ProgressButtonDone({
|
|
548
|
+
className,
|
|
549
|
+
children,
|
|
550
|
+
...props
|
|
551
|
+
}) {
|
|
552
|
+
const {
|
|
553
|
+
done,
|
|
554
|
+
completed,
|
|
555
|
+
variant,
|
|
556
|
+
slots
|
|
557
|
+
} = useProgressButtonContext('ProgressButton.Done');
|
|
558
|
+
const tint = useCSSVariable(DONE_TINT[variant]);
|
|
559
|
+
|
|
560
|
+
/*
|
|
561
|
+
* It carries the fill's own colour and covers the button edge to edge.
|
|
562
|
+
*
|
|
563
|
+
* The alternative — fading the label out from under it — takes the fill with
|
|
564
|
+
* it, because the fill is drawn inside the label so that the two copies of
|
|
565
|
+
* the text line up. The button would empty at the exact moment it succeeded,
|
|
566
|
+
* and the tick, drawn in the colour that reads against a full fill, would be
|
|
567
|
+
* left standing on nothing.
|
|
568
|
+
*/
|
|
569
|
+
const style = useAnimatedStyle(() => ({
|
|
570
|
+
opacity: done.value
|
|
571
|
+
}));
|
|
572
|
+
// The tick arrives from slightly under full size. The ground it lands on
|
|
573
|
+
// does not: a background box that grows reads as the button resizing.
|
|
574
|
+
const markStyle = useAnimatedStyle(() => ({
|
|
575
|
+
transform: [{
|
|
576
|
+
scale: 0.7 + done.value * 0.3
|
|
577
|
+
}]
|
|
578
|
+
}));
|
|
579
|
+
return /*#__PURE__*/_jsx(Animated.View, {
|
|
580
|
+
...props,
|
|
581
|
+
// Never takes the press: the button underneath still owns it, which is
|
|
582
|
+
// what lets a completed button be reset and held again.
|
|
583
|
+
pointerEvents: "none",
|
|
584
|
+
accessibilityElementsHidden: !completed,
|
|
585
|
+
importantForAccessibility: completed ? 'auto' : 'no-hide-descendants',
|
|
586
|
+
style: [{
|
|
587
|
+
position: 'absolute',
|
|
588
|
+
top: 0,
|
|
589
|
+
right: 0,
|
|
590
|
+
bottom: 0,
|
|
591
|
+
left: 0
|
|
592
|
+
}, style],
|
|
593
|
+
className: slots.fill({
|
|
594
|
+
className: slots.content({
|
|
595
|
+
className
|
|
596
|
+
})
|
|
597
|
+
}),
|
|
598
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
599
|
+
style: markStyle,
|
|
600
|
+
className: slots.content(),
|
|
601
|
+
children: /*#__PURE__*/_jsx(IconColorProvider, {
|
|
602
|
+
color: typeof tint === 'string' ? tint : undefined,
|
|
603
|
+
children: children ?? /*#__PURE__*/_jsx(CheckIcon, {
|
|
604
|
+
size: 18
|
|
605
|
+
})
|
|
606
|
+
})
|
|
607
|
+
})
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
ProgressButtonDone.displayName = 'ProgressButton.Done';
|
|
385
611
|
ProgressButtonRoot.displayName = 'ProgressButton';
|
|
386
612
|
export const ProgressButton = Object.assign(ProgressButtonRoot, {
|
|
387
|
-
Label: ProgressButtonLabel
|
|
613
|
+
Label: ProgressButtonLabel,
|
|
614
|
+
Done: ProgressButtonDone
|
|
388
615
|
});
|
|
389
|
-
export { DEFAULT_AUTO_RESET_DELAY, DEFAULT_HOLD_DURATION, DEFAULT_RELEASE_DURATION, isComplete, releaseDuration, resolveHoldDuration } from "./progress-button-hold.js";
|
|
616
|
+
export { DEFAULT_AUTO_RESET_DELAY, DEFAULT_HOLD_DURATION, DEFAULT_RELEASE_DURATION, fillDuration, isComplete, releaseDuration, resolveHoldDuration } from "./progress-button-hold.js";
|
|
390
617
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","forwardRef","useCallback","useContext","useEffect","useMemo","useRef","useState","Pressable","View","Animated","Easing","cancelAnimation","runOnJS","useAnimatedReaction","useAnimatedStyle","useReducedMotion","useSharedValue","withTiming","tv","Text","textChildren","impactKnock","selectionTick","DEFAULT_AUTO_RESET_DELAY","DEFAULT_RELEASE_DURATION","releaseDuration","resolveHoldDuration","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","REDUCED_STEPS","progressButtonVariants","slots","root","content","label","fill","fillLabel","variants","variant","primary","secondary","destructive","success","size","sm","md","lg","fullWidth","true","disabled","defaultVariants","ProgressButtonContext","useProgressButtonContext","component","context","Error","useProgressButton","progress","completed","ProgressButtonRoot","className","holdDuration","onComplete","onCompletedChange","completedProp","autoReset","autoResetDelay","haptics","accessibilityState","children","props","ref","duration","reducedMotion","width","setWidth","internalCompleted","setInternalCompleted","resetTimer","isControlled","undefined","finish","value","full","was","begin","easing","steps","linear","abandon","out","cubic","reset","current","setTimeout","clearTimeout","onLayout","event","next","Math","round","nativeEvent","layout","body","ProgressButtonLabel","Provider","accessibilityRole","accessibilityHint","checked","onPressIn","onPressOut","pressRetentionOffset","fillStyle","text","pointerEvents","style","position","top","bottom","left","overflow","displayName","ProgressButton","Object","assign","Label","DEFAULT_HOLD_DURATION","isComplete"],"sourceRoot":"../../../../src","sources":["components/progress-button/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,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zF,IAAA,CAACT,IAAI;UAAC6C,SAAS,EAAE7B,KAAK,CAACK,SAAS,CAAC,CAAE;UAAAiC,QAAA,EAAE4C;QAAI,CAAO,CACjD;MAAC,CACE;IAAC,CACM,CAAC;EAAA,CACZ,CAAC;AAEX;AACAT,mBAAmB,CAACiB,WAAW,GAAG,sBAAsB;AAExD9D,kBAAkB,CAAC8D,WAAW,GAAG,gBAAgB;AAEjD,OAAO,MAAMC,cAAc,GAAGC,MAAM,CAACC,MAAM,CAACjE,kBAAkB,EAAE;EAC9DkE,KAAK,EAAErB;AACT,CAAC,CAAC;AAEF,SACErF,wBAAwB,EACxB2G,qBAAqB,EACrB1G,wBAAwB,EACxB2G,UAAU,EACV1G,eAAe,EACfC,mBAAmB,QACd,2BAAwB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Children","createContext","forwardRef","isValidElement","useCallback","useContext","useEffect","useMemo","useRef","useState","Pressable","View","Animated","Easing","cancelAnimation","runOnJS","runOnUI","useAnimatedReaction","useAnimatedStyle","useReducedMotion","useSharedValue","withSpring","withTiming","tv","useCSSVariable","CheckIcon","IconColorProvider","Text","textChildren","impactKnock","selectionTick","DEFAULT_AUTO_RESET_DELAY","fillDuration","releaseDuration","resolveHoldDuration","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","REDUCED_STEPS","DONE_SPRING","damping","stiffness","mass","DONE_EXIT","DONE_TINT","primary","secondary","destructive","success","progressButtonVariants","slots","root","content","label","fill","fillLabel","variants","variant","size","sm","md","lg","fullWidth","true","disabled","defaultVariants","ProgressButtonContext","useProgressButtonContext","component","context","Error","useProgressButton","progress","completed","ProgressButtonRoot","className","holdDuration","onComplete","onCompletedChange","completedProp","autoReset","autoResetDelay","haptics","accessibilityState","children","props","ref","duration","reducedMotion","done","width","setWidth","internalCompleted","setInternalCompleted","resetTimer","isControlled","undefined","completedRef","current","finish","value","full","was","begin","from","easing","steps","linear","rewind","abandon","reset","setTimeout","clearTimeout","onLayout","event","next","Math","round","nativeEvent","layout","written","toArray","hasDone","some","child","type","ProgressButtonDone","body","length","ProgressButtonLabel","Provider","accessibilityRole","accessibilityHint","checked","onPressIn","onPressOut","pressRetentionOffset","fillStyle","text","pointerEvents","style","position","top","bottom","left","overflow","displayName","tint","opacity","markStyle","transform","scale","accessibilityElementsHidden","importantForAccessibility","right","color","ProgressButton","Object","assign","Label","Done","DEFAULT_HOLD_DURATION","DEFAULT_RELEASE_DURATION","isComplete"],"sourceRoot":"../../../../src","sources":["components/progress-button/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,QAAQ,EACRC,aAAa,EACbC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAEH,OAAO;AACd,SACEC,SAAS,EACTC,IAAI,QAIC,cAAc;AACrB,OAAOC,QAAQ,IACbC,MAAM,EACNC,eAAe,EACfC,OAAO,EACPC,OAAO,EACPC,mBAAmB,EACnBC,gBAAgB,EAChBC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,EACVC,UAAU,QAEL,yBAAyB;AAChC,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,sBAAa;AAC1D,SAASC,IAAI,EAAEC,YAAY,QAAQ,0BAAuB;AAC1D,SAASC,WAAW,EAAEC,aAAa,QAAQ,wBAAqB;AAChE,SACEC,wBAAwB,EACxBC,YAAY,EACZC,eAAe,EACfC,mBAAmB,QACd,2BAAwB;;AAE/B;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAA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mBAAmB,QACd,2BAAwB","ignoreList":[]}
|
|
@@ -10,8 +10,15 @@
|
|
|
10
10
|
/** Milliseconds a hold has to be sustained before it counts. */
|
|
11
11
|
export const DEFAULT_HOLD_DURATION = 2000;
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Milliseconds a complete fill takes to rewind, when the hold length is not
|
|
15
|
+
* known — the default only exists so {@link releaseDuration} has one.
|
|
16
|
+
*
|
|
17
|
+
* The component always passes the hold's own duration instead: the drain is
|
|
18
|
+
* the fill running backwards at the same rate, so a two-second hold takes two
|
|
19
|
+
* seconds to give back.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_RELEASE_DURATION = DEFAULT_HOLD_DURATION;
|
|
15
22
|
|
|
16
23
|
/** Milliseconds before an `autoReset` button offers itself again. */
|
|
17
24
|
export const DEFAULT_AUTO_RESET_DELAY = 1000;
|
|
@@ -33,12 +40,22 @@ export function resolveHoldDuration(duration) {
|
|
|
33
40
|
/**
|
|
34
41
|
* How long the fill should take to drain from where it is.
|
|
35
42
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
43
|
+
* The fill, run backwards. `full` is the hold's own duration, so the drain
|
|
44
|
+
* covers the distance left at exactly the rate it was filled at: let go at
|
|
45
|
+
* nine tenths of a two-second hold and it takes 1.8 seconds to give back, the
|
|
46
|
+
* same 1.8 seconds it took to earn.
|
|
47
|
+
*
|
|
48
|
+
* That is the point of it. The wait was drawn on the button, so undoing the
|
|
49
|
+
* wait is worth drawing too — a fill that vanishes has been deleted, and a
|
|
50
|
+
* fill that travels back has been let go.
|
|
40
51
|
*/
|
|
41
52
|
export function releaseDuration(progress, full = DEFAULT_RELEASE_DURATION) {
|
|
53
|
+
// A worklet, because the only runtime that knows how far the fill actually
|
|
54
|
+
// got is the one animating it. Reading a shared value from JavaScript gives
|
|
55
|
+
// the value before the animation started, so the release has to be started
|
|
56
|
+
// from the UI thread — and that means this has to run there too.
|
|
57
|
+
'worklet';
|
|
58
|
+
|
|
42
59
|
const travelled = Math.min(1, Math.max(0, progress));
|
|
43
60
|
return Math.max(80, full * travelled);
|
|
44
61
|
}
|
|
@@ -52,6 +69,23 @@ export function releaseDuration(progress, full = DEFAULT_RELEASE_DURATION) {
|
|
|
52
69
|
* button sometimes fires when the reader let go early on purpose.
|
|
53
70
|
*/
|
|
54
71
|
export function isComplete(progress) {
|
|
72
|
+
'worklet';
|
|
73
|
+
|
|
55
74
|
return progress >= 1;
|
|
56
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* How long it takes to cover the distance still ahead, at the fill's own rate.
|
|
79
|
+
*
|
|
80
|
+
* A press that arrives while the fill is on its way back should carry on from
|
|
81
|
+
* where it is rather than restarting the clock — otherwise a fill picked up at
|
|
82
|
+
* halfway takes the whole hold to cover the half that is left, and the second
|
|
83
|
+
* attempt is twice as slow as the first for no reason the reader can see.
|
|
84
|
+
*/
|
|
85
|
+
export function fillDuration(from, full) {
|
|
86
|
+
'worklet';
|
|
87
|
+
|
|
88
|
+
const remaining = Math.min(1, Math.max(0, 1 - from));
|
|
89
|
+
return Math.max(80, full * remaining);
|
|
90
|
+
}
|
|
57
91
|
//# sourceMappingURL=progress-button-hold.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_HOLD_DURATION","DEFAULT_RELEASE_DURATION","DEFAULT_AUTO_RESET_DELAY","resolveHoldDuration","duration","undefined","Number","isFinite","Math","max","releaseDuration","progress","full","travelled","min","isComplete"],"sourceRoot":"../../../../src","sources":["components/progress-button/progress-button-hold.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,MAAMA,qBAAqB,GAAG,IAAI;;AAEzC;AACA,OAAO,MAAMC,wBAAwB,
|
|
1
|
+
{"version":3,"names":["DEFAULT_HOLD_DURATION","DEFAULT_RELEASE_DURATION","DEFAULT_AUTO_RESET_DELAY","resolveHoldDuration","duration","undefined","Number","isFinite","Math","max","releaseDuration","progress","full","travelled","min","isComplete","fillDuration","from","remaining"],"sourceRoot":"../../../../src","sources":["components/progress-button/progress-button-hold.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,MAAMA,qBAAqB,GAAG,IAAI;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAGD,qBAAqB;;AAE7D;AACA,OAAO,MAAME,wBAAwB,GAAG,IAAI;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,QAA4B,EAAU;EACxE,IAAIA,QAAQ,KAAKC,SAAS,EAAE,OAAOL,qBAAqB;EACxD,IAAI,CAACM,MAAM,CAACC,QAAQ,CAACH,QAAQ,CAAC,EAAE,OAAOJ,qBAAqB;EAC5D,OAAOQ,IAAI,CAACC,GAAG,CAAC,GAAG,EAAEL,QAAQ,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,eAAeA,CAC7BC,QAAgB,EAChBC,IAAY,GAAGX,wBAAwB,EAC/B;EACR;EACA;EACA;EACA;EACA,SAAS;;EACT,MAAMY,SAAS,GAAGL,IAAI,CAACM,GAAG,CAAC,CAAC,EAAEN,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEE,QAAQ,CAAC,CAAC;EACpD,OAAOH,IAAI,CAACC,GAAG,CAAC,EAAE,EAAEG,IAAI,GAAGC,SAAS,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,UAAUA,CAACJ,QAAgB,EAAW;EACpD,SAAS;;EACT,OAAOA,QAAQ,IAAI,CAAC;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,YAAYA,CAACC,IAAY,EAAEL,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