@xaui/native 0.9.1-alpha.23 → 0.9.1-alpha.25

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 (59) hide show
  1. package/dist/{chunk-E3LXUXE7.js → chunk-2OY76YNB.js} +47 -13
  2. package/dist/{chunk-KM2TI5IC.js → chunk-4HELPMAK.js} +76 -82
  3. package/dist/{chunk-AHL33YAO.js → chunk-4J26FA6O.js} +9 -7
  4. package/dist/{chunk-BNWS26PX.cjs → chunk-6FBGCF5T.cjs} +9 -7
  5. package/dist/{chunk-ZQ3JSWRO.js → chunk-A4RGJBP2.js} +4 -2
  6. package/dist/{chunk-I6PE5UUH.cjs → chunk-AV5LMFS3.cjs} +13 -11
  7. package/dist/{chunk-OGC4RKE3.js → chunk-AXSJPWSJ.js} +5 -5
  8. package/dist/chunk-BULNTP5N.cjs +620 -0
  9. package/dist/chunk-EGLLDKN6.js +9 -0
  10. package/dist/chunk-EJQCQPET.cjs +9 -0
  11. package/dist/{chunk-VDRRD6GM.cjs → chunk-EWBBDVTM.cjs} +22 -21
  12. package/dist/chunk-GSEK6OCY.cjs +72 -0
  13. package/dist/chunk-I6UCYAO2.js +731 -0
  14. package/dist/{chunk-BH5DSJVX.cjs → chunk-IG4Q3WQO.cjs} +61 -68
  15. package/dist/{chunk-6WW4CSPY.cjs → chunk-J2JJLKLG.cjs} +6 -4
  16. package/dist/{chunk-4MHJOWM4.cjs → chunk-J4JFIC4W.cjs} +7 -7
  17. package/dist/{chunk-FNQF4KQV.js → chunk-MRYLLKML.js} +18 -17
  18. package/dist/{chunk-GBPWTFTU.cjs → chunk-OHEHPQLC.cjs} +10 -1
  19. package/dist/{chunk-GG2WWCBK.js → chunk-TZG3DERP.js} +10 -1
  20. package/dist/{chunk-TIP3T7JJ.cjs → chunk-YEW5LPWL.cjs} +47 -13
  21. package/dist/chunk-ZDCGPK5Z.js +72 -0
  22. package/dist/{chunk-FTCTTBLG.js → chunk-ZTA47PO5.js} +7 -5
  23. package/dist/components/alert/index.cjs +7 -6
  24. package/dist/components/alert/index.js +6 -5
  25. package/dist/components/button/index.cjs +6 -5
  26. package/dist/components/button/index.js +5 -4
  27. package/dist/components/card/index.cjs +5 -4
  28. package/dist/components/card/index.js +4 -3
  29. package/dist/components/chip/index.cjs +7 -6
  30. package/dist/components/chip/index.js +6 -5
  31. package/dist/components/input/index.cjs +13 -3
  32. package/dist/components/input/index.d.cts +109 -117
  33. package/dist/components/input/index.d.ts +109 -117
  34. package/dist/components/input/index.js +12 -2
  35. package/dist/components/input-otp/index.cjs +27 -0
  36. package/dist/components/input-otp/index.d.cts +325 -0
  37. package/dist/components/input-otp/index.d.ts +325 -0
  38. package/dist/components/input-otp/index.js +27 -0
  39. package/dist/components/text-area/index.cjs +13 -0
  40. package/dist/components/text-area/index.d.cts +73 -0
  41. package/dist/components/text-area/index.d.ts +73 -0
  42. package/dist/components/text-area/index.js +13 -0
  43. package/dist/components/typography/index.cjs +3 -3
  44. package/dist/components/typography/index.js +2 -2
  45. package/dist/index.cjs +53 -51
  46. package/dist/index.d.cts +4 -1
  47. package/dist/index.d.ts +4 -1
  48. package/dist/index.js +69 -67
  49. package/dist/input.type-BpJeUIe8.d.cts +151 -0
  50. package/dist/input.type-DjyZ6P2C.d.ts +151 -0
  51. package/dist/system/index.cjs +6 -5
  52. package/dist/system/index.js +5 -4
  53. package/dist/theme/index.cjs +2 -2
  54. package/dist/theme/index.js +1 -1
  55. package/package.json +21 -1
  56. package/dist/{chunk-DXGQ43IV.cjs → chunk-B4W2XNBP.cjs} +2 -2
  57. package/dist/{chunk-2U6JR7BF.js → chunk-G52TQJBI.js} +3 -3
  58. package/dist/{chunk-FVP5FUVS.js → chunk-ICR42HHG.js} +3 -3
  59. package/dist/{chunk-RAWOJ3N3.cjs → chunk-Y7U6ACMB.cjs} +2 -2
@@ -1,148 +1,140 @@
1
1
  import * as react from 'react';
2
- import { ReactNode } from 'react';
3
2
  import * as react_native from 'react-native';
