@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.
Files changed (188) hide show
  1. package/lib/commonjs/{form-control/createFormError.js → field/createFieldError.js} +4 -4
  2. package/lib/commonjs/field/createFieldError.js.map +1 -0
  3. package/lib/commonjs/{form-control/createFormErrorIcon.js → field/createFieldErrorIcon.js} +4 -4
  4. package/lib/commonjs/field/createFieldErrorIcon.js.map +1 -0
  5. package/lib/commonjs/{form-control/createFormErrorText.js → field/createFieldErrorText.js} +4 -4
  6. package/lib/commonjs/field/createFieldErrorText.js.map +1 -0
  7. package/lib/commonjs/{form-control/createFormHelper.js → field/createFieldHelper.js} +4 -4
  8. package/lib/commonjs/field/createFieldHelper.js.map +1 -0
  9. package/lib/commonjs/{form-control/createFormHelperText.js → field/createFieldHelperText.js} +4 -4
  10. package/lib/commonjs/field/createFieldHelperText.js.map +1 -0
  11. package/lib/commonjs/{form-control/createFormLabel.js → field/createFieldLabel.js} +4 -6
  12. package/lib/commonjs/field/createFieldLabel.js.map +1 -0
  13. package/lib/commonjs/{form-control/createFormField.js → field/createFieldRoot.js} +4 -4
  14. package/lib/commonjs/field/createFieldRoot.js.map +1 -0
  15. package/lib/commonjs/field/index.js +46 -0
  16. package/lib/commonjs/field/index.js.map +1 -0
  17. package/lib/commonjs/{form-control → field}/types.js.map +1 -1
  18. package/lib/commonjs/form/createFormRoot.js.map +1 -0
  19. package/lib/commonjs/form/index.js +15 -0
  20. package/lib/commonjs/form/index.js.map +1 -0
  21. package/lib/commonjs/form/types.js +6 -0
  22. package/lib/{module/form-control → commonjs/form}/types.js.map +1 -1
  23. package/lib/commonjs/index.js +28 -4
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/otp-input/context.js +14 -0
  26. package/lib/commonjs/otp-input/context.js.map +1 -0
  27. package/lib/commonjs/otp-input/createOtpInputCell.js +29 -0
  28. package/lib/commonjs/otp-input/createOtpInputCell.js.map +1 -0
  29. package/lib/commonjs/otp-input/createOtpInputField.js +104 -0
  30. package/lib/commonjs/otp-input/createOtpInputField.js.map +1 -0
  31. package/lib/commonjs/otp-input/createOtpInputRoot.js +136 -0
  32. package/lib/commonjs/otp-input/createOtpInputRoot.js.map +1 -0
  33. package/lib/commonjs/otp-input/index.js +48 -0
  34. package/lib/commonjs/otp-input/index.js.map +1 -0
  35. package/lib/commonjs/otp-input/types.js +6 -0
  36. package/lib/commonjs/otp-input/types.js.map +1 -0
  37. package/lib/commonjs/otp-input/utils/applyValueChange.js +73 -0
  38. package/lib/commonjs/otp-input/utils/applyValueChange.js.map +1 -0
  39. package/lib/commonjs/otp-input/utils/filterValue.js +46 -0
  40. package/lib/commonjs/otp-input/utils/filterValue.js.map +1 -0
  41. package/lib/module/{form-control/createFormError.js → field/createFieldError.js} +2 -2
  42. package/lib/module/field/createFieldError.js.map +1 -0
  43. package/lib/module/{form-control/createFormErrorIcon.js → field/createFieldErrorIcon.js} +2 -2
  44. package/lib/module/field/createFieldErrorIcon.js.map +1 -0
  45. package/lib/module/{form-control/createFormErrorText.js → field/createFieldErrorText.js} +2 -2
  46. package/lib/module/field/createFieldErrorText.js.map +1 -0
  47. package/lib/module/{form-control/createFormHelper.js → field/createFieldHelper.js} +2 -2
  48. package/lib/module/field/createFieldHelper.js.map +1 -0
  49. package/lib/module/{form-control/createFormHelperText.js → field/createFieldHelperText.js} +2 -2
  50. package/lib/module/field/createFieldHelperText.js.map +1 -0
  51. package/lib/module/{form-control/createFormLabel.js → field/createFieldLabel.js} +2 -4
  52. package/lib/module/field/createFieldLabel.js.map +1 -0
  53. package/lib/module/{form-control/createFormField.js → field/createFieldRoot.js} +2 -2
  54. package/lib/module/field/createFieldRoot.js.map +1 -0
  55. package/lib/module/field/index.js +42 -0
  56. package/lib/module/field/index.js.map +1 -0
  57. package/lib/module/field/types.js.map +1 -0
  58. package/lib/module/form/createFormRoot.js.map +1 -0
  59. package/lib/module/form/index.js +11 -0
  60. package/lib/module/form/index.js.map +1 -0
  61. package/lib/module/form/types.js +4 -0
  62. package/lib/module/form/types.js.map +1 -0
  63. package/lib/module/index.js +3 -1
  64. package/lib/module/index.js.map +1 -1
  65. package/lib/module/otp-input/context.js +6 -0
  66. package/lib/module/otp-input/context.js.map +1 -0
  67. package/lib/module/otp-input/createOtpInputCell.js +24 -0
  68. package/lib/module/otp-input/createOtpInputCell.js.map +1 -0
  69. package/lib/module/otp-input/createOtpInputField.js +99 -0
  70. package/lib/module/otp-input/createOtpInputField.js.map +1 -0
  71. package/lib/module/otp-input/createOtpInputRoot.js +131 -0
  72. package/lib/module/otp-input/createOtpInputRoot.js.map +1 -0
  73. package/lib/module/otp-input/index.js +20 -0
  74. package/lib/module/otp-input/index.js.map +1 -0
  75. package/lib/module/otp-input/types.js +4 -0
  76. package/lib/module/otp-input/types.js.map +1 -0
  77. package/lib/module/otp-input/utils/applyValueChange.js +69 -0
  78. package/lib/module/otp-input/utils/applyValueChange.js.map +1 -0
  79. package/lib/module/otp-input/utils/filterValue.js +40 -0
  80. package/lib/module/otp-input/utils/filterValue.js.map +1 -0
  81. package/lib/typescript/field/createFieldError.d.ts +5 -0
  82. package/lib/typescript/field/createFieldError.d.ts.map +1 -0
  83. package/lib/typescript/field/createFieldErrorIcon.d.ts +5 -0
  84. package/lib/typescript/field/createFieldErrorIcon.d.ts.map +1 -0
  85. package/lib/typescript/field/createFieldErrorText.d.ts +5 -0
  86. package/lib/typescript/field/createFieldErrorText.d.ts.map +1 -0
  87. package/lib/typescript/field/createFieldHelper.d.ts +5 -0
  88. package/lib/typescript/field/createFieldHelper.d.ts.map +1 -0
  89. package/lib/typescript/field/createFieldHelperText.d.ts +5 -0
  90. package/lib/typescript/field/createFieldHelperText.d.ts.map +1 -0
  91. package/lib/typescript/field/createFieldLabel.d.ts +6 -0
  92. package/lib/typescript/field/createFieldLabel.d.ts.map +1 -0
  93. package/lib/typescript/field/createFieldRoot.d.ts +6 -0
  94. package/lib/typescript/field/createFieldRoot.d.ts.map +1 -0
  95. package/lib/typescript/field/index.d.ts +13 -0
  96. package/lib/typescript/field/index.d.ts.map +1 -0
  97. package/lib/typescript/{form-control → field}/types.d.ts +14 -24
  98. package/lib/typescript/field/types.d.ts.map +1 -0
  99. package/lib/typescript/form/createFormRoot.d.ts +4 -0
  100. package/lib/typescript/form/createFormRoot.d.ts.map +1 -0
  101. package/lib/typescript/form/index.d.ts +6 -0
  102. package/lib/typescript/form/index.d.ts.map +1 -0
  103. package/lib/typescript/form/types.d.ts +14 -0
  104. package/lib/typescript/form/types.d.ts.map +1 -0
  105. package/lib/typescript/index.d.ts +3 -1
  106. package/lib/typescript/index.d.ts.map +1 -1
  107. package/lib/typescript/otp-input/context.d.ts +10 -0
  108. package/lib/typescript/otp-input/context.d.ts.map +1 -0
  109. package/lib/typescript/otp-input/createOtpInputCell.d.ts +4 -0
  110. package/lib/typescript/otp-input/createOtpInputCell.d.ts.map +1 -0
  111. package/lib/typescript/otp-input/createOtpInputField.d.ts +4 -0
  112. package/lib/typescript/otp-input/createOtpInputField.d.ts.map +1 -0
  113. package/lib/typescript/otp-input/createOtpInputRoot.d.ts +4 -0
  114. package/lib/typescript/otp-input/createOtpInputRoot.d.ts.map +1 -0
  115. package/lib/typescript/otp-input/index.d.ts +11 -0
  116. package/lib/typescript/otp-input/index.d.ts.map +1 -0
  117. package/lib/typescript/otp-input/types.d.ts +75 -0
  118. package/lib/typescript/otp-input/types.d.ts.map +1 -0
  119. package/lib/typescript/otp-input/utils/applyValueChange.d.ts +10 -0
  120. package/lib/typescript/otp-input/utils/applyValueChange.d.ts.map +1 -0
  121. package/lib/typescript/otp-input/utils/filterValue.d.ts +7 -0
  122. package/lib/typescript/otp-input/utils/filterValue.d.ts.map +1 -0
  123. package/package.json +2 -2
  124. package/src/{form-control/createFormError.tsx → field/createFieldError.tsx} +1 -1
  125. package/src/{form-control/createFormErrorIcon.tsx → field/createFieldErrorIcon.tsx} +1 -1
  126. package/src/{form-control/createFormErrorText.tsx → field/createFieldErrorText.tsx} +1 -1
  127. package/src/{form-control/createFormHelper.tsx → field/createFieldHelper.tsx} +1 -1
  128. package/src/{form-control/createFormHelperText.tsx → field/createFieldHelperText.tsx} +1 -1
  129. package/src/{form-control/createFormLabel.tsx → field/createFieldLabel.tsx} +3 -3
  130. package/src/{form-control/createFormField.tsx → field/createFieldRoot.tsx} +3 -3
  131. package/src/field/index.tsx +68 -0
  132. package/src/{form-control → field}/types.tsx +28 -42
  133. package/src/{form-control → form}/createFormRoot.tsx +3 -3
  134. package/src/form/index.tsx +12 -0
  135. package/src/form/types.tsx +16 -0
  136. package/src/index.ts +3 -1
  137. package/src/otp-input/context.tsx +8 -0
  138. package/src/otp-input/createOtpInputCell.tsx +22 -0
  139. package/src/otp-input/createOtpInputField.tsx +98 -0
  140. package/src/otp-input/createOtpInputRoot.tsx +179 -0
  141. package/src/otp-input/index.tsx +34 -0
  142. package/src/otp-input/types.ts +92 -0
  143. package/src/otp-input/utils/applyValueChange.ts +56 -0
  144. package/src/otp-input/utils/filterValue.ts +37 -0
  145. package/lib/commonjs/form-control/createFormError.js.map +0 -1
  146. package/lib/commonjs/form-control/createFormErrorIcon.js.map +0 -1
  147. package/lib/commonjs/form-control/createFormErrorText.js.map +0 -1
  148. package/lib/commonjs/form-control/createFormField.js.map +0 -1
  149. package/lib/commonjs/form-control/createFormHelper.js.map +0 -1
  150. package/lib/commonjs/form-control/createFormHelperText.js.map +0 -1
  151. package/lib/commonjs/form-control/createFormLabel.js.map +0 -1
  152. package/lib/commonjs/form-control/createFormRoot.js.map +0 -1
  153. package/lib/commonjs/form-control/index.js +0 -53
  154. package/lib/commonjs/form-control/index.js.map +0 -1
  155. package/lib/module/form-control/createFormError.js.map +0 -1
  156. package/lib/module/form-control/createFormErrorIcon.js.map +0 -1
  157. package/lib/module/form-control/createFormErrorText.js.map +0 -1
  158. package/lib/module/form-control/createFormField.js.map +0 -1
  159. package/lib/module/form-control/createFormHelper.js.map +0 -1
  160. package/lib/module/form-control/createFormHelperText.js.map +0 -1
  161. package/lib/module/form-control/createFormLabel.js.map +0 -1
  162. package/lib/module/form-control/createFormRoot.js.map +0 -1
  163. package/lib/module/form-control/index.js +0 -49
  164. package/lib/module/form-control/index.js.map +0 -1
  165. package/lib/typescript/form-control/createFormError.d.ts +0 -5
  166. package/lib/typescript/form-control/createFormError.d.ts.map +0 -1
  167. package/lib/typescript/form-control/createFormErrorIcon.d.ts +0 -5
  168. package/lib/typescript/form-control/createFormErrorIcon.d.ts.map +0 -1
  169. package/lib/typescript/form-control/createFormErrorText.d.ts +0 -5
  170. package/lib/typescript/form-control/createFormErrorText.d.ts.map +0 -1
  171. package/lib/typescript/form-control/createFormField.d.ts +0 -6
  172. package/lib/typescript/form-control/createFormField.d.ts.map +0 -1
  173. package/lib/typescript/form-control/createFormHelper.d.ts +0 -5
  174. package/lib/typescript/form-control/createFormHelper.d.ts.map +0 -1
  175. package/lib/typescript/form-control/createFormHelperText.d.ts +0 -5
  176. package/lib/typescript/form-control/createFormHelperText.d.ts.map +0 -1
  177. package/lib/typescript/form-control/createFormLabel.d.ts +0 -8
  178. package/lib/typescript/form-control/createFormLabel.d.ts.map +0 -1
  179. package/lib/typescript/form-control/createFormRoot.d.ts +0 -6
  180. package/lib/typescript/form-control/createFormRoot.d.ts.map +0 -1
  181. package/lib/typescript/form-control/index.d.ts +0 -14
  182. package/lib/typescript/form-control/index.d.ts.map +0 -1
  183. package/lib/typescript/form-control/types.d.ts.map +0 -1
  184. package/src/form-control/index.tsx +0 -71
  185. /package/lib/commonjs/{form-control → field}/types.js +0 -0
  186. /package/lib/commonjs/{form-control → form}/createFormRoot.js +0 -0
  187. /package/lib/module/{form-control → field}/types.js +0 -0
  188. /package/lib/module/{form-control → form}/createFormRoot.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useOtpInputContext","jsx","_jsx","createOtpInputCell","BaseCell","children","props","ref","isDisabled","isInvalid","isReadOnly"],"sourceRoot":"../../../src","sources":["otp-input/createOtpInputCell.tsx"],"mappings":";;AAEA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,kBAAkB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG/C,OAAO,MAAMC,kBAAkB,GAAQC,QAAgC,iBACrEL,UAAU,CAAqD,CAAC;EAAEM,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC9F,MAAM;IAAEC,UAAU;IAAEC,SAAS;IAAEC;EAAW,CAAC,GAAGV,kBAAkB,CAAC,CAAC;EAElE,oBACEE,IAAA,CAACE,QAAQ;IACPG,GAAG,EAAEA,GAAI;IACTC,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA,SAAU;IACrBC,UAAU,EAAEA,UAAW;IAAA,GAClBJ,KAAK;IAAAD,QAAA,EAETA;EAAQ,CACD,CAAC;AAEf,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ import { forwardRef, useMemo } from 'react';
