@fuf-stack/uniform 0.9.4 → 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.
Files changed (92) hide show
  1. package/dist/CheckboxGroup/index.cjs +3 -3
  2. package/dist/CheckboxGroup/index.d.cts +5 -2
  3. package/dist/CheckboxGroup/index.d.ts +5 -2
  4. package/dist/CheckboxGroup/index.js +2 -2
  5. package/dist/CheckboxGroup-o-qWkWe1.d.cts +130 -0
  6. package/dist/CheckboxGroup-o-qWkWe1.d.ts +130 -0
  7. package/dist/FieldArray/index.cjs +3 -3
  8. package/dist/FieldArray/index.js +2 -2
  9. package/dist/{FieldValidationError-BSXedjCA.d.cts → FieldValidationError-DAT12Ess.d.cts} +2 -1
  10. package/dist/{FieldValidationError-BSXedjCA.d.ts → FieldValidationError-DAT12Ess.d.ts} +2 -1
  11. package/dist/Input/index.cjs +3 -3
  12. package/dist/Input/index.js +2 -2
  13. package/dist/RadioGroup/index.cjs +3 -3
  14. package/dist/RadioGroup/index.d.cts +5 -2
  15. package/dist/RadioGroup/index.d.ts +5 -2
  16. package/dist/RadioGroup/index.js +2 -2
  17. package/dist/RadioGroup-D_kiBt0M.d.cts +162 -0
  18. package/dist/RadioGroup-D_kiBt0M.d.ts +162 -0
  19. package/dist/Select/index.cjs +3 -3
  20. package/dist/Select/index.d.cts +3 -3
  21. package/dist/Select/index.d.ts +3 -3
  22. package/dist/Select/index.js +2 -2
  23. package/dist/Select-BhS4z0Pj.d.cts +317 -0
  24. package/dist/Select-BhS4z0Pj.d.ts +317 -0
  25. package/dist/Switch/index.cjs +3 -3
  26. package/dist/Switch/index.d.cts +5 -2
  27. package/dist/Switch/index.d.ts +5 -2
  28. package/dist/Switch/index.js +2 -2
  29. package/dist/Switch-Fdldj8LV.d.cts +126 -0
  30. package/dist/Switch-Fdldj8LV.d.ts +126 -0
  31. package/dist/TextArea/index.cjs +3 -3
  32. package/dist/TextArea/index.js +2 -2
  33. package/dist/{chunk-OCR2UWG2.cjs → chunk-4RTJ5XR2.cjs} +3 -3
  34. package/dist/{chunk-OCR2UWG2.cjs.map → chunk-4RTJ5XR2.cjs.map} +1 -1
  35. package/dist/{chunk-YUAJN6HW.cjs → chunk-6HMMXOSV.cjs} +48 -15
  36. package/dist/chunk-6HMMXOSV.cjs.map +1 -0
  37. package/dist/{chunk-FMQNL3RT.js → chunk-F7GG67YU.js} +2 -2
  38. package/dist/{chunk-W24WP5YE.cjs → chunk-HFMFDBEV.cjs} +46 -14
  39. package/dist/chunk-HFMFDBEV.cjs.map +1 -0
  40. package/dist/{chunk-NHPQEYYN.js → chunk-HOCRJOEU.js} +2 -2
  41. package/dist/{chunk-TNELIBCV.cjs → chunk-JDRMKZ35.cjs} +4 -4
  42. package/dist/{chunk-TNELIBCV.cjs.map → chunk-JDRMKZ35.cjs.map} +1 -1
  43. package/dist/{chunk-4AHVJWTB.js → chunk-JG5VQZ4V.js} +46 -14
  44. package/dist/chunk-JG5VQZ4V.js.map +1 -0
  45. package/dist/{chunk-5UHHZ7KY.cjs → chunk-JRFKYVXY.cjs} +3 -3
  46. package/dist/{chunk-5UHHZ7KY.cjs.map → chunk-JRFKYVXY.cjs.map} +1 -1
  47. package/dist/chunk-LDW7K7LW.js +231 -0
  48. package/dist/chunk-LDW7K7LW.js.map +1 -0
  49. package/dist/{chunk-3XNW2VQ7.cjs → chunk-NQ4JZ7AK.cjs} +38 -16
  50. package/dist/chunk-NQ4JZ7AK.cjs.map +1 -0
  51. package/dist/{chunk-UHFAY5XK.cjs → chunk-NXTXKBTP.cjs} +105 -114
  52. package/dist/chunk-NXTXKBTP.cjs.map +1 -0
  53. package/dist/{chunk-QTL5FREE.cjs → chunk-OHJYXA6R.cjs} +7 -5
  54. package/dist/chunk-OHJYXA6R.cjs.map +1 -0
  55. package/dist/{chunk-ZOVKQ7MN.js → chunk-PFX4YRWI.js} +39 -17
  56. package/dist/chunk-PFX4YRWI.js.map +1 -0
  57. package/dist/{chunk-DTSX7YON.js → chunk-SCTH3FAO.js} +2 -2
  58. package/dist/{chunk-DBLODROX.js → chunk-WKM2D7LF.js} +7 -5
  59. package/dist/chunk-WKM2D7LF.js.map +1 -0
  60. package/dist/{chunk-ARUVDZFG.js → chunk-YSZW33OV.js} +48 -15
  61. package/dist/chunk-YSZW33OV.js.map +1 -0
  62. package/dist/index.cjs +12 -12
  63. package/dist/index.d.cts +8 -8
  64. package/dist/index.d.ts +8 -8
  65. package/dist/index.js +14 -14
  66. package/dist/partials/FieldValidationError/index.cjs +2 -2
  67. package/dist/partials/FieldValidationError/index.d.cts +2 -2
  68. package/dist/partials/FieldValidationError/index.d.ts +2 -2
  69. package/dist/partials/FieldValidationError/index.js +1 -1
  70. package/package.json +3 -3
  71. package/dist/CheckboxGroup-BYsQ0A0q.d.cts +0 -32
  72. package/dist/CheckboxGroup-BYsQ0A0q.d.ts +0 -32
  73. package/dist/RadioGroup-BU4K9cnS.d.cts +0 -40
  74. package/dist/RadioGroup-BU4K9cnS.d.ts +0 -40
  75. package/dist/Select-C08Oftdr.d.cts +0 -184
  76. package/dist/Select-C08Oftdr.d.ts +0 -184
  77. package/dist/Switch-DmjDKgKs.d.cts +0 -20
  78. package/dist/Switch-DmjDKgKs.d.ts +0 -20
  79. package/dist/chunk-3XNW2VQ7.cjs.map +0 -1
  80. package/dist/chunk-4AHVJWTB.js.map +0 -1
  81. package/dist/chunk-ARUVDZFG.js.map +0 -1
  82. package/dist/chunk-DBLODROX.js.map +0 -1
  83. package/dist/chunk-OCXF3U6L.js +0 -240
  84. package/dist/chunk-OCXF3U6L.js.map +0 -1
  85. package/dist/chunk-QTL5FREE.cjs.map +0 -1
  86. package/dist/chunk-UHFAY5XK.cjs.map +0 -1
  87. package/dist/chunk-W24WP5YE.cjs.map +0 -1
  88. package/dist/chunk-YUAJN6HW.cjs.map +0 -1
  89. package/dist/chunk-ZOVKQ7MN.js.map +0 -1
  90. /package/dist/{chunk-FMQNL3RT.js.map → chunk-F7GG67YU.js.map} +0 -0
  91. /package/dist/{chunk-NHPQEYYN.js.map → chunk-HOCRJOEU.js.map} +0 -0
  92. /package/dist/{chunk-DTSX7YON.js.map → chunk-SCTH3FAO.js.map} +0 -0