4
- import { StyleProp, TextStyle, TextInputProps, TextProps, ViewStyle, ViewProps } from 'react-native';
5
- import { T as TextStyleProps, V as ViewStyleProps } from '../../style-props.type-CfnoGEP7.js';
6
- import { S as Size, R as RadiusKey, X as XAUITheme } from '../../theme.type-C2gNHpEx.js';
3
+ import { View, Text, TextInput } from 'react-native';
4
+ import { V as ViewStyleProps, T as TextStyleProps } from '../../style-props.type-CfnoGEP7.js';
5
+ import { R as RadiusKey, X as XAUITheme } from '../../theme.type-C2gNHpEx.js';
6
+ import { i as InputVariant, g as InputSize, e as InputLabelPlacement, b as InputContextValue, h as InputSlot } from '../../input.type-DjyZ6P2C.js';
7
+ export { c as InputDescriptionProps, d as InputErrorProps, I as InputFieldProps, f as InputLabelProps, a as InputProps } from '../../input.type-DjyZ6P2C.js';
7
8
  import { R as Recipe, g as SlotStyles, j as StyleFn } from '../../create-recipe-C4JkINrA.js';
8
9
 
9
- type InputSlot = 'root' | 'label' | 'field' | 'placeholder' | 'description' | 'error';
10
10
  /**
11
- * The library's four emphasis levels, narrowed like the `Card`'s (§1 bis). A field
12
- * **reports nothing** — an error is `isInvalid`, which is a state and not a variant — so
13
- * `success`, `warning` and `danger` are absent here for the same reason they are there.
11
+ * A text field, with the label, the hint and the error that make it usable.
14
12
  *
15
- * This is where the theme's `field*` family is finally read, and the four names split
16
- * HeroUI's two-name `primary | secondary` by saying what each of their ends already is:
13
+ * ```tsx
14
+ * <Input>
15
+ * <Input.Label>Courriel</Input.Label>
16
+ * <Input.Field
17
+ * value={email}
18
+ * onChangeText={setEmail}
19
+ * placeholder="nom@exemple.fr"
20
+ * keyboardType="email-address"
21
+ * />
22
+ * <Input.Description>On ne le partage jamais.</Input.Description>
23
+ * </Input>
17
24
  *
18
- * - **`primary`** — the `fieldBackground` fill plus the theme's `field` shadow. HeroUI's
19
- * `primary`, with the elevation their flat token only implies.
20
- * - **`secondary`** — the neutral `default` fill. HeroUI's `secondary`, and the default
21
- * here: on a plain background a white field is its border and nothing else, while on a
22
- * card the `fieldBackground` token *is* the card's own colour.
23
- * - **`tertiary`** — the border alone, no fill. The same drop the `Button`'s `tertiary`
24
- * makes.
25
- * - **`ghost`** — neither. A bare field for a toolbar or an inline edit; it has no border
26
- * to move, so its focus shows in the caret alone.
25
+ * <Input isInvalid={Boolean(error)}>
26
+ * <Input.Label>Mot de passe</Input.Label>
27
+ * <Input.Field secureTextEntry value={password} onChangeText={setPassword} />
28
+ * {error ? <Input.Error>{error}</Input.Error> : null}
29
+ * </Input>
30
+ * ```
27
31
  *
28
- * The first three name the `fieldBorder` edge and `ghost` gives it up. Its width is the
29
- * theme's `borderWidth.field` HeroUI's `--field-border-width`, which they ship at `0`
30
- * and we ship at `1`. That is the one shipped default where the two differ;
31
- * `createTheme({ borderWidth: { field: 0 } })` reproduces theirs.
32
- */
33
- type InputVariant = 'primary' | 'secondary' | 'tertiary' | 'ghost';
34
- /**
35
- * Where the label sits relative to the field's box.
32
+ * **The root is the column, not the field.** `Input.Field` is the `TextInput`, which is
33
+ * what makes the label, the hint and the error slots of one component rather than three
34
+ * components a form has to keep in step — and it is why `TextInputProps` are on the field
35
+ * rather than on the root.
36
36
  *
37
- * `outside` is the label above the box, in the column's flow. `inside` lifts it into the
38
- * box, above the text the label is taken **out of flow** and placed against the box's
39
- * own padding, so the JSX is identical either way and nothing is reparented (R4).
40
- *
41
- * Because the inside label positions itself against the top of the root, it assumes the
42
- * field is the first thing in the column's flow: write `Input.Description` and
43
- * `Input.Error` after the field, which is where they belong anyway.
37
+ * There is no auto-wrap here (R3): a string child of an input is not a label, a value or
38
+ * a placeholder in any way the component could guess.
44
39
  */
