panelui-native 0.22.6 → 0.25.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 (135) hide show
  1. package/README.md +1 -0
  2. package/lib/module/components/area-chart/index.js +826 -0
  3. package/lib/module/components/area-chart/index.js.map +1 -0
  4. package/lib/module/components/avatar/index.js +1 -1
  5. package/lib/module/components/avatar/index.js.map +1 -1
  6. package/lib/module/components/bar-chart/index.js +853 -0
  7. package/lib/module/components/bar-chart/index.js.map +1 -0
  8. package/lib/module/components/bottom-sheet/index.js +207 -23
  9. package/lib/module/components/bottom-sheet/index.js.map +1 -1
  10. package/lib/module/components/breadcrumb/index.js +275 -0
  11. package/lib/module/components/breadcrumb/index.js.map +1 -0
  12. package/lib/module/components/chip/index.js +2 -2
  13. package/lib/module/components/direction/index.js +13 -19
  14. package/lib/module/components/direction/index.js.map +1 -1
  15. package/lib/module/components/frame/index.js +17 -0
  16. package/lib/module/components/frame/index.js.map +1 -1
  17. package/lib/module/components/heatmap-chart/index.js +28 -8
  18. package/lib/module/components/heatmap-chart/index.js.map +1 -1
  19. package/lib/module/components/input-group/index.js +2 -2
  20. package/lib/module/components/input-group/index.js.map +1 -1
  21. package/lib/module/components/line-chart/index.js +4 -146
  22. package/lib/module/components/line-chart/index.js.map +1 -1
  23. package/lib/module/components/loader/index.js +758 -0
  24. package/lib/module/components/loader/index.js.map +1 -0
  25. package/lib/module/components/map/basemap.js +265 -0
  26. package/lib/module/components/map/basemap.js.map +1 -0
  27. package/lib/module/components/map/index.js +850 -0
  28. package/lib/module/components/map/index.js.map +1 -0
  29. package/lib/module/components/map/maplibre.js +87 -0
  30. package/lib/module/components/map/maplibre.js.map +1 -0
  31. package/lib/module/components/message/index.js +8 -7
  32. package/lib/module/components/message/index.js.map +1 -1
  33. package/lib/module/components/otp-input/index.js +2 -2
  34. package/lib/module/components/progress/index.js +8 -2
  35. package/lib/module/components/progress/index.js.map +1 -1
  36. package/lib/module/components/ring-chart/index.js +423 -0
  37. package/lib/module/components/ring-chart/index.js.map +1 -0
  38. package/lib/module/components/section-rail/index.js +2 -2
  39. package/lib/module/components/separator/index.js +76 -22
  40. package/lib/module/components/separator/index.js.map +1 -1
  41. package/lib/module/components/shimmer/index.js +10 -1
  42. package/lib/module/components/shimmer/index.js.map +1 -1
  43. package/lib/module/components/slider/index.js +19 -5
  44. package/lib/module/components/slider/index.js.map +1 -1
  45. package/lib/module/components/steps/index.js +1 -1
  46. package/lib/module/components/switch/index.js +6 -1
  47. package/lib/module/components/switch/index.js.map +1 -1
  48. package/lib/module/components/typography/index.js +5 -0
  49. package/lib/module/components/typography/index.js.map +1 -1
  50. package/lib/module/hooks/use-direction.js +43 -0
  51. package/lib/module/hooks/use-direction.js.map +1 -0
  52. package/lib/module/icons/index.js +117 -2
  53. package/lib/module/icons/index.js.map +1 -1
  54. package/lib/module/index.js +8 -2
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/primitives/text.js +30 -10
  57. package/lib/module/primitives/text.js.map +1 -1
  58. package/lib/module/utils/chart.js +279 -0
  59. package/lib/module/utils/chart.js.map +1 -0
  60. package/lib/typescript/src/components/area-chart/index.d.ts +197 -0
  61. package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -0
  62. package/lib/typescript/src/components/bar-chart/index.d.ts +228 -0
  63. package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -0
  64. package/lib/typescript/src/components/bottom-sheet/index.d.ts +75 -4
  65. package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
  66. package/lib/typescript/src/components/breadcrumb/index.d.ts +100 -0
  67. package/lib/typescript/src/components/breadcrumb/index.d.ts.map +1 -0
  68. package/lib/typescript/src/components/direction/index.d.ts +11 -10
  69. package/lib/typescript/src/components/direction/index.d.ts.map +1 -1
  70. package/lib/typescript/src/components/frame/index.d.ts +17 -0
  71. package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
  72. package/lib/typescript/src/components/heatmap-chart/index.d.ts +22 -3
  73. package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
  74. package/lib/typescript/src/components/line-chart/index.d.ts +1 -0
  75. package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
  76. package/lib/typescript/src/components/loader/index.d.ts +38 -0
  77. package/lib/typescript/src/components/loader/index.d.ts.map +1 -0
  78. package/lib/typescript/src/components/map/basemap.d.ts +76 -0
  79. package/lib/typescript/src/components/map/basemap.d.ts.map +1 -0
  80. package/lib/typescript/src/components/map/index.d.ts +367 -0
  81. package/lib/typescript/src/components/map/index.d.ts.map +1 -0
  82. package/lib/typescript/src/components/map/maplibre.d.ts +193 -0
  83. package/lib/typescript/src/components/map/maplibre.d.ts.map +1 -0
  84. package/lib/typescript/src/components/message/index.d.ts.map +1 -1
  85. package/lib/typescript/src/components/progress/index.d.ts.map +1 -1
  86. package/lib/typescript/src/components/ring-chart/index.d.ts +156 -0
  87. package/lib/typescript/src/components/ring-chart/index.d.ts.map +1 -0
  88. package/lib/typescript/src/components/separator/index.d.ts +36 -1
  89. package/lib/typescript/src/components/separator/index.d.ts.map +1 -1
  90. package/lib/typescript/src/components/shimmer/index.d.ts.map +1 -1
  91. package/lib/typescript/src/components/slider/index.d.ts.map +1 -1
  92. package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
  93. package/lib/typescript/src/components/typography/index.d.ts +6 -0
  94. package/lib/typescript/src/components/typography/index.d.ts.map +1 -1
  95. package/lib/typescript/src/hooks/use-direction.d.ts +20 -0
  96. package/lib/typescript/src/hooks/use-direction.d.ts.map +1 -0
  97. package/lib/typescript/src/icons/index.d.ts +5 -0
  98. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  99. package/lib/typescript/src/index.d.ts +9 -3
  100. package/lib/typescript/src/index.d.ts.map +1 -1
  101. package/lib/typescript/src/primitives/text.d.ts.map +1 -1
  102. package/lib/typescript/src/utils/chart.d.ts +96 -0
  103. package/lib/typescript/src/utils/chart.d.ts.map +1 -0
  104. package/package.json +9 -1
  105. package/src/components/area-chart/index.tsx +994 -0
  106. package/src/components/avatar/index.tsx +1 -1
  107. package/src/components/bar-chart/index.tsx +1048 -0
  108. package/src/components/bottom-sheet/index.tsx +280 -20
  109. package/src/components/breadcrumb/index.tsx +365 -0
  110. package/src/components/chip/index.tsx +2 -2
  111. package/src/components/direction/index.tsx +20 -21
  112. package/src/components/frame/index.tsx +17 -0
  113. package/src/components/heatmap-chart/index.tsx +58 -11
  114. package/src/components/input-group/index.tsx +2 -2
  115. package/src/components/line-chart/index.tsx +13 -181
  116. package/src/components/loader/index.tsx +812 -0
  117. package/src/components/map/basemap.ts +304 -0
  118. package/src/components/map/index.tsx +1118 -0
  119. package/src/components/map/maplibre.ts +201 -0
  120. package/src/components/message/index.tsx +8 -7
  121. package/src/components/otp-input/index.tsx +2 -2
  122. package/src/components/progress/index.tsx +10 -2
  123. package/src/components/ring-chart/index.tsx +543 -0
  124. package/src/components/section-rail/index.tsx +2 -2
  125. package/src/components/separator/index.tsx +77 -19
  126. package/src/components/shimmer/index.tsx +10 -1
  127. package/src/components/slider/index.tsx +20 -5
  128. package/src/components/steps/index.tsx +1 -1
  129. package/src/components/switch/index.tsx +6 -1
  130. package/src/components/typography/index.tsx +5 -0
  131. package/src/hooks/use-direction.ts +45 -0
  132. package/src/icons/index.tsx +66 -0
  133. package/src/index.ts +84 -0
  134. package/src/primitives/text.tsx +25 -7
  135. package/src/utils/chart.ts +355 -0
