jfs-components 0.0.72 → 0.0.73

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 (116) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/lib/commonjs/components/AccordionCheckbox/AccordionCheckbox.js +239 -0
  3. package/lib/commonjs/components/BrandChip/BrandChip.js +149 -0
  4. package/lib/commonjs/components/CardBankAccount/CardBankAccount.js +213 -0
  5. package/lib/commonjs/components/CardInsight/CardInsight.js +166 -0
  6. package/lib/commonjs/components/CheckboxGroup/CheckboxGroup.js +67 -0
  7. package/lib/commonjs/components/CheckboxItem/CheckboxItem.js +125 -0
  8. package/lib/commonjs/components/CircularProgressBar/CircularProgressBar.js +56 -9
  9. package/lib/commonjs/components/CoverageBarComparison/CoverageBarComparison.js +272 -0
  10. package/lib/commonjs/components/CoverageRing/CoverageRing.js +141 -0
  11. package/lib/commonjs/components/DonutChart/DonutChart.js +309 -0
  12. package/lib/commonjs/components/DonutChartSummary/DonutChartSummary.js +155 -0
  13. package/lib/commonjs/components/LinearMeter/LinearMeter.js +9 -28
  14. package/lib/commonjs/components/LinearProgress/LinearProgress.js +68 -0
  15. package/lib/commonjs/components/MetricLegendItem/MetricLegendItem.js +95 -0
  16. package/lib/commonjs/components/MonthlyStatusGrid/MonthlyStatusGrid.js +286 -0
  17. package/lib/commonjs/components/OTP/OTP.js +381 -37
  18. package/lib/commonjs/components/ProductOverview/ProductOverview.js +147 -0
  19. package/lib/commonjs/components/RangeTrack/RangeTrack.js +269 -0
  20. package/lib/commonjs/components/SavingsGoalSummary/SavingsGoalSummary.js +181 -0
  21. package/lib/commonjs/components/SegmentedTrack/SegmentedTrack.js +171 -0
  22. package/lib/commonjs/components/StatGroup/StatGroup.js +128 -0
  23. package/lib/commonjs/components/StatItem/StatItem.js +65 -35
  24. package/lib/commonjs/components/StrengthIndicator/StrengthIndicator.js +157 -0
  25. package/lib/commonjs/components/SummaryTile/SummaryTile.js +150 -0
  26. package/lib/commonjs/components/index.js +171 -1
  27. package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
  28. package/lib/commonjs/icons/registry.js +1 -1
  29. package/lib/commonjs/utils/index.js +7 -0
  30. package/lib/commonjs/utils/number-utils.js +57 -0
  31. package/lib/module/components/AccordionCheckbox/AccordionCheckbox.js +233 -0
  32. package/lib/module/components/BrandChip/BrandChip.js +143 -0
  33. package/lib/module/components/CardBankAccount/CardBankAccount.js +208 -0
  34. package/lib/module/components/CardInsight/CardInsight.js +161 -0
  35. package/lib/module/components/CheckboxGroup/CheckboxGroup.js +62 -0
  36. package/lib/module/components/CheckboxItem/CheckboxItem.js +119 -0
  37. package/lib/module/components/CircularProgressBar/CircularProgressBar.js +56 -9
  38. package/lib/module/components/CoverageBarComparison/CoverageBarComparison.js +266 -0
  39. package/lib/module/components/CoverageRing/CoverageRing.js +136 -0
  40. package/lib/module/components/DonutChart/DonutChart.js +303 -0
  41. package/lib/module/components/DonutChartSummary/DonutChartSummary.js +150 -0
  42. package/lib/module/components/LinearMeter/LinearMeter.js +9 -28
  43. package/lib/module/components/LinearProgress/LinearProgress.js +63 -0
  44. package/lib/module/components/MetricLegendItem/MetricLegendItem.js +90 -0
  45. package/lib/module/components/MonthlyStatusGrid/MonthlyStatusGrid.js +281 -0
  46. package/lib/module/components/OTP/OTP.js +381 -38
  47. package/lib/module/components/ProductOverview/ProductOverview.js +142 -0
  48. package/lib/module/components/RangeTrack/RangeTrack.js +263 -0
  49. package/lib/module/components/SavingsGoalSummary/SavingsGoalSummary.js +175 -0
  50. package/lib/module/components/SegmentedTrack/SegmentedTrack.js +166 -0
  51. package/lib/module/components/StatGroup/StatGroup.js +123 -0
  52. package/lib/module/components/StatItem/StatItem.js +66 -36
  53. package/lib/module/components/StrengthIndicator/StrengthIndicator.js +152 -0
  54. package/lib/module/components/SummaryTile/SummaryTile.js +145 -0
  55. package/lib/module/components/index.js +21 -1
  56. package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
  57. package/lib/module/icons/registry.js +1 -1
  58. package/lib/module/utils/index.js +2 -1
  59. package/lib/module/utils/number-utils.js +53 -0
  60. package/lib/typescript/src/components/AccordionCheckbox/AccordionCheckbox.d.ts +71 -0
  61. package/lib/typescript/src/components/BrandChip/BrandChip.d.ts +43 -0
  62. package/lib/typescript/src/components/CardBankAccount/CardBankAccount.d.ts +79 -0
  63. package/lib/typescript/src/components/CardInsight/CardInsight.d.ts +48 -0
  64. package/lib/typescript/src/components/CheckboxGroup/CheckboxGroup.d.ts +41 -0
  65. package/lib/typescript/src/components/CheckboxItem/CheckboxItem.d.ts +56 -0
  66. package/lib/typescript/src/components/CircularProgressBar/CircularProgressBar.d.ts +11 -1
  67. package/lib/typescript/src/components/CoverageBarComparison/CoverageBarComparison.d.ts +105 -0
  68. package/lib/typescript/src/components/CoverageRing/CoverageRing.d.ts +90 -0
  69. package/lib/typescript/src/components/DonutChart/DonutChart.d.ts +117 -0
  70. package/lib/typescript/src/components/DonutChartSummary/DonutChartSummary.d.ts +103 -0
  71. package/lib/typescript/src/components/LinearProgress/LinearProgress.d.ts +17 -0
  72. package/lib/typescript/src/components/MetricLegendItem/MetricLegendItem.d.ts +37 -0
  73. package/lib/typescript/src/components/MonthlyStatusGrid/MonthlyStatusGrid.d.ts +119 -0
  74. package/lib/typescript/src/components/OTP/OTP.d.ts +88 -2
  75. package/lib/typescript/src/components/ProductOverview/ProductOverview.d.ts +39 -0
  76. package/lib/typescript/src/components/RangeTrack/RangeTrack.d.ts +173 -0
  77. package/lib/typescript/src/components/SavingsGoalSummary/SavingsGoalSummary.d.ts +95 -0
  78. package/lib/typescript/src/components/SegmentedTrack/SegmentedTrack.d.ts +108 -0
  79. package/lib/typescript/src/components/StatGroup/StatGroup.d.ts +45 -0
  80. package/lib/typescript/src/components/StatItem/StatItem.d.ts +24 -7
  81. package/lib/typescript/src/components/StrengthIndicator/StrengthIndicator.d.ts +58 -0
  82. package/lib/typescript/src/components/SummaryTile/SummaryTile.d.ts +60 -0
  83. package/lib/typescript/src/components/index.d.ts +22 -2
  84. package/lib/typescript/src/icons/registry.d.ts +1 -1
  85. package/lib/typescript/src/utils/index.d.ts +1 -0
  86. package/lib/typescript/src/utils/number-utils.d.ts +29 -0
  87. package/package.json +1 -1
  88. package/src/components/AccordionCheckbox/AccordionCheckbox.tsx +323 -0
  89. package/src/components/BrandChip/BrandChip.tsx +235 -0
  90. package/src/components/CardBankAccount/CardBankAccount.tsx +295 -0
  91. package/src/components/CardInsight/CardInsight.tsx +239 -0
  92. package/src/components/CheckboxGroup/CheckboxGroup.tsx +86 -0
  93. package/src/components/CheckboxItem/CheckboxItem.tsx +174 -0
  94. package/src/components/CircularProgressBar/CircularProgressBar.tsx +74 -9
  95. package/src/components/CoverageBarComparison/CoverageBarComparison.tsx +378 -0
  96. package/src/components/CoverageRing/CoverageRing.tsx +225 -0
  97. package/src/components/DonutChart/DonutChart.tsx +503 -0
  98. package/src/components/DonutChartSummary/DonutChartSummary.tsx +256 -0
  99. package/src/components/LinearMeter/LinearMeter.tsx +9 -39
  100. package/src/components/LinearProgress/LinearProgress.tsx +92 -0
  101. package/src/components/MetricLegendItem/MetricLegendItem.tsx +167 -0
  102. package/src/components/MonthlyStatusGrid/MonthlyStatusGrid.tsx +438 -0
  103. package/src/components/OTP/OTP.tsx +476 -29
  104. package/src/components/ProductOverview/ProductOverview.tsx +236 -0
  105. package/src/components/RangeTrack/RangeTrack.tsx +394 -0
  106. package/src/components/SavingsGoalSummary/SavingsGoalSummary.tsx +269 -0
  107. package/src/components/SegmentedTrack/SegmentedTrack.tsx +268 -0
  108. package/src/components/StatGroup/StatGroup.tsx +169 -0
  109. package/src/components/StatItem/StatItem.tsx +117 -40
  110. package/src/components/StrengthIndicator/StrengthIndicator.tsx +205 -0
  111. package/src/components/SummaryTile/SummaryTile.tsx +251 -0
  112. package/src/components/index.ts +32 -2
  113. package/src/design-tokens/Coin Variables-variables-full.json +1 -1
  114. package/src/icons/registry.ts +1 -1
  115. package/src/utils/index.ts +1 -0
  116. package/src/utils/number-utils.ts +60 -0
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DonutChartSegment = DonutChartSegment;
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _reactNative = require("react-native");
10
+ var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
11
+ var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
12
+ var _JFSThemeProvider = require("../../design-tokens/JFSThemeProvider");
13
+ var _reactUtils = require("../../utils/react-utils");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ /**
18
+ * Per-segment data definition for the data-driven `segments` prop.
19
+ *
20
+ * Each segment renders one arc on the donut ring. `value` controls the
21
+ * arc's angular share (its weight relative to the sum of all values).
22
+ * Use `modes` per segment to override the default `Appearance / DataViz`
23
+ * mode (the parent injects per-index defaults of `Senary`, `Primary`,
24
+ * `Secondary`, `Tertiary`, `Quaternary`, `Quinary`, then cycles).
25
+ */
26
+
27
+ const DEFAULT_APPEARANCE_CYCLE = ['Senary', 'Primary', 'Secondary', 'Tertiary', 'Quaternary', 'Quinary'];
28
+ const DEFAULT_SEGMENTS = [{
29
+ value: 1
30
+ }, {
31
+ value: 1
32
+ }, {
33
+ value: 1
34
+ }, {
35
+ value: 1
36
+ }, {
37
+ value: 1
38
+ }, {
39
+ value: 1
40
+ }];
41
+ const STROKE_WIDTH_RATIO = 18 / 194;
42
+ const toNumber = (value, fallback) => {
43
+ if (typeof value === 'number') {
44
+ return Number.isFinite(value) ? value : fallback;
45
+ }
46
+ if (typeof value === 'string') {
47
+ const parsed = Number(value);
48
+ return Number.isFinite(parsed) ? parsed : fallback;
49
+ }
50
+ return fallback;
51
+ };
52
+ const toFontWeight = (value, fallback) => {
53
+ if (typeof value === 'number') {
54
+ return String(value);
55
+ }
56
+ if (typeof value === 'string') {
57
+ return value;
58
+ }
59
+ return fallback;
60
+ };
61
+
62
+ /**
63
+ * Compute the default `Appearance / DataViz` mode for a segment at `index`.
64
+ * Cycles through {@link DEFAULT_APPEARANCE_CYCLE} so any number of segments
65
+ * gets a sensible default (Senary, Primary, Secondary, Tertiary,
66
+ * Quaternary, Quinary, then repeats).
67
+ */
68
+ function defaultAppearanceFor(index) {
69
+ return DEFAULT_APPEARANCE_CYCLE[index % DEFAULT_APPEARANCE_CYCLE.length];
70
+ }
71
+
72
+ /**
73
+ * Resolve a single segment's stroke color through the design tokens. Honors
74
+ * any explicit `color` override, then falls back to `dataViz/bg` for the
75
+ * supplied `modes`, then to the Figma reference purple.
76
+ */
77
+ function resolveSegmentColor(color, modes) {
78
+ if (color) return color;
79
+ return (0, _figmaVariablesResolver.getVariableByName)('dataViz/bg', modes) ?? '#5d00b5';
80
+ }
81
+
82
+ /**
83
+ * Coerce a slot child into a `DonutChartSegmentData` so the rendering path
84
+ * is uniform. Reads `value`, `color`, `modes` and `accessibilityLabel`
85
+ * from the child's props and ignores anything else.
86
+ */
87
+ function segmentDataFromChild(child, fallbackKey) {
88
+ const props = child.props ?? {};
89
+ return {
90
+ key: child.key ?? fallbackKey,
91
+ value: toNumber(props.value, 1),
92
+ color: typeof props.color === 'string' ? props.color : undefined,
93
+ modes: props.modes,
94
+ accessibilityLabel: props.accessibilityLabel
95
+ };
96
+ }
97
+ /**
98
+ * Inert helper used purely to author donut segments declaratively as
99
+ * `DonutChart.Segment` slot children. The parent reads its props and
100
+ * renders the actual SVG arcs — this component never renders anything by
101
+ * itself.
102
+ */
103
+ function DonutChartSegment(_) {
104
+ return null;
105
+ }
106
+
107
+ /**
108
+ * `DonutChart` renders a circular ring split into categorical segments.
109
+ * It is the segmented counterpart of `CircularProgressBar`: there is **no
110
+ * track background** behind the segments — the colored ring *is* the
111
+ * data, and each slice is a sibling category rather than a directional or
112
+ * temporal value.
113
+ *
114
+ * The default 6-segment layout receives per-index `Appearance / DataViz`
115
+ * defaults (segment 1 → `Senary`, 2 → `Primary`, 3 → `Secondary`, 4 →
116
+ * `Tertiary`, 5 → `Quaternary`, 6 → `Quinary`) so the wheel reads as one
117
+ * concept split into six color-coded categories. Override `modes` per
118
+ * segment to remix appearances, or set `Emphasis / DataViz` on the
119
+ * parent `modes` to dim or brighten the whole wheel at once.
120
+ *
121
+ * @component
122
+ * @param {DonutChartProps} props
123
+ */
124
+ function DonutChart({
125
+ segments,
126
+ value,
127
+ label,
128
+ children,
129
+ size = 194,
130
+ strokeWidth: strokeWidthProp,
131
+ gap = 0,
132
+ modes: propModes = _reactUtils.EMPTY_MODES,
133
+ style,
134
+ valueStyle,
135
+ labelStyle,
136
+ accessibilityLabel
137
+ }) {
138
+ const {
139
+ modes: globalModes
140
+ } = (0, _JFSThemeProvider.useTokens)();
141
+ const modes = {
142
+ ...globalModes,
143
+ ...propModes
144
+ };
145
+ const strokeWidth = Math.max(1, toNumber(strokeWidthProp, Math.max(1, size * STROKE_WIDTH_RATIO)));
146
+ const radius = Math.max(0, (size - strokeWidth) / 2);
147
+ const center = size / 2;
148
+ const circumference = 2 * Math.PI * radius;
149
+ const gapLength = Math.max(0, gap) / 360 * circumference;
150
+ const slotChildren = (0, _reactUtils.flattenChildren)(children).filter(child => /*#__PURE__*/_react.default.isValidElement(child));
151
+ const slotSegmentChildren = slotChildren.filter(child => child.type === DonutChartSegment);
152
+ let resolvedSegments;
153
+ if (slotSegmentChildren.length > 0) {
154
+ resolvedSegments = slotSegmentChildren.map((child, index) => segmentDataFromChild(child, `segment-${index}`));
155
+ } else if (segments && segments.length > 0) {
156
+ resolvedSegments = segments;
157
+ } else {
158
+ resolvedSegments = DEFAULT_SEGMENTS;
159
+ }
160
+ const totalValue = resolvedSegments.reduce((sum, segment) => sum + Math.max(0, toNumber(segment.value, 0)), 0);
161
+ const hasData = totalValue > 0 && resolvedSegments.length > 0;
162
+ const arcs = hasData ? buildArcs({
163
+ segments: resolvedSegments,
164
+ totalValue,
165
+ circumference,
166
+ gapLength,
167
+ modes
168
+ }) : [];
169
+ const customCenterChildren = slotChildren.filter(child => child.type !== DonutChartSegment);
170
+ const hasChildrenSlot = customCenterChildren.length > 0;
171
+ const showValueLabel = !hasChildrenSlot && shouldRenderText(value);
172
+ const showLabel = !hasChildrenSlot && shouldRenderText(label);
173
+ const valueColor = (0, _figmaVariablesResolver.getVariableByName)('donutChart/value/color', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('value/fg', modes) ?? '#000000';
174
+ const valueFontFamily = (0, _figmaVariablesResolver.getVariableByName)('donutChart/value/fontFamily', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('value/fontFamily', modes) ?? 'JioType Var';
175
+ const valueFontSize = toNumber((0, _figmaVariablesResolver.getVariableByName)('donutChart/value/fontSize', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('value/fontSize', modes), 29);
176
+ const valueLineHeight = toNumber((0, _figmaVariablesResolver.getVariableByName)('donutChart/value/lineHeight', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('value/lineHeight', modes), 29);
177
+ const valueFontWeight = toFontWeight((0, _figmaVariablesResolver.getVariableByName)('donutChart/value/fontWeight', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('value/fontWeight', modes), '900');
178
+ const labelColor = (0, _figmaVariablesResolver.getVariableByName)('donutChart/label/color', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('label/fg', modes) ?? '#000000';
179
+ const labelFontFamily = (0, _figmaVariablesResolver.getVariableByName)('donutChart/label/fontFamily', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('label/fontFamily', modes) ?? 'JioType Var';
180
+ const labelFontSize = toNumber((0, _figmaVariablesResolver.getVariableByName)('donutChart/label/fontSize', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('label/fontSize', modes), 12);
181
+ const labelLineHeight = toNumber((0, _figmaVariablesResolver.getVariableByName)('donutChart/label/lineHeight', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('label/lineHeight', modes), 15.6);
182
+ const labelFontWeight = toFontWeight((0, _figmaVariablesResolver.getVariableByName)('donutChart/label/fontWeight', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('label/fontWeight', modes), '400');
183
+ const textWrapGap = toNumber((0, _figmaVariablesResolver.getVariableByName)('donutChart/textWrap/gap', modes) ?? (0, _figmaVariablesResolver.getVariableByName)('textWrap/gap', modes), 7);
184
+ const containerStyle = {
185
+ alignItems: 'center',
186
+ height: size,
187
+ justifyContent: 'center',
188
+ position: 'relative',
189
+ width: size
190
+ };
191
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
192
+ accessibilityRole: "image",
193
+ accessibilityLabel: accessibilityLabel,
194
+ style: [containerStyle, style],
195
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.default, {
196
+ width: size,
197
+ height: size,
198
+ viewBox: `0 0 ${size} ${size}`,
199
+ children: arcs.map(arc => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Circle, {
200
+ cx: center,
201
+ cy: center,
202
+ r: radius,
203
+ stroke: arc.color,
204
+ strokeWidth: strokeWidth,
205
+ fill: "none",
206
+ strokeDasharray: arc.dashArray,
207
+ strokeDashoffset: arc.dashOffset,
208
+ strokeLinecap: "butt",
209
+ rotation: "-90",
210
+ originX: center,
211
+ originY: center
212
+ }, arc.key))
213
+ }), hasChildrenSlot ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
214
+ pointerEvents: "box-none",
215
+ style: _reactNative.StyleSheet.absoluteFill,
216
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
217
+ style: styles.centerSlot,
218
+ children: customCenterChildren
219
+ })
220
+ }) : showValueLabel || showLabel ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
221
+ pointerEvents: "none",
222
+ style: [styles.centerSlot, {
223
+ gap: textWrapGap
224
+ }],
225
+ children: [showValueLabel ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
226
+ style: [{
227
+ color: valueColor,
228
+ fontFamily: valueFontFamily,
229
+ fontSize: valueFontSize,
230
+ lineHeight: valueLineHeight,
231
+ fontWeight: valueFontWeight,
232
+ textAlign: 'center'
233
+ }, valueStyle],
234
+ numberOfLines: 1,
235
+ children: value
236
+ }) : null, showLabel ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
237
+ style: [{
238
+ color: labelColor,
239
+ fontFamily: labelFontFamily,
240
+ fontSize: labelFontSize,
241
+ lineHeight: labelLineHeight,
242
+ fontWeight: labelFontWeight,
243
+ textAlign: 'center'
244
+ }, labelStyle],
245
+ numberOfLines: 1,
246
+ children: label
247
+ }) : null]
248
+ }) : null]
249
+ });
250
+ }
251
+ function shouldRenderText(node) {
252
+ return node !== undefined && node !== null && node !== false && node !== '';
253
+ }
254
+ /**
255
+ * Convert the resolved segment list into a list of stroke-dasharray /
256
+ * stroke-dashoffset descriptors that can be drawn as SVG `Circle`s. Each
257
+ * arc's length is its share of `circumference`, and its rotational offset
258
+ * is the cumulative offset of all preceding segments. Visual gaps are
259
+ * applied symmetrically — half a gap is shaved from each end of the arc
260
+ * so the visible separation between two segments equals one full `gap`.
261
+ */
262
+ function buildArcs({
263
+ segments,
264
+ totalValue,
265
+ circumference,
266
+ gapLength,
267
+ modes
268
+ }) {
269
+ const arcs = [];
270
+ const halfGap = gapLength / 2;
271
+ let cumulativeOffset = 0;
272
+ segments.forEach((segment, index) => {
273
+ const safeValue = Math.max(0, toNumber(segment.value, 0));
274
+ if (safeValue <= 0) {
275
+ return;
276
+ }
277
+ const arcLength = safeValue / totalValue * circumference;
278
+ const drawnLength = Math.max(0, arcLength - gapLength);
279
+ const segmentModes = {
280
+ ...modes,
281
+ 'Appearance / DataViz': defaultAppearanceFor(index),
282
+ ...(segment.modes || {})
283
+ };
284
+ const color = resolveSegmentColor(segment.color, segmentModes);
285
+ const dashArray = `${drawnLength} ${circumference - drawnLength}`;
286
+ const dashOffset = -cumulativeOffset - halfGap;
287
+ arcs.push({
288
+ key: segment.key ?? `segment-${index}`,
289
+ color,
290
+ dashArray,
291
+ dashOffset
292
+ });
293
+ cumulativeOffset += arcLength;
294
+ });
295
+ return arcs;
296
+ }
297
+ const styles = _reactNative.StyleSheet.create({
298
+ centerSlot: {
299
+ alignItems: 'center',
300
+ bottom: 0,
301
+ justifyContent: 'center',
302
+ left: 0,
303
+ position: 'absolute',
304
+ right: 0,
305
+ top: 0
306
+ }
307
+ });
308
+ DonutChart.Segment = DonutChartSegment;
309
+ var _default = exports.default = DonutChart;
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
10
+ var _JFSThemeProvider = require("../../design-tokens/JFSThemeProvider");
11
+ var _reactUtils = require("../../utils/react-utils");
12
+ var _DonutChart = _interopRequireDefault(require("../DonutChart/DonutChart"));
13
+ var _MetricLegendItem = _interopRequireDefault(require("../MetricLegendItem/MetricLegendItem"));
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ /**
17
+ * One row of the `DonutChartSummary`. Each item drives BOTH a donut
18
+ * segment and the matching legend row, so the segment and indicator
19
+ * always share the same color by construction.
20
+ */
21
+
22
+ const DEFAULT_APPEARANCE_CYCLE = ['Senary', 'Primary', 'Secondary', 'Tertiary', 'Quaternary', 'Quinary'];
23
+ const DEFAULT_ITEMS = [{
24
+ label: 'Equity',
25
+ value: 40,
26
+ displayValue: '40%'
27
+ }, {
28
+ label: 'Recommended coverage',
29
+ value: 25,
30
+ displayValue: '25%'
31
+ }, {
32
+ label: 'Additional benefits',
33
+ value: 20,
34
+ displayValue: '20%'
35
+ }, {
36
+ label: 'Cost analysis',
37
+ value: 15,
38
+ displayValue: '15%'
39
+ }];
40
+ const defaultAppearanceFor = index => DEFAULT_APPEARANCE_CYCLE[index % DEFAULT_APPEARANCE_CYCLE.length];
41
+
42
+ /**
43
+ * Resolve the shared color for an item. Honors any explicit `color`
44
+ * override, then falls back to `dataViz/bg` for the merged mode set,
45
+ * then to the Figma reference purple.
46
+ */
47
+ function resolveItemColor(parentModes, item, index) {
48
+ if (item.color) return item.color;
49
+ const itemModes = {
50
+ ...parentModes,
51
+ 'Appearance / DataViz': defaultAppearanceFor(index),
52
+ ...(item.modes || {})
53
+ };
54
+ return (0, _figmaVariablesResolver.getVariableByName)('dataViz/bg', itemModes) ?? '#5d00b5';
55
+ }
56
+
57
+ /**
58
+ * `DonutChartSummary` pairs a `DonutChart` with a vertical list of
59
+ * `MetricLegendItem` rows. The component takes a single `items` array,
60
+ * so the number of legend rows is locked in step with the number of
61
+ * donut segments by construction — every segment has exactly one
62
+ * legend row, and they share the same color through the same
63
+ * `Appearance / DataViz` cascade as the standalone `DonutChart`.
64
+ *
65
+ * The default 4-item layout receives per-index `Appearance / DataViz`
66
+ * defaults (item 1 → `Senary`, 2 → `Primary`, 3 → `Secondary`, 4 →
67
+ * `Tertiary`, then cycles). Override `modes` per item to remix, or set
68
+ * `Emphasis / DataViz` on the parent `modes` to dim or brighten the
69
+ * whole component at once.
70
+ *
71
+ * @component
72
+ * @param {DonutChartSummaryProps} props
73
+ */
74
+ function DonutChartSummary({
75
+ items,
76
+ formatValue,
77
+ centerValue = '₹51,230',
78
+ centerLabel = 'Total invested',
79
+ donutCenter,
80
+ donutSize = 194,
81
+ donutStrokeWidth,
82
+ donutGap = 0,
83
+ modes: propModes = _reactUtils.EMPTY_MODES,
84
+ style,
85
+ legendStyle,
86
+ accessibilityLabel
87
+ }) {
88
+ const {
89
+ modes: globalModes
90
+ } = (0, _JFSThemeProvider.useTokens)();
91
+ const modes = {
92
+ ...globalModes,
93
+ ...propModes
94
+ };
95
+ const gap = (0, _figmaVariablesResolver.getVariableByName)('donutChartSummary/gap', modes) ?? 16;
96
+ const legendGap = (0, _figmaVariablesResolver.getVariableByName)('donutChartSummary/legend/gap', modes) ?? 8;
97
+ const resolvedItems = items && items.length > 0 ? items : DEFAULT_ITEMS;
98
+ const segments = resolvedItems.map((item, index) => ({
99
+ key: item.key ?? `segment-${index}`,
100
+ value: item.value,
101
+ color: resolveItemColor(modes, item, index),
102
+ accessibilityLabel: item.accessibilityLabel
103
+ }));
104
+ const showCustomCenter = donutCenter !== undefined && donutCenter !== null;
105
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
106
+ accessibilityRole: "summary",
107
+ accessibilityLabel: accessibilityLabel,
108
+ style: [{
109
+ width: '100%',
110
+ alignItems: 'center',
111
+ gap
112
+ }, style],
113
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_DonutChart.default, {
114
+ size: donutSize,
115
+ ...(donutStrokeWidth !== undefined && {
116
+ strokeWidth: donutStrokeWidth
117
+ }),
118
+ gap: donutGap,
119
+ segments: segments,
120
+ modes: modes,
121
+ ...(!showCustomCenter && {
122
+ value: centerValue,
123
+ label: centerLabel
124
+ }),
125
+ children: showCustomCenter ? donutCenter : null
126
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
127
+ style: [{
128
+ width: '100%',
129
+ gap: legendGap
130
+ }, legendStyle],
131
+ children: resolvedItems.map((item, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_MetricLegendItem.default, {
132
+ label: item.label,
133
+ value: resolveLegendValue(item, formatValue),
134
+ indicatorColor: resolveItemColor(modes, item, index),
135
+ modes: modes
136
+ }, item.key ?? `legend-${index}`))
137
+ })]
138
+ });
139
+ }
140
+
141
+ /**
142
+ * Resolve what to render in the legend row's right-side slot. The
143
+ * order of precedence is:
144
+ * 1. `item.displayValue` if explicitly provided (including `null` /
145
+ * `false`, which the underlying `MetricLegendItem` treats as
146
+ * "hide the value slot").
147
+ * 2. `formatValue(item.value)` when a parent-level formatter exists.
148
+ * 3. `undefined` — the value slot is hidden.
149
+ */
150
+ function resolveLegendValue(item, formatValue) {
151
+ if (item.displayValue !== undefined) return item.displayValue;
152
+ if (formatValue) return formatValue(item.value);
153
+ return undefined;
154
+ }
155
+ var _default = exports.default = DonutChartSummary;
@@ -9,6 +9,7 @@ var _reactNative = require("react-native");
9
9
  var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