@@ -3,7 +3,7 @@
3
3
  var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
4
4
 
5
5
 
6
- var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
6
+ var _chunkOHJYXA6Rcjs = require('./chunk-OHJYXA6R.cjs');
7
7
 
8
8
 
9
9
  var _chunkLDCRR7FPcjs = require('./chunk-LDCRR7FP.cjs');
@@ -17,9 +17,9 @@ var _pixelutils = require('@fuf-stack/pixel-utils');
17
17
  var _jsxruntime = require('react/jsx-runtime');
18
18
  var selectVariants = _pixelutils.tv.call(void 0, {
19
19
  slots: {
20
- base: "",
20
+ base: "group",
21
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",
22
+ control: "rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none",
23
23
  control_focused: "border-primary hover:border-primary",
24
24
  crossIcon: "",
25
25
  downChevron: "",
@@ -29,10 +29,11 @@ var selectVariants = _pixelutils.tv.call(void 0, {
29
29
  indicatorsContainer: "gap-1 p-1",
30
30
  indicatorSeparator: "bg-default-300",
31
31
  input: "py-0.5 pl-1",
32
- label: "!pointer-events-auto relative bottom-2 ml-1 inline",
32
+ // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts
33
+ label: 'pointer-events-auto relative bottom-1.5 ml-1 text-small subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-["*"]',
33
34
  loadingIndicator: "",
34
35
  loadingMessage: "",
35
- menu: "mt-2 rounded-xl border border-default-200 bg-background p-1 shadow-lg",
36
+ menu: "mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg",
36
37
  menuList: "",
37
38
  // ensure menu has same z-index as modal so it is visible when rendered in modal
38
39
  // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)
@@ -49,13 +50,6 @@ var selectVariants = _pixelutils.tv.call(void 0, {
49
50
  selectContainer: "",
50
51
  singleValue: "!ml-1 !leading-7",
51
52
  valueContainer: "gap-1 p-1"
52
- },
53
- variants: {
54
- invalid: {
55
- true: {
56
- control: "border-danger hover:border-danger"
57
- }
58
- }
59
53
  }
60
54
  });
61
55
  var InputComponent = (props) => {
@@ -75,7 +69,7 @@ var Select = ({
75
69
  clearable = true,
76
70
  disabled = false,
77
71
  filterOption = void 0,
78
- formatOptionLabel = void 0,
72
+ renderOptionLabel = void 0,
79
73
  inputValue = void 0,
80
74
  label: _label = void 0,
81
75
  loading = false,
@@ -89,14 +83,13 @@ var Select = ({
89
83
  const { control, getFieldState } = _chunkLDCRR7FPcjs.useFormContext.call(void 0, );
90
84
  const { error, invalid, required, testId } = getFieldState(name, _testId);
91
85
  const [isFocused, setIsFocused] = _react.useState.call(void 0, false);
92
- const variants = selectVariants({ invalid });
86
+ const variants = selectVariants();
93
87
  const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
94
88
  const {
95
89
  getBaseProps,
96
90
  getErrorMessageProps,
97
91
  getHelperWrapperProps,
98
92
  getLabelProps,
99
- getMainWrapperProps,
100
93
  getTriggerProps,
101
94
  getValueProps,
102
95
  label
@@ -120,109 +113,107 @@ var Select = ({
120
113
  render: ({
121
114
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
122
115
  field: { onChange, value, ref, onBlur }
123
- }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
116
+ }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
124
117
  "div",
125
118
  {
126
119
  ...getBaseProps(),
127
- className: _pixelutils.cn.call(void 0, classNames.base, "group mt-2"),
120
+ className: _pixelutils.cn.call(void 0, classNames.base),
128
121
  "data-testid": testId,
129
- children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...getMainWrapperProps(), children: [
130
- /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative", children: [
131
- label && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
132
- "label",
133
- {
134
- htmlFor: `react-select-${name}-input`,
135
- className: _pixelutils.cn.call(void 0, getLabelProps().className, classNames.label),
136
- children: [
137
- label,
138
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkKMMS4G7Acjs.FieldCopyTestIdButton_default, { testId })
139
- ]
140
- }
141
- ),
142
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
143
- _reactselect2.default,
144
- {
145
- "aria-errormessage": "",
146
- "aria-labelledby": _optionalChain([getTriggerProps, 'call', _7 => _7(), 'access', _8 => _8["aria-labelledby"], 'optionalAccess', _9 => _9.split, 'call', _10 => _10(" "), 'access', _11 => _11[1]]),
147
- "aria-invalid": invalid,
148
- classNames: {
149
- control: () => _pixelutils.cn.call(void 0, 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: () => _pixelutils.cn.call(void 0,
163
- classNames.multiValueLabel,
164
- `${getValueProps().className}`
165
- ),
166
- multiValueRemove: () => classNames.multiValueRemove,
167
- noOptionsMessage: () => classNames.noOptionsMessage,
168
- option: ({
169
- isFocused: optionIsFocused,
170
- isSelected: optionIsSelected
171
- }) => _pixelutils.cn.call(void 0, classNames.option, {
172
- [classNames.option_focused]: optionIsFocused,
173
- [classNames.option_selected]: optionIsSelected
174
- }),
175
- placeholder: () => classNames.placeholder,
176
- singleValue: () => _pixelutils.cn.call(void 0, 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
- _optionalChain([option, 'optionalAccess', _12 => _12.forEach, 'call', _13 => _13((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
- ] }),
122
+ "data-required": required,
123
+ children: [
124
+ label && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
125
+ "label",
126
+ {
127
+ className: classNames.label,
128
+ "data-slot": "label",
129
+ htmlFor: `react-select-${name}-input`,
130
+ id: getLabelProps().id,
131
+ children: [
132
+ label,
133
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkKMMS4G7Acjs.FieldCopyTestIdButton_default, { testId })
134
+ ]
135
+ }
136
+ ),
137
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
138
+ _reactselect2.default,
139
+ {
140
+ "aria-errormessage": "",
141
+ "aria-labelledby": _optionalChain([getTriggerProps, 'call', _7 => _7(), 'access', _8 => _8["aria-labelledby"], 'optionalAccess', _9 => _9.split, 'call', _10 => _10(" "), 'access', _11 => _11[1]]),
142
+ "aria-invalid": invalid,
143
+ classNames: {
144
+ control: () => _pixelutils.cn.call(void 0, classNames.control, {
145
+ [classNames.control_focused]: isFocused && !invalid
146
+ }),
147
+ clearIndicator: () => classNames.clearIndicator,
148
+ dropdownIndicator: () => classNames.dropdownIndicator,
149
+ groupHeading: () => classNames.groupHeading,
150
+ indicatorsContainer: () => classNames.indicatorsContainer,
151
+ indicatorSeparator: () => classNames.indicatorSeparator,
152
+ input: () => classNames.input,
153
+ menu: () => classNames.menu,
154
+ menuList: () => classNames.menuList,
155
+ menuPortal: () => classNames.menuPortal,
156
+ multiValue: () => classNames.multiValue,
157
+ multiValueLabel: () => _pixelutils.cn.call(void 0, classNames.multiValueLabel, `${getValueProps().className}`),
158
+ multiValueRemove: () => classNames.multiValueRemove,
159
+ noOptionsMessage: () => classNames.noOptionsMessage,
160
+ option: ({
161
+ isFocused: optionIsFocused,
162
+ isSelected: optionIsSelected
163
+ }) => _pixelutils.cn.call(void 0, classNames.option, {
164
+ [classNames.option_focused]: optionIsFocused,
165
+ [classNames.option_selected]: optionIsSelected
166
+ }),
167
+ placeholder: () => classNames.placeholder,
168
+ singleValue: () => _pixelutils.cn.call(void 0, classNames.singleValue, `${getValueProps().className}`),
169
+ valueContainer: () => classNames.valueContainer
170
+ },
171
+ components: {
172
+ Input: InputComponent,
173
+ Option: OptionComponent,
174
+ DropdownIndicator: DropdownIndicatorComponent
175
+ },
176
+ "data-testid": `${testId}_select`,
177
+ filterOption,
178
+ formatOptionLabel: renderOptionLabel,
179
+ inputValue,
180
+ instanceId: name,
181
+ isClearable: clearable,
182
+ isDisabled: disabled,
183
+ isLoading: loading,
184
+ isMulti: multiSelect,
185
+ name,
186
+ menuPosition: "fixed",
187
+ menuShouldBlockScroll: true,
188
+ options,
189
+ placeholder,
190
+ onBlur: (_e) => {
191
+ setIsFocused(false);
192
+ return onBlur();
193
+ },
194
+ onChange: (option) => {
195
+ if (multiSelect) {
196
+ const transformedOptions = [];
197
+ _optionalChain([option, 'optionalAccess', _12 => _12.forEach, 'call', _13 => _13((o) => {
198
+ transformedOptions.push(o.value);
199
+ })]);
200
+ onChange(transformedOptions);
201
+ } else {
202
+ onChange(option && option.value);
203
+ }
204
+ },
205
+ onFocus: (_e) => {
206
+ setIsFocused(true);
207
+ },
208
+ onInputChange,
209
+ ref,
210
+ value: options.find((option) => option.value === value),
211
+ unstyled: true
212
+ }
213
+ ),
223
214
  error && // eslint-disable-next-line react/jsx-props-no-spreading
224
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getHelperWrapperProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getErrorMessageProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkQTL5FREEcjs.FieldValidationError_default, { error }) }) })
225
- ] })
215
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getHelperWrapperProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ...getErrorMessageProps(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkOHJYXA6Rcjs.FieldValidationError_default, { error }) }) })
216
+ ]
226
217
  }
227
218
  )