45
- type InputLabelPlacement = 'outside' | 'inside';
46
- type InputSize = Size;
47
- /**
48
- * What the `Input` itself understands. R14 — a name in here is the component's, so the
49
- * style prop that shares it is not exposed: `size` is the field's scale and never
50
- * `ViewStyle`'s, and `color` is R7's tint.
51
- */
52
- type InputOwnProps = {
40
+ declare const InputRoot: react.ForwardRefExoticComponent<{
53
41
  variant?: InputVariant;
54
- /** The field's height, its padding, the gaps and the type. Never width. */
55
42
  size?: InputSize;
56
- /** Overrides the `field` radius the theme chose for every size. */
57
43
  radius?: RadiusKey;
58
- /** Above the box, or lifted into it. @default 'outside' */
59
44
  labelPlacement?: InputLabelPlacement;
60
- /**
61
- * A raw tint (`'#7c3aed'`), never a token (R7). It lands where the variant put its
62
- * tokens — the fill of a `default`, the border of a `tertiary` — and, because the focus
63
- * colour is a role like any other, it is also what the field borders on focus.
64
- */
65
45
  color?: string;
66
- /**
67
- * Paints the border, the label and the description in `danger`, and takes the focus
68
- * treatment off: an error outranks focus, and a field that is both should read as
69
- * wrong rather than as busy.
70
- *
71
- * It does **not** mount or unmount `Input.Error`. That stays the caller's — a slot that
72
- * silently renders nothing is a slot you cannot debug.
73
- */
74
46
  isInvalid?: boolean;
75
- /** Dims the field and makes it uneditable. */
76
47
  isDisabled?: boolean;
77
- style?: StyleProp<ViewStyle>;
78
- children?: ReactNode;
79
- };
48
+ style?: react_native.StyleProp<react_native.ViewStyle>;
49
+ children?: react.ReactNode;
50
+ } & Omit<react_native.ViewProps, keyof {
51
+ variant?: InputVariant;
52
+ size?: InputSize;
53
+ radius?: RadiusKey;
54
+ labelPlacement?: InputLabelPlacement;
55
+ color?: string;
56
+ isInvalid?: boolean;
57
+ isDisabled?: boolean;
58
+ style?: react_native.StyleProp<react_native.ViewStyle>;
59
+ children?: react.ReactNode;
60
+ }> & Omit<ViewStyleProps, "color" | "pointerEvents" | "style" | "children" | "hitSlop" | "id" | "needsOffscreenAlphaCompositing" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "onBlur" | "onFocus" | "renderToHardwareTextureAndroid" | "focusable" | "tabIndex" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | "isDisabled" | "radius" | "size" | "variant" | "labelPlacement" | "isInvalid"> & {
61
+ asChild?: boolean;
62
+ } & react.RefAttributes<View>>;
63
+
80
64
  /**
81
- * R14 the input's own props, the wrapper `View`'s, and every `ViewStyle` key neither
82
- * already claims. **`TextInputProps` are not here**: they belong to `Input.Field`, which
83
- * is the node that has them.
65
+ * The hint under the field the format expected, what the value is used for.
66
+ *
67
+ * It carries the id the field points at with `aria-describedby`, so it is read after the
68
+ * label rather than skipped. It turns `danger` with `isInvalid`, like the label.
69
+ *
70
+ * It sits inset by half the field's padding, so the column reads as one block rather than
71
+ * as a label, a box and a stray line.
84
72
  */
85
- type InputProps = InputOwnProps & Omit<ViewProps, keyof InputOwnProps> & Omit<ViewStyleProps, keyof InputOwnProps | keyof ViewProps> & {
86
- /** R12 — merge into the single child instead of rendering a `View`. */
87
- asChild?: boolean;
88
- };
73
+ declare const InputDescription: react.ForwardRefExoticComponent<react_native.TextProps & Omit<TextStyleProps, keyof react_native.TextProps> & {
74
+ children?: react.ReactNode;
75
+ } & react.RefAttributes<Text>>;
76
+
89
77
  /**
90
- * Everything `TextInput` accepts, plus the `TextStyle` keys as props (R14).
78
+ * What is wrong with the value, in `danger`.
79
+ *
80
+ * **It always renders what it is given.** `isInvalid` paints the border, the label and the
81
+ * description; it does not mount or unmount this slot, because a slot that silently
82
+ * renders nothing is a slot you cannot debug — you write the condition yourself and see
83
+ * it:
84
+ *
85
+ * ```tsx
86
+ * <Input isInvalid={Boolean(error)}>
87
+ * <Input.Field value={value} onChangeText={onChange} />
88
+ * {error ? <Input.Error>{error}</Input.Error> : null}
89
+ * </Input>
90
+ * ```
91
91
  *
92
- * `editable` is absent: it is `disabled` under another name, and R8 keeps that off the
93
- * public surface `isDisabled` on the root is what stops the field.
92
+ * `accessibilityLiveRegion` is deliberately not set: an error that appears while you are
93
+ * still typing in the field is announced by the field's own `aria-invalid`, and a live
94
+ * region on top of that reads the message on every keystroke that changes it.
94
95
  */