10
10
  var _reactUtils = require("../../utils/react-utils");
11
11
  var _MoneyValue = _interopRequireDefault(require("../MoneyValue/MoneyValue"));
12
+ var _LinearProgress = _interopRequireDefault(require("../LinearProgress/LinearProgress"));
12
13
  var _jsxRuntime = require("react/jsx-runtime");
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  const LinearMeterLabel = ({
@@ -46,14 +47,6 @@ const LinearMeter = ({
46
47
  ...rest
47
48
  }) => {
48
49
  const gap = (0, _figmaVariablesResolver.getVariableByName)('linearMeter/gap', modes);
49
- // Track tokens
50
- const trackBg = (0, _figmaVariablesResolver.getVariableByName)('linearMeter/track/background', modes);
51
- const trackHeight = (0, _figmaVariablesResolver.getVariableByName)('linearMeter/track/height', modes);
52
- const trackRadius = (0, _figmaVariablesResolver.getVariableByName)('linearMeter/track/radius', modes);
53
-
54
- // Indicator tokens
55
- const indicatorBg = (0, _figmaVariablesResolver.getVariableByName)('linearMeter/indicator/background', modes);
56
- const indicatorRadius = (0, _figmaVariablesResolver.getVariableByName)('linearMeter/indicator/radius', modes);
57
50
 
58
51
  // Wrap tokens
59
52
  const wrapGap = (0, _figmaVariablesResolver.getVariableByName)('linearMeter/wrap/gap', modes);
@@ -91,10 +84,6 @@ const LinearMeter = ({
91
84
  })]
92
85
  });
