@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/Select/Select.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/Select/selectVariants.ts","../../src/Select/Select.tsx"],"mappings":";;;;;qBAIa,kBAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4Ef,YAAY,mBAAmB;;;UCrE1B;;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,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,99 +1,77 @@
|
|
|
1
1
|
import { createOptionValueConverter, isValueEmpty } from "../helpers/index.mjs";
|
|
2
|
-
import { n as useFormContext } from "../useFormContext-
|
|
3
|
-
import { useUniformField } from "../
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { n as useFormContext } from "../useFormContext-BPjJjNnM.mjs";
|
|
3
|
+
import { n as useUniformField } from "../FieldLabel-DKzqkuY1.mjs";
|
|
4
|
+
import { n as getFieldControlProps, r as getFieldDataAttributes } from "../FieldDescription-C4l0HKGL.mjs";
|
|
5
|
+
import { t as FieldLayout } from "../FieldLayout-BLW5S-Jm.mjs";
|
|
6
|
+
import { createContext, useContext, 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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
11
|
+
//#region src/Select/selectVariants.ts
|
|
12
|
+
const selectVariants = tv({
|
|
13
|
+
slots: {
|
|
14
|
+
base: [
|
|
15
|
+
"group",
|
|
16
|
+
"flex w-full flex-col",
|
|
17
|
+
"gap-y-1.5",
|
|
18
|
+
"leading-normal"
|
|
19
|
+
],
|
|
20
|
+
clearIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800",
|
|
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
|
+
],
|
|
26
|
+
control_focused: "border-focus",
|
|
27
|
+
crossIcon: "",
|
|
28
|
+
description: "text-foreground-500 text-tiny",
|
|
29
|
+
downChevron: "",
|
|
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",
|
|
32
|
+
group: "",
|
|
33
|
+
groupHeading: "mb-1 ml-3 mt-2 text-sm text-foreground-500",
|
|
34
|
+
helperWrapper: "relative flex flex-col gap-1.5 p-0",
|
|
35
|
+
indicatorSeparator: "bg-default-300",
|
|
36
|
+
indicatorsContainer: "gap-1 p-1",
|
|
37
|
+
input: "py-0.5 pl-1",
|
|
38
|
+
label: ["pointer-events-auto inline-flex cursor-default text-sm text-foreground subpixel-antialiased", "group-data-[invalid=true]:!text-danger"],
|
|
39
|
+
loadingIndicator: "",
|
|
40
|
+
loadingMessage: "rounded-sm p-2 text-foreground-500",
|
|
41
|
+
menu: "mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg",
|
|
42
|
+
menuList: "",
|
|
43
|
+
menuPortal: "z-50!",
|
|
44
|
+
multiValue: "h-6 items-center gap-1.5 rounded bg-default-100 pl-2 pr-1",
|
|
45
|
+
multiValueContainer: "",
|
|
46
|
+
multiValueLabel: "py-0 leading-5",
|
|
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"],
|
|
48
|
+
noOptionsMessage: "rounded-sm p-2 text-foreground-500",
|
|
49
|
+
option: "rounded px-3 py-2 hover:cursor-pointer",
|
|
50
|
+
option_disabled: "cursor-not-allowed! hover:cursor-not-allowed! opacity-disabled",
|
|
51
|
+
option_focused: "bg-default-100 active:bg-default-200",
|
|
52
|
+
option_selected: "bg-default-300",
|
|
53
|
+
placeholder: "ml-1 py-0.5 pl-1 text-sm text-foreground-500",
|
|
54
|
+
selectContainer: "",
|
|
55
|
+
selectedValue: "w-full truncate text-start font-normal text-small",
|
|
56
|
+
singleValue: "ml-1! leading-7!",
|
|
57
|
+
valueContainer: "gap-1 p-1"
|
|
58
|
+
},
|
|
59
|
+
variants: {
|
|
60
|
+
disabled: { true: { base: "pointer-events-none opacity-disabled" } },
|
|
61
|
+
invalid: { true: { selectedValue: "text-danger!" } }
|
|
62
|
+
}
|
|
63
|
+
});
|
|
44
64
|
//#endregion
|
|
45
|
-
//#region src/Select/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
control_focused: "border-focus",
|
|
56
|
-
crossIcon: "",
|
|
57
|
-
downChevron: "",
|
|
58
|
-
dropdownIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black",
|
|
59
|
-
group: "",
|
|
60
|
-
groupHeading: "mb-1 ml-3 mt-2 text-sm text-foreground-500",
|
|
61
|
-
indicatorsContainer: "gap-1 p-1",
|
|
62
|
-
indicatorSeparator: "bg-default-300",
|
|
63
|
-
input: "py-0.5 pl-1",
|
|
64
|
-
label: "pointer-events-auto inline-flex cursor-default text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger",
|
|
65
|
-
loadingIndicator: "",
|
|
66
|
-
loadingMessage: "rounded-sm p-2 text-foreground-500",
|
|
67
|
-
menu: "mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg",
|
|
68
|
-
menuList: "",
|
|
69
|
-
menuPortal: "z-50!",
|
|
70
|
-
multiValue: "h-6 items-center gap-1.5 rounded bg-default-100 pl-2 pr-1",
|
|
71
|
-
multiValueContainer: "",
|
|
72
|
-
multiValueLabel: "py-0 leading-5",
|
|
73
|
-
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",
|
|
74
|
-
noOptionsMessage: "rounded-sm p-2 text-foreground-500",
|
|
75
|
-
option: "rounded px-3 py-2 hover:cursor-pointer",
|
|
76
|
-
option_disabled: "cursor-not-allowed! hover:cursor-not-allowed! opacity-disabled",
|
|
77
|
-
option_focused: "bg-default-100 active:bg-default-200",
|
|
78
|
-
option_selected: "bg-default-300",
|
|
79
|
-
placeholder: "ml-1 py-0.5 pl-1 text-sm text-foreground-500",
|
|
80
|
-
selectContainer: "",
|
|
81
|
-
singleValue: "ml-1! leading-7!",
|
|
82
|
-
valueContainer: "gap-1 p-1"
|
|
83
|
-
} });
|
|
84
|
-
/** Select component based on [HeroUI Select](https://www.heroui.com//docs/components/select) and [React-Select](https://react-select.com/home) */
|
|
85
|
-
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 }) => {
|
|
86
|
-
const { ariaLabel, disabled, errorMessage, field: { onBlur, onChange, ref, value }, getErrorMessageProps, getHelperWrapperProps, getLabelProps, invalid, label, required, testId } = useUniformField({
|
|
87
|
-
isArrayValue: multiSelect,
|
|
88
|
-
name,
|
|
89
|
-
...uniformFieldProps
|
|
90
|
-
});
|
|
91
|
-
const { getFieldState } = useFormContext();
|
|
92
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
93
|
-
const { convertToOriginalType } = createOptionValueConverter(options);
|
|
94
|
-
const variants = selectVariants();
|
|
95
|
-
const classNames = variantsToClassNames(variants, className, "base");
|
|
96
|
-
const reactSelectClassNames = {
|
|
65
|
+
//#region src/Select/helpers/getSelectClassNames.ts
|
|
66
|
+
/** Maps resolved Uniform slots to React Select's class callbacks */
|
|
67
|
+
const getSelectClassNames = (classNames, cn, isFocused, invalid) => {
|
|
68
|
+
return {
|
|
69
|
+
container: () => {
|
|
70
|
+
return classNames.selectContainer;
|
|
71
|
+
},
|
|
72
|
+
group: () => {
|
|
73
|
+
return classNames.group;
|
|
74
|
+
},
|
|
97
75
|
clearIndicator: () => {
|
|
98
76
|
return classNames.clearIndicator;
|
|
99
77
|
},
|
|
@@ -134,7 +112,7 @@ const Select = ({ className = void 0, clearable = true, debugMenuOpen = false, f
|
|
|
134
112
|
return classNames.multiValue;
|
|
135
113
|
},
|
|
136
114
|
multiValueLabel: () => {
|
|
137
|
-
return cn(
|
|
115
|
+
return cn(classNames.selectedValue, classNames.multiValueLabel);
|
|
138
116
|
},
|
|
139
117
|
multiValueRemove: () => {
|
|
140
118
|
return classNames.multiValueRemove;
|
|
@@ -153,68 +131,194 @@ const Select = ({ className = void 0, clearable = true, debugMenuOpen = false, f
|
|
|
153
131
|
return classNames.placeholder;
|
|
154
132
|
},
|
|
155
133
|
singleValue: () => {
|
|
156
|
-
return cn(classNames.
|
|
134
|
+
return cn(classNames.selectedValue, classNames.singleValue);
|
|
157
135
|
},
|
|
158
136
|
valueContainer: () => {
|
|
159
137
|
return classNames.valueContainer;
|
|
160
138
|
}
|
|
161
139
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
140
|
+
};
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/Select/helpers/resolveSelectValue.ts
|
|
143
|
+
/** Finds selected options, preserving fallback labels for asynchronous searches */
|
|
144
|
+
const resolveSelectValue = (value, options, multiSelect, selectedOptionFallback) => {
|
|
145
|
+
const findOption = (v) => {
|
|
146
|
+
const inOptions = options.find((option) => {
|
|
147
|
+
return String(option.value) === String(v);
|
|
148
|
+
});
|
|
149
|
+
if (inOptions) return inOptions;
|
|
150
|
+
if (selectedOptionFallback) {
|
|
151
|
+
if (Array.isArray(selectedOptionFallback)) {
|
|
152
|
+
const inSelected = selectedOptionFallback.find((option) => {
|
|
153
|
+
return String(option.value) === String(v);
|
|
154
|
+
});
|
|
155
|
+
if (inSelected) return inSelected;
|
|
156
|
+
} else if (String(selectedOptionFallback.value) === String(v)) return selectedOptionFallback;
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
isFallback: true,
|
|
160
|
+
label: String(v),
|
|
161
|
+
value: v
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
if (multiSelect) {
|
|
165
|
+
if (!Array.isArray(value) || isValueEmpty(value)) return [];
|
|
166
|
+
return value.map((v) => {
|
|
167
|
+
return findOption(v);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (isValueEmpty(value)) return null;
|
|
171
|
+
return findOption(value);
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/Select/subcomponents/SelectContext.ts
|
|
175
|
+
/** Resolved slot classes shared with the select's engine adapters */
|
|
176
|
+
const SelectSlotContext = createContext({});
|
|
177
|
+
/** Native input associations supplied by the field binding */
|
|
178
|
+
const SelectControlContext = createContext({});
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/Select/subcomponents/SelectCrossIcon.tsx
|
|
181
|
+
/** Bind the declared icon/container slots to React Select's corresponding elements. */
|
|
182
|
+
const SelectCrossIcon = (props) => {
|
|
183
|
+
const { className } = props;
|
|
184
|
+
const slots = useContext(SelectSlotContext);
|
|
185
|
+
const { cn } = useStyling();
|
|
186
|
+
return /* @__PURE__ */ jsx(components.CrossIcon, {
|
|
187
|
+
...props,
|
|
188
|
+
className: cn(className, slots.crossIcon)
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/Select/subcomponents/SelectClearIndicator.tsx
|
|
193
|
+
const SelectClearIndicator = (props) => {
|
|
194
|
+
return /* @__PURE__ */ jsx(components.ClearIndicator, {
|
|
195
|
+
...props,
|
|
196
|
+
children: /* @__PURE__ */ jsx(SelectCrossIcon, {})
|
|
172
197
|
});
|
|
198
|
+
};
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/Select/subcomponents/SelectDownChevron.tsx
|
|
201
|
+
const SelectDownChevron = (props) => {
|
|
202
|
+
const { className } = props;
|
|
203
|
+
const slots = useContext(SelectSlotContext);
|
|
204
|
+
const { cn } = useStyling();
|
|
205
|
+
return /* @__PURE__ */ jsx(components.DownChevron, {
|
|
206
|
+
...props,
|
|
207
|
+
className: cn(className, slots.downChevron)
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/Select/subcomponents/SelectDropdownIndicator.tsx
|
|
212
|
+
/** Wraps the dropdown indicator with a predictable test id for automation. */
|
|
213
|
+
const SelectDropdownIndicator = (props) => {
|
|
214
|
+
const testId = props?.selectProps["data-testid"];
|
|
215
|
+
return /* @__PURE__ */ jsx("div", {
|
|
216
|
+
"data-testid": `${testId}_select_dropdown`,
|
|
217
|
+
children: /* @__PURE__ */ jsx(components.DropdownIndicator, {
|
|
218
|
+
...props,
|
|
219
|
+
children: /* @__PURE__ */ jsx(SelectDownChevron, {})
|
|
220
|
+
})
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/Select/subcomponents/SelectInput.tsx
|
|
225
|
+
/** Mirrors the select test id onto the underlying react-select input element. */
|
|
226
|
+
const SelectInput = (props) => {
|
|
227
|
+
const associations = useContext(SelectControlContext);
|
|
228
|
+
const testId = `${props.selectProps["data-testid"]}`;
|
|
229
|
+
const { "aria-describedby": engineDescription } = props;
|
|
230
|
+
const describedBy = [engineDescription, associations["aria-describedby"]].filter(Boolean).join(" ") || void 0;
|
|
231
|
+
return /* @__PURE__ */ jsx(components.Input, {
|
|
232
|
+
...props,
|
|
233
|
+
...associations,
|
|
234
|
+
"aria-describedby": describedBy,
|
|
235
|
+
"data-testid": testId
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region src/Select/subcomponents/SelectInputControl.tsx
|
|
240
|
+
/** Wraps the control root to expose a stable `*_select` test id hook. */
|
|
241
|
+
const SelectInputControl = (props) => {
|
|
242
|
+
const testId = `${props.selectProps["data-testid"]}_select`;
|
|
243
|
+
return /* @__PURE__ */ jsx("div", {
|
|
244
|
+
"data-testid": testId,
|
|
245
|
+
children: /* @__PURE__ */ jsx(components.Control, { ...props })
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/Select/subcomponents/SelectMultiValueContainer.tsx
|
|
250
|
+
const SelectMultiValueContainer = (props) => {
|
|
251
|
+
const slots = useContext(SelectSlotContext);
|
|
252
|
+
const { cn } = useStyling();
|
|
253
|
+
const { innerProps } = props;
|
|
254
|
+
return /* @__PURE__ */ jsx(components.MultiValueContainer, {
|
|
255
|
+
...props,
|
|
256
|
+
innerProps: {
|
|
257
|
+
...innerProps,
|
|
258
|
+
className: cn(innerProps.className, slots.multiValueContainer)
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region 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
|
+
//#endregion
|
|
271
|
+
//#region src/Select/subcomponents/SelectOption.tsx
|
|
272
|
+
/** Adds deterministic option test ids and forwards disabled state semantics. */
|
|
273
|
+
const SelectOption = (props) => {
|
|
274
|
+
const { isDisabled } = props;
|
|
275
|
+
const testId = `${props.selectProps["data-testid"]}_select_option_${slugify(String(props?.data?.testId ?? props?.data?.value), { replaceDots: true })}`;
|
|
276
|
+
return /* @__PURE__ */ jsx("div", {
|
|
277
|
+
"aria-disabled": isDisabled ? true : void 0,
|
|
278
|
+
"data-testid": testId,
|
|
279
|
+
children: /* @__PURE__ */ jsx(components.Option, { ...props })
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/Select/subcomponents/SelectCombobox.tsx
|
|
284
|
+
const selectComponents = {
|
|
285
|
+
Control: SelectInputControl,
|
|
286
|
+
ClearIndicator: SelectClearIndicator,
|
|
287
|
+
MultiValueRemove: SelectMultiValueRemove,
|
|
288
|
+
DownChevron: SelectDownChevron,
|
|
289
|
+
MultiValueContainer: SelectMultiValueContainer,
|
|
290
|
+
DropdownIndicator: SelectDropdownIndicator,
|
|
291
|
+
Input: SelectInput,
|
|
292
|
+
Option: SelectOption
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Searchable option engine with value conversion, menu slots and touched timing
|
|
296
|
+
*
|
|
297
|
+
* @see https://react-select.com/components
|
|
298
|
+
*/
|
|
299
|
+
const SelectCombobox = ({ className: classNames, clearable, debugMenuOpen, field, filterOption, getIsTouched, inputValue, loading, multiSelect = false, onInputChange, options, placeholder, renderEmptyOptions, renderOptionLabel, selectedOptionFallback }) => {
|
|
300
|
+
const styling = useStyling();
|
|
301
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
302
|
+
const { disabled, ids, invalid, name, onBlur, onChange: onValueChange, ref: inputRef, testId, value } = field;
|
|
303
|
+
const controlProps = getFieldControlProps(field);
|
|
304
|
+
const { convertToOriginalType } = createOptionValueConverter(options);
|
|
305
|
+
const reactSelectClassNames = getSelectClassNames(classNames, styling.cn, isFocused, invalid);
|
|
173
306
|
const reactSelectOptions = options.map((option) => {
|
|
174
307
|
return {
|
|
175
308
|
...option,
|
|
176
309
|
isDisabled: option.disabled
|
|
177
310
|
};
|
|
178
311
|
});
|
|
179
|
-
const reactSelectValue = (
|
|
180
|
-
const findOption = (v) => {
|
|
181
|
-
const inOptions = options.find((option) => {
|
|
182
|
-
return String(option.value) === String(v);
|
|
183
|
-
});
|
|
184
|
-
if (inOptions) return inOptions;
|
|
185
|
-
if (selectedOptionFallback) {
|
|
186
|
-
if (Array.isArray(selectedOptionFallback)) {
|
|
187
|
-
const inSelected = selectedOptionFallback.find((option) => {
|
|
188
|
-
return String(option.value) === String(v);
|
|
189
|
-
});
|
|
190
|
-
if (inSelected) return inSelected;
|
|
191
|
-
} else if (String(selectedOptionFallback.value) === String(v)) return selectedOptionFallback;
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
isFallback: true,
|
|
195
|
-
label: String(v),
|
|
196
|
-
value: v
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
if (multiSelect) {
|
|
200
|
-
if (!Array.isArray(value) || isValueEmpty(value)) return [];
|
|
201
|
-
return value.map((v) => {
|
|
202
|
-
return findOption(v);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
if (isValueEmpty(value)) return null;
|
|
206
|
-
return findOption(value);
|
|
207
|
-
})();
|
|
312
|
+
const reactSelectValue = resolveSelectValue(value, options, multiSelect, selectedOptionFallback);
|
|
208
313
|
const handleChange = (option) => {
|
|
209
|
-
if (multiSelect)
|
|
210
|
-
return convertToOriginalType(
|
|
314
|
+
if (multiSelect) onValueChange(option?.map((selectedOption) => {
|
|
315
|
+
return convertToOriginalType(selectedOption.value);
|
|
211
316
|
}));
|
|
212
317
|
else {
|
|
213
|
-
const
|
|
214
|
-
|
|
318
|
+
const nextValue = option?.value;
|
|
319
|
+
onValueChange(nextValue != null ? convertToOriginalType(nextValue) : null);
|
|
215
320
|
}
|
|
216
|
-
|
|
217
|
-
if (!currentIsTouched) queueMicrotask(() => {
|
|
321
|
+
if (!getIsTouched()) queueMicrotask(() => {
|
|
218
322
|
onBlur();
|
|
219
323
|
});
|
|
220
324
|
};
|
|
@@ -225,41 +329,24 @@ const Select = ({ className = void 0, clearable = true, debugMenuOpen = false, f
|
|
|
225
329
|
const handleFocus = () => {
|
|
226
330
|
setIsFocused(true);
|
|
227
331
|
};
|
|
228
|
-
return /* @__PURE__ */
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
label ? /* @__PURE__ */ jsxs("label", {
|
|
235
|
-
className: classNames.label,
|
|
236
|
-
"data-slot": "label",
|
|
237
|
-
htmlFor: `react-select-${name}-input`,
|
|
238
|
-
id: getLabelProps().id,
|
|
239
|
-
children: [label, required ? /* @__PURE__ */ jsx("span", {
|
|
240
|
-
"aria-hidden": true,
|
|
241
|
-
className: "ml-0.5 text-danger",
|
|
242
|
-
children: "*"
|
|
243
|
-
}) : null]
|
|
244
|
-
}) : null,
|
|
245
|
-
/* @__PURE__ */ jsx(ReactSelect, {
|
|
246
|
-
ref,
|
|
332
|
+
return /* @__PURE__ */ jsx(SelectControlContext.Provider, {
|
|
333
|
+
value: controlProps,
|
|
334
|
+
children: /* @__PURE__ */ jsx(SelectSlotContext.Provider, {
|
|
335
|
+
value: classNames,
|
|
336
|
+
children: /* @__PURE__ */ jsx(ReactSelect, {
|
|
337
|
+
ref: inputRef,
|
|
247
338
|
"aria-errormessage": "",
|
|
248
339
|
"aria-invalid": invalid,
|
|
249
|
-
"aria-label":
|
|
250
|
-
"aria-labelledby":
|
|
340
|
+
"aria-label": controlProps["aria-label"],
|
|
341
|
+
"aria-labelledby": controlProps["aria-labelledby"],
|
|
251
342
|
classNames: reactSelectClassNames,
|
|
252
|
-
components:
|
|
253
|
-
Control: ControlComponent,
|
|
254
|
-
DropdownIndicator: DropdownIndicatorComponent,
|
|
255
|
-
Input: InputComponent,
|
|
256
|
-
Option: OptionComponent
|
|
257
|
-
},
|
|
343
|
+
components: selectComponents,
|
|
258
344
|
"data-testid": testId,
|
|
259
345
|
filterOption,
|
|
260
346
|
formatOptionLabel: renderOptionLabel,
|
|
347
|
+
inputId: ids.control,
|
|
261
348
|
inputValue,
|
|
262
|
-
instanceId:
|
|
349
|
+
instanceId: ids.control,
|
|
263
350
|
isClearable: clearable,
|
|
264
351
|
isDisabled: disabled,
|
|
265
352
|
isLoading: loading,
|
|
@@ -277,15 +364,70 @@ const Select = ({ className = void 0, clearable = true, debugMenuOpen = false, f
|
|
|
277
364
|
placeholder,
|
|
278
365
|
unstyled: true,
|
|
279
366
|
value: reactSelectValue
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
367
|
+
})
|
|
368
|
+
})
|
|
369
|
+
});
|
|
370
|
+
};
|
|
371
|
+
//#endregion
|
|
372
|
+
//#region src/Select/subcomponents/SelectControl.tsx
|
|
373
|
+
/** Searchable selection field layout and styling around the option engine */
|
|
374
|
+
const SelectControl = ({ className, field, ...props }) => {
|
|
375
|
+
const styling = useStyling();
|
|
376
|
+
const { description, disabled, errorMessage, ids, invalid, label, required, testId } = field;
|
|
377
|
+
const variants = styling.resolve(selectVariants, {
|
|
378
|
+
disabled,
|
|
379
|
+
invalid
|
|
380
|
+
});
|
|
381
|
+
const classNames = styling.variantsToClassNames(variants, className, "base");
|
|
382
|
+
return /* @__PURE__ */ jsx(FieldLayout, {
|
|
383
|
+
baseProps: {
|
|
384
|
+
...getFieldDataAttributes(field),
|
|
385
|
+
"data-component": "select",
|
|
386
|
+
"data-testid": `${testId}_wrapper`
|
|
387
|
+
},
|
|
388
|
+
className: classNames,
|
|
389
|
+
description,
|
|
390
|
+
errorMessage,
|
|
391
|
+
ids,
|
|
392
|
+
invalid,
|
|
393
|
+
label,
|
|
394
|
+
required,
|
|
395
|
+
children: /* @__PURE__ */ jsx(SelectCombobox, {
|
|
396
|
+
...props,
|
|
397
|
+
className: classNames,
|
|
398
|
+
field
|
|
399
|
+
})
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
//#endregion
|
|
403
|
+
//#region src/Select/Select.tsx
|
|
404
|
+
/** Form selection field with searchable single or multiple options */
|
|
405
|
+
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 }) => {
|
|
406
|
+
const { getFieldState } = useFormContext();
|
|
407
|
+
const { field } = useUniformField({
|
|
408
|
+
...uniformFieldProps,
|
|
409
|
+
isArrayValue: multiSelect,
|
|
410
|
+
name
|
|
411
|
+
});
|
|
412
|
+
const getIsTouched = () => {
|
|
413
|
+
return getFieldState(name, field.testId).isTouched;
|
|
414
|
+
};
|
|
415
|
+
return /* @__PURE__ */ jsx(SelectControl, {
|
|
416
|
+
className,
|
|
417
|
+
clearable,
|
|
418
|
+
debugMenuOpen,
|
|
419
|
+
field,
|
|
420
|
+
filterOption,
|
|
421
|
+
getIsTouched,
|
|
422
|
+
inputValue,
|
|
423
|
+
loading,
|
|
424
|
+
multiSelect,
|
|
425
|
+
onInputChange,
|
|
426
|
+
options,
|
|
427
|
+
placeholder,
|
|
428
|
+
renderEmptyOptions,
|
|
429
|
+
renderOptionLabel,
|
|
430
|
+
selectedOptionFallback
|
|
289
431
|
});
|
|
290
432
|
};
|
|
291
433
|
//#endregion
|