@kanso-labs/react-native-kanso-ui 0.1.0 → 0.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.
Files changed (49) hide show
  1. package/dist/button/index.d.ts +24 -2
  2. package/dist/button/index.js.map +1 -1
  3. package/dist/button/pending.js +144 -0
  4. package/dist/button/pending.js.map +1 -0
  5. package/dist/components/button/index.d.ts +1 -1
  6. package/dist/components/button/index.js +154 -112
  7. package/dist/components/button/index.js.map +1 -1
  8. package/dist/components/icon-button/index.d.ts +1 -1
  9. package/dist/components/icon-button/index.js +160 -110
  10. package/dist/components/icon-button/index.js.map +1 -1
  11. package/dist/components/meter/index.d.ts +73 -0
  12. package/dist/components/meter/index.js +179 -0
  13. package/dist/components/meter/index.js.map +1 -0
  14. package/dist/components/number-field/index.js +1 -9
  15. package/dist/components/number-field/index.js.map +1 -1
  16. package/dist/components/progress-indicator/index.d.ts +113 -0
  17. package/dist/components/progress-indicator/index.js +1024 -0
  18. package/dist/components/progress-indicator/index.js.map +1 -0
  19. package/dist/components/snackbar/index.d.ts +120 -0
  20. package/dist/components/snackbar/index.js +540 -0
  21. package/dist/components/snackbar/index.js.map +1 -0
  22. package/dist/glyphs/hidden.js +13 -0
  23. package/dist/glyphs/hidden.js.map +1 -0
  24. package/dist/glyphs/index.js +2 -8
  25. package/dist/glyphs/index.js.map +1 -1
  26. package/dist/i18n/index.js +23 -0
  27. package/dist/i18n/index.js.map +1 -0
  28. package/dist/i18n/messages.js +41 -0
  29. package/dist/i18n/messages.js.map +1 -0
  30. package/dist/index.d.ts +4 -1
  31. package/dist/index.js +6 -3
  32. package/dist/indicator/index.d.ts +15 -0
  33. package/dist/indicator/index.js +256 -0
  34. package/dist/indicator/index.js.map +1 -0
  35. package/dist/indicator/motion.js +86 -0
  36. package/dist/indicator/motion.js.map +1 -0
  37. package/dist/indicator/paths.js +72 -0
  38. package/dist/indicator/paths.js.map +1 -0
  39. package/dist/indicator/styles.js +62 -0
  40. package/dist/indicator/styles.js.map +1 -0
  41. package/dist/number/locale.js +14 -0
  42. package/dist/number/locale.js.map +1 -0
  43. package/dist/overlay/host.js +65 -2
  44. package/dist/overlay/host.js.map +1 -1
  45. package/dist/press/index.js +10 -9
  46. package/dist/press/index.js.map +1 -1
  47. package/dist/theme/resolve.js +1 -1
  48. package/dist/theme/resolve.js.map +1 -1
  49. package/package.json +2 -2
