jfs-components 0.0.70 → 0.0.71
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/lib/commonjs/components/CardAdvisory/CardAdvisory.js +203 -0
- package/lib/commonjs/components/CardCTA/CardCTA.js +198 -16
- package/lib/commonjs/components/CircularProgressBar/CircularProgressBar.js +147 -0
- package/lib/commonjs/components/CircularProgressBarDoted/CircularProgressBarDoted.js +258 -0
- package/lib/commonjs/components/CircularRating/CircularRating.js +161 -0
- package/lib/commonjs/components/Gauge/Gauge.js +223 -0
- package/lib/commonjs/components/ListGroup/ListGroup.js +3 -1
- package/lib/commonjs/components/Nudge/Nudge.js +179 -87
- package/lib/commonjs/components/index.js +35 -0
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/CardAdvisory/CardAdvisory.js +197 -0
- package/lib/module/components/CardCTA/CardCTA.js +199 -17
- package/lib/module/components/CircularProgressBar/CircularProgressBar.js +141 -0
- package/lib/module/components/CircularProgressBarDoted/CircularProgressBarDoted.js +253 -0
- package/lib/module/components/CircularRating/CircularRating.js +155 -0
- package/lib/module/components/Gauge/Gauge.js +217 -0
- package/lib/module/components/ListGroup/ListGroup.js +3 -1
- package/lib/module/components/Nudge/Nudge.js +178 -87
- package/lib/module/components/index.js +5 -0
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/CardAdvisory/CardAdvisory.d.ts +49 -0
- package/lib/typescript/src/components/CardCTA/CardCTA.d.ts +16 -1
- package/lib/typescript/src/components/CircularProgressBar/CircularProgressBar.d.ts +27 -0
- package/lib/typescript/src/components/CircularProgressBarDoted/CircularProgressBarDoted.d.ts +48 -0
- package/lib/typescript/src/components/CircularRating/CircularRating.d.ts +49 -0
- package/lib/typescript/src/components/Gauge/Gauge.d.ts +53 -0
- package/lib/typescript/src/components/Nudge/Nudge.d.ts +14 -11
- package/lib/typescript/src/components/index.d.ts +6 -1
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/CardAdvisory/CardAdvisory.tsx +283 -0
- package/src/components/CardCTA/CardCTA.tsx +236 -13
- package/src/components/CircularProgressBar/CircularProgressBar.tsx +190 -0
- package/src/components/CircularProgressBarDoted/CircularProgressBarDoted.tsx +357 -0
- package/src/components/CircularRating/CircularRating.tsx +241 -0
- package/src/components/Gauge/Gauge.tsx +303 -0
- package/src/components/ListGroup/ListGroup.tsx +3 -1
- package/src/components/Nudge/Nudge.tsx +222 -82
- package/src/components/index.ts +6 -1
- package/src/design-tokens/Coin Variables-variables-full.json +1 -1
- package/src/icons/registry.ts +1 -1
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
4
|
import { View, Text } from 'react-native';
|
|
5
5
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
6
|
import { useTokens } from '../../design-tokens/JFSThemeProvider';
|
|
7
7
|
import { cloneChildrenWithModes, EMPTY_MODES } from '../../utils/react-utils';
|
|
8
8
|
import Button from '../Button/Button';
|
|
9
|
+
import Icon from '../../icons/Icon';
|
|
9
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
buttonSlot,
|
|
17
|
-
startSlot,
|
|
18
|
-
children,
|
|
19
|
-
modes: propModes = EMPTY_MODES,
|
|
20
|
-
style
|
|
21
|
-
}) {
|
|
22
|
-
const {
|
|
23
|
-
modes: globalModes
|
|
24
|
-
} = useTokens();
|
|
25
|
-
const modes = {
|
|
26
|
-
...globalModes,
|
|
27
|
-
...propModes
|
|
28
|
-
};
|
|
11
|
+
function toFontWeight(value, fallback) {
|
|
12
|
+
if (typeof value === 'number') return value.toString();
|
|
13
|
+
if (typeof value === 'string') return value;
|
|
14
|
+
return fallback;
|
|
15
|
+
}
|
|
16
|
+
function resolveNudgeTokens(modes) {
|
|
29
17
|
const background = getVariableByName('nudge/background', modes) || '#f5f5f5';
|
|
30
18
|
const radius = getVariableByName('nudge/radius', modes) || 12;
|
|
31
19
|
const paddingH = getVariableByName('nudge/padding/horizontal', modes) || 12;
|
|
@@ -33,106 +21,209 @@ function Nudge({
|
|
|
33
21
|
const gap = getVariableByName('nudge/gap', modes) || 6;
|
|
34
22
|
const titleColor = getVariableByName('nudge/title/color', modes) || '#0d0d0f';
|
|
35
23
|
const titleFontSize = getVariableByName('nudge/title/fontSize', modes) || 14;
|
|
36
|
-
const titleFontFamily = getVariableByName('nudge/title/fontFamily', modes) || '
|
|
24
|
+
const titleFontFamily = getVariableByName('nudge/title/fontFamily', modes) || 'System';
|
|
37
25
|
const titleLineHeight = getVariableByName('nudge/title/lineHeight', modes) || 15;
|
|
38
|
-
const
|
|
39
|
-
const titleFontWeight = typeof titleFontWeightRaw === 'number' ? titleFontWeightRaw.toString() : titleFontWeightRaw;
|
|
26
|
+
const titleFontWeight = toFontWeight(getVariableByName('nudge/title/fontWeight', modes), '700');
|
|
40
27
|
const bodyColor = getVariableByName('nudge/body/color', modes) || '#1a1c1f';
|
|
41
28
|
const bodyFontSize = getVariableByName('nudge/body/fontSize', modes) || 12;
|
|
42
|
-
const bodyFontFamily = getVariableByName('nudge/body/fontFamily', modes) || '
|
|
29
|
+
const bodyFontFamily = getVariableByName('nudge/body/fontFamily', modes) || 'System';
|
|
43
30
|
const bodyLineHeight = getVariableByName('nudge/body/lineHeight', modes) || 16;
|
|
44
|
-
const
|
|
45
|
-
const bodyFontWeight = typeof bodyFontWeightRaw === 'number' ? bodyFontWeightRaw.toString() : bodyFontWeightRaw;
|
|
31
|
+
const bodyFontWeight = toFontWeight(getVariableByName('nudge/body/fontWeight', modes), '500');
|
|
46
32
|
const textGap = getVariableByName('nudge/text/gap', modes) || 4;
|
|
47
33
|
const contentGap = getVariableByName('nudge/content/gap', modes) || 8;
|
|
48
34
|
const contentMinHeight = getVariableByName('nudge/content/minHeight', modes) || 20;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
35
|
+
const startSlotGap = getVariableByName('nudge/startSlot/gap', modes) || 4;
|
|
36
|
+
return {
|
|
37
|
+
containerBaseStyle: {
|
|
38
|
+
backgroundColor: background,
|
|
39
|
+
borderRadius: radius,
|
|
40
|
+
paddingHorizontal: paddingH,
|
|
41
|
+
paddingVertical: paddingV,
|
|
42
|
+
gap: gap,
|
|
43
|
+
overflow: 'hidden'
|
|
44
|
+
},
|
|
45
|
+
prominentContainerStyle: {
|
|
46
|
+
flexDirection: 'row',
|
|
47
|
+
alignItems: 'flex-start'
|
|
48
|
+
},
|
|
49
|
+
compactContainerStyle: {
|
|
50
|
+
flexDirection: 'row',
|
|
51
|
+
alignItems: 'center'
|
|
52
|
+
},
|
|
53
|
+
detailedContainerStyle: {
|
|
57
54
|
flexDirection: 'column',
|
|
58
55
|
alignItems: 'flex-start'
|
|
59
|
-
}
|
|
56
|
+
},
|
|
57
|
+
contentStyle: {
|
|
58
|
+
flex: 1,
|
|
59
|
+
minWidth: 1,
|
|
60
|
+
minHeight: contentMinHeight,
|
|
61
|
+
justifyContent: 'center',
|
|
62
|
+
overflow: 'hidden'
|
|
63
|
+
},
|
|
64
|
+
compactOuterContentStyle: {
|
|
65
|
+
flex: 1,
|
|
66
|
+
minWidth: 1,
|
|
67
|
+
alignSelf: 'stretch',
|
|
68
|
+
justifyContent: 'center'
|
|
69
|
+
},
|
|
70
|
+
compactContentWrapStyle: {
|
|
60
71
|
flexDirection: 'row',
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
gap: contentGap,
|
|
74
|
+
width: '100%'
|
|
75
|
+
},
|
|
76
|
+
textWrapStyle: {
|
|
77
|
+
gap: textGap,
|
|
78
|
+
alignItems: 'flex-start',
|
|
79
|
+
width: '100%'
|
|
80
|
+
},
|
|
81
|
+
compactTextWrapStyle: {
|
|
82
|
+
flex: 1,
|
|
83
|
+
minWidth: 1,
|
|
61
84
|
alignItems: 'flex-start'
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
},
|
|
86
|
+
headerStyle: {
|
|
87
|
+
flexDirection: 'row',
|
|
88
|
+
alignItems: 'center',
|
|
89
|
+
gap: gap,
|
|
90
|
+
width: '100%'
|
|
91
|
+
},
|
|
92
|
+
detailSlotStyle: {
|
|
93
|
+
gap: getVariableByName('slot/gap', modes) || 8,
|
|
94
|
+
width: '100%'
|
|
95
|
+
},
|
|
96
|
+
titleTextStyle: {
|
|
97
|
+
color: titleColor,
|
|
98
|
+
fontSize: titleFontSize,
|
|
99
|
+
fontFamily: titleFontFamily,
|
|
100
|
+
lineHeight: titleLineHeight,
|
|
101
|
+
fontWeight: titleFontWeight
|
|
102
|
+
},
|
|
103
|
+
bodyTextStyle: {
|
|
104
|
+
color: bodyColor,
|
|
105
|
+
fontSize: bodyFontSize,
|
|
106
|
+
fontFamily: bodyFontFamily,
|
|
107
|
+
lineHeight: bodyLineHeight,
|
|
108
|
+
fontWeight: bodyFontWeight
|
|
109
|
+
},
|
|
110
|
+
iconColor: getVariableByName('appearance/nudge/icon/color', modes) || '#5d00b5',
|
|
111
|
+
iconSize: getVariableByName('nudge/icon/size', modes) || 20,
|
|
112
|
+
startSlotGap: startSlotGap
|
|
77
113
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
114
|
+
}
|
|
115
|
+
function NudgeImpl({
|
|
116
|
+
type = 'stacked-prominent',
|
|
117
|
+
title = 'Split payment',
|
|
118
|
+
body = 'Split this transaction into installments',
|
|
119
|
+
buttonLabel = 'Button',
|
|
120
|
+
onPressButton,
|
|
121
|
+
buttonSlot,
|
|
122
|
+
startSlot,
|
|
123
|
+
children,
|
|
124
|
+
modes: propModes = EMPTY_MODES,
|
|
125
|
+
style
|
|
126
|
+
}) {
|
|
127
|
+
const {
|
|
128
|
+
modes: globalModes
|
|
129
|
+
} = useTokens();
|
|
130
|
+
const modes = useMemo(() => globalModes === EMPTY_MODES && propModes === EMPTY_MODES ? EMPTY_MODES : {
|
|
131
|
+
...globalModes,
|
|
132
|
+
...propModes
|
|
133
|
+
}, [globalModes, propModes]);
|
|
134
|
+
const tokens = useMemo(() => resolveNudgeTokens(modes), [modes]);
|
|
135
|
+
const startSlotElement = useMemo(() => {
|
|
136
|
+
if (startSlot === null || startSlot === false) return null;
|
|
137
|
+
if (startSlot !== undefined) {
|
|
138
|
+
const processed = cloneChildrenWithModes(React.Children.toArray(startSlot), modes);
|
|
139
|
+
return processed.length === 1 ? processed[0] : processed;
|
|
140
|
+
}
|
|
141
|
+
return /*#__PURE__*/_jsx(Icon, {
|
|
142
|
+
name: "ic_ai_sparkle",
|
|
143
|
+
size: tokens.iconSize,
|
|
144
|
+
color: tokens.iconColor,
|
|
145
|
+
accessibilityElementsHidden: true,
|
|
146
|
+
importantForAccessibility: "no"
|
|
147
|
+
});
|
|
148
|
+
}, [startSlot, modes, tokens.iconColor, tokens.iconSize]);
|
|
149
|
+
const startSlotWrapper = startSlotElement ? /*#__PURE__*/_jsx(View, {
|
|
150
|
+
style: {
|
|
151
|
+
gap: tokens.startSlotGap,
|
|
152
|
+
alignItems: 'center'
|
|
153
|
+
},
|
|
154
|
+
children: startSlotElement
|
|
155
|
+
}) : null;
|
|
156
|
+
const processedChildren = useMemo(() => {
|
|
157
|
+
if (!children) return null;
|
|
158
|
+
const processed = cloneChildrenWithModes(React.Children.toArray(children), modes);
|
|
159
|
+
return processed.length === 1 ? processed[0] : processed;
|
|
160
|
+
}, [children, modes]);
|
|
161
|
+
const buttonElement = buttonSlot ? cloneChildrenWithModes(React.Children.toArray(buttonSlot), modes) : /*#__PURE__*/_jsx(Button, {
|
|
162
|
+
label: buttonLabel,
|
|
163
|
+
modes: modes,
|
|
164
|
+
...(onPressButton ? {
|
|
165
|
+
onPress: onPressButton
|
|
166
|
+
} : {})
|
|
167
|
+
});
|
|
168
|
+
if (type === 'stacked-detailed') {
|
|
81
169
|
return /*#__PURE__*/_jsxs(View, {
|
|
82
|
-
style: [
|
|
170
|
+
style: [tokens.containerBaseStyle, tokens.detailedContainerStyle, style],
|
|
83
171
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
84
|
-
style:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
gap: 6,
|
|
88
|
-
width: '100%'
|
|
89
|
-
},
|
|
90
|
-
children: [startSlotElement, /*#__PURE__*/_jsx(Text, {
|
|
91
|
-
style: [titleStyle, {
|
|
172
|
+
style: tokens.headerStyle,
|
|
173
|
+
children: [startSlotWrapper, /*#__PURE__*/_jsx(Text, {
|
|
174
|
+
style: [tokens.titleTextStyle, {
|
|
92
175
|
flex: 1
|
|
93
176
|
}],
|
|
94
177
|
children: title
|
|
95
178
|
})]
|
|
96
|
-
}),
|
|
179
|
+
}), processedChildren ? /*#__PURE__*/_jsx(View, {
|
|
180
|
+
style: tokens.detailSlotStyle,
|
|
181
|
+
children: processedChildren
|
|
182
|
+
}) : null]
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (type === 'inline-compact') {
|
|
186
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
187
|
+
style: [tokens.containerBaseStyle, tokens.compactContainerStyle, style],
|
|
188
|
+
children: [startSlotWrapper, /*#__PURE__*/_jsx(View, {
|
|
189
|
+
style: tokens.compactOuterContentStyle,
|
|
190
|
+
children: processedChildren || /*#__PURE__*/_jsxs(View, {
|
|
191
|
+
style: tokens.compactContentWrapStyle,
|
|
192
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
193
|
+
style: tokens.compactTextWrapStyle,
|
|
194
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
195
|
+
style: tokens.bodyTextStyle,
|
|
196
|
+
children: body
|
|
197
|
+
})
|
|
198
|
+
}), buttonElement]
|
|
199
|
+
})
|
|
200
|
+
})]
|
|
97
201
|
});
|
|
98
202
|
}
|
|
99
|
-
const
|
|
203
|
+
const prominentContent = /*#__PURE__*/_jsxs(View, {
|
|
100
204
|
style: {
|
|
101
|
-
gap:
|
|
205
|
+
gap: tokens.compactContentWrapStyle.gap,
|
|
102
206
|
alignItems: 'flex-start',
|
|
103
207
|
width: '100%'
|
|
104
208
|
},
|
|
105
209
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
106
|
-
style:
|
|
107
|
-
gap: textGap,
|
|
108
|
-
alignItems: 'flex-start',
|
|
109
|
-
width: '100%'
|
|
110
|
-
},
|
|
210
|
+
style: tokens.textWrapStyle,
|
|
111
211
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
112
|
-
style:
|
|
212
|
+
style: tokens.titleTextStyle,
|
|
113
213
|
children: title
|
|
114
214
|
}), /*#__PURE__*/_jsx(Text, {
|
|
115
|
-
style:
|
|
215
|
+
style: tokens.bodyTextStyle,
|
|
116
216
|
children: body
|
|
117
217
|
})]
|
|
118
|
-
}),
|
|
119
|
-
label: buttonLabel,
|
|
120
|
-
onPress: onPressButton,
|
|
121
|
-
modes: modes
|
|
122
|
-
})]
|
|
218
|
+
}), buttonElement]
|
|
123
219
|
});
|
|
124
220
|
return /*#__PURE__*/_jsxs(View, {
|
|
125
|
-
style: [
|
|
126
|
-
children: [
|
|
127
|
-
style:
|
|
128
|
-
|
|
129
|
-
minWidth: 1,
|
|
130
|
-
minHeight: contentMinHeight,
|
|
131
|
-
justifyContent: 'center',
|
|
132
|
-
overflow: 'hidden'
|
|
133
|
-
},
|
|
134
|
-
children: children ? cloneChildrenWithModes(React.Children.toArray(children), modes) : defaultContent
|
|
221
|
+
style: [tokens.containerBaseStyle, tokens.prominentContainerStyle, style],
|
|
222
|
+
children: [startSlotWrapper, /*#__PURE__*/_jsx(View, {
|
|
223
|
+
style: tokens.contentStyle,
|
|
224
|
+
children: processedChildren || prominentContent
|
|
135
225
|
})]
|
|
136
226
|
});
|
|
137
227
|
}
|
|
228
|
+
const Nudge = /*#__PURE__*/React.memo(NudgeImpl);
|
|
138
229
|
export default Nudge;
|
|
@@ -9,6 +9,7 @@ export { default as BottomNav } from './BottomNav/BottomNav';
|
|
|
9
9
|
export { default as BottomNavItem } from './BottomNavItem/BottomNavItem';
|
|
10
10
|
export { default as Button } from './Button/Button';
|
|
11
11
|
export { default as Card } from './Card/Card';
|
|
12
|
+
export { default as CardAdvisory } from './CardAdvisory/CardAdvisory';
|
|
12
13
|
export { default as Carousel } from './Carousel/Carousel';
|
|
13
14
|
export { default as Checkbox } from './Checkbox/Checkbox';
|
|
14
15
|
export { default as CardFeedback } from './CardFeedback/CardFeedback';
|
|
@@ -21,6 +22,10 @@ export { default as FilterBar } from './FilterBar/FilterBar';
|
|
|
21
22
|
export { default as Form } from './Form/Form';
|
|
22
23
|
export { useFormContext } from './Form/Form';
|
|
23
24
|
export { default as FormField } from './FormField/FormField';
|
|
25
|
+
export { default as CircularProgressBar } from './CircularProgressBar/CircularProgressBar';
|
|
26
|
+
export { default as CircularProgressBarDoted } from './CircularProgressBarDoted/CircularProgressBarDoted';
|
|
27
|
+
export { default as CircularRating } from './CircularRating/CircularRating';
|
|
28
|
+
export { default as Gauge } from './Gauge/Gauge';
|
|
24
29
|
export { default as HoldingsCard } from './HoldingsCard/HoldingsCard';
|
|
25
30
|
export { default as HStack } from './HStack/HStack';
|
|
26
31
|
export { default as IconButton } from './IconButton/IconButton';
|