4
+ import { Platform } from 'react-native';
5
+ import { mergeRefs } from '@cdx-ui/utils';
6
+ import { useOtpCellIndexContext, useOtpInputContext } from './context';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ export const createOtpInputField = BaseField => /*#__PURE__*/forwardRef((props, ref) => {
9
+ const {
10
+ cellIndex
11
+ } = useOtpCellIndexContext();
12
+ const {
13
+ value,
14
+ cellCount,
15
+ isDisabled,
16
+ isReadOnly,
17
+ smsOtpAutofill,
18
+ getCellProps,
19
+ cellTestIdPrefix,
20
+ rootAccessibilityLabel,
21
+ setFieldRef,
22
+ handleFieldChange,
23
+ handleFieldKeyPress
24
+ } = useOtpInputContext();
25
+ const char = cellIndex < value.length ? value[cellIndex] ?? '' : '';
26
+ const extra = getCellProps?.(cellIndex) ?? {};
27
+ const accessibilityLabel = useMemo(() => {
28
+ const fromExtra = extra.accessibilityLabel;
29
+ if (typeof fromExtra === 'string' && fromExtra !== '') {
30
+ return fromExtra;
31
+ }
32
+ if (rootAccessibilityLabel) {
33
+ return `${rootAccessibilityLabel}, ${String(cellIndex + 1)} of ${String(cellCount)}`;
34
+ }
35
+ return `OTP digit ${String(cellIndex + 1)} of ${String(cellCount)}`;
36
+ }, [cellCount, cellIndex, extra.accessibilityLabel, rootAccessibilityLabel]);
37
+ const autofillProps = useMemo(() => {
38
+ if (!smsOtpAutofill || cellIndex !== 0) {
39
+ return {};
40
+ }
41
+ return Platform.select({
42
+ web: {
43
+ autoComplete: 'one-time-code'
44
+ },
45
+ ios: {
46
+ textContentType: 'oneTimeCode'
47
+ },
48
+ android: {
49
+ autoComplete: 'sms-otp'
50
+ },
51
+ default: {}
52
+ });
53
+ }, [cellIndex, smsOtpAutofill]);
54
+ const editable = !(isDisabled || isReadOnly);
55
+ const {
56
+ style: extraStyle,
57
+ accessibilityLabel: _omitExtraA11y,
58
+ ...extraRest
59
+ } = extra;
60
+ void _omitExtraA11y;
61
+ const {
62
+ style: incomingStyle,
63
+ value: _omitValue,
64
+ defaultValue: _omitDefault,
65
+ onChangeText: _omitOnChange,
66
+ ...incomingRest
67
+ } = props;
68
+ void _omitValue;
69
+ void _omitDefault;
70
+ void _omitOnChange;
71
+
72
+ // Default digit OTP (`number-pad`). Root `getCellProps` is spread after and may override `keyboardType`.
73
+ return /*#__PURE__*/_jsx(BaseField, {
74
+ ref: mergeRefs(ref, el => {
75
+ setFieldRef(cellIndex, el);
76
+ }),
77
+ accessibilityLabel: accessibilityLabel,
78
+ "aria-label": accessibilityLabel,
79
+ accessible: true,
80
+ autoFocus: cellIndex === 0 && editable && value.length === 0,
81
+ editable: editable,
82
+ keyboardType: "number-pad",
83
+ returnKeyType: "done",
84
+ selectTextOnFocus: true,
85
+ testID: cellTestIdPrefix ? `${cellTestIdPrefix}:${String(cellIndex)}:textField:changeText` : undefined,
86
+ value: char,
87
+ onChangeText: text => {
88
+ handleFieldChange(cellIndex, text);
89
+ },
90
+ onKeyPress: e => {
91
+ handleFieldKeyPress(cellIndex, e.nativeEvent.key);
92
+ },
93
+ ...autofillProps,
94
+ ...extraRest,
95
+ ...incomingRest,
96
+ style: [extraStyle, incomingStyle]
97
+ });
98
+ });
99
+ //# sourceMappingURL=createOtpInputField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useMemo","Platform","mergeRefs","useOtpCellIndexContext","useOtpInputContext","jsx","_jsx","createOtpInputField","BaseField","props","ref","cellIndex","value","cellCount","isDisabled","isReadOnly","smsOtpAutofill","getCellProps","cellTestIdPrefix","rootAccessibilityLabel","setFieldRef","handleFieldChange","handleFieldKeyPress","char","length","extra","accessibilityLabel","fromExtra","String","autofillProps","select","web","autoComplete","ios","textContentType","android","default","editable","style","extraStyle","_omitExtraA11y","extraRest","incomingStyle","_omitValue","defaultValue","_omitDefault","onChangeText","_omitOnChange","incomingRest","el","accessible","autoFocus","keyboardType","returnKeyType","selectTextOnFocus","testID","undefined","text","onKeyPress","e","nativeEvent","key"],"sourceRoot":"../../../src","sources":["otp-input/createOtpInputField.tsx"],"mappings":";;AACA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAASC,QAAQ,QAAqD,cAAc;AACpF,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGvE,OAAO,MAAMC,mBAAmB,GAAQC,SAAiC,iBACvET,UAAU,CAAsE,CAACU,KAAK,EAAEC,GAAG,KAAK;EAC9F,MAAM;IAAEC;EAAU,CAAC,GAAGR,sBAAsB,CAAC,CAAC;EAC9C,MAAM;IACJS,KAAK;IACLC,SAAS;IACTC,UAAU;IACVC,UAAU;IACVC,cAAc;IACdC,YAAY;IACZC,gBAAgB;IAChBC,sBAAsB;IACtBC,WAAW;IACXC,iBAAiB;IACjBC;EACF,CAAC,GAAGlB,kBAAkB,CAAC,CAAC;EAExB,MAAMmB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1,131 @@
1
+ "use strict";
2
+
3
+ import { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
4
+ import { useFormControlContext } from '@cdx-ui/utils';
5
+ import { applyOtpInputChange } from './utils/applyValueChange';
6
+ import { OtpCellIndexProvider, OtpInputProvider } from './context';
7
+ import { filterAllowedCharacters, filterByRegExp, filterDigits } from './utils/filterValue';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ export const createOtpInputRoot = (BaseRoot, OtpCell, OtpField) => /*#__PURE__*/forwardRef(({
10
+ cellCount,
11
+ value,
12
+ onChangeText,
13
+ onComplete,
14
+ isDisabled: isDisabledProp,
15
+ isInvalid: isInvalidProp,
16
+ isReadOnly: isReadOnlyProp,
17
+ smsOtpAutofill = true,
18
+ filterInput,
19
+ allowedCharacters,
20
+ characterPattern,
21
+ getCellProps,
22
+ cellTestIdPrefix,
23
+ accessibilityLabel: rootAccessibilityLabel,
24
+ ...rest
25
+ }, ref) => {
26
+ const form = useFormControlContext();
27
+ const isDisabled = isDisabledProp ?? form.isDisabled ?? false;
28
+ const isInvalid = isInvalidProp ?? form.isInvalid ?? false;
29
+ const isReadOnly = isReadOnlyProp ?? form.isReadOnly ?? false;
30
+ const fieldRefs = useRef([]);
31
+ const focusAfterApply = useRef(null);
32
+ const prevLenRef = useRef(value.length);
33
+ const prevValueRef = useRef(value);
34
+ const filter = useMemo(() => {
35
+ if (filterInput) {
36
+ return filterInput;
37
+ }
38
+ if (allowedCharacters !== undefined) {
39
+ return filterAllowedCharacters(allowedCharacters);
40
+ }
41
+ if (characterPattern !== undefined) {
42
+ return filterByRegExp(characterPattern);
43
+ }
44
+ return filterDigits;
45
+ }, [filterInput, allowedCharacters, characterPattern]);
46
+ const setFieldRef = useCallback((index, el) => {
47
+ fieldRefs.current[index] = el;
48
+ }, []);
49
+ const focusCell = useCallback(index => {
50
+ const safe = Math.max(0, Math.min(index, cellCount - 1));
51
+ fieldRefs.current[safe]?.focus();
52
+ }, [cellCount]);
53
+ const handleFieldChange = useCallback((index, text) => {
54
+ const {
55
+ nextValue,
56
+ focusIndex
57
+ } = applyOtpInputChange(value, index, text, cellCount, filter);
58
+ if (nextValue !== value) {
59
+ onChangeText(nextValue);
60
+ }
61
+ focusAfterApply.current = focusIndex;
62
+ }, [cellCount, filter, onChangeText, value]);
63
+ const handleFieldKeyPress = useCallback((index, key) => {
64
+ if (key !== 'Backspace') {
65
+ return;
66
+ }
67
+ const char = index < value.length ? value[index] : '';
68
+ if (!char && index > 0) {
69
+ focusCell(index - 1);
70
+ }
71
+ }, [focusCell, value]);
72
+ useLayoutEffect(() => {
73
+ if (focusAfterApply.current !== null) {
74
+ const i = focusAfterApply.current;
75
+ focusAfterApply.current = null;
76
+ fieldRefs.current[i]?.focus();
77
+ }
78
+ });
79
+ useEffect(() => {
80
+ const prevLen = prevLenRef.current;
81
+ const prevVal = prevValueRef.current;
82
+ const isFull = value.length === cellCount;
83
+ const becameFullByLength = isFull && prevLen < cellCount;
84
+ const correctedWhileFull = isFull && prevLen === cellCount && prevVal !== value;
85
+ if (becameFullByLength || correctedWhileFull) {
86
+ onComplete?.();
87
+ }
88
+ prevLenRef.current = value.length;
89
+ prevValueRef.current = value;
90
+ }, [cellCount, onComplete, value]);
91
+ const contextValue = useMemo(() => ({
92
+ cellCount,
93
+ value,
94
+ isDisabled,
95
+ isInvalid,
96
+ isReadOnly,
97
+ smsOtpAutofill,
98
+ filter,
99
+ getCellProps,
100
+ cellTestIdPrefix,
101
+ rootAccessibilityLabel,
102
+ setFieldRef,
103
+ handleFieldChange,
104
+ handleFieldKeyPress
105
+ }), [cellCount, value, isDisabled, isInvalid, isReadOnly, smsOtpAutofill, filter, getCellProps, cellTestIdPrefix, rootAccessibilityLabel, setFieldRef, handleFieldChange, handleFieldKeyPress]);
106
+
107
+ // Hermes drops outer-scope closure vars from its environment record when
108
+ // they are only referenced inside a nested callback (Array.from). Using a
109
+ // for-loop keeps OtpCell/OtpField references in the render function's own
110
+ // scope, avoiding the Hermes closure-capture bug.
111
+ const cells = [];
112
+ for (let i = 0; i < cellCount; i++) {
113
+ cells.push(/*#__PURE__*/_jsx(OtpCellIndexProvider, {
114
+ value: {
115
+ cellIndex: i
116
+ },
117
+ children: /*#__PURE__*/_jsx(OtpCell, {
118
+ children: /*#__PURE__*/_jsx(OtpField, {})
119
+ })
120
+ }, i));
121
+ }
122
+ return /*#__PURE__*/_jsx(BaseRoot, {
123
+ ref: ref,
124
+ ...rest,
125
+ children: /*#__PURE__*/_jsx(OtpInputProvider, {
126
+ value: contextValue,
127
+ children: cells
128
+ })
129
+ });
130
+ });
131
+ //# sourceMappingURL=createOtpInputRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useFormControlContext","applyOtpInputChange","OtpCellIndexProvider","OtpInputProvider","filterAllowedCharacters","filterByRegExp","filterDigits","jsx","_jsx","createOtpInputRoot","BaseRoot","OtpCell","OtpField","cellCount","value","onChangeText","onComplete","isDisabled","isDisabledProp","isInvalid","isInvalidProp","isReadOnly","isReadOnlyProp","smsOtpAutofill","filterInput","allowedCharacters","characterPattern","getCellProps","cellTestIdPrefix","accessibilityLabel","rootAccessibilityLabel","rest","ref","form","fieldRefs","focusAfterApply","prevLenRef","length","prevValueRef","filter","undefined","setFieldRef","index","el","current","focusCell","safe","Math","max","min","focus","handleFieldChange","text","nextValue","focusIndex","handleFieldKeyPress","key","char","i","prevLen","prevVal","isFull","becameFullByLength","correctedWhileFull","contextValue","cells","push","cellIndex","children"],"sourceRoot":"../../../src","sources":["otp-input/createOtpInputRoot.tsx"],"mappings":";;AACA,SAASA,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE5F,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,W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,EACTC,KAAK,EACLG,UAAU,EACVE,SAAS,EACTE,UAAU,EACVE,cAAc,EACdgB,MAAM,EACNZ,YAAY,EACZC,gBAAgB,EAChBE,sBAAsB,EACtBW,WAAW,EACXU,iBAAiB,EACjBI,mBAAmB,CAEvB,CAAC;;EAED;EACA;EACA;EACA;EACA,MAAMU,KAA2B,GAAG,EAAE;EACtC,KAAK,IAAIP,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG7C,SAAS,EAAE6C,CAAC,EAAE,EAAE;IAClCO,KAAK,CAACC,IAAI,cACR1D,IAAA,CAACN,oBAAoB;MAASY,KAAK,EAAE;QAAEqD,SAAS,EAAET;MAAE,CAAE;MAAAU,QAAA,eACpD5D,IAAA,CAACG,OAAO;QAAAyD,QAAA,eACN5D,IAAA,CAACI,QAAQ,IAAE;MAAC,CACL;IAAC,GAHe8C,CAIL,CACxB,CAAC;EACH;EAEA,oBACElD,IAAA,CAACE,QAAQ;IAACsB,GAAG,EAAEA,GAA0B;IAAA,GAAMD,IAAI;IAAAqC,QAAA,eACjD5D,IAAA,CAACL,gBAAgB;MAACW,KAAK,EAAEkD,YAAa;MAAAI,QAAA,EAAEH;IAAK,CAAmB;EAAC,CACzD,CAAC;AAEf,CACF,CAAC","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ import { createOtpInputCell } from './createOtpInputCell';
4
+ import { createOtpInputField } from './createOtpInputField';
5
+ import { createOtpInputRoot } from './createOtpInputRoot';
6
+ export { applyOtpInputChange } from './utils/applyValueChange';
7
+ export { filterAllowedCharacters, filterByRegExp, filterDigits } from './utils/filterValue';
8
+ export function createOtpInput(BaseComponents) {
9
+ const Cell = createOtpInputCell(BaseComponents.Cell);
10
+ const Field = createOtpInputField(BaseComponents.Field);
11
+ const Root = createOtpInputRoot(BaseComponents.Root, Cell, Field);
12
+ Root.displayName = 'OtpInputPrimitive';
13
+ Cell.displayName = 'OtpInputPrimitive.Cell';
14
+ Field.displayName = 'OtpInputPrimitive.Field';
15
+ return Object.assign(Root, {
16
+ Cell,
17
+ Field
18
+ });
19
+ }
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createOtpInputCell","createOtpInputField","createOtpInputRoot","applyOtpInputChange","filterAllowedCharacters","filterByRegExp","filterDigits","createOtpInput","BaseComponents","Cell","Field","Root","displayName","Object","assign"],"sourceRoot":"../../../src","sources":["otp-input/index.tsx"],"mappings":";;AACA,SAASA,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,kBAAkB,QAAQ,sBAAsB;AAGzD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,uBAAuB,EAAEC,cAAc,EAAEC,YAAY,QAAQ,qBAAqB;AAG3F,OAAO,SAASC,cAAcA,CAM5BC,cAID,EAAE;EACD,MAAMC,IAAI,GAAGT,kBAAkB,CAACQ,cAAc,CAACC,IAAI,CAAC;EACpD,MAAMC,KAAK,GAAGT,mBAAmB,CAACO,cAAc,CAACE,KAAK,CAAC;EACvD,MAAMC,IAAI,GAAGT,kBAAkB,CAACM,cAAc,CAACG,IAAI,EAAEF,IAAI,EAAEC,KAAK,CAAC;EAEjEC,IAAI,CAACC,WAAW,GAAG,mBAAmB;EACtCH,IAAI,CAACG,WAAW,GAAG,wBAAwB;EAC3CF,KAAK,CAACE,WAAW,GAAG,yBAAyB;EAE7C,OAAOC,MAAM,CAACC,MAAM,CAACH,IAAI,EAAE;IACzBF,IAAI;IACJC;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["otp-input/types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Pure OTP value transition for a controlled prefix string (no explicit empty slots).
5
+ * - Single-character edits use index-based replace/append (no reorder).
6
+ * - Multi-character input (paste/autofill) writes at `index` forward, then packs left.
7
+ */
8
+ export function applyOtpInputChange(value, index, rawText, cellCount, filter) {
9
+ const text = filter(rawText);
10
+ if (text.length === 0) {
11
+ if (index < value.length) {
12
+ const next = (value.slice(0, index) + value.slice(index + 1)).slice(0, cellCount);
13
+ return {
14
+ nextValue: next,
15
+ focusIndex: Math.max(0, index - 1)
16
+ };
17
+ }
18
+ return {
19
+ nextValue: value,
20
+ focusIndex: index
21
+ };
22
+ }
23
+ if (text.length === 1) {
24
+ if (index < value.length) {
25
+ const next = (value.slice(0, index) + text + value.slice(index + 1)).slice(0, cellCount);
26
+ return {
27
+ nextValue: next,
28
+ focusIndex: Math.min(index + 1, cellCount - 1)
29
+ };
30
+ }
31
+ if (value.length < cellCount) {
32
+ if (index === value.length) {
33
+ const next = (value + text).slice(0, cellCount);
34
+ return {
35
+ nextValue: next,
36
+ focusIndex: Math.min(next.length, cellCount - 1)
37
+ };
38
+ }
39
+ const arr = Array.from({
40
+ length: cellCount
41
+ }, (_, i) => i < value.length ? value[i] : '');
42
+ arr[index] = text;
43
+ const next = arr.filter(c => c).join('').slice(0, cellCount);
44
+ return {
45
+ nextValue: next,
46
+ focusIndex: Math.min(index + 1, cellCount - 1)
47
+ };
48
+ }
49
+ const next = (value.slice(0, index) + text + value.slice(index + 1)).slice(0, cellCount);
50
+ return {
51
+ nextValue: next,
52
+ focusIndex: Math.min(index + 1, cellCount - 1)
53
+ };
54
+ }
55
+ const arr = Array.from({
56
+ length: cellCount
57
+ }, (_, i) => i < value.length ? value[i] : '');
58
+ for (let k = 0; k < text.length && index + k < cellCount; k++) {
59
+ arr[index + k] = text.charAt(k);
60
+ }
61
+ const next = arr.filter(c => c).join('').slice(0, cellCount);
62
+ const lastWritten = Math.min(index + text.length - 1, cellCount - 1);
63
+ const focusIndex = Math.min(Math.max(lastWritten, next.length - 1), cellCount - 1);
64
+ return {
65
+ nextValue: next,
66
+ focusIndex: Math.max(0, focusIndex)
67
+ };
68
+ }
69
+ //# 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;AACA,OAAO,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;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its(input) {
5
+ return input.replace(/\D/g, '');
6
+ }
7
+
8
+ /** Keep only characters present in `allowed` (treat as a set of UTF-16 code units). */
9
+ export function filterAllowedCharacters(allowed) {
10
+ const allowedSet = new Set();
11
+ for (let i = 0; i < allowed.length; i++) {
12
+ allowedSet.add(allowed.charAt(i));
13
+ }
14
+ return input => {
15
+ let out = '';
16
+ for (let i = 0; i < input.length; i++) {
17
+ const ch = input.charAt(i);
18
+ if (allowedSet.has(ch)) {
19
+ out += ch;
20
+ }
21
+ }
22
+ return out;
23
+ };
24
+ }
25
+
26
+ /** Keep only characters matching `re` (tested per UTF-16 code unit). */
27
+ export function filterByRegExp(re) {
28
+ return input => {
29
+ let out = '';
30
+ for (let i = 0; i < input.length; i++) {
31
+ const ch = input.charAt(i);
32
+ re.lastIndex = 0;
33
+ if (re.test(ch)) {
34
+ out += ch;
35
+ }
36
+ }
37
+ return out;
38
+ };
39
+ }
40
+ //# 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;AACA,OAAO,SAASA,YAAYA,CAACC,KAAa,EAAU;EAClD,OAAOA,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AACjC;;AAEA;AACA,OAAO,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;AACA,OAAO,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":[]}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const createFieldError: <T>(BaseFormError: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldError.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldError.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,eAAe,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eACvC,KAAK,CAAC,SAAS;iCA2B9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type React from 'react';
2
+ export declare const createFieldErrorIcon: <T>(BaseFormErrorIcon: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldErrorIcon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldErrorIcon.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldErrorIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAG,mBAAmB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eAC/C,KAAK,CAAC,SAAS;iCAI9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type React from 'react';
2
+ export declare const createFieldErrorText: <T>(BaseFormErrorText: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldErrorText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldErrorText.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldErrorText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAG,mBAAmB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eAC/C,KAAK,CAAC,SAAS;iCAI9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const createFieldHelper: <T>(BaseFormHelper: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldHelper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldHelper.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldHelper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAG,gBAAgB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eACzC,KAAK,CAAC,SAAS;iCAuB9C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type React from 'react';
2
+ export declare const createFieldHelperText: <T>(BaseFormHelperText: React.ComponentType<T>) => React.ForwardRefExoticComponent<{
3
+ children?: React.ReactNode;
4
+ } & React.RefAttributes<unknown>>;
5
+ //# sourceMappingURL=createFieldHelperText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldHelperText.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldHelperText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAG,oBAAoB,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eACjD,KAAK,CAAC,SAAS;iCAI9C,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type React from 'react';
2
+ import type { IFieldLabelProps } from './types';
3
+ export declare const createFieldLabel: <T>(BaseFormLabel: React.ComponentType<T>) => React.ForwardRefExoticComponent<IFieldLabelProps & {
4
+ children?: React.ReactNode;
5
+ } & React.RefAttributes<unknown>>;
6
+ //# sourceMappingURL=createFieldLabel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldLabel.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAG,eAAe,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eACpB,KAAK,CAAC,SAAS;iCAsBlE,CAAC"}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { IFieldRootProps } from './types';
3
+ export declare const createFieldRoot: <T>(BaseFormField: React.ComponentType<T>) => React.ForwardRefExoticComponent<IFieldRootProps & {
4
+ children?: React.ReactNode;
5
+ } & React.RefAttributes<unknown>>;
6
+ //# sourceMappingURL=createFieldRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldRoot.d.ts","sourceRoot":"","sources":["../../../src/field/createFieldRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,eAAe,GAAI,CAAC,EAAG,eAAe,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;eAEb,KAAK,CAAC,SAAS;iCAmBxE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type React from 'react';
2
+ import type { IFieldComponentType } from './types';
3
+ export type { IFieldRootProps, IFieldLabelProps, IFieldHelperProps, IFieldHelperTextProps, IFieldErrorProps, IFieldErrorTextProps, IFieldErrorIconProps, IFieldComponentType, } from './types';
4
+ export declare function createField<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon>({ Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon, }: {
5
+ Root: React.ComponentType<Root>;
6
+ Label: React.ComponentType<Label>;
7
+ Helper: React.ComponentType<Helper>;
8
+ HelperText: React.ComponentType<HelperText>;
9
+ Error: React.ComponentType<Error>;
10
+ ErrorText: React.ComponentType<ErrorText>;
11
+ ErrorIcon: React.ComponentType<ErrorIcon>;
12
+ }): IFieldComponentType<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon>;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/field/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,EACxF,IAAI,EACJ,KAAK,EACL,MAAM,EACN,UAAU,EACV,KAAK,EACL,SAAS,EACT,SAAS,GACV,EAAE;IACD,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACpC,UAAU,EAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC5C,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC1C,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;CAC3C,GA6BO,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CACxF"}
@@ -1,14 +1,5 @@
1
1
  import type React from 'react';
2
2
  import type { TextProps, ViewProps } from 'react-native';
3
- /**
4
- * Props for the Form container (`<form>` on web, `<View>` on RN).
5
- * Does NOT provide field-level context — use `Form.Field` for that.
6
- *
7
- * Web-only submit props (`onSubmit`, `action`, `method`) belong in the
8
- * platform-specific base component (`FormRoot.web.tsx`), not here.
9
- */
10
- export interface IFormProps {
11
- }
12
3
  /**
13
4
  * Props for a single form field (`Form.Field`).
14
5
  * Provides field-level context (name, validation state, ids) to children.
@@ -19,7 +10,7 @@ export interface IFormProps {
19
10
  *
20
11
  * **Submit UX:** "focus first invalid on error" needs form-level validation state; not built in yet.
21
12
  */
22
- export interface IFormFieldProps extends ViewProps {
13
+ export interface IFieldRootProps extends ViewProps {
23
14
  /** Unique id for this field. Auto-generated if not provided. */
24
15
  readonly id?: string;
25
16
  /**
@@ -36,7 +27,7 @@ export interface IFormFieldProps extends ViewProps {
36
27
  /** If true, the field is read-only. */
37
28
  readonly isReadOnly?: boolean;
38
29
  }
39
- export interface IFormLabelProps extends TextProps {
30
+ export interface IFieldLabelProps extends TextProps {
40
31
  /**
41
32
  * Associates the label with a control `id` on web (`<label htmlFor>`).
42
33
  * If omitted, defaults to the same id `Input.Field` gets from form context: `fieldId + "-input"`.
@@ -49,24 +40,23 @@ export interface IFormLabelProps extends TextProps {
49
40
  */
50
41
  readonly requiredIndicator?: React.ReactNode;
51
42
  }
52
- export interface IFormHelperProps extends ViewProps {
43
+ export interface IFieldHelperProps extends ViewProps {
53
44
  }
54
- export interface IFormHelperTextProps extends TextProps {
45
+ export interface IFieldHelperTextProps extends TextProps {
55
46
  }
56
- export interface IFormErrorProps extends ViewProps {
47
+ export interface IFieldErrorProps extends ViewProps {
57
48
  }
58
- export interface IFormErrorTextProps extends TextProps {
49
+ export interface IFieldErrorTextProps extends TextProps {
59
50
  }
60
- export interface IFormErrorIconProps extends ViewProps {
51
+ export interface IFieldErrorIconProps extends ViewProps {
61
52
  }
62
- export type IFormComponentType<Root, Field, Error, ErrorText, ErrorIcon, Label, Helper, HelperText> = React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFormProps> & {
63
- Field: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Field> & IFormFieldProps>;
64
- Label: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Label> & IFormLabelProps>;
65
- Helper: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Helper> & IFormHelperProps>;
66
- HelperText: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<HelperText> & IFormHelperTextProps>;
67
- Error: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Error> & IFormErrorProps>;
68
- ErrorText: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<ErrorText> & IFormErrorTextProps>;
69
- ErrorIcon: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<ErrorIcon> & IFormErrorIconProps>;
53
+ export type IFieldComponentType<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon> = React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFieldRootProps> & {
54
+ Label: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Label> & IFieldLabelProps>;
55
+ Helper: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Helper> & IFieldHelperProps>;
56
+ HelperText: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<HelperText> & IFieldHelperTextProps>;
57
+ Error: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Error> & IFieldErrorProps>;
58
+ ErrorText: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<ErrorText> & IFieldErrorTextProps>;
59
+ ErrorIcon: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<ErrorIcon> & IFieldErrorIconProps>;
70
60
  };
71
61
  type InnerForwardRefExoticComponent<T> = React.PropsWithoutRef<T> & React.RefAttributes<unknown>;
72
62
  export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/field/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAChD,gEAAgE;IAChE,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,CAAC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AS,EAAE,KAAK,CAAC,yBAAyB,CACxC,8BAA8B,CAAC,SAAS,CAAC,GAAG,oBAAoB,CACjE,CAAC;IACF,SAAS,EAAE,KAAK,CAAC,yBAAyB,CACxC,8BAA8B,CAAC,SAAS,CAAC,GAAG,oBAAoB,CACjE,CAAC;CACH,CAAC;AAEJ,KAAK,8BAA8B,CAAC,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { IFormComponentType } from './types';
3
+ export declare const createFormRoot: <T>(BaseFormRoot: React.ComponentType<T>) => IFormComponentType<T>;
4
+ //# sourceMappingURL=createFormRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFormRoot.d.ts","sourceRoot":"","sources":["../../../src/form/createFormRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAkB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAIlE,eAAO,MAAM,cAAc,GAAI,CAAC,EAAG,cAAc,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAG,kBAAkB,CAAC,CAAC,CAO3F,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type React from 'react';
2
+ export type { IFormRootProps, IFormComponentType } from './types';
3
+ export declare function createForm<Root>({ Root }: {
4
+ Root: React.ComponentType<Root>;
5
+ }): import("./types").IFormComponentType<Root>;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElE,wBAAgB,UAAU,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;CAAE,8CAM7E"}
@@ -0,0 +1,14 @@
1
+ import type React from 'react';
2
+ /**
3
+ * Props for the Form container (`<form>` on web, `<View>` on RN).
4
+ * Does NOT provide field-level context — use `Form.Field` for that.
5
+ *
6
+ * Web-only submit props (`onSubmit`, `action`, `method`) belong in the
7
+ * platform-specific base component (`FormRoot.web.tsx`), not here.
8
+ */
9
+ export interface IFormRootProps {
10
+ }
11
+ export type IFormComponentType<Root> = React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFormRootProps>;
12
+ type InnerForwardRefExoticComponent<T> = React.PropsWithoutRef<T> & React.RefAttributes<unknown>;
13
+ export {};
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/form/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;CAAG;AAElC,MAAM,MAAM,kBAAkB,CAAC,IAAI,IAAI,KAAK,CAAC,yBAAyB,CACpE,8BAA8B,CAAC,IAAI,CAAC,GAAG,cAAc,CACtD,CAAC;AAEF,KAAK,8BAA8B,CAAC,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC"}