95
- type InputFieldProps = Omit<TextInputProps, 'editable'> & Omit<TextStyleProps, keyof TextInputProps>;
96
- /** `Text`'s own props win over the `TextStyle` keys of the same name (R14). */
97
- type InputTextProps = TextProps & Omit<TextStyleProps, keyof TextProps> & {
98
- children?: ReactNode;
99
- };
100
- type InputLabelProps = InputTextProps;
101
- type InputDescriptionProps = InputTextProps;
102
- type InputErrorProps = InputTextProps;
96
+ declare const InputError: react.ForwardRefExoticComponent<react_native.TextProps & Omit<TextStyleProps, keyof react_native.TextProps> & {
97
+ children?: react.ReactNode;
98
+ } & react.RefAttributes<Text>>;
99
+
103
100
  /**
104
- * Read off `TextInput`'s own props rather than spelled out: React Native has renamed the
105
- * payload of these two more than once, and a hand-written `NativeSyntheticEvent<…>` here
106
- * would be a second declaration free to drift from the node that actually fires them.
101
+ * The `TextInput` itself the one node of this component that the user types into.
102
+ *
103
+ * ```tsx
104
+ * <Input.Field value={email} onChangeText={setEmail} placeholder="nom@exemple.fr" />
105
+ * ```
106
+ *
107
+ * It takes everything `TextInput` takes, which is why `value`, `defaultValue`, `onChange`,
108
+ * `keyboardType`, `secureTextEntry`, `autoComplete` and `multiline` are written here and
109
+ * not on the root. There is no `type`: that is an HTML prop, and React Native splits it
110
+ * into `inputMode`, `keyboardType`, `secureTextEntry` and `autoComplete`.
111
+ *
112
+ * What it does *not* take is `editable`: that is `disabled` under another name, and R8
113
+ * keeps it off the public surface — `isDisabled` on the root is what stops the field.
114
+ *
115
+ * It reports focus up rather than styling it (R5): the root's recipe resolves on the
116
+ * focus state, so the root owns it and this composes the caller's handlers into the two
117
+ * the context published.
107
118
  */
108
- type FieldFocusEvent = Parameters<NonNullable<TextInputProps['onFocus']>>[0];
109
- type FieldBlurEvent = Parameters<NonNullable<TextInputProps['onBlur']>>[0];
119
+ declare const InputField: react.ForwardRefExoticComponent<Omit<react_native.TextInputProps, "editable"> & Omit<TextStyleProps, keyof react_native.TextInputProps> & react.RefAttributes<TextInput>>;
120
+
110
121
  /**
111
- * R5 resolved styles, not props for a slot to resolve a second time. Each entry is the
112
- * cached `StyleSheet` reference with the uncached tint pass layered over it, so a slot
113
- * merges its own `style` on top and does no work of its own.
122
+ * What the field is for. It turns `danger` with `isInvalid`, so the field that is wrong is
123
+ * findable on a long form without reading every message.
124
+ *
125
+ * It carries the id the field points at, which is what makes a screen reader announce
126
+ * "Courriel, champ de saisie" instead of reading the placeholder and hoping.
127
+ *
128
+ * Its colour comes from the theme's `foreground` rather than the variant's: the label sits
129
+ * outside the box, on the screen behind it, so a tinted field does not tint it.
114
130
  */
115
- type InputContextValue = {
116
- labelStyle: StyleProp<TextStyle>;
117
- fieldStyle: StyleProp<TextStyle>;
118
- descriptionStyle: StyleProp<TextStyle>;
119
- errorStyle: StyleProp<TextStyle>;
120
- /**
121
- * A value and not a style: `placeholderTextColor` is a `TextInput` prop, so the root
122
- * flattens its placeholder slot once here rather than in the field.
123
- */
124
- placeholderTextColor?: string;
125
- /**
126
- * The focus state lives on the **root**, because the root's recipe resolves on it (R5)
127
- * and it needs the value before it renders — but the node that hears the event is
128
- * `Input.Field`, three levels down. These are how it reports back. Their identity is
129
- * stable, so publishing them costs no re-render of a memoized slot.
130
- */
131
- onFieldFocus: (event: FieldFocusEvent) => void;
132
- onFieldBlur: (event: FieldBlurEvent) => void;
133
- /**
134
- * The id the label carries and the field points at, so a screen reader reads "Courriel,
135
- * champ de saisie" rather than just the placeholder.
136
- */
137
- labelId: string;
138
- descriptionId: string;
139
- isDisabled: boolean;
140
- isInvalid: boolean;
141
- };
131
+ declare const InputLabel: react.ForwardRefExoticComponent<react_native.TextProps & Omit<TextStyleProps, keyof react_native.TextProps> & {
132
+ children?: react.ReactNode;
133
+ } & react.RefAttributes<Text>>;
142
134
 
143
135
  declare const useInput: () => InputContextValue;
144
136
 