@@ -0,0 +1,1024 @@
1
+ import { HIDDEN } from "../../glyphs/hidden.js";
2
+ import { parseLength } from "../../theme/resolve.js";
3
+ import { useTheme } from "../../theme/scope.js";
4
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
5
+ import { DETERMINATE_EASING, stylesOf as stylesOf$1 } from "../../indicator/styles.js";
6
+ import { IndicatorLabels, IndicatorLine, activeLength, fillOf, readingOf, useEased, useIndicatorColors, useMeasuredWidth } from "../../indicator/index.js";
7
+ import { keyframeAt, useLoop } from "../../indicator/motion.js";
8
+ import { TURN, WAVE_HEIGHT, WAVE_ORIGIN, arcPath, wavePath, wavyArcPath } from "../../indicator/paths.js";
9
+ import { c } from "react/compiler-runtime";
10
+ import { I18nManager, StyleSheet, View } from "react-native";
11
+ import Svg, { Path } from "react-native-svg";
12
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ import Animated, { useAnimatedProps, useAnimatedStyle, useDerivedValue, useReducedMotion } from "react-native-reanimated";
14
+ //#region src/components/progress-indicator/index.tsx
15
+ const CIRCULAR_SIZE = 40;
16
+ const RADIUS = 18;
17
+ const ARC_MS = 1333;
18
+ const CYCLE_MS = ARC_MS * 4;
19
+ const ROTATE_MS = Math.round(ARC_MS * 360 / 306);
20
+ const RING_EASING = [
21
+ .4,
22
+ 0,
23
+ .2,
24
+ 1
25
+ ];
26
+ const RING_SETTLE = [
27
+ 0,
28
+ 0,
29
+ .2,
30
+ 1
31
+ ];
32
+ const INDETERMINATE_MS = 2e3;
33
+ const BUFFER_MS = 250;
34
+ const LINE_SLOWDOWN = 2;
35
+ const RING_SLOWDOWN = 1.25;
36
+ const WAVE_WAVELENGTH = 40;
37
+ const INDETERMINATE_WAVELENGTH = 20;
38
+ const WAVE_REACH = 2048;
39
+ const WAVE_FROM = 10;
40
+ const WAVE_UNTIL = 95;
41
+ const WAVY_SIZE = 48;
42
+ const RING_AMPLITUDE = 1.6;
43
+ const RING_WAVELENGTH = 15;
44
+ const WAVY_RADIUS = 20.4;
45
+ const RING_WAVE = {
46
+ amplitude: RING_AMPLITUDE,
47
+ centre: WAVY_SIZE / 2,
48
+ radius: WAVY_RADIUS,
49
+ waves: Math.round(TURN * WAVY_RADIUS / RING_WAVELENGTH)
50
+ };
51
+ const PITCH = 10;
52
+ const PRIMARY_BAR = {
53
+ scale: [
54
+ [0, .08],
55
+ [
56
+ .3665,
57
+ .08,
58
+ [
59
+ .334731,
60
+ .12482,
61
+ .785844,
62
+ 1
63
+ ]
64
+ ],
65
+ [
66
+ .6915,
67
+ .661479,
68
+ [
69
+ .06,
70
+ .11,
71
+ .6,
72
+ 1
73
+ ]
74
+ ],
75
+ [1, .08]
76
+ ],
77
+ start: -1.45167,
78
+ translate: [
79
+ [0, 0],
80
+ [
81
+ .2,
82
+ 0,
83
+ [
84
+ .5,
85
+ 0,
86
+ .701732,
87
+ .495819
88
+ ]
89
+ ],
90
+ [
91
+ .5915,
92
+ .836714,
93
+ [
94
+ .302435,
95
+ .381352,
96
+ .55,
97
+ .956352
98
+ ]
99
+ ],
100
+ [1, 2.00611]
101
+ ]
102
+ };
103
+ const SECONDARY_BAR = {
104
+ scale: [
105
+ [
106
+ 0,
107
+ .08,
108
+ [
109
+ .205028,
110
+ .057051,
111
+ .57661,
112
+ .453971
113
+ ]
114
+ ],
115
+ [
116
+ .1915,
117
+ .457104,
118
+ [
119
+ .152313,
120
+ .196432,
121
+ .648374,
122
+ 1.00432
123
+ ]
124
+ ],
125
+ [
126
+ .4415,
127
+ .72796,
128
+ [
129
+ .257759,
130
+ -.003163,
131
+ .211762,
132
+ 1.38179
133
+ ]
134
+ ],
135
+ [1, .08]
136
+ ],
137
+ start: -.548889,
138
+ translate: [
139
+ [
140
+ 0,
141
+ 0,
142
+ [
143
+ .15,
144
+ 0,
145
+ .515058,
146
+ .409685
147
+ ]
148
+ ],
149
+ [
150
+ .25,
151
+ .376519,
152
+ [
153
+ .31033,
154
+ .284058,
155
+ .8,
156
+ .733712
157
+ ]
158
+ ],
159
+ [
160
+ .4835,
161
+ .843862,
162
+ [
163
+ .4,
164
+ .627035,
165
+ .6,
166
+ .902026
167
+ ]
168
+ ],
169
+ [1, 1.60278]
170
+ ]
171
+ };
172
+ const EXPAND_ARC = [
173
+ [
174
+ 0,
175
+ .08,
176
+ RING_EASING
177
+ ],
178
+ [
179
+ .5,
180
+ .75,
181
+ RING_EASING
182
+ ],
183
+ [1, .08]
184
+ ];
185
+ const TRAVEL_ARC = [
186
+ [
187
+ 0,
188
+ 0,
189
+ RING_EASING
190
+ ],
191
+ [
192
+ .125,
193
+ .375,
194
+ RING_EASING
195
+ ],
196
+ [
197
+ .25,
198
+ .75,
199
+ RING_EASING
200
+ ],
201
+ [
202
+ .375,
203
+ 1.125,
204
+ RING_EASING
205
+ ],
206
+ [
207
+ .5,
208
+ 1.5,
209
+ RING_EASING
210
+ ],
211
+ [
212
+ .625,
213
+ 1.875,
214
+ RING_EASING
215
+ ],
216
+ [
217
+ .75,
218
+ 2.25,
219
+ RING_EASING
220
+ ],
221
+ [
222
+ .875,
223
+ 2.625,
224
+ RING_EASING
225
+ ],
226
+ [1, 3]
227
+ ];
228
+ const AnimatedPath = Animated.createAnimatedComponent(Path);
229
+ const styles = StyleSheet.create({
230
+ bar: {
231
+ height: 4,
232
+ left: 0,
233
+ position: "absolute",
234
+ top: 0,
235
+ transformOrigin: "left center"
236
+ },
237
+ buffered: {
238
+ flexShrink: 0,
239
+ height: 4
240
+ },
241
+ dot: {
242
+ height: 4,
243
+ width: 4
244
+ },
245
+ dotRow: {
246
+ flexDirection: "row",
247
+ gap: 6
248
+ },
249
+ dots: {
250
+ flexGrow: 1,
251
+ flexShrink: 1,
252
+ height: 4,
253
+ minWidth: 0,
254
+ overflow: "hidden"
255
+ },
256
+ line: {
257
+ alignSelf: "stretch",
258
+ justifyContent: "center"
259
+ },
260
+ mirrored: { transform: [{ scaleX: -1 }] },
261
+ rootCircular: { alignItems: "flex-start" },
262
+ row: {
263
+ alignSelf: "stretch",
264
+ height: 4,
265
+ overflow: "hidden"
266
+ },
267
+ track: { ...StyleSheet.absoluteFill },
268
+ wave: {
269
+ left: 0,
270
+ overflow: "hidden",
271
+ position: "absolute",
272
+ top: 0
273
+ },
274
+ wavyLine: {
275
+ alignSelf: "stretch",
276
+ height: WAVE_HEIGHT,
277
+ justifyContent: "center"
278
+ }
279
+ });
280
+ const stylesOf = themedStyles(({ radii }) => StyleSheet.create({
281
+ bar: { borderRadius: radii.pill },
282
+ dot: { borderRadius: radii.circle },
283
+ row: { borderRadius: radii.pill }
284
+ }));
285
+ /**
286
+ * The dots beyond the buffer, scrolling toward the start of the line. There
287
+ * is one more of them than the row has room for, so the row stays full as
288
+ * they move.
289
+ */
290
+ function Buffer(t0) {
291
+ const $ = c(18);
292
+ const { colors, share, width } = t0;
293
+ const theme = useTheme();
294
+ const own = stylesOf(theme);
295
+ const reduceMotion = useReducedMotion();
296
+ const clock = useLoop(BUFFER_MS * (reduceMotion ? LINE_SLOWDOWN : 1), true);
297
+ const direction = I18nManager.isRTL ? -1 : 1;
298
+ const scroll = useAnimatedStyle(() => {
299
+ "worklet";
300
+ return { transform: [{ translateX: -10 * clock.get() * direction }] };
301
+ });
302
+ let t1;
303
+ if ($[0] !== colors.track || $[1] !== share) {
304
+ t1 = composeStyles(styles.buffered, fillOf(colors.track), widthOf(`${share}%`));
305
+ $[0] = colors.track;
306
+ $[1] = share;
307
+ $[2] = t1;
308
+ } else t1 = $[2];
309
+ let t2;
310
+ if ($[3] !== t1) {
311
+ t2 = /* @__PURE__ */ jsx(View, { style: t1 });
312
+ $[3] = t1;
313
+ $[4] = t2;
314
+ } else t2 = $[4];
315
+ const T0 = View;
316
+ const t3 = styles;
317
+ const t4 = Animated;
318
+ let t5;
319
+ if ($[5] !== scroll) {
320
+ t5 = composeStyles(styles.dotRow, scroll);
321
+ $[5] = scroll;
322
+ $[6] = t5;
323
+ } else t5 = $[6];
324
+ const t6 = dotsFor(width).map((dot) => /* @__PURE__ */ jsx(View, { style: composeStyles(styles.dot, own.dot, fillOf(colors.track)) }, dot));
325
+ let t7;
326
+ if ($[7] !== t4.View || $[8] !== t5 || $[9] !== t6) {
327
+ t7 = /* @__PURE__ */ jsx(t4.View, {
328
+ style: t5,
329
+ children: t6
330
+ });
331
+ $[7] = t4.View;
332
+ $[8] = t5;
333
+ $[9] = t6;
334
+ $[10] = t7;
335
+ } else t7 = $[10];
336
+ let t8;
337
+ if ($[11] !== T0 || $[12] !== t3.dots || $[13] !== t7) {
338
+ t8 = /* @__PURE__ */ jsx(T0, {
339
+ style: t3.dots,
340
+ children: t7
341
+ });
342
+ $[11] = T0;
343
+ $[12] = t3.dots;
344
+ $[13] = t7;
345
+ $[14] = t8;
346
+ } else t8 = $[14];
347
+ let t9;
348
+ if ($[15] !== t2 || $[16] !== t8) {
349
+ t9 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, t8] });
350
+ $[15] = t2;
351
+ $[16] = t8;
352
+ $[17] = t9;
353
+ } else t9 = $[17];
354
+ return t9;
355
+ }
356
+ function bufferShare(buffer, percentage, minValue, maxValue) {
357
+ if (buffer === void 0) return;
358
+ const range = maxValue - minValue;
359
+ const buffered = range === 0 ? 0 : (buffer - minValue) / range * 100;
360
+ const remaining = 100 - percentage;
361
+ if (remaining <= 0) return 0;
362
+ return Math.min(100, Math.max(0, (buffered - percentage) / remaining * 100));
363
+ }
364
+ /**
365
+ * The ring: two arcs of one circle while determinate, one arc growing,
366
+ * shrinking and travelling round while indeterminate, and for the wavy shape a
367
+ * wave over the active arc. Drawn on a box of its own size and scaled to the
368
+ * diameter, so the stroke and the gap scale with it.
369
+ */
370
+ function CircularTrack(t0) {
371
+ const $ = c(28);
372
+ const { colors, diameter, isIndeterminate, percentage, shape } = t0;
373
+ const { motion } = useTheme();
374
+ const reduceMotion = useReducedMotion();
375
+ const wavy = shape === "wavy";
376
+ const waves = wavy && !reduceMotion;
377
+ const box = wavy ? WAVY_SIZE : CIRCULAR_SIZE;
378
+ const centre = box / 2;
379
+ const radius = wavy ? WAVY_RADIUS : RADIUS;
380
+ const circumference = TURN * radius;
381
+ let t1;
382
+ if ($[0] !== motion.durationLong2) {
383
+ t1 = {
384
+ duration: motion.durationLong2,
385
+ easing: RING_SETTLE
386
+ };
387
+ $[0] = motion.durationLong2;
388
+ $[1] = t1;
389
+ } else t1 = $[1];
390
+ const timing = t1;
391
+ const shown = useEased(percentage, timing);
392
+ const fade = useEased(waves && (isIndeterminate || isWaving(percentage)) ? 1 : 0, timing);
393
+ const slowdown = reduceMotion ? RING_SLOWDOWN : 1;
394
+ const arc = useLoop(ARC_MS * slowdown, isIndeterminate);
395
+ const cycle = useLoop(CYCLE_MS * slowdown, isIndeterminate);
396
+ let t2;
397
+ if ($[2] !== slowdown) {
398
+ t2 = Math.round(ROTATE_MS * slowdown);
399
+ $[2] = slowdown;
400
+ $[3] = t2;
401
+ } else t2 = $[3];
402
+ const turn = useLoop(t2, isIndeterminate);
403
+ const active = useAnimatedProps(() => {
404
+ "worklet";
405
+ const opacity = 1 - fade.get();
406
+ if (isIndeterminate) {
407
+ const from = TURN / 4 + TURN * (turn.get() + keyframeAt(TRAVEL_ARC, cycle.get()));
408
+ return {
409
+ d: arcPath(centre, radius, from, TURN * keyframeAt(EXPAND_ARC, arc.get())),
410
+ opacity
411
+ };
412
+ }
413
+ return {
414
+ d: arcPath(centre, radius, 0, TURN * shown.get() / 100),
415
+ opacity
416
+ };
417
+ });
418
+ const track = useAnimatedProps(() => {
419
+ "worklet";
420
+ const length = circumference * shown.get() / 100;
421
+ return { d: arcPath(centre, radius, (length + 4) / radius, Math.max(0, circumference - length - 8) / radius) };
422
+ });
423
+ const t3 = `0 0 ${box} ${box}`;
424
+ let t4;
425
+ if ($[4] !== colors.track || $[5] !== isIndeterminate || $[6] !== track) {
426
+ t4 = isIndeterminate ? null : /* @__PURE__ */ jsx(AnimatedPath, {
427
+ animatedProps: track,
428
+ ...strokeOf(colors.track)
429
+ });
430
+ $[4] = colors.track;
431
+ $[5] = isIndeterminate;
432
+ $[6] = track;
433
+ $[7] = t4;
434
+ } else t4 = $[7];
435
+ let t5;
436
+ if ($[8] !== colors.active) {
437
+ t5 = strokeOf(colors.active);
438
+ $[8] = colors.active;
439
+ $[9] = t5;
440
+ } else t5 = $[9];
441
+ let t6;
442
+ if ($[10] !== active || $[11] !== t5) {
443
+ t6 = /* @__PURE__ */ jsx(AnimatedPath, {
444
+ animatedProps: active,
445
+ ...t5
446
+ });
447
+ $[10] = active;
448
+ $[11] = t5;
449
+ $[12] = t6;
450
+ } else t6 = $[12];
451
+ let t7;
452
+ if ($[13] !== arc || $[14] !== colors || $[15] !== cycle || $[16] !== fade || $[17] !== isIndeterminate || $[18] !== shown || $[19] !== turn || $[20] !== waves) {
453
+ t7 = waves ? /* @__PURE__ */ jsx(RingWavePath, {
454
+ arc,
455
+ colors,
456
+ cycle,
457
+ fade,
458
+ isIndeterminate,
459
+ shown,
460
+ turn
461
+ }) : null;
462
+ $[13] = arc;
463
+ $[14] = colors;
464
+ $[15] = cycle;
465
+ $[16] = fade;
466
+ $[17] = isIndeterminate;
467
+ $[18] = shown;
468
+ $[19] = turn;
469
+ $[20] = waves;
470
+ $[21] = t7;
471
+ } else t7 = $[21];
472
+ let t8;
473
+ if ($[22] !== diameter || $[23] !== t3 || $[24] !== t4 || $[25] !== t6 || $[26] !== t7) {
474
+ t8 = /* @__PURE__ */ jsxs(Svg, {
475
+ ...HIDDEN,
476
+ height: diameter,
477
+ viewBox: t3,
478
+ width: diameter,
479
+ children: [
480
+ t4,
481
+ t6,
482
+ t7
483
+ ]
484
+ });
485
+ $[22] = diameter;
486
+ $[23] = t3;
487
+ $[24] = t4;
488
+ $[25] = t6;
489
+ $[26] = t7;
490
+ $[27] = t8;
491
+ } else t8 = $[27];
492
+ return t8;
493
+ }
494
+ /**
495
+ * The line determinate: src/indicator's, with the buffer in its track, and
496
+ * for the wavy shape a wave over its active indicator, crossfading with it as
497
+ * the value crosses the bounds the wave stands between.
498
+ */
499
+ function DeterminateLine(t0) {
500
+ const $ = c(21);
501
+ const { buffer, colors, percentage, waves, width } = t0;
502
+ const { motion } = useTheme();
503
+ let t1;
504
+ if ($[0] !== motion.durationMedium1) {
505
+ t1 = {
506
+ duration: motion.durationMedium1,
507
+ easing: DETERMINATE_EASING
508
+ };
509
+ $[0] = motion.durationMedium1;
510
+ $[1] = t1;
511
+ } else t1 = $[1];
512
+ const timing = t1;
513
+ const shown = useEased(percentage, timing);
514
+ const fade = useEased(waves && isWaving(percentage) ? 1 : 0, timing);
515
+ const under = useDerivedValue(() => 1 - fade.get());
516
+ const t2 = waves ? under : void 0;
517
+ let t3;
518
+ if ($[2] !== buffer || $[3] !== colors || $[4] !== width) {
519
+ t3 = buffer === void 0 ? void 0 : /* @__PURE__ */ jsx(Buffer, {
520
+ colors,
521
+ share: buffer,
522
+ width
523
+ });
524
+ $[2] = buffer;
525
+ $[3] = colors;
526
+ $[4] = width;
527
+ $[5] = t3;
528
+ } else t3 = $[5];
529
+ let t4;
530
+ if ($[6] !== colors || $[7] !== shown || $[8] !== t2 || $[9] !== t3 || $[10] !== width) {
531
+ t4 = /* @__PURE__ */ jsx(IndicatorLine, {
532
+ activeOpacity: t2,
533
+ colors,
534
+ percentage: shown,
535
+ width,
536
+ children: t3
537
+ });
538
+ $[6] = colors;
539
+ $[7] = shown;
540
+ $[8] = t2;
541
+ $[9] = t3;
542
+ $[10] = width;
543
+ $[11] = t4;
544
+ } else t4 = $[11];
545
+ let t5;
546
+ if ($[12] !== colors || $[13] !== fade || $[14] !== shown || $[15] !== waves || $[16] !== width) {
547
+ t5 = waves ? /* @__PURE__ */ jsx(LineWave, {
548
+ colors,
549
+ fade,
550
+ shown,
551
+ width
552
+ }) : null;
553
+ $[12] = colors;
554
+ $[13] = fade;
555
+ $[14] = shown;
556
+ $[15] = waves;
557
+ $[16] = width;
558
+ $[17] = t5;
559
+ } else t5 = $[17];
560
+ let t6;
561
+ if ($[18] !== t4 || $[19] !== t5) {
562
+ t6 = /* @__PURE__ */ jsxs(Fragment, { children: [t4, t5] });
563
+ $[18] = t4;
564
+ $[19] = t5;
565
+ $[20] = t6;
566
+ } else t6 = $[20];
567
+ return t6;
568
+ }
569
+ function dotsFor(width) {
570
+ return Array.from({ length: Math.ceil(width / PITCH) + 1 }, (_, index) => index);
571
+ }
572
+ function IndeterminateBars(t0) {
573
+ const $ = c(3);
574
+ const { clock, colors, width } = t0;
575
+ const own = stylesOf(useTheme());
576
+ const primary = useBarStyle(clock, PRIMARY_BAR, width);
577
+ const secondary = useBarStyle(clock, SECONDARY_BAR, width);
578
+ const t1 = Animated;
579
+ const t2 = composeStyles(styles.bar, own.bar, widthOf(width), fillOf(colors.active), secondary);
580
+ let t3;
581
+ if ($[0] !== t1.View || $[1] !== t2) {
582
+ t3 = /* @__PURE__ */ jsx(t1.View, { style: t2 });
583
+ $[0] = t1.View;
584
+ $[1] = t2;
585
+ $[2] = t3;
586
+ } else t3 = $[2];
587
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Animated.View, { style: composeStyles(styles.bar, own.bar, widthOf(width), fillOf(colors.active), primary) }), t3] });
588
+ }
589
+ /**
590
+ * The line indeterminate: the track, with two bars crossing it, or for the
591
+ * wavy shape two stretches of a wave crossing it where the bars would be. The
592
+ * row is mirrored under a right-to-left layout, which makes the sweep travel
593
+ * the way the line reads while the bars move as Material's keyframes say.
594
+ */
595
+ function IndeterminateLine(t0) {
596
+ const $ = c(23);
597
+ const { colors, waves, width } = t0;
598
+ const own = stylesOf(useTheme());
599
+ const reduceMotion = useReducedMotion();
600
+ const clock = useLoop(INDETERMINATE_MS * (reduceMotion ? LINE_SLOWDOWN : 1), true);
601
+ const mirrored = I18nManager.isRTL ? styles.mirrored : void 0;
602
+ const T0 = View;
603
+ const t1 = composeStyles(styles.row, own.row, mirrored);
604
+ let t2;
605
+ if ($[0] !== colors.track) {
606
+ t2 = composeStyles(styles.track, fillOf(colors.track));
607
+ $[0] = colors.track;
608
+ $[1] = t2;
609
+ } else t2 = $[1];
610
+ let t3;
611
+ if ($[2] !== t2) {
612
+ t3 = /* @__PURE__ */ jsx(View, { style: t2 });
613
+ $[2] = t2;
614
+ $[3] = t3;
615
+ } else t3 = $[3];
616
+ let t4;
617
+ if ($[4] !== clock || $[5] !== colors || $[6] !== waves || $[7] !== width) {
618
+ t4 = waves ? null : /* @__PURE__ */ jsx(IndeterminateBars, {
619
+ clock,
620
+ colors,
621
+ width
622
+ });
623
+ $[4] = clock;
624
+ $[5] = colors;
625
+ $[6] = waves;
626
+ $[7] = width;
627
+ $[8] = t4;
628
+ } else t4 = $[8];
629
+ let t5;
630
+ if ($[9] !== T0 || $[10] !== t1 || $[11] !== t3 || $[12] !== t4) {
631
+ t5 = /* @__PURE__ */ jsxs(T0, {
632
+ style: t1,
633
+ children: [t3, t4]
634
+ });
635
+ $[9] = T0;
636
+ $[10] = t1;
637
+ $[11] = t3;
638
+ $[12] = t4;
639
+ $[13] = t5;
640
+ } else t5 = $[13];
641
+ let t6;
642
+ if ($[14] !== clock || $[15] !== colors || $[16] !== mirrored || $[17] !== waves || $[18] !== width) {
643
+ t6 = waves ? /* @__PURE__ */ jsxs(Svg, {
644
+ ...HIDDEN,
645
+ height: WAVE_HEIGHT,
646
+ style: composeStyles(styles.wave, mirrored),
647
+ width,
648
+ children: [/* @__PURE__ */ jsx(WaveBar, {
649
+ bar: PRIMARY_BAR,
650
+ clock,
651
+ colors,
652
+ width
653
+ }), /* @__PURE__ */ jsx(WaveBar, {
654
+ bar: SECONDARY_BAR,
655
+ clock,
656
+ colors,
657
+ width
658
+ })]
659
+ }) : null;
660
+ $[14] = clock;
661
+ $[15] = colors;
662
+ $[16] = mirrored;
663
+ $[17] = waves;
664
+ $[18] = width;
665
+ $[19] = t6;
666
+ } else t6 = $[19];
667
+ let t7;
668
+ if ($[20] !== t5 || $[21] !== t6) {
669
+ t7 = /* @__PURE__ */ jsxs(Fragment, { children: [t5, t6] });
670
+ $[20] = t5;
671
+ $[21] = t6;
672
+ $[22] = t7;
673
+ } else t7 = $[22];
674
+ return t7;
675
+ }
676
+ function isWaving(percentage) {
677
+ return percentage > WAVE_FROM && percentage < WAVE_UNTIL;
678
+ }
679
+ /**
680
+ * The line, measured: the row is laid out first and the line drawn to its
681
+ * width, which is what web's `calc()` and container units do without a
682
+ * measurement.
683
+ */
684
+ function LinearTrack(t0) {
685
+ const $ = c(11);
686
+ const { buffer, colors, isIndeterminate, percentage, shape } = t0;
687
+ const { onLayout, width } = useMeasuredWidth();
688
+ const reduceMotion = useReducedMotion();
689
+ const wavy = shape === "wavy";
690
+ const waves = wavy && !reduceMotion && width <= WAVE_REACH;
691
+ const t1 = wavy ? styles.wavyLine : styles.line;
692
+ let t2;
693
+ if ($[0] !== buffer || $[1] !== colors || $[2] !== isIndeterminate || $[3] !== percentage || $[4] !== waves || $[5] !== width) {
694
+ t2 = isIndeterminate ? /* @__PURE__ */ jsx(IndeterminateLine, {
695
+ colors,
696
+ waves,
697
+ width
698
+ }) : /* @__PURE__ */ jsx(DeterminateLine, {
699
+ buffer,
700
+ colors,
701
+ percentage,
702
+ waves,
703
+ width
704
+ });
705
+ $[0] = buffer;
706
+ $[1] = colors;
707
+ $[2] = isIndeterminate;
708
+ $[3] = percentage;
709
+ $[4] = waves;
710
+ $[5] = width;
711
+ $[6] = t2;
712
+ } else t2 = $[6];
713
+ let t3;
714
+ if ($[7] !== onLayout || $[8] !== t1 || $[9] !== t2) {
715
+ t3 = /* @__PURE__ */ jsx(View, {
716
+ onLayout,
717
+ style: t1,
718
+ children: t2
719
+ });
720
+ $[7] = onLayout;
721
+ $[8] = t1;
722
+ $[9] = t2;
723
+ $[10] = t3;
724
+ } else t3 = $[10];
725
+ return t3;
726
+ }
727
+ /** The determinate line's wave, cut to the active indicator's length. */
728
+ function LineWave(t0) {
729
+ const $ = c(9);
730
+ const { colors, fade, shown, width } = t0;
731
+ const wave = useAnimatedProps(() => {
732
+ "worklet";
733
+ const length = Math.max(0, activeLength(width, shown.get()) - 4);
734
+ return {
735
+ d: wavePath(WAVE_WAVELENGTH, WAVE_ORIGIN, WAVE_ORIGIN + length),
736
+ opacity: fade.get()
737
+ };
738
+ });
739
+ let t1;
740
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
741
+ t1 = composeStyles(styles.wave, I18nManager.isRTL ? styles.mirrored : void 0);
742
+ $[0] = t1;
743
+ } else t1 = $[0];
744
+ let t2;
745
+ if ($[1] !== colors.active) {
746
+ t2 = strokeOf(colors.active);
747
+ $[1] = colors.active;
748
+ $[2] = t2;
749
+ } else t2 = $[2];
750
+ let t3;
751
+ if ($[3] !== t2 || $[4] !== wave) {
752
+ t3 = /* @__PURE__ */ jsx(AnimatedPath, {
753
+ animatedProps: wave,
754
+ ...t2
755
+ });
756
+ $[3] = t2;
757
+ $[4] = wave;
758
+ $[5] = t3;
759
+ } else t3 = $[5];
760
+ let t4;
761
+ if ($[6] !== t3 || $[7] !== width) {
762
+ t4 = /* @__PURE__ */ jsx(Svg, {
763
+ ...HIDDEN,
764
+ height: WAVE_HEIGHT,
765
+ style: t1,
766
+ width,
767
+ children: t3
768
+ });
769
+ $[6] = t3;
770
+ $[7] = width;
771
+ $[8] = t4;
772
+ } else t4 = $[8];
773
+ return t4;
774
+ }
775
+ /**
776
+ * Progress through a task, as a line or a ring. Pass `value` between
777
+ * `minValue` and `maxValue`, or set `isIndeterminate` for work whose length is
778
+ * not known. `formatOptions` says how the value reads, in `locale`, and
779
+ * `buffer` marks how far the work is loaded ahead of it.
780
+ *
781
+ * ```tsx
782
+ * <ProgressIndicator label="Label" showValue value={40} />
783
+ * ```
784
+ *
785
+ * A screen reader hears it as a progress bar named by its label, with its
786
+ * value as `formatOptions` writes it, and no value while it is indeterminate.
787
+ * `style`, `ref` and `testID` land on the indicator as a whole, which is the
788
+ * view a layout positions.
789
+ */
790
+ function ProgressIndicator(t0) {
791
+ const $ = c(41);
792
+ let ariaLabel;
793
+ let buffer;
794
+ let diameter;
795
+ let formatOptions;
796
+ let label;
797
+ let locale;
798
+ let props;
799
+ let style;
800
+ let t1;
801
+ let t2;
802
+ let t3;
803
+ let t4;
804
+ let t5;
805
+ let t6;
806
+ let t7;
807
+ let t8;
808
+ let valueLabel;
809
+ if ($[0] !== t0) {
810
+ ({"aria-label": ariaLabel, buffer, diameter, formatOptions, isIndeterminate: t1, label, locale, maxValue: t2, minValue: t3, shape: t4, showValue: t5, style, tone: t6, value: t7, valueLabel, variant: t8, ...props} = t0);
811
+ $[0] = t0;
812
+ $[1] = ariaLabel;
813
+ $[2] = buffer;
814
+ $[3] = diameter;
815
+ $[4] = formatOptions;
816
+ $[5] = label;
817
+ $[6] = locale;
818
+ $[7] = props;
819
+ $[8] = style;
820
+ $[9] = t1;
821
+ $[10] = t2;
822
+ $[11] = t3;
823
+ $[12] = t4;
824
+ $[13] = t5;
825
+ $[14] = t6;
826
+ $[15] = t7;
827
+ $[16] = t8;
828
+ $[17] = valueLabel;
829
+ } else {
830
+ ariaLabel = $[1];
831
+ buffer = $[2];
832
+ diameter = $[3];
833
+ formatOptions = $[4];
834
+ label = $[5];
835
+ locale = $[6];
836
+ props = $[7];
837
+ style = $[8];
838
+ t1 = $[9];
839
+ t2 = $[10];
840
+ t3 = $[11];
841
+ t4 = $[12];
842
+ t5 = $[13];
843
+ t6 = $[14];
844
+ t7 = $[15];
845
+ t8 = $[16];
846
+ valueLabel = $[17];
847
+ }
848
+ const isIndeterminate = t1 === void 0 ? false : t1;
849
+ const maxValue = t2 === void 0 ? 100 : t2;
850
+ const minValue = t3 === void 0 ? 0 : t3;
851
+ const shape = t4 === void 0 ? "flat" : t4;
852
+ const showValue = t5 === void 0 ? false : t5;
853
+ const tone = t6 === void 0 ? "primary" : t6;
854
+ const value = t7 === void 0 ? 0 : t7;
855
+ const variant = t8 === void 0 ? "linear" : t8;
856
+ const theme = useTheme();
857
+ const colors = useIndicatorColors(tone);
858
+ let t9;
859
+ if ($[18] !== ariaLabel || $[19] !== buffer || $[20] !== colors || $[21] !== diameter || $[22] !== formatOptions || $[23] !== isIndeterminate || $[24] !== label || $[25] !== locale || $[26] !== maxValue || $[27] !== minValue || $[28] !== props || $[29] !== shape || $[30] !== showValue || $[31] !== style || $[32] !== theme || $[33] !== value || $[34] !== valueLabel || $[35] !== variant) {
860
+ const reading = readingOf({
861
+ formatOptions,
862
+ locale,
863
+ maxValue,
864
+ minValue,
865
+ value,
866
+ valueLabel
867
+ });
868
+ const text = isIndeterminate ? void 0 : reading.text;
869
+ let t10;
870
+ if ($[37] !== style || $[38] !== theme || $[39] !== variant) {
871
+ t10 = composeStyles(stylesOf$1(theme).root, variant === "circular" ? styles.rootCircular : void 0, style);
872
+ $[37] = style;
873
+ $[38] = theme;
874
+ $[39] = variant;
875
+ $[40] = t10;
876
+ } else t10 = $[40];
877
+ t9 = /* @__PURE__ */ jsxs(View, {
878
+ accessible: true,
879
+ "aria-label": label ?? ariaLabel,
880
+ "aria-valuemax": maxValue,
881
+ "aria-valuemin": minValue,
882
+ "aria-valuenow": isIndeterminate ? void 0 : reading.value,
883
+ "aria-valuetext": text,
884
+ role: "progressbar",
885
+ ...props,
886
+ style: t10,
887
+ children: [/* @__PURE__ */ jsx(IndicatorLabels, {
888
+ label,
889
+ value: showValue ? text : void 0
890
+ }), variant === "circular" ? /* @__PURE__ */ jsx(CircularTrack, {
891
+ colors,
892
+ diameter: (diameter === void 0 ? void 0 : parseLength(diameter)) ?? (shape === "wavy" ? WAVY_SIZE : CIRCULAR_SIZE),
893
+ isIndeterminate,
894
+ percentage: reading.percentage,
895
+ shape
896
+ }) : /* @__PURE__ */ jsx(LinearTrack, {
897
+ buffer: bufferShare(buffer, reading.percentage, minValue, maxValue),
898
+ colors,
899
+ isIndeterminate,
900
+ percentage: reading.percentage,
901
+ shape
902
+ })]
903
+ });
904
+ $[18] = ariaLabel;
905
+ $[19] = buffer;
906
+ $[20] = colors;
907
+ $[21] = diameter;
908
+ $[22] = formatOptions;
909
+ $[23] = isIndeterminate;
910
+ $[24] = label;
911
+ $[25] = locale;
912
+ $[26] = maxValue;
913
+ $[27] = minValue;
914
+ $[28] = props;
915
+ $[29] = shape;
916
+ $[30] = showValue;
917
+ $[31] = style;
918
+ $[32] = theme;
919
+ $[33] = value;
920
+ $[34] = valueLabel;
921
+ $[35] = variant;
922
+ $[36] = t9;
923
+ } else t9 = $[36];
924
+ return t9;
925
+ }
926
+ /**
927
+ * The wave over the ring's active arc, cut by the same lengths, or running
928
+ * round as the indeterminate arc does. Its crests turn with the ring.
929
+ */
930
+ function RingWavePath(t0) {
931
+ const $ = c(5);
932
+ const { arc, colors, cycle, fade, isIndeterminate, shown, turn } = t0;
933
+ const wave = useAnimatedProps(() => {
934
+ "worklet";
935
+ if (isIndeterminate) {
936
+ const phase = TURN / 4 + TURN * turn.get();
937
+ return {
938
+ d: wavyArcPath(RING_WAVE, phase, phase + TURN * keyframeAt(TRAVEL_ARC, cycle.get()), TURN * keyframeAt(EXPAND_ARC, arc.get())),
939
+ opacity: fade.get()
940
+ };
941
+ }
942
+ return {
943
+ d: wavyArcPath(RING_WAVE, 0, 0, TURN * shown.get() / 100),
944
+ opacity: fade.get()
945
+ };
946
+ });
947
+ let t1;
948
+ if ($[0] !== colors.active) {
949
+ t1 = strokeOf(colors.active);
950
+ $[0] = colors.active;
951
+ $[1] = t1;
952
+ } else t1 = $[1];
953
+ let t2;
954
+ if ($[2] !== t1 || $[3] !== wave) {
955
+ t2 = /* @__PURE__ */ jsx(AnimatedPath, {
956
+ animatedProps: wave,
957
+ ...t1
958
+ });
959
+ $[2] = t1;
960
+ $[3] = wave;
961
+ $[4] = t2;
962
+ } else t2 = $[4];
963
+ return t2;
964
+ }
965
+ function strokeOf(color) {
966
+ return {
967
+ fill: "none",
968
+ stroke: color,
969
+ strokeLinecap: "round",
970
+ strokeLinejoin: "round",
971
+ strokeWidth: 4
972
+ };
973
+ }
974
+ /**
975
+ * A bar of the indeterminate line where the clock has it: its start, and its
976
+ * scale from there, both as web's keyframes give them in shares of the row.
977
+ */
978
+ function useBarStyle(clock, bar, width) {
979
+ return useAnimatedStyle(() => {
980
+ "worklet";
981
+ const time = clock.get();
982
+ return { transform: [{ translateX: (bar.start + keyframeAt(bar.translate, time)) * width }, { scaleX: keyframeAt(bar.scale, time) }] };
983
+ });
984
+ }
985
+ /**
986
+ * A bar of the indeterminate line drawn as a stretch of the wave: from where
987
+ * the flat bar starts, as long as the flat bar is, and nothing of it before
988
+ * the wave's own start.
989
+ */
990
+ function WaveBar(t0) {
991
+ const $ = c(5);
992
+ const { bar, clock, colors, width } = t0;
993
+ const wave = useAnimatedProps(() => {
994
+ "worklet";
995
+ const time = clock.get();
996
+ const from = WAVE_ORIGIN + (bar.start + keyframeAt(bar.translate, time)) * width;
997
+ const to = from + keyframeAt(bar.scale, time) * width;
998
+ return { d: wavePath(INDETERMINATE_WAVELENGTH, Math.max(WAVE_ORIGIN, from), Math.min(WAVE_ORIGIN + width, to)) };
999
+ });
1000
+ let t1;
1001
+ if ($[0] !== colors.active) {
1002
+ t1 = strokeOf(colors.active);
1003
+ $[0] = colors.active;
1004
+ $[1] = t1;
1005
+ } else t1 = $[1];
1006
+ let t2;
1007
+ if ($[2] !== t1 || $[3] !== wave) {
1008
+ t2 = /* @__PURE__ */ jsx(AnimatedPath, {
1009
+ animatedProps: wave,
1010
+ ...t1
1011
+ });
1012
+ $[2] = t1;
1013
+ $[3] = wave;
1014
+ $[4] = t2;
1015
+ } else t2 = $[4];
1016
+ return t2;
1017
+ }
1018
+ function widthOf(width) {
1019
+ return { width };
1020
+ }
1021
+ //#endregion
1022
+ export { ProgressIndicator };
1023
+
1024
+ //# sourceMappingURL=index.js.map