@fuf-stack/uniform 1.27.0 → 2.0.0-next.1
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/README.md +9 -0
- package/dist/Checkboxes/index.d.mts +192 -263
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +294 -90
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +1282 -500
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +403 -83
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.d.mts +105 -98
- package/dist/FieldArray/index.d.mts.map +1 -1
- package/dist/FieldArray/index.mjs +344 -195
- package/dist/FieldArray/index.mjs.map +1 -1
- package/dist/FieldCard/index.d.mts +37 -35
- package/dist/FieldCard/index.d.mts.map +1 -1
- package/dist/FieldCard/index.mjs +187 -128
- package/dist/FieldCard/index.mjs.map +1 -1
- package/dist/{FieldCopyTestIdButton-CRJBix9D.mjs → FieldCopyTestIdButton-DV0tkdh2.mjs} +5 -3
- package/dist/FieldCopyTestIdButton-DV0tkdh2.mjs.map +1 -0
- package/dist/FieldDescription-C4l0HKGL.mjs +36 -0
- package/dist/FieldDescription-C4l0HKGL.mjs.map +1 -0
- package/dist/FieldLabel-DKzqkuY1.mjs +125 -0
- package/dist/FieldLabel-DKzqkuY1.mjs.map +1 -0
- package/dist/FieldLayout-BLW5S-Jm.mjs +46 -0
- package/dist/FieldLayout-BLW5S-Jm.mjs.map +1 -0
- package/dist/FieldValidationError-DgkCL3cC.mjs +77 -0
- package/dist/FieldValidationError-DgkCL3cC.mjs.map +1 -0
- package/dist/Form/index.d.mts +11 -11
- package/dist/Form/index.d.mts.map +1 -1
- package/dist/Form/index.mjs +14 -11
- package/dist/Form/index.mjs.map +1 -1
- package/dist/FormContext-CHctWFAP.mjs +520 -0
- package/dist/FormContext-CHctWFAP.mjs.map +1 -0
- package/dist/FormContext-CsFiNvuJ.d.mts.map +1 -1
- package/dist/Grid/index.mjs +1 -2
- package/dist/{Grid-CTs-Rb9G.mjs → Grid-DfcZeuib.mjs} +4 -2
- package/dist/Grid-DfcZeuib.mjs.map +1 -0
- package/dist/Input/index.d.mts +640 -392
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +421 -76
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +1583 -120
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +159 -114
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +300 -81
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +277 -86
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +1353 -108
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +105 -54
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +558 -3013
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +319 -177
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +414 -1326
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +276 -94
- package/dist/Slider/index.mjs.map +1 -1
- package/dist/SubmitButton/index.d.mts.map +1 -1
- package/dist/SubmitButton/index.mjs +4 -1
- package/dist/SubmitButton/index.mjs.map +1 -1
- package/dist/Switch/index.d.mts +2 -1248
- package/dist/Switch/index.mjs +167 -68
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/Switch-CvPO8IF9.d.mts +601 -0
- package/dist/Switch-CvPO8IF9.d.mts.map +1 -0
- package/dist/SwitchBox/index.d.mts +139 -43
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +142 -87
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +295 -411
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +200 -48
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +1170 -601
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +162 -74
- package/dist/Time/index.mjs.map +1 -1
- package/dist/helpers/index.d.mts +1 -1
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/index.mjs.map +1 -1
- package/dist/hooks/useClientValidation/index.mjs +1 -1
- package/dist/hooks/useController/index.d.mts +31 -3
- package/dist/hooks/useController/index.d.mts.map +1 -0
- package/dist/hooks/useController/index.mjs +1 -2
- package/dist/hooks/useFormContext/index.d.mts +65 -3
- package/dist/hooks/useFormContext/index.d.mts.map +1 -0
- package/dist/hooks/useFormContext/index.mjs +1 -2
- package/dist/hooks/useInputValueDebounce/index.d.mts +11 -5
- package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.mjs +27 -5
- package/dist/hooks/useInputValueDebounce/index.mjs.map +1 -1
- package/dist/hooks/useInputValueTransform/index.d.mts +1 -2
- package/dist/hooks/useInputValueTransform/index.mjs +1 -2
- package/dist/hooks/useWatchFormReset/index.mjs +1 -1
- package/dist/hooks/useWatchUserChange/index.d.mts +2 -2
- package/dist/hooks/useWatchUserChange/index.d.mts.map +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs.map +1 -1
- package/dist/{useInputValueTransform-LOaEim7k.d.mts → index-BS8IoBOn.d.mts} +3 -3
- package/dist/index-BS8IoBOn.d.mts.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -2
- package/dist/partials/FieldValidationError/index.d.mts +637 -3
- package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
- package/dist/partials/FieldValidationError/index.mjs +1 -2
- package/dist/radioControlVariants-Cm6WufWo.mjs +188 -0
- package/dist/radioControlVariants-Cm6WufWo.mjs.map +1 -0
- package/dist/switchVariants-BaQw2DA7.mjs +67 -0
- package/dist/switchVariants-BaQw2DA7.mjs.map +1 -0
- package/dist/timeVariants-B9HDfNYt.mjs +58 -0
- package/dist/timeVariants-B9HDfNYt.mjs.map +1 -0
- package/dist/{useController-CK39i6HI.mjs → useController-BCFeZbBZ.mjs} +2 -2
- package/dist/{useController-CK39i6HI.mjs.map → useController-BCFeZbBZ.mjs.map} +1 -1
- package/dist/{useFormContext-fYWtlnpE.mjs → useFormContext-BPjJjNnM.mjs} +2 -2
- package/dist/{useFormContext-fYWtlnpE.mjs.map → useFormContext-BPjJjNnM.mjs.map} +1 -1
- package/dist/{useInputValueTransform-DJ5zkqSy.mjs → useInputValueTransform-Mw8YEOXT.mjs} +2 -2
- package/dist/{useInputValueTransform-DJ5zkqSy.mjs.map → useInputValueTransform-Mw8YEOXT.mjs.map} +1 -1
- package/package.json +17 -29
- package/dist/FieldCopyTestIdButton-CRJBix9D.mjs.map +0 -1
- package/dist/FieldValidationError-ByRoIxaM.mjs +0 -50
- package/dist/FieldValidationError-ByRoIxaM.mjs.map +0 -1
- package/dist/FormContext-gHSwOlcy.mjs +0 -278
- package/dist/FormContext-gHSwOlcy.mjs.map +0 -1
- package/dist/Grid-CTs-Rb9G.mjs.map +0 -1
- package/dist/Switch/index.d.mts.map +0 -1
- package/dist/hooks/useInput/index.d.mts +0 -2
- package/dist/hooks/useInput/index.mjs +0 -7
- package/dist/hooks/useInput/index.mjs.map +0 -1
- package/dist/hooks/useUniformField/index.d.mts +0 -98
- package/dist/hooks/useUniformField/index.d.mts.map +0 -1
- package/dist/hooks/useUniformField/index.mjs +0 -137
- package/dist/hooks/useUniformField/index.mjs.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.d.mts +0 -73
- package/dist/hooks/useUniformFieldArray/index.d.mts.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.mjs +0 -101
- package/dist/hooks/useUniformFieldArray/index.mjs.map +0 -1
- package/dist/index-CAdGtKE_.d.mts +0 -1
- package/dist/index-CaxrMD1A.d.mts +0 -1
- package/dist/index-D5HVU2jP.d.mts +0 -1
- package/dist/useController-DcK2YHbw.d.mts +0 -32
- package/dist/useController-DcK2YHbw.d.mts.map +0 -1
- package/dist/useFormContext-B3QGVVaO.d.mts +0 -66
- package/dist/useFormContext-B3QGVVaO.d.mts.map +0 -1
- package/dist/useInput-C0aJaAGe.mjs +0 -2
- package/dist/useInput-ClpHDPdr.d.mts +0 -2
- package/dist/useInputValueTransform-LOaEim7k.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/Input/Input.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/Input/inputVariants.ts","../../src/Input/Input.tsx"],"mappings":";;;;;qBAKa,iBAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsGd,YAAY,mBAAmB;;;UCjG1B;;EAEf;;EAEA,YAAY;;EAEZ;;EAEA;;EAEA,cAAc;;EAEd;;EAEA,aAAa;;EAEb;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,eAAe;;EAEf;;EAEA,YAAY;;EAEZ;;;cAII,UAAS,WAAA,WAAA,eAAA,YAAA,cAAA,MAAA,MAAA,oBAAA,MAAA,SAAA,gBAAA,gBAaZ,+BAAU,IAAA"}
|
package/dist/Input/index.mjs
CHANGED
|
@@ -1,97 +1,442 @@
|
|
|
1
|
-
import { useUniformField } from "../
|
|
1
|
+
import { n as useUniformField } from "../FieldLabel-DKzqkuY1.mjs";
|
|
2
|
+
import { n as getFieldControlProps, r as getFieldDataAttributes } from "../FieldDescription-C4l0HKGL.mjs";
|
|
3
|
+
import { t as FieldLayout } from "../FieldLayout-BLW5S-Jm.mjs";
|
|
2
4
|
import { useInputValueDebounce } from "../hooks/useInputValueDebounce/index.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { tv } from "@fuf-stack/pixel-utils";
|
|
8
|
+
import { FaEye, FaEyeSlash } from "react-icons/fa6";
|
|
9
|
+
import { useStyling } from "@fuf-stack/pixels/StylingProvider";
|
|
10
|
+
import { Button, Group, Input, NumberField, TextField } from "react-aria-components";
|
|
11
|
+
import { useFocusRing } from "react-aria/useFocusRing";
|
|
12
|
+
import { useObjectRef } from "react-aria/useObjectRef";
|
|
13
|
+
//#region src/Input/inputVariants.ts
|
|
14
|
+
/** Default styles for all public Input slots */
|
|
15
|
+
const inputVariants = tv({
|
|
16
|
+
slots: {
|
|
17
|
+
/** Container grouping the label, control and hints */
|
|
18
|
+
base: "group relative flex w-full flex-col",
|
|
19
|
+
/** Button for clearing the current value */
|
|
20
|
+
clearButton: ["absolute end-3 z-10 -m-2 cursor-pointer rounded-full p-2 text-large opacity-70 outline-none", "hover:opacity-100 focus-visible:outline-2 focus-visible:outline-focus"],
|
|
21
|
+
/** Supporting text below the input */
|
|
22
|
+
description: "text-tiny text-foreground-500",
|
|
23
|
+
/** Container for validation messages */
|
|
24
|
+
errorMessage: "text-tiny text-danger",
|
|
25
|
+
/** Container for help text and validation messages */
|
|
26
|
+
helperWrapper: "relative flex flex-col p-0",
|
|
27
|
+
/** Row containing the input, addons and actions */
|
|
28
|
+
innerWrapper: "inline-flex h-full w-full items-center gap-0",
|
|
29
|
+
/** Native input for text or numeric entry */
|
|
30
|
+
input: [
|
|
31
|
+
"w-full min-w-0 bg-transparent bg-clip-text text-small font-normal text-inherit outline-none",
|
|
32
|
+
"placeholder:text-foreground-500 autofill:bg-transparent",
|
|
33
|
+
"data-[has-end-content=true]:pe-1.5 data-[has-start-content=true]:ps-1.5",
|
|
34
|
+
"dark:autofill:[-webkit-text-fill-color:var(--pixel-color-foreground)] [&::-ms-reveal]:hidden"
|
|
35
|
+
],
|
|
36
|
+
/** Bordered container around the editable area */
|
|
37
|
+
inputWrapper: [
|
|
38
|
+
"relative inline-flex h-10 min-h-10 w-full cursor-text items-center shadow-xs",
|
|
39
|
+
"rounded-small border-medium border-default-200 bg-content1 px-3 text-foreground",
|
|
40
|
+
"transition-colors",
|
|
41
|
+
"group-data-[disabled=true]:pointer-events-none group-data-[focus=true]:border-focus group-data-[invalid=true]:border-danger data-[hovered=true]:border-default-400 group-data-[focus=true]:data-[hovered=true]:border-default-foreground",
|
|
42
|
+
"motion-reduce:transition-none"
|
|
43
|
+
],
|
|
44
|
+
/** Label above the input */
|
|
45
|
+
label: "block cursor-default pb-1 text-small text-foreground group-data-[invalid=true]:text-danger",
|
|
46
|
+
/** Button for revealing or masking a password */
|
|
47
|
+
passwordToggle: "shrink-0 rounded-sm p-1 text-default-400 outline-none focus-visible:ring-2 focus-visible:ring-focus",
|
|
48
|
+
/** Container grouping increment and decrement buttons */
|
|
49
|
+
stepper: "flex h-full flex-col justify-center ps-1",
|
|
50
|
+
/** Buttons for increasing or decreasing the numeric value */
|
|
51
|
+
stepperButton: ["flex h-3 w-3 items-center justify-center text-default-foreground outline-none", "hover:opacity-hover focus-visible:outline-2 focus-visible:outline-focus"]
|
|
52
|
+
},
|
|
53
|
+
variants: {
|
|
54
|
+
filled: { true: {
|
|
55
|
+
base: "is-filled",
|
|
56
|
+
input: "is-filled",
|
|
57
|
+
inputWrapper: "is-filled"
|
|
58
|
+
} },
|
|
59
|
+
number: { true: { clearButton: "relative" } },
|
|
60
|
+
password: { true: {
|
|
61
|
+
clearButton: "relative end-auto m-0 p-1",
|
|
62
|
+
innerWrapper: "gap-2"
|
|
63
|
+
} },
|
|
64
|
+
clearable: { true: { input: "pe-6" } },
|
|
65
|
+
size: {
|
|
66
|
+
lg: {
|
|
67
|
+
input: "text-medium",
|
|
68
|
+
inputWrapper: "h-12 min-h-12",
|
|
69
|
+
label: "text-medium"
|
|
70
|
+
},
|
|
71
|
+
md: {},
|
|
72
|
+
sm: {
|
|
73
|
+
clearButton: "text-medium",
|
|
74
|
+
input: "text-small",
|
|
75
|
+
inputWrapper: "h-8 min-h-8 px-2",
|
|
76
|
+
label: "text-tiny"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
disabled: { true: { base: "pointer-events-none opacity-disabled" } },
|
|
80
|
+
invalid: { true: {
|
|
81
|
+
input: "text-danger",
|
|
82
|
+
inputWrapper: "border-danger group-data-[focus=true]:border-danger data-[hovered=true]:border-danger group-data-[focus=true]:data-[hovered=true]:border-danger",
|
|
83
|
+
label: "text-danger"
|
|
84
|
+
} }
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/Input/subcomponents/InputField.tsx
|
|
18
89
|
/**
|
|
19
|
-
*
|
|
90
|
+
* React Aria field root for text, password and number inputs.
|
|
91
|
+
*
|
|
92
|
+
* Provides TextField or NumberField context to the editable content and actions,
|
|
93
|
+
* forwards validation/accessibility state, and adapts numeric values to the
|
|
94
|
+
* binding's string display values. Preserves Uniform's root styling selectors.
|
|
95
|
+
*
|
|
96
|
+
* @see https://react-aria.adobe.com/TextField
|
|
97
|
+
* @see https://react-aria.adobe.com/NumberField
|
|
20
98
|
*/
|
|
21
|
-
const
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const clearableProps = clearable ? {
|
|
35
|
-
isClearable: true,
|
|
36
|
-
onClear: () => {
|
|
37
|
-
resetField(name, { defaultValue: null });
|
|
38
|
-
if (onClear) onClear();
|
|
39
|
-
}
|
|
40
|
-
} : {};
|
|
41
|
-
const variants = inputVariants();
|
|
42
|
-
const classNames = variantsToClassNames(variants, _className, "base");
|
|
43
|
-
const commonProps = {
|
|
44
|
-
ref,
|
|
45
|
-
"aria-label": !placeholder || placeholder.trim() === "" ? ariaLabel : void 0,
|
|
46
|
-
autoComplete: "off",
|
|
47
|
-
classNames: {
|
|
48
|
-
base: classNames.base,
|
|
49
|
-
clearButton: classNames.clearButton,
|
|
50
|
-
helperWrapper: "p-0",
|
|
51
|
-
input: classNames.input,
|
|
52
|
-
inputWrapper: classNames.inputWrapper
|
|
53
|
-
},
|
|
54
|
-
"data-testid": testId,
|
|
55
|
-
endContent,
|
|
56
|
-
errorMessage,
|
|
57
|
-
id: testId,
|
|
99
|
+
const InputField = ({ field, type, children, className = void 0, focused, hasValue, isFocusVisible }) => {
|
|
100
|
+
const { disabled, invalid, name, onBlur, onChange: onValueChange, required, value } = field;
|
|
101
|
+
const controlProps = getFieldControlProps(field);
|
|
102
|
+
const dataAttributes = getFieldDataAttributes(field);
|
|
103
|
+
const rootProps = {
|
|
104
|
+
...controlProps,
|
|
105
|
+
...dataAttributes,
|
|
106
|
+
className,
|
|
107
|
+
"data-component": "input",
|
|
108
|
+
"data-filled": hasValue || void 0,
|
|
109
|
+
"data-focus": focused || void 0,
|
|
110
|
+
"data-focus-visible": isFocusVisible || void 0,
|
|
111
|
+
"data-slot": "base",
|
|
58
112
|
isDisabled: disabled,
|
|
59
113
|
isInvalid: invalid,
|
|
60
114
|
isRequired: required,
|
|
61
|
-
label,
|
|
62
|
-
labelPlacement: "outside",
|
|
63
115
|
name,
|
|
64
116
|
onBlur,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
variant: "bordered",
|
|
70
|
-
...clearableProps
|
|
117
|
+
validationBehavior: "aria"
|
|
118
|
+
};
|
|
119
|
+
const handleNumberChange = (next) => {
|
|
120
|
+
onValueChange(Number.isNaN(next) ? "" : String(next));
|
|
71
121
|
};
|
|
72
122
|
if (type === "number") {
|
|
73
|
-
const
|
|
74
|
-
return /* @__PURE__ */ jsx(
|
|
75
|
-
...
|
|
123
|
+
const numericValue = value !== "" && value != null ? Number(value) : NaN;
|
|
124
|
+
return /* @__PURE__ */ jsx(NumberField, {
|
|
125
|
+
...rootProps,
|
|
76
126
|
formatOptions: { useGrouping: false },
|
|
77
|
-
onChange:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
value: numberValue
|
|
127
|
+
onChange: handleNumberChange,
|
|
128
|
+
value: numericValue,
|
|
129
|
+
children
|
|
82
130
|
});
|
|
83
131
|
}
|
|
84
|
-
return /* @__PURE__ */ jsx(
|
|
85
|
-
...
|
|
86
|
-
onChange,
|
|
87
|
-
type,
|
|
88
|
-
value
|
|
132
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
133
|
+
...rootProps,
|
|
134
|
+
onChange: onValueChange,
|
|
135
|
+
type: type ?? "text",
|
|
136
|
+
value: String(value ?? ""),
|
|
137
|
+
children
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/Input/subcomponents/InputClearButton.tsx
|
|
142
|
+
/**
|
|
143
|
+
* React Aria Button that invokes the supplied clear action without taking focus.
|
|
144
|
+
*
|
|
145
|
+
* Uses slot=null to opt out of NumberField's increment/decrement button context.
|
|
146
|
+
* Renders custom end content when supplied, otherwise the default clear icon.
|
|
147
|
+
*
|
|
148
|
+
* @see https://react-aria.adobe.com/Button
|
|
149
|
+
* @see https://react-aria.adobe.com/NumberField
|
|
150
|
+
*/
|
|
151
|
+
const InputClearButton = ({ children = void 0, className, disabled = void 0, onClear }) => {
|
|
152
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
153
|
+
"aria-label": "clear input",
|
|
154
|
+
className,
|
|
155
|
+
"data-slot": "clear-button",
|
|
156
|
+
isDisabled: disabled,
|
|
157
|
+
onPress: onClear,
|
|
158
|
+
preventFocusOnPress: true,
|
|
159
|
+
slot: null,
|
|
160
|
+
children: children ?? /* @__PURE__ */ jsx("svg", {
|
|
161
|
+
"aria-hidden": true,
|
|
162
|
+
height: "1em",
|
|
163
|
+
viewBox: "0 0 24 24",
|
|
164
|
+
width: "1em",
|
|
165
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
166
|
+
d: "M12 2a10 10 0 1010 10A10.016 10.016 0 0012 2zm3.36 12.3a.754.754 0 010 1.06.748.748 0 01-1.06 0l-2.3-2.3-2.3 2.3a.748.748 0 01-1.06 0 .754.754 0 010-1.06l2.3-2.3-2.3-2.3A.75.75 0 019.7 8.64l2.3 2.3 2.3-2.3a.75.75 0 011.06 1.06l-2.3 2.3z",
|
|
167
|
+
fill: "currentColor"
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/Input/subcomponents/InputPasswordToggle.tsx
|
|
174
|
+
/**
|
|
175
|
+
* Password visibility action preserving input focus on pointer activation
|
|
176
|
+
*
|
|
177
|
+
* @see https://react-aria.adobe.com/Button
|
|
178
|
+
*/
|
|
179
|
+
const InputPasswordToggle = ({ className, controlId, disabled = false, onToggle, testId, visible }) => {
|
|
180
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
181
|
+
"aria-controls": controlId,
|
|
182
|
+
"aria-label": visible ? "Hide password" : "Show password",
|
|
183
|
+
"aria-pressed": visible,
|
|
184
|
+
className,
|
|
185
|
+
"data-testid": `${testId}_password_toggle`,
|
|
186
|
+
isDisabled: disabled,
|
|
187
|
+
onPress: onToggle,
|
|
188
|
+
preventFocusOnPress: true,
|
|
189
|
+
slot: null,
|
|
190
|
+
type: "button",
|
|
191
|
+
children: visible ? /* @__PURE__ */ jsx(FaEyeSlash, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(FaEye, { "aria-hidden": "true" })
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/Input/subcomponents/InputStepper.tsx
|
|
196
|
+
/** Decorative direction indicator for the number stepper buttons. */
|
|
197
|
+
const Chevron = ({ up = false }) => {
|
|
198
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
199
|
+
"aria-hidden": true,
|
|
200
|
+
fill: "none",
|
|
201
|
+
height: "1em",
|
|
202
|
+
stroke: "currentColor",
|
|
203
|
+
strokeLinecap: "round",
|
|
204
|
+
strokeLinejoin: "round",
|
|
205
|
+
strokeWidth: "1.5",
|
|
206
|
+
viewBox: "0 0 24 24",
|
|
207
|
+
width: "1em",
|
|
208
|
+
children: /* @__PURE__ */ jsx("path", { d: up ? "m18 15-6-6-6 6" : "m6 9 6 6 6-6" })
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Increment and decrement React Aria Buttons for the surrounding NumberField.
|
|
213
|
+
*
|
|
214
|
+
* Named slots connect each button to NumberField's value and disabled state.
|
|
215
|
+
* Keeps the controls outside the tab order so keyboard editing stays in the input.
|
|
216
|
+
*
|
|
217
|
+
* @see https://react-aria.adobe.com/NumberField
|
|
218
|
+
* @see https://react-aria.adobe.com/Button
|
|
219
|
+
*/
|
|
220
|
+
const InputStepper = ({ className }) => {
|
|
221
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
222
|
+
className: className.stepper,
|
|
223
|
+
"data-slot": "stepper-wrapper",
|
|
224
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
225
|
+
className: className.stepperButton,
|
|
226
|
+
"data-slot": "increase-button",
|
|
227
|
+
slot: "increment",
|
|
228
|
+
children: /* @__PURE__ */ jsx(Chevron, { up: true })
|
|
229
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
230
|
+
className: className.stepperButton,
|
|
231
|
+
"data-slot": "decrease-button",
|
|
232
|
+
slot: "decrement",
|
|
233
|
+
children: /* @__PURE__ */ jsx(Chevron, {})
|
|
234
|
+
})]
|
|
89
235
|
});
|
|
90
236
|
};
|
|
91
237
|
//#endregion
|
|
238
|
+
//#region src/Input/subcomponents/InputWrapper.tsx
|
|
239
|
+
/**
|
|
240
|
+
* Bordered input surface built from React Aria Group and Input
|
|
241
|
+
*
|
|
242
|
+
* Arranges addons, clear actions and number steppers around the native input,
|
|
243
|
+
* forwards its ref and accessibility attributes, and reports wrapper interactions.
|
|
244
|
+
* The surrounding InputField supplies the TextField or NumberField context.
|
|
245
|
+
*
|
|
246
|
+
* @see https://react-aria.adobe.com/Group
|
|
247
|
+
* @see https://react-aria.adobe.com/TextField (Input composition)
|
|
248
|
+
* @see https://react-aria.adobe.com/NumberField (Input and stepper composition)
|
|
249
|
+
*/
|
|
250
|
+
const InputWrapper = ({ field, clearable = false, endContent, hidePasswordToggle, inputRef, onClear, onFocusControl, onTogglePassword, passwordVisible, placeholder, startContent, type, className, focused, focusProps, hasValue }) => {
|
|
251
|
+
const { disabled, onChange: onValueChange, testId } = field;
|
|
252
|
+
const controlProps = getFieldControlProps(field);
|
|
253
|
+
const handleWrapperClick = (event) => {
|
|
254
|
+
if (!disabled && event.currentTarget === event.target) onFocusControl();
|
|
255
|
+
};
|
|
256
|
+
const handleChange = (event) => {
|
|
257
|
+
onValueChange(event.target.value);
|
|
258
|
+
};
|
|
259
|
+
const handleKeyDown = (event) => {
|
|
260
|
+
if (event.key === "Escape" && clearable && hasValue && !disabled) {
|
|
261
|
+
event.preventDefault();
|
|
262
|
+
onClear();
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
return /* @__PURE__ */ jsx(Group, {
|
|
266
|
+
...focusProps,
|
|
267
|
+
className: className.inputWrapper,
|
|
268
|
+
"data-focus": focused || void 0,
|
|
269
|
+
"data-slot": "input-wrapper",
|
|
270
|
+
isDisabled: disabled,
|
|
271
|
+
onClick: handleWrapperClick,
|
|
272
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
273
|
+
className: className.innerWrapper,
|
|
274
|
+
"data-slot": "inner-wrapper",
|
|
275
|
+
children: [
|
|
276
|
+
startContent,
|
|
277
|
+
/* @__PURE__ */ jsx(Input, {
|
|
278
|
+
...controlProps,
|
|
279
|
+
ref: inputRef,
|
|
280
|
+
autoComplete: "off",
|
|
281
|
+
className: className.input,
|
|
282
|
+
"data-filled": hasValue || void 0,
|
|
283
|
+
"data-has-end-content": !!endContent || clearable && hasValue || void 0,
|
|
284
|
+
"data-has-start-content": !!startContent || void 0,
|
|
285
|
+
"data-slot": "input",
|
|
286
|
+
"data-testid": testId,
|
|
287
|
+
onChange: type === "number" ? handleChange : void 0,
|
|
288
|
+
onKeyDown: handleKeyDown,
|
|
289
|
+
placeholder
|
|
290
|
+
}),
|
|
291
|
+
type === "password" ? endContent : null,
|
|
292
|
+
clearable && hasValue ? /* @__PURE__ */ jsx(InputClearButton, {
|
|
293
|
+
className: className.clearButton,
|
|
294
|
+
disabled,
|
|
295
|
+
onClear,
|
|
296
|
+
children: type !== "number" && type !== "password" && endContent ? endContent : void 0
|
|
297
|
+
}) : null,
|
|
298
|
+
type !== "password" && (!clearable || type === "number") ? endContent : null,
|
|
299
|
+
type === "password" && !hidePasswordToggle ? /* @__PURE__ */ jsx(InputPasswordToggle, {
|
|
300
|
+
className: className.passwordToggle,
|
|
301
|
+
controlId: field.ids.control,
|
|
302
|
+
disabled,
|
|
303
|
+
onToggle: onTogglePassword,
|
|
304
|
+
testId,
|
|
305
|
+
visible: passwordVisible
|
|
306
|
+
}) : null,
|
|
307
|
+
type === "number" ? /* @__PURE__ */ jsx(InputStepper, { className }) : null
|
|
308
|
+
]
|
|
309
|
+
})
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/Input/subcomponents/InputControl.tsx
|
|
314
|
+
/**
|
|
315
|
+
* Composes the Input presentation without registering a form field.
|
|
316
|
+
*
|
|
317
|
+
* Owns the editable ref, focus restoration and interaction styling.
|
|
318
|
+
* Connects InputField's Aria field root, FieldLayout and the editable content.
|
|
319
|
+
* Values, validation state and callbacks are supplied by the Input binding.
|
|
320
|
+
*
|
|
321
|
+
* @see https://react-aria.adobe.com/useFocusRing
|
|
322
|
+
* @see https://react-aria.adobe.com/TextField
|
|
323
|
+
* @see https://react-aria.adobe.com/NumberField
|
|
324
|
+
*/
|
|
325
|
+
const InputControl = (props) => {
|
|
326
|
+
const { field, subscribeReset } = props;
|
|
327
|
+
const styling = useStyling();
|
|
328
|
+
const [passwordVisible, setPasswordVisible] = useState(false);
|
|
329
|
+
useEffect(() => {
|
|
330
|
+
const handleReset = () => {
|
|
331
|
+
setPasswordVisible(false);
|
|
332
|
+
};
|
|
333
|
+
return subscribeReset?.(handleReset);
|
|
334
|
+
}, [subscribeReset]);
|
|
335
|
+
const controlRef = useObjectRef(field.ref);
|
|
336
|
+
const { focusProps, isFocused: focused, isFocusVisible } = useFocusRing({
|
|
337
|
+
isTextInput: true,
|
|
338
|
+
within: true
|
|
339
|
+
});
|
|
340
|
+
const { size, type, clearable, className, hidePasswordToggle, onClear, onReset } = props;
|
|
341
|
+
const displayType = type === "password" && !hidePasswordToggle && passwordVisible ? "text" : type;
|
|
342
|
+
const { value, disabled, invalid, label, required, ids, description, errorMessage } = field;
|
|
343
|
+
const hasValue = value !== "" && value != null;
|
|
344
|
+
const variants = styling.resolve(inputVariants, {
|
|
345
|
+
clearable,
|
|
346
|
+
disabled,
|
|
347
|
+
filled: hasValue,
|
|
348
|
+
invalid,
|
|
349
|
+
number: type === "number",
|
|
350
|
+
password: type === "password",
|
|
351
|
+
size
|
|
352
|
+
});
|
|
353
|
+
const classNames = styling.variantsToClassNames(variants, className, "base");
|
|
354
|
+
const handleFocus = () => {
|
|
355
|
+
controlRef.current?.focus();
|
|
356
|
+
};
|
|
357
|
+
const handleTogglePassword = () => {
|
|
358
|
+
setPasswordVisible((visible) => {
|
|
359
|
+
return !visible;
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
const handleClear = () => {
|
|
363
|
+
setPasswordVisible(false);
|
|
364
|
+
onReset();
|
|
365
|
+
onClear?.();
|
|
366
|
+
handleFocus();
|
|
367
|
+
};
|
|
368
|
+
return /* @__PURE__ */ jsx(FieldLayout, {
|
|
369
|
+
baseAs: InputField,
|
|
370
|
+
baseProps: {
|
|
371
|
+
field,
|
|
372
|
+
focused,
|
|
373
|
+
hasValue,
|
|
374
|
+
isFocusVisible,
|
|
375
|
+
type: displayType
|
|
376
|
+
},
|
|
377
|
+
className: classNames,
|
|
378
|
+
description,
|
|
379
|
+
errorMessage,
|
|
380
|
+
ids,
|
|
381
|
+
invalid,
|
|
382
|
+
label,
|
|
383
|
+
required,
|
|
384
|
+
children: /* @__PURE__ */ jsx(InputWrapper, {
|
|
385
|
+
...props,
|
|
386
|
+
className: classNames,
|
|
387
|
+
focusProps,
|
|
388
|
+
focused,
|
|
389
|
+
hasValue,
|
|
390
|
+
inputRef: controlRef,
|
|
391
|
+
onClear: handleClear,
|
|
392
|
+
onFocusControl: handleFocus,
|
|
393
|
+
onTogglePassword: handleTogglePassword,
|
|
394
|
+
passwordVisible
|
|
395
|
+
})
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/Input/Input.tsx
|
|
400
|
+
/** Form input field for text, passwords or numbers */
|
|
401
|
+
const Input$1 = ({ className = void 0, clearable = false, debounceDelay = 300, endContent = void 0, startContent = void 0, size = "md", type = void 0, hidePasswordToggle = false, name, onClear = void 0, placeholder = " ", ...uniformProps }) => {
|
|
402
|
+
const { field, formReset } = useUniformField({
|
|
403
|
+
...uniformProps,
|
|
404
|
+
name,
|
|
405
|
+
placeholder,
|
|
406
|
+
type
|
|
407
|
+
});
|
|
408
|
+
const { value, onChange, onBlur, clear } = useInputValueDebounce({
|
|
409
|
+
debounceDelay,
|
|
410
|
+
emptyValue: "",
|
|
411
|
+
name,
|
|
412
|
+
onBlur: field.onBlur,
|
|
413
|
+
onChange: field.onChange,
|
|
414
|
+
value: field.value
|
|
415
|
+
});
|
|
416
|
+
return /* @__PURE__ */ jsx(InputControl, {
|
|
417
|
+
hidePasswordToggle,
|
|
418
|
+
className,
|
|
419
|
+
clearable,
|
|
420
|
+
endContent,
|
|
421
|
+
field: {
|
|
422
|
+
...field,
|
|
423
|
+
onBlur,
|
|
424
|
+
onChange,
|
|
425
|
+
value
|
|
426
|
+
},
|
|
427
|
+
onClear,
|
|
428
|
+
onReset: clear,
|
|
429
|
+
placeholder,
|
|
430
|
+
size,
|
|
431
|
+
startContent,
|
|
432
|
+
subscribeReset: formReset.subscribe,
|
|
433
|
+
type
|
|
434
|
+
}, `${name}-${type}-${hidePasswordToggle}`);
|
|
435
|
+
};
|
|
436
|
+
//#endregion
|
|
92
437
|
//#region src/Input/index.ts
|
|
93
438
|
var Input_default = Input$1;
|
|
94
439
|
//#endregion
|
|
95
|
-
export { Input_default as default };
|
|
440
|
+
export { Input_default as default, inputVariants };
|
|
96
441
|
|
|
97
442
|
//# sourceMappingURL=index.mjs.map
|
package/dist/Input/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["Input","HeroNumberInput","HeroInput","Input"],"sources":["../../src/Input/Input.tsx","../../src/Input/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\n\nimport { Input as HeroInput } from '@heroui/input';\nimport { NumberInput as HeroNumberInput } from '@heroui/number-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport { useUniformField } from '../hooks/useUniformField';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform<string>;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n ariaLabel,\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, type, ...uniformFieldProps });\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n name,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n // Common props for both Input and NumberInput\n const commonProps = {\n ref,\n // Only add aria-label if there's no meaningful placeholder (HeroUI uses placeholder as aria-label)\n 'aria-label':\n !placeholder || placeholder.trim() === '' ? ariaLabel : undefined,\n // disable autocomplete\n autoComplete: 'off',\n classNames: {\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n },\n 'data-testid': testId,\n endContent,\n errorMessage,\n id: testId,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside' as const,\n name,\n onBlur,\n placeholder,\n radius: 'sm' as const,\n size,\n startContent,\n variant: 'bordered' as const,\n ...clearableProps,\n };\n\n // Render NumberInput for number type\n if (type === 'number') {\n // Parse the string value to number - use null for empty/cleared state to keep component controlled\n const numberValue =\n value !== '' && value != null && !Number.isNaN(Number(value))\n ? Number(value)\n : null;\n\n return (\n <HeroNumberInput\n {...commonProps}\n // Disable thousands separator to avoid parsing issues\n formatOptions={{\n useGrouping: false,\n }}\n // NumberInput onChange receives either an event or a number\n onChange={(e: React.ChangeEvent<HTMLInputElement> | number) => {\n if (typeof e === 'number') {\n // Convert number to synthetic event and pass through debounced onChange\n onChange({\n target: { value: String(e) },\n });\n } else {\n // Pass event through debounced onChange\n onChange(e);\n }\n }}\n // @ts-expect-error - HeroUI NumberInput type is not compatible with null,\n // but it needs to be for empty/cleared state to be controlled\n value={numberValue}\n />\n );\n }\n\n // Render regular Input for text/password\n return (\n <HeroInput {...commonProps} onChange={onChange} type={type} value={value} />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport default Input;\n"],"mappings":";;;;;;;AAcA,MAAa,gBAAgB,GAAG,EAC9B,OAAO;;CAEL,MAAM;;CAEN,aAAa;;CAEb,OAAO;;CAEP,cAAc;AAChB,EACF,CAAC;;;;AAyCD,MAAMA,WAAS,EACb,WAAW,aAAa,KAAA,GACxB,YAAY,OACZ,gBAAgB,KAChB,aAAa,KAAA,GACb,MACA,UAAU,KAAA,GACV,cAAc,KACd,OAAO,KAAA,GACP,eAAe,KAAA,GACf,OAAO,KAAA,GACP,GAAG,wBACa;CAChB,MAAM,EACJ,WACA,UACA,OAAO,EACL,U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1
|
+
{"version":3,"file":"index.mjs","names":["AriaInput","Input","Input"],"sources":["../../src/Input/inputVariants.ts","../../src/Input/subcomponents/InputField.tsx","../../src/Input/subcomponents/InputClearButton.tsx","../../src/Input/subcomponents/InputPasswordToggle.tsx","../../src/Input/subcomponents/InputStepper.tsx","../../src/Input/subcomponents/InputWrapper.tsx","../../src/Input/subcomponents/InputControl.tsx","../../src/Input/Input.tsx","../../src/Input/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\n/** Default styles for all public Input slots */\nexport const inputVariants = tv({\n slots: {\n /** Container grouping the label, control and hints */\n base: 'group relative flex w-full flex-col',\n /** Button for clearing the current value */\n clearButton: [\n // clear button placement and appearance\n 'absolute end-3 z-10 -m-2 cursor-pointer rounded-full p-2 text-large opacity-70 outline-none',\n // hover and keyboard focus\n 'hover:opacity-100 focus-visible:outline-2 focus-visible:outline-focus',\n ],\n /** Supporting text below the input */\n description: 'text-tiny text-foreground-500',\n /** Container for validation messages */\n errorMessage: 'text-tiny text-danger',\n /** Container for help text and validation messages */\n helperWrapper: 'relative flex flex-col p-0',\n /** Row containing the input, addons and actions */\n innerWrapper: 'inline-flex h-full w-full items-center gap-0',\n /** Native input for text or numeric entry */\n input: [\n // editable text and transparent surface\n 'w-full min-w-0 bg-transparent bg-clip-text text-small font-normal text-inherit outline-none',\n // placeholder and autofill\n 'placeholder:text-foreground-500 autofill:bg-transparent',\n // spacing around surrounding content\n 'data-[has-end-content=true]:pe-1.5 data-[has-start-content=true]:ps-1.5',\n // browser-specific input appearance\n 'dark:autofill:[-webkit-text-fill-color:var(--pixel-color-foreground)] [&::-ms-reveal]:hidden',\n ],\n /** Bordered container around the editable area */\n inputWrapper: [\n // input frame and layout\n 'relative inline-flex h-10 min-h-10 w-full cursor-text items-center shadow-xs',\n // bordered surface and text\n 'rounded-small border-medium border-default-200 bg-content1 px-3 text-foreground',\n // interaction transitions\n 'transition-colors',\n // hover, disabled and validation states\n 'group-data-[disabled=true]:pointer-events-none group-data-[focus=true]:border-focus group-data-[invalid=true]:border-danger data-[hovered=true]:border-default-400 group-data-[focus=true]:data-[hovered=true]:border-default-foreground',\n // reduced motion\n 'motion-reduce:transition-none',\n ],\n /** Label above the input */\n label:\n 'block cursor-default pb-1 text-small text-foreground group-data-[invalid=true]:text-danger',\n /** Button for revealing or masking a password */\n passwordToggle:\n 'shrink-0 rounded-sm p-1 text-default-400 outline-none focus-visible:ring-2 focus-visible:ring-focus',\n /** Container grouping increment and decrement buttons */\n stepper: 'flex h-full flex-col justify-center ps-1',\n /** Buttons for increasing or decreasing the numeric value */\n stepperButton: [\n // stepper button dimensions and appearance\n 'flex h-3 w-3 items-center justify-center text-default-foreground outline-none',\n // hover and keyboard focus\n 'hover:opacity-hover focus-visible:outline-2 focus-visible:outline-focus',\n ],\n },\n variants: {\n filled: {\n true: {\n base: 'is-filled',\n input: 'is-filled',\n inputWrapper: 'is-filled',\n },\n },\n number: { true: { clearButton: 'relative' } },\n password: {\n true: { clearButton: 'relative end-auto m-0 p-1', innerWrapper: 'gap-2' },\n },\n clearable: { true: { input: 'pe-6' } },\n size: {\n lg: {\n input: 'text-medium',\n inputWrapper: 'h-12 min-h-12',\n label: 'text-medium',\n },\n md: {},\n sm: {\n clearButton: 'text-medium',\n input: 'text-small',\n inputWrapper: 'h-8 min-h-8 px-2',\n label: 'text-tiny',\n },\n },\n disabled: { true: { base: 'pointer-events-none opacity-disabled' } },\n invalid: {\n true: {\n input: 'text-danger',\n inputWrapper:\n 'border-danger group-data-[focus=true]:border-danger data-[hovered=true]:border-danger group-data-[focus=true]:data-[hovered=true]:border-danger',\n label: 'text-danger',\n },\n },\n },\n});\n\n/** Variant options for the input styling slots */\nexport type VariantProps = TVProps<typeof inputVariants>;\n\n/** Class name overrides for the public Input styling slots. */\nexport type ClassName = TVClassName<typeof inputVariants>;\n\n/** Resolved class names for every Input styling slot. */\nexport type InputClassNames = Record<\n keyof ReturnType<typeof inputVariants>,\n string\n>;\n\nexport default inputVariants;\n","import type { ReactNode } from 'react';\nimport type { InputControlProps } from './InputControl';\n\nimport { NumberField, TextField } from 'react-aria-components';\n\nimport {\n getFieldControlProps,\n getFieldDataAttributes,\n} from '../../helpers/fieldProps/fieldProps';\n\ntype InputFieldProps = Pick<InputControlProps, 'field'> & {\n /** Selects the native display type without changing form registration */\n type?: 'text' | 'number' | 'password';\n /** Renders content inside the field */\n children: ReactNode;\n /** CSS class name */\n className?: string;\n /** Shows focus styling while focus is within the control */\n focused: boolean;\n /** Marks the input as filled when the display value is nonempty */\n hasValue: boolean;\n /** Shows the keyboard focus indicator */\n isFocusVisible: boolean;\n};\n\n/**\n * React Aria field root for text, password and number inputs.\n *\n * Provides TextField or NumberField context to the editable content and actions,\n * forwards validation/accessibility state, and adapts numeric values to the\n * binding's string display values. Preserves Uniform's root styling selectors.\n *\n * @see https://react-aria.adobe.com/TextField\n * @see https://react-aria.adobe.com/NumberField\n */\nconst InputField = ({\n field,\n type,\n children,\n className = undefined,\n focused,\n hasValue,\n isFocusVisible,\n}: InputFieldProps) => {\n const {\n disabled,\n invalid,\n name,\n onBlur,\n onChange: onValueChange,\n required,\n value,\n } = field;\n\n // associate the editable control with its label and messages\n const controlProps = getFieldControlProps(field);\n\n const dataAttributes = getFieldDataAttributes(field);\n\n // shared root props for the text and number field engines\n const rootProps = {\n ...controlProps,\n ...dataAttributes,\n className,\n 'data-component': 'input',\n 'data-filled': hasValue || undefined,\n 'data-focus': focused || undefined,\n 'data-focus-visible': isFocusVisible || undefined,\n 'data-slot': 'base',\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n name,\n onBlur,\n validationBehavior: 'aria' as const,\n };\n\n // keep numeric edits as strings at the binding boundary\n const handleNumberChange = (next: number) => {\n onValueChange(Number.isNaN(next) ? '' : String(next));\n };\n\n // NumberField represents an empty value as NaN\n if (type === 'number') {\n const numericValue = value !== '' && value != null ? Number(value) : NaN;\n\n return (\n <NumberField\n {...rootProps}\n formatOptions={{ useGrouping: false }}\n onChange={handleNumberChange}\n value={numericValue}\n >\n {children}\n </NumberField>\n );\n }\n\n return (\n <TextField\n {...rootProps}\n onChange={onValueChange}\n type={type ?? 'text'}\n value={String(value ?? '')}\n >\n {children}\n </TextField>\n );\n};\n\nexport default InputField;\n","import type { ReactNode } from 'react';\n\nimport { Button } from 'react-aria-components';\n\ninterface InputClearButtonProps {\n /** Replaces the default clear icon */\n children?: ReactNode;\n /** CSS class name */\n className: string;\n /** Disables the clear button when the input is disabled */\n disabled?: boolean;\n /** Callback when the clear button is activated */\n onClear: () => void;\n}\n\n/**\n * React Aria Button that invokes the supplied clear action without taking focus.\n *\n * Uses slot=null to opt out of NumberField's increment/decrement button context.\n * Renders custom end content when supplied, otherwise the default clear icon.\n *\n * @see https://react-aria.adobe.com/Button\n * @see https://react-aria.adobe.com/NumberField\n */\nconst InputClearButton = ({\n children = undefined,\n className,\n disabled = undefined,\n onClear,\n}: InputClearButtonProps) => {\n return (\n <Button\n aria-label=\"clear input\"\n className={className}\n data-slot=\"clear-button\"\n isDisabled={disabled}\n onPress={onClear}\n preventFocusOnPress\n slot={null}\n >\n {children ?? (\n <svg aria-hidden height=\"1em\" viewBox=\"0 0 24 24\" width=\"1em\">\n <path\n d=\"M12 2a10 10 0 1010 10A10.016 10.016 0 0012 2zm3.36 12.3a.754.754 0 010 1.06.748.748 0 01-1.06 0l-2.3-2.3-2.3 2.3a.748.748 0 01-1.06 0 .754.754 0 010-1.06l2.3-2.3-2.3-2.3A.75.75 0 019.7 8.64l2.3 2.3 2.3-2.3a.75.75 0 011.06 1.06l-2.3 2.3z\"\n fill=\"currentColor\"\n />\n </svg>\n )}\n </Button>\n );\n};\n\nexport default InputClearButton;\n","import { Button } from 'react-aria-components';\nimport { FaEye, FaEyeSlash } from 'react-icons/fa6';\n\ninterface InputPasswordToggleProps {\n /** CSS class name */\n className: string;\n /** Identifies the input controlled by the visibility action */\n controlId: string;\n /** Disables password visibility changes */\n disabled?: boolean;\n /** Callback invoked when visibility is toggled */\n onToggle: () => void;\n /** Identifies the toggle in tests */\n testId: string;\n /** Shows the password as plain text */\n visible: boolean;\n}\n\n/**\n * Password visibility action preserving input focus on pointer activation\n *\n * @see https://react-aria.adobe.com/Button\n */\nconst InputPasswordToggle = ({\n className,\n controlId,\n disabled = false,\n onToggle,\n testId,\n visible,\n}: InputPasswordToggleProps) => {\n return (\n <Button\n aria-controls={controlId}\n aria-label={visible ? 'Hide password' : 'Show password'}\n aria-pressed={visible}\n className={className}\n data-testid={`${testId}_password_toggle`}\n isDisabled={disabled}\n onPress={onToggle}\n preventFocusOnPress\n slot={null}\n type=\"button\"\n >\n {visible ? (\n <FaEyeSlash aria-hidden=\"true\" />\n ) : (\n <FaEye aria-hidden=\"true\" />\n )}\n </Button>\n );\n};\n\nexport default InputPasswordToggle;\n","import type { InputClassNames } from '../inputVariants';\n\nimport { Button } from 'react-aria-components';\n\ninterface ChevronProps {\n /** Points the chevron upward for the increment action */\n up?: boolean;\n}\n\n/** Decorative direction indicator for the number stepper buttons. */\nconst Chevron = ({ up = false }: ChevronProps) => {\n return (\n <svg\n aria-hidden\n fill=\"none\"\n height=\"1em\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.5\"\n viewBox=\"0 0 24 24\"\n width=\"1em\"\n >\n <path d={up ? 'm18 15-6-6-6 6' : 'm6 9 6 6 6-6'} />\n </svg>\n );\n};\n\ninterface InputStepperProps {\n /** CSS class name */\n className: InputClassNames;\n}\n\n/**\n * Increment and decrement React Aria Buttons for the surrounding NumberField.\n *\n * Named slots connect each button to NumberField's value and disabled state.\n * Keeps the controls outside the tab order so keyboard editing stays in the input.\n *\n * @see https://react-aria.adobe.com/NumberField\n * @see https://react-aria.adobe.com/Button\n */\nconst InputStepper = ({ className }: InputStepperProps) => {\n return (\n <div className={className.stepper} data-slot=\"stepper-wrapper\">\n <Button\n className={className.stepperButton}\n data-slot=\"increase-button\"\n slot=\"increment\"\n >\n <Chevron up />\n </Button>\n <Button\n className={className.stepperButton}\n data-slot=\"decrease-button\"\n slot=\"decrement\"\n >\n <Chevron />\n </Button>\n </div>\n );\n};\n\nexport default InputStepper;\n","import type { ChangeEvent, KeyboardEvent, MouseEvent, Ref } from 'react';\nimport type { FocusRingAria } from 'react-aria/useFocusRing';\nimport type { InputClassNames } from '../inputVariants';\nimport type { InputControlProps } from './InputControl';\n\nimport { Input as AriaInput, Group } from 'react-aria-components';\n\nimport { getFieldControlProps } from '../../helpers/fieldProps/fieldProps';\nimport InputClearButton from './InputClearButton';\nimport InputPasswordToggle from './InputPasswordToggle';\nimport InputStepper from './InputStepper';\n\ntype InputWrapperProps = Pick<\n InputControlProps,\n | 'field'\n | 'clearable'\n | 'endContent'\n | 'hidePasswordToggle'\n | 'placeholder'\n | 'startContent'\n | 'type'\n> & {\n /** Ref to the editable input */\n inputRef: Ref<HTMLInputElement>;\n /** CSS class name */\n className: InputClassNames;\n /** Shows focus styling while focus is within the control */\n focused: boolean;\n /** Connects the wrapper to the focus ring handlers */\n focusProps: Pick<FocusRingAria['focusProps'], 'onBlur' | 'onFocus'>;\n /** Marks the input as filled when the display value is nonempty */\n hasValue: boolean;\n /** Callback when the clear button or Escape key clears the input */\n onClear: () => void;\n /** Callback invoked to reveal or mask the password */\n onTogglePassword: () => void;\n /** Shows the password without changing the registered field type */\n passwordVisible: boolean;\n /** Callback invoked to focus the input after a wrapper click */\n onFocusControl: () => void;\n};\n\n/**\n * Bordered input surface built from React Aria Group and Input\n *\n * Arranges addons, clear actions and number steppers around the native input,\n * forwards its ref and accessibility attributes, and reports wrapper interactions.\n * The surrounding InputField supplies the TextField or NumberField context.\n *\n * @see https://react-aria.adobe.com/Group\n * @see https://react-aria.adobe.com/TextField (Input composition)\n * @see https://react-aria.adobe.com/NumberField (Input and stepper composition)\n */\nconst InputWrapper = ({\n field,\n clearable = false,\n endContent,\n hidePasswordToggle,\n inputRef,\n onClear,\n onFocusControl,\n onTogglePassword,\n passwordVisible,\n placeholder,\n startContent,\n type,\n className,\n focused,\n focusProps,\n hasValue,\n}: InputWrapperProps) => {\n const { disabled, onChange: onValueChange, testId } = field;\n\n // associate the editable control with its label and messages\n const controlProps = getFieldControlProps(field);\n\n // focus the input when its wrapper padding is clicked\n const handleWrapperClick = (event: MouseEvent<HTMLElement>) => {\n if (!disabled && event.currentTarget === event.target) {\n onFocusControl();\n }\n };\n\n // forward the raw number text to the value handler\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n onValueChange(event.target.value);\n };\n\n // clear a populated input when Escape is pressed\n const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Escape' && clearable && hasValue && !disabled) {\n event.preventDefault();\n onClear();\n }\n };\n\n return (\n <Group\n {...focusProps}\n className={className.inputWrapper}\n data-focus={focused || undefined}\n data-slot=\"input-wrapper\"\n isDisabled={disabled}\n onClick={handleWrapperClick}\n >\n <div className={className.innerWrapper} data-slot=\"inner-wrapper\">\n {startContent}\n <AriaInput\n {...controlProps}\n ref={inputRef}\n autoComplete=\"off\"\n className={className.input}\n data-filled={hasValue || undefined}\n data-has-end-content={\n !!endContent || (clearable && hasValue) || undefined\n }\n data-has-start-content={!!startContent || undefined}\n data-slot=\"input\"\n data-testid={testId}\n onChange={type === 'number' ? handleChange : undefined}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n />\n {type === 'password' ? endContent : null}\n {clearable && hasValue ? (\n <InputClearButton\n className={className.clearButton}\n disabled={disabled}\n onClear={onClear}\n >\n {type !== 'number' && type !== 'password' && endContent\n ? endContent\n : undefined}\n </InputClearButton>\n ) : null}\n {type !== 'password' && (!clearable || type === 'number')\n ? endContent\n : null}\n {type === 'password' && !hidePasswordToggle ? (\n <InputPasswordToggle\n className={className.passwordToggle}\n controlId={field.ids.control}\n disabled={disabled}\n onToggle={onTogglePassword}\n testId={testId}\n visible={passwordVisible}\n />\n ) : null}\n {type === 'number' ? <InputStepper className={className} /> : null}\n </div>\n </Group>\n );\n};\n\nexport default InputWrapper;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { InputProps } from '../Input';\n\nimport { useEffect, useState } from 'react';\nimport { useFocusRing } from 'react-aria/useFocusRing';\nimport { useObjectRef } from 'react-aria/useObjectRef';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldLayout from '../../partials/FieldLayout/FieldLayout';\nimport { inputVariants } from '../inputVariants';\nimport InputField from './InputField';\nimport InputWrapper from './InputWrapper';\n\n/** Presentation receives values and callbacks; it never registers a form field. */\nexport interface InputControlProps extends Pick<\n InputProps,\n | 'className'\n | 'clearable'\n | 'endContent'\n | 'hidePasswordToggle'\n | 'onClear'\n | 'placeholder'\n | 'size'\n | 'startContent'\n | 'type'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField<unknown, string>;\n /** Callback that clears pending edits and resets the bound value */\n onReset: () => void;\n /** Subscribes to reset notifications without accessing form context */\n subscribeReset?: (listener: () => void) => () => void;\n}\n\n/**\n * Composes the Input presentation without registering a form field.\n *\n * Owns the editable ref, focus restoration and interaction styling.\n * Connects InputField's Aria field root, FieldLayout and the editable content.\n * Values, validation state and callbacks are supplied by the Input binding.\n *\n * @see https://react-aria.adobe.com/useFocusRing\n * @see https://react-aria.adobe.com/TextField\n * @see https://react-aria.adobe.com/NumberField\n */\nconst InputControl = (props: InputControlProps) => {\n const { field, subscribeReset } = props;\n\n const styling = useStyling();\n const [passwordVisible, setPasswordVisible] = useState(false);\n\n // reset notifications keep presentation independent of form context\n useEffect(() => {\n const handleReset = () => {\n setPasswordVisible(false);\n };\n\n return subscribeReset?.(handleReset);\n }, [subscribeReset]);\n\n const controlRef = useObjectRef<HTMLInputElement>(field.ref);\n const {\n focusProps,\n isFocused: focused,\n isFocusVisible,\n } = useFocusRing({\n isTextInput: true,\n within: true,\n });\n\n const {\n size,\n type,\n clearable,\n className,\n hidePasswordToggle,\n onClear,\n onReset,\n } = props;\n\n const displayType =\n type === 'password' && !hidePasswordToggle && passwordVisible\n ? 'text'\n : type;\n\n const {\n value,\n disabled,\n invalid,\n label,\n required,\n ids,\n description,\n errorMessage,\n } = field;\n\n // treat empty and nullish values as cleared, preserve numeric zero\n const hasValue = value !== '' && value != null;\n\n // classNames from slots\n const variants = styling.resolve(inputVariants, {\n clearable,\n disabled,\n filled: hasValue,\n invalid,\n number: type === 'number',\n password: type === 'password',\n size,\n });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n // focus the editable input\n const handleFocus = () => {\n controlRef.current?.focus();\n };\n\n // change only the display, the binding keeps its declared password type\n const handleTogglePassword = () => {\n setPasswordVisible((visible) => {\n return !visible;\n });\n };\n\n // clear the value, notify the consumer and restore input focus\n const handleClear = () => {\n setPasswordVisible(false);\n onReset();\n onClear?.();\n handleFocus();\n };\n\n return (\n <FieldLayout\n // provide the text or number field engine\n baseAs={InputField}\n baseProps={{\n field,\n focused,\n hasValue,\n isFocusVisible,\n type: displayType,\n }}\n className={classNames}\n description={description}\n errorMessage={errorMessage}\n ids={ids}\n invalid={invalid}\n label={label}\n required={required}\n >\n <InputWrapper\n {...props}\n className={classNames}\n focusProps={focusProps}\n focused={focused}\n hasValue={hasValue}\n inputRef={controlRef}\n onClear={handleClear}\n onFocusControl={handleFocus}\n onTogglePassword={handleTogglePassword}\n passwordVisible={passwordVisible}\n />\n </FieldLayout>\n );\n};\n\nexport default InputControl;\n","import type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks/useInputValueTransform';\nimport type { ClassName } from './inputVariants';\n\nimport { useInputValueDebounce } from '../hooks/useInputValueDebounce';\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport InputControl from './subcomponents/InputControl';\n\nexport { default as inputVariants } from './inputVariants';\n\nexport interface InputProps {\n /** Custom accessible name */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** Shows a clear button when the input has a value */\n clearable?: boolean;\n /** Delay in milliseconds before updating form state (default: 300) */\n debounceDelay?: number;\n /** Help text associated with the input */\n description?: ReactNode;\n /** Disables the input */\n disabled?: boolean;\n /** Content at the end of the input */\n endContent?: ReactNode;\n /** Hides the password visibility toggle (default: false) */\n hidePasswordToggle?: boolean;\n /** Field label */\n label?: ReactNode;\n /** Field name */\n name: string;\n /** Callback when the input value is cleared */\n onClear?: () => void;\n /** Placeholder text */\n placeholder?: string;\n /** Redacts diagnostic values, password fields are always redacted */\n sensitive?: boolean;\n /** Input size */\n size?: 'sm' | 'md' | 'lg';\n /** Content at the start of the input */\n startContent?: ReactNode;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n /** Conversion between display and form values */\n transform?: InputValueTransform<string>;\n /** Input type */\n type?: 'number' | 'password';\n}\n\n/** Form input field for text, passwords or numbers */\nconst Input = ({\n className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n startContent = undefined,\n size = 'md',\n type = undefined,\n hidePasswordToggle = false,\n name,\n onClear = undefined,\n placeholder = ' ',\n ...uniformProps\n}: InputProps) => {\n const { field, formReset } = useUniformField({\n ...uniformProps,\n name,\n placeholder,\n type,\n });\n\n // debounce form updates, flush pending edits on blur\n const { value, onChange, onBlur, clear } = useInputValueDebounce({\n debounceDelay,\n emptyValue: '',\n name,\n onBlur: field.onBlur,\n onChange: field.onChange,\n value: field.value,\n });\n\n return (\n <InputControl\n key={`${name}-${type}-${hidePasswordToggle}`}\n hidePasswordToggle={hidePasswordToggle}\n className={className}\n clearable={clearable}\n endContent={endContent}\n field={{ ...field, onBlur, onChange, value }}\n onClear={onClear}\n onReset={clear}\n placeholder={placeholder}\n size={size}\n startContent={startContent}\n subscribeReset={formReset.subscribe}\n type={type}\n />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { inputVariants } from './inputVariants';\n\nexport default Input;\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAa,gBAAgB,GAAG;CAC9B,OAAO;;EAEL,MAAM;;EAEN,aA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