jfs-components 0.0.43 → 0.0.45
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/AmountInput/AmountInput.js +82 -0
- package/lib/commonjs/components/AmountInput/index.js +13 -0
- package/lib/commonjs/components/Button/Button.js +45 -28
- package/lib/commonjs/components/CardProviderInfo/CardProviderInfo.js +76 -0
- package/lib/commonjs/components/Checkbox/Checkbox.js +208 -0
- package/lib/commonjs/components/EmptyState/EmptyState.js +2 -1
- package/lib/commonjs/components/MoneyValue/MoneyValue.js +81 -49
- package/lib/commonjs/components/NoteInput/NoteInput.js +120 -0
- package/lib/commonjs/components/NoteInput/index.js +13 -0
- package/lib/commonjs/components/Numpad/Numpad.js +108 -0
- package/lib/commonjs/components/OTP/OTP.js +242 -0
- package/lib/commonjs/components/PortfolioHero/PortfolioHero.js +78 -0
- package/lib/commonjs/components/ProductLabel/ProductLabel.js +50 -0
- package/lib/commonjs/components/ProgressBadge/ProgressBadge.js +130 -0
- package/lib/commonjs/components/ProgressBadge/index.js +25 -0
- package/lib/commonjs/components/StatItem/StatItem.js +61 -0
- package/lib/commonjs/components/StatusHero/StatusHero.js +148 -0
- package/lib/commonjs/components/SwappableAmount/SwappableAmount.js +71 -0
- package/lib/commonjs/components/Tabs/TabItem.js +79 -0
- package/lib/commonjs/components/Tabs/Tabs.js +88 -0
- package/lib/commonjs/components/Text/Text.js +38 -0
- package/lib/commonjs/components/Toggle/Toggle.js +102 -0
- package/lib/commonjs/components/index.js +105 -0
- package/lib/commonjs/design-tokens/Coin Variables-variables-full.json +1 -0
- package/lib/commonjs/design-tokens/figma-variables-resolver.js +1 -1
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/AmountInput/AmountInput.js +77 -0
- package/lib/module/components/AmountInput/index.js +3 -0
- package/lib/module/components/Button/Button.js +44 -28
- package/lib/module/components/CardProviderInfo/CardProviderInfo.js +71 -0
- package/lib/module/components/Checkbox/Checkbox.js +205 -0
- package/lib/module/components/EmptyState/EmptyState.js +2 -1
- package/lib/module/components/MoneyValue/MoneyValue.js +81 -49
- package/lib/module/components/NoteInput/NoteInput.js +115 -0
- package/lib/module/components/NoteInput/index.js +3 -0
- package/lib/module/components/Numpad/Numpad.js +103 -0
- package/lib/module/components/OTP/OTP.js +236 -0
- package/lib/module/components/PortfolioHero/PortfolioHero.js +73 -0
- package/lib/module/components/ProductLabel/ProductLabel.js +45 -0
- package/lib/module/components/ProgressBadge/ProgressBadge.js +125 -0
- package/lib/module/components/ProgressBadge/index.js +4 -0
- package/lib/module/components/StatItem/StatItem.js +56 -0
- package/lib/module/components/StatusHero/StatusHero.js +142 -0
- package/lib/module/components/SwappableAmount/SwappableAmount.js +66 -0
- package/lib/module/components/Tabs/TabItem.js +74 -0
- package/lib/module/components/Tabs/Tabs.js +78 -0
- package/lib/module/components/Text/Text.js +33 -0
- package/lib/module/components/Toggle/Toggle.js +97 -0
- package/lib/module/components/index.js +16 -1
- package/lib/module/design-tokens/Coin Variables-variables-full.json +1 -0
- package/lib/module/design-tokens/figma-variables-resolver.js +1 -1
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/src/components/AmountInput/AmountInput.d.ts +23 -0
- package/lib/typescript/src/components/AmountInput/index.d.ts +3 -0
- package/lib/typescript/src/components/Button/Button.d.ts +6 -1
- package/lib/typescript/src/components/CardProviderInfo/CardProviderInfo.d.ts +24 -0
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +30 -0
- package/lib/typescript/src/components/EmptyState/EmptyState.d.ts +6 -1
- package/lib/typescript/src/components/MoneyValue/MoneyValue.d.ts +18 -26
- package/lib/typescript/src/components/NoteInput/NoteInput.d.ts +23 -0
- package/lib/typescript/src/components/NoteInput/index.d.ts +3 -0
- package/lib/typescript/src/components/Numpad/Numpad.d.ts +35 -0
- package/lib/typescript/src/components/OTP/OTP.d.ts +36 -0
- package/lib/typescript/src/components/PortfolioHero/PortfolioHero.d.ts +21 -0
- package/lib/typescript/src/components/ProductLabel/ProductLabel.d.ts +14 -0
- package/lib/typescript/src/components/ProgressBadge/ProgressBadge.d.ts +36 -0
- package/lib/typescript/src/components/ProgressBadge/index.d.ts +3 -0
- package/lib/typescript/src/components/StatItem/StatItem.d.ts +21 -0
- package/lib/typescript/src/components/StatusHero/StatusHero.d.ts +47 -0
- package/lib/typescript/src/components/SwappableAmount/SwappableAmount.d.ts +22 -0
- package/lib/typescript/src/components/Tabs/TabItem.d.ts +29 -0
- package/lib/typescript/src/components/Tabs/Tabs.d.ts +44 -0
- package/lib/typescript/src/components/Text/Text.d.ts +14 -0
- package/lib/typescript/src/components/Toggle/Toggle.d.ts +29 -0
- package/lib/typescript/src/components/index.d.ts +15 -0
- package/lib/typescript/src/icons/registry.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/AmountInput/AmountInput.tsx +81 -0
- package/src/components/AmountInput/index.ts +2 -0
- package/src/components/Button/Button.tsx +40 -20
- package/src/components/CardProviderInfo/CardProviderInfo.tsx +81 -0
- package/src/components/Checkbox/Checkbox.tsx +238 -0
- package/src/components/EmptyState/EmptyState.tsx +7 -1
- package/src/components/MoneyValue/MoneyValue.tsx +134 -79
- package/src/components/NoteInput/NoteInput.tsx +146 -0
- package/src/components/NoteInput/index.ts +2 -0
- package/src/components/Numpad/Numpad.tsx +162 -0
- package/src/components/OTP/OTP.tsx +275 -0
- package/src/components/PortfolioHero/PortfolioHero.tsx +91 -0
- package/src/components/ProductLabel/ProductLabel.tsx +58 -0
- package/src/components/ProgressBadge/ProgressBadge.tsx +172 -0
- package/src/components/ProgressBadge/index.ts +2 -0
- package/src/components/StatItem/StatItem.tsx +71 -0
- package/src/components/StatusHero/StatusHero.tsx +156 -0
- package/src/components/SwappableAmount/SwappableAmount.tsx +92 -0
- package/src/components/Tabs/TabItem.tsx +96 -0
- package/src/components/Tabs/Tabs.tsx +105 -0
- package/src/components/Text/Text.tsx +48 -0
- package/src/components/Toggle/Toggle.tsx +122 -0
- package/src/components/index.ts +15 -0
- package/src/design-tokens/Coin Variables-variables-full.json +1 -0
- package/src/design-tokens/figma-variables-resolver.ts +1 -1
- package/src/icons/registry.ts +1 -1
- package/lib/commonjs/design-tokens/JFS Variables-variables-full.json +0 -1
- package/lib/module/design-tokens/JFS Variables-variables-full.json +0 -1
- package/src/design-tokens/JFS Variables-variables-full.json +0 -1
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
function
|
|
11
|
+
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); }
|
|
12
12
|
// Map of common ISO 4217 currency codes to display symbols
|
|
13
13
|
const CURRENCY_SYMBOLS = {
|
|
14
14
|
INR: '₹',
|
|
@@ -46,34 +46,20 @@ const CURRENCY_SYMBOLS = {
|
|
|
46
46
|
/**
|
|
47
47
|
* MoneyValue component that mirrors the Figma MoneyValue design.
|
|
48
48
|
*
|
|
49
|
-
* The styling is fully resolved from Figma design tokens using `getVariableByName
|
|
50
|
-
*
|
|
49
|
+
* The styling is fully resolved from Figma design tokens using `getVariableByName`.
|
|
50
|
+
* Supports separate typography scaling for currency and value.
|
|
51
51
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* Negative values are auto-detected from the value prop (e.g., -500 or "-500").
|
|
57
|
-
* The `negative` prop can be used to explicitly override this behavior.
|
|
58
|
-
*
|
|
59
|
-
* @component
|
|
60
|
-
* @param {Object} props
|
|
61
|
-
* @param {string|number} [props.value="500"] - Monetary value to display. Negative values are auto-detected.
|
|
62
|
-
* @param {string} [props.currency="₹"] - Currency symbol or ISO code (e.g. "INR").
|
|
63
|
-
* @param {boolean} [props.negative] - Explicitly override negative display. If undefined, auto-detects from value.
|
|
64
|
-
* @param {Object} [props.modes={}] - Modes object passed directly to `getVariableByName`.
|
|
65
|
-
* Example: {"MoneyValue / Theme": "Default"}
|
|
66
|
-
* @param {Object} [props.style] - Optional container style overrides.
|
|
67
|
-
* @param {Object} [props.valueStyle] - Optional value text style overrides.
|
|
68
|
-
* @param {Object} [props.currencyStyle] - Optional currency text style overrides.
|
|
69
|
-
* @param {Object} [props.negativeSignStyle] - Optional negative sign text style overrides.
|
|
70
|
-
* @param {string} [props.accessibilityLabel] - Accessibility label for screen readers. If not provided, generates from value and currency
|
|
71
|
-
* @param {string} [props.accessibilityHint] - Additional accessibility hint for screen readers
|
|
52
|
+
* To make this component editable without coupling it to a Numpad component,
|
|
53
|
+
* use the `onPress` prop and manage the data state in the parent layer. When
|
|
54
|
+
* the `focused` prop is provided to this component, it will display a natural
|
|
55
|
+
* blinking text cursor.
|
|
72
56
|
*/
|
|
73
57
|
function MoneyValue({
|
|
74
58
|
value = '500',
|
|
75
59
|
currency = '₹',
|
|
76
60
|
negative,
|
|
61
|
+
focused = false,
|
|
62
|
+
hidden = false,
|
|
77
63
|
modes = {},
|
|
78
64
|
style,
|
|
79
65
|
valueStyle,
|
|
@@ -81,13 +67,14 @@ function MoneyValue({
|
|
|
81
67
|
negativeSignStyle,
|
|
82
68
|
accessibilityLabel,
|
|
83
69
|
accessibilityHint,
|
|
70
|
+
onPress,
|
|
84
71
|
...rest
|
|
85
72
|
}) {
|
|
86
73
|
// Auto-detect negative from value and compute display value
|
|
87
74
|
const {
|
|
88
75
|
isNegative,
|
|
89
76
|
displayValue
|
|
90
|
-
} = _react.
|
|
77
|
+
} = (0, _react.useMemo)(() => {
|
|
91
78
|
const stringValue = String(value);
|
|
92
79
|
const trimmed = stringValue.trim();
|
|
93
80
|
const valueIsNegative = trimmed.startsWith('-') || typeof value === 'number' && value < 0;
|
|
@@ -98,62 +85,107 @@ function MoneyValue({
|
|
|
98
85
|
// Use explicit negative prop if provided, otherwise use auto-detected
|
|
99
86
|
const showNegative = negative !== undefined ? negative : valueIsNegative;
|
|
100
87
|
return {
|
|
101
|
-
isNegative: showNegative,
|
|
102
|
-
displayValue: absoluteValue
|
|
88
|
+
isNegative: hidden ? false : showNegative,
|
|
89
|
+
displayValue: hidden ? '•••' : absoluteValue
|
|
103
90
|
};
|
|
104
|
-
}, [value, negative]);
|
|
91
|
+
}, [value, negative, hidden]);
|
|
105
92
|
|
|
106
93
|
// Resolve typography and layout tokens from Figma
|
|
107
94
|
const textColor = (0, _figmaVariablesResolver.getVariableByName)('moneyValue/text/color', modes) || '#0f0d0a';
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const
|
|
95
|
+
const currencyFontSize = (0, _figmaVariablesResolver.getVariableByName)('moneyValue/currency/fontSize', modes) || 14;
|
|
96
|
+
const currencyLineHeight = (0, _figmaVariablesResolver.getVariableByName)('moneyValue/currency/lineHeight', modes) || 18;
|
|
97
|
+
const valueFontSize = (0, _figmaVariablesResolver.getVariableByName)('moneyValue/value/fontSize', modes) || 14;
|
|
98
|
+
const valueLineHeight = (0, _figmaVariablesResolver.getVariableByName)('moneyValue/value/lineHeight', modes) || 18;
|
|
99
|
+
const fontWeightValue = (0, _figmaVariablesResolver.getVariableByName)('moneyValue/fontWeight', modes) || 500;
|
|
111
100
|
const fontWeight = typeof fontWeightValue === 'number' ? fontWeightValue.toString() : fontWeightValue;
|
|
112
|
-
const fontFamily = (0, _figmaVariablesResolver.getVariableByName)('moneyValue/
|
|
101
|
+
const fontFamily = (0, _figmaVariablesResolver.getVariableByName)('moneyValue/fontFamily', modes) || 'System';
|
|
113
102
|
const gap = (0, _figmaVariablesResolver.getVariableByName)('moneyValue/gap', modes) || 4;
|
|
114
103
|
|
|
115
104
|
// Resolve currency to a symbol, supporting both symbols and ISO codes
|
|
116
|
-
const resolvedCurrency = _react.
|
|
105
|
+
const resolvedCurrency = (0, _react.useMemo)(() => {
|
|
117
106
|
if (!currency) return '';
|
|
118
107
|
const upper = currency.toUpperCase ? currency.toUpperCase() : currency;
|
|
119
108
|
return upper in CURRENCY_SYMBOLS ? CURRENCY_SYMBOLS[upper] : currency;
|
|
120
109
|
}, [currency]);
|
|
121
|
-
const
|
|
110
|
+
const currencyTextStyle = {
|
|
111
|
+
color: textColor,
|
|
112
|
+
fontSize: currencyFontSize,
|
|
113
|
+
lineHeight: currencyLineHeight,
|
|
114
|
+
fontWeight: fontWeight,
|
|
115
|
+
fontFamily: fontFamily
|
|
116
|
+
};
|
|
117
|
+
const valueTextStyle = {
|
|
122
118
|
color: textColor,
|
|
123
|
-
fontSize,
|
|
124
|
-
lineHeight,
|
|
125
|
-
fontWeight,
|
|
126
|
-
fontFamily
|
|
119
|
+
fontSize: valueFontSize,
|
|
120
|
+
lineHeight: valueLineHeight,
|
|
121
|
+
fontWeight: fontWeight,
|
|
122
|
+
fontFamily: fontFamily
|
|
127
123
|
};
|
|
128
124
|
const containerStyle = {
|
|
129
125
|
flexDirection: 'row',
|
|
130
126
|
alignItems: 'center',
|
|
131
|
-
gap
|
|
127
|
+
gap: gap
|
|
132
128
|
};
|
|
133
129
|
|
|
134
|
-
//
|
|
135
|
-
const
|
|
136
|
-
|
|
130
|
+
// Blinking cursor animation
|
|
131
|
+
const cursorOpacity = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
|
|
132
|
+
(0, _react.useEffect)(() => {
|
|
133
|
+
if (focused) {
|
|
134
|
+
const animation = _reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(cursorOpacity, {
|
|
135
|
+
toValue: 1,
|
|
136
|
+
duration: 400,
|
|
137
|
+
useNativeDriver: true
|
|
138
|
+
}), _reactNative.Animated.timing(cursorOpacity, {
|
|
139
|
+
toValue: 0,
|
|
140
|
+
duration: 400,
|
|
141
|
+
useNativeDriver: true
|
|
142
|
+
})]));
|
|
143
|
+
animation.start();
|
|
144
|
+
return () => {
|
|
145
|
+
animation.stop();
|
|
146
|
+
cursorOpacity.setValue(0);
|
|
147
|
+
};
|
|
148
|
+
} else {
|
|
149
|
+
cursorOpacity.setValue(0);
|
|
150
|
+
}
|
|
151
|
+
}, [focused, cursorOpacity]);
|
|
152
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
137
153
|
style: [containerStyle, style],
|
|
138
154
|
accessibilityRole: "text",
|
|
139
155
|
accessibilityLabel: undefined,
|
|
140
156
|
accessibilityHint: accessibilityHint,
|
|
157
|
+
onPress: onPress,
|
|
158
|
+
disabled: !onPress,
|
|
141
159
|
...rest,
|
|
142
160
|
children: [isNegative && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
143
|
-
style: [
|
|
161
|
+
style: [currencyTextStyle, negativeSignStyle],
|
|
144
162
|
accessibilityElementsHidden: true,
|
|
145
163
|
importantForAccessibility: "no",
|
|
146
164
|
children: "-"
|
|
147
165
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
148
|
-
style: [
|
|
166
|
+
style: [currencyTextStyle, currencyStyle],
|
|
149
167
|
accessibilityElementsHidden: true,
|
|
150
168
|
importantForAccessibility: "no",
|
|
151
169
|
children: resolvedCurrency
|
|
152
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
153
|
-
style:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
170
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
171
|
+
style: {
|
|
172
|
+
flexDirection: 'row',
|
|
173
|
+
alignItems: 'center'
|
|
174
|
+
},
|
|
175
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
176
|
+
style: [valueTextStyle, valueStyle],
|
|
177
|
+
accessibilityElementsHidden: true,
|
|
178
|
+
importantForAccessibility: "no",
|
|
179
|
+
children: displayValue
|
|
180
|
+
}), focused && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
181
|
+
style: {
|
|
182
|
+
opacity: cursorOpacity,
|
|
183
|
+
width: 2,
|
|
184
|
+
height: valueFontSize * 1.1,
|
|
185
|
+
backgroundColor: textColor,
|
|
186
|
+
marginLeft: 2
|
|
187
|
+
}
|
|
188
|
+
})]
|
|
157
189
|
})]
|
|
158
190
|
});
|
|
159
191
|
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = NoteInput;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
|
|
10
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
+
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); }
|
|
12
|
+
/**
|
|
13
|
+
* NoteInput component representing an interactive "Add note" badge style field.
|
|
14
|
+
* Allows the user to click, clears the placeholder text, and shows a blinking cursor when focused.
|
|
15
|
+
*/
|
|
16
|
+
function NoteInput({
|
|
17
|
+
value = '',
|
|
18
|
+
placeholder = 'Add note',
|
|
19
|
+
onChangeText,
|
|
20
|
+
modes = {},
|
|
21
|
+
style,
|
|
22
|
+
textStyle,
|
|
23
|
+
state: explicitState,
|
|
24
|
+
onFocus,
|
|
25
|
+
onBlur,
|
|
26
|
+
...rest
|
|
27
|
+
}) {
|
|
28
|
+
const [internalFocused, setInternalFocused] = (0, _react.useState)(false);
|
|
29
|
+
const inputRef = (0, _react.useRef)(null);
|
|
30
|
+
|
|
31
|
+
// Resolve tokens from Figma Design
|
|
32
|
+
const foreground = (0, _figmaVariablesResolver.getVariableByName)('noteInput/foreground', modes) || '#0d0d0f';
|
|
33
|
+
const fontSize = (0, _figmaVariablesResolver.getVariableByName)('noteInput/fontSize', modes) || 14;
|
|
34
|
+
const fontFamily = (0, _figmaVariablesResolver.getVariableByName)('noteInput/fontFamily', modes) || 'JioType Var';
|
|
35
|
+
const lineHeight = (0, _figmaVariablesResolver.getVariableByName)('noteInput/lineHeight', modes) || 16;
|
|
36
|
+
const fontWeightRaw = (0, _figmaVariablesResolver.getVariableByName)('noteInput/fontWeight', modes) || 700;
|
|
37
|
+
const fontWeight = typeof fontWeightRaw === 'number' ? fontWeightRaw.toString() : fontWeightRaw;
|
|
38
|
+
const gap = (0, _figmaVariablesResolver.getVariableByName)('noteInput/gap', modes) || 0; // 4 in some files, 0 in context
|
|
39
|
+
const paddingHorizontal = (0, _figmaVariablesResolver.getVariableByName)('noteInput/padding/horizontal', modes) || 17;
|
|
40
|
+
const paddingVertical = (0, _figmaVariablesResolver.getVariableByName)('noteInput/padding/vertical', modes) || 9;
|
|
41
|
+
const radius = (0, _figmaVariablesResolver.getVariableByName)('noteInput/radius', modes) || 999;
|
|
42
|
+
const borderSize = (0, _figmaVariablesResolver.getVariableByName)('noteInput/border/size', modes) || 1;
|
|
43
|
+
const background = (0, _figmaVariablesResolver.getVariableByName)('noteInput/background', modes) || '#ebebed';
|
|
44
|
+
const borderColor = (0, _figmaVariablesResolver.getVariableByName)('noteInput/border/color', modes) || 'rgba(255,255,255,0)';
|
|
45
|
+
const containerStyle = {
|
|
46
|
+
flexDirection: 'row',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
justifyContent: 'center',
|
|
49
|
+
paddingHorizontal: paddingHorizontal,
|
|
50
|
+
paddingVertical: paddingVertical,
|
|
51
|
+
borderRadius: radius,
|
|
52
|
+
backgroundColor: background,
|
|
53
|
+
borderWidth: borderSize,
|
|
54
|
+
borderColor: borderColor,
|
|
55
|
+
gap: gap,
|
|
56
|
+
// Add specific width when editing if requested by Figma design logic, though flex fits content generically
|
|
57
|
+
alignSelf: 'flex-start'
|
|
58
|
+
};
|
|
59
|
+
const baseTextStyle = {
|
|
60
|
+
color: foreground,
|
|
61
|
+
fontSize: fontSize,
|
|
62
|
+
fontFamily: fontFamily,
|
|
63
|
+
lineHeight: lineHeight,
|
|
64
|
+
fontWeight: fontWeight,
|
|
65
|
+
padding: 0,
|
|
66
|
+
margin: 0,
|
|
67
|
+
minHeight: lineHeight
|
|
68
|
+
};
|
|
69
|
+
const handleFocus = e => {
|
|
70
|
+
setInternalFocused(true);
|
|
71
|
+
if (onFocus) onFocus(e);
|
|
72
|
+
};
|
|
73
|
+
const handleBlur = e => {
|
|
74
|
+
setInternalFocused(false);
|
|
75
|
+
if (onBlur) onBlur(e);
|
|
76
|
+
};
|
|
77
|
+
const handlePress = () => {
|
|
78
|
+
inputRef.current?.focus();
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Blinking cursor setup for custom UI representation if we were drawing it natively.
|
|
82
|
+
// We use RNTextInput's native cursor, but we can style it or ensure it's visible.
|
|
83
|
+
|
|
84
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
85
|
+
style: [containerStyle, style],
|
|
86
|
+
onPress: handlePress,
|
|
87
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
88
|
+
style: {
|
|
89
|
+
position: 'relative',
|
|
90
|
+
justifyContent: 'center'
|
|
91
|
+
},
|
|
92
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
93
|
+
style: [baseTextStyle, textStyle, {
|
|
94
|
+
opacity: 0
|
|
95
|
+
}],
|
|
96
|
+
accessibilityElementsHidden: true,
|
|
97
|
+
importantForAccessibility: "no",
|
|
98
|
+
children: internalFocused ? value || ' ' : value || placeholder
|
|
99
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
|
|
100
|
+
ref: inputRef,
|
|
101
|
+
value: value,
|
|
102
|
+
onChangeText: onChangeText,
|
|
103
|
+
placeholder: internalFocused ? '' : placeholder,
|
|
104
|
+
placeholderTextColor: foreground,
|
|
105
|
+
onFocus: handleFocus,
|
|
106
|
+
onBlur: handleBlur,
|
|
107
|
+
selectionColor: foreground,
|
|
108
|
+
style: [baseTextStyle, {
|
|
109
|
+
position: 'absolute',
|
|
110
|
+
left: 0,
|
|
111
|
+
right: 0,
|
|
112
|
+
top: 0,
|
|
113
|
+
bottom: 0,
|
|
114
|
+
outlineStyle: 'none'
|
|
115
|
+
}, textStyle],
|
|
116
|
+
...rest
|
|
117
|
+
})]
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _NoteInput.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _NoteInput = _interopRequireDefault(require("./NoteInput"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,108 @@
|
|
|
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 _IconDeletebackspace = require("../../icons/components/IconDeletebackspace");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
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); }
|
|
13
|
+
function shuffleArray(arr) {
|
|
14
|
+
const shuffled = [...arr];
|
|
15
|
+
for (let i = shuffled.length - 1; i > 0; i--) {
|
|
16
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
17
|
+
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
|
|
18
|
+
}
|
|
19
|
+
return shuffled;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Secure numpad component for the JFS finance system.
|
|
24
|
+
*
|
|
25
|
+
* Renders a 3×4 grid of digit keys (0-9), an optional decimal key, and a
|
|
26
|
+
* backspace key. Digit positions are shuffled by default to guard against
|
|
27
|
+
* keylogging and shoulder-surfing attacks on mobile devices.
|
|
28
|
+
*
|
|
29
|
+
* @component
|
|
30
|
+
* @param {NumpadProps} props
|
|
31
|
+
*/
|
|
32
|
+
function Numpad({
|
|
33
|
+
modes = {},
|
|
34
|
+
onKeyPress,
|
|
35
|
+
showDecimal = true,
|
|
36
|
+
shuffle = true,
|
|
37
|
+
style,
|
|
38
|
+
keyStyle,
|
|
39
|
+
keyTextStyle
|
|
40
|
+
}) {
|
|
41
|
+
const foreground = (0, _figmaVariablesResolver.getVariableByName)('numpad/foreground', modes) ?? '#141414';
|
|
42
|
+
const lineHeight = (0, _figmaVariablesResolver.getVariableByName)('numpad/lineHeight', modes) ?? 32;
|
|
43
|
+
const fontFamily = (0, _figmaVariablesResolver.getVariableByName)('numpad/fontFamily', modes) ?? 'JioType Var';
|
|
44
|
+
const fontSize = (0, _figmaVariablesResolver.getVariableByName)('numpad/fontSize', modes) ?? 32;
|
|
45
|
+
const rowGap = (0, _figmaVariablesResolver.getVariableByName)('numpad/gridRowGap/vertical', modes) ?? 12;
|
|
46
|
+
const columnGap = (0, _figmaVariablesResolver.getVariableByName)('numpad/gridColumnGap/horizontal', modes) ?? 12;
|
|
47
|
+
const digits = (0, _react.useMemo)(() => {
|
|
48
|
+
const base = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];
|
|
49
|
+
return shuffle ? shuffleArray(base) : base;
|
|
50
|
+
}, [shuffle]);
|
|
51
|
+
const rows = (0, _react.useMemo)(() => [digits.slice(0, 3), digits.slice(3, 6), digits.slice(6, 9), [showDecimal ? '.' : null, digits[9], 'backspace']], [digits, showDecimal]);
|
|
52
|
+
const handlePress = (0, _react.useCallback)(key => {
|
|
53
|
+
onKeyPress?.(key);
|
|
54
|
+
}, [onKeyPress]);
|
|
55
|
+
const textStyle = {
|
|
56
|
+
color: foreground,
|
|
57
|
+
fontFamily: fontFamily,
|
|
58
|
+
fontSize: fontSize,
|
|
59
|
+
lineHeight: lineHeight,
|
|
60
|
+
textAlign: 'center'
|
|
61
|
+
};
|
|
62
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
63
|
+
style: [{
|
|
64
|
+
gap: rowGap
|
|
65
|
+
}, style],
|
|
66
|
+
accessibilityRole: "none",
|
|
67
|
+
children: rows.map((row, rowIndex) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
68
|
+
style: {
|
|
69
|
+
flexDirection: 'row',
|
|
70
|
+
gap: columnGap
|
|
71
|
+
},
|
|
72
|
+
children: row.map((key, colIndex) => {
|
|
73
|
+
if (key === null) {
|
|
74
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
75
|
+
style: {
|
|
76
|
+
flex: 1
|
|
77
|
+
}
|
|
78
|
+
}, `empty-${colIndex}`);
|
|
79
|
+
}
|
|
80
|
+
const isBackspace = key === 'backspace';
|
|
81
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
82
|
+
style: ({
|
|
83
|
+
pressed
|
|
84
|
+
}) => [{
|
|
85
|
+
flex: 1,
|
|
86
|
+
justifyContent: 'center',
|
|
87
|
+
alignItems: 'center',
|
|
88
|
+
minHeight: 46
|
|
89
|
+
}, pressed && {
|
|
90
|
+
opacity: 0.4
|
|
91
|
+
}, keyStyle],
|
|
92
|
+
onPress: () => handlePress(key),
|
|
93
|
+
accessibilityRole: "button",
|
|
94
|
+
accessibilityLabel: isBackspace ? 'Backspace' : key,
|
|
95
|
+
children: isBackspace ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconDeletebackspace.IconDeletebackspace, {
|
|
96
|
+
width: fontSize,
|
|
97
|
+
height: fontSize,
|
|
98
|
+
fill: foreground
|
|
99
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
100
|
+
style: [textStyle, keyTextStyle],
|
|
101
|
+
children: key
|
|
102
|
+
})
|
|
103
|
+
}, `${key}-${colIndex}`);
|
|
104
|
+
})
|
|
105
|
+
}, rowIndex))
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
var _default = exports.default = Numpad;
|