228
219
  }
@@ -237,4 +228,4 @@ var Select_default2 = Select_default;
237
228
 
238
229
 
239
230
  exports.Select_default = Select_default; exports.Select_default2 = Select_default2;
240
- //# sourceMappingURL=chunk-UHFAY5XK.cjs.map
231
+ //# sourceMappingURL=chunk-NXTXKBTP.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-NXTXKBTP.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["Select_default"],"mappings":"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","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-NXTXKBTP.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: 'group',\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 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger 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 // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'pointer-events-auto relative bottom-1.5 ml-1 text-small subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\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});\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 renderOptionLabel?: 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 renderOptionLabel = 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();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\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)}\n data-testid={testId}\n // See NextUI styles for group-data condition (data-invalid), e.g.: https://github.com/nextui-org/nextui/blob/main/packages/components/select/src/use-select.ts\n data-required={required}\n >\n {label && (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\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(classNames.multiValueLabel, `${getValueProps().className}`),\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={renderOptionLabel}\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 {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 )}\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"]}
@@ -5,20 +5,21 @@ var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
5
5
  // src/partials/FieldValidationError/FieldValidationError.tsx
6
6
  var _jsxruntime = require('react/jsx-runtime');
7
7
  var FieldValidationError = ({
8
+ className = void 0,
8
9
  error,
9
10
  testId = void 0
10
11
  }) => {
11
12
  if (!error) {
12
13
  return null;
13
14
  }
14
- let tmp_errors = [];
15
+ let tmpErrors = [];
15
16
  if (typeof error === "object" && !(error instanceof Array)) {
16
- const error_object = error;
17
+ const errorObject = error;
17
18
  Object.keys(error).forEach((key) => {
18
- tmp_errors = [...tmp_errors, ...error_object[key]];
19
+ tmpErrors = [...tmpErrors, ...errorObject[key]];
19
20
  });
20
21
  }
21
- const errorArray = JSON.stringify(tmp_errors) !== "[]" ? tmp_errors : error;
22
+ const errorArray = JSON.stringify(tmpErrors) !== "[]" ? tmpErrors : error;
22
23
  const errorStrings = errorArray.map((e) => e.message);
23
24
  const ariaString = `Error: ${errorStrings.join("\n")}`;
24
25
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -26,6 +27,7 @@ var FieldValidationError = ({
26
27
  {
27
28
  "data-testid": _chunkBBB4FEY6cjs.slugify.call(void 0, testId || errorStrings.join()),
28
29
  "aria-label": ariaString,
30
+ className,
29
31
  children: errorStrings.map((errorString, i) => (
30
32
  // eslint-disable-next-line react/no-array-index-key
31
33
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: errorString }) }, `error_${i}`)
@@ -42,4 +44,4 @@ var FieldValidationError_default2 = FieldValidationError_default;
42
44
 
43
45
 
44
46
  exports.FieldValidationError_default = FieldValidationError_default; exports.FieldValidationError_default2 = FieldValidationError_default2;
45
- //# sourceMappingURL=chunk-QTL5FREE.cjs.map
47
+ //# sourceMappingURL=chunk-OHJYXA6R.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-OHJYXA6R.cjs","../src/partials/FieldValidationError/FieldValidationError.tsx","../src/partials/FieldValidationError/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACyCU,+CAAA;AAhCV,IAAM,qBAAA,EAAuB,CAAC;AAAA,EAC5B,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,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,UAAA,EAA0B,CAAC,CAAA;AAE/B,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,SAAA,GAAY,CAAA,CAAE,MAAA,WAAiB,KAAA,CAAA,EAAQ;AAC1D,IAAA,MAAM,YAAA,EAAc,KAAA;AACpB,IAAA,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,CAAE,OAAA,CAAQ,CAAC,GAAA,EAAA,GAAQ;AAClC,MAAA,UAAA,EAAY,CAAC,GAAG,SAAA,EAAW,GAAG,WAAA,CAAY,GAAG,CAAC,CAAA;AAAA,IAChD,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,MAAM,WAAA,EACJ,IAAA,CAAK,SAAA,CAAU,SAAS,EAAA,IAAM,KAAA,EAAO,UAAA,EAAa,KAAA;AACpD,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;AACZ,MAAA;AAEwC,MAAA;AAAA;AAGpC,wBAAA;AAEH,MAAA;AAAA,IAAA;AACH,EAAA;AAEJ;AAEe;ADdwC;AACA;AEjCxC;AFmCwC;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-OHJYXA6R.cjs","sourcesContent":[null,"import type { FieldError } from 'react-hook-form';\n\nimport { slugify } from '../../helpers';\n\nexport interface FieldValidationErrorProps {\n className?: string;\n error: FieldError[] | Record<string, FieldError[]>;\n testId?: string;\n}\n\n/**\n * Renders a validation error of a field\n */\nconst FieldValidationError = ({\n className = undefined,\n error,\n testId = undefined,\n}: FieldValidationErrorProps) => {\n if (!error) {\n return null;\n }\n\n let tmpErrors: FieldError[] = [];\n\n if (typeof error === 'object' && !(error instanceof Array)) {\n const errorObject = error as Record<string, FieldError[]>;\n Object.keys(error).forEach((key) => {\n tmpErrors = [...tmpErrors, ...errorObject[key]];\n });\n }\n\n const errorArray: FieldError[] =\n JSON.stringify(tmpErrors) !== '[]' ? tmpErrors : (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 className={className}\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"]}
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-T3CCNJHK.js";
4
4
  import {
5
5
  FieldValidationError_default
6
- } from "./chunk-DBLODROX.js";
6
+ } from "./chunk-WKM2D7LF.js";
7
7
  import {
8
8
  useFormContext
9
9
  } from "./chunk-HWDQZO7X.js";
@@ -12,9 +12,24 @@ import {
12
12
  import { Controller } from "react-hook-form";
13
13
  import { useInput } from "@nextui-org/input";
14
14
  import { Switch as NextSwitch } from "@nextui-org/switch";
15
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
+ import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ var switchVariants = tv({
18
+ slots: {
19
+ base: "",
20
+ endContent: "",
21
+ errorMessage: "ml-1 mt-1",
22
+ // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts
23
+ label: 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-["*"]',
24
+ outerWrapper: "place-content-center",
25
+ startContent: "",
26
+ thumb: "",
27
+ thumbIcon: "",
28
+ wrapper: ""
29
+ }
30
+ });
16
31
  var Switch = ({
17
- className,
32
+ className = void 0,
18
33
  disabled = false,
19
34
  label: _label = void 0,
20
35
  name,
@@ -30,6 +45,10 @@ var Switch = ({
30
45
  labelPlacement: "outside",
31
46
  placeholder: " "
32
47
  });
48
+ const variants = switchVariants();
49
+ const classNames = variantsToClassNames(variants, className, "outerWrapper");
50
+ console.log("getHelperWrapperProps()", getHelperWrapperProps());
51
+ console.log("getErrorMessageProps()", getErrorMessageProps());
33
52
  return /* @__PURE__ */ jsx(
34
53
  Controller,
35
54
  {
@@ -38,33 +57,36 @@ var Switch = ({
38
57
  disabled,
39
58
  render: ({
40
59
  field: { disabled: isDisabled, value, ref, onBlur, onChange }
41
- }) => /* @__PURE__ */ jsxs(Fragment, { children: [
60
+ }) => /* @__PURE__ */ jsxs("div", { className: classNames.outerWrapper, children: [
42
61
  /* @__PURE__ */ jsxs(
43
62
  NextSwitch,
44
63
  {
45
64
  "aria-describedby": getInputProps()["aria-describedby"],
46
- required,
47
- isSelected: !!value,
48
- className,
49
- classNames: {
50
- label: `text-bold block text-ellipsis text-small ${invalid ? "text-danger" : ""}`
51
- },
65
+ classNames,
66
+ "data-invalid": invalid,
67
+ "data-required": required,
52
68
  "data-testid": testId,
53
69
  isDisabled,
54
- value,
55
- onChange,
56
- onBlur,
70
+ isSelected: !!value,
57
71
  name,
72
+ onBlur,
73
+ onChange,
58
74
  ref,
75
+ required,
76
+ value,
59
77
  children: [
60
78
  label,
61
- !!required && !!_label && /* @__PURE__ */ jsx("span", { className: "!text-danger", children: " *" }),
62
79
  /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
63
80
  ]
64
81
  }
65
82
  ),
66
- error && // eslint-disable-next-line react/jsx-props-no-spreading
67
- /* @__PURE__ */ jsx("div", { ...getHelperWrapperProps(), children: /* @__PURE__ */ jsx("div", { ...getErrorMessageProps(), children: /* @__PURE__ */ jsx(FieldValidationError_default, { error }) }) })
83
+ error && /* @__PURE__ */ jsx("div", { className: classNames.errorMessage, children: /* @__PURE__ */ jsx(
84
+ "div",
85
+ {
86
+ ...getErrorMessageProps(),
87
+ children: /* @__PURE__ */ jsx(FieldValidationError_default, { error })
88
+ }
89
+ ) })
68
90
  ] })
69
91
  }
70
92
  );
@@ -78,4 +100,4 @@ export {
78
100
  Switch_default,
79
101
  Switch_default2
80
102
  };
81
- //# sourceMappingURL=chunk-ZOVKQ7MN.js.map
103
+ //# sourceMappingURL=chunk-PFX4YRWI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Switch/Switch.tsx","../src/Switch/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { Controller } from 'react-hook-form';\n\nimport { useInput } from '@nextui-org/input';\nimport { Switch as NextSwitch } from '@nextui-org/switch';\n\nimport { 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 switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\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 const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n console.log('getHelperWrapperProps()', getHelperWrapperProps());\n console.log('getErrorMessageProps()', getErrorMessageProps());\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 <div className={classNames.outerWrapper}>\n <NextSwitch\n aria-describedby={getInputProps()['aria-describedby']}\n classNames={classNames}\n // See NextUI styles for group-data condition (data-invalid), e.g.: https://github.com/nextui-org/nextui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n isDisabled={isDisabled}\n isSelected={!!value}\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n ref={ref}\n required={required}\n value={value}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </NextSwitch>\n {error && (\n <div className={classNames.errorMessage}>\n <div\n /* eslint-disable-next-line react/jsx-props-no-spreading */\n {...getErrorMessageProps()}\n >\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\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"],"mappings":";;;;;;;;;;;AAEA,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AACzB,SAAS,UAAU,kBAAkB;AAErC,SAAS,IAAI,4BAA4B;AA4E/B,SAiBE,KAjBF;AAtEH,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,cAAc;AAAA;AAAA,IAEd,OACE;AAAA,IACF,cAAc;AAAA,IACd,cAAc;AAAA,IACd,OAAO;AAAA,IACP,WAAW;AAAA,IACX,SAAS;AAAA,EACX;AACF,CAAC;AAqBD,IAAM,SAAS,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,OAAO,SAAS;AAAA,EAChB;AAAA,EACA,QAAQ,UAAU;AACpB,MAAmB;AACjB,QAAM,EAAE,SAAS,cAAc,IAAI,eAAe;AAClD,QAAM,EAAE,OAAO,UAAU,QAAQ,QAAQ,IAAI,cAAc,MAAM,OAAO;AAExE,QAAM,EAAE,OAAO,eAAe,uBAAuB,qBAAqB,IACxE,SAAS;AAAA,IACP,cAAc,KAAK,UAAU,KAAK;AAAA,IAClC,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,aAAa;AAAA,EACf,CAAC;AAEH,QAAM,WAAW,eAAe;AAChC,QAAM,aAAa,qBAAqB,UAAU,WAAW,cAAc;AAE3E,UAAQ,IAAI,2BAA2B,sBAAsB,CAAC;AAC9D,UAAQ,IAAI,0BAA0B,qBAAqB,CAAC;AAE5D,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,CAAC;AAAA,QACP,OAAO,EAAE,UAAU,YAAY,OAAO,KAAK,QAAQ,SAAS;AAAA,MAC9D,MACE,qBAAC,SAAI,WAAW,WAAW,cACzB;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,oBAAkB,cAAc,EAAE,kBAAkB;AAAA,YACpD;AAAA,YAEA,gBAAc;AAAA,YACd,iBAAe;AAAA,YACf,eAAa;AAAA,YACb;AAAA,YACA,YAAY,CAAC,CAAC;AAAA,YACd;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YAEC;AAAA;AAAA,cACD,oBAAC,iCAAsB,QAAgB;AAAA;AAAA;AAAA,QACzC;AAAA,QACC,SACC,oBAAC,SAAI,WAAW,WAAW,cACzB;AAAA,UAAC;AAAA;AAAA,YAEE,GAAG,qBAAqB;AAAA,YAEzB,8BAAC,gCAAqB,OAAc;AAAA;AAAA,QACtC,GACF;AAAA,SAEJ;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,iBAAQ;;;AChHf,IAAOA,kBAAQ;","names":["Switch_default"]}
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-T3CCNJHK.js";
4
4
  import {
5
5
  FieldValidationError_default
6
- } from "./chunk-DBLODROX.js";
6
+ } from "./chunk-WKM2D7LF.js";
7
7
  import {
8
8
  useFormContext
9
9
  } from "./chunk-HWDQZO7X.js";
@@ -78,4 +78,4 @@ export {
78
78
  Input_default,
79
79
  Input_default2
80
80
  };
81
- //# sourceMappingURL=chunk-DTSX7YON.js.map
81
+ //# sourceMappingURL=chunk-SCTH3FAO.js.map
@@ -5,20 +5,21 @@ import {
5
5
  // src/partials/FieldValidationError/FieldValidationError.tsx
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  var FieldValidationError = ({
8
+ className = void 0,
8
9
  error,
9
10
  testId = void 0
10
11
  }) => {
11
12
  if (!error) {
12
13
  return null;
13
14
  }
14
- let tmp_errors = [];
15
+ let tmpErrors = [];
15
16
  if (typeof error === "object" && !(error instanceof Array)) {
16
- const error_object = error;
17
+ const errorObject = error;
17
18
  Object.keys(error).forEach((key) => {
18
- tmp_errors = [...tmp_errors, ...error_object[key]];
19
+ tmpErrors = [...tmpErrors, ...errorObject[key]];
19
20
  });
20
21
  }
21
- const errorArray = JSON.stringify(tmp_errors) !== "[]" ? tmp_errors : error;
22
+ const errorArray = JSON.stringify(tmpErrors) !== "[]" ? tmpErrors : error;
22
23
  const errorStrings = errorArray.map((e) => e.message);
23
24
  const ariaString = `Error: ${errorStrings.join("\n")}`;
24
25
  return /* @__PURE__ */ jsx(
@@ -26,6 +27,7 @@ var FieldValidationError = ({
26
27
  {
27
28
  "data-testid": slugify(testId || errorStrings.join()),
28
29
  "aria-label": ariaString,
30
+ className,
29
31
  children: errorStrings.map((errorString, i) => (
30
32
  // eslint-disable-next-line react/no-array-index-key
31
33
  /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("div", { children: errorString }) }, `error_${i}`)
@@ -42,4 +44,4 @@ export {
42
44
  FieldValidationError_default,
43
45
  FieldValidationError_default2
44
46
  };
45
- //# sourceMappingURL=chunk-DBLODROX.js.map
47
+ //# sourceMappingURL=chunk-WKM2D7LF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/partials/FieldValidationError/FieldValidationError.tsx","../src/partials/FieldValidationError/index.ts"],"sourcesContent":["import type { FieldError } from 'react-hook-form';\n\nimport { slugify } from '../../helpers';\n\nexport interface FieldValidationErrorProps {\n className?: string;\n error: FieldError[] | Record<string, FieldError[]>;\n testId?: string;\n}\n\n/**\n * Renders a validation error of a field\n */\nconst FieldValidationError = ({\n className = undefined,\n error,\n testId = undefined,\n}: FieldValidationErrorProps) => {\n if (!error) {\n return null;\n }\n\n let tmpErrors: FieldError[] = [];\n\n if (typeof error === 'object' && !(error instanceof Array)) {\n const errorObject = error as Record<string, FieldError[]>;\n Object.keys(error).forEach((key) => {\n tmpErrors = [...tmpErrors, ...errorObject[key]];\n });\n }\n\n const errorArray: FieldError[] =\n JSON.stringify(tmpErrors) !== '[]' ? tmpErrors : (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 className={className}\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"],"mappings":";;;;;AA6CU;AAhCV,IAAM,uBAAuB,CAAC;AAAA,EAC5B,YAAY;AAAA,EACZ;AAAA,EACA,SAAS;AACX,MAAiC;AAC/B,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,MAAI,YAA0B,CAAC;AAE/B,MAAI,OAAO,UAAU,YAAY,EAAE,iBAAiB,QAAQ;AAC1D,UAAM,cAAc;AACpB,WAAO,KAAK,KAAK,EAAE,QAAQ,CAAC,QAAQ;AAClC,kBAAY,CAAC,GAAG,WAAW,GAAG,YAAY,GAAG,CAAC;AAAA,IAChD,CAAC;AAAA,EACH;AAEA,QAAM,aACJ,KAAK,UAAU,SAAS,MAAM,OAAO,YAAa;AACpD,QAAM,eAAyB,WAAW,IAAI,CAAC,MAAM,EAAE,OAAO;AAC9D,QAAM,aAAa,UAAU,aAAa,KAAK,IAAI,CAAC;AAEpD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAa,QAAQ,UAAU,aAAa,KAAK,CAAC;AAAA,MAClD,cAAY;AAAA,MACZ;AAAA,MAEC,uBAAa,IAAI,CAAC,aAAqB;AAAA;AAAA,QAEtC,oBAAC,QACC,8BAAC,SAAK,uBAAY,KADX,SAAS,CAAC,EAEnB;AAAA,OACD;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,+BAAQ;;;AC9Cf,IAAOA,gCAAQ;","names":["FieldValidationError_default"]}