jfs-components 0.0.77 → 0.0.79
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 +28 -0
- package/lib/commonjs/components/Accordion/Accordion.js +55 -55
- package/lib/commonjs/components/ActionFooter/ActionFooter.js +48 -2
- package/lib/commonjs/components/Attached/Attached.js +144 -0
- package/lib/commonjs/components/Card/Card.js +25 -2
- package/lib/commonjs/components/Checkbox/Checkbox.js +21 -9
- package/lib/commonjs/components/DropdownInput/DropdownInput.js +30 -16
- package/lib/commonjs/components/ExpandableCheckbox/ExpandableCheckbox.js +167 -0
- package/lib/commonjs/components/FormField/FormField.js +14 -1
- package/lib/commonjs/components/FullscreenModal/FullscreenModal.js +353 -0
- package/lib/commonjs/components/ListItem/ListItem.js +46 -24
- package/lib/commonjs/components/MessageField/MessageField.js +318 -0
- package/lib/commonjs/components/NavArrow/NavArrow.js +58 -17
- package/lib/commonjs/components/PlanComparisonCard/PlanComparisonCard.js +328 -0
- package/lib/commonjs/components/Slot/Slot.js +73 -0
- package/lib/commonjs/components/Stepper/Step.js +47 -60
- package/lib/commonjs/components/Stepper/StepLabel.js +40 -10
- package/lib/commonjs/components/Stepper/Stepper.js +15 -17
- package/lib/commonjs/components/SuggestiveSearch/SuggestiveSearch.js +487 -0
- package/lib/commonjs/components/TextInput/TextInput.js +16 -1
- package/lib/commonjs/components/Title/Title.js +10 -2
- package/lib/commonjs/components/index.js +49 -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/Accordion/Accordion.js +56 -56
- package/lib/module/components/ActionFooter/ActionFooter.js +50 -4
- package/lib/module/components/Attached/Attached.js +139 -0
- package/lib/module/components/Card/Card.js +25 -2
- package/lib/module/components/Checkbox/Checkbox.js +22 -10
- package/lib/module/components/DropdownInput/DropdownInput.js +30 -16
- package/lib/module/components/ExpandableCheckbox/ExpandableCheckbox.js +161 -0
- package/lib/module/components/FormField/FormField.js +16 -3
- package/lib/module/components/FullscreenModal/FullscreenModal.js +348 -0
- package/lib/module/components/ListItem/ListItem.js +46 -24
- package/lib/module/components/MessageField/MessageField.js +313 -0
- package/lib/module/components/NavArrow/NavArrow.js +59 -18
- package/lib/module/components/PlanComparisonCard/PlanComparisonCard.js +322 -0
- package/lib/module/components/Slot/Slot.js +68 -0
- package/lib/module/components/Stepper/Step.js +48 -61
- package/lib/module/components/Stepper/StepLabel.js +40 -10
- package/lib/module/components/Stepper/Stepper.js +15 -17
- package/lib/module/components/SuggestiveSearch/SuggestiveSearch.js +481 -0
- package/lib/module/components/TextInput/TextInput.js +17 -2
- package/lib/module/components/Title/Title.js +10 -2
- package/lib/module/components/index.js +7 -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/Accordion/Accordion.d.ts +14 -20
- package/lib/typescript/src/components/Attached/Attached.d.ts +61 -0
- package/lib/typescript/src/components/Card/Card.d.ts +9 -2
- package/lib/typescript/src/components/ExpandableCheckbox/ExpandableCheckbox.d.ts +63 -0
- package/lib/typescript/src/components/FullscreenModal/FullscreenModal.d.ts +99 -0
- package/lib/typescript/src/components/ListItem/ListItem.d.ts +15 -5
- package/lib/typescript/src/components/MessageField/MessageField.d.ts +81 -0
- package/lib/typescript/src/components/NavArrow/NavArrow.d.ts +10 -5
- package/lib/typescript/src/components/PlanComparisonCard/PlanComparisonCard.d.ts +64 -0
- package/lib/typescript/src/components/Slot/Slot.d.ts +52 -0
- package/lib/typescript/src/components/Stepper/Step.d.ts +4 -1
- package/lib/typescript/src/components/Stepper/StepLabel.d.ts +4 -1
- package/lib/typescript/src/components/Stepper/Stepper.d.ts +3 -1
- package/lib/typescript/src/components/SuggestiveSearch/SuggestiveSearch.d.ts +123 -0
- package/lib/typescript/src/components/index.d.ts +10 -3
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Accordion/Accordion.tsx +113 -73
- package/src/components/ActionFooter/ActionFooter.tsx +56 -4
- package/src/components/Attached/Attached.tsx +181 -0
- package/src/components/Card/Card.tsx +28 -1
- package/src/components/Checkbox/Checkbox.tsx +22 -9
- package/src/components/DropdownInput/DropdownInput.tsx +67 -39
- package/src/components/ExpandableCheckbox/ExpandableCheckbox.tsx +237 -0
- package/src/components/FormField/FormField.tsx +19 -3
- package/src/components/FullscreenModal/FullscreenModal.tsx +414 -0
- package/src/components/ListItem/ListItem.tsx +55 -25
- package/src/components/MessageField/MessageField.tsx +543 -0
- package/src/components/NavArrow/NavArrow.tsx +81 -17
- package/src/components/PlanComparisonCard/PlanComparisonCard.tsx +426 -0
- package/src/components/Slot/Slot.tsx +91 -0
- package/src/components/Stepper/Step.tsx +52 -51
- package/src/components/Stepper/StepLabel.tsx +46 -9
- package/src/components/Stepper/Stepper.tsx +20 -15
- package/src/components/SuggestiveSearch/SuggestiveSearch.tsx +756 -0
- package/src/components/TextInput/TextInput.tsx +14 -1
- package/src/components/Title/Title.tsx +13 -2
- package/src/components/index.ts +10 -3
- package/src/design-tokens/Coin Variables-variables-full.json +1 -1
- package/src/icons/registry.ts +1 -1
|
@@ -13,7 +13,6 @@ export default function Stepper({
|
|
|
13
13
|
modes = EMPTY_MODES,
|
|
14
14
|
style
|
|
15
15
|
}) {
|
|
16
|
-
// Stepper container styles
|
|
17
16
|
const paddingHorizontal = Number(getVariableByName('stepper/padding/horizontal', modes)) || 8;
|
|
18
17
|
const paddingVertical = Number(getVariableByName('stepper/padding/vertical', modes)) || 0;
|
|
19
18
|
const gap = Number(getVariableByName('stepper/gap', modes)) || 2;
|
|
@@ -23,25 +22,24 @@ export default function Stepper({
|
|
|
23
22
|
gap,
|
|
24
23
|
...style
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
// Inject index and connectorStyle logic into Step children
|
|
28
25
|
const steps = React.Children.toArray(children);
|
|
29
|
-
const
|
|
30
|
-
if (/*#__PURE__*/React.isValidElement(child))
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
const stepsWithProps = steps.map((child, stepIndex) => {
|
|
27
|
+
if (! /*#__PURE__*/React.isValidElement(child)) return child;
|
|
28
|
+
const isLast = stepIndex === steps.length - 1;
|
|
29
|
+
const childProps = child.props || {};
|
|
30
|
+
const childModes = childProps.modes ? {
|
|
31
|
+
...modes,
|
|
32
|
+
...childProps.modes
|
|
33
|
+
} : modes;
|
|
34
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
35
|
+
...childProps,
|
|
36
|
+
index: childProps.index ?? stepIndex,
|
|
37
|
+
modes: childModes,
|
|
38
|
+
showLine: childProps.showLine !== undefined ? childProps.showLine : !isLast
|
|
39
|
+
});
|
|
42
40
|
});
|
|
43
41
|
return /*#__PURE__*/_jsx(View, {
|
|
44
42
|
style: containerStyle,
|
|
45
|
-
children:
|
|
43
|
+
children: stepsWithProps
|
|
46
44
|
});
|
|
47
45
|
}
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { Platform, Pressable, Text, TextInput as RNTextInput, View } from 'react-native';
|
|
5
|
+
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
|
+
import { useTokens } from '../../design-tokens/JFSThemeProvider';
|
|
7
|
+
import { EMPTY_MODES } from '../../utils/react-utils';
|
|
8
|
+
import SupportText from '../SupportText/SupportText';
|
|
9
|
+
import Dropdown, { DropdownItem } from '../Dropdown/Dropdown';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
const IS_WEB = Platform.OS === 'web';
|
|
12
|
+
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Types
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Suggestions accept either a bare string (used as both value and label) or a
|
|
19
|
+
* full `{ value, label }` option object for richer data.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Helpers
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
function toNumber(value, fallback) {
|
|
27
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
28
|
+
if (typeof value === 'string') {
|
|
29
|
+
const parsed = parseFloat(value);
|
|
30
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
31
|
+
}
|
|
32
|
+
return fallback;
|
|
33
|
+
}
|
|
34
|
+
function normalizeItem(item) {
|
|
35
|
+
if (typeof item === 'string') return {
|
|
36
|
+
value: item,
|
|
37
|
+
label: item
|
|
38
|
+
};
|
|
39
|
+
return item;
|
|
40
|
+
}
|
|
41
|
+
const defaultFilter = (query, option) => option.label.toLowerCase().includes(query.toLowerCase());
|
|
42
|
+
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Token resolution
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
function useFormFieldTokens(modes) {
|
|
48
|
+
return useMemo(() => {
|
|
49
|
+
const labelColor = getVariableByName('formField/label/color', modes) || '#000000';
|
|
50
|
+
const labelFontFamily = getVariableByName('formField/label/fontFamily', modes) || 'JioType Var';
|
|
51
|
+
const labelFontSize = toNumber(getVariableByName('formField/label/fontSize', modes), 14);
|
|
52
|
+
const labelLineHeight = toNumber(getVariableByName('formField/label/lineHeight', modes), 17);
|
|
53
|
+
const labelFontWeight = getVariableByName('formField/label/fontWeight', modes) || '500';
|
|
54
|
+
const gap = toNumber(getVariableByName('formField/gap', modes), 8);
|
|
55
|
+
const inputPaddingH = toNumber(getVariableByName('formField/input/padding/horizontal', modes), 12);
|
|
56
|
+
const inputGap = toNumber(getVariableByName('formField/input/gap', modes), 8);
|
|
57
|
+
const inputRadius = toNumber(getVariableByName('formField/input/radius', modes), 8);
|
|
58
|
+
const inputBorderSize = toNumber(getVariableByName('formField/input/border/size', modes), 1.5);
|
|
59
|
+
const inputBackground = getVariableByName('formField/input/background', modes) || '#ffffff';
|
|
60
|
+
const inputBorderColor = getVariableByName('formField/input/border/color', modes) || '#b5b6b7';
|
|
61
|
+
const inputFontSize = toNumber(getVariableByName('formField/input/label/fontSize', modes), 16);
|
|
62
|
+
const inputLineHeight = toNumber(getVariableByName('formField/input/label/lineHeight', modes), 45);
|
|
63
|
+
const inputFontFamily = getVariableByName('formField/input/label/fontFamily', modes) || 'JioType Var';
|
|
64
|
+
const inputFontWeight = getVariableByName('formField/input/label/fontWeight', modes) || '400';
|
|
65
|
+
const inputTextColor = getVariableByName('formField/input/label/color', modes) || '#24262b';
|
|
66
|
+
return {
|
|
67
|
+
labelColor,
|
|
68
|
+
labelFontFamily,
|
|
69
|
+
labelFontSize,
|
|
70
|
+
labelLineHeight,
|
|
71
|
+
labelFontWeight,
|
|
72
|
+
gap,
|
|
73
|
+
inputPaddingH,
|
|
74
|
+
inputGap,
|
|
75
|
+
inputRadius,
|
|
76
|
+
inputBorderSize,
|
|
77
|
+
inputBackground,
|
|
78
|
+
inputBorderColor,
|
|
79
|
+
inputFontSize,
|
|
80
|
+
inputLineHeight,
|
|
81
|
+
inputFontFamily,
|
|
82
|
+
inputFontWeight,
|
|
83
|
+
inputTextColor
|
|
84
|
+
};
|
|
85
|
+
}, [modes]);
|
|
86
|
+
}
|
|
87
|
+
function useDropdownItemTextTokens(modes) {
|
|
88
|
+
return useMemo(() => {
|
|
89
|
+
const foreground = getVariableByName('dropdownItem/foreground', modes) || '#000000';
|
|
90
|
+
const fontFamily = getVariableByName('dropdownItem/fontFamily', modes) || 'JioType Var';
|
|
91
|
+
const fontSize = toNumber(getVariableByName('dropdownItem/fontSize', modes), 16);
|
|
92
|
+
const lineHeight = toNumber(getVariableByName('dropdownItem/lineHeight', modes), 19);
|
|
93
|
+
return {
|
|
94
|
+
foreground,
|
|
95
|
+
fontFamily,
|
|
96
|
+
fontSize,
|
|
97
|
+
lineHeight
|
|
98
|
+
};
|
|
99
|
+
}, [modes]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
// Component
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
|
|
106
|
+
function SuggestiveSearch({
|
|
107
|
+
label,
|
|
108
|
+
placeholder = 'Search',
|
|
109
|
+
items,
|
|
110
|
+
inputValue,
|
|
111
|
+
defaultInputValue = '',
|
|
112
|
+
onInputChange,
|
|
113
|
+
value,
|
|
114
|
+
defaultValue = null,
|
|
115
|
+
onValueChange,
|
|
116
|
+
filter = defaultFilter,
|
|
117
|
+
minChars = 1,
|
|
118
|
+
maxResults,
|
|
119
|
+
highlightMatch = true,
|
|
120
|
+
emptyMessage,
|
|
121
|
+
renderItem,
|
|
122
|
+
open,
|
|
123
|
+
defaultOpen = false,
|
|
124
|
+
onOpenChange,
|
|
125
|
+
menuMaxHeight = 240,
|
|
126
|
+
menuOffset = 6,
|
|
127
|
+
isRequired = false,
|
|
128
|
+
isDisabled = false,
|
|
129
|
+
isInvalid = false,
|
|
130
|
+
isReadOnly = false,
|
|
131
|
+
supportText,
|
|
132
|
+
errorMessage,
|
|
133
|
+
modes: propModes = EMPTY_MODES,
|
|
134
|
+
style,
|
|
135
|
+
inputStyle,
|
|
136
|
+
inputTextStyle,
|
|
137
|
+
menuStyle,
|
|
138
|
+
accessibilityLabel,
|
|
139
|
+
accessibilityHint,
|
|
140
|
+
onFocus,
|
|
141
|
+
onBlur,
|
|
142
|
+
testID
|
|
143
|
+
}) {
|
|
144
|
+
// ---------------- Modes ----------------
|
|
145
|
+
const {
|
|
146
|
+
modes: globalModes
|
|
147
|
+
} = useTokens();
|
|
148
|
+
const baseModes = useMemo(() => ({
|
|
149
|
+
...globalModes,
|
|
150
|
+
...propModes
|
|
151
|
+
}), [globalModes, propModes]);
|
|
152
|
+
const interactive = !isDisabled && !isReadOnly;
|
|
153
|
+
|
|
154
|
+
// ---------------- Query state ----------------
|
|
155
|
+
const isControlledInput = inputValue !== undefined;
|
|
156
|
+
const [internalInput, setInternalInput] = useState(defaultInputValue);
|
|
157
|
+
const query = isControlledInput ? inputValue : internalInput;
|
|
158
|
+
|
|
159
|
+
// ---------------- Selected value state ----------------
|
|
160
|
+
const isControlledValue = value !== undefined;
|
|
161
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
162
|
+
const currentValue = isControlledValue ? value : internalValue;
|
|
163
|
+
|
|
164
|
+
// ---------------- Open state ----------------
|
|
165
|
+
const isControlledOpen = open !== undefined;
|
|
166
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
167
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
168
|
+
const setOpenState = useCallback(next => {
|
|
169
|
+
if (!isControlledOpen) setInternalOpen(next);
|
|
170
|
+
onOpenChange?.(next);
|
|
171
|
+
}, [isControlledOpen, onOpenChange]);
|
|
172
|
+
|
|
173
|
+
// ---------------- Suggestions ----------------
|
|
174
|
+
const normalizedItems = useMemo(() => (items ?? []).map(normalizeItem), [items]);
|
|
175
|
+
const suggestions = useMemo(() => {
|
|
176
|
+
const trimmed = query.trim();
|
|
177
|
+
if (trimmed.length < minChars) return [];
|
|
178
|
+
const matched = normalizedItems.filter(opt => filter(query, opt));
|
|
179
|
+
return maxResults != null ? matched.slice(0, maxResults) : matched;
|
|
180
|
+
}, [normalizedItems, query, minChars, filter, maxResults]);
|
|
181
|
+
const hasSuggestions = suggestions.length > 0;
|
|
182
|
+
const showEmpty = Boolean(emptyMessage && query.trim().length >= minChars && !hasSuggestions);
|
|
183
|
+
const hasMenuContent = hasSuggestions || showEmpty;
|
|
184
|
+
|
|
185
|
+
// Resolved open state: an explicit `open` prop wins; otherwise the dropdown
|
|
186
|
+
// tracks the internal "wants suggestions" flag (set on focus / typing,
|
|
187
|
+
// cleared on blur / select). Blur and outside-press handle dismissal, so we
|
|
188
|
+
// intentionally do NOT gate on `isFocused` here — that would suppress
|
|
189
|
+
// `defaultOpen` on mount.
|
|
190
|
+
const isOpen = interactive && (isControlledOpen ? Boolean(open) : internalOpen) && hasMenuContent;
|
|
191
|
+
|
|
192
|
+
// ---------------- Token modes (state cascade) ----------------
|
|
193
|
+
const modes = useMemo(() => ({
|
|
194
|
+
...baseModes,
|
|
195
|
+
'FormField States': isInvalid ? 'Error' : isReadOnly || isDisabled ? 'Read Only' : isFocused ? 'Active' : baseModes['FormField States'] || 'Idle'
|
|
196
|
+
}), [baseModes, isInvalid, isReadOnly, isDisabled, isFocused]);
|
|
197
|
+
const tokens = useFormFieldTokens(modes);
|
|
198
|
+
const itemTextTokens = useDropdownItemTextTokens(modes);
|
|
199
|
+
|
|
200
|
+
// ---------------- Handlers ----------------
|
|
201
|
+
const inputRef = useRef(null);
|
|
202
|
+
const blurTimer = useRef(null);
|
|
203
|
+
const clearBlurTimer = useCallback(() => {
|
|
204
|
+
if (blurTimer.current) {
|
|
205
|
+
clearTimeout(blurTimer.current);
|
|
206
|
+
blurTimer.current = null;
|
|
207
|
+
}
|
|
208
|
+
}, []);
|
|
209
|
+
useEffect(() => () => clearBlurTimer(), [clearBlurTimer]);
|
|
210
|
+
const setQuery = useCallback(text => {
|
|
211
|
+
if (!isControlledInput) setInternalInput(text);
|
|
212
|
+
onInputChange?.(text);
|
|
213
|
+
}, [isControlledInput, onInputChange]);
|
|
214
|
+
const handleChangeText = useCallback(text => {
|
|
215
|
+
setQuery(text);
|
|
216
|
+
// Typing invalidates a prior selection unless the text still
|
|
217
|
+
// exactly matches the selected option's label.
|
|
218
|
+
if (currentValue != null) {
|
|
219
|
+
const selected = normalizedItems.find(o => o.value === currentValue);
|
|
220
|
+
if (!selected || selected.label !== text) {
|
|
221
|
+
if (!isControlledValue) setInternalValue(null);
|
|
222
|
+
onValueChange?.(null);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (!isControlledOpen) setInternalOpen(true);
|
|
226
|
+
}, [setQuery, currentValue, normalizedItems, isControlledValue, onValueChange, isControlledOpen]);
|
|
227
|
+
const handleSelect = useCallback(selectedValue => {
|
|
228
|
+
clearBlurTimer();
|
|
229
|
+
const option = normalizedItems.find(o => o.value === selectedValue);
|
|
230
|
+
if (!option || option.disabled) return;
|
|
231
|
+
setQuery(option.label);
|
|
232
|
+
if (!isControlledValue) setInternalValue(option.value);
|
|
233
|
+
onValueChange?.(option.value, option);
|
|
234
|
+
setOpenState(false);
|
|
235
|
+
inputRef.current?.blur();
|
|
236
|
+
}, [clearBlurTimer, normalizedItems, setQuery, isControlledValue, onValueChange, setOpenState]);
|
|
237
|
+
const handleFocus = useCallback(e => {
|
|
238
|
+
clearBlurTimer();
|
|
239
|
+
setIsFocused(true);
|
|
240
|
+
if (!isControlledOpen) setInternalOpen(true);
|
|
241
|
+
onFocus?.(e);
|
|
242
|
+
}, [clearBlurTimer, isControlledOpen, onFocus]);
|
|
243
|
+
const handleBlur = useCallback(e => {
|
|
244
|
+
// Delay closing so a suggestion press (which blurs the input first
|
|
245
|
+
// on web) still registers before the list unmounts.
|
|
246
|
+
clearBlurTimer();
|
|
247
|
+
blurTimer.current = setTimeout(() => {
|
|
248
|
+
setIsFocused(false);
|
|
249
|
+
if (!isControlledOpen) setInternalOpen(false);
|
|
250
|
+
}, 120);
|
|
251
|
+
onBlur?.(e);
|
|
252
|
+
}, [clearBlurTimer, isControlledOpen, onBlur]);
|
|
253
|
+
|
|
254
|
+
// ---------------- Web outside-press to close ----------------
|
|
255
|
+
const rootRef = useRef(null);
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
if (!IS_WEB || !isOpen) return;
|
|
258
|
+
const handler = e => {
|
|
259
|
+
const node = rootRef.current;
|
|
260
|
+
if (node?.contains && !node.contains(e.target)) {
|
|
261
|
+
clearBlurTimer();
|
|
262
|
+
setIsFocused(false);
|
|
263
|
+
if (!isControlledOpen) setInternalOpen(false);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
document.addEventListener('mousedown', handler);
|
|
267
|
+
return () => document.removeEventListener('mousedown', handler);
|
|
268
|
+
}, [isOpen, isControlledOpen, clearBlurTimer]);
|
|
269
|
+
|
|
270
|
+
// ---------------- Styles ----------------
|
|
271
|
+
const labelTextStyle = {
|
|
272
|
+
color: tokens.labelColor,
|
|
273
|
+
fontFamily: tokens.labelFontFamily,
|
|
274
|
+
fontSize: tokens.labelFontSize,
|
|
275
|
+
lineHeight: tokens.labelLineHeight,
|
|
276
|
+
fontWeight: tokens.labelFontWeight
|
|
277
|
+
};
|
|
278
|
+
const requiredIndicatorStyle = {
|
|
279
|
+
...labelTextStyle,
|
|
280
|
+
color: '#d93d3d'
|
|
281
|
+
};
|
|
282
|
+
const wrapperStyle = {
|
|
283
|
+
gap: tokens.gap,
|
|
284
|
+
opacity: isDisabled ? 0.5 : 1,
|
|
285
|
+
width: '100%',
|
|
286
|
+
position: 'relative',
|
|
287
|
+
// Keep the dropdown above sibling content when it overflows the field.
|
|
288
|
+
zIndex: isOpen ? 1000 : undefined
|
|
289
|
+
};
|
|
290
|
+
const inputRowStyle = {
|
|
291
|
+
flexDirection: 'row',
|
|
292
|
+
alignItems: 'center',
|
|
293
|
+
backgroundColor: tokens.inputBackground,
|
|
294
|
+
borderColor: tokens.inputBorderColor,
|
|
295
|
+
borderWidth: tokens.inputBorderSize,
|
|
296
|
+
borderStyle: 'solid',
|
|
297
|
+
borderRadius: tokens.inputRadius,
|
|
298
|
+
paddingHorizontal: tokens.inputPaddingH,
|
|
299
|
+
paddingVertical: 0,
|
|
300
|
+
gap: tokens.inputGap,
|
|
301
|
+
minHeight: tokens.inputLineHeight,
|
|
302
|
+
width: '100%'
|
|
303
|
+
};
|
|
304
|
+
const inputTextStyles = {
|
|
305
|
+
flex: 1,
|
|
306
|
+
color: tokens.inputTextColor,
|
|
307
|
+
fontFamily: tokens.inputFontFamily,
|
|
308
|
+
fontSize: tokens.inputFontSize,
|
|
309
|
+
lineHeight: tokens.inputLineHeight,
|
|
310
|
+
fontWeight: tokens.inputFontWeight,
|
|
311
|
+
padding: 0,
|
|
312
|
+
margin: 0,
|
|
313
|
+
...(IS_WEB ? {
|
|
314
|
+
outlineStyle: 'none',
|
|
315
|
+
outlineWidth: 0,
|
|
316
|
+
outlineColor: 'transparent'
|
|
317
|
+
} : {})
|
|
318
|
+
};
|
|
319
|
+
const placeholderColor = '#888a8d';
|
|
320
|
+
const itemBaseTextStyle = {
|
|
321
|
+
flex: 1,
|
|
322
|
+
color: itemTextTokens.foreground,
|
|
323
|
+
fontFamily: itemTextTokens.fontFamily,
|
|
324
|
+
fontSize: itemTextTokens.fontSize,
|
|
325
|
+
lineHeight: itemTextTokens.lineHeight,
|
|
326
|
+
fontWeight: '400'
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
// ---------------- Support text ----------------
|
|
330
|
+
const supportStatus = isInvalid ? 'Error' : 'Neutral';
|
|
331
|
+
const supportLabel = isInvalid && errorMessage ? errorMessage : supportText;
|
|
332
|
+
|
|
333
|
+
// ---------------- Accessibility ----------------
|
|
334
|
+
const resolvedA11yLabel = accessibilityLabel || label || placeholder || 'Search';
|
|
335
|
+
const a11yProps = {
|
|
336
|
+
accessibilityRole: IS_WEB ? undefined : 'search',
|
|
337
|
+
accessibilityLabel: resolvedA11yLabel,
|
|
338
|
+
accessibilityState: {
|
|
339
|
+
disabled: isDisabled,
|
|
340
|
+
expanded: isOpen
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
if (accessibilityHint) a11yProps.accessibilityHint = accessibilityHint;
|
|
344
|
+
|
|
345
|
+
// ---------------- Suggestion highlight ----------------
|
|
346
|
+
const renderHighlighted = useCallback(optLabel => {
|
|
347
|
+
const trimmed = query.trim();
|
|
348
|
+
if (!highlightMatch || trimmed.length === 0) {
|
|
349
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
350
|
+
style: itemBaseTextStyle,
|
|
351
|
+
children: optLabel
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
const idx = optLabel.toLowerCase().indexOf(trimmed.toLowerCase());
|
|
355
|
+
if (idx < 0) {
|
|
356
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
357
|
+
style: itemBaseTextStyle,
|
|
358
|
+
children: optLabel
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
const before = optLabel.slice(0, idx);
|
|
362
|
+
const match = optLabel.slice(idx, idx + trimmed.length);
|
|
363
|
+
const after = optLabel.slice(idx + trimmed.length);
|
|
364
|
+
return /*#__PURE__*/_jsxs(Text, {
|
|
365
|
+
style: itemBaseTextStyle,
|
|
366
|
+
children: [before, /*#__PURE__*/_jsx(Text, {
|
|
367
|
+
style: {
|
|
368
|
+
fontWeight: '700'
|
|
369
|
+
},
|
|
370
|
+
children: match
|
|
371
|
+
}), after]
|
|
372
|
+
});
|
|
373
|
+
}, [query, highlightMatch, itemBaseTextStyle]);
|
|
374
|
+
|
|
375
|
+
// ---------------- Render ----------------
|
|
376
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
377
|
+
ref: rootRef,
|
|
378
|
+
style: [wrapperStyle, style],
|
|
379
|
+
pointerEvents: isDisabled ? 'none' : 'auto',
|
|
380
|
+
testID: testID,
|
|
381
|
+
children: [label != null && /*#__PURE__*/_jsxs(View, {
|
|
382
|
+
style: styles.labelRow,
|
|
383
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
384
|
+
style: labelTextStyle,
|
|
385
|
+
children: label
|
|
386
|
+
}), isRequired && /*#__PURE__*/_jsx(Text, {
|
|
387
|
+
style: requiredIndicatorStyle,
|
|
388
|
+
children: " *"
|
|
389
|
+
})]
|
|
390
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
391
|
+
style: styles.anchor,
|
|
392
|
+
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
393
|
+
style: [inputRowStyle, inputStyle],
|
|
394
|
+
onPress: () => inputRef.current?.focus(),
|
|
395
|
+
accessible: false,
|
|
396
|
+
children: /*#__PURE__*/_jsx(RNTextInput, {
|
|
397
|
+
ref: inputRef,
|
|
398
|
+
style: [inputTextStyles, inputTextStyle],
|
|
399
|
+
value: query,
|
|
400
|
+
onChangeText: handleChangeText,
|
|
401
|
+
onFocus: handleFocus,
|
|
402
|
+
onBlur: handleBlur,
|
|
403
|
+
placeholder: placeholder,
|
|
404
|
+
placeholderTextColor: placeholderColor,
|
|
405
|
+
editable: interactive,
|
|
406
|
+
autoCapitalize: "none",
|
|
407
|
+
autoComplete: "off",
|
|
408
|
+
autoCorrect: false,
|
|
409
|
+
...a11yProps,
|
|
410
|
+
...(IS_WEB ? {
|
|
411
|
+
accessibilityRole: 'search',
|
|
412
|
+
'aria-autocomplete': 'list',
|
|
413
|
+
'aria-expanded': isOpen
|
|
414
|
+
} : {})
|
|
415
|
+
})
|
|
416
|
+
}), isOpen && /*#__PURE__*/_jsx(View, {
|
|
417
|
+
style: [styles.popup, {
|
|
418
|
+
top: '100%',
|
|
419
|
+
marginTop: menuOffset
|
|
420
|
+
}]
|
|
421
|
+
// Keep taps from dismissing the keyboard before the
|
|
422
|
+
// item's press handler runs on native.
|
|
423
|
+
,
|
|
424
|
+
children: /*#__PURE__*/_jsx(Dropdown, {
|
|
425
|
+
modes: modes,
|
|
426
|
+
maxHeight: menuMaxHeight,
|
|
427
|
+
style: menuStyle,
|
|
428
|
+
accessibilityLabel: `${resolvedA11yLabel} suggestions`,
|
|
429
|
+
children: hasSuggestions ? suggestions.map(opt => {
|
|
430
|
+
const isSelected = opt.value === currentValue;
|
|
431
|
+
return /*#__PURE__*/_jsx(DropdownItem, {
|
|
432
|
+
value: opt.value,
|
|
433
|
+
selected: isSelected,
|
|
434
|
+
disabled: opt.disabled ?? false,
|
|
435
|
+
onPress: handleSelect,
|
|
436
|
+
modes: modes,
|
|
437
|
+
children: renderItem ? renderItem(opt, {
|
|
438
|
+
query,
|
|
439
|
+
isSelected
|
|
440
|
+
}) : renderHighlighted(opt.label)
|
|
441
|
+
}, `sg-${opt.value}`);
|
|
442
|
+
}) : showEmpty && /*#__PURE__*/_jsx(View, {
|
|
443
|
+
style: styles.emptyRow,
|
|
444
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
445
|
+
style: [itemBaseTextStyle, {
|
|
446
|
+
color: placeholderColor
|
|
447
|
+
}],
|
|
448
|
+
children: emptyMessage
|
|
449
|
+
})
|
|
450
|
+
})
|
|
451
|
+
})
|
|
452
|
+
})]
|
|
453
|
+
}), supportLabel != null && supportLabel !== '' && /*#__PURE__*/_jsx(SupportText, {
|
|
454
|
+
label: supportLabel,
|
|
455
|
+
status: supportStatus,
|
|
456
|
+
modes: modes
|
|
457
|
+
})]
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
const styles = {
|
|
461
|
+
labelRow: {
|
|
462
|
+
flexDirection: 'row',
|
|
463
|
+
alignItems: 'baseline'
|
|
464
|
+
},
|
|
465
|
+
anchor: {
|
|
466
|
+
position: 'relative',
|
|
467
|
+
width: '100%',
|
|
468
|
+
zIndex: 1
|
|
469
|
+
},
|
|
470
|
+
popup: {
|
|
471
|
+
position: 'absolute',
|
|
472
|
+
left: 0,
|
|
473
|
+
right: 0,
|
|
474
|
+
zIndex: 1000
|
|
475
|
+
},
|
|
476
|
+
emptyRow: {
|
|
477
|
+
paddingHorizontal: 12,
|
|
478
|
+
paddingVertical: 12
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
export default SuggestiveSearch;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { useState } from 'react';
|
|
3
|
+
import React, { useRef, useState } from 'react';
|
|
4
4
|
import { Pressable, View, TextInput as RNTextInput } from 'react-native';
|
|
5
5
|
import { getVariableByName } from '../../design-tokens/figma-variables-resolver';
|
|
6
6
|
import Icon from '../../icons/Icon';
|
|
@@ -114,6 +114,11 @@ function TextInput({
|
|
|
114
114
|
// Track focus state to hide placeholder when focused
|
|
115
115
|
const [isFocused, setIsFocused] = useState(false);
|
|
116
116
|
const [isHovered, setIsHovered] = useState(false);
|
|
117
|
+
// Ref to the underlying native input so a tap anywhere inside the Pressable
|
|
118
|
+
// wrapper can programmatically focus it. Without this, on Android the
|
|
119
|
+
// wrapping Pressable becomes the touch responder on the first tap and the
|
|
120
|
+
// native input only gains focus on the *second* tap.
|
|
121
|
+
const inputRef = useRef(null);
|
|
117
122
|
|
|
118
123
|
// Resolve container tokens
|
|
119
124
|
const backgroundColor = getVariableByName('textInput/background', modes) || '#f5f5f5';
|
|
@@ -207,12 +212,22 @@ function TextInput({
|
|
|
207
212
|
return /*#__PURE__*/_jsxs(Pressable, {
|
|
208
213
|
style: [containerStyle, focusContainerStyle, hoverStyle, style],
|
|
209
214
|
onHoverIn: () => setIsHovered(true),
|
|
210
|
-
onHoverOut: () => setIsHovered(false)
|
|
215
|
+
onHoverOut: () => setIsHovered(false)
|
|
216
|
+
// Forward taps on the wrapper (padding, leading icon gutter, etc.) to the
|
|
217
|
+
// native input. This guarantees the keyboard opens on the FIRST tap on
|
|
218
|
+
// Android instead of requiring a second tap.
|
|
219
|
+
,
|
|
220
|
+
onPress: () => inputRef.current?.focus()
|
|
221
|
+
// The native input is the real accessible element; don't add a redundant
|
|
222
|
+
// focusable node for screen readers.
|
|
223
|
+
,
|
|
224
|
+
accessible: false,
|
|
211
225
|
children: [processedLeading && /*#__PURE__*/_jsx(View, {
|
|
212
226
|
accessibilityElementsHidden: true,
|
|
213
227
|
importantForAccessibility: "no",
|
|
214
228
|
children: processedLeading
|
|
215
229
|
}), /*#__PURE__*/_jsx(RNTextInput, {
|
|
230
|
+
ref: inputRef,
|
|
216
231
|
accessibilityLabel: undefined,
|
|
217
232
|
accessibilityHint: accessibilityHint,
|
|
218
233
|
placeholder: displayPlaceholder,
|
|
@@ -35,13 +35,21 @@ function Title({
|
|
|
35
35
|
const gap = getVariableByName('title/gap', modes) || 8;
|
|
36
36
|
const labelColor = getVariableByName('title/label/color', modes) || '#0d0d0f';
|
|
37
37
|
const fontSize = getVariableByName('title/fontSize', modes) || 26;
|
|
38
|
-
const
|
|
38
|
+
const rawLineHeight = getVariableByName('title/lineHeight', modes) || 26;
|
|
39
|
+
// The Figma title tokens ship with `lineHeight === fontSize` (26/26). On
|
|
40
|
+
// native (especially Android) that produces a Text box exactly `lineHeight`
|
|
41
|
+
// tall, which clips descenders like p/g/y/q/j at the bottom — particularly
|
|
42
|
+
// noticeable with `numberOfLines={1}`. Clamp to ~1.2x fontSize so descenders
|
|
43
|
+
// always fit. When a downstream token already provides adequate leading,
|
|
44
|
+
// the original value is preserved.
|
|
45
|
+
const lineHeight = Math.max(rawLineHeight, Math.ceil(fontSize * 1.2));
|
|
39
46
|
const fontFamily = getVariableByName('title/fontFamily', modes) || 'System';
|
|
40
47
|
const fontWeightRaw = getVariableByName('title/fontWeight', modes) || 900;
|
|
41
48
|
const fontWeight = typeof fontWeightRaw === 'number' ? fontWeightRaw.toString() : fontWeightRaw;
|
|
42
49
|
const subtitleColor = getVariableByName('pageSubtitle/label/color', modes) || '#0d0d0f';
|
|
43
50
|
const subtitleFontSize = getVariableByName('pageSubtitle/fontSize', modes) || 14;
|
|
44
|
-
const
|
|
51
|
+
const subtitleRawLineHeight = getVariableByName('pageSubtitle/lineHeight', modes) || 18;
|
|
52
|
+
const subtitleLineHeight = Math.max(subtitleRawLineHeight, Math.ceil(subtitleFontSize * 1.2));
|
|
45
53
|
const subtitleFontFamily = getVariableByName('pageSubtitle/fontFamily', modes) || 'System';
|
|
46
54
|
const subtitleFontWeightRaw = getVariableByName('pageSubtitle/fontWeight', modes) || 500;
|
|
47
55
|
const subtitleFontWeight = typeof subtitleFontWeightRaw === 'number' ? subtitleFontWeightRaw.toString() : subtitleFontWeightRaw;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
export { default as AccountCard } from './AccountCard/AccountCard';
|
|
4
4
|
export { default as ActionFooter } from './ActionFooter/ActionFooter';
|
|
5
|
+
export { default as Attached } from './Attached/Attached';
|
|
5
6
|
export { default as AppBar } from './AppBar/AppBar';
|
|
6
7
|
export { default as Avatar } from './Avatar/Avatar';
|
|
7
8
|
export { default as AvatarGroup } from './AvatarGroup/AvatarGroup';
|
|
@@ -25,9 +26,11 @@ export { default as Divider } from './Divider/Divider';
|
|
|
25
26
|
export { default as Drawer } from './Drawer/Drawer';
|
|
26
27
|
export { default as Dropdown, DropdownItem } from './Dropdown/Dropdown';
|
|
27
28
|
export { default as DropdownInput } from './DropdownInput/DropdownInput';
|
|
29
|
+
export { default as SuggestiveSearch } from './SuggestiveSearch/SuggestiveSearch';
|
|
28
30
|
export { default as CardCTA } from './CardCTA/CardCTA';
|
|
29
31
|
export { default as DebitCard } from './DebitCard/DebitCard';
|
|
30
32
|
export { default as FilterBar } from './FilterBar/FilterBar';
|
|
33
|
+
export { default as FullscreenModal } from './FullscreenModal/FullscreenModal';
|
|
31
34
|
export { default as Form } from './Form/Form';
|
|
32
35
|
export { useFormContext } from './Form/Form';
|
|
33
36
|
export { default as FormField } from './FormField/FormField';
|
|
@@ -52,6 +55,7 @@ export { default as LottiePlayer } from './LottiePlayer/LottiePlayer';
|
|
|
52
55
|
export { default as ListItem } from './ListItem/ListItem';
|
|
53
56
|
export { default as MediaCard } from './MediaCard/MediaCard';
|
|
54
57
|
export { default as MerchantProfile } from './MerchantProfile/MerchantProfile';
|
|
58
|
+
export { default as MessageField } from './MessageField/MessageField';
|
|
55
59
|
export { default as MetricLegendItem } from './MetricLegendItem/MetricLegendItem';
|
|
56
60
|
export { default as MoneyValue } from './MoneyValue/MoneyValue';
|
|
57
61
|
export { default as NoteInput } from './NoteInput/NoteInput';
|
|
@@ -61,6 +65,7 @@ export { default as Numpad } from './Numpad/Numpad';
|
|
|
61
65
|
export { default as Title } from './Title/Title';
|
|
62
66
|
export { default as Screen } from './Screen/Screen';
|
|
63
67
|
export { default as Section } from './Section/Section';
|
|
68
|
+
export { default as Slot } from './Slot/Slot';
|
|
64
69
|
export { default as Stepper } from './Stepper/Stepper';
|
|
65
70
|
export { Step } from './Stepper/Step';
|
|
66
71
|
export { StepLabel } from './Stepper/StepLabel';
|
|
@@ -75,6 +80,7 @@ export { default as UpiHandle } from './UpiHandle/UpiHandle';
|
|
|
75
80
|
export { default as VStack } from './VStack/VStack';
|
|
76
81
|
export { default as ChipGroup } from './ChipGroup/ChipGroup';
|
|
77
82
|
export { default as EmptyState } from './EmptyState/EmptyState';
|
|
83
|
+
export { default as ExpandableCheckbox } from './ExpandableCheckbox/ExpandableCheckbox';
|
|
78
84
|
export { default as Accordion } from './Accordion/Accordion';
|
|
79
85
|
export { default as AccordionCheckbox } from './AccordionCheckbox/AccordionCheckbox';
|
|
80
86
|
export { default as ActionTile } from './ActionTile/ActionTile';
|
|
@@ -107,6 +113,7 @@ export { default as AmountInput } from './AmountInput/AmountInput';
|
|
|
107
113
|
export { default as PageHero } from './PageHero/PageHero';
|
|
108
114
|
export { default as Popup } from './Popup/Popup';
|
|
109
115
|
export { default as PortfolioHero } from './PortfolioHero/PortfolioHero';
|
|
116
|
+
export { default as PlanComparisonCard } from './PlanComparisonCard/PlanComparisonCard';
|
|
110
117
|
export { default as PoweredByLabel } from './PoweredByLabel/PoweredByLabel';
|
|
111
118
|
export { default as ProductLabel } from './ProductLabel/ProductLabel';
|
|
112
119
|
export { default as ProductOverview } from './ProductOverview/ProductOverview';
|