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.
- package/CHANGELOG.md +11 -0
- package/lib/commonjs/components/AccordionCheckbox/AccordionCheckbox.js +239 -0
- package/lib/commonjs/components/BrandChip/BrandChip.js +149 -0
- package/lib/commonjs/components/CardBankAccount/CardBankAccount.js +213 -0
- package/lib/commonjs/components/CardInsight/CardInsight.js +166 -0
- 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/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/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 +171 -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/CardBankAccount/CardBankAccount.js +208 -0
- package/lib/module/components/CardInsight/CardInsight.js +161 -0
- 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/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/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 +21 -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/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/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/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 +22 -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/CardBankAccount/CardBankAccount.tsx +295 -0
- package/src/components/CardInsight/CardInsight.tsx +239 -0
- 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/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/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 +32 -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,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;
|
|
@@ -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;
|
|
@@ -37,11 +37,13 @@ function CircularProgressBar({
|
|
|
37
37
|
value = 70,
|
|
38
38
|
state = 'Inactive',
|
|
39
39
|
valueLabel,
|
|
40
|
+
supportText,
|
|
40
41
|
modes: propModes = EMPTY_MODES,
|
|
41
42
|
style,
|
|
42
43
|
trackStyle,
|
|
43
44
|
progressStyle,
|
|
44
45
|
valueStyle,
|
|
46
|
+
supportTextStyle,
|
|
45
47
|
accessibilityLabel,
|
|
46
48
|
...rest
|
|
47
49
|
}) {
|
|
@@ -52,6 +54,17 @@ function CircularProgressBar({
|
|
|
52
54
|
...globalModes,
|
|
53
55
|
...propModes
|
|
54
56
|
};
|
|
57
|
+
// The Figma `circularProgressBar/track/color` variable aliases to the same
|
|
58
|
+
// chain as `progress/color`, so user-selected Brand modes collapse the
|
|
59
|
+
// track and progress to a single hue. The Figma source of truth always
|
|
60
|
+
// renders the track as a neutral gray, so we force Neutral/Medium when
|
|
61
|
+
// resolving the track color while keeping the user modes for everything
|
|
62
|
+
// else.
|
|
63
|
+
const trackModes = {
|
|
64
|
+
...modes,
|
|
65
|
+
'AppearanceBrand': 'Neutral',
|
|
66
|
+
'Emphasis': 'Medium'
|
|
67
|
+
};
|
|
55
68
|
const isActive = state === true || state === 'Active';
|
|
56
69
|
const normalizedValue = clamp(value, 0, 100);
|
|
57
70
|
const size = toNumber(getVariableByName('circularProgressBar/size', modes), 60);
|
|
@@ -59,15 +72,18 @@ function CircularProgressBar({
|
|
|
59
72
|
const radius = Math.max(0, (size - strokeWidth) / 2);
|
|
60
73
|
const center = size / 2;
|
|
61
74
|
const circumference = 2 * Math.PI * radius;
|
|
62
|
-
const trackColor = getStrokeColor(trackStyle, getVariableByName('circularProgressBar/track/color',
|
|
75
|
+
const trackColor = getStrokeColor(trackStyle, getVariableByName('circularProgressBar/track/color', trackModes) || '#ebebed');
|
|
63
76
|
const progressColor = getStrokeColor(progressStyle, getVariableByName('circularProgressBar/progress/color', modes) || '#25ab21');
|
|
64
77
|
const iconColor = getVariableByName('circularProgressBar/icon/color', modes) || '#666666';
|
|
65
78
|
const iconSize = toNumber(getVariableByName('circularProgressBar/icon/size', modes), 24);
|
|
66
79
|
const foreground = getVariableByName('circularProgressBar/foreground', modes) || '#0d0d0f';
|
|
67
|
-
const fontSize = toNumber(getVariableByName('circularProgressBar/fontSize', modes), 18);
|
|
80
|
+
const fontSize = toNumber(getVariableByName('circularProgressBar/value/fontSize', modes), 18);
|
|
68
81
|
const fontFamily = getVariableByName('circularProgressBar/fontFamily', modes) || 'JioType Var';
|
|
69
|
-
const lineHeight = toNumber(getVariableByName('circularProgressBar/lineHeight', modes), 21);
|
|
70
|
-
const fontWeight = toFontWeight(getVariableByName('circularProgressBar/fontWeight', modes), '700');
|
|
82
|
+
const lineHeight = toNumber(getVariableByName('circularProgressBar/value/lineHeight', modes), 21);
|
|
83
|
+
const fontWeight = toFontWeight(getVariableByName('circularProgressBar/value/fontWeight', modes), '700');
|
|
84
|
+
const supportFontSize = toNumber(getVariableByName('circularProgressBar/supportText/fontSize', modes), 11);
|
|
85
|
+
const supportLineHeight = toNumber(getVariableByName('circularProgressBar/supportText/lineHeight', modes), 13);
|
|
86
|
+
const supportFontWeight = toFontWeight(getVariableByName('circularProgressBar/supportText/fontWeight', modes), '500');
|
|
71
87
|
const computedContainerStyle = {
|
|
72
88
|
alignItems: 'center',
|
|
73
89
|
height: size,
|
|
@@ -75,13 +91,34 @@ function CircularProgressBar({
|
|
|
75
91
|
position: 'relative',
|
|
76
92
|
width: size
|
|
77
93
|
};
|
|
94
|
+
|
|
95
|
+
// The text stack (support text + value) is centered inside the ring using
|
|
96
|
+
// an absolutely-positioned column. Keeping the wrapper absolute (rather
|
|
97
|
+
// than the individual texts, as in earlier versions) lets multi-line stacks
|
|
98
|
+
// render correctly without sub-pixel misalignment.
|
|
99
|
+
const textStackStyle = {
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
justifyContent: 'center',
|
|
102
|
+
left: 0,
|
|
103
|
+
position: 'absolute',
|
|
104
|
+
right: 0,
|
|
105
|
+
top: 0,
|
|
106
|
+
bottom: 0
|
|
107
|
+
};
|
|
78
108
|
const computedValueStyle = {
|
|
79
109
|
color: foreground,
|
|
80
110
|
fontFamily,
|
|
81
111
|
fontSize,
|
|
82
112
|
fontWeight,
|
|
83
113
|
lineHeight,
|
|
84
|
-
|
|
114
|
+
textAlign: 'center'
|
|
115
|
+
};
|
|
116
|
+
const computedSupportTextStyle = {
|
|
117
|
+
color: foreground,
|
|
118
|
+
fontFamily,
|
|
119
|
+
fontSize: supportFontSize,
|
|
120
|
+
fontWeight: supportFontWeight,
|
|
121
|
+
lineHeight: supportLineHeight,
|
|
85
122
|
textAlign: 'center'
|
|
86
123
|
};
|
|
87
124
|
const iconStyle = {
|
|
@@ -90,7 +127,8 @@ function CircularProgressBar({
|
|
|
90
127
|
top: (size - iconSize) / 2
|
|
91
128
|
};
|
|
92
129
|
const displayValue = valueLabel ?? String(Math.round(normalizedValue));
|
|
93
|
-
const
|
|
130
|
+
const hasSupportText = typeof supportText === 'string' && supportText.length > 0;
|
|
131
|
+
const defaultAccessibilityLabel = accessibilityLabel ?? (isActive ? hasSupportText ? `${supportText}, ${displayValue} out of 100` : `${displayValue} out of 100` : 'Inactive progress');
|
|
94
132
|
return /*#__PURE__*/_jsxs(View, {
|
|
95
133
|
accessibilityRole: "progressbar",
|
|
96
134
|
accessibilityLabel: defaultAccessibilityLabel,
|
|
@@ -126,9 +164,18 @@ function CircularProgressBar({
|
|
|
126
164
|
originX: center,
|
|
127
165
|
originY: center
|
|
128
166
|
}) : null]
|
|
129
|
-
}), isActive ? /*#__PURE__*/
|
|
130
|
-
style:
|
|
131
|
-
|
|
167
|
+
}), isActive ? /*#__PURE__*/_jsxs(View, {
|
|
168
|
+
style: textStackStyle,
|
|
169
|
+
pointerEvents: "none",
|
|
170
|
+
children: [hasSupportText ? /*#__PURE__*/_jsx(Text, {
|
|
171
|
+
style: [computedSupportTextStyle, supportTextStyle],
|
|
172
|
+
numberOfLines: 1,
|
|
173
|
+
children: supportText
|
|
174
|
+
}) : null, /*#__PURE__*/_jsx(Text, {
|
|
175
|
+
style: [computedValueStyle, valueStyle],
|
|
176
|
+
numberOfLines: 1,
|
|
177
|
+
children: displayValue
|
|
178
|
+
})]
|
|
132
179
|
}) : /*#__PURE__*/_jsx(IconMinus, {
|
|
133
180
|
width: iconSize,
|
|
134
181
|
height: iconSize,
|