145
- declare const inputRecipe: Recipe<"label" | "field" | "description" | "root" | "placeholder" | "error", InputVariant, {
137
+ declare const inputRecipe: Recipe<"label" | "field" | "description" | "root" | "textArea" | "placeholder" | "error", InputVariant, {
146
138
  readonly size: {
147
139
  readonly xs: (theme: XAUITheme) => SlotStyles<InputSlot>;
148
140
  readonly sm: (theme: XAUITheme) => SlotStyles<InputSlot>;
@@ -210,4 +202,4 @@ declare const Input: react.ForwardRefExoticComponent<{
210
202
  } & react.RefAttributes<react_native.Text>>;
211
203
  };
212
204
 
213
- export { Input, type InputContextValue, type InputDescriptionProps, type InputErrorProps, type InputFieldProps, type InputLabelPlacement, type InputLabelProps, type InputProps, type InputSize, type InputSlot, type InputVariant, inputRecipe, useInput };
205
+ export { Input, InputContextValue, InputDescription, InputError, InputField, InputLabel, InputLabelPlacement, InputRoot, InputSize, InputSlot, InputVariant, inputRecipe, useInput };
@@ -1,14 +1,24 @@
1
1
  import {
2
2
  Input,
3
+ InputDescription,
4
+ InputError,
5
+ InputField,
6
+ InputLabel,
7
+ InputRoot,
3
8
  inputRecipe,
4
9
  useInput
5
- } from "../../chunk-E3LXUXE7.js";
10
+ } from "../../chunk-2OY76YNB.js";
6
11
  import "../../chunk-3JATAB7S.js";
7
- import "../../chunk-A3EGFI6T.js";
8
12
  import "../../chunk-PMO62QK4.js";
13
+ import "../../chunk-A3EGFI6T.js";
9
14
  import "../../chunk-GGW42MY4.js";
10
15
  export {
11
16
  Input,
17
+ InputDescription,
18
+ InputError,
19
+ InputField,
20
+ InputLabel,
21
+ InputRoot,
12
22
  inputRecipe,
13
23
  useInput
14
24
  };
@@ -0,0 +1,27 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ var _chunkBULNTP5Ncjs = require('../../chunk-BULNTP5N.cjs');
12
+ require('../../chunk-EJQCQPET.cjs');
13
+ require('../../chunk-YXVKQMCK.cjs');
14
+ require('../../chunk-HUZ4AUM2.cjs');
15
+ require('../../chunk-57SJ4LJF.cjs');
16
+ require('../../chunk-MC7SY2QH.cjs');
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+ exports.InputOTP = _chunkBULNTP5Ncjs.InputOTP; exports.OTP_ALPHANUMERIC = _chunkBULNTP5Ncjs.OTP_ALPHANUMERIC; exports.OTP_DIGITS = _chunkBULNTP5Ncjs.OTP_DIGITS; exports.OTP_LETTERS = _chunkBULNTP5Ncjs.OTP_LETTERS; exports.buildSlots = _chunkBULNTP5Ncjs.buildSlots; exports.extractPastedCode = _chunkBULNTP5Ncjs.extractPastedCode; exports.inputOTPRecipe = _chunkBULNTP5Ncjs.inputOTPRecipe; exports.useInputOTP = _chunkBULNTP5Ncjs.useInputOTP; exports.useInputOTPBox = _chunkBULNTP5Ncjs.useInputOTPBox;
@@ -0,0 +1,325 @@
1
+ import * as react from 'react';
2
+ import { RefObject, ReactNode } from 'react';
3
+ import * as react_native from 'react-native';
4
+ import { StyleProp, ViewStyle, TextStyle, TextInput, ViewProps, TextProps, TextInputProps } from 'react-native';
5
+ import { V as ViewStyleProps, T as TextStyleProps } from '../../style-props.type-CfnoGEP7.cjs';
6
+ import { S as Size, R as RadiusKey, X as XAUITheme } from '../../theme.type-C2gNHpEx.cjs';
7
+ import { R as Recipe, g as SlotStyles, j as StyleFn } from '../../create-recipe-dBN_ewZc.cjs';
8
+
9
+ /**
10
+ * The two decisions this component makes that are worth pinning down: which box shows
11
+ * what, and what survives a paste. Both are pure string work, so they live here and are
12
+ * tested — the component around them is verified by its demo screen like every other.
13
+ */
14
+ /** What one box knows about itself. The slots read it; nothing else does. */
15
+ type OTPSlotState = {
16
+ index: number;
17
+ /** The character typed here, or `null` while the box is empty. */
18
+ char: string | null;
19
+ /** The placeholder for this box, or `null` when a char or the caret takes the room. */
20
+ placeholderChar: string | null;
21
+ /** The box the next character will land in. Only ever one, and only while focused. */
22
+ isActive: boolean;
23
+ /** Active **and** empty: a caret over a character would sit on top of it. */
24
+ isCaretVisible: boolean;
25
+ };
26
+ type BuildSlotsArgs = {
27
+ value: string;
28
+ maxLength: number;
29
+ isFocused: boolean;
30
+ /** One character per box, or a single character repeated across all of them. */
31
+ placeholder?: string;
32
+ };
33
+ /**
34
+ * The boxes, from the value. One pass, no state: what a box shows is a function of the
35
+ * value's length and where the caret is, and deriving it is what keeps a paste, a
36
+ * backspace and a keystroke from each needing their own update path.
37
+ *
38
+ * The active box is the one **after** the last character — `value.length` — which is
39
+ * also why a full value has no active box: there is nowhere left to type.
40
+ */
41
+ declare function buildSlots({ value, maxLength, isFocused, placeholder, }: BuildSlotsArgs): OTPSlotState[];
42
+ /**
43
+ * The code inside whatever the platform handed us on paste.
44
+ *
45
+ * A one-time code arrives surrounded by prose far more often than alone — "Your code is
46
+ * 482913, it expires in 10 minutes" — and the naïve `slice(0, maxLength)` takes "Your c".
47
+ * This looks for a run of exactly `maxLength` digits with no digit on either side, which
48
+ * is what rules out the "10" in that sentence and the year in a date.
49
+ *
50
+ * Returns `''` when nothing matches, so a paste of unrelated text clears nothing and
51
+ * fills nothing.
52
+ */
53
+ declare function extractPastedCode(pasted: string, maxLength: number): string;
54
+ /** The three patterns a one-time code is normally restricted to. */
55
+ declare const OTP_DIGITS = "^\\d+$";
56
+ declare const OTP_LETTERS = "^[a-zA-Z]+$";
57
+ declare const OTP_ALPHANUMERIC = "^[a-zA-Z0-9]+$";
58
+
59
+ type InputOTPSlot = 'root' | 'group' | 'box' | 'value' | 'placeholder' | 'caret' | 'separator';
60
+ /**
61
+ * Three of the `Input`'s four levels — a one-time code is a field, and a box of it is a
62
+ * field one character wide. `primary` is the `fieldBackground` fill plus the theme's
63
+ * `field` shadow, `secondary` the neutral fill and the default here, `tertiary` the border
64
+ * alone.
65
+ *
66
+ * **No `ghost`**, where the `Input` has one, and it is the shape of the component that
67
+ * removes it: an input is one wide field whose position the caret and the label already
68
+ * give away, so it survives having neither fill nor edge. A code is *six* boxes, and their
69
+ * only job before anything is typed is to say **how many characters are expected and where
70
+ * they go**. With no fill and no border there is nothing to count. It is the reason the
71
+ * `Checkbox` has no `ghost` either — a box that is not a box is not a box.
72
+ *
73
+ * HeroUI splits their OTP slot the same two ways their input is split, and they reach for
74
+ * the `field` shadow on `primary` here explicitly — which is the same reading our `Input`
75
+ * takes.
76
+ */
77
+ type InputOTPVariant = 'primary' | 'secondary' | 'tertiary';
78
+ /**
79
+ * Three of the four, and `xs` is the one missing. The box's width is the control height
80
+ * less one spacing step, so `xs` is 28 by 32 — a box that small has to carry an 18pt
81
+ * character to stay legible, and 18 in 28 leaves no room for the two-point active ring
82
+ * without the digit touching it. A code is also the one field a user reads back to
83
+ * themselves character by character, which is the worst place to save eight points.
84
+ *
85
+ * `sm` is the compact size; below it, use fewer boxes rather than smaller ones.
86
+ */
87
+ type InputOTPSize = Exclude<Size, 'xs'>;
88
+ /** What the boxes are allowed to contain. A string is compiled once, per §. */
89
+ type InputOTPPattern = string | RegExp;
90
+ /** What `ref` gives you: the three things only the hidden input can do. */
91
+ type InputOTPHandle = {
92
+ focus: () => void;
93
+ blur: () => void;
94
+ clear: () => void;
95
+ };
96
+ type InputOTPOwnProps = {
97
+ /** How many boxes, and therefore how long the code is. */
98
+ maxLength: number;
99
+ variant?: InputOTPVariant;
100
+ /** The box's height and width, the type inside it, and the gaps. */
101
+ size?: InputOTPSize;
102
+ /** Overrides the `lg` radius the theme chose for every size. */
103
+ radius?: RadiusKey;
104
+ /**
105
+ * A raw tint (`'#7c3aed'`), never a token (R7). It lands where the variant put its
106
+ * tokens, and it is also the ring the active box takes — the focus colour is a role
107
+ * like any other.
108
+ */
109
+ color?: string;
110
+ /** Controlled. Leave it out and the component keeps the value itself. */
111
+ value?: string;
112
+ /** The starting value when uncontrolled. */
113
+ defaultValue?: string;
114
+ onChangeText?: (value: string) => void;
115
+ /** Fired once the last box is filled — the only event most callers need. */
116
+ onComplete?: (value: string) => void;
117
+ /**
118
+ * What a box may contain. `OTP_DIGITS`, `OTP_LETTERS` and `OTP_ALPHANUMERIC` are
119
+ * exported for the three usual answers; anything else is your own expression.
120
+ *
121
+ * It is tested against the **whole** value rather than each character, so a pattern
122
+ * that allows a shape rather than a set works too.
123
+ */
124
+ pattern?: InputOTPPattern;
125
+ /**
126
+ * One character per box, or a single character repeated across all of them. Shown only
127
+ * where there is neither a typed character nor the caret.
128
+ */
129
+ placeholder?: string;
130
+ /** Paints the boxes in `danger` and takes the active ring off the accent. */
131
+ isInvalid?: boolean;
132
+ /** Dims the boxes and stops the hidden input. */
133
+ isDisabled?: boolean;
134
+ /** The keyboard the hidden input asks for. @default 'numeric' */
135
+ inputMode?: TextInputProps['inputMode'];
136
+ /**
137
+ * Everything else the hidden `TextInput` should carry — `autoComplete="one-time-code"`,
138
+ * `textContentType`, `onSubmitEditing`. It is a prop rather than a slot because the
139
+ * input is not composed: it is the one node this component owns and hides.
140
+ */
141
+ textInputProps?: Omit<TextInputProps, 'value' | 'defaultValue' | 'onChangeText' | 'onFocus' | 'onBlur' | 'editable' | 'maxLength' | 'style'>;
142
+ style?: StyleProp<ViewStyle>;
143
+ children?: ReactNode;
144
+ };
145
+ /**
146
+ * R14 — the component's own props, the `Pressable`'s, and every `ViewStyle` key neither
147
+ * already claims.
148
+ *
149
+ * **No `asChild`** (the one root in the library without it, deliberately): this root is
150
+ * not a pass-through container. It owns a hidden `TextInput` that has to be its own
151
+ * child, and `Slot` merges into a *single* element. A caller who wants their own element
152
+ * around the boxes wraps the `InputOTP` instead of replacing it.
153
+ */
154
+ type InputOTPProps = InputOTPOwnProps & Omit<ViewProps, keyof InputOTPOwnProps> & Omit<ViewStyleProps, keyof InputOTPOwnProps | keyof ViewProps>;
155
+ /** `View`'s own props win over the `ViewStyle` keys of the same name (R14). */
156
+ type InputOTPViewProps = ViewProps & Omit<ViewStyleProps, keyof ViewProps> & {
157
+ children?: ReactNode;
158
+ };
159
+ /**
160
+ * A group takes a render function as well as elements, which is what lets a caller draw
161
+ * `maxLength` boxes without writing them out — the one place in the library where a slot
162
+ * does, because the number of children is data here rather than markup.
163
+ */
164
+ type InputOTPGroupProps = Omit<InputOTPViewProps, 'children'> & {
165
+ children?: ReactNode | ((state: InputOTPRenderState) => ReactNode);
166
+ };
167
+ /** What the render function is handed. Everything the boxes are drawn from. */
168
+ type InputOTPRenderState = {
169
+ slots: readonly OTPSlotState[];
170
+ value: string;
171
+ maxLength: number;
172
+ isFocused: boolean;
173
+ isDisabled: boolean;
174
+ isInvalid: boolean;
175
+ };
176
+ type InputOTPBoxProps = Omit<InputOTPViewProps, 'children'> & {
177
+ /** Which box this is. It is what the root's state is read by. */
178
+ index: number;
179
+ /** Replaces the value, the placeholder and the caret with your own. */
180
+ children?: ReactNode;
181
+ };
182
+ type InputOTPSeparatorProps = InputOTPViewProps;
183
+ /** `Text`'s own props win over the `TextStyle` keys of the same name (R14). */
184
+ type InputOTPTextProps = TextProps & Omit<TextStyleProps, keyof TextProps> & {
185
+ children?: ReactNode;
186
+ };
187
+ type InputOTPValueProps = InputOTPTextProps;
188
+ type InputOTPPlaceholderProps = InputOTPTextProps;
189
+ type InputOTPCaretOwnProps = {
190
+ /** `false` stops the blink. The bar stays, so nothing moves. */
191
+ animation?: boolean;
192
+ style?: StyleProp<ViewStyle>;
193
+ };
194
+ type InputOTPCaretProps = InputOTPCaretOwnProps & Omit<ViewStyleProps, keyof InputOTPCaretOwnProps>;
195
+ /**
196
+ * R5 — resolved styles, not props for a slot to resolve a second time.
197
+ *
198
+ * The box comes in two, because exactly one box is active at a time and a slot that
199
+ * resolved its own would be re-running the recipe per box. The root resolves both once —
200
+ * two cache reads — and each box picks the reference that applies to it.
201
+ */
202
+ type InputOTPContextValue = {
203
+ groupStyle: StyleProp<ViewStyle>;
204
+ boxStyle: StyleProp<ViewStyle>;
205
+ boxActiveStyle: StyleProp<ViewStyle>;
206
+ valueStyle: StyleProp<TextStyle>;
207
+ placeholderStyle: StyleProp<TextStyle>;
208
+ caretStyle: StyleProp<ViewStyle>;
209
+ separatorStyle: StyleProp<ViewStyle>;
210
+ slots: readonly OTPSlotState[];
211
+ value: string;
212
+ maxLength: number;
213
+ isFocused: boolean;
214
+ isDisabled: boolean;
215
+ isInvalid: boolean;
216
+ /** So a custom box, or a "change number" link, can put the caret back. */
217
+ inputRef: RefObject<TextInput | null>;
218
+ };
219
+ /** What one box publishes to whatever it contains. */
220
+ type InputOTPBoxContextValue = {
221
+ slot: OTPSlotState | undefined;
222
+ };
223
+
224
+ /**
225
+ * The bar in the box the next character lands in.
226
+ *
227
+ * It is ours rather than the platform's: the real caret belongs to the hidden input,
228
+ * which is stretched across the whole row, so it would sit wherever the invisible text
229
+ * happens to end rather than in the box the reader is looking at. `caretHidden` on that
230
+ * input is the other half of the same decision.
231
+ *
232
+ * It renders only while its box is active **and** empty — a bar over a character would
233
+ * cross it out.
234
+ */
235
+ declare function InputOTPCaret({ style, animation, ...props }: InputOTPCaretProps): react.JSX.Element | null;
236
+ declare namespace InputOTPCaret {
237
+ var displayName: string;
238
+ }
239
+
240
+ declare const useInputOTP: () => InputOTPContextValue;
241
+ declare const useInputOTPBox: () => InputOTPBoxContextValue;
242
+
243
+ declare const inputOTPRecipe: Recipe<"value" | "separator" | "group" | "root" | "placeholder" | "box" | "caret", InputOTPVariant, {
244
+ readonly size: {
245
+ readonly sm: (theme: XAUITheme) => SlotStyles<InputOTPSlot>;
246
+ readonly md: (theme: XAUITheme) => SlotStyles<InputOTPSlot>;
247
+ readonly lg: (theme: XAUITheme) => SlotStyles<InputOTPSlot>;
248
+ };
249
+ readonly radius: Record<RadiusKey, StyleFn<"box">>;
250
+ /**
251
+ * Declared after `size` and before the states, so a code that is wrong stays wrong
252
+ * under the finger: the ring below reads `borderFocus`, and the root hands it the
253
+ * danger colour by suppressing the active state and painting every box instead.
254
+ */
255
+ readonly isInvalid: {
256
+ readonly true: (theme: XAUITheme) => {
257
+ box: {
258
+ borderColor: string;
259
+ borderWidth: number;
260
+ };
261
+ };
262
+ };
263
+ }>;
264
+
265
+ declare const InputOTP: react.ForwardRefExoticComponent<{
266
+ maxLength: number;
267
+ variant?: InputOTPVariant;
268
+ size?: InputOTPSize;
269
+ radius?: RadiusKey;
270
+ color?: string;
271
+ value?: string;
272
+ defaultValue?: string;
273
+ onChangeText?: (value: string) => void;
274
+ onComplete?: (value: string) => void;
275
+ pattern?: InputOTPPattern;
276
+ placeholder?: string;
277
+ isInvalid?: boolean;
278
+ isDisabled?: boolean;
279
+ inputMode?: react_native.TextInputProps["inputMode"];
280
+ textInputProps?: Omit<react_native.TextInputProps, "value" | "defaultValue" | "onChangeText" | "onFocus" | "onBlur" | "editable" | "maxLength" | "style">;
281
+ style?: react_native.StyleProp<react_native.ViewStyle>;
282
+ children?: react.ReactNode;
283
+ } & Omit<react_native.ViewProps, keyof {
284
+ maxLength: number;
285
+ variant?: InputOTPVariant;
286
+ size?: InputOTPSize;
287
+ radius?: RadiusKey;
288
+ color?: string;
289
+ value?: string;
290
+ defaultValue?: string;
291
+ onChangeText?: (value: string) => void;
292
+ onComplete?: (value: string) => void;
293
+ pattern?: InputOTPPattern;
294
+ placeholder?: string;
295
+ isInvalid?: boolean;
296
+ isDisabled?: boolean;
297
+ inputMode?: react_native.TextInputProps["inputMode"];
298
+ textInputProps?: Omit<react_native.TextInputProps, "value" | "defaultValue" | "onChangeText" | "onFocus" | "onBlur" | "editable" | "maxLength" | "style">;
299
+ style?: react_native.StyleProp<react_native.ViewStyle>;
300
+ children?: react.ReactNode;
301
+ }> & Omit<ViewStyleProps, "color" | "value" | "pointerEvents" | "style" | "children" | "hitSlop" | "id" | "needsOffscreenAlphaCompositing" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "onBlur" | "onFocus" | "renderToHardwareTextureAndroid" | "focusable" | "tabIndex" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerUp" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "role" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | "pattern" | "isDisabled" | "radius" | "size" | "variant" | "placeholder" | "isInvalid" | "defaultValue" | "inputMode" | "maxLength" | "onChangeText" | "onComplete" | "textInputProps"> & react.RefAttributes<InputOTPHandle>> & {
302
+ Group: react.ForwardRefExoticComponent<Omit<react_native.ViewProps & Omit<ViewStyleProps, keyof react_native.ViewProps> & {
303
+ children?: react.ReactNode;
304
+ }, "children"> & {
305
+ children?: react.ReactNode | ((state: InputOTPRenderState) => react.ReactNode);
306
+ } & react.RefAttributes<react_native.View>>;
307
+ Box: react.ForwardRefExoticComponent<Omit<react_native.ViewProps & Omit<ViewStyleProps, keyof react_native.ViewProps> & {
308
+ children?: react.ReactNode;
309
+ }, "children"> & {
310
+ index: number;
311
+ children?: react.ReactNode;
312
+ } & react.RefAttributes<react_native.View>>;
313
+ Value: react.ForwardRefExoticComponent<react_native.TextProps & Omit<TextStyleProps, keyof react_native.TextProps> & {
314
+ children?: react.ReactNode;
315
+ } & react.RefAttributes<react_native.Text>>;
316
+ Placeholder: react.ForwardRefExoticComponent<react_native.TextProps & Omit<TextStyleProps, keyof react_native.TextProps> & {
317
+ children?: react.ReactNode;
318
+ } & react.RefAttributes<react_native.Text>>;
319
+ Caret: typeof InputOTPCaret;
320
+ Separator: react.ForwardRefExoticComponent<react_native.ViewProps & Omit<ViewStyleProps, keyof react_native.ViewProps> & {
321
+ children?: react.ReactNode;
322
+ } & react.RefAttributes<react_native.View>>;
323
+ };
324
+
325
+ export { InputOTP, type InputOTPBoxContextValue, type InputOTPBoxProps, type InputOTPCaretProps, type InputOTPContextValue, type InputOTPGroupProps, type InputOTPHandle, type InputOTPPattern, type InputOTPPlaceholderProps, type InputOTPProps, type InputOTPRenderState, type InputOTPSeparatorProps, type InputOTPSize, type InputOTPSlot, type InputOTPValueProps, type InputOTPVariant, type OTPSlotState, OTP_ALPHANUMERIC, OTP_DIGITS, OTP_LETTERS, buildSlots, extractPastedCode, inputOTPRecipe, useInputOTP, useInputOTPBox };