@fuf-stack/uniform 0.9.5 → 0.9.6
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/dist/CheckboxGroup/index.cjs +3 -3
- package/dist/CheckboxGroup/index.d.cts +5 -2
- package/dist/CheckboxGroup/index.d.ts +5 -2
- package/dist/CheckboxGroup/index.js +2 -2
- package/dist/CheckboxGroup-o-qWkWe1.d.cts +130 -0
- package/dist/CheckboxGroup-o-qWkWe1.d.ts +130 -0
- package/dist/FieldArray/index.cjs +3 -3
- package/dist/FieldArray/index.js +2 -2
- package/dist/{FieldValidationError-BSXedjCA.d.cts → FieldValidationError-DAT12Ess.d.cts} +2 -1
- package/dist/{FieldValidationError-BSXedjCA.d.ts → FieldValidationError-DAT12Ess.d.ts} +2 -1
- package/dist/Input/index.cjs +3 -3
- package/dist/Input/index.js +2 -2
- package/dist/RadioGroup/index.cjs +3 -3
- package/dist/RadioGroup/index.d.cts +5 -2
- package/dist/RadioGroup/index.d.ts +5 -2
- package/dist/RadioGroup/index.js +2 -2
- package/dist/RadioGroup-D_kiBt0M.d.cts +162 -0
- package/dist/RadioGroup-D_kiBt0M.d.ts +162 -0
- package/dist/Select/index.cjs +3 -3
- package/dist/Select/index.d.cts +3 -3
- package/dist/Select/index.d.ts +3 -3
- package/dist/Select/index.js +2 -2
- package/dist/Select-BhS4z0Pj.d.cts +317 -0
- package/dist/Select-BhS4z0Pj.d.ts +317 -0
- package/dist/Switch/index.cjs +3 -3
- package/dist/Switch/index.d.cts +5 -2
- package/dist/Switch/index.d.ts +5 -2
- package/dist/Switch/index.js +2 -2
- package/dist/Switch-Fdldj8LV.d.cts +126 -0
- package/dist/Switch-Fdldj8LV.d.ts +126 -0
- package/dist/TextArea/index.cjs +3 -3
- package/dist/TextArea/index.js +2 -2
- package/dist/{chunk-OCR2UWG2.cjs → chunk-4RTJ5XR2.cjs} +3 -3
- package/dist/{chunk-OCR2UWG2.cjs.map → chunk-4RTJ5XR2.cjs.map} +1 -1
- package/dist/{chunk-YUAJN6HW.cjs → chunk-6HMMXOSV.cjs} +48 -15
- package/dist/chunk-6HMMXOSV.cjs.map +1 -0
- package/dist/{chunk-FMQNL3RT.js → chunk-F7GG67YU.js} +2 -2
- package/dist/{chunk-W24WP5YE.cjs → chunk-HFMFDBEV.cjs} +46 -14
- package/dist/chunk-HFMFDBEV.cjs.map +1 -0
- package/dist/{chunk-NHPQEYYN.js → chunk-HOCRJOEU.js} +2 -2
- package/dist/{chunk-TNELIBCV.cjs → chunk-JDRMKZ35.cjs} +4 -4
- package/dist/{chunk-TNELIBCV.cjs.map → chunk-JDRMKZ35.cjs.map} +1 -1
- package/dist/{chunk-4AHVJWTB.js → chunk-JG5VQZ4V.js} +46 -14
- package/dist/chunk-JG5VQZ4V.js.map +1 -0
- package/dist/{chunk-5UHHZ7KY.cjs → chunk-JRFKYVXY.cjs} +3 -3
- package/dist/{chunk-5UHHZ7KY.cjs.map → chunk-JRFKYVXY.cjs.map} +1 -1
- package/dist/chunk-LDW7K7LW.js +231 -0
- package/dist/chunk-LDW7K7LW.js.map +1 -0
- package/dist/{chunk-INTLZONV.cjs → chunk-NQ4JZ7AK.cjs} +37 -15
- package/dist/chunk-NQ4JZ7AK.cjs.map +1 -0
- package/dist/{chunk-QVBZ5RLN.cjs → chunk-NXTXKBTP.cjs} +104 -113
- package/dist/chunk-NXTXKBTP.cjs.map +1 -0
- package/dist/{chunk-QTL5FREE.cjs → chunk-OHJYXA6R.cjs} +7 -5
- package/dist/chunk-OHJYXA6R.cjs.map +1 -0
- package/dist/{chunk-AVKEYJH7.js → chunk-PFX4YRWI.js} +38 -16
- package/dist/chunk-PFX4YRWI.js.map +1 -0
- package/dist/{chunk-DTSX7YON.js → chunk-SCTH3FAO.js} +2 -2
- package/dist/{chunk-DBLODROX.js → chunk-WKM2D7LF.js} +7 -5
- package/dist/chunk-WKM2D7LF.js.map +1 -0
- package/dist/{chunk-ARUVDZFG.js → chunk-YSZW33OV.js} +48 -15
- package/dist/chunk-YSZW33OV.js.map +1 -0
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +10 -10
- package/dist/partials/FieldValidationError/index.cjs +2 -2
- package/dist/partials/FieldValidationError/index.d.cts +2 -2
- package/dist/partials/FieldValidationError/index.d.ts +2 -2
- package/dist/partials/FieldValidationError/index.js +1 -1
- package/package.json +4 -4
- package/dist/CheckboxGroup-BYsQ0A0q.d.cts +0 -32
- package/dist/CheckboxGroup-BYsQ0A0q.d.ts +0 -32
- package/dist/RadioGroup-BU4K9cnS.d.cts +0 -40
- package/dist/RadioGroup-BU4K9cnS.d.ts +0 -40
- package/dist/Select-C08Oftdr.d.cts +0 -184
- package/dist/Select-C08Oftdr.d.ts +0 -184
- package/dist/Switch-OkO3GdPy.d.cts +0 -20
- package/dist/Switch-OkO3GdPy.d.ts +0 -20
- package/dist/chunk-4AHVJWTB.js.map +0 -1
- package/dist/chunk-ARUVDZFG.js.map +0 -1
- package/dist/chunk-AVKEYJH7.js.map +0 -1
- package/dist/chunk-DBLODROX.js.map +0 -1
- package/dist/chunk-I5M2A3MN.js +0 -240
- package/dist/chunk-I5M2A3MN.js.map +0 -1
- package/dist/chunk-INTLZONV.cjs.map +0 -1
- package/dist/chunk-QTL5FREE.cjs.map +0 -1
- package/dist/chunk-QVBZ5RLN.cjs.map +0 -1
- package/dist/chunk-W24WP5YE.cjs.map +0 -1
- package/dist/chunk-YUAJN6HW.cjs.map +0 -1
- /package/dist/{chunk-FMQNL3RT.js.map → chunk-F7GG67YU.js.map} +0 -0
- /package/dist/{chunk-NHPQEYYN.js.map → chunk-HOCRJOEU.js.map} +0 -0
- /package/dist/{chunk-DTSX7YON.js.map → chunk-SCTH3FAO.js.map} +0 -0
package/dist/chunk-I5M2A3MN.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FieldCopyTestIdButton_default
|
|
3
|
-
} from "./chunk-T3CCNJHK.js";
|
|
4
|
-
import {
|
|
5
|
-
FieldValidationError_default
|
|
6
|
-
} from "./chunk-DBLODROX.js";
|
|
7
|
-
import {
|
|
8
|
-
useFormContext
|
|
9
|
-
} from "./chunk-HWDQZO7X.js";
|
|
10
|
-
|
|
11
|
-
// src/Select/Select.tsx
|
|
12
|
-
import { useState } from "react";
|
|
13
|
-
import { Controller } from "react-hook-form";
|
|
14
|
-
import ReactSelect, { components } from "react-select";
|
|
15
|
-
import { useSelect } from "@nextui-org/select";
|
|
16
|
-
import { cn, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
17
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
-
var selectVariants = tv({
|
|
19
|
-
slots: {
|
|
20
|
-
base: "",
|
|
21
|
-
clearIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800",
|
|
22
|
-
control: "rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 motion-reduce:transition-none",
|
|
23
|
-
control_focused: "border-primary hover:border-primary",
|
|
24
|
-
crossIcon: "",
|
|
25
|
-
downChevron: "",
|
|
26
|
-
dropdownIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black",
|
|
27
|
-
group: "",
|
|
28
|
-
groupHeading: "mb-1 ml-3 mt-2 text-sm text-foreground-500",
|
|
29
|
-
indicatorsContainer: "gap-1 p-1",
|
|
30
|
-
indicatorSeparator: "bg-default-300",
|
|
31
|
-
input: "py-0.5 pl-1",
|
|
32
|
-
label: "!pointer-events-auto relative bottom-2 ml-1 inline",
|
|
33
|
-
loadingIndicator: "",
|
|
34
|
-
loadingMessage: "",
|
|
35
|
-
menu: "mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg",
|
|
36
|
-
menuList: "",
|
|
37
|
-
// ensure menu has same z-index as modal so it is visible when rendered in modal
|
|
38
|
-
// see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)
|
|
39
|
-
menuPortal: "!z-50",
|
|
40
|
-
multiValue: "items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1",
|
|
41
|
-
multiValueContainer: "",
|
|
42
|
-
multiValueLabel: "py-0.5 leading-6",
|
|
43
|
-
multiValueRemove: "rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800",
|
|
44
|
-
noOptionsMessage: "rounded-sm p-2 text-foreground-500",
|
|
45
|
-
option_focused: "bg-default-100 active:bg-default-200",
|
|
46
|
-
option_selected: "bg-default-300",
|
|
47
|
-
option: "rounded px-3 py-2 hover:cursor-pointer",
|
|
48
|
-
placeholder: "py-0.5 pl-1 text-foreground-500",
|
|
49
|
-
selectContainer: "",
|
|
50
|
-
singleValue: "!ml-1 !leading-7",
|
|
51
|
-
valueContainer: "gap-1 p-1"
|
|
52
|
-
},
|
|
53
|
-
variants: {
|
|
54
|
-
invalid: {
|
|
55
|
-
true: {
|
|
56
|
-
control: "border-danger hover:border-danger"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
var InputComponent = (props) => {
|
|
62
|
-
const testId = `${props.selectProps["data-testid"]}_input`;
|
|
63
|
-
return /* @__PURE__ */ jsx(components.Input, { "data-testid": testId, ...props });
|
|
64
|
-
};
|
|
65
|
-
var OptionComponent = (props) => {
|
|
66
|
-
const testId = `${props.selectProps["data-testid"]}_option_${props?.data?.testId ?? props?.data?.value}`;
|
|
67
|
-
return /* @__PURE__ */ jsx("div", { "data-testid": testId, children: /* @__PURE__ */ jsx(components.Option, { ...props }) });
|
|
68
|
-
};
|
|
69
|
-
var DropdownIndicatorComponent = (props) => {
|
|
70
|
-
const testId = props?.selectProps["data-testid"];
|
|
71
|
-
return /* @__PURE__ */ jsx("div", { "data-testid": `${testId}_dropdown`, children: /* @__PURE__ */ jsx(components.DropdownIndicator, { ...props }) });
|
|
72
|
-
};
|
|
73
|
-
var Select = ({
|
|
74
|
-
className = void 0,
|
|
75
|
-
clearable = true,
|
|
76
|
-
disabled = false,
|
|
77
|
-
filterOption = void 0,
|
|
78
|
-
formatOptionLabel = void 0,
|
|
79
|
-
inputValue = void 0,
|
|
80
|
-
label: _label = void 0,
|
|
81
|
-
loading = false,
|
|
82
|
-
multiSelect = false,
|
|
83
|
-
name,
|
|
84
|
-
onInputChange = void 0,
|
|
85
|
-
options,
|
|
86
|
-
placeholder = void 0,
|
|
87
|
-
testId: _testId = void 0
|
|
88
|
-
}) => {
|
|
89
|
-
const { control, getFieldState } = useFormContext();
|
|
90
|
-
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
91
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
92
|
-
const variants = selectVariants({ invalid });
|
|
93
|
-
const classNames = variantsToClassNames(variants, className, "base");
|
|
94
|
-
const {
|
|
95
|
-
getBaseProps,
|
|
96
|
-
getErrorMessageProps,
|
|
97
|
-
getHelperWrapperProps,
|
|
98
|
-
getLabelProps,
|
|
99
|
-
getMainWrapperProps,
|
|
100
|
-
getTriggerProps,
|
|
101
|
-
getValueProps,
|
|
102
|
-
label
|
|
103
|
-
} = useSelect({
|
|
104
|
-
children: [],
|
|
105
|
-
classNames,
|
|
106
|
-
errorMessage: JSON.stringify(error),
|
|
107
|
-
isDisabled: disabled,
|
|
108
|
-
isInvalid: invalid,
|
|
109
|
-
isLoading: loading,
|
|
110
|
-
isRequired: required,
|
|
111
|
-
label: _label,
|
|
112
|
-
labelPlacement: "outside",
|
|
113
|
-
placeholder: " "
|
|
114
|
-
});
|
|
115
|
-
return /* @__PURE__ */ jsx(
|
|
116
|
-
Controller,
|
|
117
|
-
{
|
|
118
|
-
control,
|
|
119
|
-
name,
|
|
120
|
-
render: ({
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
122
|
-
field: { onChange, value, ref, onBlur }
|
|
123
|
-
}) => /* @__PURE__ */ jsx(
|
|
124
|
-
"div",
|
|
125
|
-
{
|
|
126
|
-
...getBaseProps(),
|
|
127
|
-
className: cn(classNames.base, "group mt-2"),
|
|
128
|
-
"data-testid": testId,
|
|
129
|
-
children: /* @__PURE__ */ jsxs("div", { ...getMainWrapperProps(), children: [
|
|
130
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
131
|
-
label && /* @__PURE__ */ jsxs(
|
|
132
|
-
"label",
|
|
133
|
-
{
|
|
134
|
-
htmlFor: `react-select-${name}-input`,
|
|
135
|
-
className: cn(getLabelProps().className, classNames.label),
|
|
136
|
-
children: [
|
|
137
|
-
label,
|
|
138
|
-
/* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
|
|
139
|
-
]
|
|
140
|
-
}
|
|
141
|
-
),
|
|
142
|
-
/* @__PURE__ */ jsx(
|
|
143
|
-
ReactSelect,
|
|
144
|
-
{
|
|
145
|
-
"aria-errormessage": "",
|
|
146
|
-
"aria-labelledby": getTriggerProps()["aria-labelledby"]?.split(" ")[1],
|
|
147
|
-
"aria-invalid": invalid,
|
|
148
|
-
classNames: {
|
|
149
|
-
control: () => cn(classNames.control, {
|
|
150
|
-
[classNames.control_focused]: isFocused && !invalid
|
|
151
|
-
}),
|
|
152
|
-
clearIndicator: () => classNames.clearIndicator,
|
|
153
|
-
dropdownIndicator: () => classNames.dropdownIndicator,
|
|
154
|
-
groupHeading: () => classNames.groupHeading,
|
|
155
|
-
indicatorsContainer: () => classNames.indicatorsContainer,
|
|
156
|
-
indicatorSeparator: () => classNames.indicatorSeparator,
|
|
157
|
-
input: () => classNames.input,
|
|
158
|
-
menu: () => classNames.menu,
|
|
159
|
-
menuList: () => classNames.menuList,
|
|
160
|
-
menuPortal: () => classNames.menuPortal,
|
|
161
|
-
multiValue: () => classNames.multiValue,
|
|
162
|
-
multiValueLabel: () => cn(
|
|
163
|
-
classNames.multiValueLabel,
|
|
164
|
-
`${getValueProps().className}`
|
|
165
|
-
),
|
|
166
|
-
multiValueRemove: () => classNames.multiValueRemove,
|
|
167
|
-
noOptionsMessage: () => classNames.noOptionsMessage,
|
|
168
|
-
option: ({
|
|
169
|
-
isFocused: optionIsFocused,
|
|
170
|
-
isSelected: optionIsSelected
|
|
171
|
-
}) => cn(classNames.option, {
|
|
172
|
-
[classNames.option_focused]: optionIsFocused,
|
|
173
|
-
[classNames.option_selected]: optionIsSelected
|
|
174
|
-
}),
|
|
175
|
-
placeholder: () => classNames.placeholder,
|
|
176
|
-
singleValue: () => cn(classNames.singleValue, `${getValueProps().className}`),
|
|
177
|
-
valueContainer: () => classNames.valueContainer
|
|
178
|
-
},
|
|
179
|
-
components: {
|
|
180
|
-
Input: InputComponent,
|
|
181
|
-
Option: OptionComponent,
|
|
182
|
-
DropdownIndicator: DropdownIndicatorComponent
|
|
183
|
-
},
|
|
184
|
-
"data-testid": `${testId}_select`,
|
|
185
|
-
filterOption,
|
|
186
|
-
formatOptionLabel,
|
|
187
|
-
inputValue,
|
|
188
|
-
instanceId: name,
|
|
189
|
-
isClearable: clearable,
|
|
190
|
-
isDisabled: disabled,
|
|
191
|
-
isLoading: loading,
|
|
192
|
-
isMulti: multiSelect,
|
|
193
|
-
name,
|
|
194
|
-
menuPosition: "fixed",
|
|
195
|
-
menuShouldBlockScroll: true,
|
|
196
|
-
options,
|
|
197
|
-
placeholder,
|
|
198
|
-
onBlur: (_e) => {
|
|
199
|
-
setIsFocused(false);
|
|
200
|
-
return onBlur();
|
|
201
|
-
},
|
|
202
|
-
onChange: (option) => {
|
|
203
|
-
if (multiSelect) {
|
|
204
|
-
const transformedOptions = [];
|
|
205
|
-
option?.forEach((o) => {
|
|
206
|
-
transformedOptions.push(o.value);
|
|
207
|
-
});
|
|
208
|
-
onChange(transformedOptions);
|
|
209
|
-
} else {
|
|
210
|
-
onChange(option && option.value);
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
onFocus: (_e) => {
|
|
214
|
-
setIsFocused(true);
|
|
215
|
-
},
|
|
216
|
-
onInputChange,
|
|
217
|
-
ref,
|
|
218
|
-
value: options.find((option) => option.value === value),
|
|
219
|
-
unstyled: true
|
|
220
|
-
}
|
|
221
|
-
)
|
|
222
|
-
] }),
|
|
223
|
-
error && // eslint-disable-next-line react/jsx-props-no-spreading
|
|
224
|
-
/* @__PURE__ */ jsx("div", { ...getHelperWrapperProps(), children: /* @__PURE__ */ jsx("div", { ...getErrorMessageProps(), children: /* @__PURE__ */ jsx(FieldValidationError_default, { error }) }) })
|
|
225
|
-
] })
|
|
226
|
-
}
|
|
227
|
-
)
|
|
228
|
-
}
|
|
229
|
-
);
|
|
230
|
-
};
|
|
231
|
-
var Select_default = Select;
|
|
232
|
-
|
|
233
|
-
// src/Select/index.ts
|
|
234
|
-
var Select_default2 = Select_default;
|
|
235
|
-
|
|
236
|
-
export {
|
|
237
|
-
Select_default,
|
|
238
|
-
Select_default2
|
|
239
|
-
};
|
|
240
|
-
//# sourceMappingURL=chunk-I5M2A3MN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Select/Select.tsx","../src/Select/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { Props } from 'react-select';\n\nimport { useState } from 'react';\nimport { Controller } from 'react-hook-form';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const selectVariants = tv({\n slots: {\n base: '',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 motion-reduce:transition-none',\n control_focused: 'border-primary hover:border-primary',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\n label: '!pointer-events-auto relative bottom-2 ml-1 inline',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: '!z-50',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-foreground-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n variants: {\n invalid: {\n true: {\n control: 'border-danger hover:border-danger',\n },\n },\n },\n});\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n formatOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_input`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_option_${props?.data?.testId ?? props?.data?.value}`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n formatOptionLabel = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const variants = selectVariants({ invalid });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getMainWrapperProps,\n getTriggerProps,\n getValueProps,\n label,\n } = useSelect({\n children: [],\n classNames,\n errorMessage: JSON.stringify(error),\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n control={control}\n name={name}\n render={({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n field: { onChange, value, ref, onBlur },\n }) => (\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(classNames.base, 'group mt-2')}\n data-testid={testId}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getMainWrapperProps()}>\n <div className=\"relative\">\n {label && (\n <label\n htmlFor={`react-select-${name}-input`}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n aria-invalid={invalid}\n classNames={{\n control: () =>\n cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n }),\n clearIndicator: () => classNames.clearIndicator,\n dropdownIndicator: () => classNames.dropdownIndicator,\n groupHeading: () => classNames.groupHeading,\n indicatorsContainer: () => classNames.indicatorsContainer,\n indicatorSeparator: () => classNames.indicatorSeparator,\n input: () => classNames.input,\n menu: () => classNames.menu,\n menuList: () => classNames.menuList,\n menuPortal: () => classNames.menuPortal,\n multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(\n classNames.multiValueLabel,\n `${getValueProps().className}`,\n ),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n filterOption={filterOption}\n formatOptionLabel={formatOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n options={options}\n placeholder={placeholder}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n const transformedOptions: string[] = [];\n // @ts-expect-error in this case option is an array.\n option?.forEach((o: { value: string }) => {\n transformedOptions.push(o.value);\n });\n onChange(transformedOptions);\n } else {\n // @ts-expect-error in this case option is of type SelectOption and has the property value.\n onChange(option && option.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n onInputChange={onInputChange}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n unstyled\n />\n </div>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;;AAGA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,OAAO,eAAe,kBAAkB;AAExC,SAAS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Q;","names":["Select_default"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-INTLZONV.cjs","../src/Switch/Switch.tsx","../src/Switch/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,gDAA2B;AAE3B,0CAAyB;AACzB,4CAAqC;AAkD7B,+CAAA;AA5BR,IAAM,OAAA,EAAS,CAAC;AAAA,EACd,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,SAAA,EAAW,KAAA;AAAA,EACX,KAAA,EAAO,OAAA,EAAS,KAAA,CAAA;AAAA,EAChB,IAAA;AAAA,EACA,MAAA,EAAQ,QAAA,EAAU,KAAA;AACpB,CAAA,EAAA,GAAmB;AACjB,EAAA,MAAM,EAAE,OAAA,EAAS,cAAc,EAAA,EAAI,8CAAA,CAAe;AAClD,EAAA,MAAM,EAAE,KAAA,EAAO,QAAA,EAAU,MAAA,EAAQ,QAAQ,EAAA,EAAI,aAAA,CAAc,IAAA,EAAM,OAAO,CAAA;AAExE,EAAA,MAAM,EAAE,KAAA,EAAO,aAAA,EAAe,qBAAA,EAAuB,qBAAqB,EAAA,EACxE,6BAAA;AAAS,IACP,YAAA,EAAc,IAAA,CAAK,SAAA,CAAU,KAAK,CAAA;AAAA,IAClC,SAAA,EAAW,OAAA;AAAA,IACX,UAAA,EAAY,QAAA;AAAA,IACZ,KAAA,EAAO,MAAA;AAAA,IACP,cAAA,EAAgB,SAAA;AAAA,IAChB,WAAA,EAAa;AAAA,EACf,CAAC,CAAA;AAEH,EAAA,uBACE,6BAAA;AAAA,IAAC,yBAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,OAAA;AAAA,MACA,QAAA;AAAA,MACA,MAAA,EAAQ,CAAC;AAAA,QACP,KAAA,EAAO,EAAE,QAAA,EAAU,UAAA,EAAY,KAAA,EAAO,GAAA,EAAK,MAAA,EAAQ,SAAS;AAAA,MAC9D,CAAA,EAAA,mBACE,8BAAA,oBAAA,EAAA,EACE,QAAA,EAAA;AAAA,wBAAA,8BAAA;AAAA,UAAC,cAAA;AAAA,UAAA;AAAA,YACC,kBAAA,EAAkB,aAAA,CAAc,CAAA,CAAE,kBAAkB,CAAA;AAAA,YACpD,QAAA;AAAA,YACA,UAAA,EAAY,CAAC,CAAC,KAAA;AAAA,YACd,SAAA;AAAA,YACA,UAAA,EAAY;AAAA,cACV,KAAA,EAAO,CAAA,yCAAA,EAA4C,QAAA,EAAU,cAAA,EAAgB,EAAE,CAAA;AAAA,YAAA;AACjF,YAAA;AACa,YAAA;AACb,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AAEC,cAAA;AAAA,cAAA;AAE2C,8BAAA;AAEL,YAAA;AAAA,UAAA;AAAA,QAAA;AACzC,QAAA;AACC,wBAAA;AAOC,MAAA;AAEJ,IAAA;AAAA,EAAA;AAIR;AAEA;ADnBA;AACA;AEnEA;AFqEA;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-INTLZONV.cjs","sourcesContent":[null,"import { Controller } from 'react-hook-form';\n\nimport { useInput } from '@nextui-org/input';\nimport { Switch as NextSwitch } from '@nextui-org/switch';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface SwitchProps {\n /** CSS class name */\n className?: string;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** component displayed next to the switch. */\n label?: React.ReactNode;\n /** name the field is registered under */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Switch component based on [NextUI Switch](https://nextui.org/docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n disabled = false,\n label: _label = undefined,\n name,\n testId: _testId = undefined,\n}: SwitchProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { label, getInputProps, getHelperWrapperProps, getErrorMessageProps } =\n useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n name={name}\n control={control}\n disabled={disabled}\n render={({\n field: { disabled: isDisabled, value, ref, onBlur, onChange },\n }) => (\n <>\n <NextSwitch\n aria-describedby={getInputProps()['aria-describedby']}\n required={required}\n isSelected={!!value}\n className={className}\n classNames={{\n label: `text-bold block text-ellipsis text-small ${invalid ? 'text-danger' : ''}`,\n }}\n data-testid={testId}\n isDisabled={isDisabled}\n value={value}\n onChange={onChange}\n onBlur={onBlur}\n name={name}\n ref={ref}\n >\n {label}\n {!!required && !!_label && (\n <span className=\"!text-danger\">{' \\u002A'}</span>\n )}\n <FieldCopyTestIdButton testId={testId} />\n </NextSwitch>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </>\n )}\n />\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-QTL5FREE.cjs","../src/partials/FieldValidationError/FieldValidationError.tsx","../src/partials/FieldValidationError/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACsCU,+CAAA;AA9BV,IAAM,qBAAA,EAAuB,CAAC;AAAA,EAC5B,KAAA;AAAA,EACA,OAAA,EAAS,KAAA;AACX,CAAA,EAAA,GAAiC;AAC/B,EAAA,GAAA,CAAI,CAAC,KAAA,EAAO;AACV,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,WAAA,EAA2B,CAAC,CAAA;AAEhC,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,CAAA,CAAE,MAAA,WAAiB,KAAA,CAAA,EAAQ;AAC1D,IAAA,MAAM,aAAA,EAAe,KAAA;AACrB,IAAA,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,CAAE,OAAA,CAAQ,CAAC,GAAA,EAAA,GAAQ;AAClC,MAAA,WAAA,EAAa,CAAC,GAAG,UAAA,EAAY,GAAG,YAAA,CAAa,GAAG,CAAC,CAAA;AAAA,IACnD,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,MAAM,WAAA,EACJ,IAAA,CAAK,SAAA,CAAU,UAAU,EAAA,IAAM,KAAA,EAAO,WAAA,EAAc,KAAA;AACtD,EAAA,MAAM,aAAA,EAAyB,UAAA,CAAW,GAAA,CAAI,CAAC,CAAA,EAAA,GAAM,CAAA,CAAE,OAAO,CAAA;AAC9D,EAAA,MAAM,WAAA,EAAa,CAAA,OAAA,EAAU,YAAA,CAAa,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAGlD,EAAA;AAAC,IAAA;AAAA,IAAA;AAC6C,MAAA;AAChC,MAAA;AAE4B,MAAA;AAAA;AAGpC,wBAAA;AAEH,MAAA;AAAA,IAAA;AACH,EAAA;AAEJ;AAEe;ADbwC;AACA;AE/BxC;AFiCwC;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-QTL5FREE.cjs","sourcesContent":[null,"import type { FieldError } from 'react-hook-form';\n\nimport { slugify } from '../../helpers';\n\nexport interface FieldValidationErrorProps {\n error: FieldError[] | Record<string, FieldError[]>;\n testId?: string;\n}\n\n/**\n * Renders a validation error of a field\n */\nconst FieldValidationError = ({\n error,\n testId = undefined,\n}: FieldValidationErrorProps) => {\n if (!error) {\n return null;\n }\n\n let tmp_errors: FieldError[] = [];\n\n if (typeof error === 'object' && !(error instanceof Array)) {\n const error_object = error as Record<string, FieldError[]>;\n Object.keys(error).forEach((key) => {\n tmp_errors = [...tmp_errors, ...error_object[key]];\n });\n }\n\n const errorArray: FieldError[] =\n JSON.stringify(tmp_errors) !== '[]' ? tmp_errors : (error as FieldError[]);\n const errorStrings: string[] = errorArray.map((e) => e.message) as string[];\n const ariaString = `Error: ${errorStrings.join('\\n')}`;\n\n return (\n <ul\n data-testid={slugify(testId || errorStrings.join())}\n aria-label={ariaString} // TODO: ist das richtig @Hannes?\n >\n {errorStrings.map((errorString: string, i: number) => (\n // eslint-disable-next-line react/no-array-index-key\n <li key={`error_${i}`}>\n <div>{errorString}</div>\n </li>\n ))}\n </ul>\n );\n};\n\nexport default FieldValidationError;\n","import FieldValidationError from './FieldValidationError';\n\nexport type { FieldValidationErrorProps } from './FieldValidationError';\n\nexport { FieldValidationError };\n\nexport default FieldValidationError;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-QVBZ5RLN.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["Select_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACPA,8BAAyB;AACzB,gDAA2B;AAC3B,qGAAwC;AAExC,4CAA0B;AAE1B,oDAA6C;AAsGpC,+CAAA;AAhGF,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,EAAA;AAAA,IACN,cAAA,EACE,wGAAA;AAAA,IACF,OAAA,EACE,mIAAA;AAAA,IACF,eAAA,EAAiB,qCAAA;AAAA,IACjB,SAAA,EAAW,EAAA;AAAA,IACX,WAAA,EAAa,EAAA;AAAA,IACb,iBAAA,EACE,+FAAA;AAAA,IACF,KAAA,EAAO,EAAA;AAAA,IACP,YAAA,EAAc,4CAAA;A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ACA,kBAAA;AACA,kBAAA;AACA,kBAAA;AACE,oBAAA;AACA,oBAAA;AACF,kBAAA;AACA,kBAAA;AACE,oBAAA;AACE,sBAAA;AAEA,sCAAA;AACE,wBAAA;AAA+B,sBAAA;AAEjC,sBAAA;AAA2B,oBAAA;AAG3B,sBAAA;AAA+B,oBAAA;AAEnC,kBAAA;AACA,kBAAA;AACE,oBAAA;AACF,kBAAA;AACA,kBAAA;AACA,kBAAA;AAEA,kBAAA;AACA,kBAAA;AAAQ,gBAAA;AACV,cAAA;AACF,YAAA;AACC,YAAA;AAEC,4BAAA;AAOJ,UAAA;AAAA,QAAA;AACF,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;ADzFW;AACA;AElOXA;AFoOW;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-QVBZ5RLN.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { Props } from 'react-select';\n\nimport { useState } from 'react';\nimport { Controller } from 'react-hook-form';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const selectVariants = tv({\n slots: {\n base: '',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 motion-reduce:transition-none',\n control_focused: 'border-primary hover:border-primary',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\n label: '!pointer-events-auto relative bottom-2 ml-1 inline',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: '!z-50',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-foreground-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n variants: {\n invalid: {\n true: {\n control: 'border-danger hover:border-danger',\n },\n },\n },\n});\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n formatOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_input`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_option_${props?.data?.testId ?? props?.data?.value}`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n formatOptionLabel = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const variants = selectVariants({ invalid });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getMainWrapperProps,\n getTriggerProps,\n getValueProps,\n label,\n } = useSelect({\n children: [],\n classNames,\n errorMessage: JSON.stringify(error),\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n control={control}\n name={name}\n render={({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n field: { onChange, value, ref, onBlur },\n }) => (\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(classNames.base, 'group mt-2')}\n data-testid={testId}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getMainWrapperProps()}>\n <div className=\"relative\">\n {label && (\n <label\n htmlFor={`react-select-${name}-input`}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n aria-invalid={invalid}\n classNames={{\n control: () =>\n cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n }),\n clearIndicator: () => classNames.clearIndicator,\n dropdownIndicator: () => classNames.dropdownIndicator,\n groupHeading: () => classNames.groupHeading,\n indicatorsContainer: () => classNames.indicatorsContainer,\n indicatorSeparator: () => classNames.indicatorSeparator,\n input: () => classNames.input,\n menu: () => classNames.menu,\n menuList: () => classNames.menuList,\n menuPortal: () => classNames.menuPortal,\n multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(\n classNames.multiValueLabel,\n `${getValueProps().className}`,\n ),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n filterOption={filterOption}\n formatOptionLabel={formatOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n options={options}\n placeholder={placeholder}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n const transformedOptions: string[] = [];\n // @ts-expect-error in this case option is an array.\n option?.forEach((o: { value: string }) => {\n transformedOptions.push(o.value);\n });\n onChange(transformedOptions);\n } else {\n // @ts-expect-error in this case option is of type SelectOption and has the property value.\n onChange(option && option.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n onInputChange={onInputChange}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n unstyled\n />\n </div>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-W24WP5YE.cjs","../src/CheckboxGroup/CheckboxGroup.tsx","../src/CheckboxGroup/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;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A,kBAAA;AACsC,kCAAA;AAAA,gBAAA;AAAA,cAAA;AACzC,YAAA;AAKA,YAAA;AAC8C,cAAA;AACY,cAAA;AAE1D,YAAA;AACE,cAAA;AACA,cAAA;AACF,YAAA;AACJ,YAAA;AACA,YAAA;AAE0B,YAAA;AAEtB,cAAA;AAAC,gBAAA;AAAA,gBAAA;AAEgC,kBAAA;AAChB,kBAAA;AACF,kBAAA;AACwC,oBAAA;AACrD,kBAAA;AAES,kBAAA;AAAA,gBAAA;AAPiB,gBAAA;AAQ5B,cAAA;AAEH,YAAA;AAAA,UAAA;AACH,QAAA;AAEJ,MAAA;AAAA,IAAA;AACF,EAAA;AAEJ;AAEe;ADxBkG;AACA;AElFlG;AFoFkG;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-W24WP5YE.cjs","sourcesContent":[null,"import { Controller } from 'react-hook-form';\n\nimport {\n Checkbox,\n CheckboxGroup as NextCheckboxGroup,\n} from '@nextui-org/checkbox';\n\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport type CheckboxGroupOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n /** disables the option */\n disabled?: boolean;\n /** HTML data-testid attribute of the option */\n testId?: string;\n};\n\nexport interface CheckboxGroupProps {\n /** CSS class name. ClassName: string | { buttons?: string | { base?: string; active?: string }; base?: string;} */\n className?: string;\n /** label displayed above the Checkboxes */\n label?: React.ReactNode;\n /** Name the Field is registered on the form. */\n name: string;\n /** Checkboxes that should be displayed. */\n options: CheckboxGroupOption[];\n /** sets all buttons disabled */\n disabled?: boolean;\n /** id for internal testing. */\n testId?: string;\n}\n\n/**\n * CheckboxGroup component based on [NextUI CheckboxGroup](https://nextui.org/docs/components/checkbox-group)\n */\nconst CheckboxGroup = ({\n className = undefined,\n label = undefined,\n options,\n disabled = false,\n name,\n testId: _testId = undefined,\n}: CheckboxGroupProps) => {\n const { getFieldState, control } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n return (\n <Controller\n control={control}\n name={name}\n disabled={disabled}\n render={({ field: { onChange, value, ref, onBlur } }) => {\n return (\n <NextCheckboxGroup\n className={className}\n data-testid={testId}\n errorMessage={error && <FieldValidationError error={error} />}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n label && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n className={`text-bold text-ellipsis text-small ${invalid ? 'text-danger' : 'text-foreground-500'}`}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )\n }\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...(options.length === 1\n ? {\n value: [value].filter((v) => v !== undefined),\n onChange: (newValue) => onChange(newValue && newValue[0]),\n }\n : {\n onChange,\n value,\n })}\n onBlur={onBlur}\n ref={ref}\n >\n {options?.map((option) => {\n return (\n <Checkbox\n key={`index_${option.value}`}\n isDisabled={disabled || option.disabled}\n value={option?.value}\n data-testid={slugify(\n `${testId}_option_${option?.testId || option?.value}`,\n )}\n >\n {option?.label}\n </Checkbox>\n );\n })}\n </NextCheckboxGroup>\n );\n }}\n />\n );\n};\n\nexport default CheckboxGroup;\n","import CheckboxGroup from './CheckboxGroup';\n\nexport type { CheckboxGroupProps, CheckboxGroupOption } from './CheckboxGroup';\n\nexport { CheckboxGroup };\n\nexport default CheckboxGroup;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-YUAJN6HW.cjs","../src/RadioGroup/RadioGroup.tsx","../src/RadioGroup/Variants/RadioBox.tsx","../src/RadioGroup/Variants/RadioButton.tsx","../src/RadioGroup/index.ts"],"names":["jsx","cn"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AA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;AAV1B,YAAA;AAahB,YAAA;AAAA,UAAA;AAEA,YAAA;AACE,cAAA;AAAC,cAAA;AAAA,gBAAA;AAEc,kBAAA;AACsC,gBAAA;AACnD,gBAAA;AACiC,gBAAA;AACnB,gBAAA;AACd,gBAAA;AAEW,kBAAA;AACmD,gBAAA;AAC9D,gBAAA;AAEsC,cAAA;AAAA,cAAA;AAZ1B,YAAA;AAehB,YAAA;AAAA,UAAA;AAEA,YAAA;AACE,cAAA;AAAC,cAAA;AAAA,gBAAA;AAEc,kBAAA;AACsC,gBAAA;AACnD,gBAAA;AACiC,gBAAA;AACnB,gBAAA;AACd,gBAAA;AAEsC,cAAA;AAAA,cAAA;AAR1B,YAAA;AAUf,QAAA;AAGL,QAAA;AACE,UAAA;AAAC,UAAA;AAAA,YAAA;AACC,YAAA;AACa,YAAA;AAC8C,YAAA;AAC3D,YAAA;AACW,YAAA;AACC,YAAA;AAEV,4BAAA;AAGK,cAAA;AAAA,8BAAA;AACsC,YAAA;AACzC,YAAA;AAGiC,YAAA;AACrC,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AAEa;AAAA,8BAAA;AAEuB,YAAA;AAElC,UAAA;AAAA,QAAA;AAEJ,MAAA;AAEJ,IAAA;AAAA,EAAA;AAGN;AAEA;ADiCA;AACA;AI/LA;AJiMA;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-YUAJN6HW.cjs","sourcesContent":[null,"import type { ReactElement, ReactNode } from 'react';\n\nimport { Controller } from 'react-hook-form';\n\nimport { ButtonGroup as NextButtonGroup } from '@nextui-org/button';\nimport { RadioGroup as NextRadioGroup, Radio } from '@nextui-org/radio';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\nimport { RadioBox } from './Variants/RadioBox';\nimport { RadioButton } from './Variants/RadioButton';\n\nexport interface RadioGroupOption {\n /** Description of the value. Works with variant radioBox. */\n description?: React.ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioGroupProps {\n /** CSS class name */\n className?: string;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioGroupOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n /** How the RadioGroup should look like. */\n variant?: 'default' | 'radioBox' | 'radioButton';\n}\n\n/**\n * RadioGroup component based on [NextUI RadioGroup](https://nextui.org/docs/components/radio-group)\n */\nconst RadioGroup = ({\n className = undefined,\n disabled = false,\n inline = false,\n label = undefined,\n name,\n options,\n testId: _testId = undefined,\n variant = 'default',\n}: RadioGroupProps): ReactElement => {\n const { control, getFieldState, getValues } = useFormContext();\n\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={name}\n render={({ field: { onChange, disabled: isDisabled, onBlur, ref } }) => {\n let RadioComponents: ReactNode;\n switch (variant) {\n case 'radioBox':\n RadioComponents = options.map((option) => (\n <RadioBox\n key={option.value}\n data-testid={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n isDisabled={isDisabled || option.disabled}\n value={option.value}\n onChange={onChange}\n description={option.description}\n icon={option.icon}\n >\n {option.label ? option.label : option.value}\n </RadioBox>\n ));\n break;\n case 'radioButton':\n RadioComponents = options.map((option) => (\n <RadioButton\n key={option.value}\n data-testid={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n isDisabled={isDisabled || option.disabled}\n value={option.value}\n onChange={onChange}\n // TODO: how to do the classNames properly (make selected option darker with same color)\n className={cn(\n `${getValues()[name] !== option.value ? 'bg-opacity-50' : ''}`,\n )}\n >\n {option.label ? option.label : option.value}\n </RadioButton>\n ));\n break;\n default:\n RadioComponents = options.map((option) => (\n <Radio\n key={option.value}\n data-testid={slugify(\n `${testId}_option_${option.testId || option.value}`,\n )}\n isDisabled={isDisabled || option.disabled}\n value={option.value}\n onChange={onChange}\n >\n {option.label ? option.label : option.value}\n </Radio>\n ));\n }\n\n return (\n <NextRadioGroup\n className={className}\n data-testid={testId}\n errorMessage={error && <FieldValidationError error={error} />}\n isDisabled={isDisabled}\n isInvalid={invalid}\n isRequired={required}\n label={\n label && (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label className={`${invalid ? 'text-danger' : ''}`}>\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )\n }\n orientation={inline ? 'horizontal' : 'vertical'}\n onBlur={onBlur}\n onChange={onChange}\n name={name}\n ref={ref}\n >\n {variant === 'radioButton' ? (\n // TODO: NextButtonGroup uses ref to modify Button style, but we wrap it, so it does not work at the moment.\n <NextButtonGroup>{RadioComponents}</NextButtonGroup>\n ) : (\n RadioComponents\n )}\n </NextRadioGroup>\n );\n }}\n />\n );\n};\n\nexport default RadioGroup;\n","import type { RadioProps as NextRadioProps } from '@nextui-org/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@nextui-org/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\ninterface RadioProps extends NextRadioProps {\n /** icon for the option */\n icon?: ReactNode;\n}\n\nexport const RadioBox = ({ icon = undefined, ...props }: RadioProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props);\n\n return (\n <Component\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(\n 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-primary',\n {\n // disabled styles\n 'pointer-events-none opacity-disabled': isDisabled,\n },\n )}\n >\n <VisuallyHidden>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <input {...getInputProps()} />\n </VisuallyHidden>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <span {...getWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <span {...getControlProps()} />\n </span>\n {icon}\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getLabelWrapperProps()}\n className={cn(getLabelWrapperProps().className, 'grow')}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n {children && <span {...getLabelProps()}>{children}</span>}\n {description && (\n <span className=\"text-small text-foreground opacity-70\">\n {description}\n </span>\n )}\n </div>\n </Component>\n );\n};\n\nexport default RadioBox;\n","import { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\n\ninterface RadioButtonProps {\n /** label of the value. */\n children: React.ReactNode;\n /** CSS class name */\n className?: string;\n /** disables the option */\n isDisabled?: boolean;\n /** Callback function. Executed if the option is clicked. */\n onChange: (...event: unknown[]) => void;\n /** value of the option. */\n value: string;\n}\n\nexport const RadioButton = ({\n className = undefined,\n value,\n isDisabled = false,\n onChange,\n children,\n}: RadioButtonProps) => {\n return (\n <Button\n key={`index_${value}`}\n className={cn(className)}\n disabled={isDisabled}\n onClick={() => {\n return onChange(value);\n }}\n >\n {children}\n </Button>\n );\n};\n\nexport default RadioButton;\n","import RadioGroup from './RadioGroup';\n\nexport type { RadioGroupProps } from './RadioGroup';\n\nexport { RadioGroup };\n\nexport default RadioGroup;\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|