jfs-components 0.0.40 → 0.0.42
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/Form/Form.js +83 -0
- package/lib/commonjs/components/FormField/FormField.js +228 -0
- package/lib/commonjs/components/index.js +21 -0
- package/lib/commonjs/design-tokens/JFS Variables-variables-full.json +1 -1
- package/lib/commonjs/icons/registry.js +1 -1
- package/lib/module/components/Form/Form.js +77 -0
- package/lib/module/components/FormField/FormField.js +222 -0
- package/lib/module/components/index.js +3 -0
- package/lib/module/design-tokens/JFS Variables-variables-full.json +1 -1
- package/lib/module/icons/registry.js +1 -1
- package/lib/typescript/App.d.ts +2 -0
- package/lib/typescript/babel.config.d.ts +6 -0
- package/lib/typescript/build/bundle.d.ts +2 -0
- package/lib/typescript/debug-gap.d.ts +2 -0
- package/lib/typescript/index.d.ts +1 -4
- package/lib/typescript/metro.config.d.ts +78 -0
- package/lib/typescript/react-native.config.d.ts +4 -0
- package/lib/typescript/scripts/extract-component-tokens.d.ts +9 -0
- package/lib/typescript/scripts/generate-component-docs.d.ts +9 -0
- package/lib/typescript/scripts/generate-icon-registry.d.ts +3 -0
- package/lib/typescript/src/components/Form/Form.d.ts +19 -0
- package/lib/typescript/src/components/FormField/FormField.d.ts +27 -0
- package/lib/typescript/{components → src/components}/index.d.ts +3 -0
- package/lib/typescript/{icons → src/icons}/registry.d.ts +1 -1
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/webpack.config.d.ts +35 -0
- package/package.json +3 -1
- package/src/components/Form/Form.tsx +97 -0
- package/src/components/FormField/FormField.tsx +265 -0
- package/src/components/index.ts +3 -1
- package/src/design-tokens/JFS Variables-variables-full.json +1 -1
- package/src/icons/registry.ts +1 -1
- /package/lib/typescript/{Containers.d.ts → src/Containers.d.ts} +0 -0
- /package/lib/typescript/{components → src/components}/Accordion/Accordion.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/ActionFooter/ActionFooter.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/ActionTile/ActionTile.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/ActionTile/index.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/AppBar/AppBar.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Avatar/Avatar.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/AvatarGroup/AvatarGroup.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Badge/Badge.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Balance/Balance.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/BottomNav/BottomNav.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/BottomNavItem/BottomNavItem.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Button/Button.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/ButtonGroup/ButtonGroup.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Card/Card.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/CardFeedback/CardFeedback.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Carousel/Carousel.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/ChipGroup/ChipGroup.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/ChipSelect/ChipSelect.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/CtaCard/CtaCard.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/CtaCard/index.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Disclaimer/Disclaimer.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Divider/Divider.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Drawer/Drawer.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/EmptyState/EmptyState.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/FilterBar/FilterBar.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/HStack/HStack.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/IconButton/IconButton.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/IconCapsule/IconCapsule.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/InputSearch/InputSearch.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/LazyList/LazyList.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/LinearMeter/LinearMeter.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/LinearMeter/index.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/ListGroup/ListGroup.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/ListItem/ListItem.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/MediaCard/MediaCard.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/MerchantProfile/MerchantProfile.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/MoneyValue/MoneyValue.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/NavArrow/NavArrow.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/PageTitle/PageTitle.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/RadioButton/RadioButton.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/RechargeCard/RechargeCard.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Screen/Screen.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Section/Section.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Stepper/Step.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Stepper/StepLabel.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Stepper/Stepper.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/SupportText/SupportText.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/SupportText/SupportTextIcon.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/SupportText/index.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/TextInput/TextInput.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/ThreadHero/ThreadHero.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/Tooltip/Tooltip.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/TransactionDetails/TransactionDetails.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/TransactionStatus/TransactionStatus.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/UpiHandle/UpiHandle.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/VStack/VStack.d.ts +0 -0
- /package/lib/typescript/{components → src/components}/docs/DocSections.d.ts +0 -0
- /package/lib/typescript/{design-tokens → src/design-tokens}/JFSThemeProvider.d.ts +0 -0
- /package/lib/typescript/{design-tokens → src/design-tokens}/figma-variables-resolver.d.ts +0 -0
- /package/lib/typescript/{design-tokens → src/design-tokens}/index.d.ts +0 -0
- /package/lib/typescript/{icons → src/icons}/Icon.d.ts +0 -0
- /package/lib/typescript/{icons → src/icons}/index.d.ts +0 -0
- /package/lib/typescript/{utils → src/utils}/react-utils.d.ts +0 -0
- /package/lib/typescript/{utils → src/utils}/web-platform-utils.d.ts +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
exports.useFormContext = useFormContext;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _figmaVariablesResolver = require("../../design-tokens/figma-variables-resolver");
|
|
11
|
+
var _JFSThemeProvider = require("../../design-tokens/JFSThemeProvider");
|
|
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
|
+
const FormContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
15
|
+
function useFormContext() {
|
|
16
|
+
return (0, _react.useContext)(FormContext);
|
|
17
|
+
}
|
|
18
|
+
function Form({
|
|
19
|
+
children,
|
|
20
|
+
validationErrors: externalErrors,
|
|
21
|
+
onSubmit,
|
|
22
|
+
modes: propModes = {},
|
|
23
|
+
style,
|
|
24
|
+
accessibilityLabel,
|
|
25
|
+
testID
|
|
26
|
+
}) {
|
|
27
|
+
const {
|
|
28
|
+
modes: globalModes
|
|
29
|
+
} = (0, _JFSThemeProvider.useTokens)();
|
|
30
|
+
const modes = (0, _react.useMemo)(() => ({
|
|
31
|
+
...globalModes,
|
|
32
|
+
...propModes
|
|
33
|
+
}), [globalModes, propModes]);
|
|
34
|
+
const [clearedFields, setClearedFields] = (0, _react.useState)({});
|
|
35
|
+
|
|
36
|
+
// Re-sync cleared state when external errors change reference
|
|
37
|
+
const prevErrorsRef = _react.default.useRef(externalErrors);
|
|
38
|
+
if (externalErrors !== prevErrorsRef.current) {
|
|
39
|
+
prevErrorsRef.current = externalErrors;
|
|
40
|
+
setClearedFields({});
|
|
41
|
+
}
|
|
42
|
+
const validationErrors = (0, _react.useMemo)(() => {
|
|
43
|
+
if (!externalErrors) return {};
|
|
44
|
+
const result = {};
|
|
45
|
+
for (const key of Object.keys(externalErrors)) {
|
|
46
|
+
if (!clearedFields[key]) {
|
|
47
|
+
result[key] = externalErrors[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}, [externalErrors, clearedFields]);
|
|
52
|
+
const onFieldChange = (0, _react.useCallback)(name => {
|
|
53
|
+
if (externalErrors && name in externalErrors) {
|
|
54
|
+
setClearedFields(prev => ({
|
|
55
|
+
...prev,
|
|
56
|
+
[name]: true
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
}, [externalErrors]);
|
|
60
|
+
const contextValue = (0, _react.useMemo)(() => ({
|
|
61
|
+
validationErrors,
|
|
62
|
+
onFieldChange
|
|
63
|
+
}), [validationErrors, onFieldChange]);
|
|
64
|
+
const gap = parseInt((0, _figmaVariablesResolver.getVariableByName)('form/gap', modes), 10) || 12;
|
|
65
|
+
const paddingHorizontal = parseInt((0, _figmaVariablesResolver.getVariableByName)('form/padding/horizontal', modes), 10) || 0;
|
|
66
|
+
const paddingVertical = parseInt((0, _figmaVariablesResolver.getVariableByName)('form/padding/vertical', modes), 10) || 0;
|
|
67
|
+
const containerStyle = (0, _react.useMemo)(() => ({
|
|
68
|
+
gap,
|
|
69
|
+
paddingHorizontal,
|
|
70
|
+
paddingVertical
|
|
71
|
+
}), [gap, paddingHorizontal, paddingVertical]);
|
|
72
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(FormContext.Provider, {
|
|
73
|
+
value: contextValue,
|
|
74
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
75
|
+
style: [containerStyle, style],
|
|
76
|
+
accessibilityRole: "none",
|
|
77
|
+
accessibilityLabel: accessibilityLabel,
|
|
78
|
+
testID: testID,
|
|
79
|
+
children: children
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
var _default = exports.default = Form;
|
|
@@ -0,0 +1,228 @@
|
|
|
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 _TextInput = _interopRequireDefault(require("../TextInput/TextInput"));
|
|
12
|
+
var _SupportText = _interopRequireDefault(require("../SupportText/SupportText"));
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
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); }
|
|
16
|
+
function useFormField(props) {
|
|
17
|
+
const {
|
|
18
|
+
type = 'text',
|
|
19
|
+
isDisabled = false,
|
|
20
|
+
isInvalid = false,
|
|
21
|
+
supportText,
|
|
22
|
+
errorMessage,
|
|
23
|
+
modes: propModes = {},
|
|
24
|
+
onFocus,
|
|
25
|
+
onBlur
|
|
26
|
+
} = props;
|
|
27
|
+
const {
|
|
28
|
+
modes: globalModes
|
|
29
|
+
} = (0, _JFSThemeProvider.useTokens)();
|
|
30
|
+
const baseModes = (0, _react.useMemo)(() => ({
|
|
31
|
+
...globalModes,
|
|
32
|
+
...propModes
|
|
33
|
+
}), [globalModes, propModes]);
|
|
34
|
+
const [isFocused, setIsFocused] = (0, _react.useState)(false);
|
|
35
|
+
|
|
36
|
+
// Merge FormField States collection based on focus
|
|
37
|
+
const modes = (0, _react.useMemo)(() => ({
|
|
38
|
+
...baseModes,
|
|
39
|
+
'FormField States': isFocused ? 'Active' : 'Idle'
|
|
40
|
+
}), [baseModes, isFocused]);
|
|
41
|
+
|
|
42
|
+
// -- Label tokens (from "FormField / Output" collection) --
|
|
43
|
+
const labelColor = (0, _figmaVariablesResolver.getVariableByName)('formField/label/color', modes) || '#0c0d10';
|
|
44
|
+
const labelFontFamily = (0, _figmaVariablesResolver.getVariableByName)('formField/label/fontFamily', modes) || 'JioType Var';
|
|
45
|
+
const labelFontSize = parseInt((0, _figmaVariablesResolver.getVariableByName)('formField/label/fontSize', modes), 10) || 14;
|
|
46
|
+
const labelLineHeight = parseInt((0, _figmaVariablesResolver.getVariableByName)('formField/label/lineHeight', modes), 10) || 17;
|
|
47
|
+
const labelFontWeight = (0, _figmaVariablesResolver.getVariableByName)('formField/label/fontWeight', modes) || '500';
|
|
48
|
+
const gap = parseInt((0, _figmaVariablesResolver.getVariableByName)('formField/gap', modes), 10) || 8;
|
|
49
|
+
|
|
50
|
+
// -- Input tokens (from "FormField / Output" + "FormField States" collections) --
|
|
51
|
+
const inputPaddingH = parseInt((0, _figmaVariablesResolver.getVariableByName)('formField/input/padding/horizontal', modes), 10) || 12;
|
|
52
|
+
const inputGap = parseInt((0, _figmaVariablesResolver.getVariableByName)('formField/input/gap', modes), 10) || 8;
|
|
53
|
+
const inputRadius = parseInt((0, _figmaVariablesResolver.getVariableByName)('formField/input/radius', modes), 10) || 8;
|
|
54
|
+
const inputBackground = (0, _figmaVariablesResolver.getVariableByName)('formField/input/background', modes) || '#ffffff';
|
|
55
|
+
const inputFontSize = parseInt((0, _figmaVariablesResolver.getVariableByName)('formField/input/label/fontSize', modes), 10) || 16;
|
|
56
|
+
const inputLineHeight = parseInt((0, _figmaVariablesResolver.getVariableByName)('formField/input/label/lineHeight', modes), 10) || 45;
|
|
57
|
+
const inputFontFamily = (0, _figmaVariablesResolver.getVariableByName)('formField/input/label/fontFamily', modes) || 'JioType Var';
|
|
58
|
+
const inputFontWeight = (0, _figmaVariablesResolver.getVariableByName)('formField/input/label/fontWeight', modes) || '400';
|
|
59
|
+
const inputTextColor = (0, _figmaVariablesResolver.getVariableByName)('states/formField/input/label/color', modes) || (0, _figmaVariablesResolver.getVariableByName)('formField/input/label/color', modes) || '#24262b';
|
|
60
|
+
const inputBorderColor = (0, _figmaVariablesResolver.getVariableByName)('states/formField/input/border/color', modes) || (0, _figmaVariablesResolver.getVariableByName)('formField/input/border/color', modes) || '#b5b6b7';
|
|
61
|
+
const inputBorderSize = parseInt((0, _figmaVariablesResolver.getVariableByName)('formField/input/border/size', modes), 10) || 1;
|
|
62
|
+
|
|
63
|
+
// -- Styles --
|
|
64
|
+
const labelStyle = (0, _react.useMemo)(() => ({
|
|
65
|
+
color: labelColor,
|
|
66
|
+
fontFamily: labelFontFamily,
|
|
67
|
+
fontSize: labelFontSize,
|
|
68
|
+
lineHeight: labelLineHeight,
|
|
69
|
+
fontWeight: labelFontWeight
|
|
70
|
+
}), [labelColor, labelFontFamily, labelFontSize, labelLineHeight, labelFontWeight]);
|
|
71
|
+
const wrapperStyle = (0, _react.useMemo)(() => ({
|
|
72
|
+
gap,
|
|
73
|
+
opacity: isDisabled ? 0.5 : 1
|
|
74
|
+
}), [gap, isDisabled]);
|
|
75
|
+
const requiredIndicatorStyle = (0, _react.useMemo)(() => ({
|
|
76
|
+
color: '#d93d3d',
|
|
77
|
+
fontFamily: labelFontFamily,
|
|
78
|
+
fontSize: labelFontSize,
|
|
79
|
+
lineHeight: labelLineHeight,
|
|
80
|
+
fontWeight: labelFontWeight
|
|
81
|
+
}), [labelFontFamily, labelFontSize, labelLineHeight, labelFontWeight]);
|
|
82
|
+
|
|
83
|
+
// Style overrides for the input row, sourced from formField/input/* tokens
|
|
84
|
+
const inputContainerStyle = (0, _react.useMemo)(() => ({
|
|
85
|
+
backgroundColor: inputBackground,
|
|
86
|
+
borderColor: inputBorderColor,
|
|
87
|
+
borderWidth: inputBorderSize,
|
|
88
|
+
borderRadius: inputRadius,
|
|
89
|
+
paddingHorizontal: inputPaddingH,
|
|
90
|
+
gap: inputGap
|
|
91
|
+
}), [inputBackground, inputBorderColor, inputBorderSize, inputRadius, inputPaddingH, inputGap]);
|
|
92
|
+
const inputTextStyle = (0, _react.useMemo)(() => ({
|
|
93
|
+
color: inputTextColor,
|
|
94
|
+
fontSize: inputFontSize,
|
|
95
|
+
lineHeight: inputLineHeight,
|
|
96
|
+
fontFamily: inputFontFamily,
|
|
97
|
+
fontWeight: inputFontWeight
|
|
98
|
+
}), [inputTextColor, inputFontSize, inputLineHeight, inputFontFamily, inputFontWeight]);
|
|
99
|
+
|
|
100
|
+
// -- Support text logic --
|
|
101
|
+
const supportStatus = isInvalid ? 'Error' : 'Neutral';
|
|
102
|
+
const supportLabel = isInvalid && errorMessage ? errorMessage : supportText;
|
|
103
|
+
|
|
104
|
+
// -- Input type derived props --
|
|
105
|
+
const secureTextEntry = type === 'password';
|
|
106
|
+
const keyboardType = type === 'email' ? 'email-address' : 'default';
|
|
107
|
+
const autoCapitalize = type === 'email' || type === 'password' ? 'none' : 'sentences';
|
|
108
|
+
|
|
109
|
+
// -- Event handlers --
|
|
110
|
+
const handleFocus = (0, _react.useCallback)(e => {
|
|
111
|
+
setIsFocused(true);
|
|
112
|
+
onFocus?.(e);
|
|
113
|
+
}, [onFocus]);
|
|
114
|
+
const handleBlur = (0, _react.useCallback)(e => {
|
|
115
|
+
setIsFocused(false);
|
|
116
|
+
onBlur?.(e);
|
|
117
|
+
}, [onBlur]);
|
|
118
|
+
return {
|
|
119
|
+
modes,
|
|
120
|
+
labelStyle,
|
|
121
|
+
wrapperStyle,
|
|
122
|
+
requiredIndicatorStyle,
|
|
123
|
+
inputContainerStyle,
|
|
124
|
+
inputTextStyle,
|
|
125
|
+
supportStatus,
|
|
126
|
+
supportLabel,
|
|
127
|
+
secureTextEntry,
|
|
128
|
+
keyboardType,
|
|
129
|
+
autoCapitalize,
|
|
130
|
+
handleFocus,
|
|
131
|
+
handleBlur
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function FormField({
|
|
135
|
+
label,
|
|
136
|
+
placeholder,
|
|
137
|
+
value = '',
|
|
138
|
+
onChangeText,
|
|
139
|
+
type = 'text',
|
|
140
|
+
leading,
|
|
141
|
+
trailing,
|
|
142
|
+
leadingIconName,
|
|
143
|
+
isRequired = false,
|
|
144
|
+
isDisabled = false,
|
|
145
|
+
isInvalid = false,
|
|
146
|
+
supportText,
|
|
147
|
+
errorMessage,
|
|
148
|
+
modes = {},
|
|
149
|
+
style,
|
|
150
|
+
onFocus,
|
|
151
|
+
onBlur,
|
|
152
|
+
accessibilityLabel,
|
|
153
|
+
accessibilityHint
|
|
154
|
+
}) {
|
|
155
|
+
const {
|
|
156
|
+
modes: resolvedModes,
|
|
157
|
+
labelStyle,
|
|
158
|
+
wrapperStyle,
|
|
159
|
+
requiredIndicatorStyle,
|
|
160
|
+
inputContainerStyle,
|
|
161
|
+
inputTextStyle,
|
|
162
|
+
supportStatus,
|
|
163
|
+
supportLabel,
|
|
164
|
+
secureTextEntry,
|
|
165
|
+
keyboardType,
|
|
166
|
+
autoCapitalize,
|
|
167
|
+
handleFocus,
|
|
168
|
+
handleBlur
|
|
169
|
+
} = useFormField({
|
|
170
|
+
type,
|
|
171
|
+
isDisabled,
|
|
172
|
+
isInvalid,
|
|
173
|
+
supportText,
|
|
174
|
+
errorMessage,
|
|
175
|
+
modes,
|
|
176
|
+
onFocus,
|
|
177
|
+
onBlur
|
|
178
|
+
});
|
|
179
|
+
const resolvedA11yLabel = accessibilityLabel || label || placeholder || 'Form field';
|
|
180
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
181
|
+
style: [wrapperStyle, style],
|
|
182
|
+
pointerEvents: isDisabled ? 'none' : 'auto',
|
|
183
|
+
accessible: true,
|
|
184
|
+
accessibilityRole: "none",
|
|
185
|
+
accessibilityLabel: resolvedA11yLabel,
|
|
186
|
+
accessibilityState: {
|
|
187
|
+
disabled: isDisabled
|
|
188
|
+
},
|
|
189
|
+
children: [label != null && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
190
|
+
style: {
|
|
191
|
+
flexDirection: 'row',
|
|
192
|
+
alignItems: 'baseline'
|
|
193
|
+
},
|
|
194
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
195
|
+
style: labelStyle,
|
|
196
|
+
children: label
|
|
197
|
+
}), isRequired && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
198
|
+
style: requiredIndicatorStyle,
|
|
199
|
+
children: " *"
|
|
200
|
+
})]
|
|
201
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInput.default, {
|
|
202
|
+
placeholder: placeholder || '',
|
|
203
|
+
value: value,
|
|
204
|
+
...(onChangeText ? {
|
|
205
|
+
onChangeText
|
|
206
|
+
} : {}),
|
|
207
|
+
leading: leading,
|
|
208
|
+
trailing: trailing,
|
|
209
|
+
leadingIconName: leadingIconName || 'ic_search',
|
|
210
|
+
modes: resolvedModes,
|
|
211
|
+
style: inputContainerStyle,
|
|
212
|
+
inputStyle: inputTextStyle,
|
|
213
|
+
onFocus: handleFocus,
|
|
214
|
+
onBlur: handleBlur,
|
|
215
|
+
secureTextEntry: secureTextEntry,
|
|
216
|
+
keyboardType: keyboardType,
|
|
217
|
+
autoCapitalize: autoCapitalize,
|
|
218
|
+
editable: !isDisabled,
|
|
219
|
+
accessibilityLabel: resolvedA11yLabel,
|
|
220
|
+
accessibilityHint: accessibilityHint || ''
|
|
221
|
+
}), supportLabel != null && /*#__PURE__*/(0, _jsxRuntime.jsx)(_SupportText.default, {
|
|
222
|
+
label: supportLabel,
|
|
223
|
+
status: supportStatus,
|
|
224
|
+
modes: resolvedModes
|
|
225
|
+
})]
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
var _default = exports.default = FormField;
|
|
@@ -135,6 +135,18 @@ Object.defineProperty(exports, "FilterBar", {
|
|
|
135
135
|
return _FilterBar.default;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
|
+
Object.defineProperty(exports, "Form", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () {
|
|
141
|
+
return _Form.default;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, "FormField", {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return _FormField.default;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
138
150
|
Object.defineProperty(exports, "HStack", {
|
|
139
151
|
enumerable: true,
|
|
140
152
|
get: function () {
|
|
@@ -297,6 +309,12 @@ Object.defineProperty(exports, "VStack", {
|
|
|
297
309
|
return _VStack.default;
|
|
298
310
|
}
|
|
299
311
|
});
|
|
312
|
+
Object.defineProperty(exports, "useFormContext", {
|
|
313
|
+
enumerable: true,
|
|
314
|
+
get: function () {
|
|
315
|
+
return _Form.useFormContext;
|
|
316
|
+
}
|
|
317
|
+
});
|
|
300
318
|
var _ActionFooter = _interopRequireDefault(require("./ActionFooter/ActionFooter"));
|
|
301
319
|
var _AppBar = _interopRequireDefault(require("./AppBar/AppBar"));
|
|
302
320
|
var _Avatar = _interopRequireDefault(require("./Avatar/Avatar"));
|
|
@@ -312,6 +330,8 @@ var _Divider = _interopRequireDefault(require("./Divider/Divider"));
|
|
|
312
330
|
var _Drawer = _interopRequireDefault(require("./Drawer/Drawer"));
|
|
313
331
|
var _CtaCard = _interopRequireDefault(require("./CtaCard/CtaCard"));
|
|
314
332
|
var _FilterBar = _interopRequireDefault(require("./FilterBar/FilterBar"));
|
|
333
|
+
var _Form = _interopRequireWildcard(require("./Form/Form"));
|
|
334
|
+
var _FormField = _interopRequireDefault(require("./FormField/FormField"));
|
|
315
335
|
var _HStack = _interopRequireDefault(require("./HStack/HStack"));
|
|
316
336
|
var _IconButton = _interopRequireDefault(require("./IconButton/IconButton"));
|
|
317
337
|
var _IconCapsule = _interopRequireDefault(require("./IconCapsule/IconCapsule"));
|
|
@@ -346,4 +366,5 @@ var _InputSearch = _interopRequireDefault(require("./InputSearch/InputSearch"));
|
|
|
346
366
|
var _SupportText = _interopRequireDefault(require("./SupportText/SupportText"));
|
|
347
367
|
var _SupportTextIcon = _interopRequireDefault(require("./SupportText/SupportTextIcon"));
|
|
348
368
|
var _RadioButton = _interopRequireDefault(require("./RadioButton/RadioButton"));
|
|
369
|
+
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); }
|
|
349
370
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|