jfs-components 0.1.25 → 0.1.28
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 +40 -0
- package/lib/commonjs/components/AutoplayControl/AutoplayControl.js +66 -0
- package/lib/commonjs/components/Carousel/Carousel.js +112 -19
- package/lib/commonjs/components/ContentSheet/ContentSheet.js +39 -5
- package/lib/commonjs/components/FormUpload/Additem.js +168 -0
- package/lib/commonjs/components/FormUpload/FormUpload.js +198 -0
- package/lib/commonjs/components/Grid/Grid.js +206 -0
- package/lib/commonjs/components/NumberPagination/NumberPagination.js +144 -0
- package/lib/commonjs/components/ProfileCard/ProfileCard.js +208 -0
- package/lib/commonjs/components/UpiHandle/UpiHandle.js +23 -11
- package/lib/commonjs/components/index.js +42 -0
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/commonjs/design-tokens/figma-modes.generated.js +21 -10
- package/lib/commonjs/icons/components/IconBrokenimage.js +19 -0
- package/lib/commonjs/icons/components/IconImage.js +19 -0
- package/lib/commonjs/icons/components/IconMic.js +19 -0
- package/lib/commonjs/icons/components/IconMicoff.js +19 -0
- package/lib/commonjs/icons/components/IconPause.js +19 -0
- package/lib/commonjs/icons/components/IconPlay.js +19 -0
- package/lib/commonjs/icons/components/index.js +66 -0
- package/lib/commonjs/icons/registry.js +2 -2
- package/lib/module/components/AutoplayControl/AutoplayControl.js +60 -0
- package/lib/module/components/Carousel/Carousel.js +111 -19
- package/lib/module/components/ContentSheet/ContentSheet.js +41 -7
- package/lib/module/components/FormUpload/Additem.js +162 -0
- package/lib/module/components/FormUpload/FormUpload.js +192 -0
- package/lib/module/components/Grid/Grid.js +201 -0
- package/lib/module/components/NumberPagination/NumberPagination.js +138 -0
- package/lib/module/components/ProfileCard/ProfileCard.js +202 -0
- package/lib/module/components/UpiHandle/UpiHandle.js +23 -11
- package/lib/module/components/index.js +7 -1
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -1
- package/lib/module/design-tokens/figma-modes.generated.js +21 -10
- package/lib/module/icons/components/IconBrokenimage.js +12 -0
- package/lib/module/icons/components/IconImage.js +12 -0
- package/lib/module/icons/components/IconMic.js +12 -0
- package/lib/module/icons/components/IconMicoff.js +12 -0
- package/lib/module/icons/components/IconPause.js +12 -0
- package/lib/module/icons/components/IconPlay.js +12 -0
- package/lib/module/icons/components/index.js +6 -0
- package/lib/module/icons/registry.js +2 -2
- package/lib/typescript/src/components/AutoplayControl/AutoplayControl.d.ts +15 -0
- package/lib/typescript/src/components/Carousel/Carousel.d.ts +8 -1
- package/lib/typescript/src/components/ContentSheet/ContentSheet.d.ts +7 -1
- package/lib/typescript/src/components/FormUpload/Additem.d.ts +96 -0
- package/lib/typescript/src/components/FormUpload/FormUpload.d.ts +85 -0
- package/lib/typescript/src/components/Grid/Grid.d.ts +87 -0
- package/lib/typescript/src/components/NumberPagination/NumberPagination.d.ts +21 -0
- package/lib/typescript/src/components/ProfileCard/ProfileCard.d.ts +89 -0
- package/lib/typescript/src/components/UpiHandle/UpiHandle.d.ts +7 -1
- package/lib/typescript/src/components/index.d.ts +34 -28
- package/lib/typescript/src/design-tokens/figma-modes.generated.d.ts +10 -4
- package/lib/typescript/src/icons/components/IconBrokenimage.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconImage.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconMic.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconMicoff.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconPause.d.ts +3 -0
- package/lib/typescript/src/icons/components/IconPlay.d.ts +3 -0
- package/lib/typescript/src/icons/components/index.d.ts +6 -0
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/AutoplayControl/AutoplayControl.tsx +77 -0
- package/src/components/Carousel/Carousel.tsx +133 -23
- package/src/components/ContentSheet/ContentSheet.tsx +50 -0
- package/src/components/FormUpload/Additem.tsx +262 -0
- package/src/components/FormUpload/FormUpload.tsx +313 -0
- package/src/components/Grid/Grid.tsx +368 -0
- package/src/components/NumberPagination/NumberPagination.tsx +170 -0
- package/src/components/ProfileCard/ProfileCard.tsx +268 -0
- package/src/components/UpiHandle/UpiHandle.tsx +35 -24
- package/src/components/index.ts +329 -182
- package/src/design-tokens/Coin Variables-variables-full.json +1 -1
- package/src/design-tokens/figma-modes.generated.ts +21 -10
- package/src/icons/components/IconBrokenimage.tsx +11 -0
- package/src/icons/components/IconImage.tsx +11 -0
- package/src/icons/components/IconMic.tsx +11 -0
- package/src/icons/components/IconMicoff.tsx +11 -0
- package/src/icons/components/IconPause.tsx +11 -0
- package/src/icons/components/IconPlay.tsx +11 -0
- package/src/icons/components/index.ts +6 -0
- package/src/icons/registry.ts +25 -1
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(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 _Form = require("../Form/Form");
|
|
13
|
+
var _SupportText = _interopRequireDefault(require("../SupportText/SupportText"));
|
|
14
|
+
var _Additem = _interopRequireDefault(require("./Additem"));
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
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); }
|
|
18
|
+
function toNumber(value, fallback) {
|
|
19
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
20
|
+
if (typeof value === 'string') {
|
|
21
|
+
const parsed = parseFloat(value);
|
|
22
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
23
|
+
}
|
|
24
|
+
return fallback;
|
|
25
|
+
}
|
|
26
|
+
function toFontWeight(value, fallback) {
|
|
27
|
+
if (typeof value === 'number') return value.toString();
|
|
28
|
+
if (typeof value === 'string' && value.length > 0) return value;
|
|
29
|
+
return fallback;
|
|
30
|
+
}
|
|
31
|
+
function resolveFormUploadTokens(modes) {
|
|
32
|
+
const gap = toNumber((0, _figmaVariablesResolver.getVariableByName)('formField/input/gap', modes), 8);
|
|
33
|
+
const rowGap = toNumber((0, _figmaVariablesResolver.getVariableByName)('formField/gap', modes), 8);
|
|
34
|
+
const labelColor = (0, _figmaVariablesResolver.getVariableByName)('formField/label/color', modes);
|
|
35
|
+
const labelFontFamily = (0, _figmaVariablesResolver.getVariableByName)('formField/label/fontFamily', modes);
|
|
36
|
+
const labelFontSize = toNumber((0, _figmaVariablesResolver.getVariableByName)('formField/label/fontSize', modes), 14);
|
|
37
|
+
const labelLineHeight = toNumber((0, _figmaVariablesResolver.getVariableByName)('formField/label/lineHeight', modes), 17);
|
|
38
|
+
const labelFontWeight = toFontWeight((0, _figmaVariablesResolver.getVariableByName)('formField/label/fontWeight', modes), '500');
|
|
39
|
+
return {
|
|
40
|
+
gap,
|
|
41
|
+
rowGap,
|
|
42
|
+
labelColor,
|
|
43
|
+
labelFontFamily,
|
|
44
|
+
labelFontSize,
|
|
45
|
+
labelLineHeight,
|
|
46
|
+
labelFontWeight
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function firstError(error) {
|
|
50
|
+
if (!error) return undefined;
|
|
51
|
+
if (Array.isArray(error)) return error[0];
|
|
52
|
+
return error;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Figma defaults for the remove `IconCapsule` on filled preview cells. Overridable via `modes`. */
|
|
56
|
+
const FORM_UPLOAD_PREVIEW_ICON_CAPSULE_MODES = {
|
|
57
|
+
AppearanceBrand: 'Neutral',
|
|
58
|
+
Emphasis: 'Medium',
|
|
59
|
+
'Icon Capsule Size': 'XS'
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* `FormUpload` — a form-aware upload row built from reusable `Additem` cells.
|
|
64
|
+
*
|
|
65
|
+
* The component mirrors the Figma "FormUpload" design: a label, a horizontal
|
|
66
|
+
* row of upload/preview cells, and support text. It integrates with the
|
|
67
|
+
* existing `<Form>` context so server-side validation errors automatically
|
|
68
|
+
* show below the row, and it clears those errors when attachments change.
|
|
69
|
+
*
|
|
70
|
+
* Upload behaviour is provided through the `picker` prop so the library stays
|
|
71
|
+
* free of native image-picker dependencies. Pass any picker that returns the
|
|
72
|
+
* `AdditemPickerResult` shape and the empty cell becomes a real upload trigger
|
|
73
|
+
* on both iOS and Android.
|
|
74
|
+
*/
|
|
75
|
+
function FormUpload({
|
|
76
|
+
label,
|
|
77
|
+
supportText,
|
|
78
|
+
name,
|
|
79
|
+
attachments = [],
|
|
80
|
+
maxCount,
|
|
81
|
+
onAttachmentsChange,
|
|
82
|
+
picker,
|
|
83
|
+
errorMessage,
|
|
84
|
+
isInvalid = false,
|
|
85
|
+
isDisabled = false,
|
|
86
|
+
children,
|
|
87
|
+
modes: propModes = _reactUtils.EMPTY_MODES,
|
|
88
|
+
style,
|
|
89
|
+
rowStyle,
|
|
90
|
+
accessibilityLabel,
|
|
91
|
+
testID
|
|
92
|
+
}) {
|
|
93
|
+
const formCtx = (0, _Form.useFormContext)();
|
|
94
|
+
const formError = name && formCtx ? firstError(formCtx.validationErrors[name]) : undefined;
|
|
95
|
+
const resolvedIsInvalid = isInvalid || Boolean(formError);
|
|
96
|
+
const resolvedErrorMessage = errorMessage ?? formError;
|
|
97
|
+
const {
|
|
98
|
+
modes: globalModes
|
|
99
|
+
} = (0, _JFSThemeProvider.useTokens)();
|
|
100
|
+
const baseModes = (0, _react.useMemo)(() => globalModes === _reactUtils.EMPTY_MODES && propModes === _reactUtils.EMPTY_MODES ? _reactUtils.EMPTY_MODES : {
|
|
101
|
+
...globalModes,
|
|
102
|
+
...propModes
|
|
103
|
+
}, [globalModes, propModes]);
|
|
104
|
+
const modes = (0, _react.useMemo)(() => ({
|
|
105
|
+
...baseModes,
|
|
106
|
+
'FormField States': resolvedIsInvalid ? 'Error' : 'Idle',
|
|
107
|
+
Status: resolvedIsInvalid ? 'Error' : 'Auto'
|
|
108
|
+
}), [baseModes, resolvedIsInvalid]);
|
|
109
|
+
|
|
110
|
+
// Empty cells rely on `Additem`'s built-in Neutral / Low / S defaults for the
|
|
111
|
+
// add icon. Preview cells use the tighter remove-icon treatment from Figma.
|
|
112
|
+
const previewAdditemModes = (0, _react.useMemo)(() => ({
|
|
113
|
+
...FORM_UPLOAD_PREVIEW_ICON_CAPSULE_MODES,
|
|
114
|
+
...modes
|
|
115
|
+
}), [modes]);
|
|
116
|
+
const tokens = (0, _react.useMemo)(() => resolveFormUploadTokens(modes), [modes]);
|
|
117
|
+
const handleAssetsPicked = (0, _react.useCallback)(assets => {
|
|
118
|
+
if (isDisabled) return;
|
|
119
|
+
const next = [...attachments, ...assets];
|
|
120
|
+
if (maxCount != null && next.length > maxCount) {
|
|
121
|
+
next.length = maxCount;
|
|
122
|
+
}
|
|
123
|
+
onAttachmentsChange?.(next);
|
|
124
|
+
if (name && formCtx) {
|
|
125
|
+
formCtx.onFieldChange(name);
|
|
126
|
+
}
|
|
127
|
+
}, [attachments, maxCount, onAttachmentsChange, isDisabled, name, formCtx]);
|
|
128
|
+
const handleRemove = (0, _react.useCallback)(index => {
|
|
129
|
+
if (isDisabled) return;
|
|
130
|
+
const next = attachments.filter((_, i) => i !== index);
|
|
131
|
+
onAttachmentsChange?.(next);
|
|
132
|
+
if (name && formCtx) {
|
|
133
|
+
formCtx.onFieldChange(name);
|
|
134
|
+
}
|
|
135
|
+
}, [attachments, onAttachmentsChange, isDisabled, name, formCtx]);
|
|
136
|
+
const containerStyle = (0, _react.useMemo)(() => ({
|
|
137
|
+
gap: tokens.gap,
|
|
138
|
+
opacity: isDisabled ? 0.5 : 1
|
|
139
|
+
}), [tokens.gap, isDisabled]);
|
|
140
|
+
const rowStyleResolved = (0, _react.useMemo)(() => ({
|
|
141
|
+
flexDirection: 'row',
|
|
142
|
+
flexWrap: 'wrap',
|
|
143
|
+
gap: tokens.rowGap,
|
|
144
|
+
alignItems: 'flex-start'
|
|
145
|
+
}), [tokens.rowGap]);
|
|
146
|
+
const labelStyle = (0, _react.useMemo)(() => ({
|
|
147
|
+
color: tokens.labelColor,
|
|
148
|
+
fontFamily: tokens.labelFontFamily,
|
|
149
|
+
fontSize: tokens.labelFontSize,
|
|
150
|
+
lineHeight: tokens.labelLineHeight,
|
|
151
|
+
fontWeight: tokens.labelFontWeight
|
|
152
|
+
}), [tokens]);
|
|
153
|
+
const resolvedA11yLabel = accessibilityLabel ?? label ?? 'Attachment upload';
|
|
154
|
+
const canAddMore = maxCount == null || attachments.length < maxCount;
|
|
155
|
+
const renderContent = () => {
|
|
156
|
+
if (children) {
|
|
157
|
+
return (0, _reactUtils.cloneChildrenWithModes)(children, modes);
|
|
158
|
+
}
|
|
159
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
160
|
+
children: [attachments.map((attachment, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Additem.default, {
|
|
161
|
+
state: "preview",
|
|
162
|
+
imageSource: attachment.uri,
|
|
163
|
+
onRemove: () => handleRemove(index),
|
|
164
|
+
modes: previewAdditemModes,
|
|
165
|
+
isDisabled: isDisabled,
|
|
166
|
+
accessibilityLabel: attachment.name ?? `Attachment ${index + 1}`,
|
|
167
|
+
testID: `${testID}-item-${index}`
|
|
168
|
+
}, `${attachment.uri}-${index}`)), canAddMore && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Additem.default, {
|
|
169
|
+
state: "empty",
|
|
170
|
+
picker: picker,
|
|
171
|
+
onAssetsPicked: handleAssetsPicked,
|
|
172
|
+
modes: modes,
|
|
173
|
+
isDisabled: isDisabled,
|
|
174
|
+
testID: `${testID}-add`
|
|
175
|
+
})]
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
const supportLabel = resolvedIsInvalid && resolvedErrorMessage ? resolvedErrorMessage : supportText;
|
|
179
|
+
const supportStatus = resolvedIsInvalid ? 'Error' : 'Neutral';
|
|
180
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
181
|
+
style: [containerStyle, style],
|
|
182
|
+
accessibilityRole: "none",
|
|
183
|
+
accessibilityLabel: resolvedA11yLabel,
|
|
184
|
+
testID: testID,
|
|
185
|
+
children: [label != null && label !== '' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
186
|
+
style: labelStyle,
|
|
187
|
+
children: label
|
|
188
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
189
|
+
style: [rowStyleResolved, rowStyle],
|
|
190
|
+
children: renderContent()
|
|
191
|
+
}), supportLabel != null && supportLabel !== '' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_SupportText.default, {
|
|
192
|
+
label: supportLabel,
|
|
193
|
+
status: supportStatus,
|
|
194
|
+
modes: modes
|
|
195
|
+
})]
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
var _default = exports.default = /*#__PURE__*/_react.default.memo(FormUpload);
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(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 _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
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); }
|
|
14
|
+
function toNumber(value, fallback) {
|
|
15
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
16
|
+
if (typeof value === 'string') {
|
|
17
|
+
const parsed = parseFloat(value);
|
|
18
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
19
|
+
}
|
|
20
|
+
return fallback;
|
|
21
|
+
}
|
|
22
|
+
function resolveGridTokens(modes) {
|
|
23
|
+
const gapFallback = toNumber((0, _figmaVariablesResolver.getVariableByName)('Grid/gap', modes), 8);
|
|
24
|
+
const columnGap = toNumber((0, _figmaVariablesResolver.getVariableByName)('Grid/column/gap', modes), gapFallback);
|
|
25
|
+
const rowGap = toNumber((0, _figmaVariablesResolver.getVariableByName)('Grid/row/gap', modes), gapFallback);
|
|
26
|
+
const paddingHorizontal = toNumber((0, _figmaVariablesResolver.getVariableByName)('Grid/padding/horizontal', modes), 8);
|
|
27
|
+
const paddingVertical = toNumber((0, _figmaVariablesResolver.getVariableByName)('Grid/padding/vertical', modes), 8);
|
|
28
|
+
const paddingTop = toNumber((0, _figmaVariablesResolver.getVariableByName)('Grid/padding/top', modes), paddingVertical);
|
|
29
|
+
const paddingBottom = toNumber((0, _figmaVariablesResolver.getVariableByName)('Grid/padding/bottom', modes), paddingVertical);
|
|
30
|
+
const paddingLeft = toNumber((0, _figmaVariablesResolver.getVariableByName)('Grid/padding/left', modes), paddingHorizontal);
|
|
31
|
+
const paddingRight = toNumber((0, _figmaVariablesResolver.getVariableByName)('Grid/padding/right', modes), paddingHorizontal);
|
|
32
|
+
const backgroundColor = (0, _figmaVariablesResolver.getVariableByName)('Grid/background/color', modes) ?? 'transparent';
|
|
33
|
+
return {
|
|
34
|
+
backgroundColor,
|
|
35
|
+
columnGap,
|
|
36
|
+
rowGap,
|
|
37
|
+
paddingTop,
|
|
38
|
+
paddingBottom,
|
|
39
|
+
paddingLeft,
|
|
40
|
+
paddingRight
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function normalizeFrs(frs, count) {
|
|
44
|
+
if (!frs || frs.length === 0) {
|
|
45
|
+
return Array.from({
|
|
46
|
+
length: count
|
|
47
|
+
}, () => 1);
|
|
48
|
+
}
|
|
49
|
+
return Array.from({
|
|
50
|
+
length: count
|
|
51
|
+
}, (_, index) => {
|
|
52
|
+
const value = frs[index] ?? frs[frs.length - 1] ?? 1;
|
|
53
|
+
return value > 0 ? value : 1;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function resolveAlignSelf(alignItems) {
|
|
57
|
+
if (alignItems === 'center') return 'center';
|
|
58
|
+
if (alignItems === 'start') return 'flex-start';
|
|
59
|
+
return 'stretch';
|
|
60
|
+
}
|
|
61
|
+
function resolveRowJustifyContent(justifyContent) {
|
|
62
|
+
if (justifyContent === 'space-between') return 'space-between';
|
|
63
|
+
if (justifyContent === 'start') return 'flex-start';
|
|
64
|
+
return 'flex-start';
|
|
65
|
+
}
|
|
66
|
+
function buildCellStyle(columnFr, justifyContent, alignItems) {
|
|
67
|
+
const alignSelf = resolveAlignSelf(alignItems);
|
|
68
|
+
if (justifyContent === 'space-between' || justifyContent === 'start') {
|
|
69
|
+
return {
|
|
70
|
+
flexGrow: 0,
|
|
71
|
+
flexShrink: 1,
|
|
72
|
+
flexBasis: 'auto',
|
|
73
|
+
minWidth: 0,
|
|
74
|
+
alignSelf
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
flex: columnFr,
|
|
79
|
+
minWidth: 0,
|
|
80
|
+
alignSelf
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* `Grid` — a token-driven layout grid for React Native.
|
|
86
|
+
*
|
|
87
|
+
* Mirrors the Figma "Grid" component: a padded container with configurable
|
|
88
|
+
* columns, rows, fractional column tracks (`columnFrs`), and gap tokens.
|
|
89
|
+
* Each slot child maps to one cell — no separate `GridItem` wrapper is needed.
|
|
90
|
+
*
|
|
91
|
+
* @component
|
|
92
|
+
*/
|
|
93
|
+
function Grid({
|
|
94
|
+
columns = 1,
|
|
95
|
+
rows,
|
|
96
|
+
columnFrs,
|
|
97
|
+
rowFrs,
|
|
98
|
+
columnGap: columnGapProp,
|
|
99
|
+
rowGap: rowGapProp,
|
|
100
|
+
gap: gapProp,
|
|
101
|
+
padding: paddingProp,
|
|
102
|
+
paddingHorizontal: paddingHorizontalProp,
|
|
103
|
+
paddingVertical: paddingVerticalProp,
|
|
104
|
+
paddingTop: paddingTopProp,
|
|
105
|
+
paddingBottom: paddingBottomProp,
|
|
106
|
+
paddingLeft: paddingLeftProp,
|
|
107
|
+
paddingRight: paddingRightProp,
|
|
108
|
+
justifyContent = 'stretch',
|
|
109
|
+
alignItems = 'stretch',
|
|
110
|
+
children,
|
|
111
|
+
modes: propModes = _reactUtils.EMPTY_MODES,
|
|
112
|
+
style,
|
|
113
|
+
contentStyle,
|
|
114
|
+
cellStyle,
|
|
115
|
+
accessibilityLabel,
|
|
116
|
+
testID
|
|
117
|
+
}) {
|
|
118
|
+
const {
|
|
119
|
+
modes: globalModes
|
|
120
|
+
} = (0, _JFSThemeProvider.useTokens)();
|
|
121
|
+
const modes = (0, _react.useMemo)(() => globalModes === _reactUtils.EMPTY_MODES && propModes === _reactUtils.EMPTY_MODES ? _reactUtils.EMPTY_MODES : {
|
|
122
|
+
...globalModes,
|
|
123
|
+
...propModes
|
|
124
|
+
}, [globalModes, propModes]);
|
|
125
|
+
const tokens = (0, _react.useMemo)(() => resolveGridTokens(modes), [modes]);
|
|
126
|
+
const resolvedColumnGap = columnGapProp ?? gapProp ?? tokens.columnGap;
|
|
127
|
+
const resolvedRowGap = rowGapProp ?? gapProp ?? tokens.rowGap;
|
|
128
|
+
const resolvedPadding = (0, _react.useMemo)(() => ({
|
|
129
|
+
paddingTop: paddingTopProp ?? paddingVerticalProp ?? paddingProp ?? tokens.paddingTop,
|
|
130
|
+
paddingBottom: paddingBottomProp ?? paddingVerticalProp ?? paddingProp ?? tokens.paddingBottom,
|
|
131
|
+
paddingLeft: paddingLeftProp ?? paddingHorizontalProp ?? paddingProp ?? tokens.paddingLeft,
|
|
132
|
+
paddingRight: paddingRightProp ?? paddingHorizontalProp ?? paddingProp ?? tokens.paddingRight
|
|
133
|
+
}), [paddingTopProp, paddingBottomProp, paddingLeftProp, paddingRightProp, paddingHorizontalProp, paddingVerticalProp, paddingProp, tokens]);
|
|
134
|
+
const safeColumns = Math.max(1, Math.floor(columns));
|
|
135
|
+
const processedChildren = (0, _react.useMemo)(() => (0, _reactUtils.cloneChildrenWithModes)((0, _reactUtils.flattenChildren)(children), modes), [children, modes]);
|
|
136
|
+
const cellNodes = (0, _react.useMemo)(() => {
|
|
137
|
+
const nodes = [...processedChildren];
|
|
138
|
+
if (rows != null) {
|
|
139
|
+
const targetCount = safeColumns * Math.max(1, Math.floor(rows));
|
|
140
|
+
while (nodes.length < targetCount) {
|
|
141
|
+
nodes.push(null);
|
|
142
|
+
}
|
|
143
|
+
if (nodes.length > targetCount) {
|
|
144
|
+
nodes.length = targetCount;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return nodes;
|
|
148
|
+
}, [processedChildren, rows, safeColumns]);
|
|
149
|
+
const gridRows = (0, _react.useMemo)(() => {
|
|
150
|
+
const result = [];
|
|
151
|
+
for (let index = 0; index < cellNodes.length; index += safeColumns) {
|
|
152
|
+
result.push(cellNodes.slice(index, index + safeColumns));
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}, [cellNodes, safeColumns]);
|
|
156
|
+
const normalizedColumnFrs = (0, _react.useMemo)(() => normalizeFrs(columnFrs, safeColumns), [columnFrs, safeColumns]);
|
|
157
|
+
const normalizedRowFrs = (0, _react.useMemo)(() => rowFrs ? normalizeFrs(rowFrs, gridRows.length) : null, [rowFrs, gridRows.length]);
|
|
158
|
+
const containerStyle = (0, _react.useMemo)(() => ({
|
|
159
|
+
backgroundColor: tokens.backgroundColor,
|
|
160
|
+
...resolvedPadding,
|
|
161
|
+
width: '100%'
|
|
162
|
+
}), [tokens.backgroundColor, resolvedPadding]);
|
|
163
|
+
const rowsContainerStyle = (0, _react.useMemo)(() => ({
|
|
164
|
+
gap: resolvedRowGap,
|
|
165
|
+
width: '100%'
|
|
166
|
+
}), [resolvedRowGap]);
|
|
167
|
+
const rowStyle = (0, _react.useMemo)(() => ({
|
|
168
|
+
flexDirection: 'row',
|
|
169
|
+
columnGap: resolvedColumnGap,
|
|
170
|
+
justifyContent: resolveRowJustifyContent(justifyContent),
|
|
171
|
+
alignItems: alignItems === 'stretch' ? 'stretch' : alignItems === 'center' ? 'center' : 'flex-start',
|
|
172
|
+
width: '100%'
|
|
173
|
+
}), [resolvedColumnGap, justifyContent, alignItems]);
|
|
174
|
+
const defaultAccessibilityLabel = accessibilityLabel ?? `Grid, ${safeColumns} column${safeColumns === 1 ? '' : 's'}, ${gridRows.length} row${gridRows.length === 1 ? '' : 's'}`;
|
|
175
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
176
|
+
style: [containerStyle, style],
|
|
177
|
+
accessibilityRole: "none",
|
|
178
|
+
accessibilityLabel: defaultAccessibilityLabel,
|
|
179
|
+
testID: testID,
|
|
180
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
181
|
+
style: [rowsContainerStyle, contentStyle],
|
|
182
|
+
children: gridRows.map((row, rowIndex) => {
|
|
183
|
+
const rowFr = normalizedRowFrs?.[rowIndex];
|
|
184
|
+
const spacersNeeded = justifyContent === 'space-between' && row.length < safeColumns ? safeColumns - row.length : 0;
|
|
185
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
186
|
+
style: rowFr != null ? [rowStyle, {
|
|
187
|
+
flexGrow: rowFr
|
|
188
|
+
}] : rowStyle,
|
|
189
|
+
children: [row.map((cell, columnIndex) => {
|
|
190
|
+
const absoluteIndex = rowIndex * safeColumns + columnIndex;
|
|
191
|
+
const cellFlexStyle = buildCellStyle(normalizedColumnFrs[columnIndex] ?? 1, justifyContent, alignItems);
|
|
192
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
193
|
+
style: [cellFlexStyle, cellStyle],
|
|
194
|
+
children: cell
|
|
195
|
+
}, `grid-cell-${absoluteIndex}`);
|
|
196
|
+
}), spacersNeeded > 0 && Array.from({
|
|
197
|
+
length: spacersNeeded
|
|
198
|
+
}, (_, spacerIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
199
|
+
style: buildCellStyle(normalizedColumnFrs[row.length + spacerIndex] ?? 1, justifyContent, alignItems)
|
|
200
|
+
}, `grid-spacer-${rowIndex}-${spacerIndex}`))]
|
|
201
|
+
}, `grid-row-${rowIndex}`);
|
|
202
|
+
})
|
|
203
|
+
})
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
var _default = exports.default = /*#__PURE__*/_react.default.memo(Grid);
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = NumberPagination;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
|
|
10
|
+
var _GlassFill = _interopRequireDefault(require("../../utils/GlassFill/GlassFill"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
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); }
|
|
14
|
+
function resolveNumberPaginationTokens(modes) {
|
|
15
|
+
const horizontalPadding = (0, _figmaVariablesResolver.getVariableByName)('numberPagination/padding/horizontal', modes) ?? 4;
|
|
16
|
+
const verticalPadding = (0, _figmaVariablesResolver.getVariableByName)('numberPagination/padding/vertical', modes) ?? 4;
|
|
17
|
+
const radiusRaw = (0, _figmaVariablesResolver.getVariableByName)('numberPagination/radius', modes) ?? 9999;
|
|
18
|
+
const backgroundColor = (0, _figmaVariablesResolver.getVariableByName)('numberPagination/background/color', modes) ?? 'rgba(141, 141, 141, 0.4)';
|
|
19
|
+
const borderColor = (0, _figmaVariablesResolver.getVariableByName)('numberPagination/border/color', modes) ?? 'rgba(255, 255, 255, 0.15)';
|
|
20
|
+
|
|
21
|
+
// control number variables
|
|
22
|
+
const itemWidth = (0, _figmaVariablesResolver.getVariableByName)('controlNumber/width', modes) ?? 32;
|
|
23
|
+
const itemHeight = (0, _figmaVariablesResolver.getVariableByName)('controlNumber/height', modes) ?? 32;
|
|
24
|
+
const itemRadiusRaw = (0, _figmaVariablesResolver.getVariableByName)('controlNumber/radius', modes) ?? 9999;
|
|
25
|
+
const activeBgColor = (0, _figmaVariablesResolver.getVariableByName)('control/active/background/color', modes) ?? '#ffffff';
|
|
26
|
+
const activeTextColor = (0, _figmaVariablesResolver.getVariableByName)('control/active/text/color', modes) ?? '#000000';
|
|
27
|
+
const inactiveTextColor = (0, _figmaVariablesResolver.getVariableByName)('control/text/default', modes) ?? '#ffffff';
|
|
28
|
+
|
|
29
|
+
// typography variables
|
|
30
|
+
const fontFamily = (0, _figmaVariablesResolver.getVariableByName)('numberPagination/fontFamily', modes) ?? 'JioType';
|
|
31
|
+
const fontSize = (0, _figmaVariablesResolver.getVariableByName)('numberPagination/fontSize', modes) ?? 16;
|
|
32
|
+
const fontWeight = String((0, _figmaVariablesResolver.getVariableByName)('numberPagination/fontWeight', modes) ?? '500');
|
|
33
|
+
const lineHeight = (0, _figmaVariablesResolver.getVariableByName)('numberPagination/lineHeight', modes) ?? 18;
|
|
34
|
+
const blurMinimal = (0, _figmaVariablesResolver.getVariableByName)('blur/minimal', modes) ?? 29;
|
|
35
|
+
const blurIntensity = Math.max(0, Math.min(100, Math.round(Number(blurMinimal))));
|
|
36
|
+
const borderRadius = radiusRaw === 9999 ? 39 / 2 : radiusRaw;
|
|
37
|
+
const itemRadius = itemRadiusRaw === 9999 ? itemWidth / 2 : itemRadiusRaw;
|
|
38
|
+
return {
|
|
39
|
+
containerStyle: {
|
|
40
|
+
height: 39,
|
|
41
|
+
borderRadius,
|
|
42
|
+
borderWidth: 1,
|
|
43
|
+
borderColor,
|
|
44
|
+
backgroundColor: 'transparent',
|
|
45
|
+
overflow: 'hidden',
|
|
46
|
+
flexDirection: 'row',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
paddingHorizontal: horizontalPadding,
|
|
49
|
+
paddingVertical: verticalPadding
|
|
50
|
+
},
|
|
51
|
+
activeItemStyle: {
|
|
52
|
+
width: itemWidth,
|
|
53
|
+
height: itemHeight,
|
|
54
|
+
borderRadius: itemRadius,
|
|
55
|
+
backgroundColor: activeBgColor,
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center'
|
|
58
|
+
},
|
|
59
|
+
inactiveItemStyle: {
|
|
60
|
+
width: itemWidth,
|
|
61
|
+
height: itemHeight,
|
|
62
|
+
borderRadius: itemRadius,
|
|
63
|
+
backgroundColor: 'transparent',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center'
|
|
66
|
+
},
|
|
67
|
+
activeTextStyle: {
|
|
68
|
+
fontFamily,
|
|
69
|
+
fontSize,
|
|
70
|
+
fontWeight,
|
|
71
|
+
lineHeight,
|
|
72
|
+
color: activeTextColor,
|
|
73
|
+
textAlign: 'center'
|
|
74
|
+
},
|
|
75
|
+
inactiveTextStyle: {
|
|
76
|
+
fontFamily,
|
|
77
|
+
fontSize,
|
|
78
|
+
fontWeight,
|
|
79
|
+
lineHeight,
|
|
80
|
+
color: inactiveTextColor,
|
|
81
|
+
textAlign: 'center'
|
|
82
|
+
},
|
|
83
|
+
blurIntensity,
|
|
84
|
+
backgroundColor
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* NumberPagination component displays a horizontal list of page numbers on a frosted glass surface.
|
|
90
|
+
* All styling is driven by Figma design tokens with support for custom children slot.
|
|
91
|
+
*/
|
|
92
|
+
function NumberPagination({
|
|
93
|
+
activePage = 1,
|
|
94
|
+
totalPages = 1,
|
|
95
|
+
onPageChange,
|
|
96
|
+
children,
|
|
97
|
+
modes,
|
|
98
|
+
style
|
|
99
|
+
}) {
|
|
100
|
+
const tokens = (0, _react.useMemo)(() => resolveNumberPaginationTokens(modes ?? {}), [modes]);
|
|
101
|
+
const renderPages = () => {
|
|
102
|
+
if (children) {
|
|
103
|
+
return children;
|
|
104
|
+
}
|
|
105
|
+
const pages = [];
|
|
106
|
+
for (let i = 1; i <= totalPages; i++) {
|
|
107
|
+
const active = i === activePage;
|
|
108
|
+
pages.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
109
|
+
onPress: () => onPageChange?.(i),
|
|
110
|
+
style: ({
|
|
111
|
+
pressed
|
|
112
|
+
}) => [active ? tokens.activeItemStyle : tokens.inactiveItemStyle, pressed && {
|
|
113
|
+
opacity: 0.7
|
|
114
|
+
}],
|
|
115
|
+
accessibilityRole: "button",
|
|
116
|
+
accessibilityState: {
|
|
117
|
+
selected: active
|
|
118
|
+
},
|
|
119
|
+
accessibilityLabel: `Page ${i}`,
|
|
120
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
121
|
+
style: active ? tokens.activeTextStyle : tokens.inactiveTextStyle,
|
|
122
|
+
children: i
|
|
123
|
+
})
|
|
124
|
+
}, i));
|
|
125
|
+
}
|
|
126
|
+
return pages;
|
|
127
|
+
};
|
|
128
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
129
|
+
style: [tokens.containerStyle, style],
|
|
130
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GlassFill.default, {
|
|
131
|
+
tint: "light",
|
|
132
|
+
intensity: tokens.blurIntensity,
|
|
133
|
+
overlayColor: tokens.backgroundColor,
|
|
134
|
+
androidTintWash: false
|
|
135
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
136
|
+
style: {
|
|
137
|
+
flexDirection: 'row',
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
height: '100%'
|
|
140
|
+
},
|
|
141
|
+
children: renderPages()
|
|
142
|
+
})]
|
|
143
|
+
});
|
|
144
|
+
}
|