@@ -0,0 +1,423 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * RingChart — progress towards several targets, as concentric arcs.
5
+ *
6
+ * ```tsx
7
+ * <RingChart data={goals}>
8
+ * <RingChart.Ring index={0} />
9
+ * <RingChart.Ring index={1} />
10
+ * <RingChart.Center />
11
+ * <RingChart.Legend />
12
+ * </RingChart>
13
+ * ```
14
+ *
15
+ * ## What it is not
16
+ *
17
+ * It is not a pie or a donut, and the difference matters. A pie divides one
18
+ * whole between its slices, so its parts are only meaningful against each
19
+ * other and the angles must add to a full turn. A ring here is a value against
20
+ * *its own* target — three rings can all be at ninety percent of three
21
+ * unrelated numbers, and that is the reading. Nothing is normalised across
22
+ * rings, and nothing has to add up.
23
+ *
24
+ * That is also why each ring gets a track. An arc drawn on nothing shows how
25
+ * far something went; an arc drawn on a full circle shows how far it went *of
26
+ * what it was aiming at*, which is the entire question.
27
+ *
28
+ * ## Drawing
29
+ *
30
+ * Each ring is two arcs — a full-circle track and the progress over it — with
31
+ * only the progress animated, through `strokeDasharray`. Sweeping the arc by
32
+ * rebuilding its path would work, but a dash offset is two numbers moving on
33
+ * an unchanged path, and it keeps the rounded cap pinned to the moving end for
34
+ * free.
35
+ *
36
+ * Touch, not hover: a ring is selected by pressing it, and pressing the same
37
+ * one again clears the selection. There is no equivalent of a pointer resting
38
+ * somewhere without committing, so a chart that only revealed its numbers on
39
+ * hover would never reveal them at all.
40
+ */
41
+ import { Children, createContext, forwardRef, isValidElement, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
42
+ import { Pressable, View } from 'react-native';
43
+ import Animated, { Easing, useAnimatedProps, useReducedMotion, useSharedValue, withTiming } from 'react-native-reanimated';
44
+ import Svg, { Circle, G } from 'react-native-svg';
45
+ import { Text } from "../../primitives/text.js";
46
+ import { compactNumber, useSeriesColor } from "../../utils/chart.js";
47
+ import { cn } from "../../utils/cn.js";
48
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
49
+ const AnimatedCircle = Animated.createAnimatedComponent(Circle);
50
+
51
+ /** One ring per datum, and the datum is the whole of its contract. */
52
+
53
+ const RingChartContext = /*#__PURE__*/createContext(null);
54
+ function useChart(component) {
55
+ const context = useContext(RingChartContext);
56
+ if (!context) {
57
+ throw new Error(`${component} must be used within a <RingChart>`);
58
+ }
59
+ return context;
60
+ }
61
+
62
+ /** The selected ring, for something rendered inside the chart. */
63
+ export function useRingChart() {
64
+ const {
65
+ data,
66
+ activeIndex
67
+ } = useChart('useRingChart');
68
+ return {
69
+ activeIndex,
70
+ activeRing: activeIndex >= 0 ? data[activeIndex] ?? null : null
71
+ };
72
+ }
73
+
74
+ /** Imperative handle: re-run the sweep, for a "replay" control. */
75
+
76
+ const RingChartRoot = /*#__PURE__*/forwardRef(function RingChartRoot({
77
+ className,
78
+ data,
79
+ size,
80
+ strokeWidth = 12,
81
+ ringGap = 6,
82
+ animationDuration = 1100,
83
+ activeIndex: activeIndexProp,
84
+ onActiveIndexChange,
85
+ children,
86
+ ...props
87
+ }, ref) {
88
+ const [measured, setMeasured] = useState(0);
89
+ const [internalActive, setInternalActive] = useState(-1);
90
+ const reveal = useSharedValue(0);
91
+ const reducedMotion = useReducedMotion();
92
+ const controlled = activeIndexProp !== undefined;
93
+ const activeIndex = controlled ? activeIndexProp : internalActive;
94
+ const setActiveIndex = useMemo(() => index => {
95
+ if (!controlled) setInternalActive(index);
96
+ onActiveIndexChange?.(index);
97
+ }, [controlled, onActiveIndexChange]);
98
+ const box = size ?? measured;
99
+
100
+ /*
101
+ * Outermost ring first, so `data[0]` is the one the eye lands on. Each ring
102
+ * inside it steps in by its own thickness plus the gap.
103
+ */
104
+ const radiusOf = useMemo(() => index => Math.max(box / 2 - strokeWidth / 2 - index * (strokeWidth + ringGap), strokeWidth / 2), [box, strokeWidth, ringGap]);
105
+ const playReveal = useMemo(() => () => {
106
+ if (reducedMotion) {
107
+ reveal.value = 1;
108
+ return;
109
+ }
110
+ reveal.value = 0;
111
+ reveal.value = withTiming(1, {
112
+ duration: animationDuration,
113
+ easing: Easing.bezier(0.85, 0, 0.15, 1)
114
+ });
115
+ }, [reducedMotion, animationDuration, reveal]);
116
+ const revealed = useRef(false);
117
+ useEffect(() => {
118
+ if (revealed.current || box <= 0 || !data.length) return;
119
+ revealed.current = true;
120
+ playReveal();
121
+ }, [box, data.length, playReveal]);
122
+ useImperativeHandle(ref, () => ({
123
+ replay: playReveal
124
+ }), [playReveal]);
125
+
126
+ // Resolved here rather than inside each ring, so the legend and the centre
127
+ // readout can name a ring's colour without rendering one.
128
+ const c1 = useSeriesColor(undefined, 1);
129
+ const c2 = useSeriesColor(undefined, 2);
130
+ const c3 = useSeriesColor(undefined, 3);
131
+ const c4 = useSeriesColor(undefined, 4);
132
+ const c5 = useSeriesColor(undefined, 5);
133
+ const palette = useMemo(() => [c1, c2, c3, c4, c5], [c1, c2, c3, c4, c5]);
134
+ const colors = useMemo(() => data.map((ring, index) => ring.color ?? palette[index % palette.length]), [data, palette]);
135
+ const onLayout = event => {
136
+ const {
137
+ width,
138
+ height
139
+ } = event.nativeEvent.layout;
140
+ const next = Math.round(Math.min(width, height));
141
+ if (next !== measured) setMeasured(next);
142
+ props.onLayout?.(event);
143
+ };
144
+ const context = useMemo(() => ({
145
+ data,
146
+ size: box,
147
+ strokeWidth,
148
+ ringGap,
149
+ colors,
150
+ reveal,
151
+ activeIndex,
152
+ setActiveIndex,
153
+ radiusOf
154
+ }), [data, box, strokeWidth, ringGap, colors, reveal, activeIndex, setActiveIndex, radiusOf]);
155
+ const rings = [];
156
+ const overlay = [];
157
+ Children.forEach(children, (child, index) => {
158
+ if (! /*#__PURE__*/isValidElement(child)) return;
159
+ const slot = child.type.slot ?? 'overlay';
160
+ (slot === 'ring' ? rings : overlay).push(/*#__PURE__*/_jsx(ChildSlot, {
161
+ children: child
162
+ }, index));
163
+ });
164
+ return /*#__PURE__*/_jsx(RingChartContext.Provider, {
165
+ value: context,
166
+ children: /*#__PURE__*/_jsx(View, {
167
+ ...props,
168
+ onLayout: onLayout,
169
+ style: [size ? {
170
+ width: size,
171
+ height: size
172
+ } : {
173
+ aspectRatio: 1
174
+ }, props.style],
175
+ className: cn('w-full items-center justify-center', className),
176
+ children: box > 0 ? /*#__PURE__*/_jsxs(_Fragment, {
177
+ children: [/*#__PURE__*/_jsx(Svg, {
178
+ width: box,
179
+ height: box,
180
+ children: rings
181
+ }), /*#__PURE__*/_jsx(View, {
182
+ pointerEvents: "box-none",
183
+ style: {
184
+ position: 'absolute',
185
+ width: box,
186
+ height: box
187
+ },
188
+ className: "items-center justify-center",
189
+ children: overlay
190
+ })]
191
+ }) : null
192
+ })
193
+ });
194
+ });
195
+ RingChartRoot.displayName = 'RingChart';
196
+ function ChildSlot({
197
+ children
198
+ }) {
199
+ return /*#__PURE__*/_jsx(_Fragment, {
200
+ children: children
201
+ });
202
+ }
203
+ /**
204
+ * One ring: a full-circle track, and the arc showing how far along it the
205
+ * value has got.
206
+ *
207
+ * The arc is swept with `strokeDasharray` rather than by rebuilding its path.
208
+ * Both work, but a dash offset moves two numbers on a path that never changes
209
+ * — and it keeps the rounded cap pinned to the moving end without any extra
210
+ * geometry.
211
+ */
212
+ function RingChartRing({
213
+ index,
214
+ color,
215
+ colorIndex,
216
+ lineCap = 'round',
217
+ trackOpacity = 0.15
218
+ }) {
219
+ const {
220
+ data,
221
+ size,
222
+ strokeWidth,
223
+ colors,
224
+ reveal,
225
+ activeIndex,
226
+ setActiveIndex,
227
+ radiusOf
228
+ } = useChart('RingChart.Ring');
229
+ const datum = data[index];
230
+ const tokenColor = useSeriesColor(undefined, colorIndex ?? 1);
231
+ const stroke = color ?? datum?.color ?? (colorIndex ? tokenColor : colors[index]) ?? tokenColor;
232
+ const radius = radiusOf(index);
233
+ const circumference = 2 * Math.PI * radius;
234
+ const centre = size / 2;
235
+ const fraction = datum && datum.maxValue > 0 ? datum.value / datum.maxValue : 0;
236
+ // A value past its target fills the ring and stops. Going round twice would
237
+ // draw 110% as 10%, which is the wrong answer told confidently.
238
+ const clamped = Math.max(0, Math.min(1, fraction));
239
+
240
+ /*
241
+ * Staggered outward-in, so the rings arrive as a sequence rather than all at
242
+ * once. The window each gets is what is left after the stagger, so a chart
243
+ * of five rings still finishes inside the one duration.
244
+ */
245
+ const count = Math.max(1, data.length);
246
+ const start = index / count * 0.4;
247
+ const props = useAnimatedProps(() => {
248
+ const progress = Math.max(0, Math.min(1, (reveal.value - start) / 0.6));
249
+ const drawn = circumference * clamped * progress;
250
+ return {
251
+ strokeDasharray: [drawn, circumference]
252
+ };
253
+ });
254
+ const dimmed = activeIndex >= 0 && activeIndex !== index;
255
+ if (!datum || radius <= 0) return null;
256
+ return /*#__PURE__*/_jsxs(G, {
257
+ opacity: dimmed ? 0.35 : 1,
258
+ children: [/*#__PURE__*/_jsx(Circle, {
259
+ cx: centre,
260
+ cy: centre,
261
+ r: radius,
262
+ stroke: stroke,
263
+ strokeOpacity: trackOpacity,
264
+ strokeWidth: strokeWidth,
265
+ fill: "none"
266
+ }), /*#__PURE__*/_jsx(AnimatedCircle, {
267
+ animatedProps: props,
268
+ cx: centre,
269
+ cy: centre,
270
+ r: radius,
271
+ stroke: stroke,
272
+ strokeWidth: strokeWidth,
273
+ strokeLinecap: lineCap,
274
+ fill: "none"
275
+ // Rotated so the arc starts at twelve o'clock. An arc starting at
276
+ // three reads as a gauge that has already been running.
277
+ ,
278
+ transform: `rotate(-90 ${centre} ${centre})`
279
+ }), /*#__PURE__*/_jsx(Circle, {
280
+ cx: centre,
281
+ cy: centre,
282
+ r: radius,
283
+ stroke: "transparent",
284
+ strokeWidth: Math.max(strokeWidth, 28),
285
+ fill: "none",
286
+ onPress: () => setActiveIndex(activeIndex === index ? -1 : index)
287
+ })]
288
+ });
289
+ }
290
+ RingChartRing.displayName = 'RingChart.Ring';
291
+ RingChartRing.slot = 'ring';
292
+ /**
293
+ * The readout in the hole.
294
+ *
295
+ * With nothing selected it shows the outermost ring — the one the eye lands on
296
+ * first. Not a total: the rings measure different things against different
297
+ * targets, so their values do not add up and their percentages do not average,
298
+ * and a total here would be a confident number about nothing. Selecting a ring
299
+ * swaps it for that ring's own figures.
300
+ */
301
+ function RingChartCenter({
302
+ defaultLabel,
303
+ formatValue,
304
+ children,
305
+ className
306
+ }) {
307
+ const {
308
+ data,
309
+ activeIndex,
310
+ strokeWidth,
311
+ radiusOf
312
+ } = useChart('RingChart.Center');
313
+
314
+ /*
315
+ * With nothing selected the centre shows the outermost ring — the one the
316
+ * eye lands on — rather than an aggregate. There is no aggregate to show:
317
+ * the rings measure different things against different targets, so their
318
+ * values do not add up and their percentages do not average. A total here
319
+ * would be a confident number about nothing.
320
+ */
321
+ const ring = (activeIndex >= 0 ? data[activeIndex] : data[0]) ?? null;
322
+ const selected = activeIndex >= 0;
323
+ const format = formatValue ?? (amount => compactNumber(amount));
324
+
325
+ /*
326
+ * The hole is what is left inside the innermost ring, measured off the same
327
+ * function that places the rings so the two cannot disagree. Text wider than
328
+ * it would sit on the arcs rather than inside them.
329
+ */
330
+ const inner = Math.max(radiusOf(Math.max(data.length - 1, 0)) - strokeWidth / 2, 0);
331
+ // A square inside a circle, not across it: the corners of a box as wide as
332
+ // the diameter fall outside the hole.
333
+ const hole = inner * Math.SQRT2;
334
+ return /*#__PURE__*/_jsx(View, {
335
+ pointerEvents: "none",
336
+ style: {
337
+ maxWidth: hole
338
+ },
339
+ className: cn('items-center', className),
340
+ children: children ? children(selected ? ring : null) : ring ? /*#__PURE__*/_jsxs(_Fragment, {
341
+ children: [/*#__PURE__*/_jsx(Text, {
342
+ size: "xs",
343
+ muted: true,
344
+ numberOfLines: 1,
345
+ children: selected ? ring.label : defaultLabel ?? ring.label
346
+ }), /*#__PURE__*/_jsx(Text, {
347
+ size: hole < 90 ? 'lg' : 'xl',
348
+ weight: "semibold",
349
+ numberOfLines: 1,
350
+ children: format(ring.value, ring)
351
+ }), hole >= 90 ? /*#__PURE__*/_jsx(Text, {
352
+ size: "xs",
353
+ muted: true,
354
+ numberOfLines: 1,
355
+ children: `of ${format(ring.maxValue, ring)}`
356
+ }) : null]
357
+ }) : null
358
+ });
359
+ }
360
+ RingChartCenter.displayName = 'RingChart.Center';
361
+ RingChartCenter.slot = 'overlay';
362
+ /**
363
+ * A swatch and a name per ring, pressable in the same way the rings are — the
364
+ * legend is usually the easier target of the two, and on a small chart it is
365
+ * the only comfortable one.
366
+ */
367
+ function RingChartLegend({
368
+ className,
369
+ showValue = true,
370
+ ...props
371
+ }) {
372
+ const {
373
+ data,
374
+ colors,
375
+ activeIndex,
376
+ setActiveIndex
377
+ } = useChart('RingChart.Legend');
378
+ if (!data.length) return null;
379
+ return /*#__PURE__*/_jsx(View, {
380
+ ...props,
381
+ pointerEvents: "box-none",
382
+ className: cn('absolute -bottom-2 w-full gap-1', className),
383
+ children: data.map((ring, index) => {
384
+ const percent = ring.maxValue > 0 ? Math.round(ring.value / ring.maxValue * 100) : 0;
385
+ const dimmed = activeIndex >= 0 && activeIndex !== index;
386
+ return /*#__PURE__*/_jsxs(Pressable, {
387
+ accessibilityRole: "button",
388
+ accessibilityLabel: `${ring.label}, ${percent} percent`,
389
+ onPress: () => setActiveIndex(activeIndex === index ? -1 : index),
390
+ style: {
391
+ opacity: dimmed ? 0.4 : 1
392
+ },
393
+ className: "flex-row items-center gap-1.5",
394
+ children: [/*#__PURE__*/_jsx(View, {
395
+ style: {
396
+ width: 8,
397
+ height: 8,
398
+ borderRadius: 4,
399
+ backgroundColor: colors[index]
400
+ }
401
+ }), /*#__PURE__*/_jsx(Text, {
402
+ size: "xs",
403
+ muted: true,
404
+ numberOfLines: 1,
405
+ className: "flex-1",
406
+ children: ring.label
407
+ }), showValue ? /*#__PURE__*/_jsxs(Text, {
408
+ size: "xs",
409
+ weight: "medium",
410
+ children: [percent, "%"]
411
+ }) : null]
412
+ }, ring.label);
413
+ })
414
+ });
415
+ }
416
+ RingChartLegend.displayName = 'RingChart.Legend';
417
+ RingChartLegend.slot = 'overlay';
418
+ export const RingChart = Object.assign(RingChartRoot, {
419
+ Ring: RingChartRing,
420
+ Center: RingChartCenter,
421
+ Legend: RingChartLegend
422
+ });
423
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Children","createContext","forwardRef","isValidElement","useContext","useEffect","useImperativeHandle","useMemo","useRef","useState","Pressable","View","Animated","Easing","useAnimatedProps","useReducedMotion","useSharedValue","withTiming","Svg","Circle","G","Text","compactNumber","useSeriesColor","cn","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","AnimatedCircle","createAnimatedComponent","RingChartContext","useChart","component","context","Error","useRingChart","data","activeIndex","activeRing","RingChartRoot","className","size","strokeWidth","ringGap","animationDuration","activeIndexProp","onActiveIndexChange","children","props","ref","measured","setMeasured","internalActive","setInternalActive","reveal","reducedMotion","controlled","undefined","setActiveIndex","index","box","radiusOf","Math","max","playReveal","value","duration","easing","bezier","revealed","current","length","replay","c1","c2","c3","c4","c5","palette","colors","map","ring","color","onLayout","event","width","height","nativeEvent","layout","next","round","min","rings","overlay","forEach","child","slot","type","push","ChildSlot","Provider","style","aspectRatio","pointerEvents","position","displayName","RingChartRing","colorIndex","lineCap","trackOpacity","datum","tokenColor","stroke","radius","circumference","PI","centre","fraction","maxValue","clamped","count","start","progress","drawn","strokeDasharray","dimmed","opacity","cx","cy","r","strokeOpacity","fill","animatedProps","strokeLinecap","transform","onPress","RingChartCenter","defaultLabel","formatValue","selected","format","amount","inner","hole","SQRT2","maxWidth","muted","numberOfLines","label","weight","RingChartLegend","showValue","percent","accessibilityRole","accessibilityLabel","borderRadius","backgroundColor","RingChart","Object","assign","Ring","Center","Legend"],"sourceRoot":"../../../../src","sources":["components/ring-chart/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,SACEA,QAAQ,EACRC,aAAa,EACbC,UAAU,EACVC,cAAc,EACdC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAEH,OAAO;AACd,SAASC,SAAS,EAAEC,IAAI,QAAgD,cAAc;AACtF,OAAOC,QAAQ,IACbC,MAAM,EACNC,gBAAgB,EAChBC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QAEL,yBAAyB;AAChC,OAAOC,GAAG,IAAIC,MAAM,EAAEC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AI;MAAA,GAtBHvE,IAAI,CAACmE,KAuBD,CAAC;IAEhB,CAAC;EAAC,CACE,CAAC;AAEX;AACAE,eAAe,CAAC7C,WAAW,GAAG,kBAAkB;AAChD6C,eAAe,CAACtD,IAAI,GAAG,SAAkB;AAEzC,OAAO,MAAM6D,SAAS,GAAGC,MAAM,CAACC,MAAM,CAACxH,aAAa,EAAE;EACpDyH,IAAI,EAAEtD,aAAa;EACnBuD,MAAM,EAAEzB,eAAe;EACvB0B,MAAM,EAAEZ;AACV,CAAC,CAAC","ignoreList":[]}
@@ -182,7 +182,7 @@ function SectionRailTrigger({
182
182
  // Generous padding is the hit target; the bars themselves are hairlines.
183
183
  ,
184
184
  hitSlop: 8,
185
- className: cn('gap-2 py-3', placement === 'right' ? 'items-end pl-6 pr-2' : 'items-start pl-2 pr-6', className),
185
+ className: cn('gap-2 py-3', placement === 'right' ? 'items-end ps-6 pe-2' : 'items-start ps-2 pe-6', className),
186
186
  ...props,
187
187
  children: children
188
188
  });
@@ -336,7 +336,7 @@ function SectionRailItem({
336
336
  style: {
337
337
  paddingLeft: 12 + level * ITEM_INDENT
338
338
  },
339
- className: cn('rounded-lg py-2 pr-3 active:bg-accent', selected && 'bg-accent', className),
339
+ className: cn('rounded-lg py-2 pe-3 active:bg-accent', selected && 'bg-accent', className),
340
340
  children: /*#__PURE__*/_jsx(Text, {
341
341
  size: "sm",
342
342
  weight: selected ? 'medium' : 'normal',
@@ -11,17 +11,25 @@
11
11
  * ```tsx
12
12
  * <Separator />
13
13
  * <Separator orientation="vertical" />
14
+ * <Separator>or</Separator>
14
15
  * ```
15
16
  *
16
17
  * A vertical separator takes its length from the parent, so the parent needs a
17
18
  * height — inside a `flex-row` with `items-stretch`, or with an explicit `h-*`
18
19
  * on either the row or the separator itself. Without one it measures zero and
19
20
  * nothing draws.
21
+ *
22
+ * Passing children turns it into a *labelled* separator: the rule breaks around
23
+ * centred content — the "or continue with" divider in a sign-in form. Only the
24
+ * horizontal axis carries a label, because a stacked word is not a divider; a
25
+ * vertical separator ignores its children and stays a plain hairline.
20
26
  */
21
- import { forwardRef } from 'react';
27
+ import { forwardRef, isValidElement } from 'react';
22
28
  import { View } from 'react-native';
23
29
  import { tv } from 'tailwind-variants';
24
- import { jsx as _jsx } from "react/jsx-runtime";
30
+ import { Text } from "../../primitives/text.js";
31
+ import { cn } from "../../utils/cn.js";
32
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
33
  const separatorVariants = tv({
26
34
  base: 'bg-border',
27
35
  variants: {
@@ -61,31 +69,77 @@ const separatorVariants = tv({
61
69
  });
62
70
  export const Separator = /*#__PURE__*/forwardRef(({
63
71
  className,
72
+ labelClassName,
64
73
  orientation = 'horizontal',
65
74
  variant,
66
75
  thickness,
67
76
  decorative = true,
77
+ children,
68
78
  style,
69
79
  ...props
70
- }, ref) => /*#__PURE__*/_jsx(View, {
71
- ref: ref
72
- // `role` rather than `accessibilityRole` — React Native's older role list
73
- // has no separator, the ARIA-aligned one does.
74
- ,
75
- role: decorative ? 'none' : 'separator',
76
- accessible: !decorative,
77
- "aria-orientation": decorative ? undefined : orientation,
78
- className: separatorVariants({
79
- orientation,
80
- variant,
81
- className
82
- }),
83
- style: thickness !== undefined ? [orientation === 'horizontal' ? {
84
- height: thickness
85
- } : {
86
- width: thickness
87
- }, style] : style,
88
- ...props
89
- }));
80
+ }, ref) => {
81
+ const hasLabel = orientation === 'horizontal' && children != null && children !== false;
82
+
83
+ // Labelled: two rules flanking centred content. The label carries meaning,
84
+ // so the row announces itself as a separator regardless of `decorative`,
85
+ // and the flanking rules are hidden from the reader. Here `className`
86
+ // styles the wrapping row and `labelClassName` the text.
87
+ if (hasLabel) {
88
+ const rule = separatorVariants({
89
+ orientation,
90
+ variant
91
+ });
92
+ const ruleStyle = thickness !== undefined ? {
93
+ height: thickness
94
+ } : undefined;
95
+ return /*#__PURE__*/_jsxs(View, {
96
+ ref: ref,
97
+ role: "separator",
98
+ "aria-orientation": "horizontal",
99
+ className: cn('w-full flex-row items-center gap-3', className),
100
+ style: style,
101
+ ...props,
102
+ children: [/*#__PURE__*/_jsx(View, {
103
+ "aria-hidden": true,
104
+ className: rule,
105
+ style: [styles.flex, ruleStyle]
106
+ }), /*#__PURE__*/isValidElement(children) ? children : /*#__PURE__*/_jsx(Text, {
107
+ size: "xs",
108
+ muted: true,
109
+ className: labelClassName,
110
+ children: children
111
+ }), /*#__PURE__*/_jsx(View, {
112
+ "aria-hidden": true,
113
+ className: rule,
114
+ style: [styles.flex, ruleStyle]
115
+ })]
116
+ });
117
+ }
118
+ return /*#__PURE__*/_jsx(View, {
119
+ ref: ref
120
+ // `role` rather than `accessibilityRole` — React Native's older role list
121
+ // has no separator, the ARIA-aligned one does.
122
+ ,
123
+ role: decorative ? 'none' : 'separator',
124
+ accessible: !decorative,
125
+ "aria-orientation": decorative ? undefined : orientation,
126
+ className: separatorVariants({
127
+ orientation,
128
+ variant,
129
+ className
130
+ }),
131
+ style: thickness !== undefined ? [orientation === 'horizontal' ? {
132
+ height: thickness
133
+ } : {
134
+ width: thickness
135
+ }, style] : style,
136
+ ...props
137
+ });
138
+ });
90
139
  Separator.displayName = 'Separator';
140
+ const styles = {
141
+ flex: {
142
+ flex: 1
143
+ }
144
+ };
91
145
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["forwardRef","View","tv","jsx","_jsx","separatorVariants","base","variants","orientation","horizontal","vertical","variant","thin","thick","compoundVariants","class","defaultVariants","Separator","className","thickness","decorative","style","props","ref","role","accessible","undefined","height","width","displayName"],"sourceRoot":"../../../../src","sources":["components/separator/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,IAAI,QAAwB,cAAc;AACnD,SAASC,EAAE,QAA2B,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE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ClB,WAAW,KAAK,YAAY,GAAG;IAAEmB,MAAM,EAAER;EAAU,CAAC,GAAG;IAAES,KAAK,EAAET;EAAU,CAAC,EAAEE,KAAK,CAAC,GACpFA,KACL;EAAA,GACGC;AAAK,CACV,CAEL,CAAC;AAEDL,SAAS,CAACY,WAAW,GAAG,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["forwardRef","isValidElement","View","tv","Text","cn","jsx","_jsx","jsxs","_jsxs","separatorVariants","base","variants","orientation","horizontal","vertical","variant","thin","thick","compoundVariants","class","defaultVariants","Separator","className","labelClassName","thickness","decorative","children","style","props","ref","hasLabel","rule","ruleStyle","undefined","height","role","styles","flex","size","muted","accessible","width","displayName"],"sourceRoot":"../../../../src","sources":["components/separator/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,SAASA,UAAU,EAAEC,cAAc,QAAwB,OAAO;AAClE,SAASC,IAAI,QAAwB,cAAc;AACnD,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,IAAI,QAAQ,0BAAuB;AAC5C,SAASC,EAAE,QAAQ,mBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEpC,MAAMC,iBAAiB,GAAGP,EAAE,CAAC;EAC3BQ,IAAI,EAAE,WAAW;EACjBC,QAAQ,EAAE;IACRC,WAAW,EAAE;MACXC,UAAU,EAAE,QAAQ;MACpBC,QAAQ,EAAE;IACZ,CAAC;IACDC,OAAO,EAAE;MACPC,IAAI,EAAE,EAAE;MACRC,KAAK,EAAE;IACT;EACF,CAAC;EACDC,gBAAgB,EAAE;EAChB;EACA;EACA;IAAEN,WAAW,EAAE,YAAY;IAAEG,OAAO,EAAE,MAAM;IAAEI,KAAK,EAAE;EAAO,CAAC,EAC7D;IAAEP,WAAW,EAAE,YAAY;IAAEG,OAA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AhC,cAAc,CAAC0B,QAAQ,CAAC,GACvBA,QAAQ,gBAERpB,IAAA,CAACH,IAAI;QAACmC,IAAI,EAAC,IAAI;QAACC,KAAK;QAACjB,SAAS,EAAEC,cAAe;QAAAG,QAAA,EAC7CA;MAAQ,CACL,CACP,eACDpB,IAAA,CAACL,IAAI;QAAC,mBAAW;QAACqB,SAAS,EAAES,IAAK;QAACJ,KAAK,EAAE,CAACS,MAAM,CAACC,IAAI,EAAEL,SAAS;MAAE,CAAE,CAAC;IAAA,CAClE,CAAC;EAEX;EAEA,oBACE1B,IAAA,CAACL,IAAI;IACH4B,GAAG,EAAEA;IACL;IACA;IAAA;IACAM,IAAI,EAAEV,UAAU,GAAG,MAAM,GAAG,WAAY;IACxCe,UAAU,EAAE,CAACf,UAAW;IACxB,oBAAkBA,UAAU,GAAGQ,SAAS,GAAGrB,WAAY;IACvDU,SAAS,EAAEb,iBAAiB,CAAC;MAAEG,WAAW;MAAEG,OAAO;MAAEO;IAAU,CAAC,CAAE;IAClEK,KAAK,EACHH,SAAS,KAAKS,SAAS,GACnB,CAACrB,WAAW,KAAK,YAAY,GAAG;MAAEsB,MAAM,EAAEV;IAAU,CAAC,GAAG;MAAEiB,KAAK,EAAEjB;IAAU,CAAC,EAAEG,KAAK,CAAC,GACpFA,KACL;IAAA,GACGC;EAAK,CACV,CAAC;AAEN,CACF,CAAC;AAEDP,SAAS,CAACqB,WAAW,GAAG,WAAW;AAEnC,MAAMN,MAAM,GAAG;EAAEC,IAAI,EAAE;IAAEA,IAAI,EAAE;EAAE;AAAE,CAAU","ignoreList":[]}
@@ -21,6 +21,7 @@ import MaskedView from '@react-native-masked-view/masked-view';
21
21
  import { LinearGradient } from 'expo-linear-gradient';
22
22
  import Animated, { cancelAnimation, Easing, useAnimatedStyle, useReducedMotion, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
23
23
  import { useCSSVariable } from 'uniwind';
24
+ import { useDirectionSign } from "../../hooks/use-direction.js";
24
25
  import { Text } from "../../primitives/text.js";
25
26
  import { cn } from "../../utils/cn.js";
26
27
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -45,6 +46,8 @@ export function Shimmer({
45
46
  const [width, setWidth] = useState(0);
46
47
  const progress = useSharedValue(0);
47
48
  const reducedMotion = useReducedMotion();
49
+ // The sweep follows the reading direction; `reverse` then flips it again.
50
+ const sign = useDirectionSign();
48
51
  const themeMuted = useCSSVariable('--color-muted-foreground');
49
52
  const themeForeground = useCSSVariable('--color-foreground');
50
53
  const base = baseColor ?? (typeof themeMuted === 'string' ? themeMuted : '#a1a1aa');
@@ -71,7 +74,13 @@ export function Shimmer({
71
74
  // Travel from fully off one edge to fully off the other.
72
75
  const from = -bandWidth;
73
76
  const to = width;
74
- const x = reverse ? to - progress.value * (to - from) : from + progress.value * (to - from);
77
+ /*
78
+ * The sweep follows the reading direction. It is standing in for text
79
+ * arriving, and text arrives from the side you start reading on — a band
80
+ * travelling against the script reads as something leaving.
81
+ */
82
+ const backwards = reverse !== (sign === -1);
83
+ const x = backwards ? to - progress.value * (to - from) : from + progress.value * (to - from);
75
84
  return {
76
85
  transform: [{
77
86
  translateX: x