jfs-components 0.0.71 → 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.
- package/CHANGELOG.md +60 -0
- package/lib/commonjs/components/AccordionCheckbox/AccordionCheckbox.js +239 -0
- package/lib/commonjs/components/BrandChip/BrandChip.js +149 -0
- package/lib/commonjs/components/CardAdvisory/CardAdvisory.js +2 -2
- package/lib/commonjs/components/CardBankAccount/CardBankAccount.js +213 -0
- package/lib/commonjs/components/CardFinancialCondition/CardFinancialCondition.js +213 -0
- package/lib/commonjs/components/CardInsight/CardInsight.js +166 -0
- package/lib/commonjs/components/Carousel/Carousel.js +9 -7
- package/lib/commonjs/components/CheckboxGroup/CheckboxGroup.js +67 -0
- package/lib/commonjs/components/CheckboxItem/CheckboxItem.js +125 -0
- package/lib/commonjs/components/CircularProgressBar/CircularProgressBar.js +56 -9
- package/lib/commonjs/components/CoverageBarComparison/CoverageBarComparison.js +272 -0
- package/lib/commonjs/components/CoverageRing/CoverageRing.js +141 -0
- package/lib/commonjs/components/DonutChart/DonutChart.js +309 -0
- package/lib/commonjs/components/DonutChartSummary/DonutChartSummary.js +155 -0
- package/lib/commonjs/components/HoldingsCard/HoldingsCard.js +2 -2
- package/lib/commonjs/components/InstitutionBadge/InstitutionBadge.js +132 -0
- package/lib/commonjs/components/LinearMeter/LinearMeter.js +9 -28
- package/lib/commonjs/components/LinearProgress/LinearProgress.js +68 -0
- package/lib/commonjs/components/MetricLegendItem/MetricLegendItem.js +95 -0
- package/lib/commonjs/components/MonthlyStatusGrid/MonthlyStatusGrid.js +286 -0
- package/lib/commonjs/components/OTP/OTP.js +381 -37
- package/lib/commonjs/components/ProductOverview/ProductOverview.js +147 -0
- package/lib/commonjs/components/Radio/Radio.js +194 -0
- package/lib/commonjs/components/RadioButton/RadioButton.js +21 -188
- package/lib/commonjs/components/RangeTrack/RangeTrack.js +269 -0
- package/lib/commonjs/components/SavingsGoalSummary/SavingsGoalSummary.js +181 -0
- package/lib/commonjs/components/SegmentedTrack/SegmentedTrack.js +171 -0
- package/lib/commonjs/components/StatGroup/StatGroup.js +128 -0
- package/lib/commonjs/components/StatItem/StatItem.js +65 -35
- package/lib/commonjs/components/StrengthIndicator/StrengthIndicator.js +157 -0
- package/lib/commonjs/components/SummaryTile/SummaryTile.js +150 -0
- package/lib/commonjs/components/index.js +192 -1
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/number-utils.js +57 -0
- package/lib/module/components/AccordionCheckbox/AccordionCheckbox.js +233 -0
- package/lib/module/components/BrandChip/BrandChip.js +143 -0
- package/lib/module/components/CardAdvisory/CardAdvisory.js +2 -2
- package/lib/module/components/CardBankAccount/CardBankAccount.js +208 -0
- package/lib/module/components/CardFinancialCondition/CardFinancialCondition.js +207 -0
- package/lib/module/components/CardInsight/CardInsight.js +161 -0
- package/lib/module/components/Carousel/Carousel.js +9 -7
- package/lib/module/components/CheckboxGroup/CheckboxGroup.js +62 -0
- package/lib/module/components/CheckboxItem/CheckboxItem.js +119 -0
- package/lib/module/components/CircularProgressBar/CircularProgressBar.js +56 -9
- package/lib/module/components/CoverageBarComparison/CoverageBarComparison.js +266 -0
- package/lib/module/components/CoverageRing/CoverageRing.js +136 -0
- package/lib/module/components/DonutChart/DonutChart.js +303 -0
- package/lib/module/components/DonutChartSummary/DonutChartSummary.js +150 -0
- package/lib/module/components/HoldingsCard/HoldingsCard.js +2 -2
- package/lib/module/components/InstitutionBadge/InstitutionBadge.js +127 -0
- package/lib/module/components/LinearMeter/LinearMeter.js +9 -28
- package/lib/module/components/LinearProgress/LinearProgress.js +63 -0
- package/lib/module/components/MetricLegendItem/MetricLegendItem.js +90 -0
- package/lib/module/components/MonthlyStatusGrid/MonthlyStatusGrid.js +281 -0
- package/lib/module/components/OTP/OTP.js +381 -38
- package/lib/module/components/ProductOverview/ProductOverview.js +142 -0
- package/lib/module/components/Radio/Radio.js +188 -0
- package/lib/module/components/RadioButton/RadioButton.js +20 -185
- package/lib/module/components/RangeTrack/RangeTrack.js +263 -0
- package/lib/module/components/SavingsGoalSummary/SavingsGoalSummary.js +175 -0
- package/lib/module/components/SegmentedTrack/SegmentedTrack.js +166 -0
- package/lib/module/components/StatGroup/StatGroup.js +123 -0
- package/lib/module/components/StatItem/StatItem.js +66 -36
- package/lib/module/components/StrengthIndicator/StrengthIndicator.js +152 -0
- package/lib/module/components/SummaryTile/SummaryTile.js +145 -0
- package/lib/module/components/index.js +28 -1
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/module/icons/registry.js +1 -1
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/number-utils.js +53 -0
- package/lib/typescript/src/components/AccordionCheckbox/AccordionCheckbox.d.ts +71 -0
- package/lib/typescript/src/components/BrandChip/BrandChip.d.ts +43 -0
- package/lib/typescript/src/components/CardBankAccount/CardBankAccount.d.ts +79 -0
- package/lib/typescript/src/components/CardFinancialCondition/CardFinancialCondition.d.ts +50 -0
- package/lib/typescript/src/components/CardInsight/CardInsight.d.ts +48 -0
- package/lib/typescript/src/components/CheckboxGroup/CheckboxGroup.d.ts +41 -0
- package/lib/typescript/src/components/CheckboxItem/CheckboxItem.d.ts +56 -0
- package/lib/typescript/src/components/CircularProgressBar/CircularProgressBar.d.ts +11 -1
- package/lib/typescript/src/components/CoverageBarComparison/CoverageBarComparison.d.ts +105 -0
- package/lib/typescript/src/components/CoverageRing/CoverageRing.d.ts +90 -0
- package/lib/typescript/src/components/DonutChart/DonutChart.d.ts +117 -0
- package/lib/typescript/src/components/DonutChartSummary/DonutChartSummary.d.ts +103 -0
- package/lib/typescript/src/components/InstitutionBadge/InstitutionBadge.d.ts +30 -0
- package/lib/typescript/src/components/LinearProgress/LinearProgress.d.ts +17 -0
- package/lib/typescript/src/components/MetricLegendItem/MetricLegendItem.d.ts +37 -0
- package/lib/typescript/src/components/MonthlyStatusGrid/MonthlyStatusGrid.d.ts +119 -0
- package/lib/typescript/src/components/OTP/OTP.d.ts +88 -2
- package/lib/typescript/src/components/ProductOverview/ProductOverview.d.ts +39 -0
- package/lib/typescript/src/components/Radio/Radio.d.ts +30 -0
- package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +20 -28
- package/lib/typescript/src/components/RangeTrack/RangeTrack.d.ts +173 -0
- package/lib/typescript/src/components/SavingsGoalSummary/SavingsGoalSummary.d.ts +95 -0
- package/lib/typescript/src/components/SegmentedTrack/SegmentedTrack.d.ts +108 -0
- package/lib/typescript/src/components/StatGroup/StatGroup.d.ts +45 -0
- package/lib/typescript/src/components/StatItem/StatItem.d.ts +24 -7
- package/lib/typescript/src/components/StrengthIndicator/StrengthIndicator.d.ts +58 -0
- package/lib/typescript/src/components/SummaryTile/SummaryTile.d.ts +60 -0
- package/lib/typescript/src/components/index.d.ts +29 -2
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/number-utils.d.ts +29 -0
- package/package.json +1 -1
- package/src/components/AccordionCheckbox/AccordionCheckbox.tsx +323 -0
- package/src/components/BrandChip/BrandChip.tsx +235 -0
- package/src/components/CardAdvisory/CardAdvisory.tsx +2 -2
- package/src/components/CardBankAccount/CardBankAccount.tsx +295 -0
- package/src/components/CardFinancialCondition/CardFinancialCondition.tsx +366 -0
- package/src/components/CardInsight/CardInsight.tsx +239 -0
- package/src/components/Carousel/Carousel.tsx +14 -6
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +86 -0
- package/src/components/CheckboxItem/CheckboxItem.tsx +174 -0
- package/src/components/CircularProgressBar/CircularProgressBar.tsx +74 -9
- package/src/components/CoverageBarComparison/CoverageBarComparison.tsx +378 -0
- package/src/components/CoverageRing/CoverageRing.tsx +225 -0
- package/src/components/DonutChart/DonutChart.tsx +503 -0
- package/src/components/DonutChartSummary/DonutChartSummary.tsx +256 -0
- package/src/components/HoldingsCard/HoldingsCard.tsx +2 -2
- package/src/components/InstitutionBadge/InstitutionBadge.tsx +216 -0
- package/src/components/LinearMeter/LinearMeter.tsx +9 -39
- package/src/components/LinearProgress/LinearProgress.tsx +92 -0
- package/src/components/MetricLegendItem/MetricLegendItem.tsx +167 -0
- package/src/components/MonthlyStatusGrid/MonthlyStatusGrid.tsx +438 -0
- package/src/components/OTP/OTP.tsx +476 -29
- package/src/components/ProductOverview/ProductOverview.tsx +236 -0
- package/src/components/Radio/Radio.tsx +227 -0
- package/src/components/RadioButton/RadioButton.tsx +23 -225
- package/src/components/RangeTrack/RangeTrack.tsx +394 -0
- package/src/components/SavingsGoalSummary/SavingsGoalSummary.tsx +269 -0
- package/src/components/SegmentedTrack/SegmentedTrack.tsx +268 -0
- package/src/components/StatGroup/StatGroup.tsx +169 -0
- package/src/components/StatItem/StatItem.tsx +117 -40
- package/src/components/StrengthIndicator/StrengthIndicator.tsx +205 -0
- package/src/components/SummaryTile/SummaryTile.tsx +251 -0
- package/src/components/index.ts +39 -2
- package/src/design-tokens/Coin Variables-variables-full.json +1 -1
- package/src/icons/registry.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/number-utils.ts +60 -0
|
@@ -0,0 +1,141 @@
|
|
|
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 _Button = _interopRequireDefault(require("../Button/Button"));
|
|
13
|
+
var _CircularProgressBar = _interopRequireDefault(require("../CircularProgressBar/CircularProgressBar"));
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const toNumber = (value, fallback) => {
|
|
17
|
+
if (typeof value === 'number') {
|
|
18
|
+
return Number.isFinite(value) ? value : fallback;
|
|
19
|
+
}
|
|
20
|
+
if (typeof value === 'string') {
|
|
21
|
+
const parsed = Number(value);
|
|
22
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
23
|
+
}
|
|
24
|
+
return fallback;
|
|
25
|
+
};
|
|
26
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
27
|
+
|
|
28
|
+
// The Figma "Coverage Ring" pairs a `circularProgressBar Size: M` ring with a
|
|
29
|
+
// `Button / Size: S` Secondary button. Locking these in as component defaults
|
|
30
|
+
// keeps the visual identical to the Figma reference when the caller supplies
|
|
31
|
+
// only their own brand/theme modes — caller modes are still merged on top so
|
|
32
|
+
// any of these can be overridden per-instance.
|
|
33
|
+
const COMPONENT_DEFAULT_MODES = Object.freeze({
|
|
34
|
+
'circularProgressBar Size': 'M',
|
|
35
|
+
'Button / Size': 'S'
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Match the Figma source: regardless of the overall AppearanceBrand/Emphasis
|
|
39
|
+
// the caller picks (used to colour the ring), the Coverage Ring CTA renders
|
|
40
|
+
// with the Secondary brand at Medium emphasis — which resolves to the
|
|
41
|
+
// pale-lavender background (`#dbcfff`) + deep-purple foreground (`#5d00b5`)
|
|
42
|
+
// shown in Figma. Mirrors the pattern used by `CardFinancialCondition.tsx`.
|
|
43
|
+
const BUTTON_FORCED_BRAND = Object.freeze({
|
|
44
|
+
AppearanceBrand: 'Secondary',
|
|
45
|
+
Emphasis: 'Medium'
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* `CoverageRing` renders a single-purpose insight: how many items out of a
|
|
50
|
+
* total have been covered (e.g. "4 of 7 benefits availed"), paired with a
|
|
51
|
+
* call-to-action button below the ring.
|
|
52
|
+
*
|
|
53
|
+
* It composes the existing {@link CircularProgressBar} (in its `M` size so
|
|
54
|
+
* there is room for a caption + value inside the ring) and {@link Button}
|
|
55
|
+
* (in its `S`, Secondary brand variant) — both driven by the same design
|
|
56
|
+
* tokens used by the rest of the design system.
|
|
57
|
+
*
|
|
58
|
+
* The ring fill is derived from `value / total`, so the percentage, the
|
|
59
|
+
* displayed `"{value} of {total}"` label and the support caption stay in
|
|
60
|
+
* sync automatically. There is no separate `progress` prop.
|
|
61
|
+
*
|
|
62
|
+
* @component
|
|
63
|
+
*/
|
|
64
|
+
function CoverageRing({
|
|
65
|
+
value = 4,
|
|
66
|
+
total = 7,
|
|
67
|
+
supportText = 'Benefits availed',
|
|
68
|
+
valueLabel,
|
|
69
|
+
actionLabel = 'Learn more',
|
|
70
|
+
onActionPress,
|
|
71
|
+
actionProps,
|
|
72
|
+
action,
|
|
73
|
+
children,
|
|
74
|
+
modes: propModes = _reactUtils.EMPTY_MODES,
|
|
75
|
+
style,
|
|
76
|
+
supportTextStyle,
|
|
77
|
+
valueStyle,
|
|
78
|
+
accessibilityLabel,
|
|
79
|
+
...rest
|
|
80
|
+
}) {
|
|
81
|
+
const {
|
|
82
|
+
modes: globalModes
|
|
83
|
+
} = (0, _JFSThemeProvider.useTokens)();
|
|
84
|
+
|
|
85
|
+
// Merge order matches the rest of the design system (see `Gauge.tsx`):
|
|
86
|
+
// 1. Component-level defaults — the lowest-priority safety net.
|
|
87
|
+
// 2. Global modes from `JFSThemeProvider` — app-wide theme.
|
|
88
|
+
// 3. Caller-supplied `propModes` — highest priority, overrides everything.
|
|
89
|
+
const modes = _react.default.useMemo(() => ({
|
|
90
|
+
...COMPONENT_DEFAULT_MODES,
|
|
91
|
+
...globalModes,
|
|
92
|
+
...propModes
|
|
93
|
+
}), [propModes, globalModes]);
|
|
94
|
+
|
|
95
|
+
// Force the Secondary brand on the button only; the ring stays on whatever
|
|
96
|
+
// brand the caller selected. Done via a forcedModes layer so callers can't
|
|
97
|
+
// accidentally bring back a Primary-coloured CTA through their own modes.
|
|
98
|
+
const buttonModes = _react.default.useMemo(() => ({
|
|
99
|
+
...modes,
|
|
100
|
+
...BUTTON_FORCED_BRAND
|
|
101
|
+
}), [modes]);
|
|
102
|
+
const safeTotal = total > 0 ? total : 0;
|
|
103
|
+
const clampedValue = clamp(value, 0, safeTotal);
|
|
104
|
+
const progressPercent = safeTotal > 0 ? clampedValue / safeTotal * 100 : 0;
|
|
105
|
+
const computedValueLabel = valueLabel ?? `${clampedValue} of ${safeTotal}`;
|
|
106
|
+
const gap = toNumber((0, _figmaVariablesResolver.getVariableByName)('coverageRing/gap', modes), 16);
|
|
107
|
+
const containerStyle = {
|
|
108
|
+
alignItems: 'center',
|
|
109
|
+
gap
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// Custom action slot resolution order: explicit `action` prop wins over
|
|
113
|
+
// `children`. We pass `modes` down via cloneChildrenWithModes so any
|
|
114
|
+
// token-driven child (e.g. a custom `<Button>`) inherits the parent theme.
|
|
115
|
+
const customAction = action ?? children;
|
|
116
|
+
const hasCustomAction = customAction !== undefined && customAction !== null;
|
|
117
|
+
const defaultAccessibilityLabel = accessibilityLabel ?? `${supportText}, ${computedValueLabel}`;
|
|
118
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
119
|
+
accessibilityLabel: defaultAccessibilityLabel,
|
|
120
|
+
style: [containerStyle, style],
|
|
121
|
+
...rest,
|
|
122
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgressBar.default, {
|
|
123
|
+
state: "Active",
|
|
124
|
+
value: progressPercent,
|
|
125
|
+
valueLabel: computedValueLabel,
|
|
126
|
+
supportText: supportText,
|
|
127
|
+
supportTextStyle: supportTextStyle,
|
|
128
|
+
valueStyle: valueStyle,
|
|
129
|
+
modes: modes,
|
|
130
|
+
accessibilityLabel: `${supportText}, ${computedValueLabel}`
|
|
131
|
+
}), hasCustomAction ? (0, _reactUtils.cloneChildrenWithModes)(customAction, buttonModes) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
|
|
132
|
+
label: actionLabel,
|
|
133
|
+
modes: buttonModes,
|
|
134
|
+
...(onActionPress !== undefined ? {
|
|
135
|
+
onPress: onActionPress
|
|
136
|
+
} : {}),
|
|
137
|
+
...actionProps
|
|
138
|
+
})]
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
var _default = exports.default = CoverageRing;
|
|
@@ -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;
|
|
@@ -7,7 +7,7 @@ exports.default = HoldingsCard;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
|
|
10
|
-
var
|
|
10
|
+
var _Radio = _interopRequireDefault(require("../Radio/Radio"));
|
|
11
11
|
var _reactUtils = require("../../utils/react-utils");
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -128,7 +128,7 @@ function HoldingsCard({
|
|
|
128
128
|
}
|
|
129
129
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
130
130
|
pointerEvents: "none",
|
|
131
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
131
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Radio.default, {
|
|
132
132
|
selected: selected,
|
|
133
133
|
disabled: disabled,
|
|
134
134
|
modes: modes
|