93
86
  const content = children ? childrenWithModes : defaultContent;
94
-
95
- // Calculate width percentage
96
- const clampedValue = Math.min(Math.max(value, 0), 1);
97
- const widthPercent = `${clampedValue * 100}%`;
98
87
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
99
88
  style: [{
100
89
  flexDirection: 'row',
@@ -102,22 +91,14 @@ const LinearMeter = ({
102
91
  gap
103
92
  }, style],
104
93
  ...rest,
105
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
106
- style: [{
107
- flex: 1,
108
- height: trackHeight,
109
- backgroundColor: trackBg,
110
- borderRadius: trackRadius,
111
- overflow: 'hidden' // Ensure indicator stays inside
112
- }, trackStyle],
113
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
114
- style: [{
115
- width: widthPercent,
116
- height: '100%',
117
- backgroundColor: indicatorBg,
118
- borderRadius: indicatorRadius
119
- }, indicatorStyle]
120
- })
94
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_LinearProgress.default, {
95
+ value: value,
96
+ modes: modes,
97
+ style: {
98
+ flex: 1
99
+ },
100
+ trackStyle: trackStyle,
101
+ indicatorStyle: indicatorStyle
121
102
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
122
103
  style: {
123
104
  flexDirection: 'row',
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
10
+ var _reactUtils = require("../../utils/react-utils");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ const LinearProgress = ({
14
+ value = 0,
15
+ modes = _reactUtils.EMPTY_MODES,
16
+ style,
17
+ trackStyle,
18
+ indicatorStyle,
19
+ ...rest
20
+ }) => {
21
+ // The track and the progress indicator are intentionally rendered at
22
+ // different emphasis levels by default: the track sits in the
23
+ // background as a low-emphasis surface, while the progress indicator
24
+ // is the high-emphasis foreground. Defaults are placed *before* the
25
+ // user-provided modes spread, so callers can still override
26
+ // `Emphasis / DataViz` (or any other mode) via the `modes` prop.
27
+ const trackModes = {
28
+ 'Emphasis': 'Low',
29
+ ...modes
30
+ };
31
+ const progressModes = {
32
+ 'Emphasis': 'High',
33
+ ...modes
34
+ };
35
+ const trackHeight = (0, _figmaVariablesResolver.getVariableByName)('linearProgress/track/height', trackModes) ?? 8;
36
+ const trackRadius = (0, _figmaVariablesResolver.getVariableByName)('linearProgress/track/radius', trackModes) ?? 999;
37
+ const trackBg = (0, _figmaVariablesResolver.getVariableByName)('linearProgress/track/background', trackModes) ?? '#ede7ff';
38
+ const indicatorHeight = (0, _figmaVariablesResolver.getVariableByName)('linearProgress/indicator/height', progressModes) ?? 8;
39
+ const indicatorRadius = (0, _figmaVariablesResolver.getVariableByName)('linearProgress/indicator/radius', progressModes) ?? 999;
40
+ const indicatorBg = (0, _figmaVariablesResolver.getVariableByName)('linearProgress/indicator/background', progressModes) ?? '#5d00b5';
41
+ const clampedValue = Math.min(Math.max(value, 0), 1);
42
+ const widthPercent = `${clampedValue * 100}%`;
43
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
44
+ style: [{
45
+ height: trackHeight,
46
+ backgroundColor: trackBg,
47
+ borderRadius: trackRadius,
48
+ overflow: 'hidden',
49
+ width: '100%'
50
+ }, style, trackStyle],
51
+ accessibilityRole: "progressbar",
52
+ accessibilityValue: {
53
+ min: 0,
54
+ max: 1,
55
+ now: clampedValue
56
+ },
57
+ ...rest,
58
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
59
+ style: [{
60
+ width: widthPercent,
61
+ height: indicatorHeight,
62
+ backgroundColor: indicatorBg,
63
+ borderRadius: indicatorRadius
64
+ }, indicatorStyle]
65
+ })
66
+ });
67
+ };
68
+ var _default = exports.default = LinearProgress;