@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/Select/Select.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/Select/selectVariants.ts","../../src/Select/Select.tsx"],"mappings":";;;;qBAIa,kBAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmGf,YAAY,mBAAmB;UC5F1B;;EAEf;;;;;EAKA;;EAEA,QAAQ;;EAER;;UAGe;;EAEf;;EAEA,YAAY;;EAEZ;;EAEA;;EAGA,cAAc;;EAEd;;EAEA,6BACgB,SAAS,cAAc;;EAEvC;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;EAEA,gBAAgB;;EAEhB,SAAS;;EAET;;EAEA;;EAEA,qBAAqB;;EAErB,gCAAgC;;;;;;;;EAQhC,yBAAyB,eAAe;;EAExC;;EAEA,YAAY;;;cAIR,WAAU,WAAA,WAAA,eAAA,cAAA,YAAA,SAAA,aAAA,MAAA,eAAA,SAAA,aAAA,oBAAA,mBAAA,2BAAA,qBAgBb,gCAAW,IAAA"}
|
package/dist/Select/index.mjs
CHANGED
|
@@ -1,49 +1,14 @@
|
|
|
1
|
+
import { n as useFormContext } from "../useFormContext-piqnN2L-.mjs";
|
|
2
|
+
import { n as useUniformField } from "../FieldLabel-DrNWJIVh.mjs";
|
|
3
|
+
import { n as getFieldControlProps, r as getFieldDataAttributes } from "../FieldDescription-X_0s1Lhu.mjs";
|
|
4
|
+
import { t as FieldLayout } from "../FieldLayout-DcvQU0zN.mjs";
|
|
1
5
|
import { createOptionValueConverter, isValueEmpty } from "../helpers/index.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { createContext, useContext, useMemo, useState } from "react";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
import { slugify, tv } from "@fuf-stack/pixel-utils";
|
|
9
|
+
import { useStyling } from "@fuf-stack/pixels/StylingProvider";
|
|
7
10
|
import ReactSelect, { components } from "react-select";
|
|
8
|
-
|
|
9
|
-
// src/Select/SelectComponents.tsx
|
|
10
|
-
/** Mirrors the select test id and read-only state onto the underlying react-select input element. */
|
|
11
|
-
const InputComponent = (props) => {
|
|
12
|
-
const testId = `${props.selectProps["data-testid"]}`;
|
|
13
|
-
const ariaReadOnly = props.selectProps["aria-readonly"];
|
|
14
|
-
return /* @__PURE__ */ jsx(components.Input, {
|
|
15
|
-
"aria-readonly": ariaReadOnly,
|
|
16
|
-
"data-testid": testId,
|
|
17
|
-
...props
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
/** Wraps the control root to expose a stable `*_select` test id hook. */
|
|
21
|
-
const ControlComponent = (props) => {
|
|
22
|
-
const testId = `${props.selectProps["data-testid"]}_select`;
|
|
23
|
-
return /* @__PURE__ */ jsx("div", {
|
|
24
|
-
"data-testid": testId,
|
|
25
|
-
children: /* @__PURE__ */ jsx(components.Control, { ...props })
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
/** Adds deterministic option test ids and forwards disabled state semantics. */
|
|
29
|
-
const OptionComponent = (props) => {
|
|
30
|
-
const { isDisabled } = props;
|
|
31
|
-
const testId = `${props.selectProps["data-testid"]}_select_option_${slugify(String(props?.data?.testId ?? props?.data?.value), { replaceDots: true })}`;
|
|
32
|
-
return /* @__PURE__ */ jsx("div", {
|
|
33
|
-
"aria-disabled": isDisabled ? true : void 0,
|
|
34
|
-
"data-testid": testId,
|
|
35
|
-
children: /* @__PURE__ */ jsx(components.Option, { ...props })
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
/** Wraps the dropdown indicator with a predictable test id for automation. */
|
|
39
|
-
const DropdownIndicatorComponent = (props) => {
|
|
40
|
-
const testId = props?.selectProps["data-testid"];
|
|
41
|
-
return /* @__PURE__ */ jsx("div", {
|
|
42
|
-
"data-testid": `${testId}_select_dropdown`,
|
|
43
|
-
children: /* @__PURE__ */ jsx(components.DropdownIndicator, { ...props })
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
// src/Select/Select.tsx
|
|
11
|
+
// src/Select/selectVariants.ts
|
|
47
12
|
const selectVariants = tv({
|
|
48
13
|
slots: {
|
|
49
14
|
base: [
|
|
@@ -53,17 +18,24 @@ const selectVariants = tv({
|
|
|
53
18
|
"leading-normal"
|
|
54
19
|
],
|
|
55
20
|
clearIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800",
|
|
56
|
-
control:
|
|
21
|
+
control: [
|
|
22
|
+
"duration-150! min-h-10 rounded-lg border-2 border-default-200 bg-content1 transition-background",
|
|
23
|
+
"hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger",
|
|
24
|
+
"motion-reduce:transition-none"
|
|
25
|
+
],
|
|
57
26
|
control_focused: "border-focus",
|
|
58
27
|
crossIcon: "",
|
|
28
|
+
description: "text-foreground-500 text-tiny",
|
|
59
29
|
downChevron: "",
|
|
60
30
|
dropdownIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black",
|
|
31
|
+
errorMessage: "text-danger text-tiny",
|
|
61
32
|
group: "",
|
|
62
33
|
groupHeading: "mb-1 ml-3 mt-2 text-sm text-foreground-500",
|
|
63
|
-
|
|
34
|
+
helperWrapper: "relative flex flex-col gap-1.5 p-0",
|
|
64
35
|
indicatorSeparator: "bg-default-300",
|
|
36
|
+
indicatorsContainer: "gap-1 p-1",
|
|
65
37
|
input: "py-0.5 pl-1",
|
|
66
|
-
label: "pointer-events-auto inline-flex cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger",
|
|
38
|
+
label: ["pointer-events-auto inline-flex cursor-default text-sm text-foreground subpixel-antialiased", "group-data-[invalid=true]:!text-danger"],
|
|
67
39
|
loadingIndicator: "",
|
|
68
40
|
loadingMessage: "rounded-sm p-2 text-foreground-500",
|
|
69
41
|
menu: "mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg",
|
|
@@ -72,7 +44,7 @@ const selectVariants = tv({
|
|
|
72
44
|
multiValue: "h-6 items-center gap-1.5 rounded bg-default-100 pl-2 pr-1",
|
|
73
45
|
multiValueContainer: "",
|
|
74
46
|
multiValueLabel: "py-0 leading-5",
|
|
75
|
-
multiValueRemove: "flex h-5 w-5 items-center justify-center rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800",
|
|
47
|
+
multiValueRemove: ["flex h-5 w-5 items-center justify-center rounded text-default-500", "hover:cursor-pointer hover:border-default-300 hover:text-default-800"],
|
|
76
48
|
noOptionsMessage: "rounded-sm p-2 text-foreground-500",
|
|
77
49
|
option: "rounded px-3 py-2 hover:cursor-pointer",
|
|
78
50
|
option_disabled: "cursor-not-allowed! hover:cursor-not-allowed! opacity-disabled",
|
|
@@ -80,44 +52,36 @@ const selectVariants = tv({
|
|
|
80
52
|
option_selected: "bg-default-300",
|
|
81
53
|
placeholder: "ml-1 py-0.5 pl-1 text-sm text-foreground-500",
|
|
82
54
|
selectContainer: "",
|
|
55
|
+
selectedValue: "w-full truncate text-start font-normal text-small",
|
|
83
56
|
singleValue: "ml-1! leading-7!",
|
|
84
57
|
valueContainer: "gap-1 p-1"
|
|
85
58
|
},
|
|
86
59
|
variants: {
|
|
87
60
|
disabled: { true: {
|
|
88
|
-
base: "
|
|
61
|
+
base: "cursor-not-allowed opacity-disabled **:cursor-not-allowed",
|
|
89
62
|
clearIndicator: "hover:cursor-not-allowed hover:bg-transparent hover:text-foreground-500",
|
|
90
63
|
control: "hover:border-default-200",
|
|
91
64
|
dropdownIndicator: "hover:cursor-not-allowed hover:bg-transparent hover:text-foreground-500"
|
|
92
65
|
} },
|
|
66
|
+
invalid: { true: { selectedValue: "text-danger!" } },
|
|
93
67
|
readOnly: { true: {
|
|
94
|
-
base: "
|
|
68
|
+
base: "cursor-not-allowed opacity-disabled **:cursor-not-allowed",
|
|
95
69
|
clearIndicator: "hover:cursor-not-allowed hover:bg-transparent hover:text-foreground-500",
|
|
96
70
|
control: "hover:border-default-200",
|
|
97
71
|
dropdownIndicator: "hover:cursor-not-allowed hover:bg-transparent hover:text-foreground-500"
|
|
98
72
|
} }
|
|
99
73
|
}
|
|
100
74
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
const { getFieldState } = useFormContext();
|
|
113
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
114
|
-
const { convertToOriginalType } = createOptionValueConverter(options);
|
|
115
|
-
const variants = selectVariants({
|
|
116
|
-
disabled,
|
|
117
|
-
readOnly
|
|
118
|
-
});
|
|
119
|
-
const classNames = variantsToClassNames(variants, className, "base");
|
|
120
|
-
const reactSelectClassNames = {
|
|
75
|
+
// src/Select/helpers/getSelectClassNames.ts
|
|
76
|
+
/** Maps resolved Uniform slots to React Select's class callbacks */
|
|
77
|
+
const getSelectClassNames = (classNames, cn, isFocused, invalid) => {
|
|
78
|
+
return {
|
|
79
|
+
container: () => {
|
|
80
|
+
return classNames.selectContainer;
|
|
81
|
+
},
|
|
82
|
+
group: () => {
|
|
83
|
+
return classNames.group;
|
|
84
|
+
},
|
|
121
85
|
clearIndicator: () => {
|
|
122
86
|
return classNames.clearIndicator;
|
|
123
87
|
},
|
|
@@ -158,7 +122,7 @@ const Select = ({ className = void 0, clearable = true, debugMenuOpen = false, f
|
|
|
158
122
|
return classNames.multiValue;
|
|
159
123
|
},
|
|
160
124
|
multiValueLabel: () => {
|
|
161
|
-
return cn(
|
|
125
|
+
return cn(classNames.selectedValue, classNames.multiValueLabel);
|
|
162
126
|
},
|
|
163
127
|
multiValueRemove: () => {
|
|
164
128
|
return classNames.multiValueRemove;
|
|
@@ -177,73 +141,201 @@ const Select = ({ className = void 0, clearable = true, debugMenuOpen = false, f
|
|
|
177
141
|
return classNames.placeholder;
|
|
178
142
|
},
|
|
179
143
|
singleValue: () => {
|
|
180
|
-
return cn(classNames.
|
|
144
|
+
return cn(classNames.selectedValue, classNames.singleValue);
|
|
181
145
|
},
|
|
182
146
|
valueContainer: () => {
|
|
183
147
|
return classNames.valueContainer;
|
|
184
148
|
}
|
|
185
149
|
};
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
150
|
+
};
|
|
151
|
+
// src/Select/helpers/resolveSelectValue.ts
|
|
152
|
+
/** Finds selected options, preserving fallback labels for asynchronous searches */
|
|
153
|
+
const resolveSelectValue = (value, options, multiSelect, selectedOptionFallback) => {
|
|
154
|
+
const findOption = (v) => {
|
|
155
|
+
const inOptions = options.find((option) => {
|
|
156
|
+
return String(option.value) === String(v);
|
|
157
|
+
});
|
|
158
|
+
if (inOptions) return inOptions;
|
|
159
|
+
if (selectedOptionFallback) {
|
|
160
|
+
if (Array.isArray(selectedOptionFallback)) {
|
|
161
|
+
const inSelected = selectedOptionFallback.find((option) => {
|
|
162
|
+
return String(option.value) === String(v);
|
|
163
|
+
});
|
|
164
|
+
if (inSelected) return inSelected;
|
|
165
|
+
} else if (String(selectedOptionFallback.value) === String(v)) return selectedOptionFallback;
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
isFallback: true,
|
|
169
|
+
label: String(v),
|
|
170
|
+
value: v
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
if (multiSelect) {
|
|
174
|
+
if (!Array.isArray(value) || isValueEmpty(value)) return [];
|
|
175
|
+
return value.map((v) => {
|
|
176
|
+
return findOption(v);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (isValueEmpty(value)) return null;
|
|
180
|
+
return findOption(value);
|
|
181
|
+
};
|
|
182
|
+
// src/Select/subcomponents/SelectContext.ts
|
|
183
|
+
/** Resolved slot classes shared with the select's engine adapters */
|
|
184
|
+
const SelectSlotContext = createContext({});
|
|
185
|
+
/** Native input associations supplied by the field binding */
|
|
186
|
+
const SelectControlContext = createContext({});
|
|
187
|
+
// src/Select/subcomponents/SelectCrossIcon.tsx
|
|
188
|
+
/** Bind the declared icon/container slots to React Select's corresponding elements. */
|
|
189
|
+
const SelectCrossIcon = (props) => {
|
|
190
|
+
const { className } = props;
|
|
191
|
+
const slots = useContext(SelectSlotContext);
|
|
192
|
+
const { cn } = useStyling();
|
|
193
|
+
return /* @__PURE__ */ jsx(components.CrossIcon, {
|
|
194
|
+
...props,
|
|
195
|
+
className: cn(className, slots.crossIcon)
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
// src/Select/subcomponents/SelectClearIndicator.tsx
|
|
199
|
+
const SelectClearIndicator = (props) => {
|
|
200
|
+
return /* @__PURE__ */ jsx(components.ClearIndicator, {
|
|
201
|
+
...props,
|
|
202
|
+
children: /* @__PURE__ */ jsx(SelectCrossIcon, {})
|
|
196
203
|
});
|
|
204
|
+
};
|
|
205
|
+
// src/Select/subcomponents/SelectDownChevron.tsx
|
|
206
|
+
const SelectDownChevron = (props) => {
|
|
207
|
+
const { className } = props;
|
|
208
|
+
const slots = useContext(SelectSlotContext);
|
|
209
|
+
const { cn } = useStyling();
|
|
210
|
+
return /* @__PURE__ */ jsx(components.DownChevron, {
|
|
211
|
+
...props,
|
|
212
|
+
className: cn(className, slots.downChevron)
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
// src/Select/subcomponents/SelectDropdownIndicator.tsx
|
|
216
|
+
/** Wraps the dropdown indicator with a predictable test id for automation. */
|
|
217
|
+
const SelectDropdownIndicator = (props) => {
|
|
218
|
+
const testId = props?.selectProps["data-testid"];
|
|
219
|
+
return /* @__PURE__ */ jsx("div", {
|
|
220
|
+
"data-testid": `${testId}_select_dropdown`,
|
|
221
|
+
children: /* @__PURE__ */ jsx(components.DropdownIndicator, {
|
|
222
|
+
...props,
|
|
223
|
+
children: /* @__PURE__ */ jsx(SelectDownChevron, {})
|
|
224
|
+
})
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
// src/Select/subcomponents/SelectInput.tsx
|
|
228
|
+
/** Mirrors the select test id onto the underlying react-select input element. */
|
|
229
|
+
const SelectInput = (props) => {
|
|
230
|
+
const associations = useContext(SelectControlContext);
|
|
231
|
+
const testId = `${props.selectProps["data-testid"]}`;
|
|
232
|
+
const { "aria-describedby": engineDescription } = props;
|
|
233
|
+
const describedBy = [engineDescription, associations["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
234
|
+
return /* @__PURE__ */ jsx(components.Input, {
|
|
235
|
+
...props,
|
|
236
|
+
...associations,
|
|
237
|
+
"aria-describedby": describedBy,
|
|
238
|
+
"data-testid": testId
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
// src/Select/subcomponents/SelectInputControl.tsx
|
|
242
|
+
/** Wraps the control root to expose a stable `*_select` test id hook. */
|
|
243
|
+
const SelectInputControl = (props) => {
|
|
244
|
+
const testId = `${props.selectProps["data-testid"]}_select`;
|
|
245
|
+
return /* @__PURE__ */ jsx("div", {
|
|
246
|
+
"data-testid": testId,
|
|
247
|
+
children: /* @__PURE__ */ jsx(components.Control, { ...props })
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
// src/Select/subcomponents/SelectMultiValueContainer.tsx
|
|
251
|
+
const SelectMultiValueContainer = (props) => {
|
|
252
|
+
const slots = useContext(SelectSlotContext);
|
|
253
|
+
const { cn } = useStyling();
|
|
254
|
+
const { innerProps } = props;
|
|
255
|
+
return /* @__PURE__ */ jsx(components.MultiValueContainer, {
|
|
256
|
+
...props,
|
|
257
|
+
innerProps: {
|
|
258
|
+
...innerProps,
|
|
259
|
+
className: cn(innerProps.className, slots.multiValueContainer)
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
// src/Select/subcomponents/SelectMultiValueRemove.tsx
|
|
264
|
+
const SelectMultiValueRemove = (props) => {
|
|
265
|
+
return /* @__PURE__ */ jsx(components.MultiValueRemove, {
|
|
266
|
+
...props,
|
|
267
|
+
children: /* @__PURE__ */ jsx(SelectCrossIcon, { size: 14 })
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
// src/Select/subcomponents/SelectOption.tsx
|
|
271
|
+
/** Adds deterministic option test ids and forwards disabled state semantics. */
|
|
272
|
+
const SelectOption = (props) => {
|
|
273
|
+
const { isDisabled } = props;
|
|
274
|
+
const testId = `${props.selectProps["data-testid"]}_select_option_${slugify(String(props?.data?.testId ?? props?.data?.value), { replaceDots: true })}`;
|
|
275
|
+
return /* @__PURE__ */ jsx("div", {
|
|
276
|
+
"aria-disabled": isDisabled ? true : void 0,
|
|
277
|
+
"data-testid": testId,
|
|
278
|
+
children: /* @__PURE__ */ jsx(components.Option, { ...props })
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
// src/Select/subcomponents/SelectCombobox.tsx
|
|
282
|
+
const selectComponents = {
|
|
283
|
+
Control: SelectInputControl,
|
|
284
|
+
ClearIndicator: SelectClearIndicator,
|
|
285
|
+
MultiValueRemove: SelectMultiValueRemove,
|
|
286
|
+
DownChevron: SelectDownChevron,
|
|
287
|
+
MultiValueContainer: SelectMultiValueContainer,
|
|
288
|
+
DropdownIndicator: SelectDropdownIndicator,
|
|
289
|
+
Input: SelectInput,
|
|
290
|
+
Option: SelectOption
|
|
291
|
+
};
|
|
292
|
+
/** Hides React Select actions that would change a read-only selection */
|
|
293
|
+
const HiddenSelectAction = () => {
|
|
294
|
+
return null;
|
|
295
|
+
};
|
|
296
|
+
const readOnlySelectComponents = {
|
|
297
|
+
...selectComponents,
|
|
298
|
+
MultiValueRemove: HiddenSelectAction
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Searchable option engine with value conversion, menu slots and touched timing
|
|
302
|
+
*
|
|
303
|
+
* @see https://react-select.com/components
|
|
304
|
+
*/
|
|
305
|
+
const SelectCombobox = ({ className: classNames, clearable, debugMenuOpen, field, filterOption, getIsTouched, inputValue, loading, multiSelect = false, onInputChange, options, placeholder, renderEmptyOptions, renderOptionLabel, selectedOptionFallback }) => {
|
|
306
|
+
const styling = useStyling();
|
|
307
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
308
|
+
const { disabled, ids, invalid, name, onBlur, onChange: onValueChange, readOnly, ref: inputRef, testId, value } = field;
|
|
309
|
+
const controlProps = getFieldControlProps(field);
|
|
310
|
+
const inputAssociations = useMemo(() => {
|
|
311
|
+
return {
|
|
312
|
+
...controlProps,
|
|
313
|
+
"aria-readonly": readOnly || void 0
|
|
314
|
+
};
|
|
315
|
+
}, [controlProps, readOnly]);
|
|
316
|
+
const isClearable = !!clearable && !readOnly;
|
|
317
|
+
const { convertToOriginalType } = createOptionValueConverter(options);
|
|
318
|
+
const reactSelectClassNames = getSelectClassNames(classNames, styling.cn, isFocused, invalid);
|
|
197
319
|
const reactSelectOptions = options.map((option) => {
|
|
198
320
|
return {
|
|
199
321
|
...option,
|
|
200
322
|
isDisabled: option.disabled
|
|
201
323
|
};
|
|
202
324
|
});
|
|
203
|
-
const reactSelectValue = (
|
|
204
|
-
const findOption = (v) => {
|
|
205
|
-
const inOptions = options.find((option) => {
|
|
206
|
-
return String(option.value) === String(v);
|
|
207
|
-
});
|
|
208
|
-
if (inOptions) return inOptions;
|
|
209
|
-
if (selectedOptionFallback) {
|
|
210
|
-
if (Array.isArray(selectedOptionFallback)) {
|
|
211
|
-
const inSelected = selectedOptionFallback.find((option) => {
|
|
212
|
-
return String(option.value) === String(v);
|
|
213
|
-
});
|
|
214
|
-
if (inSelected) return inSelected;
|
|
215
|
-
} else if (String(selectedOptionFallback.value) === String(v)) return selectedOptionFallback;
|
|
216
|
-
}
|
|
217
|
-
return {
|
|
218
|
-
isFallback: true,
|
|
219
|
-
label: String(v),
|
|
220
|
-
value: v
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
if (multiSelect) {
|
|
224
|
-
if (!Array.isArray(value) || isValueEmpty(value)) return [];
|
|
225
|
-
return value.map((v) => {
|
|
226
|
-
return findOption(v);
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
if (isValueEmpty(value)) return null;
|
|
230
|
-
return findOption(value);
|
|
231
|
-
})();
|
|
325
|
+
const reactSelectValue = resolveSelectValue(value, options, multiSelect, selectedOptionFallback);
|
|
232
326
|
const handleChange = (option) => {
|
|
233
327
|
if (readOnly) return;
|
|
234
|
-
if (multiSelect)
|
|
235
|
-
return convertToOriginalType(
|
|
328
|
+
if (multiSelect) onValueChange(option?.map((selectedOption) => {
|
|
329
|
+
return convertToOriginalType(selectedOption.value);
|
|
236
330
|
}));
|
|
237
331
|
else {
|
|
238
|
-
const
|
|
239
|
-
|
|
332
|
+
const nextValue = option?.value;
|
|
333
|
+
onValueChange(nextValue != null ? convertToOriginalType(nextValue) : null);
|
|
240
334
|
}
|
|
241
|
-
|
|
242
|
-
if (!currentIsTouched) queueMicrotask(() => {
|
|
335
|
+
if (!getIsTouched()) queueMicrotask(() => {
|
|
243
336
|
onBlur();
|
|
244
337
|
});
|
|
245
338
|
};
|
|
246
|
-
const isClearable = clearable && !readOnly;
|
|
247
339
|
let menuIsOpen;
|
|
248
340
|
if (readOnly) menuIsOpen = false;
|
|
249
341
|
else if (debugMenuOpen) menuIsOpen = true;
|
|
@@ -254,44 +346,25 @@ const Select = ({ className = void 0, clearable = true, debugMenuOpen = false, f
|
|
|
254
346
|
const handleFocus = () => {
|
|
255
347
|
setIsFocused(true);
|
|
256
348
|
};
|
|
257
|
-
return /* @__PURE__ */
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
label ? /* @__PURE__ */ jsxs("label", {
|
|
264
|
-
className: classNames.label,
|
|
265
|
-
"data-slot": "label",
|
|
266
|
-
htmlFor: `react-select-${name}-input`,
|
|
267
|
-
id: getLabelProps().id,
|
|
268
|
-
children: [label, required ? /* @__PURE__ */ jsx("span", {
|
|
269
|
-
"aria-hidden": true,
|
|
270
|
-
className: "ml-0.5 text-danger",
|
|
271
|
-
children: "*"
|
|
272
|
-
}) : null]
|
|
273
|
-
}) : null,
|
|
274
|
-
/* @__PURE__ */ jsx(ReactSelect, {
|
|
275
|
-
ref,
|
|
349
|
+
return /* @__PURE__ */ jsx(SelectControlContext.Provider, {
|
|
350
|
+
value: inputAssociations,
|
|
351
|
+
children: /* @__PURE__ */ jsx(SelectSlotContext.Provider, {
|
|
352
|
+
value: classNames,
|
|
353
|
+
children: /* @__PURE__ */ jsx(ReactSelect, {
|
|
354
|
+
ref: inputRef,
|
|
276
355
|
"aria-errormessage": "",
|
|
277
356
|
"aria-invalid": invalid,
|
|
278
|
-
"aria-label":
|
|
279
|
-
"aria-labelledby":
|
|
280
|
-
"aria-readonly": readOnly || void 0,
|
|
357
|
+
"aria-label": controlProps["aria-label"],
|
|
358
|
+
"aria-labelledby": controlProps["aria-labelledby"],
|
|
281
359
|
backspaceRemovesValue: !readOnly,
|
|
282
360
|
classNames: reactSelectClassNames,
|
|
283
|
-
components:
|
|
284
|
-
Control: ControlComponent,
|
|
285
|
-
DropdownIndicator: DropdownIndicatorComponent,
|
|
286
|
-
Input: InputComponent,
|
|
287
|
-
...readOnly ? { MultiValueRemove: hiddenComponent } : {},
|
|
288
|
-
Option: OptionComponent
|
|
289
|
-
},
|
|
361
|
+
components: readOnly ? readOnlySelectComponents : selectComponents,
|
|
290
362
|
"data-testid": testId,
|
|
291
363
|
filterOption,
|
|
292
364
|
formatOptionLabel: renderOptionLabel,
|
|
365
|
+
inputId: ids.control,
|
|
293
366
|
inputValue: readOnly ? "" : inputValue,
|
|
294
|
-
instanceId:
|
|
367
|
+
instanceId: ids.control,
|
|
295
368
|
isClearable,
|
|
296
369
|
isDisabled: disabled,
|
|
297
370
|
isLoading: loading,
|
|
@@ -310,15 +383,69 @@ const Select = ({ className = void 0, clearable = true, debugMenuOpen = false, f
|
|
|
310
383
|
placeholder,
|
|
311
384
|
unstyled: true,
|
|
312
385
|
value: reactSelectValue
|
|
313
|
-
})
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
386
|
+
})
|
|
387
|
+
})
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
// src/Select/subcomponents/SelectControl.tsx
|
|
391
|
+
/** Searchable selection field layout and styling around the option engine */
|
|
392
|
+
const SelectControl = ({ className, field, ...props }) => {
|
|
393
|
+
const styling = useStyling();
|
|
394
|
+
const { description, disabled, errorMessage, ids, invalid, label, readOnly, required, testId } = field;
|
|
395
|
+
const variants = styling.resolve(selectVariants, {
|
|
396
|
+
disabled,
|
|
397
|
+
invalid,
|
|
398
|
+
readOnly
|
|
399
|
+
});
|
|
400
|
+
const classNames = styling.variantsToClassNames(variants, className, "base");
|
|
401
|
+
return /* @__PURE__ */ jsx(FieldLayout, {
|
|
402
|
+
baseProps: {
|
|
403
|
+
...getFieldDataAttributes(field),
|
|
404
|
+
"data-component": "select",
|
|
405
|
+
"data-testid": `${testId}_wrapper`
|
|
406
|
+
},
|
|
407
|
+
className: classNames,
|
|
408
|
+
description,
|
|
409
|
+
errorMessage,
|
|
410
|
+
ids,
|
|
411
|
+
invalid,
|
|
412
|
+
label,
|
|
413
|
+
required,
|
|
414
|
+
children: /* @__PURE__ */ jsx(SelectCombobox, {
|
|
415
|
+
...props,
|
|
416
|
+
className: classNames,
|
|
417
|
+
field
|
|
418
|
+
})
|
|
419
|
+
});
|
|
420
|
+
};
|
|
421
|
+
// src/Select/Select.tsx
|
|
422
|
+
/** Form selection field with searchable single or multiple options */
|
|
423
|
+
const Select = ({ className = void 0, clearable = true, debugMenuOpen = false, filterOption = void 0, inputValue = void 0, loading = false, multiSelect = false, name, onInputChange = void 0, options, placeholder = void 0, renderEmptyOptions = void 0, renderOptionLabel = void 0, selectedOptionFallback = void 0, ...uniformFieldProps }) => {
|
|
424
|
+
const { getFieldState } = useFormContext();
|
|
425
|
+
const { field } = useUniformField({
|
|
426
|
+
...uniformFieldProps,
|
|
427
|
+
isArrayValue: multiSelect,
|
|
428
|
+
name
|
|
429
|
+
});
|
|
430
|
+
const getIsTouched = () => {
|
|
431
|
+
return getFieldState(name, field.testId).isTouched;
|
|
432
|
+
};
|
|
433
|
+
return /* @__PURE__ */ jsx(SelectControl, {
|
|
434
|
+
className,
|
|
435
|
+
clearable,
|
|
436
|
+
debugMenuOpen,
|
|
437
|
+
field,
|
|
438
|
+
filterOption,
|
|
439
|
+
getIsTouched,
|
|
440
|
+
inputValue,
|
|
441
|
+
loading,
|
|
442
|
+
multiSelect,
|
|
443
|
+
onInputChange,
|
|
444
|
+
options,
|
|
445
|
+
placeholder,
|
|
446
|
+
renderEmptyOptions,
|
|
447
|
+
renderOptionLabel,
|
|
448
|
+
selectedOptionFallback
|
|
322
449
|
});
|
|
323
450
|
};
|
|
324
451
|
// src/Select/index.ts
|