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,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { 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, cloneChildrenWithModes } from '../../utils/react-utils';
|
|
8
|
+
import Button from '../Button/Button';
|
|
9
|
+
import CircularProgressBar from '../CircularProgressBar/CircularProgressBar';
|
|
10
|
+
import Divider from '../Divider/Divider';
|
|
11
|
+
import Nudge from '../Nudge/Nudge';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const toNumber = (value, fallback) => {
|
|
14
|
+
if (typeof value === 'number') {
|
|
15
|
+
return Number.isFinite(value) ? value : fallback;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === 'string') {
|
|
18
|
+
const parsed = Number(value);
|
|
19
|
+
return Number.isFinite(parsed) ? parsed : fallback;
|
|
20
|
+
}
|
|
21
|
+
return fallback;
|
|
22
|
+
};
|
|
23
|
+
const toFontWeight = (value, fallback) => {
|
|
24
|
+
if (typeof value === 'number') {
|
|
25
|
+
return String(value);
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === 'string') {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return fallback;
|
|
31
|
+
};
|
|
32
|
+
function resolveCardFinancialConditionTokens(modes) {
|
|
33
|
+
const background = getVariableByName('financialConditionCard/background', modes) || '#ffffff';
|
|
34
|
+
const radius = toNumber(getVariableByName('financialConditionCard/radius', modes), 16);
|
|
35
|
+
const paddingH = toNumber(getVariableByName('financialConditionCard/padding/horizontal', modes), 16);
|
|
36
|
+
const paddingV = toNumber(getVariableByName('financialConditionCard/padding/vertical', modes), 16);
|
|
37
|
+
const gap = toNumber(getVariableByName('financialConditionCard/gap', modes), 8);
|
|
38
|
+
const headerGap = toNumber(getVariableByName('financialConditionCard/header/gap', modes), 16);
|
|
39
|
+
const textContentGap = toNumber(getVariableByName('financialConditionCard/textContent/gap', modes), 8);
|
|
40
|
+
const titleColor = getVariableByName('financialConditionCard/title/color', modes) || '#0c0d10';
|
|
41
|
+
const titleFontSize = toNumber(getVariableByName('financialConditionCard/title/fontSize', modes), 16);
|
|
42
|
+
const titleFontFamily = getVariableByName('financialConditionCard/title/fontFamily', modes) || 'JioType Var';
|
|
43
|
+
const titleLineHeight = toNumber(getVariableByName('financialConditionCard/title/lineHeight', modes), 18);
|
|
44
|
+
const titleFontWeight = toFontWeight(getVariableByName('financialConditionCard/title/fontWeight', modes), '700');
|
|
45
|
+
const bodyColor = getVariableByName('financialConditionCard/body/color', modes) || '#0c0d10';
|
|
46
|
+
const bodyFontSize = toNumber(getVariableByName('financialConditionCard/body/fontSize', modes), 14);
|
|
47
|
+
const bodyFontFamily = getVariableByName('financialConditionCard/body/fontFamily', modes) || 'JioType Var';
|
|
48
|
+
const bodyLineHeight = toNumber(getVariableByName('financialConditionCard/body/lineHeight', modes), 17);
|
|
49
|
+
const bodyFontWeight = toFontWeight(getVariableByName('financialConditionCard/body/fontWeight', modes), '400');
|
|
50
|
+
const nudgeBodyColor = getVariableByName('nudge/body/color', modes) || '#1a1c1f';
|
|
51
|
+
const nudgeBodyFontSize = toNumber(getVariableByName('nudge/body/fontSize', modes), 12);
|
|
52
|
+
const nudgeBodyFontFamily = getVariableByName('nudge/body/fontFamily', modes) || 'JioType Var';
|
|
53
|
+
const nudgeBodyLineHeight = toNumber(getVariableByName('nudge/body/lineHeight', modes), 16);
|
|
54
|
+
const nudgeBodyFontWeight = toFontWeight(getVariableByName('nudge/body/fontWeight', modes), '500');
|
|
55
|
+
return {
|
|
56
|
+
containerStyle: {
|
|
57
|
+
alignItems: 'flex-start',
|
|
58
|
+
backgroundColor: background,
|
|
59
|
+
borderRadius: radius,
|
|
60
|
+
gap,
|
|
61
|
+
justifyContent: 'center',
|
|
62
|
+
overflow: 'hidden',
|
|
63
|
+
paddingHorizontal: paddingH,
|
|
64
|
+
paddingVertical: paddingV
|
|
65
|
+
},
|
|
66
|
+
headerStyle: {
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
gap: headerGap,
|
|
70
|
+
width: '100%'
|
|
71
|
+
},
|
|
72
|
+
textContentStyle: {
|
|
73
|
+
alignItems: 'flex-start',
|
|
74
|
+
flex: 1,
|
|
75
|
+
gap: textContentGap,
|
|
76
|
+
minWidth: 1
|
|
77
|
+
},
|
|
78
|
+
titleStyle: {
|
|
79
|
+
color: titleColor,
|
|
80
|
+
fontFamily: titleFontFamily,
|
|
81
|
+
fontSize: titleFontSize,
|
|
82
|
+
fontWeight: titleFontWeight,
|
|
83
|
+
lineHeight: titleLineHeight
|
|
84
|
+
},
|
|
85
|
+
bodyStyle: {
|
|
86
|
+
color: bodyColor,
|
|
87
|
+
fontFamily: bodyFontFamily,
|
|
88
|
+
fontSize: bodyFontSize,
|
|
89
|
+
fontWeight: bodyFontWeight,
|
|
90
|
+
lineHeight: bodyLineHeight
|
|
91
|
+
},
|
|
92
|
+
nudgeBodyStyle: {
|
|
93
|
+
color: nudgeBodyColor,
|
|
94
|
+
fontFamily: nudgeBodyFontFamily,
|
|
95
|
+
fontSize: nudgeBodyFontSize,
|
|
96
|
+
fontWeight: nudgeBodyFontWeight,
|
|
97
|
+
lineHeight: nudgeBodyLineHeight
|
|
98
|
+
},
|
|
99
|
+
buttonWrapStyle: {
|
|
100
|
+
alignSelf: 'stretch',
|
|
101
|
+
alignItems: 'flex-start'
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function CardFinancialCondition({
|
|
106
|
+
title = 'Protection',
|
|
107
|
+
body = 'Check your coverage and gaps',
|
|
108
|
+
value = 0,
|
|
109
|
+
progressState = 'Inactive',
|
|
110
|
+
valueLabel,
|
|
111
|
+
showNudge = true,
|
|
112
|
+
nudgeBody = 'There may be gaps in your health or life cover\nAdd coverage to stay financially secure',
|
|
113
|
+
showDivider = true,
|
|
114
|
+
showButton = true,
|
|
115
|
+
buttonLabel = 'View Details',
|
|
116
|
+
onPressButton,
|
|
117
|
+
progressSlot,
|
|
118
|
+
nudgeSlot,
|
|
119
|
+
buttonSlot,
|
|
120
|
+
modes: propModes = EMPTY_MODES,
|
|
121
|
+
style,
|
|
122
|
+
headerStyle,
|
|
123
|
+
titleStyle,
|
|
124
|
+
bodyStyle,
|
|
125
|
+
accessibilityLabel,
|
|
126
|
+
...rest
|
|
127
|
+
}) {
|
|
128
|
+
const {
|
|
129
|
+
modes: globalModes
|
|
130
|
+
} = useTokens();
|
|
131
|
+
const modes = useMemo(() => globalModes === EMPTY_MODES && propModes === EMPTY_MODES ? EMPTY_MODES : {
|
|
132
|
+
...globalModes,
|
|
133
|
+
...propModes
|
|
134
|
+
}, [globalModes, propModes]);
|
|
135
|
+
const tokens = useMemo(() => resolveCardFinancialConditionTokens(modes), [modes]);
|
|
136
|
+
|
|
137
|
+
// Match Figma: the action button is the primary call-to-action and uses the
|
|
138
|
+
// Secondary brand (purple) regardless of the card's overall AppearanceBrand,
|
|
139
|
+
// while Nudge / CircularProgressBar still follow the user-supplied modes.
|
|
140
|
+
const buttonModes = useMemo(() => ({
|
|
141
|
+
...modes,
|
|
142
|
+
AppearanceBrand: 'Secondary'
|
|
143
|
+
}), [modes]);
|
|
144
|
+
const processedProgressSlot = useMemo(() => {
|
|
145
|
+
if (!progressSlot) return null;
|
|
146
|
+
const processed = cloneChildrenWithModes(React.Children.toArray(progressSlot), modes);
|
|
147
|
+
return processed.length === 1 ? processed[0] : processed;
|
|
148
|
+
}, [progressSlot, modes]);
|
|
149
|
+
const processedNudgeSlot = useMemo(() => {
|
|
150
|
+
if (!nudgeSlot) return null;
|
|
151
|
+
const processed = cloneChildrenWithModes(React.Children.toArray(nudgeSlot), modes);
|
|
152
|
+
return processed.length === 1 ? processed[0] : processed;
|
|
153
|
+
}, [nudgeSlot, modes]);
|
|
154
|
+
const processedButtonSlot = useMemo(() => {
|
|
155
|
+
if (!buttonSlot) return null;
|
|
156
|
+
const processed = cloneChildrenWithModes(React.Children.toArray(buttonSlot), buttonModes);
|
|
157
|
+
return processed.length === 1 ? processed[0] : processed;
|
|
158
|
+
}, [buttonSlot, buttonModes]);
|
|
159
|
+
const defaultAccessibilityLabel = accessibilityLabel ?? `${title}. ${body}.`;
|
|
160
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
161
|
+
accessibilityLabel: defaultAccessibilityLabel,
|
|
162
|
+
style: [tokens.containerStyle, style],
|
|
163
|
+
...rest,
|
|
164
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
165
|
+
style: [tokens.headerStyle, headerStyle],
|
|
166
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
167
|
+
style: tokens.textContentStyle,
|
|
168
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
169
|
+
style: [tokens.titleStyle, titleStyle],
|
|
170
|
+
children: title
|
|
171
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
172
|
+
style: [tokens.bodyStyle, bodyStyle],
|
|
173
|
+
children: body
|
|
174
|
+
})]
|
|
175
|
+
}), processedProgressSlot || /*#__PURE__*/_jsx(CircularProgressBar, {
|
|
176
|
+
state: progressState,
|
|
177
|
+
value: value,
|
|
178
|
+
modes: modes,
|
|
179
|
+
...(valueLabel ? {
|
|
180
|
+
valueLabel
|
|
181
|
+
} : {})
|
|
182
|
+
})]
|
|
183
|
+
}), showNudge ? processedNudgeSlot || /*#__PURE__*/_jsx(Nudge, {
|
|
184
|
+
type: "inline-compact",
|
|
185
|
+
modes: modes,
|
|
186
|
+
style: {
|
|
187
|
+
width: '100%'
|
|
188
|
+
},
|
|
189
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
190
|
+
style: tokens.nudgeBodyStyle,
|
|
191
|
+
children: nudgeBody
|
|
192
|
+
})
|
|
193
|
+
}) : null, showDivider ? /*#__PURE__*/_jsx(Divider, {
|
|
194
|
+
modes: modes
|
|
195
|
+
}) : null, showButton ? /*#__PURE__*/_jsx(View, {
|
|
196
|
+
style: tokens.buttonWrapStyle,
|
|
197
|
+
children: processedButtonSlot || /*#__PURE__*/_jsx(Button, {
|
|
198
|
+
label: buttonLabel,
|
|
199
|
+
modes: buttonModes,
|
|
200
|
+
...(onPressButton ? {
|
|
201
|
+
onPress: onPressButton
|
|
202
|
+
} : {})
|
|
203
|
+
})
|
|
204
|
+
}) : null]
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
export default /*#__PURE__*/React.memo(CardFinancialCondition);
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { View, Text } from 'react-native';
|
|
5
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
|
+
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils';
|
|
7
|
+
import Badge from '../Badge/Badge';
|
|
8
|
+
import Divider from '../Divider/Divider';
|
|
9
|
+
import Nudge from '../Nudge/Nudge';
|
|
10
|
+
import SavingsGoalSummary from '../SavingsGoalSummary/SavingsGoalSummary';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
/**
|
|
13
|
+
* `CardInsight` renders a single insight card composed of:
|
|
14
|
+
*
|
|
15
|
+
* 1. A header with a title, subtitle and a trailing `Badge`.
|
|
16
|
+
* 2. A flexible content slot — defaults to `SavingsGoalSummary`.
|
|
17
|
+
* 3. A `Divider` separating the slot from the footer.
|
|
18
|
+
* 4. A footer slot — defaults to an inline-compact `Nudge`.
|
|
19
|
+
*
|
|
20
|
+
* @component
|
|
21
|
+
* @param {CardInsightProps} props
|
|
22
|
+
*/
|
|
23
|
+
function CardInsight({
|
|
24
|
+
title = 'Emergency savings',
|
|
25
|
+
subtitle = 'One line explanation here.',
|
|
26
|
+
badge = 'Label',
|
|
27
|
+
children,
|
|
28
|
+
footer,
|
|
29
|
+
divider,
|
|
30
|
+
modes = EMPTY_MODES,
|
|
31
|
+
style
|
|
32
|
+
}) {
|
|
33
|
+
const background = getVariableByName('cardInsight/background', modes) ?? '#ffffff';
|
|
34
|
+
const radius = getVariableByName('cardInsight/radius', modes) ?? 16;
|
|
35
|
+
const paddingHorizontal = getVariableByName('cardInsight/padding/horizontal', modes) ?? 12;
|
|
36
|
+
const paddingVertical = getVariableByName('cardInsight/padding/vertical', modes) ?? 16;
|
|
37
|
+
const gap = getVariableByName('cardInsight/gap', modes) ?? 12;
|
|
38
|
+
const contentGap = getVariableByName('cardInsight/contentGap', modes) ?? 8;
|
|
39
|
+
const width = getVariableByName('cardInsight/width', modes) ?? 356;
|
|
40
|
+
const slotBackground = getVariableByName('cardInsight/slot/background', modes) ?? '#ffffff';
|
|
41
|
+
const headerGap = getVariableByName('cardInsight/header/gap', modes) ?? 8;
|
|
42
|
+
const textGap = getVariableByName('cardInsight/text/gap', modes) ?? 4;
|
|
43
|
+
const titleColor = getVariableByName('cardInsight/title/color', modes) ?? '#0d0d0f';
|
|
44
|
+
const titleFontFamily = getVariableByName('cardInsight/title/fontFamily', modes) ?? 'JioType Var';
|
|
45
|
+
const titleFontSize = getVariableByName('cardInsight/title/fontSize', modes) ?? 16;
|
|
46
|
+
const titleLineHeight = getVariableByName('cardInsight/title/lineHeight', modes) ?? 17.6;
|
|
47
|
+
const titleFontWeightRaw = getVariableByName('cardInsight/title/fontWeight', modes) ?? 700;
|
|
48
|
+
const titleFontWeight = String(titleFontWeightRaw);
|
|
49
|
+
const bodyColor = getVariableByName('cardInsight/body/color', modes) ?? '#0d0d0f';
|
|
50
|
+
const bodyFontFamily = getVariableByName('cardInsight/body/fontFamily', modes) ?? 'JioType Var';
|
|
51
|
+
const bodyFontSize = getVariableByName('cardInsight/body/fontSize', modes) ?? 12;
|
|
52
|
+
const bodyLineHeight = getVariableByName('cardInsight/body/lineHeight', modes) ?? 15.6;
|
|
53
|
+
const bodyFontWeightRaw = getVariableByName('cardInsight/body/fontWeight', modes) ?? 400;
|
|
54
|
+
const bodyFontWeight = String(bodyFontWeightRaw);
|
|
55
|
+
const renderBadge = () => {
|
|
56
|
+
if (badge === false || badge === null || badge === undefined) return null;
|
|
57
|
+
if (typeof badge === 'string') {
|
|
58
|
+
return /*#__PURE__*/_jsx(Badge, {
|
|
59
|
+
label: badge,
|
|
60
|
+
modes: modes
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const processed = cloneChildrenWithModes(badge, modes);
|
|
64
|
+
return processed.length === 1 ? processed[0] : processed;
|
|
65
|
+
};
|
|
66
|
+
const renderSlot = () => {
|
|
67
|
+
if (!children) {
|
|
68
|
+
return /*#__PURE__*/_jsx(SavingsGoalSummary, {
|
|
69
|
+
modes: modes
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const processed = cloneChildrenWithModes(children, modes);
|
|
73
|
+
return processed.length === 1 ? processed[0] : processed;
|
|
74
|
+
};
|
|
75
|
+
const renderFooter = () => {
|
|
76
|
+
if (footer === false || footer === null) return null;
|
|
77
|
+
if (footer === undefined) {
|
|
78
|
+
return /*#__PURE__*/_jsx(Nudge, {
|
|
79
|
+
type: "inline-compact",
|
|
80
|
+
modes: {
|
|
81
|
+
AppearanceBrand: 'Neutral',
|
|
82
|
+
Context: 'Nudge&Alert',
|
|
83
|
+
...modes
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const processed = cloneChildrenWithModes(footer, modes);
|
|
88
|
+
return processed.length === 1 ? processed[0] : processed;
|
|
89
|
+
};
|
|
90
|
+
const renderDivider = () => {
|
|
91
|
+
if (divider === false || divider === null) return null;
|
|
92
|
+
if (divider === undefined || divider === true) {
|
|
93
|
+
return /*#__PURE__*/_jsx(Divider, {
|
|
94
|
+
modes: modes
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const processed = cloneChildrenWithModes(divider, modes);
|
|
98
|
+
return processed.length === 1 ? processed[0] : processed;
|
|
99
|
+
};
|
|
100
|
+
const footerNode = renderFooter();
|
|
101
|
+
const showDivider = footerNode !== null && divider !== false && divider !== null;
|
|
102
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
103
|
+
style: [{
|
|
104
|
+
width,
|
|
105
|
+
backgroundColor: background,
|
|
106
|
+
borderRadius: radius,
|
|
107
|
+
paddingHorizontal,
|
|
108
|
+
paddingVertical,
|
|
109
|
+
gap,
|
|
110
|
+
overflow: 'hidden',
|
|
111
|
+
alignItems: 'stretch'
|
|
112
|
+
}, style],
|
|
113
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
114
|
+
style: {
|
|
115
|
+
flexDirection: 'row',
|
|
116
|
+
alignItems: 'flex-start',
|
|
117
|
+
gap: headerGap,
|
|
118
|
+
width: '100%'
|
|
119
|
+
},
|
|
120
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
121
|
+
style: {
|
|
122
|
+
flex: 1,
|
|
123
|
+
minWidth: 0,
|
|
124
|
+
gap: textGap,
|
|
125
|
+
alignItems: 'flex-start'
|
|
126
|
+
},
|
|
127
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
128
|
+
style: {
|
|
129
|
+
color: titleColor,
|
|
130
|
+
fontFamily: titleFontFamily,
|
|
131
|
+
fontSize: titleFontSize,
|
|
132
|
+
lineHeight: titleLineHeight,
|
|
133
|
+
fontWeight: titleFontWeight,
|
|
134
|
+
width: '100%'
|
|
135
|
+
},
|
|
136
|
+
children: title
|
|
137
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
138
|
+
style: {
|
|
139
|
+
color: bodyColor,
|
|
140
|
+
fontFamily: bodyFontFamily,
|
|
141
|
+
fontSize: bodyFontSize,
|
|
142
|
+
lineHeight: bodyLineHeight,
|
|
143
|
+
fontWeight: bodyFontWeight,
|
|
144
|
+
width: '100%'
|
|
145
|
+
},
|
|
146
|
+
children: subtitle
|
|
147
|
+
})]
|
|
148
|
+
}), renderBadge()]
|
|
149
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
150
|
+
style: {
|
|
151
|
+
width: '100%',
|
|
152
|
+
backgroundColor: slotBackground,
|
|
153
|
+
gap: contentGap,
|
|
154
|
+
overflow: 'hidden',
|
|
155
|
+
alignItems: 'stretch'
|
|
156
|
+
},
|
|
157
|
+
children: renderSlot()
|
|
158
|
+
}), showDivider ? renderDivider() : null, footerNode]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
export default CardInsight;
|
|
@@ -43,6 +43,8 @@ export function Carousel({
|
|
|
43
43
|
const gap = gapProp ?? tokenGap;
|
|
44
44
|
const containerPaddingH = parseFloat(getVariableByName('carousel/padding/horizontal', modes) || '0');
|
|
45
45
|
const containerPaddingV = parseFloat(getVariableByName('carousel/padding/vertical', modes) || '0');
|
|
46
|
+
// Outer container max height per Figma (`carousel/maxHeight`).
|
|
47
|
+
const maxHeight = parseFloat(getVariableByName('carousel/maxHeight', modes) || '280');
|
|
46
48
|
// Spacing between the cards row and the pagination dots uses `carousel/gap`.
|
|
47
49
|
const paginationOffset = gap;
|
|
48
50
|
|
|
@@ -154,7 +156,8 @@ export function Carousel({
|
|
|
154
156
|
|
|
155
157
|
// ---- Render ----
|
|
156
158
|
const outerStyle = {
|
|
157
|
-
paddingVertical: containerPaddingV
|
|
159
|
+
paddingVertical: containerPaddingV,
|
|
160
|
+
maxHeight
|
|
158
161
|
};
|
|
159
162
|
const contentContainerStyle = {
|
|
160
163
|
paddingHorizontal: containerPaddingH * 2,
|
|
@@ -262,13 +265,12 @@ export function Pagination({
|
|
|
262
265
|
const modes = propModes || ctxModes || {};
|
|
263
266
|
|
|
264
267
|
// Token resolution for dots — matches Figma tokens
|
|
265
|
-
// (carousel/pagination/gap, carousel/pagination/indicator/{
|
|
266
|
-
|
|
267
|
-
const
|
|
268
|
-
const dotActiveWidth = 16;
|
|
268
|
+
// (carousel/pagination/gap, carousel/pagination/indicator/{activeColor,inactiveColor,radius,size,activeWidth}).
|
|
269
|
+
const dotSize = parseFloat(getVariableByName('carousel/pagination/indicator/size', modes) || '6');
|
|
270
|
+
const dotActiveWidth = parseFloat(getVariableByName('carousel/pagination/indicator/activeWidth', modes) || '16');
|
|
269
271
|
const dotGap = parseFloat(getVariableByName('carousel/pagination/gap', modes) || '4');
|
|
270
|
-
const dotColor = getVariableByName('carousel/pagination/indicator/
|
|
271
|
-
const dotActiveColor = getVariableByName('carousel/pagination/indicator/
|
|
272
|
+
const dotColor = getVariableByName('carousel/pagination/indicator/inactiveColor', modes) || 'rgba(0,0,0,0.3)';
|
|
273
|
+
const dotActiveColor = getVariableByName('carousel/pagination/indicator/activeColor', modes) || '#170d0a';
|
|
272
274
|
const dotRadius = parseFloat(getVariableByName('carousel/pagination/indicator/radius', modes) || '9999');
|
|
273
275
|
const containerStyle = {
|
|
274
276
|
flexDirection: 'row',
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
|
+
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils';
|
|
7
|
+
import CheckboxItem from '../CheckboxItem/CheckboxItem';
|
|
8
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
/**
|
|
10
|
+
* CheckboxGroup composes a vertical stack of `CheckboxItem`s. Spacing and
|
|
11
|
+
* padding are driven by the `checkboxGroup/*` design tokens so groups stay
|
|
12
|
+
* visually consistent across screens.
|
|
13
|
+
*
|
|
14
|
+
* The `modes` prop is forwarded recursively to all children — including
|
|
15
|
+
* `CheckboxItem`s and any element rendered inside their `endSlot`.
|
|
16
|
+
*
|
|
17
|
+
* @component
|
|
18
|
+
* @param {CheckboxGroupProps} props
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <CheckboxGroup modes={{ 'Color Mode': 'Light' }}>
|
|
23
|
+
* <CheckboxItem label="Fixed deposit • 0245" />
|
|
24
|
+
* <CheckboxItem label="Recurring deposit • 1182" />
|
|
25
|
+
* <CheckboxItem label="Mutual fund • Equity" />
|
|
26
|
+
* </CheckboxGroup>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function CheckboxGroup({
|
|
30
|
+
children,
|
|
31
|
+
modes = EMPTY_MODES,
|
|
32
|
+
style,
|
|
33
|
+
accessibilityLabel
|
|
34
|
+
}) {
|
|
35
|
+
const gap = getVariableByName('checkboxGroup/gap', modes) ?? 12;
|
|
36
|
+
const paddingHorizontal = getVariableByName('checkboxGroup/padding/horizontal', modes) ?? 0;
|
|
37
|
+
const paddingVertical = getVariableByName('checkboxGroup/padding/vertical', modes) ?? 0;
|
|
38
|
+
const containerStyle = {
|
|
39
|
+
width: '100%',
|
|
40
|
+
flexDirection: 'column',
|
|
41
|
+
alignItems: 'stretch',
|
|
42
|
+
gap,
|
|
43
|
+
paddingHorizontal,
|
|
44
|
+
paddingVertical
|
|
45
|
+
};
|
|
46
|
+
const items = children ? cloneChildrenWithModes(children, modes) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
47
|
+
children: [/*#__PURE__*/_jsx(CheckboxItem, {
|
|
48
|
+
modes: modes
|
|
49
|
+
}), /*#__PURE__*/_jsx(CheckboxItem, {
|
|
50
|
+
modes: modes
|
|
51
|
+
}), /*#__PURE__*/_jsx(CheckboxItem, {
|
|
52
|
+
modes: modes
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
return /*#__PURE__*/_jsx(View, {
|
|
56
|
+
style: [containerStyle, style],
|
|
57
|
+
accessibilityRole: "list",
|
|
58
|
+
accessibilityLabel: accessibilityLabel,
|
|
59
|
+
children: items
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export default CheckboxGroup;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useState } from 'react';
|
|
4
|
+
import { View, Text, Pressable } from 'react-native';
|
|
5
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
|
+
import { EMPTY_MODES, cloneChildrenWithModes } from '../../utils/react-utils';
|
|
7
|
+
import Checkbox from '../Checkbox/Checkbox';
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
/**
|
|
10
|
+
* CheckboxItem composes a `Checkbox`, a label and an optional `endSlot` into a
|
|
11
|
+
* single horizontal pressable row. Pressing anywhere on the row (outside of the
|
|
12
|
+
* `endSlot`) toggles the checkbox, mirroring the typical native form pattern.
|
|
13
|
+
*
|
|
14
|
+
* Mirrors the Figma "Checkbox Item" component and uses the `checkboxItem/*`
|
|
15
|
+
* design tokens for typography and spacing.
|
|
16
|
+
*
|
|
17
|
+
* @component
|
|
18
|
+
* @param {CheckboxItemProps} props
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* const [checked, setChecked] = useState(false)
|
|
23
|
+
*
|
|
24
|
+
* <CheckboxItem
|
|
25
|
+
* label="Fixed deposit • 0245"
|
|
26
|
+
* checked={checked}
|
|
27
|
+
* onValueChange={setChecked}
|
|
28
|
+
* modes={{ 'Color Mode': 'Light' }}
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function CheckboxItem({
|
|
33
|
+
checked: controlledChecked,
|
|
34
|
+
defaultChecked = false,
|
|
35
|
+
onValueChange,
|
|
36
|
+
disabled = false,
|
|
37
|
+
label = 'Fixed deposit • 0245',
|
|
38
|
+
endSlot,
|
|
39
|
+
endSlotWidth = 80,
|
|
40
|
+
modes = EMPTY_MODES,
|
|
41
|
+
style,
|
|
42
|
+
labelStyle,
|
|
43
|
+
accessibilityLabel
|
|
44
|
+
}) {
|
|
45
|
+
const isControlled = controlledChecked !== undefined;
|
|
46
|
+
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
47
|
+
const isChecked = isControlled ? controlledChecked : internalChecked;
|
|
48
|
+
const handleToggle = useCallback(() => {
|
|
49
|
+
if (disabled) return;
|
|
50
|
+
const next = !isChecked;
|
|
51
|
+
if (!isControlled) {
|
|
52
|
+
setInternalChecked(next);
|
|
53
|
+
}
|
|
54
|
+
onValueChange?.(next);
|
|
55
|
+
}, [disabled, isChecked, isControlled, onValueChange]);
|
|
56
|
+
const gap = getVariableByName('checkboxItem/gap', modes) ?? 8;
|
|
57
|
+
const paddingHorizontal = getVariableByName('checkboxItem/padding/horizontal', modes) ?? 0;
|
|
58
|
+
const paddingVertical = getVariableByName('checkboxItem/padding/vertical', modes) ?? 0;
|
|
59
|
+
const labelColor = getVariableByName('checkboxItem/foreground', modes) ?? '#1a1c1f';
|
|
60
|
+
const labelFontFamily = getVariableByName('checkboxItem/label/fontFamily', modes) ?? 'JioType Var';
|
|
61
|
+
const labelFontSize = getVariableByName('checkboxItem/label/fontSize', modes) ?? 14;
|
|
62
|
+
const labelLineHeight = getVariableByName('checkboxItem/label/lineHeight', modes) ?? 19;
|
|
63
|
+
const labelFontWeightRaw = getVariableByName('checkboxItem/label/fontWeight', modes) ?? 400;
|
|
64
|
+
const labelFontWeight = String(labelFontWeightRaw);
|
|
65
|
+
const containerStyle = {
|
|
66
|
+
flexDirection: 'row',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
gap,
|
|
69
|
+
paddingHorizontal,
|
|
70
|
+
paddingVertical,
|
|
71
|
+
width: '100%'
|
|
72
|
+
};
|
|
73
|
+
const resolvedLabelStyle = {
|
|
74
|
+
flex: 1,
|
|
75
|
+
minWidth: 0,
|
|
76
|
+
color: labelColor,
|
|
77
|
+
fontFamily: labelFontFamily,
|
|
78
|
+
fontSize: labelFontSize,
|
|
79
|
+
lineHeight: labelLineHeight,
|
|
80
|
+
fontWeight: labelFontWeight
|
|
81
|
+
};
|
|
82
|
+
const a11yLabel = accessibilityLabel ?? (typeof label === 'string' ? label : undefined);
|
|
83
|
+
return /*#__PURE__*/_jsxs(Pressable, {
|
|
84
|
+
style: [containerStyle, style],
|
|
85
|
+
onPress: handleToggle,
|
|
86
|
+
disabled: disabled,
|
|
87
|
+
accessibilityRole: "checkbox",
|
|
88
|
+
accessibilityState: {
|
|
89
|
+
checked: isChecked,
|
|
90
|
+
disabled
|
|
91
|
+
},
|
|
92
|
+
accessibilityLabel: a11yLabel,
|
|
93
|
+
children: [/*#__PURE__*/_jsx(Checkbox, {
|
|
94
|
+
checked: isChecked,
|
|
95
|
+
disabled: disabled,
|
|
96
|
+
onValueChange: handleToggle,
|
|
97
|
+
modes: modes,
|
|
98
|
+
accessibilityLabel: a11yLabel
|
|
99
|
+
}), label != null && label !== false ? typeof label === 'string' || typeof label === 'number' ? /*#__PURE__*/_jsx(Text, {
|
|
100
|
+
style: [resolvedLabelStyle, labelStyle],
|
|
101
|
+
selectable: false,
|
|
102
|
+
children: label
|
|
103
|
+
}) : /*#__PURE__*/_jsx(View, {
|
|
104
|
+
style: {
|
|
105
|
+
flex: 1,
|
|
106
|
+
minWidth: 0
|
|
107
|
+
},
|
|
108
|
+
children: label
|
|
109
|
+
}) : null, endSlot ? /*#__PURE__*/_jsx(View, {
|
|
110
|
+
style: {
|
|
111
|
+
width: endSlotWidth,
|
|
112
|
+
flexShrink: 0,
|
|
113
|
+
alignItems: 'stretch'
|
|
114
|
+
},
|
|
115
|
+
children: cloneChildrenWithModes(endSlot, modes)
|
|
116
|
+
}) : null]
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export default CheckboxItem;
|