jfs-components 0.0.84 → 0.0.85

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 (43) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/lib/commonjs/components/AppBar/AppBar.js +36 -22
  3. package/lib/commonjs/components/AreaLineChart/AreaLineChart.js +866 -0
  4. package/lib/commonjs/components/AreaLineChart/chartMath.js +252 -0
  5. package/lib/commonjs/components/Attached/Attached.js +34 -4
  6. package/lib/commonjs/components/BubbleChart/BubbleChart.js +191 -0
  7. package/lib/commonjs/components/BubbleChart/bubblePacking.js +378 -0
  8. package/lib/commonjs/components/ClusterBubble/ClusterBubble.js +272 -0
  9. package/lib/commonjs/components/MetricLegendItem/MetricLegendItem.js +7 -1
  10. package/lib/commonjs/components/index.js +27 -0
  11. package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
  12. package/lib/commonjs/icons/registry.js +1 -1
  13. package/lib/module/components/AppBar/AppBar.js +36 -22
  14. package/lib/module/components/AreaLineChart/AreaLineChart.js +859 -0
  15. package/lib/module/components/AreaLineChart/chartMath.js +242 -0
  16. package/lib/module/components/Attached/Attached.js +34 -4
  17. package/lib/module/components/BubbleChart/BubbleChart.js +185 -0
  18. package/lib/module/components/BubbleChart/bubblePacking.js +370 -0
  19. package/lib/module/components/ClusterBubble/ClusterBubble.js +267 -0
  20. package/lib/module/components/MetricLegendItem/MetricLegendItem.js +7 -1
  21. package/lib/module/components/index.js +3 -0
  22. package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
  23. package/lib/module/icons/registry.js +1 -1
  24. package/lib/typescript/src/components/AreaLineChart/AreaLineChart.d.ts +212 -0
  25. package/lib/typescript/src/components/AreaLineChart/chartMath.d.ts +90 -0
  26. package/lib/typescript/src/components/BubbleChart/BubbleChart.d.ts +81 -0
  27. package/lib/typescript/src/components/BubbleChart/bubblePacking.d.ts +83 -0
  28. package/lib/typescript/src/components/ClusterBubble/ClusterBubble.d.ts +76 -0
  29. package/lib/typescript/src/components/MetricLegendItem/MetricLegendItem.d.ts +7 -1
  30. package/lib/typescript/src/components/index.d.ts +3 -0
  31. package/lib/typescript/src/icons/registry.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/src/components/AppBar/AppBar.tsx +37 -24
  34. package/src/components/AreaLineChart/AreaLineChart.tsx +1161 -0
  35. package/src/components/AreaLineChart/chartMath.ts +265 -0
  36. package/src/components/Attached/Attached.tsx +36 -5
  37. package/src/components/BubbleChart/BubbleChart.tsx +319 -0
  38. package/src/components/BubbleChart/bubblePacking.ts +397 -0
  39. package/src/components/ClusterBubble/ClusterBubble.tsx +359 -0
  40. package/src/components/MetricLegendItem/MetricLegendItem.tsx +20 -6
  41. package/src/components/index.ts +3 -0
  42. package/src/design-tokens/Coin Variables-variables-full.json +1 -1
  43. package/src/icons/registry.ts +1 -1
