@cdx-ui/primitives 0.0.1-alpha.35 → 0.0.1-alpha.37
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/{form-control/createFormError.js → field/createFieldError.js} +4 -4
- package/lib/commonjs/field/createFieldError.js.map +1 -0
- package/lib/commonjs/{form-control/createFormErrorIcon.js → field/createFieldErrorIcon.js} +4 -4
- package/lib/commonjs/field/createFieldErrorIcon.js.map +1 -0
- package/lib/commonjs/{form-control/createFormErrorText.js → field/createFieldErrorText.js} +4 -4
- package/lib/commonjs/field/createFieldErrorText.js.map +1 -0
- package/lib/commonjs/{form-control/createFormHelper.js → field/createFieldHelper.js} +4 -4
- package/lib/commonjs/field/createFieldHelper.js.map +1 -0
- package/lib/commonjs/{form-control/createFormHelperText.js → field/createFieldHelperText.js} +4 -4
- package/lib/commonjs/field/createFieldHelperText.js.map +1 -0
- package/lib/commonjs/{form-control/createFormLabel.js → field/createFieldLabel.js} +4 -6
- package/lib/commonjs/field/createFieldLabel.js.map +1 -0
- package/lib/commonjs/{form-control/createFormField.js → field/createFieldRoot.js} +4 -4
- package/lib/commonjs/field/createFieldRoot.js.map +1 -0
- package/lib/commonjs/field/index.js +46 -0
- package/lib/commonjs/field/index.js.map +1 -0
- package/lib/commonjs/{form-control → field}/types.js.map +1 -1
- package/lib/commonjs/form/createFormRoot.js.map +1 -0
- package/lib/commonjs/form/index.js +15 -0
- package/lib/commonjs/form/index.js.map +1 -0
- package/lib/commonjs/form/types.js +6 -0
- package/lib/{module/form-control → commonjs/form}/types.js.map +1 -1
- package/lib/commonjs/index.js +28 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/otp-input/context.js +14 -0
- package/lib/commonjs/otp-input/context.js.map +1 -0
- package/lib/commonjs/otp-input/createOtpInputCell.js +29 -0
- package/lib/commonjs/otp-input/createOtpInputCell.js.map +1 -0
- package/lib/commonjs/otp-input/createOtpInputField.js +104 -0
- package/lib/commonjs/otp-input/createOtpInputField.js.map +1 -0
- package/lib/commonjs/otp-input/createOtpInputRoot.js +136 -0
- package/lib/commonjs/otp-input/createOtpInputRoot.js.map +1 -0
- package/lib/commonjs/otp-input/index.js +48 -0
- package/lib/commonjs/otp-input/index.js.map +1 -0
- package/lib/commonjs/otp-input/types.js +6 -0
- package/lib/commonjs/otp-input/types.js.map +1 -0
- package/lib/commonjs/otp-input/utils/applyValueChange.js +73 -0
- package/lib/commonjs/otp-input/utils/applyValueChange.js.map +1 -0
- package/lib/commonjs/otp-input/utils/filterValue.js +46 -0
- package/lib/commonjs/otp-input/utils/filterValue.js.map +1 -0
- package/lib/module/{form-control/createFormError.js → field/createFieldError.js} +2 -2
- package/lib/module/field/createFieldError.js.map +1 -0
- package/lib/module/{form-control/createFormErrorIcon.js → field/createFieldErrorIcon.js} +2 -2
- package/lib/module/field/createFieldErrorIcon.js.map +1 -0
- package/lib/module/{form-control/createFormErrorText.js → field/createFieldErrorText.js} +2 -2
- package/lib/module/field/createFieldErrorText.js.map +1 -0
- package/lib/module/{form-control/createFormHelper.js → field/createFieldHelper.js} +2 -2
- package/lib/module/field/createFieldHelper.js.map +1 -0
- package/lib/module/{form-control/createFormHelperText.js → field/createFieldHelperText.js} +2 -2
- package/lib/module/field/createFieldHelperText.js.map +1 -0
- package/lib/module/{form-control/createFormLabel.js → field/createFieldLabel.js} +2 -4
- package/lib/module/field/createFieldLabel.js.map +1 -0
- package/lib/module/{form-control/createFormField.js → field/createFieldRoot.js} +2 -2
- package/lib/module/field/createFieldRoot.js.map +1 -0
- package/lib/module/field/index.js +42 -0
- package/lib/module/field/index.js.map +1 -0
- package/lib/module/field/types.js.map +1 -0
- package/lib/module/form/createFormRoot.js.map +1 -0
- package/lib/module/form/index.js +11 -0
- package/lib/module/form/index.js.map +1 -0
- package/lib/module/form/types.js +4 -0
- package/lib/module/form/types.js.map +1 -0
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/otp-input/context.js +6 -0
- package/lib/module/otp-input/context.js.map +1 -0
- package/lib/module/otp-input/createOtpInputCell.js +24 -0
- package/lib/module/otp-input/createOtpInputCell.js.map +1 -0
- package/lib/module/otp-input/createOtpInputField.js +99 -0
- package/lib/module/otp-input/createOtpInputField.js.map +1 -0
- package/lib/module/otp-input/createOtpInputRoot.js +131 -0
- package/lib/module/otp-input/createOtpInputRoot.js.map +1 -0
- package/lib/module/otp-input/index.js +20 -0
- package/lib/module/otp-input/index.js.map +1 -0
- package/lib/module/otp-input/types.js +4 -0
- package/lib/module/otp-input/types.js.map +1 -0
- package/lib/module/otp-input/utils/applyValueChange.js +69 -0
- package/lib/module/otp-input/utils/applyValueChange.js.map +1 -0
- package/lib/module/otp-input/utils/filterValue.js +40 -0
- package/lib/module/otp-input/utils/filterValue.js.map +1 -0
- package/lib/typescript/field/createFieldError.d.ts +5 -0
- package/lib/typescript/field/createFieldError.d.ts.map +1 -0
- package/lib/typescript/field/createFieldErrorIcon.d.ts +5 -0
- package/lib/typescript/field/createFieldErrorIcon.d.ts.map +1 -0
- package/lib/typescript/field/createFieldErrorText.d.ts +5 -0
- package/lib/typescript/field/createFieldErrorText.d.ts.map +1 -0
- package/lib/typescript/field/createFieldHelper.d.ts +5 -0
- package/lib/typescript/field/createFieldHelper.d.ts.map +1 -0
- package/lib/typescript/field/createFieldHelperText.d.ts +5 -0
- package/lib/typescript/field/createFieldHelperText.d.ts.map +1 -0
- package/lib/typescript/field/createFieldLabel.d.ts +6 -0
- package/lib/typescript/field/createFieldLabel.d.ts.map +1 -0
- package/lib/typescript/field/createFieldRoot.d.ts +6 -0
- package/lib/typescript/field/createFieldRoot.d.ts.map +1 -0
- package/lib/typescript/field/index.d.ts +13 -0
- package/lib/typescript/field/index.d.ts.map +1 -0
- package/lib/typescript/{form-control → field}/types.d.ts +14 -24
- package/lib/typescript/field/types.d.ts.map +1 -0
- package/lib/typescript/form/createFormRoot.d.ts +4 -0
- package/lib/typescript/form/createFormRoot.d.ts.map +1 -0
- package/lib/typescript/form/index.d.ts +6 -0
- package/lib/typescript/form/index.d.ts.map +1 -0
- package/lib/typescript/form/types.d.ts +14 -0
- package/lib/typescript/form/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/otp-input/context.d.ts +10 -0
- package/lib/typescript/otp-input/context.d.ts.map +1 -0
- package/lib/typescript/otp-input/createOtpInputCell.d.ts +4 -0
- package/lib/typescript/otp-input/createOtpInputCell.d.ts.map +1 -0
- package/lib/typescript/otp-input/createOtpInputField.d.ts +4 -0
- package/lib/typescript/otp-input/createOtpInputField.d.ts.map +1 -0
- package/lib/typescript/otp-input/createOtpInputRoot.d.ts +4 -0
- package/lib/typescript/otp-input/createOtpInputRoot.d.ts.map +1 -0
- package/lib/typescript/otp-input/index.d.ts +11 -0
- package/lib/typescript/otp-input/index.d.ts.map +1 -0
- package/lib/typescript/otp-input/types.d.ts +75 -0
- package/lib/typescript/otp-input/types.d.ts.map +1 -0
- package/lib/typescript/otp-input/utils/applyValueChange.d.ts +10 -0
- package/lib/typescript/otp-input/utils/applyValueChange.d.ts.map +1 -0
- package/lib/typescript/otp-input/utils/filterValue.d.ts +7 -0
- package/lib/typescript/otp-input/utils/filterValue.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/{form-control/createFormError.tsx → field/createFieldError.tsx} +1 -1
- package/src/{form-control/createFormErrorIcon.tsx → field/createFieldErrorIcon.tsx} +1 -1
- package/src/{form-control/createFormErrorText.tsx → field/createFieldErrorText.tsx} +1 -1
- package/src/{form-control/createFormHelper.tsx → field/createFieldHelper.tsx} +1 -1
- package/src/{form-control/createFormHelperText.tsx → field/createFieldHelperText.tsx} +1 -1
- package/src/{form-control/createFormLabel.tsx → field/createFieldLabel.tsx} +3 -3
- package/src/{form-control/createFormField.tsx → field/createFieldRoot.tsx} +3 -3
- package/src/field/index.tsx +68 -0
- package/src/{form-control → field}/types.tsx +28 -42
- package/src/{form-control → form}/createFormRoot.tsx +3 -3
- package/src/form/index.tsx +12 -0
- package/src/form/types.tsx +16 -0
- package/src/index.ts +3 -1
- package/src/otp-input/context.tsx +8 -0
- package/src/otp-input/createOtpInputCell.tsx +22 -0
- package/src/otp-input/createOtpInputField.tsx +98 -0
- package/src/otp-input/createOtpInputRoot.tsx +179 -0
- package/src/otp-input/index.tsx +34 -0
- package/src/otp-input/types.ts +92 -0
- package/src/otp-input/utils/applyValueChange.ts +56 -0
- package/src/otp-input/utils/filterValue.ts +37 -0
- package/lib/commonjs/form-control/createFormError.js.map +0 -1
- package/lib/commonjs/form-control/createFormErrorIcon.js.map +0 -1
- package/lib/commonjs/form-control/createFormErrorText.js.map +0 -1
- package/lib/commonjs/form-control/createFormField.js.map +0 -1
- package/lib/commonjs/form-control/createFormHelper.js.map +0 -1
- package/lib/commonjs/form-control/createFormHelperText.js.map +0 -1
- package/lib/commonjs/form-control/createFormLabel.js.map +0 -1
- package/lib/commonjs/form-control/createFormRoot.js.map +0 -1
- package/lib/commonjs/form-control/index.js +0 -53
- package/lib/commonjs/form-control/index.js.map +0 -1
- package/lib/module/form-control/createFormError.js.map +0 -1
- package/lib/module/form-control/createFormErrorIcon.js.map +0 -1
- package/lib/module/form-control/createFormErrorText.js.map +0 -1
- package/lib/module/form-control/createFormField.js.map +0 -1
- package/lib/module/form-control/createFormHelper.js.map +0 -1
- package/lib/module/form-control/createFormHelperText.js.map +0 -1
- package/lib/module/form-control/createFormLabel.js.map +0 -1
- package/lib/module/form-control/createFormRoot.js.map +0 -1
- package/lib/module/form-control/index.js +0 -49
- package/lib/module/form-control/index.js.map +0 -1
- package/lib/typescript/form-control/createFormError.d.ts +0 -5
- package/lib/typescript/form-control/createFormError.d.ts.map +0 -1
- package/lib/typescript/form-control/createFormErrorIcon.d.ts +0 -5
- package/lib/typescript/form-control/createFormErrorIcon.d.ts.map +0 -1
- package/lib/typescript/form-control/createFormErrorText.d.ts +0 -5
- package/lib/typescript/form-control/createFormErrorText.d.ts.map +0 -1
- package/lib/typescript/form-control/createFormField.d.ts +0 -6
- package/lib/typescript/form-control/createFormField.d.ts.map +0 -1
- package/lib/typescript/form-control/createFormHelper.d.ts +0 -5
- package/lib/typescript/form-control/createFormHelper.d.ts.map +0 -1
- package/lib/typescript/form-control/createFormHelperText.d.ts +0 -5
- package/lib/typescript/form-control/createFormHelperText.d.ts.map +0 -1
- package/lib/typescript/form-control/createFormLabel.d.ts +0 -8
- package/lib/typescript/form-control/createFormLabel.d.ts.map +0 -1
- package/lib/typescript/form-control/createFormRoot.d.ts +0 -6
- package/lib/typescript/form-control/createFormRoot.d.ts.map +0 -1
- package/lib/typescript/form-control/index.d.ts +0 -14
- package/lib/typescript/form-control/index.d.ts.map +0 -1
- package/lib/typescript/form-control/types.d.ts.map +0 -1
- package/src/form-control/index.tsx +0 -71
- /package/lib/commonjs/{form-control → field}/types.js +0 -0
- /package/lib/commonjs/{form-control → form}/createFormRoot.js +0 -0
- /package/lib/module/{form-control → field}/types.js +0 -0
- /package/lib/module/{form-control → form}/createFormRoot.js +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createOtpInputRoot = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _utils = require("@cdx-ui/utils");
|
|
9
|
+
var _applyValueChange = require("./utils/applyValueChange");
|
|
10
|
+
var _context = require("./context");
|
|
11
|
+
var _filterValue = require("./utils/filterValue");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
const createOtpInputRoot = (BaseRoot, OtpCell, OtpField) => /*#__PURE__*/(0, _react.forwardRef)(({
|
|
14
|
+
cellCount,
|
|
15
|
+
value,
|
|
16
|
+
onChangeText,
|
|
17
|
+
onComplete,
|
|
18
|
+
isDisabled: isDisabledProp,
|
|
19
|
+
isInvalid: isInvalidProp,
|
|
20
|
+
isReadOnly: isReadOnlyProp,
|
|
21
|
+
smsOtpAutofill = true,
|
|
22
|
+
filterInput,
|
|
23
|
+
allowedCharacters,
|
|
24
|
+
characterPattern,
|
|
25
|
+
getCellProps,
|
|
26
|
+
cellTestIdPrefix,
|
|
27
|
+
accessibilityLabel: rootAccessibilityLabel,
|
|
28
|
+
...rest
|
|
29
|
+
}, ref) => {
|
|
30
|
+
const form = (0, _utils.useFormControlContext)();
|
|
31
|
+
const isDisabled = isDisabledProp ?? form.isDisabled ?? false;
|
|
32
|
+
const isInvalid = isInvalidProp ?? form.isInvalid ?? false;
|
|
33
|
+
const isReadOnly = isReadOnlyProp ?? form.isReadOnly ?? false;
|
|
34
|
+
const fieldRefs = (0, _react.useRef)([]);
|
|
35
|
+
const focusAfterApply = (0, _react.useRef)(null);
|
|
36
|
+
const prevLenRef = (0, _react.useRef)(value.length);
|
|
37
|
+
const prevValueRef = (0, _react.useRef)(value);
|
|
38
|
+
const filter = (0, _react.useMemo)(() => {
|
|
39
|
+
if (filterInput) {
|
|
40
|
+
return filterInput;
|
|
41
|
+
}
|
|
42
|
+
if (allowedCharacters !== undefined) {
|
|
43
|
+
return (0, _filterValue.filterAllowedCharacters)(allowedCharacters);
|
|
44
|
+
}
|
|
45
|
+
if (characterPattern !== undefined) {
|
|
46
|
+
return (0, _filterValue.filterByRegExp)(characterPattern);
|
|
47
|
+
}
|
|
48
|
+
return _filterValue.filterDigits;
|
|
49
|
+
}, [filterInput, allowedCharacters, characterPattern]);
|
|
50
|
+
const setFieldRef = (0, _react.useCallback)((index, el) => {
|
|
51
|
+
fieldRefs.current[index] = el;
|
|
52
|
+
}, []);
|
|
53
|
+
const focusCell = (0, _react.useCallback)(index => {
|
|
54
|
+
const safe = Math.max(0, Math.min(index, cellCount - 1));
|
|
55
|
+
fieldRefs.current[safe]?.focus();
|
|
56
|
+
}, [cellCount]);
|
|
57
|
+
const handleFieldChange = (0, _react.useCallback)((index, text) => {
|
|
58
|
+
const {
|
|
59
|
+
nextValue,
|
|
60
|
+
focusIndex
|
|
61
|
+
} = (0, _applyValueChange.applyOtpInputChange)(value, index, text, cellCount, filter);
|
|
62
|
+
if (nextValue !== value) {
|
|
63
|
+
onChangeText(nextValue);
|
|
64
|
+
}
|
|
65
|
+
focusAfterApply.current = focusIndex;
|
|
66
|
+
}, [cellCount, filter, onChangeText, value]);
|
|
67
|
+
const handleFieldKeyPress = (0, _react.useCallback)((index, key) => {
|
|
68
|
+
if (key !== 'Backspace') {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const char = index < value.length ? value[index] : '';
|
|
72
|
+
if (!char && index > 0) {
|
|
73
|
+
focusCell(index - 1);
|
|
74
|
+
}
|
|
75
|
+
}, [focusCell, value]);
|
|
76
|
+
(0, _react.useLayoutEffect)(() => {
|
|
77
|
+
if (focusAfterApply.current !== null) {
|
|
78
|
+
const i = focusAfterApply.current;
|
|
79
|
+
focusAfterApply.current = null;
|
|
80
|
+
fieldRefs.current[i]?.focus();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
(0, _react.useEffect)(() => {
|
|
84
|
+
const prevLen = prevLenRef.current;
|
|
85
|
+
const prevVal = prevValueRef.current;
|
|
86
|
+
const isFull = value.length === cellCount;
|
|
87
|
+
const becameFullByLength = isFull && prevLen < cellCount;
|
|
88
|
+
const correctedWhileFull = isFull && prevLen === cellCount && prevVal !== value;
|
|
89
|
+
if (becameFullByLength || correctedWhileFull) {
|
|
90
|
+
onComplete?.();
|
|
91
|
+
}
|
|
92
|
+
prevLenRef.current = value.length;
|
|
93
|
+
prevValueRef.current = value;
|
|
94
|
+
}, [cellCount, onComplete, value]);
|
|
95
|
+
const contextValue = (0, _react.useMemo)(() => ({
|
|
96
|
+
cellCount,
|
|
97
|
+
value,
|
|
98
|
+
isDisabled,
|
|
99
|
+
isInvalid,
|
|
100
|
+
isReadOnly,
|
|
101
|
+
smsOtpAutofill,
|
|
102
|
+
filter,
|
|
103
|
+
getCellProps,
|
|
104
|
+
cellTestIdPrefix,
|
|
105
|
+
rootAccessibilityLabel,
|
|
106
|
+
setFieldRef,
|
|
107
|
+
handleFieldChange,
|
|
108
|
+
handleFieldKeyPress
|
|
109
|
+
}), [cellCount, value, isDisabled, isInvalid, isReadOnly, smsOtpAutofill, filter, getCellProps, cellTestIdPrefix, rootAccessibilityLabel, setFieldRef, handleFieldChange, handleFieldKeyPress]);
|
|
110
|
+
|
|
111
|
+
// Hermes drops outer-scope closure vars from its environment record when
|
|
112
|
+
// they are only referenced inside a nested callback (Array.from). Using a
|
|
113
|
+
// for-loop keeps OtpCell/OtpField references in the render function's own
|
|
114
|
+
// scope, avoiding the Hermes closure-capture bug.
|
|
115
|
+
const cells = [];
|
|
116
|
+
for (let i = 0; i < cellCount; i++) {
|
|
117
|
+
cells.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_context.OtpCellIndexProvider, {
|
|
118
|
+
value: {
|
|
119
|
+
cellIndex: i
|
|
120
|
+
},
|
|
121
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(OtpCell, {
|
|
122
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(OtpField, {})
|
|
123
|
+
})
|
|
124
|
+
}, i));
|
|
125
|
+
}
|
|
126
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(BaseRoot, {
|
|
127
|
+
ref: ref,
|
|
128
|
+
...rest,
|
|
129
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.OtpInputProvider, {
|
|
130
|
+
value: contextValue,
|
|
131
|
+
children: cells
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
exports.createOtpInputRoot = createOtpInputRoot;
|
|
136
|
+
//# sourceMappingURL=createOtpInputRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_utils","_applyValueChange","_context","_filterValue","_jsxRuntime","createOtpInputRoot","BaseRoot","OtpCell","OtpField","forwardRef","cellCount","value","onChangeText","onComplete","isDisabled","isDisabledProp","isInvalid","isInvalidProp","isReadOnly","isReadOnlyProp","smsOtpAutofill","filterInput","allowedCharacters","characterPattern","getCellProps","cellTestIdPrefix","accessibilityLabel","rootAccessibilityLabel","rest","ref","form","useFormControlContext","fieldRefs","useRef","focusAfterApply","prevLenRef","length","prevValueRef","filter","useMemo","undefined","filterAllowedCharacters","filterByRegExp","filterDigits","setFieldRef","useCallback","index","el","current","focusCell","safe","Math","max","min","focus","handleFieldChange","text","nextValue","focusIndex","applyOtpInputChange","handleFieldKeyPress","key","char","useLayoutEffect","i","useEffect","prevLen","prevVal","isFull","becameFullByLength","correctedWhileFull","contextValue","cells","push","jsx","OtpCellIndexProvider","cellIndex","children","OtpInputProvider","exports"],"sourceRoot":"../../../src","sources":["otp-input/createOtpInputRoot.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAA4F,IAAAK,WAAA,GAAAL,OAAA;AAGrF,MAAMM,kBAAkB,GAAGA,CAChCC,QAAwC,EAExCC,OAAiC,EAEjCC,QAAkC,kBAElC,IAAAC,iBAAU,EACR,CACE;EACEC,SAAS;EACTC,KAAK;EACLC,YAAY;EACZC,UAAU;EACVC,UAAU,EAAEC,cAAc;EAC1BC,SAAS,EAAEC,aAAa;EACxBC,UAAU,EAAEC,cAAc;EAC1BC,cAAc,GAAG,IAAI;EACrBC,WAAW;EACXC,iBAAiB;EACjBC,gBAAgB;EAChBC,YAAY;EACZC,gBAAgB;EAChBC,kBAAkB,EAAEC,sBAAsB;EAC1C,GAAGC;AACL,CAAC,EACDC,GAAG,KACA;EACH,MAAMC,IAAI,GAAG,IAAAC,4BAAqB,EAAC,CAAC;EACpC,MAAMjB,UAAU,GAAGC,cAAc,IAAIe,IAAI,CAACh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EAACnE,OAAO;QAAAsE,QAAA,eACN,IAAAzE,WAAA,CAAAsE,GAAA,EAAClE,QAAQ,IAAE;MAAC,CACL;IAAC,GAHewD,CAIL,CACxB,CAAC;EACH;EAEA,oBACE,IAAA5D,WAAA,CAAAsE,GAAA,EAACpE,QAAQ;IAACuB,GAAG,EAAEA,GAA0B;IAAA,GAAMD,IAAI;IAAAiD,QAAA,eACjD,IAAAzE,WAAA,CAAAsE,GAAA,EAACxE,QAAA,CAAA4E,gBAAgB;MAACnE,KAAK,EAAE4D,YAAa;MAAAM,QAAA,EAAEL;IAAK,CAAmB;EAAC,CACzD,CAAC;AAEf,CACF,CAAC;AAACO,OAAA,CAAA1E,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "applyOtpInputChange", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _applyValueChange.applyOtpInputChange;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.createOtpInput = createOtpInput;
|
|
13
|
+
Object.defineProperty(exports, "filterAllowedCharacters", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _filterValue.filterAllowedCharacters;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "filterByRegExp", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _filterValue.filterByRegExp;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "filterDigits", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _filterValue.filterDigits;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var _createOtpInputCell = require("./createOtpInputCell");
|
|
32
|
+
var _createOtpInputField = require("./createOtpInputField");
|
|
33
|
+
var _createOtpInputRoot = require("./createOtpInputRoot");
|
|
34
|
+
var _applyValueChange = require("./utils/applyValueChange");
|
|
35
|
+
var _filterValue = require("./utils/filterValue");
|
|
36
|
+
function createOtpInput(BaseComponents) {
|
|
37
|
+
const Cell = (0, _createOtpInputCell.createOtpInputCell)(BaseComponents.Cell);
|
|
38
|
+
const Field = (0, _createOtpInputField.createOtpInputField)(BaseComponents.Field);
|
|
39
|
+
const Root = (0, _createOtpInputRoot.createOtpInputRoot)(BaseComponents.Root, Cell, Field);
|
|
40
|
+
Root.displayName = 'OtpInputPrimitive';
|
|
41
|
+
Cell.displayName = 'OtpInputPrimitive.Cell';
|
|
42
|
+
Field.displayName = 'OtpInputPrimitive.Field';
|
|
43
|
+
return Object.assign(Root, {
|
|
44
|
+
Cell,
|
|
45
|
+
Field
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_createOtpInputCell","require","_createOtpInputField","_createOtpInputRoot","_applyValueChange","_filterValue","createOtpInput","BaseComponents","Cell","createOtpInputCell","Field","createOtpInputField","Root","createOtpInputRoot","displayName","Object","assign"],"sourceRoot":"../../../src","sources":["otp-input/index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAGA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAGO,SAASK,cAAcA,CAM5BC,cAID,EAAE;EACD,MAAMC,IAAI,GAAG,IAAAC,sCAAkB,EAACF,cAAc,CAACC,IAAI,CAAC;EACpD,MAAME,KAAK,GAAG,IAAAC,wCAAmB,EAACJ,cAAc,CAACG,KAAK,CAAC;EACvD,MAAME,IAAI,GAAG,IAAAC,sCAAkB,EAACN,cAAc,CAACK,IAAI,EAAEJ,IAAI,EAAEE,KAAK,CAAC;EAEjEE,IAAI,CAACE,WAAW,GAAG,mBAAmB;EACtCN,IAAI,CAACM,WAAW,GAAG,wBAAwB;EAC3CJ,KAAK,CAACI,WAAW,GAAG,yBAAyB;EAE7C,OAAOC,MAAM,CAACC,MAAM,CAACJ,IAAI,EAAE;IACzBJ,IAAI;IACJE;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["otp-input/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyOtpInputChange = applyOtpInputChange;
|
|
7
|
+
/**
|
|
8
|
+
* Pure OTP value transition for a controlled prefix string (no explicit empty slots).
|
|
9
|
+
* - Single-character edits use index-based replace/append (no reorder).
|
|
10
|
+
* - Multi-character input (paste/autofill) writes at `index` forward, then packs left.
|
|
11
|
+
*/
|
|
12
|
+
function applyOtpInputChange(value, index, rawText, cellCount, filter) {
|
|
13
|
+
const text = filter(rawText);
|
|
14
|
+
if (text.length === 0) {
|
|
15
|
+
if (index < value.length) {
|
|
16
|
+
const next = (value.slice(0, index) + value.slice(index + 1)).slice(0, cellCount);
|
|
17
|
+
return {
|
|
18
|
+
nextValue: next,
|
|
19
|
+
focusIndex: Math.max(0, index - 1)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
nextValue: value,
|
|
24
|
+
focusIndex: index
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (text.length === 1) {
|
|
28
|
+
if (index < value.length) {
|
|
29
|
+
const next = (value.slice(0, index) + text + value.slice(index + 1)).slice(0, cellCount);
|
|
30
|
+
return {
|
|
31
|
+
nextValue: next,
|
|
32
|
+
focusIndex: Math.min(index + 1, cellCount - 1)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (value.length < cellCount) {
|
|
36
|
+
if (index === value.length) {
|
|
37
|
+
const next = (value + text).slice(0, cellCount);
|
|
38
|
+
return {
|
|
39
|
+
nextValue: next,
|
|
40
|
+
focusIndex: Math.min(next.length, cellCount - 1)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const arr = Array.from({
|
|
44
|
+
length: cellCount
|
|
45
|
+
}, (_, i) => i < value.length ? value[i] : '');
|
|
46
|
+
arr[index] = text;
|
|
47
|
+
const next = arr.filter(c => c).join('').slice(0, cellCount);
|
|
48
|
+
return {
|
|
49
|
+
nextValue: next,
|
|
50
|
+
focusIndex: Math.min(index + 1, cellCount - 1)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const next = (value.slice(0, index) + text + value.slice(index + 1)).slice(0, cellCount);
|
|
54
|
+
return {
|
|
55
|
+
nextValue: next,
|
|
56
|
+
focusIndex: Math.min(index + 1, cellCount - 1)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const arr = Array.from({
|
|
60
|
+
length: cellCount
|
|
61
|
+
}, (_, i) => i < value.length ? value[i] : '');
|
|
62
|
+
for (let k = 0; k < text.length && index + k < cellCount; k++) {
|
|
63
|
+
arr[index + k] = text.charAt(k);
|
|
64
|
+
}
|
|
65
|
+
const next = arr.filter(c => c).join('').slice(0, cellCount);
|
|
66
|
+
const lastWritten = Math.min(index + text.length - 1, cellCount - 1);
|
|
67
|
+
const focusIndex = Math.min(Math.max(lastWritten, next.length - 1), cellCount - 1);
|
|
68
|
+
return {
|
|
69
|
+
nextValue: next,
|
|
70
|
+
focusIndex: Math.max(0, focusIndex)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=applyValueChange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["applyOtpInputChange","value","index","rawText","cellCount","filter","text","length","next","slice","nextValue","focusIndex","Math","max","min","arr","Array","from","_","i","c","join","k","charAt","lastWritten"],"sourceRoot":"../../../../src","sources":["otp-input/utils/applyValueChange.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAmBA,CACjCC,KAAa,EACbC,KAAa,EACbC,OAAe,EACfC,SAAiB,EACjBC,MAAiC,EACU;EAC3C,MAAMC,IAAI,GAAGD,MAAM,CAACF,OAAO,CAAC;EAE5B,IAAIG,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IACrB,IAAIL,KAAK,GAAGD,KAAK,CAACM,MAAM,EAAE;MACxB,MAAMC,IAAI,GAAG,CAACP,KAAK,CAACQ,KAAK,CAAC,CAAC,EAAEP,KAAK,CAAC,GAAGD,KAAK,CAACQ,KAAK,CAACP,KAAK,GAAG,CAAC,CAAC,EAAEO,KAAK,CAAC,CAAC,EAAEL,SAAS,CAAC;MACjF,OAAO;QAAEM,SAAS,EAAEF,IAAI;QAAEG,UAAU,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEX,KAAK,GAAG,CAAC;MAAE,CAAC;IAChE;IACA,OAAO;MAAEQ,SAAS,EAAET,KAAK;MAAEU,UAAU,EAAET;IAAM,CAAC;EAChD;EAEA,IAAII,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IACrB,IAAIL,KAAK,GAAGD,KAAK,CAACM,MAAM,EAAE;MACxB,MAAMC,IAAI,GAAG,CAACP,KAAK,CAACQ,KAAK,CAAC,CAAC,EAAEP,KAAK,CAAC,GAAGI,IAAI,GAAGL,KAAK,CAACQ,KAAK,CAACP,KAAK,GAAG,CAAC,CAAC,EAAEO,KAAK,CAAC,CAAC,EAAEL,SAAS,CAAC;MACxF,OAAO;QAAEM,SAAS,EAAEF,IAAI;QAAEG,UAAU,EAAEC,IAAI,CAACE,GAAG,CAACZ,KAAK,GAAG,CAAC,EAAEE,SAAS,G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,GAAG,CAAC;IAAE,CAAC;EAC5E;EAEA,MAAMW,GAAG,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEV,MAAM,EAAEH;EAAU,CAAC,EAAE,CAACc,CAAC,EAAEC,CAAC,KAAMA,CAAC,GAAGlB,KAAK,CAACM,MAAM,GAAGN,KAAK,CAACkB,CAAC,CAAC,GAAG,EAAG,CAAC;EAC3F,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGhB,IAAI,CAACC,MAAM,IAAIL,KAAK,GAAGoB,CAAC,GAAGlB,SAAS,EAAEkB,CAAC,EAAE,EAAE;IAC7DP,GAAG,CAACb,KAAK,GAAGoB,CAAC,CAAC,GAAGhB,IAAI,CAACiB,MAAM,CAACD,CAAC,CAAC;EACjC;EACA,MAAMd,IAAI,GAAGO,GAAG,CACbV,MAAM,CAAEe,CAAC,IAAKA,CAAC,CAAC,CAChBC,IAAI,CAAC,EAAE,CAAC,CACRZ,KAAK,CAAC,CAAC,EAAEL,SAAS,CAAC;EACtB,MAAMoB,WAAW,GAAGZ,IAAI,CAACE,GAAG,CAACZ,KAAK,GAAGI,IAAI,CAACC,MAAM,GAAG,CAAC,EAAEH,SAAS,GAAG,CAAC,CAAC;EACpE,MAAMO,UAAU,GAAGC,IAAI,CAACE,GAAG,CAACF,IAAI,CAACC,GAAG,CAACW,WAAW,EAAEhB,IAAI,CAACD,MAAM,GAAG,CAAC,CAAC,EAAEH,SAAS,GAAG,CAAC,CAAC;EAClF,OAAO;IAAEM,SAAS,EAAEF,IAAI;IAAEG,UAAU,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEF,UAAU;EAAE,CAAC;AACjE","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.filterAllowedCharacters = filterAllowedCharacters;
|
|
7
|
+
exports.filterByRegExp = filterByRegExp;
|
|
8
|
+
exports.filterDigits = filterDigits;
|
|
9
|
+
/** Strip to digits (default OTP behavior). */
|
|
10
|
+
function filterDigits(input) {
|
|
11
|
+
return input.replace(/\D/g, '');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Keep only characters present in `allowed` (treat as a set of UTF-16 code units). */
|
|
15
|
+
function filterAllowedCharacters(allowed) {
|
|
16
|
+
const allowedSet = new Set();
|
|
17
|
+
for (let i = 0; i < allowed.length; i++) {
|
|
18
|
+
allowedSet.add(allowed.charAt(i));
|
|
19
|
+
}
|
|
20
|
+
return input => {
|
|
21
|
+
let out = '';
|
|
22
|
+
for (let i = 0; i < input.length; i++) {
|
|
23
|
+
const ch = input.charAt(i);
|
|
24
|
+
if (allowedSet.has(ch)) {
|
|
25
|
+
out += ch;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Keep only characters matching `re` (tested per UTF-16 code unit). */
|
|
33
|
+
function filterByRegExp(re) {
|
|
34
|
+
return input => {
|
|
35
|
+
let out = '';
|
|
36
|
+
for (let i = 0; i < input.length; i++) {
|
|
37
|
+
const ch = input.charAt(i);
|
|
38
|
+
re.lastIndex = 0;
|
|
39
|
+
if (re.test(ch)) {
|
|
40
|
+
out += ch;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=filterValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["filterDigits","input","replace","filterAllowedCharacters","allowed","allowedSet","Set","i","length","add","charAt","out","ch","has","filterByRegExp","re","lastIndex","test"],"sourceRoot":"../../../../src","sources":["otp-input/utils/filterValue.ts"],"mappings":";;;;;;;;AAAA;AACO,SAASA,YAAYA,CAACC,KAAa,EAAU;EAClD,OAAOA,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AACjC;;AAEA;AACO,SAASC,uBAAuBA,CAACC,OAAe,EAAE;EACvD,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAS,CAAC;EACpC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,OAAO,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACvCF,UAAU,CAACI,GAAG,CAACL,OAAO,CAACM,MAAM,CAACH,CAAC,CAAC,CAAC;EACnC;EACA,OAAQN,KAAa,IAAK;IACxB,IAAIU,GAAG,GAAG,EAAE;IACZ,KAAK,IAAIJ,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,KAAK,CAACO,MAAM,EAAED,CAAC,EAAE,EAAE;MACrC,MAAMK,EAAE,GAAGX,KAAK,CAACS,MAAM,CAACH,CAAC,CAAC;MAC1B,IAAIF,UAAU,CAACQ,GAAG,CAACD,EAAE,CAAC,EAAE;QACtBD,GAAG,IAAIC,EAAE;MACX;IACF;IACA,OAAOD,GAAG;EACZ,CAAC;AACH;;AAEA;AACO,SAASG,cAAcA,CAACC,EAAU,EAAE;EACzC,OAAQd,KAAa,IAAK;IACxB,IAAIU,GAAG,GAAG,EAAE;IACZ,KAAK,IAAIJ,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,KAAK,CAACO,MAAM,EAAED,CAAC,EAAE,EAAE;MACrC,MAAMK,EAAE,GAAGX,KAAK,CAACS,MAAM,CAACH,CAAC,CAAC;MAC1BQ,EAAE,CAACC,SAAS,GAAG,CAAC;MAChB,IAAID,EAAE,CAACE,IAAI,CAACL,EAAE,CAAC,EAAE;QACfD,GAAG,IAAIC,EAAE;MACX;IACF;IACA,OAAOD,GAAG;EACZ,CAAC;AACH","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
4
|
import { useFormControlContext } from '@cdx-ui/utils';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
export const
|
|
6
|
+
export const createFieldError = BaseFormError => /*#__PURE__*/forwardRef(({
|
|
7
7
|
children,
|
|
8
8
|
...props
|
|
9
9
|
}, ref) => {
|
|
@@ -32,4 +32,4 @@ export const createFormError = BaseFormError => /*#__PURE__*/forwardRef(({
|
|
|
32
32
|
children: children
|
|
33
33
|
}) : null;
|
|
34
34
|
});
|
|
35
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=createFieldError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useFormControlContext","jsx","_jsx","createFieldError","BaseFormError","children","props","ref","isInvalid","feedbackId","setHasFeedbackText","visible","Boolean","useEffect","undefined","id","accessibilityRole","accessibilityLiveRegion"],"sourceRoot":"../../../src","sources":["field/createFieldError.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,qBAAqB,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEtD,OAAO,MAAMC,gBAAgB,GAAQC,aAAqC,iBACxEL,UAAU,CAA0C,CAAC;EAAEM,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACnF,MAAM;IAAEC,SAAS;IAAEC,UAAU;IAAEC;EAAmB,CAAC,GAAGV,qBAAqB,CAAC,CAAC;EAE7E,MAAMW,OAAO,GAAGC,OAAO,CAACJ,SAAS,IAAIH,QAAQ,CAAC;EAE9CP,KAAK,CAACe,SAAS,CAAC,MAAM;IACpB,IAAI,CAACF,OAAO,EAAE;MACZD,kBAAkB,GAAG,KAAK,CAAC;MAC3B,OAAOI,SAAS;IAClB;IACAJ,kBAAkB,GAAG,IAAI,CAAC;IAC1B,OAAO,MAAM;MACXA,kBAAkB,GAAG,KAAK,CAAC;IAC7B,CAAC;EACH,CAAC,EAAE,CAACA,kBAAkB,EAAEC,OAAO,CAAC,CAAC;EAEjC,OAAOA,OAAO,gBACZT,IAAA,CAACE,aAAa;IACZG,GAAG,EAAEA,GAAI;IAAA,GACJD,KAAK;IACVS,EAAE,EAAEN,UAAW;IACfO,iBAAiB,EAAC,OAAO;IACzBC,uBAAuB,EAAC,WAAW;IAAAZ,QAAA,EAElCA;EAAQ,CACI,CAAC,GACd,IAAI;AACV,CAAC,CAAC","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
export const
|
|
5
|
+
export const createFieldErrorIcon = BaseFormErrorIcon => /*#__PURE__*/forwardRef(({
|
|
6
6
|
children,
|
|
7
7
|
...props
|
|
8
8
|
}, ref) => /*#__PURE__*/_jsx(BaseFormErrorIcon, {
|
|
@@ -10,4 +10,4 @@ export const createFormErrorIcon = BaseFormErrorIcon => /*#__PURE__*/forwardRef(
|
|
|
10
10
|
...props,
|
|
11
11
|
children: children
|
|
12
12
|
}));
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=createFieldErrorIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","jsx","_jsx","createFieldErrorIcon","BaseFormErrorIcon","children","props","ref"],"sourceRoot":"../../../src","sources":["field/createFieldErrorIcon.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnC,OAAO,MAAMC,oBAAoB,GAAQC,iBAAyC,iBAChFJ,UAAU,CAA0C,CAAC;EAAEK,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,kBAC9EL,IAAA,CAACE,iBAAiB;EAACG,GAAG,EAAEA,GAAI;EAAA,GAAMD,KAAK;EAAAD,QAAA,EACpCA;AAAQ,CACQ,CACpB,CAAC","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
export const
|
|
5
|
+
export const createFieldErrorText = BaseFormErrorText => /*#__PURE__*/forwardRef(({
|
|
6
6
|
children,
|
|
7
7
|
...props
|
|
8
8
|
}, ref) => /*#__PURE__*/_jsx(BaseFormErrorText, {
|
|
@@ -10,4 +10,4 @@ export const createFormErrorText = BaseFormErrorText => /*#__PURE__*/forwardRef(
|
|
|
10
10
|
...props,
|
|
11
11
|
children: children
|
|
12
12
|
}));
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=createFieldErrorText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","jsx","_jsx","createFieldErrorText","BaseFormErrorText","children","props","ref"],"sourceRoot":"../../../src","sources":["field/createFieldErrorText.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnC,OAAO,MAAMC,oBAAoB,GAAQC,iBAAyC,iBAChFJ,UAAU,CAA0C,CAAC;EAAEK,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,kBAC9EL,IAAA,CAACE,iBAAiB;EAACG,GAAG,EAAEA,GAAI;EAAA,GAAMD,KAAK;EAAAD,QAAA,EACpCA;AAAQ,CACQ,CACpB,CAAC","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React, { forwardRef } from 'react';
|
|
4
4
|
import { useFormControlContext } from '@cdx-ui/utils';
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
export const
|
|
6
|
+
export const createFieldHelper = BaseFormHelper => /*#__PURE__*/forwardRef(({
|
|
7
7
|
children,
|
|
8
8
|
...props
|
|
9
9
|
}, ref) => {
|
|
@@ -32,4 +32,4 @@ export const createFormHelper = BaseFormHelper => /*#__PURE__*/forwardRef(({
|
|
|
32
32
|
children: children
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
|
-
//# sourceMappingURL=
|
|
35
|
+
//# sourceMappingURL=createFieldHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useFormControlContext","jsx","_jsx","createFieldHelper","BaseFormHelper","children","props","ref","helpTextId","setHasHelpText","isInvalid","useEffect","undefined","id"],"sourceRoot":"../../../src","sources":["field/createFieldHelper.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,qBAAqB,QAAQ,eAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEtD,OAAO,MAAMC,iBAAiB,GAAQC,cAAsC,iBAC1EL,UAAU,CAA0C,CAAC;EAAEM,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACnF,MAAM;IAAEC,UAAU;IAAEC,cAAc;IAAEC;EAAU,CAAC,GAAGV,qBAAqB,CAAC,CAAC;EAEzEF,KAAK,CAACa,SAAS,CAAC,MAAM;IACpB,IAAID,SAAS,EAAE;MACbD,cAAc,GAAG,KAAK,CAAC;MACvB,OAAOG,SAAS;IAClB;IACAH,cAAc,GAAG,IAAI,CAAC;IACtB,OAAO,MAAM;MACXA,cAAc,GAAG,KAAK,CAAC;IACzB,CAAC;EACH,CAAC,EAAE,CAACA,cAAc,EAAEC,SAAS,CAAC,CAAC;EAE/B,IAAIA,SAAS,EAAE;IACb,OAAO,IAAI;EACb;EAEA,oBACER,IAAA,CAACE,cAAc;IAACG,GAAG,EAAEA,GAAI;IAAA,GAAMD,KAAK;IAAQO,EAAE,EAAEL,UAAW;IAAAH,QAAA,EACxDA;EAAQ,CACK,CAAC;AAErB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
export const
|
|
5
|
+
export const createFieldHelperText = BaseFormHelperText => /*#__PURE__*/forwardRef(({
|
|
6
6
|
children,
|
|
7
7
|
...props
|
|
8
8
|
}, ref) => /*#__PURE__*/_jsx(BaseFormHelperText, {
|
|
@@ -10,4 +10,4 @@ export const createFormHelperText = BaseFormHelperText => /*#__PURE__*/forwardRe
|
|
|
10
10
|
...props,
|
|
11
11
|
children: children
|
|
12
12
|
}));
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=createFieldHelperText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","jsx","_jsx","createFieldHelperText","BaseFormHelperText","children","props","ref"],"sourceRoot":"../../../src","sources":["field/createFieldHelperText.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEnC,OAAO,MAAMC,qBAAqB,GAAQC,kBAA0C,iBAClFJ,UAAU,CAA0C,CAAC;EAAEK,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,kBAC9EL,IAAA,CAACE,kBAAkB;EAACG,GAAG,EAAEA,GAAI;EAAA,GAAMD,KAAK;EAAAD,QAAA,EACrCA;AAAQ,CACS,CACrB,CAAC","ignoreList":[]}
|
|
@@ -4,9 +4,7 @@ import { forwardRef } from 'react';
|
|
|
4
4
|
import { useFormControlContext } from '@cdx-ui/utils';
|
|
5
5
|
import { dataAttributes } from '../utils/dataAttributes';
|
|
6
6
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
export const
|
|
8
|
-
Label: BaseFormLabel
|
|
9
|
-
}) => /*#__PURE__*/forwardRef(({
|
|
7
|
+
export const createFieldLabel = BaseFormLabel => /*#__PURE__*/forwardRef(({
|
|
10
8
|
children,
|
|
11
9
|
htmlFor: htmlForProp,
|
|
12
10
|
requiredIndicator,
|
|
@@ -30,4 +28,4 @@ export const createFormLabel = ({
|
|
|
30
28
|
children: [children, field.isRequired ? requiredIndicator : null]
|
|
31
29
|
});
|
|
32
30
|
});
|
|
33
|
-
//# sourceMappingURL=
|
|
31
|
+
//# sourceMappingURL=createFieldLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useFormControlContext","dataAttributes","jsxs","_jsxs","createFieldLabel","BaseFormLabel","children","htmlFor","htmlForProp","requiredIndicator","props","ref","field","fieldId","id","labelId","undefined","invalid","isInvalid","required","isRequired"],"sourceRoot":"../../../src","sources":["field/createFieldLabel.tsx"],"mappings":";;AACA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,cAAc,QAAQ,yBAAyB;AAAC,SAAAC,IAAA,IAAAC,KAAA;AAGzD,OAAO,MAAMC,gBAAgB,GAAQC,aAAqC,iBACxEN,UAAU,CACR,CAAC;EAAEO,QAAQ;EAAEC,OAAO,EAAEC,WAAW;EAAEC,iBAAiB;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EACxE,MAAMC,KAAK,GAAGZ,qBAAqB,CAAC,CAAC;EACrC,MAAMa,OAAO,GAAGD,KAAK,CAACE,EAAE;EACxB,MAAMC,OAAO,GAAGH,KAAK,CAACG,OAAO;;EAE7B;EACA,MAAMR,OAAO,GAAGC,WAAW,KAAKK,OAAO,GAAG,GAAGA,OAAO,QAAQ,GAAGG,SAAS,CAAC;EAEzE,oBACEb,KAAA,CAACE,aAAa;IACZM,GAAG,EAAEA,GAAI;IAAA,GACJD,KAAK;IACVI,EAAE,EAAEC,OAAQ;IACZR,OAAO,EAAEA,OAAQ;IAAA,GACbN,cAAc,CAAC;MAAEgB,OAAO,EAAEL,KAAK,CAACM,SAAS;MAAEC,QAAQ,EAAEP,KAAK,CAACQ;IAAW,CAAC,CAAC;IAAAd,QAAA,GAE3EA,QAAQ,EACRM,KAAK,CAACQ,UAAU,GAAGX,iBAAiB,GAAG,IAAI;EAAA,CAC/B,CAAC;AAEpB,CACF,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ import React, { forwardRef } from 'react';
|
|
|
4
4
|
import { useFormControlRoot, FormControlContext } from '@cdx-ui/utils';
|
|
5
5
|
import { dataAttributes } from '../utils/dataAttributes';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
export const
|
|
7
|
+
export const createFieldRoot = BaseFormField => /*#__PURE__*/forwardRef(({
|
|
8
8
|
children,
|
|
9
9
|
...props
|
|
10
10
|
}, ref) => {
|
|
@@ -26,4 +26,4 @@ export const createFormField = BaseFormField => /*#__PURE__*/forwardRef(({
|
|
|
26
26
|
})
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
|
-
//# sourceMappingURL=
|
|
29
|
+
//# sourceMappingURL=createFieldRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useFormControlRoot","FormControlContext","dataAttributes","jsx","_jsx","createFieldRoot","BaseFormField","children","props","ref","htmlProps","context","Provider","value","disabled","isDisabled","invalid","isInvalid","required","isRequired"],"sourceRoot":"../../../src","sources":["field/createFieldRoot.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,kBAAkB,EAAEC,kBAAkB,QAAQ,eAAe;AACtE,SAASC,cAAc,QAAQ,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGzD,OAAO,MAAMC,eAAe,GAAQC,aAAqC,iBACvEP,UAAU,CACR,CAAC;EAAEQ,QAAQ;EAAE,GAAGC;AAAwD,CAAC,EAAEC,GAAa,KAAK;EAC3F,MAAM;IAAEC,SAAS;IAAE,GAAGC;EAAQ,CAAC,GAAGX,kBAAkB,CAACQ,KAAK,CAAC;EAE3D,oBACEJ,IAAA,CAACH,kBAAkB,CAACW,QAAQ;IAACC,KAAK,EAAEF,OAAQ;IAAAJ,QAAA,eAC1CH,IAAA,CAACE,aAAa;MACZG,GAAG,EAAEA,GAAI;MAAA,GACJC,SAAS;MAAA,GACVR,cAAc,CAAC;QACjBY,QAAQ,EAAEH,OAAO,CAACI,UAAU;QAC5BC,OAAO,EAAEL,OAAO,CAACM,SAAS;QAC1BC,QAAQ,EAAEP,OAAO,CAACQ;MACpB,CAAC,CAAC;MAAAZ,QAAA,EAEDA;IAAQ,CACI;EAAC,CACW,CAAC;AAElC,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createFieldError } from './createFieldError';
|
|
4
|
+
import { createFieldErrorIcon } from './createFieldErrorIcon';
|
|
5
|
+
import { createFieldErrorText } from './createFieldErrorText';
|
|
6
|
+
import { createFieldRoot } from './createFieldRoot';
|
|
7
|
+
import { createFieldHelper } from './createFieldHelper';
|
|
8
|
+
import { createFieldHelperText } from './createFieldHelperText';
|
|
9
|
+
import { createFieldLabel } from './createFieldLabel';
|
|
10
|
+
export function createField({
|
|
11
|
+
Root,
|
|
12
|
+
Label,
|
|
13
|
+
Helper,
|
|
14
|
+
HelperText,
|
|
15
|
+
Error,
|
|
16
|
+
ErrorText,
|
|
17
|
+
ErrorIcon
|
|
18
|
+
}) {
|
|
19
|
+
const FieldRoot = createFieldRoot(Root);
|
|
20
|
+
FieldRoot.displayName = 'FieldPrimitive';
|
|
21
|
+
const FieldLabel = createFieldLabel(Label);
|
|
22
|
+
FieldLabel.displayName = 'FieldPrimitive.Label';
|
|
23
|
+
const FieldHelper = createFieldHelper(Helper);
|
|
24
|
+
FieldHelper.displayName = 'FieldPrimitive.Helper';
|
|
25
|
+
const FieldHelperText = createFieldHelperText(HelperText);
|
|
26
|
+
FieldHelperText.displayName = 'FieldPrimitive.HelperText';
|
|
27
|
+
const FieldError = createFieldError(Error);
|
|
28
|
+
FieldError.displayName = 'FieldPrimitive.Error';
|
|
29
|
+
const FieldErrorText = createFieldErrorText(ErrorText);
|
|
30
|
+
FieldErrorText.displayName = 'FieldPrimitive.ErrorText';
|
|
31
|
+
const FieldErrorIcon = createFieldErrorIcon(ErrorIcon);
|
|
32
|
+
FieldErrorIcon.displayName = 'FieldPrimitive.ErrorIcon';
|
|
33
|
+
return Object.assign(FieldRoot, {
|
|
34
|
+
Label: FieldLabel,
|
|
35
|
+
Helper: FieldHelper,
|
|
36
|
+
HelperText: FieldHelperText,
|
|
37
|
+
Error: FieldError,
|
|
38
|
+
ErrorText: FieldErrorText,
|
|
39
|
+
ErrorIcon: FieldErrorIcon
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFieldError","createFieldErrorIcon","createFieldErrorText","createFieldRoot","createFieldHelper","createFieldHelperText","createFieldLabel","createField","Root","Label","Helper","HelperText","Error","ErrorText","ErrorIcon","FieldRoot","displayName","FieldLabel","FieldHelper","FieldHelperText","FieldError","FieldErrorText","FieldErrorIcon","Object","assign"],"sourceRoot":"../../../src","sources":["field/index.tsx"],"mappings":";;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,gBAAgB,QAAQ,oBAAoB;AAcrD,OAAO,SAASC,WAAWA,CAA+D;EACxFC,IAAI;EACJC,KAAK;EACLC,MAAM;EACNC,UAAU;EACVC,KAAK;EACLC,SAAS;EACTC;AASF,CAAC,EAAE;EACD,MAAMC,SAAS,GAAGZ,eAAe,CAACK,IAAI,CAAC;EACvCO,SAAS,CAACC,WAAW,GAAG,gBAAgB;EAExC,MAAMC,UAAU,GAAGX,gBAAgB,CAACG,KAAK,CAAC;EAC1CQ,UAAU,CAACD,WAAW,GAAG,sBAAsB;EAE/C,MAAME,WAAW,GAAGd,iBAAiB,CAACM,MAAM,CAAC;EAC7CQ,WAAW,CAACF,WAAW,GAAG,uBAAuB;EAEjD,MAAMG,eAAe,GAAGd,qBAAqB,CAACM,UAAU,CAAC;EACzDQ,eAAe,CAACH,WAAW,GAAG,2BAA2B;EAEzD,MAAMI,UAAU,GAAGpB,gBAAgB,CAACY,KAAK,CAAC;EAC1CQ,UAAU,CAACJ,WAAW,GAAG,sBAAsB;EAE/C,MAAMK,cAAc,GAAGnB,oBAAoB,CAACW,SAAS,CAAC;EACtDQ,cAAc,CAACL,WAAW,GAAG,0BAA0B;EAEvD,MAAMM,cAAc,GAAGrB,oBAAoB,CAACa,SAAS,CAAC;EACtDQ,cAAc,CAACN,WAAW,GAAG,0BAA0B;EAEvD,OAAOO,MAAM,CAACC,MAAM,CAACT,SAAS,EAAE;IAC9BN,KAAK,EAAEQ,UAAU;IACjBP,MAAM,EAAEQ,WAAW;IACnBP,UAAU,EAAEQ,eAAe;IAC3BP,KAAK,EAAEQ,UAAU;IACjBP,SAAS,EAAEQ,cAAc;IACzBP,SAAS,EAAEQ;EACb,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["field/types.tsx"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","jsx","_jsx","createFormRoot","BaseFormRoot","children","props","ref"],"sourceRoot":"../../../src","sources":["form/createFormRoot.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG1C;;AAEA,OAAO,MAAMC,cAAc,GAAQC,YAAoC,iBACrEJ,UAAU,CACR,CAAC;EAAEK,QAAQ;EAAE,GAAGC;AAAuD,CAAC,EAAEC,GAAa,kBACrFL,IAAA,CAACE,YAAY;EAACG,GAAG,EAAEA,GAAI;EAAA,GAAMD,KAAK;EAAAD,QAAA,EAC/BA;AAAQ,CACG,CAElB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFormRoot","createForm","Root","FormRoot","displayName"],"sourceRoot":"../../../src","sources":["form/index.tsx"],"mappings":";;AACA,SAASA,cAAc,QAAQ,kBAAkB;AAIjD,OAAO,SAASC,UAAUA,CAAO;EAAEC;AAA0C,CAAC,EAAE;EAC9E,MAAMC,QAAQ,GAAGH,cAAc,CAACE,IAAI,CAAC;EAErCC,QAAQ,CAACC,WAAW,GAAG,eAAe;EAEtC,OAAOD,QAAQ;AACjB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["form/types.tsx"],"mappings":"","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -4,8 +4,10 @@ export * from './avatar';
|
|
|
4
4
|
export * from './button';
|
|
5
5
|
export * from './checkbox';
|
|
6
6
|
export * from './dialog';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './field';
|
|
8
|
+
export * from './form';
|
|
8
9
|
export * from './input';
|
|
10
|
+
export * from './otp-input';
|
|
9
11
|
export * from './link';
|
|
10
12
|
export { OverlayInsetsProvider } from './overlay';
|
|
11
13
|
export * from './select';
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OverlayInsetsProvider","dataAttributes"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,
|
|
1
|
+
{"version":3,"names":["OverlayInsetsProvider","dataAttributes"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,QAAQ;AACtB,SAA0BA,qBAAqB,QAAQ,WAAW;AAClE,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,YAAY;AAE1B,SAASC,cAAc,QAAQ,wBAAwB","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createContext } from '@cdx-ui/utils';
|
|
4
|
+
export const [OtpInputProvider, useOtpInputContext] = createContext('OtpInputContext');
|
|
5
|
+
export const [OtpCellIndexProvider, useOtpCellIndexContext] = createContext('OtpCellIndexContext');
|
|
6
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","OtpInputProvider","useOtpInputContext","OtpCellIndexProvider","useOtpCellIndexContext"],"sourceRoot":"../../../src","sources":["otp-input/context.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,eAAe;AAG7C,OAAO,MAAM,CAACC,gBAAgB,EAAEC,kBAAkB,CAAC,GACjDF,aAAa,CAAuB,iBAAiB,CAAC;AAExD,OAAO,MAAM,CAACG,oBAAoB,EAAEC,sBAAsB,CAAC,GACzDJ,aAAa,CAAgC,qBAAqB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { useOtpInputContext } from './context';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export const createOtpInputCell = BaseCell => /*#__PURE__*/forwardRef(({
|
|
7
|
+
children,
|
|
8
|
+
...props
|
|
9
|
+
}, ref) => {
|
|
10
|
+
const {
|
|
11
|
+
isDisabled,
|
|
12
|
+
isInvalid,
|
|
13
|
+
isReadOnly
|
|
14
|
+
} = useOtpInputContext();
|
|
15
|
+
return /*#__PURE__*/_jsx(BaseCell, {
|
|
16
|
+
ref: ref,
|
|
17
|
+
isDisabled: isDisabled,
|
|
18
|
+
isInvalid: isInvalid,
|
|
19
|
+
isReadOnly: isReadOnly,
|
|
20
|
+
...props,
|
|
21
|
+
children: children
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=createOtpInputCell.js.map
|