@fuf-stack/uniform 1.30.0 → 2.0.0-next.3
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 +0 -6
- package/dist/Checkboxes/index.d.mts +178 -274
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +294 -94
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +1963 -148
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +401 -82
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.d.mts +102 -97
- package/dist/FieldArray/index.d.mts.map +1 -1
- package/dist/FieldArray/index.mjs +340 -195
- package/dist/FieldArray/index.mjs.map +1 -1
- package/dist/FieldCard/index.d.mts +34 -34
- package/dist/FieldCard/index.d.mts.map +1 -1
- package/dist/FieldCard/index.mjs +181 -127
- package/dist/FieldCard/index.mjs.map +1 -1
- package/dist/{FieldCopyTestIdButton-Y9SfvaM9.mjs → FieldCopyTestIdButton-D3_jZYJ1.mjs} +4 -2
- package/dist/FieldCopyTestIdButton-D3_jZYJ1.mjs.map +1 -0
- package/dist/FieldDescription-X_0s1Lhu.mjs +35 -0
- package/dist/FieldDescription-X_0s1Lhu.mjs.map +1 -0
- package/dist/FieldLabel-DrNWJIVh.mjs +128 -0
- package/dist/FieldLabel-DrNWJIVh.mjs.map +1 -0
- package/dist/FieldLayout-DcvQU0zN.mjs +45 -0
- package/dist/FieldLayout-DcvQU0zN.mjs.map +1 -0
- package/dist/FieldReset/index.d.mts +17 -12
- package/dist/FieldReset/index.d.mts.map +1 -1
- package/dist/FieldReset/index.mjs +50 -33
- package/dist/FieldReset/index.mjs.map +1 -1
- package/dist/FieldValidationError-iAayfTEw.mjs +75 -0
- package/dist/FieldValidationError-iAayfTEw.mjs.map +1 -0
- package/dist/Form/index.d.mts +2 -2
- package/dist/Form/index.d.mts.map +1 -1
- package/dist/Form/index.mjs +9 -7
- package/dist/Form/index.mjs.map +1 -1
- package/dist/{FormContext-Dvt3MiKq.d.mts → FormContext-BnNJYZOo.d.mts} +3 -3
- package/dist/{FormContext-Dvt3MiKq.d.mts.map → FormContext-BnNJYZOo.d.mts.map} +1 -1
- package/dist/{FormContext-B8G_Xxd6.mjs → FormContext-PXkVlBdU.mjs} +6 -2
- package/dist/FormContext-PXkVlBdU.mjs.map +1 -0
- package/dist/Grid/index.mjs +1 -1
- package/dist/{Grid-Us2JFczS.mjs → Grid-DBL29Kwb.mjs} +4 -2
- package/dist/Grid-DBL29Kwb.mjs.map +1 -0
- package/dist/Input/index.d.mts +734 -47
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +411 -168
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +300 -98
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +156 -119
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +302 -76
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +274 -87
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +314 -78
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +90 -44
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +410 -142
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +284 -157
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +382 -63
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +269 -90
- 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 -427
- package/dist/Switch/index.mjs +167 -72
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/Switch-Db2dpGz7.d.mts +648 -0
- package/dist/Switch-Db2dpGz7.d.mts.map +1 -0
- package/dist/SwitchBox/index.d.mts +191 -91
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +142 -88
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +347 -29
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +195 -47
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +1373 -139
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +160 -77
- 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 +29 -2
- package/dist/hooks/useController/index.d.mts.map +1 -0
- package/dist/hooks/useController/index.mjs +1 -1
- package/dist/hooks/useFormContext/index.d.mts +44 -2
- package/dist/hooks/useFormContext/index.d.mts.map +1 -0
- package/dist/hooks/useFormContext/index.mjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.mts +9 -3
- 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 -1
- package/dist/hooks/useWatchFormReset/index.mjs +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs +1 -1
- package/dist/{useInputValueTransform-cevZBrIN.d.mts → index-cevZBrIN.d.mts} +1 -1
- package/dist/index-cevZBrIN.d.mts.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -1
- 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 -1
- package/dist/radioControlVariants-BYRfaD6y.mjs +187 -0
- package/dist/radioControlVariants-BYRfaD6y.mjs.map +1 -0
- package/dist/switchVariants-D16b2VaT.mjs +67 -0
- package/dist/switchVariants-D16b2VaT.mjs.map +1 -0
- package/dist/timeVariants-CtXyNKmW.mjs +58 -0
- package/dist/timeVariants-CtXyNKmW.mjs.map +1 -0
- package/dist/{useController-CJjMqXU5.mjs → useController-JtIeurpw.mjs} +2 -2
- package/dist/{useController-CJjMqXU5.mjs.map → useController-JtIeurpw.mjs.map} +1 -1
- package/dist/{useFormContext-BEjPBdzb.mjs → useFormContext-piqnN2L-.mjs} +2 -2
- package/dist/{useFormContext-BEjPBdzb.mjs.map → useFormContext-piqnN2L-.mjs.map} +1 -1
- package/dist/{useInputValueTransform-D44BLp1Z.mjs → useInputValueTransform-CXWWFhy_.mjs} +2 -2
- package/dist/{useInputValueTransform-D44BLp1Z.mjs.map → useInputValueTransform-CXWWFhy_.mjs.map} +1 -1
- package/package.json +13 -25
- package/dist/FieldCopyTestIdButton-Y9SfvaM9.mjs.map +0 -1
- package/dist/FieldValidationError-BcUV0r1I.mjs +0 -48
- package/dist/FieldValidationError-BcUV0r1I.mjs.map +0 -1
- package/dist/FormContext-B8G_Xxd6.mjs.map +0 -1
- package/dist/Grid-Us2JFczS.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 -5
- package/dist/hooks/useInput/index.mjs.map +0 -1
- package/dist/hooks/useUniformField/index.d.mts +0 -2
- package/dist/hooks/useUniformField/index.mjs +0 -141
- package/dist/hooks/useUniformField/index.mjs.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.d.mts +0 -47
- package/dist/hooks/useUniformFieldArray/index.d.mts.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.mjs +0 -99
- package/dist/hooks/useUniformFieldArray/index.mjs.map +0 -1
- package/dist/index-CaxrMD1A.d.mts +0 -1
- package/dist/index-DsB0_365.d.mts +0 -106
- package/dist/index-DsB0_365.d.mts.map +0 -1
- package/dist/useController-CdFEp-Wa.d.mts +0 -30
- package/dist/useController-CdFEp-Wa.d.mts.map +0 -1
- package/dist/useFormContext-BSSUZ0Md.d.mts +0 -45
- package/dist/useFormContext-BSSUZ0Md.d.mts.map +0 -1
- package/dist/useInput-ClpHDPdr.d.mts +0 -2
- package/dist/useInput-NPbS4w_n.mjs +0 -1
- package/dist/useInputValueTransform-cevZBrIN.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4Gd,YAAY,mBAAmB;UCvG1B;;EAEf;;EAEA,YAAY;;EAEZ;;EAEA;;EAEA,cAAc;;EAEd;;EAEA,aAAa;;EAEb;;EAEA,QAAQ;;EAER;;EAEA;;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,195 +1,438 @@
|
|
|
1
1
|
import { useInputValueDebounce } from "../hooks/useInputValueDebounce/index.mjs";
|
|
2
|
-
import { useUniformField } from "../
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { n as useUniformField } from "../FieldLabel-DrNWJIVh.mjs";
|
|
3
|
+
import { t as FieldLayout } from "../FieldLayout-DcvQU0zN.mjs";
|
|
4
|
+
import { n as getFieldControlProps, r as getFieldDataAttributes } from "../FieldDescription-X_0s1Lhu.mjs";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
name,
|
|
16
|
-
hidePasswordToggle
|
|
17
|
-
});
|
|
18
|
-
if (previousPasswordField.name !== name || previousPasswordField.hidePasswordToggle !== hidePasswordToggle) {
|
|
19
|
-
setPreviousPasswordField({
|
|
20
|
-
name,
|
|
21
|
-
hidePasswordToggle
|
|
22
|
-
});
|
|
23
|
-
setIsPasswordVisible(false);
|
|
24
|
-
}
|
|
25
|
-
useWatchFormReset({ onReset: () => {
|
|
26
|
-
setIsPasswordVisible(false);
|
|
27
|
-
} });
|
|
28
|
-
const clearValue = () => {
|
|
29
|
-
onClear();
|
|
30
|
-
setIsPasswordVisible(false);
|
|
31
|
-
};
|
|
32
|
-
const passwordEndContent = !hidePasswordToggle ? /* @__PURE__ */ jsxs("span", {
|
|
33
|
-
className: "inline-flex shrink-0 items-center gap-2",
|
|
34
|
-
children: [
|
|
35
|
-
endContent,
|
|
36
|
-
clearable && !!value ? /* @__PURE__ */ jsx("button", {
|
|
37
|
-
"aria-label": "clear input",
|
|
38
|
-
className: cn("rounded-sm p-1 text-default-400 outline-none focus-visible:ring-2 focus-visible:ring-focus", classNames?.clearButton),
|
|
39
|
-
disabled: isDisabled,
|
|
40
|
-
onClick: clearValue,
|
|
41
|
-
onMouseDown: (event) => {
|
|
42
|
-
event.preventDefault();
|
|
43
|
-
},
|
|
44
|
-
type: "button",
|
|
45
|
-
children: /* @__PURE__ */ jsx(FaXmark, { "aria-hidden": "true" })
|
|
46
|
-
}) : null,
|
|
47
|
-
/* @__PURE__ */ jsx("button", {
|
|
48
|
-
"aria-controls": testId,
|
|
49
|
-
"aria-label": isPasswordVisible ? "Hide password" : "Show password",
|
|
50
|
-
"aria-pressed": isPasswordVisible,
|
|
51
|
-
className: "rounded-sm p-1 text-default-400 outline-none focus-visible:ring-2 focus-visible:ring-focus",
|
|
52
|
-
"data-testid": `${testId}_password_toggle`,
|
|
53
|
-
disabled: isDisabled,
|
|
54
|
-
onClick: () => {
|
|
55
|
-
setIsPasswordVisible((visible) => {
|
|
56
|
-
return !visible;
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
onMouseDown: (event) => {
|
|
60
|
-
event.preventDefault();
|
|
61
|
-
},
|
|
62
|
-
type: "button",
|
|
63
|
-
children: isPasswordVisible ? /* @__PURE__ */ jsx(FaEyeSlash, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(FaEye, { "aria-hidden": "true" })
|
|
64
|
-
})
|
|
65
|
-
]
|
|
66
|
-
}) : endContent;
|
|
67
|
-
const clearableProps = clearable && hidePasswordToggle ? {
|
|
68
|
-
isClearable: true,
|
|
69
|
-
onClear: clearValue
|
|
70
|
-
} : {};
|
|
71
|
-
return /* @__PURE__ */ jsx(Input, {
|
|
72
|
-
...inputProps,
|
|
73
|
-
...clearableProps,
|
|
74
|
-
ref,
|
|
75
|
-
classNames,
|
|
76
|
-
endContent: passwordEndContent,
|
|
77
|
-
isDisabled,
|
|
78
|
-
name,
|
|
79
|
-
onKeyDown: !hidePasswordToggle && clearable ? (event) => {
|
|
80
|
-
onKeyDown?.(event);
|
|
81
|
-
if (!event.defaultPrevented && event.key === "Escape" && value && !isDisabled) {
|
|
82
|
-
event.preventDefault();
|
|
83
|
-
clearValue();
|
|
84
|
-
}
|
|
85
|
-
} : onKeyDown,
|
|
86
|
-
type: !hidePasswordToggle && isPasswordVisible ? "text" : "password",
|
|
87
|
-
value
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
InputPassword.displayName = "InputPassword";
|
|
91
|
-
// src/Input/Input.tsx
|
|
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
|
+
// src/Input/inputVariants.ts
|
|
14
|
+
/** Default styles for all public Input slots */
|
|
92
15
|
const inputVariants = tv({
|
|
93
16
|
slots: {
|
|
94
|
-
/**
|
|
95
|
-
base: "",
|
|
96
|
-
/**
|
|
97
|
-
clearButton: "",
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
|
|
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"]
|
|
102
52
|
},
|
|
103
|
-
variants: {
|
|
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
|
+
readOnly: { true: { base: "cursor-not-allowed opacity-disabled **:cursor-not-allowed" } },
|
|
81
|
+
invalid: { true: {
|
|
82
|
+
input: "text-danger",
|
|
83
|
+
inputWrapper: "border-danger group-data-[focus=true]:border-danger data-[hovered=true]:border-danger group-data-[focus=true]:data-[hovered=true]:border-danger",
|
|
84
|
+
label: "text-danger"
|
|
85
|
+
} }
|
|
86
|
+
}
|
|
104
87
|
});
|
|
88
|
+
// src/Input/subcomponents/InputField.tsx
|
|
105
89
|
/**
|
|
106
|
-
*
|
|
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
|
|
107
98
|
*/
|
|
108
|
-
const
|
|
109
|
-
const {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const clearValue = () => {
|
|
122
|
-
resetField(name, { defaultValue: null });
|
|
123
|
-
onClear?.();
|
|
124
|
-
};
|
|
125
|
-
const isClearable = clearable && !readOnly;
|
|
126
|
-
const clearableProps = isClearable ? {
|
|
127
|
-
isClearable: true,
|
|
128
|
-
onClear: clearValue
|
|
129
|
-
} : {};
|
|
130
|
-
const variants = inputVariants({ readOnly });
|
|
131
|
-
const classNames = variantsToClassNames(variants, _className, "base");
|
|
132
|
-
const commonProps = {
|
|
133
|
-
ref,
|
|
134
|
-
"aria-label": !placeholder || placeholder.trim() === "" ? ariaLabel : void 0,
|
|
135
|
-
autoComplete: "off",
|
|
136
|
-
classNames: {
|
|
137
|
-
base: classNames.base,
|
|
138
|
-
clearButton: classNames.clearButton,
|
|
139
|
-
helperWrapper: "p-0",
|
|
140
|
-
input: classNames.input,
|
|
141
|
-
inputWrapper: classNames.inputWrapper
|
|
142
|
-
},
|
|
143
|
-
"data-testid": testId,
|
|
144
|
-
endContent,
|
|
145
|
-
errorMessage,
|
|
146
|
-
id: testId,
|
|
99
|
+
const InputField = ({ field, type, children, className = void 0, focused, hasValue, isFocusVisible }) => {
|
|
100
|
+
const { disabled, invalid, name, onBlur, onChange: onValueChange, readOnly, 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",
|
|
147
112
|
isDisabled: disabled,
|
|
148
113
|
isInvalid: invalid,
|
|
149
114
|
isReadOnly: readOnly,
|
|
150
115
|
isRequired: required,
|
|
151
|
-
label,
|
|
152
|
-
labelPlacement: "outside",
|
|
153
116
|
name,
|
|
154
117
|
onBlur,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
variant: "bordered"
|
|
118
|
+
validationBehavior: "aria"
|
|
119
|
+
};
|
|
120
|
+
const handleNumberChange = (next) => {
|
|
121
|
+
onValueChange(Number.isNaN(next) ? "" : String(next));
|
|
160
122
|
};
|
|
161
123
|
if (type === "number") {
|
|
162
|
-
const
|
|
163
|
-
return /* @__PURE__ */ jsx(
|
|
164
|
-
...
|
|
165
|
-
...clearableProps,
|
|
124
|
+
const numericValue = value !== "" && value != null ? Number(value) : NaN;
|
|
125
|
+
return /* @__PURE__ */ jsx(NumberField, {
|
|
126
|
+
...rootProps,
|
|
166
127
|
formatOptions: { useGrouping: false },
|
|
167
|
-
onChange:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
},
|
|
171
|
-
value: numberValue
|
|
128
|
+
onChange: handleNumberChange,
|
|
129
|
+
value: numericValue,
|
|
130
|
+
children
|
|
172
131
|
});
|
|
173
132
|
}
|
|
174
|
-
|
|
175
|
-
...
|
|
133
|
+
return /* @__PURE__ */ jsx(TextField, {
|
|
134
|
+
...rootProps,
|
|
135
|
+
onChange: onValueChange,
|
|
136
|
+
type: type ?? "text",
|
|
137
|
+
value: String(value ?? ""),
|
|
138
|
+
children
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
// 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
|
+
// src/Input/subcomponents/InputPasswordToggle.tsx
|
|
173
|
+
/**
|
|
174
|
+
* Password visibility action preserving input focus on pointer activation
|
|
175
|
+
*
|
|
176
|
+
* @see https://react-aria.adobe.com/Button
|
|
177
|
+
*/
|
|
178
|
+
const InputPasswordToggle = ({ className, controlId, disabled = false, onToggle, testId, visible }) => {
|
|
179
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
180
|
+
"aria-controls": controlId,
|
|
181
|
+
"aria-label": visible ? "Hide password" : "Show password",
|
|
182
|
+
"aria-pressed": visible,
|
|
183
|
+
className,
|
|
184
|
+
"data-testid": `${testId}_password_toggle`,
|
|
185
|
+
isDisabled: disabled,
|
|
186
|
+
onPress: onToggle,
|
|
187
|
+
preventFocusOnPress: true,
|
|
188
|
+
slot: null,
|
|
189
|
+
type: "button",
|
|
190
|
+
children: visible ? /* @__PURE__ */ jsx(FaEyeSlash, { "aria-hidden": "true" }) : /* @__PURE__ */ jsx(FaEye, { "aria-hidden": "true" })
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
// src/Input/subcomponents/InputStepper.tsx
|
|
194
|
+
/** Decorative direction indicator for the number stepper buttons. */
|
|
195
|
+
const Chevron = ({ up = false }) => {
|
|
196
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
197
|
+
"aria-hidden": true,
|
|
198
|
+
fill: "none",
|
|
199
|
+
height: "1em",
|
|
200
|
+
stroke: "currentColor",
|
|
201
|
+
strokeLinecap: "round",
|
|
202
|
+
strokeLinejoin: "round",
|
|
203
|
+
strokeWidth: "1.5",
|
|
204
|
+
viewBox: "0 0 24 24",
|
|
205
|
+
width: "1em",
|
|
206
|
+
children: /* @__PURE__ */ jsx("path", { d: up ? "m18 15-6-6-6 6" : "m6 9 6 6 6-6" })
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Increment and decrement React Aria Buttons for the surrounding NumberField.
|
|
211
|
+
*
|
|
212
|
+
* Named slots connect each button to NumberField's value and disabled state.
|
|
213
|
+
* Keeps the controls outside the tab order so keyboard editing stays in the input.
|
|
214
|
+
*
|
|
215
|
+
* @see https://react-aria.adobe.com/NumberField
|
|
216
|
+
* @see https://react-aria.adobe.com/Button
|
|
217
|
+
*/
|
|
218
|
+
const InputStepper = ({ className }) => {
|
|
219
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
220
|
+
className: className.stepper,
|
|
221
|
+
"data-slot": "stepper-wrapper",
|
|
222
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
223
|
+
className: className.stepperButton,
|
|
224
|
+
"data-slot": "increase-button",
|
|
225
|
+
slot: "increment",
|
|
226
|
+
children: /* @__PURE__ */ jsx(Chevron, { up: true })
|
|
227
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
228
|
+
className: className.stepperButton,
|
|
229
|
+
"data-slot": "decrease-button",
|
|
230
|
+
slot: "decrement",
|
|
231
|
+
children: /* @__PURE__ */ jsx(Chevron, {})
|
|
232
|
+
})]
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
// src/Input/subcomponents/InputWrapper.tsx
|
|
236
|
+
/**
|
|
237
|
+
* Bordered input surface built from React Aria Group and Input
|
|
238
|
+
*
|
|
239
|
+
* Arranges addons, clear actions and number steppers around the native input,
|
|
240
|
+
* forwards its ref and accessibility attributes, and reports wrapper interactions.
|
|
241
|
+
* The surrounding InputField supplies the TextField or NumberField context.
|
|
242
|
+
*
|
|
243
|
+
* @see https://react-aria.adobe.com/Group
|
|
244
|
+
* @see https://react-aria.adobe.com/TextField (Input composition)
|
|
245
|
+
* @see https://react-aria.adobe.com/NumberField (Input and stepper composition)
|
|
246
|
+
*/
|
|
247
|
+
const InputWrapper = ({ field, clearable = false, endContent, hidePasswordToggle, inputRef, onClear, onFocusControl, onTogglePassword, passwordVisible, placeholder, startContent, type, className, focused, focusProps, hasValue }) => {
|
|
248
|
+
const { disabled, onChange: onValueChange, testId } = field;
|
|
249
|
+
const controlProps = getFieldControlProps(field);
|
|
250
|
+
const handleWrapperClick = (event) => {
|
|
251
|
+
if (!disabled && event.currentTarget === event.target) onFocusControl();
|
|
252
|
+
};
|
|
253
|
+
const handleChange = (event) => {
|
|
254
|
+
onValueChange(event.target.value);
|
|
255
|
+
};
|
|
256
|
+
const handleKeyDown = (event) => {
|
|
257
|
+
if (event.key === "Escape" && clearable && hasValue && !disabled) {
|
|
258
|
+
event.preventDefault();
|
|
259
|
+
onClear();
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
return /* @__PURE__ */ jsx(Group, {
|
|
263
|
+
...focusProps,
|
|
264
|
+
className: className.inputWrapper,
|
|
265
|
+
"data-focus": focused || void 0,
|
|
266
|
+
"data-slot": "input-wrapper",
|
|
267
|
+
isDisabled: disabled,
|
|
268
|
+
onClick: handleWrapperClick,
|
|
269
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
270
|
+
className: className.innerWrapper,
|
|
271
|
+
"data-slot": "inner-wrapper",
|
|
272
|
+
children: [
|
|
273
|
+
startContent,
|
|
274
|
+
/* @__PURE__ */ jsx(Input, {
|
|
275
|
+
...controlProps,
|
|
276
|
+
ref: inputRef,
|
|
277
|
+
autoComplete: "off",
|
|
278
|
+
className: className.input,
|
|
279
|
+
"data-filled": hasValue || void 0,
|
|
280
|
+
"data-has-end-content": !!endContent || clearable && hasValue || void 0,
|
|
281
|
+
"data-has-start-content": !!startContent || void 0,
|
|
282
|
+
"data-slot": "input",
|
|
283
|
+
"data-testid": testId,
|
|
284
|
+
onChange: type === "number" ? handleChange : void 0,
|
|
285
|
+
onKeyDown: handleKeyDown,
|
|
286
|
+
placeholder
|
|
287
|
+
}),
|
|
288
|
+
type === "password" ? endContent : null,
|
|
289
|
+
clearable && hasValue ? /* @__PURE__ */ jsx(InputClearButton, {
|
|
290
|
+
className: className.clearButton,
|
|
291
|
+
disabled,
|
|
292
|
+
onClear,
|
|
293
|
+
children: type !== "number" && type !== "password" && endContent ? endContent : void 0
|
|
294
|
+
}) : null,
|
|
295
|
+
type !== "password" && (!clearable || type === "number") ? endContent : null,
|
|
296
|
+
type === "password" && !hidePasswordToggle ? /* @__PURE__ */ jsx(InputPasswordToggle, {
|
|
297
|
+
className: className.passwordToggle,
|
|
298
|
+
controlId: field.ids.control,
|
|
299
|
+
disabled,
|
|
300
|
+
onToggle: onTogglePassword,
|
|
301
|
+
testId,
|
|
302
|
+
visible: passwordVisible
|
|
303
|
+
}) : null,
|
|
304
|
+
type === "number" ? /* @__PURE__ */ jsx(InputStepper, { className }) : null
|
|
305
|
+
]
|
|
306
|
+
})
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
// src/Input/subcomponents/InputControl.tsx
|
|
310
|
+
/**
|
|
311
|
+
* Composes the Input presentation without registering a form field.
|
|
312
|
+
*
|
|
313
|
+
* Owns the editable ref, focus restoration and interaction styling.
|
|
314
|
+
* Connects InputField's Aria field root, FieldLayout and the editable content.
|
|
315
|
+
* Values, validation state and callbacks are supplied by the Input binding.
|
|
316
|
+
*
|
|
317
|
+
* @see https://react-aria.adobe.com/useFocusRing
|
|
318
|
+
* @see https://react-aria.adobe.com/TextField
|
|
319
|
+
* @see https://react-aria.adobe.com/NumberField
|
|
320
|
+
*/
|
|
321
|
+
const InputControl = (props) => {
|
|
322
|
+
const { field, subscribeReset } = props;
|
|
323
|
+
const styling = useStyling();
|
|
324
|
+
const [passwordVisible, setPasswordVisible] = useState(false);
|
|
325
|
+
useEffect(() => {
|
|
326
|
+
const handleReset = () => {
|
|
327
|
+
setPasswordVisible(false);
|
|
328
|
+
};
|
|
329
|
+
return subscribeReset?.(handleReset);
|
|
330
|
+
}, [subscribeReset]);
|
|
331
|
+
const controlRef = useObjectRef(field.ref);
|
|
332
|
+
const { focusProps, isFocused: focused, isFocusVisible } = useFocusRing({
|
|
333
|
+
isTextInput: true,
|
|
334
|
+
within: true
|
|
335
|
+
});
|
|
336
|
+
const { size, type, clearable, className, hidePasswordToggle, onClear, onReset } = props;
|
|
337
|
+
const displayType = type === "password" && !hidePasswordToggle && passwordVisible ? "text" : type;
|
|
338
|
+
const { value, disabled, invalid, label, readOnly, required, ids, description, errorMessage } = field;
|
|
339
|
+
const hasValue = value !== "" && value != null;
|
|
340
|
+
const isClearable = clearable && !readOnly;
|
|
341
|
+
const variants = styling.resolve(inputVariants, {
|
|
176
342
|
clearable: isClearable,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
343
|
+
disabled,
|
|
344
|
+
filled: hasValue,
|
|
345
|
+
invalid,
|
|
346
|
+
number: type === "number",
|
|
347
|
+
password: type === "password",
|
|
348
|
+
readOnly,
|
|
349
|
+
size
|
|
182
350
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
351
|
+
const classNames = styling.variantsToClassNames(variants, className, "base");
|
|
352
|
+
const handleFocus = () => {
|
|
353
|
+
controlRef.current?.focus();
|
|
354
|
+
};
|
|
355
|
+
const handleTogglePassword = () => {
|
|
356
|
+
setPasswordVisible((visible) => {
|
|
357
|
+
return !visible;
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
const handleClear = () => {
|
|
361
|
+
setPasswordVisible(false);
|
|
362
|
+
onReset();
|
|
363
|
+
onClear?.();
|
|
364
|
+
handleFocus();
|
|
365
|
+
};
|
|
366
|
+
return /* @__PURE__ */ jsx(FieldLayout, {
|
|
367
|
+
baseAs: InputField,
|
|
368
|
+
baseProps: {
|
|
369
|
+
field,
|
|
370
|
+
focused,
|
|
371
|
+
hasValue,
|
|
372
|
+
isFocusVisible,
|
|
373
|
+
type: displayType
|
|
374
|
+
},
|
|
375
|
+
className: classNames,
|
|
376
|
+
description,
|
|
377
|
+
errorMessage,
|
|
378
|
+
ids,
|
|
379
|
+
invalid,
|
|
380
|
+
label,
|
|
381
|
+
required,
|
|
382
|
+
children: /* @__PURE__ */ jsx(InputWrapper, {
|
|
383
|
+
...props,
|
|
384
|
+
className: classNames,
|
|
385
|
+
clearable: isClearable,
|
|
386
|
+
focusProps,
|
|
387
|
+
focused,
|
|
388
|
+
hasValue,
|
|
389
|
+
inputRef: controlRef,
|
|
390
|
+
onClear: handleClear,
|
|
391
|
+
onFocusControl: handleFocus,
|
|
392
|
+
onTogglePassword: handleTogglePassword,
|
|
393
|
+
passwordVisible
|
|
394
|
+
})
|
|
189
395
|
});
|
|
190
396
|
};
|
|
397
|
+
// src/Input/Input.tsx
|
|
398
|
+
/** Form input field for text, passwords or numbers */
|
|
399
|
+
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 }) => {
|
|
400
|
+
const { field, formReset } = useUniformField({
|
|
401
|
+
...uniformProps,
|
|
402
|
+
name,
|
|
403
|
+
placeholder,
|
|
404
|
+
type
|
|
405
|
+
});
|
|
406
|
+
const { value, onChange, onBlur, clear } = useInputValueDebounce({
|
|
407
|
+
debounceDelay,
|
|
408
|
+
emptyValue: "",
|
|
409
|
+
name,
|
|
410
|
+
onBlur: field.onBlur,
|
|
411
|
+
onChange: field.onChange,
|
|
412
|
+
value: field.value
|
|
413
|
+
});
|
|
414
|
+
return /* @__PURE__ */ jsx(InputControl, {
|
|
415
|
+
hidePasswordToggle,
|
|
416
|
+
className,
|
|
417
|
+
clearable,
|
|
418
|
+
endContent,
|
|
419
|
+
field: {
|
|
420
|
+
...field,
|
|
421
|
+
onBlur,
|
|
422
|
+
onChange,
|
|
423
|
+
value
|
|
424
|
+
},
|
|
425
|
+
onClear,
|
|
426
|
+
onReset: clear,
|
|
427
|
+
placeholder,
|
|
428
|
+
size,
|
|
429
|
+
startContent,
|
|
430
|
+
subscribeReset: formReset.subscribe,
|
|
431
|
+
type
|
|
432
|
+
}, `${name}-${type}-${hidePasswordToggle}`);
|
|
433
|
+
};
|
|
191
434
|
// src/Input/index.ts
|
|
192
435
|
var Input_default = Input$1;
|
|
193
|
-
export { Input_default as default };
|
|
436
|
+
export { Input_default as default, inputVariants };
|
|
194
437
|
|
|
195
438
|
//# sourceMappingURL=index.mjs.map
|