@@ -0,0 +1,370 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Dependency-free layout math for `BubbleChart`.
5
+ *
6
+ * Instead of a rigid ring, bubbles are arranged with a small **force
7
+ * simulation** — think of bubbles floating in a rectangular pool: each one
8
+ * repels the others (collision), a gentle pull keeps the cluster balanced
9
+ * (gravity), and the pool walls confine everything inside the container box so
10
+ * nothing overflows. Radii are first `sqrt`-scaled from the data magnitudes and
11
+ * down-scaled to fit the available area. Finally, for bubbles whose text must
12
+ * sit *outside* the circle, a direction chooser picks the side (top / bottom /
13
+ * left / right) with the most free space so labels avoid further collisions.
14
+ */
15
+
16
+ // --- Radius scaling --------------------------------------------------------
17
+
18
+ /**
19
+ * Map magnitudes to radii so a bubble's *area* scales with its value
20
+ * (`sqrt`-encoding), clamped into `[minRadius, maxRadius]`.
21
+ */
22
+ export function scaleRadii(magnitudes, minRadius, maxRadius) {
23
+ if (magnitudes.length === 0) return [];
24
+ const safe = magnitudes.map(m => Number.isFinite(m) && m > 0 ? m : 0);
25
+ let lo = Infinity;
26
+ let hi = -Infinity;
27
+ for (const m of safe) {
28
+ if (m < lo) lo = m;
29
+ if (m > hi) hi = m;
30
+ }
31
+ if (!Number.isFinite(lo) || !Number.isFinite(hi) || hi <= 0 || hi === lo) {
32
+ return safe.map(() => maxRadius);
33
+ }
34
+ const sqrtLo = Math.sqrt(lo);
35
+ const sqrtHi = Math.sqrt(hi);
36
+ const span = sqrtHi - sqrtLo;
37
+ return safe.map(m => {
38
+ if (m <= 0) return minRadius;
39
+ const t = span > 0 ? (Math.sqrt(m) - sqrtLo) / span : 1;
40
+ return minRadius + t * (maxRadius - minRadius);
41
+ });
42
+ }
43
+
44
+ /**
45
+ * Uniformly shrink radii (preserving relative proportions) so the bubbles plus
46
+ * some breathing room and label allowance fit inside the `width × height` box.
47
+ * Returns the radii unchanged when they already fit.
48
+ */
49
+ export function fitRadiiToBox(radii, width, height, options = {}) {
50
+ const {
51
+ density = 0.58,
52
+ labelArea = 0,
53
+ minRadius = 6
54
+ } = options;
55
+ if (radii.length === 0 || width <= 0 || height <= 0) return radii;
56
+ let circleArea = 0;
57
+ for (const r of radii) circleArea += Math.PI * r * r;
58
+ const required = circleArea / density + labelArea;
59
+ const available = width * height;
60
+ if (required <= available) return radii;
61
+
62
+ // Area scales with the square of the linear factor; ignore the (non-scaling)
63
+ // label term in the factor for simplicity — the sim's hard clamp covers the
64
+ // small remainder.
65
+ const factor = Math.sqrt(Math.max(0.05, (available - labelArea) / circleArea) * density);
66
+ return radii.map(r => Math.max(minRadius, r * Math.min(1, factor)));
67
+ }
68
+
69
+ // --- Force simulation ------------------------------------------------------
70
+
71
+ /** Tiny deterministic PRNG so layouts are reproducible across renders. */
72
+ function mulberry32(seed) {
73
+ let s = seed >>> 0;
74
+ return () => {
75
+ s = s + 0x6d2b79f5 >>> 0;
76
+ let t = s;
77
+ t = Math.imul(t ^ t >>> 15, t | 1);
78
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
79
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
80
+ };
81
+ }
82
+
83
+ /**
84
+ * Arrange circles inside a `width × height` box with a collision + gravity
85
+ * relaxation. Bubbles never overlap (separated by at least `gap`) and are hard-
86
+ * clamped within the walls so the cluster stays inside the container.
87
+ */
88
+ export function simulateCluster(radii, options) {
89
+ const {
90
+ width,
91
+ height,
92
+ gap = 8,
93
+ iterations = 500,
94
+ gravity = 0.02,
95
+ insetX = 0,
96
+ insetY = 0,
97
+ perimeter
98
+ } = options;
99
+ const n = radii.length;
100
+ const nodes = radii.map(r => ({
101
+ x: 0,
102
+ y: 0,
103
+ r
104
+ }));
105
+ if (n === 0) return nodes;
106
+ const cx = width / 2;
107
+ const cy = height / 2;
108
+ const rand = mulberry32(0x9e3779b9 ^ n * 2654435761);
109
+
110
+ // Seed positions on a phyllotaxis spiral so the relaxation starts spread out.
111
+ const spread = Math.min(width - 2 * insetX, height - 2 * insetY) * 0.45;
112
+ for (let i = 0; i < n; i++) {
113
+ const nd = nodes[i];
114
+ const a = i * 2.399963229728653; // golden angle
115
+ const rad = Math.sqrt((i + 0.5) / n) * spread;
116
+ nd.x = cx + Math.cos(a) * rad + (rand() - 0.5) * 2;
117
+ nd.y = cy + Math.sin(a) * rad + (rand() - 0.5) * 2;
118
+ }
119
+ const margin = gap / 2;
120
+ let maxR = 0;
121
+ for (const r of radii) if (r > maxR) maxR = r;
122
+ maxR = maxR || 1;
123
+ const clamp = () => {
124
+ for (const nd of nodes) {
125
+ const minX = insetX + nd.r + margin;
126
+ const maxX = Math.max(minX, width - insetX - nd.r - margin);
127
+ const minY = insetY + nd.r + margin;
128
+ const maxY = Math.max(minY, height - insetY - nd.r - margin);
129
+ nd.x = Math.min(maxX, Math.max(minX, nd.x));
130
+ nd.y = Math.min(maxY, Math.max(minY, nd.y));
131
+ }
132
+ };
133
+ for (let it = 0; it < iterations; it++) {
134
+ // Big bubbles are pulled to the center; "perimeter" bubbles (the small,
135
+ // outside-labelled ones) are pulled toward the wall ring so their labels
136
+ // land in the open band — like small bubbles floating around a big one.
137
+ for (let i = 0; i < n; i++) {
138
+ const nd = nodes[i];
139
+ if (perimeter && perimeter[i]) {
140
+ const dx = nd.x - cx;
141
+ const dy = nd.y - cy;
142
+ const d = Math.sqrt(dx * dx + dy * dy) || 1;
143
+ const targetD = Math.max(0, Math.min(width / 2 - insetX - nd.r - margin, height / 2 - insetY - nd.r - margin));
144
+ const f = (targetD - d) / d * gravity * 2;
145
+ nd.x += dx * f;
146
+ nd.y += dy * f;
147
+ } else {
148
+ const ratio = nd.r / maxR;
149
+ const g = gravity * (0.4 + 0.6 * ratio);
150
+ nd.x += (cx - nd.x) * g;
151
+ nd.y += (cy - nd.y) * g;
152
+ }
153
+ }
154
+
155
+ // Collision: push overlapping pairs apart. Two passes per tick keeps it
156
+ // stable for dense clusters. Smaller bubbles move more than bigger ones.
157
+ for (let pass = 0; pass < 2; pass++) {
158
+ for (let i = 0; i < n; i++) {
159
+ for (let j = i + 1; j < n; j++) {
160
+ const a = nodes[i];
161
+ const b = nodes[j];
162
+ let dx = b.x - a.x;
163
+ let dy = b.y - a.y;
164
+ let dist = Math.sqrt(dx * dx + dy * dy);
165
+ const min = a.r + b.r + gap;
166
+ if (dist < min) {
167
+ if (dist < 1e-6) {
168
+ dx = rand() - 0.5 || 0.01;
169
+ dy = rand() - 0.5 || 0.01;
170
+ dist = Math.sqrt(dx * dx + dy * dy);
171
+ }
172
+ const overlap = min - dist;
173
+ const ux = dx / dist;
174
+ const uy = dy / dist;
175
+ const total = a.r + b.r;
176
+ const aShare = b.r / total;
177
+ const bShare = a.r / total;
178
+ a.x -= ux * overlap * aShare;
179
+ a.y -= uy * overlap * aShare;
180
+ b.x += ux * overlap * bShare;
181
+ b.y += uy * overlap * bShare;
182
+ }
183
+ }
184
+ }
185
+ clamp();
186
+ }
187
+ }
188
+ return nodes;
189
+ }
190
+
191
+ // --- Outside-label sizing + direction --------------------------------------
192
+
193
+ /**
194
+ * Roughly estimate the rendered size of an outside label block (a bold value
195
+ * line stacked over a lighter caption line), used purely for layout scoring.
196
+ */
197
+ export function estimateLabelBox(value, label, options = {}) {
198
+ const {
199
+ valueFontSize = 24,
200
+ labelFontSize = 14
201
+ } = options;
202
+ // Slightly over-estimate width so the direction chooser reserves enough
203
+ // room and never picks a side that would clip the (wider) rendered text.
204
+ const valueW = value.length * valueFontSize * 0.68;
205
+ const labelW = label.length * labelFontSize * 0.6;
206
+ const valueH = value ? valueFontSize * 1.18 : 0;
207
+ const labelH = label ? labelFontSize * 1.32 : 0;
208
+ const gapBetween = value && label ? 2 : 0;
209
+ return {
210
+ w: Math.max(valueW, labelW, 1),
211
+ h: Math.max(valueH + labelH + gapBetween, 1)
212
+ };
213
+ }
214
+ const DIRECTIONS = ['bottom', 'right', 'left', 'top'];
215
+ function directionVector(dir) {
216
+ switch (dir) {
217
+ case 'top':
218
+ return {
219
+ x: 0,
220
+ y: -1
221
+ };
222
+ case 'bottom':
223
+ return {
224
+ x: 0,
225
+ y: 1
226
+ };
227
+ case 'left':
228
+ return {
229
+ x: -1,
230
+ y: 0
231
+ };
232
+ case 'right':
233
+ return {
234
+ x: 1,
235
+ y: 0
236
+ };
237
+ }
238
+ }
239
+
240
+ /** The rect an outside label occupies for a given direction (at `r + gap`). */
241
+ function labelRect(node, box, dir, gap) {
242
+ const {
243
+ x: cx,
244
+ y: cy,
245
+ r
246
+ } = node;
247
+ switch (dir) {
248
+ case 'bottom':
249
+ return {
250
+ x: cx - box.w / 2,
251
+ y: cy + r + gap,
252
+ w: box.w,
253
+ h: box.h
254
+ };
255
+ case 'top':
256
+ return {
257
+ x: cx - box.w / 2,
258
+ y: cy - r - gap - box.h,
259
+ w: box.w,
260
+ h: box.h
261
+ };
262
+ case 'right':
263
+ return {
264
+ x: cx + r + gap,
265
+ y: cy - box.h / 2,
266
+ w: box.w,
267
+ h: box.h
268
+ };
269
+ case 'left':
270
+ return {
271
+ x: cx - r - gap - box.w,
272
+ y: cy - box.h / 2,
273
+ w: box.w,
274
+ h: box.h
275
+ };
276
+ }
277
+ }
278
+ function rectOverlapArea(a, b) {
279
+ const ox = Math.max(0, Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x));
280
+ const oy = Math.max(0, Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y));
281
+ return ox * oy;
282
+ }
283
+
284
+ /** Approximate a circle as its bounding square for cheap rect/circle overlap. */
285
+ function rectCircleOverlap(rect, node) {
286
+ const circleRect = {
287
+ x: node.x - node.r,
288
+ y: node.y - node.r,
289
+ w: node.r * 2,
290
+ h: node.r * 2
291
+ };
292
+ return rectOverlapArea(rect, circleRect);
293
+ }
294
+
295
+ /**
296
+ * For each node that has an outside label (`labels[i]` non-null), pick the
297
+ * direction whose label rect best avoids the other circles, already-placed
298
+ * labels, and the container walls — biased to point *outward* (away from the
299
+ * cluster centroid, toward free space).
300
+ *
301
+ * Returns a direction per node, or `null` for nodes without an outside label.
302
+ */
303
+ export function chooseLabelDirections(nodes, labels, options) {
304
+ const {
305
+ width,
306
+ height,
307
+ gap = 8
308
+ } = options;
309
+ const result = nodes.map(() => null);
310
+ if (nodes.length === 0) return result;
311
+ let gx = 0;
312
+ let gy = 0;
313
+ for (const nd of nodes) {
314
+ gx += nd.x;
315
+ gy += nd.y;
316
+ }
317
+ gx /= nodes.length;
318
+ gy /= nodes.length;
319
+
320
+ // Place outer bubbles first — they sit near free space and deserve the best slot.
321
+ const order = nodes.map((_, i) => i).filter(i => labels[i]).sort((a, b) => {
322
+ const na = nodes[a];
323
+ const nb = nodes[b];
324
+ const da = (na.x - gx) ** 2 + (na.y - gy) ** 2;
325
+ const db = (nb.x - gx) ** 2 + (nb.y - gy) ** 2;
326
+ return db - da;
327
+ });
328
+ const placed = [];
329
+ for (const i of order) {
330
+ const node = nodes[i];
331
+ const box = labels[i];
332
+ const ox = node.x - gx;
333
+ const oy = node.y - gy;
334
+ const outLen = Math.hypot(ox, oy) || 1;
335
+ let best = 'bottom';
336
+ let bestScore = Infinity;
337
+ for (const dir of DIRECTIONS) {
338
+ const rect = labelRect(node, box, dir, gap);
339
+ let score = 0;
340
+
341
+ // Out-of-bounds is forbidden whenever any in-bounds option exists:
342
+ // a clipped label is the worst possible outcome. A large fixed
343
+ // penalty plus a proportional term enforces this.
344
+ const outX = Math.max(0, -rect.x) + Math.max(0, rect.x + rect.w - width);
345
+ const outY = Math.max(0, -rect.y) + Math.max(0, rect.y + rect.h - height);
346
+ if (outX > 0 || outY > 0) score += 1_000_000 + (outX + outY) * 150;
347
+
348
+ // Overlap with other circles.
349
+ for (let k = 0; k < nodes.length; k++) {
350
+ if (k === i) continue;
351
+ score += rectCircleOverlap(rect, nodes[k]);
352
+ }
353
+
354
+ // Overlap with previously-placed labels (penalized extra to spread).
355
+ for (const p of placed) score += rectOverlapArea(rect, p) * 2;
356
+
357
+ // Mild preference for pointing outward (toward open space).
358
+ const dv = directionVector(dir);
359
+ const align = (dv.x * ox + dv.y * oy) / outLen; // -1..1
360
+ score += (1 - align) * 15;
361
+ if (score < bestScore) {
362
+ bestScore = score;
363
+ best = dir;
364
+ }
365
+ }
366
+ result[i] = best;
367
+ placed.push(labelRect(node, box, best, gap));
368
+ }
369
+ return result;
370
+ }
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+
3
+ import React, { useMemo, useState } from 'react';
4
+ import { Pressable, StyleSheet, Text, View } from 'react-native';
5
+ import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
6
+ import { useTokens } from '../../design-tokens/JFSThemeProvider';
7
+ import { EMPTY_MODES } from '../../utils/react-utils';
8
+
9
+ /** Where the value/label text sits relative to the circle. */
10
+
11
+ /** Which side of the circle an *outside* label is anchored to. */
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ const DEFAULT_FILL = '#5d00b5';
14
+
15
+ /** Parse `#rgb`, `#rrggbb`, `rgb()` / `rgba()` into 0–255 channels. */
16
+ function parseColor(input) {
17
+ if (typeof input !== 'string') return null;
18
+ const value = input.trim();
19
+ if (value[0] === '#') {
20
+ let hex = value.slice(1);
21
+ if (hex.length === 3) {
22
+ hex = hex.split('').map(ch => ch + ch).join('');
23
+ }
24
+ if (hex.length >= 6) {
25
+ const r = parseInt(hex.slice(0, 2), 16);
26
+ const g = parseInt(hex.slice(2, 4), 16);
27
+ const b = parseInt(hex.slice(4, 6), 16);
28
+ if ([r, g, b].every(n => Number.isFinite(n))) return {
29
+ r,
30
+ g,
31
+ b
32
+ };
33
+ }
34
+ return null;
35
+ }
36
+ const match = value.match(/rgba?\(([^)]+)\)/i);
37
+ if (match) {
38
+ const parts = match[1].split(',').map(p => parseFloat(p));
39
+ if (parts.length >= 3 && parts.slice(0, 3).every(n => Number.isFinite(n))) {
40
+ return {
41
+ r: parts[0],
42
+ g: parts[1],
43
+ b: parts[2]
44
+ };
45
+ }
46
+ }
47
+ return null;
48
+ }
49
+
50
+ /** Pick a legible foreground (near-black or white) for a given background. */
51
+ function readableTextColor(background) {
52
+ const rgb = parseColor(background);
53
+ if (!rgb) return '#ffffff';
54
+ // Perceived luminance (ITU-R BT.601).
55
+ const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
56
+ return luminance > 0.6 ? '#0f0d0a' : '#ffffff';
57
+ }
58
+
59
+ /**
60
+ * `ClusterBubble` is the atomic circle that composes a `BubbleChart`. It renders
61
+ * a single token-colored disc with a bold `value` and a secondary `label`. The
62
+ * text can sit inside the circle or anchor just outside its edge on any side
63
+ * (`labelDirection`) at a precise `labelGap` distance — so consumers (or the
64
+ * chart) can steer labels toward free space. The inside text color adapts to
65
+ * the fill for legibility. It is fully usable standalone.
66
+ *
67
+ * @component
68
+ */
69
+ function ClusterBubble({
70
+ value,
71
+ label,
72
+ size = 120,
73
+ appearance = 'Primary',
74
+ color,
75
+ labelPlacement = 'auto',
76
+ labelDirection = 'bottom',
77
+ labelGap = 8,
78
+ autoInsideMinSize = 88,
79
+ insideTextColor,
80
+ onPress,
81
+ valueStyle,
82
+ labelStyle,
83
+ circleStyle,
84
+ style,
85
+ modes: propModes = EMPTY_MODES,
86
+ accessibilityLabel
87
+ }) {
88
+ const {
89
+ modes: globalModes
90
+ } = useTokens();
91
+ const modes = useMemo(() => ({
92
+ ...globalModes,
93
+ ...propModes
94
+ }), [globalModes, propModes]);
95
+
96
+ // Emphasis is read from the `Emphasis / DataViz` mode (defaulting to the
97
+ // token's own default) rather than a dedicated prop.
98
+ const fill = useMemo(() => {
99
+ if (color) return color;
100
+ return getVariableByName('dataViz/bg', {
101
+ ...modes,
102
+ 'Appearance / DataViz': appearance
103
+ }) ?? DEFAULT_FILL;
104
+ }, [color, modes, appearance]);
105
+ const fontFamily = getVariableByName('text/fontFamily', modes) ?? 'JioType';
106
+ const outsideTextColor = getVariableByName('text/foreground', modes) ?? '#0f0d0a';
107
+ const placement = labelPlacement === 'auto' ? size >= autoInsideMinSize ? 'inside' : 'outside' : labelPlacement;
108
+
109
+ // Measure the outside label so it can be anchored precisely on any side
110
+ // without guessing its dimensions.
111
+ const [labelSize, setLabelSize] = useState(null);
112
+ const handleLabelLayout = e => {
113
+ const {
114
+ width,
115
+ height
116
+ } = e.nativeEvent.layout;
117
+ setLabelSize(prev => prev && Math.abs(prev.w - width) < 0.5 && Math.abs(prev.h - height) < 0.5 ? prev : {
118
+ w: width,
119
+ h: height
120
+ });
121
+ };
122
+
123
+ // Default typography scales with the bubble when inside (so it fits the
124
+ // disc); fixed comfortable sizes when anchored outside.
125
+ const valueFontSize = placement === 'inside' ? Math.round(Math.min(48, Math.max(13, size * 0.17))) : 24;
126
+ const labelFontSize = placement === 'inside' ? Math.round(Math.min(18, Math.max(10, size * 0.085))) : 14;
127
+ const textColor = placement === 'inside' ? insideTextColor ?? readableTextColor(fill) : outsideTextColor;
128
+ const renderText = (node, baseStyle, override) => {
129
+ if (node === undefined || node === null || node === false) return null;
130
+ if (typeof node === 'string' || typeof node === 'number') {
131
+ return /*#__PURE__*/_jsx(Text, {
132
+ style: [baseStyle, override],
133
+ numberOfLines: 2,
134
+ children: node
135
+ });
136
+ }
137
+ return node;
138
+ };
139
+ const valueNode = renderText(value, {
140
+ color: textColor,
141
+ fontFamily,
142
+ fontSize: valueFontSize,
143
+ lineHeight: Math.round(valueFontSize * 1.15),
144
+ fontWeight: '700',
145
+ textAlign: 'center',
146
+ letterSpacing: -0.5
147
+ }, valueStyle);
148
+ const labelNode = renderText(label, {
149
+ color: textColor,
150
+ fontFamily,
151
+ fontSize: labelFontSize,
152
+ lineHeight: Math.round(labelFontSize * 1.3),
153
+ fontWeight: '400',
154
+ textAlign: 'center',
155
+ letterSpacing: -0.2
156
+ }, labelStyle);
157
+ const hasText = !!valueNode || !!labelNode;
158
+ const textBlock = hasText ? /*#__PURE__*/_jsxs(View, {
159
+ style: styles.textBlock,
160
+ children: [valueNode, labelNode]
161
+ }) : null;
162
+ const derivedA11y = [value, label].filter(v => typeof v === 'string' || typeof v === 'number').join(', ');
163
+ const a11yLabel = accessibilityLabel ?? (derivedA11y || undefined);
164
+ const circle = /*#__PURE__*/_jsx(View, {
165
+ style: [styles.circle, {
166
+ width: size,
167
+ height: size,
168
+ borderRadius: size / 2,
169
+ backgroundColor: fill
170
+ }, circleStyle],
171
+ children: placement === 'inside' ? textBlock : null
172
+ });
173
+ let content;
174
+ if (placement === 'inside' || !textBlock) {
175
+ content = /*#__PURE__*/_jsx(View, {
176
+ style: [styles.inlineContainer, style],
177
+ children: circle
178
+ });
179
+ } else {
180
+ // Anchor the label exactly `labelGap` beyond the radius on the chosen
181
+ // side. Hidden until measured to avoid a positioning flash.
182
+ const offset = labelOffset(labelDirection, size, labelGap, labelSize);
183
+ content = /*#__PURE__*/_jsxs(View, {
184
+ style: [{
185
+ width: size,
186
+ height: size
187
+ }, style],
188
+ children: [circle, /*#__PURE__*/_jsx(View, {
189
+ onLayout: handleLabelLayout,
190
+ style: [styles.outsideLabel, {
191
+ left: offset.left,
192
+ top: offset.top,
193
+ opacity: labelSize ? 1 : 0
194
+ }],
195
+ pointerEvents: "none",
196
+ children: textBlock
197
+ })]
198
+ });
199
+ }
200
+ if (onPress) {
201
+ return /*#__PURE__*/_jsx(Pressable, {
202
+ onPress: onPress,
203
+ accessibilityRole: "button",
204
+ accessibilityLabel: a11yLabel,
205
+ style: ({
206
+ pressed
207
+ }) => pressed ? styles.pressed : undefined,
208
+ children: content
209
+ });
210
+ }
211
+ return /*#__PURE__*/_jsx(View, {
212
+ accessibilityRole: "image",
213
+ accessibilityLabel: a11yLabel,
214
+ children: content
215
+ });
216
+ }
217
+
218
+ /** Compute the absolute `left/top` of the outside label box for a direction. */
219
+ function labelOffset(direction, size, gap, labelSize) {
220
+ const center = size / 2;
221
+ const w = labelSize?.w ?? 0;
222
+ const h = labelSize?.h ?? 0;
223
+ switch (direction) {
224
+ case 'top':
225
+ return {
226
+ left: center - w / 2,
227
+ top: -(gap + h)
228
+ };
229
+ case 'bottom':
230
+ return {
231
+ left: center - w / 2,
232
+ top: size + gap
233
+ };
234
+ case 'left':
235
+ return {
236
+ left: -(gap + w),
237
+ top: center - h / 2
238
+ };
239
+ case 'right':
240
+ return {
241
+ left: size + gap,
242
+ top: center - h / 2
243
+ };
244
+ }
245
+ }
246
+ const styles = StyleSheet.create({
247
+ inlineContainer: {
248
+ alignItems: 'center'
249
+ },
250
+ circle: {
251
+ alignItems: 'center',
252
+ justifyContent: 'center',
253
+ overflow: 'hidden'
254
+ },
255
+ textBlock: {
256
+ alignItems: 'center',
257
+ justifyContent: 'center',
258
+ paddingHorizontal: 8
259
+ },
260
+ outsideLabel: {
261
+ position: 'absolute'
262
+ },
263
+ pressed: {
264
+ opacity: 0.85
265
+ }
266
+ });
267
+ export default ClusterBubble;
@@ -17,6 +17,7 @@ function MetricLegendItem({
17
17
  label = 'Current (4 months)',
18
18
  value,
19
19
  indicatorColor,
20
+ indicatorShape = 'dot',
20
21
  modes = EMPTY_MODES,
21
22
  style,
22
23
  indicatorStyle,
@@ -49,7 +50,12 @@ function MetricLegendItem({
49
50
  }, style],
50
51
  accessibilityRole: "text",
51
52
  children: [/*#__PURE__*/_jsx(View, {
52
- style: [{
53
+ style: [indicatorShape === 'line' ? {
54
+ width: indicatorSize * 2,
55
+ height: Math.max(2, Math.round(indicatorSize / 4)),
56
+ borderRadius: indicatorRadius,
57
+ backgroundColor: indicatorBg
58
+ } : {
53
59
  width: indicatorSize,
54
60
  height: indicatorSize,
55
61
  borderRadius: indicatorRadius,
@@ -102,6 +102,9 @@ export { default as RadioButton } from './RadioButton/RadioButton';
102
102
  export { default as RechargeCard } from './RechargeCard/RechargeCard';
103
103
  export { default as SavingsGoalSummary } from './SavingsGoalSummary/SavingsGoalSummary';
104
104
  export { default as DonutChart, DonutChartSegment } from './DonutChart/DonutChart';
105
+ export { default as AreaLineChart, useChart } from './AreaLineChart/AreaLineChart';
106
+ export { default as ClusterBubble } from './ClusterBubble/ClusterBubble';
107
+ export { default as BubbleChart } from './BubbleChart/BubbleChart';
105
108
  export { default as DonutChartSummary } from './DonutChartSummary/DonutChartSummary';
106
109
  export { default as RangeTrack } from './RangeTrack/RangeTrack';
107
110
  export { default as SegmentedTrack, SegmentedTrackSegment } from './SegmentedTrack/SegmentedTrack';