@fuf-stack/uniform 0.9.0 → 0.9.2

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.
@@ -0,0 +1,237 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
4
+
5
+
6
+ var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
7
+
8
+
9
+ var _chunkLDCRR7FPcjs = require('./chunk-LDCRR7FP.cjs');
10
+
11
+ // src/Select/Select.tsx
12
+ var _react = require('react');
13
+ var _reacthookform = require('react-hook-form');
14
+ var _reactselect = require('react-select'); var _reactselect2 = _interopRequireDefault(_reactselect);
15
+ var _select = require('@nextui-org/select');
16
+ var _pixelutils = require('@fuf-stack/pixel-utils');
17
+ var _jsxruntime = require('react/jsx-runtime');
18
+ var selectVariants = _pixelutils.tv.call(void 0, {
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 shadow-sm !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
+ loadingIndicator: "",
33
+ loadingMessage: "",
34
+ menu: "mt-2 rounded-xl border border-default-200 bg-background p-1 shadow-lg",
35
+ menuList: "",
36
+ multiValue: "items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1",
37
+ multiValueContainer: "",
38
+ multiValueLabel: "py-0.5 leading-6",
39
+ multiValueRemove: "rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800",
40
+ noOptionsMessage: "rounded-sm p-2 text-foreground-500",
41
+ option_focused: "bg-default-100 active:bg-default-200",
42
+ option_selected: "bg-default-300",
43
+ option: "rounded px-3 py-2 hover:cursor-pointer",
44
+ placeholder: "py-0.5 pl-1 text-foreground-500",
45
+ selectContainer: "",
46
+ singleValue: "!ml-1 !leading-7",
47
+ valueContainer: "gap-1 p-1"
48
+ },
49
+ variants: {
50
+ invalid: {
51
+ true: {
52
+ control: "border-danger hover:border-danger"
53
+ }
54
+ }
55
+ }
56
+ });
57
+ var InputComponent = (props) => {
58
+ const testId = `${props.selectProps["data-testid"]}_input`;
59
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.Input, { "data-testid": testId, ...props });
60
+ };
61
+ var OptionComponent = (props) => {
62
+ const testId = `${props.selectProps["data-testid"]}_option_${_nullishCoalesce(_optionalChain([props, 'optionalAccess', _ => _.data, 'optionalAccess', _2 => _2.testId]), () => ( _optionalChain([props, 'optionalAccess', _3 => _3.data, 'optionalAccess', _4 => _4.value])))}`;
63
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.Option, { ...props }) });
64
+ };
65
+ var DropdownIndicatorComponent = (props) => {
66
+ const testId = _optionalChain([props, 'optionalAccess', _5 => _5.selectProps, 'access', _6 => _6["data-testid"]]);
67
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-testid": `${testId}_dropdown`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.DropdownIndicator, { ...props }) });
68
+ };
69
+ var Select = ({
70
+ className = void 0,
71
+ clearable = true,
72
+ disabled = false,
73
+ filterOption = void 0,
74
+ formatOptionLabel = void 0,
75
+ inputValue = void 0,
76
+ label: _label = void 0,
77
+ loading = false,
78
+ multiSelect = false,
79
+ name,
80
+ onInputChange = void 0,
81
+ options,
82
+ placeholder = void 0,
83
+ testId: _testId = void 0
84
+ }) => {
85
+ const { control, getFieldState } = _chunkLDCRR7FPcjs.useFormContext.call(void 0, );
86
+ const { error, invalid, required, testId } = getFieldState(name, _testId);
87
+ const [isFocused, setIsFocused] = _react.useState.call(void 0, false);
88
+ const variants = selectVariants({ invalid });
89
+ const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
90
+ const {
91
+ getBaseProps,
92
+ getErrorMessageProps,
93
+ getHelperWrapperProps,
94
+ getLabelProps,
95
+ getMainWrapperProps,
96
+ getTriggerProps,
97
+ getValueProps,
98
+ label
99
+ } = _select.useSelect.call(void 0, {
100
+ children: [],
101
+ classNames,
102
+ errorMessage: JSON.stringify(error),
103
+ isDisabled: disabled,
104
+ isInvalid: invalid,
105
+ isLoading: loading,
106
+ isRequired: required,
107
+ label: _label,
108
+ labelPlacement: "outside",
109
+ placeholder: " "
110
+ });
111
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
112
+ _reacthookform.Controller,
113
+ {
114
+ control,
115
+ name,
116
+ render: ({
117
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
118
+ field: { onChange, value, ref, onBlur }
119
+ }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
120
+ "div",
121
+ {
122
+ ...getBaseProps(),
123
+ className: _pixelutils.cn.call(void 0, classNames.base, "group mt-2"),
124
+ "data-testid": testId,
125
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ...getMainWrapperProps(), children: [
126
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative", children: [
127
+ label && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
128
+ "label",
129
+ {
130
+ htmlFor: `react-select-${name}-input`,
131
+ className: _pixelutils.cn.call(void 0,
132
+ getLabelProps().className.replace("absolute", "relative").replace("block", ""),
133
+ "!pointer-events-auto bottom-2 ml-1"
134
+ ),
135
+ children: [
136
+ label,
137
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkKMMS4G7Acjs.FieldCopyTestIdButton_default, { testId })
138
+ ]
139
+ }
140
+ ),
141
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
142
+ _reactselect2.default,
143
+ {
144
+ "aria-errormessage": "",
145
+ "aria-labelledby": _optionalChain([getTriggerProps, 'call', _7 => _7(), 'access', _8 => _8["aria-labelledby"], 'optionalAccess', _9 => _9.split, 'call', _10 => _10(" "), 'access', _11 => _11[1]]),
146
+ "aria-invalid": invalid,
147
+ classNames: {
148
+ control: () => _pixelutils.cn.call(void 0, classNames.control, {
149
+ [classNames.control_focused]: isFocused && !invalid
150
+ }),
151
+ clearIndicator: () => classNames.clearIndicator,
152
+ dropdownIndicator: () => classNames.dropdownIndicator,
153
+ groupHeading: () => classNames.groupHeading,
154
+ indicatorsContainer: () => classNames.indicatorsContainer,
155
+ indicatorSeparator: () => classNames.indicatorSeparator,
156
+ input: () => classNames.input,
157
+ menu: () => classNames.menu,
158
+ multiValue: () => classNames.multiValue,
159
+ multiValueLabel: () => _pixelutils.cn.call(void 0,
160
+ classNames.multiValueLabel,
161
+ `${getValueProps().className}`
162
+ ),
163
+ multiValueRemove: () => classNames.multiValueRemove,
164
+ noOptionsMessage: () => classNames.noOptionsMessage,
165
+ option: ({
166
+ isFocused: optionIsFocused,
167
+ isSelected: optionIsSelected
168
+ }) => _pixelutils.cn.call(void 0, classNames.option, {
169
+ [classNames.option_focused]: optionIsFocused,
170
+ [classNames.option_selected]: optionIsSelected
171
+ }),
172
+ placeholder: () => classNames.placeholder,
173
+ singleValue: () => _pixelutils.cn.call(void 0, classNames.singleValue, `${getValueProps().className}`),
174
+ valueContainer: () => classNames.valueContainer
175
+ },
176
+ components: {
177
+ Input: InputComponent,
178
+ Option: OptionComponent,
179
+ DropdownIndicator: DropdownIndicatorComponent
180
+ },
181
+ "data-testid": `${testId}_select`,
182
+ filterOption,
183
+ formatOptionLabel,
184
+ inputValue,
185
+ instanceId: name,
186
+ isClearable: clearable,
187
+ isDisabled: disabled,
188
+ isLoading: loading,
189
+ isMulti: multiSelect,
190
+ name,
191
+ menuPosition: "fixed",
192
+ menuShouldBlockScroll: true,
193
+ options,
194
+ placeholder,
195
+ value: options.find((option) => option.value === value),
196
+ onBlur: (_e) => {
197
+ setIsFocused(false);
198
+ return onBlur();
199
+ },
200
+ onChange: (option) => {
201
+ if (multiSelect) {
202
+ const transformedOptions = [];
203
+ _optionalChain([option, 'optionalAccess', _12 => _12.forEach, 'call', _13 => _13((o) => {
204
+ transformedOptions.push(o.value);
205
+ })]);
206
+ onChange(transformedOptions);
207
+ } else {
208
+ onChange(option && option.value);
209
+ }
210
+ },
211
+ onFocus: (_e) => {
212
+ setIsFocused(true);
213
+ },
214
+ onInputChange,
215
+ ref,
216
+ unstyled: true
217
+ }
218
+ )
219
+ ] }),
220
+ error && // eslint-disable-next-line react/jsx-props-no-spreading
221
+ /* @__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 }) }) })
222
+ ] })
223
+ }
224
+ )
225
+ }
226
+ );
227
+ };
228
+ var Select_default = Select;
229
+
230
+ // src/Select/index.ts
231
+ var Select_default2 = Select_default;
232
+
233
+
234
+
235
+
236
+ exports.Select_default = Select_default; exports.Select_default2 = Select_default2;
237
+ //# sourceMappingURL=chunk-KN7JXFK5.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-KN7JXFK5.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;AAkGpC,+CAAA;AA5FF,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,EAAA;AAAA,IACN,cAAA,EACE,wGAAA;AAAA,IACF,OAAA,EACE,6IAAA;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;AAAA,IACd,mBAAA,EAAqB,WAAA;AAAA,IACrB,kBAAA,EAAoB,gBAAA;AAAA,IACpB,KAAA,EAAO,aAAA;AAAA,IACP,gBAAA,EAAkB,EAAA;AAAA,IAClB,cAAA,EAAgB,EAAA;AAAA,IAChB,IAAA,EAAM,uEAAA;AAAA,IACN,QAAA,EAAU,EAAA;AAAA,IACV,UAAA,EAAY,8DAAA;AAAA,IACZ,mBAAA,EAAqB,EAAA;AAAA,IACrB,eAAA,EAAiB,kBAAA;AAAA,IACjB,gBAAA,EACE,+FAAA;AAAA,IACF,gBAAA,EAAkB,oCAAA;AAAA,IAClB,cAAA,EAAgB,sCAAA;AAAA,IAChB,eAAA,EAAiB,gBAAA;AAAA,IACjB,MAAA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/dist/chunk-KN7JXFK5.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 shadow-sm !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 loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-default-200 bg-background p-1 shadow-lg',\n menuList: '',\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(\n getLabelProps()\n .className.replace('absolute', 'relative')\n .replace('block', ''),\n '!pointer-events-auto bottom-2 ml-1',\n )}\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 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 value={options.find((option) => option.value === value)}\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 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"]}
package/dist/index.cjs CHANGED
@@ -27,7 +27,7 @@ var _chunk5UHHZ7KYcjs = require('./chunk-5UHHZ7KY.cjs');
27
27
  var _chunkYUAJN6HWcjs = require('./chunk-YUAJN6HW.cjs');
28
28
 
29
29
 
30
- var _chunkWCQYZ5RIcjs = require('./chunk-WCQYZ5RI.cjs');
30
+ var _chunkKN7JXFK5cjs = require('./chunk-KN7JXFK5.cjs');
31
31
 
32
32
 
33
33
  var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
@@ -57,5 +57,5 @@ var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
57
57
 
58
58
 
59
59
 
60
- exports.CheckboxGroup = _chunkW24WP5YEcjs.CheckboxGroup_default; exports.FieldArray = _chunkTNELIBCVcjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkKMMS4G7Acjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkQTL5FREEcjs.FieldValidationError_default; exports.Form = _chunkQYZV7ZUYcjs.Form_default; exports.Grid = _chunk6GN255GPcjs.Grid_default; exports.Input = _chunk5UHHZ7KYcjs.Input_default; exports.RadioGroup = _chunkYUAJN6HWcjs.RadioGroup_default; exports.Select = _chunkWCQYZ5RIcjs.Select_default; exports.SubmitButton = _chunkMKM7ZYRNcjs.SubmitButton_default; exports.Switch = _chunk3XNW2VQ7cjs.Switch_default; exports.TextArea = _chunkOCR2UWG2cjs.TextArea_default; exports.recursiveFieldKeySearch = _chunkLDCRR7FPcjs.recursiveFieldKeySearch; exports.slugify = _chunkBBB4FEY6cjs.slugify; exports.useFormContext = _chunkLDCRR7FPcjs.useFormContext;
60
+ exports.CheckboxGroup = _chunkW24WP5YEcjs.CheckboxGroup_default; exports.FieldArray = _chunkTNELIBCVcjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkKMMS4G7Acjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkQTL5FREEcjs.FieldValidationError_default; exports.Form = _chunkQYZV7ZUYcjs.Form_default; exports.Grid = _chunk6GN255GPcjs.Grid_default; exports.Input = _chunk5UHHZ7KYcjs.Input_default; exports.RadioGroup = _chunkYUAJN6HWcjs.RadioGroup_default; exports.Select = _chunkKN7JXFK5cjs.Select_default; exports.SubmitButton = _chunkMKM7ZYRNcjs.SubmitButton_default; exports.Switch = _chunk3XNW2VQ7cjs.Switch_default; exports.TextArea = _chunkOCR2UWG2cjs.TextArea_default; exports.recursiveFieldKeySearch = _chunkLDCRR7FPcjs.recursiveFieldKeySearch; exports.slugify = _chunkBBB4FEY6cjs.slugify; exports.useFormContext = _chunkLDCRR7FPcjs.useFormContext;
61
61
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -8,7 +8,7 @@ export { I as Input, a as InputProps } from './Input-B6dNQiiD.cjs';
8
8
  export { F as FieldCopyTestIdButton, a as FieldCopyTestIdButtonProps } from './FieldCopyTestIdButton-D-z1usqE.cjs';
9
9
  export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-BSXedjCA.cjs';
10
10
  export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-BU4K9cnS.cjs';
11
- export { S as Select, a as SelectProps } from './Select-Mp6Y00dT.cjs';
11
+ export { S as Select, a as SelectProps } from './Select-fR2SSJSx.cjs';
12
12
  export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-BEp_zzwf.cjs';
13
13
  export { S as Switch, a as SwitchProps } from './Switch-DmjDKgKs.cjs';
14
14
  export { T as TextArea, a as TextAreaProps } from './TextArea-B-sKvTkd.cjs';
@@ -17,5 +17,8 @@ import 'react-hook-form';
17
17
  import '@fuf-stack/veto';
18
18
  import 'react';
19
19
  import 'slug';
20
+ import 'tailwind-variants';
21
+ import 'tailwind-variants/dist/config.js';
22
+ import '@fuf-stack/pixel-utils';
20
23
  import 'react-select';
21
24
  import '@fuf-stack/pixels';
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export { I as Input, a as InputProps } from './Input-B6dNQiiD.js';
8
8
  export { F as FieldCopyTestIdButton, a as FieldCopyTestIdButtonProps } from './FieldCopyTestIdButton-D-z1usqE.js';
9
9
  export { F as FieldValidationError, a as FieldValidationErrorProps } from './FieldValidationError-BSXedjCA.js';
10
10
  export { R as RadioGroup, a as RadioGroupProps } from './RadioGroup-BU4K9cnS.js';
11
- export { S as Select, a as SelectProps } from './Select-Mp6Y00dT.js';
11
+ export { S as Select, a as SelectProps } from './Select-fR2SSJSx.js';
12
12
  export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-BEp_zzwf.js';
13
13
  export { S as Switch, a as SwitchProps } from './Switch-DmjDKgKs.js';
14
14
  export { T as TextArea, a as TextAreaProps } from './TextArea-B-sKvTkd.js';
@@ -17,5 +17,8 @@ import 'react-hook-form';
17
17
  import '@fuf-stack/veto';
18
18
  import 'react';
19
19
  import 'slug';
20
+ import 'tailwind-variants';
21
+ import 'tailwind-variants/dist/config.js';
22
+ import '@fuf-stack/pixel-utils';
20
23
  import 'react-select';
21
24
  import '@fuf-stack/pixels';
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  } from "./chunk-ARUVDZFG.js";
28
28
  import {
29
29
  Select_default
30
- } from "./chunk-C2AWFTC5.js";
30
+ } from "./chunk-HQLY2H3C.js";
31
31
  import {
32
32
  FieldCopyTestIdButton_default
33
33
  } from "./chunk-T3CCNJHK.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuf-stack/uniform",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "fuf react form library",
5
5
  "author": "Hannes Tiede",
6
6
  "homepage": "https://github.com/fuf-stack/uniform#readme",
@@ -124,7 +124,7 @@
124
124
  "react-hook-form": "7.53.0",
125
125
  "react-select": "5.8.1",
126
126
  "slug": "9.1.0",
127
- "@fuf-stack/pixel-utils": "0.2.0",
127
+ "@fuf-stack/pixel-utils": "0.3.0",
128
128
  "@fuf-stack/pixels": "0.24.0",
129
129
  "@fuf-stack/veto": "0.5.0"
130
130
  },
@@ -136,9 +136,9 @@
136
136
  "react": "18.3.1",
137
137
  "react-dom": "18.3.1",
138
138
  "@repo/storybook-config": "0.0.1",
139
+ "@repo/tailwind-config": "0.0.1",
139
140
  "@repo/tsup-config": "0.0.1",
140
- "@repo/vite-config": "0.0.1",
141
- "@repo/tailwind-config": "0.0.1"
141
+ "@repo/vite-config": "0.0.1"
142
142
  },
143
143
  "scripts": {
144
144
  "build": "tsup --config node_modules/@repo/tsup-config/config.ts",
@@ -1,40 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Props } from 'react-select';
3
-
4
- type SelectOption = {
5
- /** option label */
6
- label?: React.ReactNode;
7
- /** option value */
8
- value: string;
9
- };
10
- interface SelectProps {
11
- /** CSS class name */
12
- className?: string;
13
- /** Determine if the */
14
- clearable?: boolean;
15
- /** Set the select to disabled state. */
16
- disabled?: boolean;
17
- filterOption?: undefined | ((option?: SelectOption, inputValue?: string) => boolean);
18
- /** The value of the search input */
19
- inputValue?: string;
20
- /** Label that should be associated with the select. */
21
- label?: React.ReactNode;
22
- /** Set the select to a loading state. */
23
- loading?: boolean;
24
- /** switch between single and multi select mode. */
25
- multiSelect?: boolean;
26
- /** The name for the Select component, used by react-hook-form */
27
- name: string;
28
- /** Placeholder that is displayed when nothing is selected */
29
- placeholder?: string;
30
- /** The options for the Select component */
31
- options: SelectOption[];
32
- /** Handle change events on the input */
33
- onInputChange?: Props['onInputChange'];
34
- /** HTML data-testid attribute used in e2e tests */
35
- testId?: string;
36
- }
37
- /** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */
38
- declare const Select: ({ className, clearable, disabled, filterOption, inputValue, label: _label, loading, multiSelect, name, onInputChange, options, placeholder, testId: _testId, }: SelectProps) => react_jsx_runtime.JSX.Element;
39
-
40
- export { Select as S, type SelectProps as a };
@@ -1,40 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Props } from 'react-select';
3
-
4
- type SelectOption = {
5
- /** option label */
6
- label?: React.ReactNode;
7
- /** option value */
8
- value: string;
9
- };
10
- interface SelectProps {
11
- /** CSS class name */
12
- className?: string;
13
- /** Determine if the */
14
- clearable?: boolean;
15
- /** Set the select to disabled state. */
16
- disabled?: boolean;
17
- filterOption?: undefined | ((option?: SelectOption, inputValue?: string) => boolean);
18
- /** The value of the search input */
19
- inputValue?: string;
20
- /** Label that should be associated with the select. */
21
- label?: React.ReactNode;
22
- /** Set the select to a loading state. */
23
- loading?: boolean;
24
- /** switch between single and multi select mode. */
25
- multiSelect?: boolean;
26
- /** The name for the Select component, used by react-hook-form */
27
- name: string;
28
- /** Placeholder that is displayed when nothing is selected */
29
- placeholder?: string;
30
- /** The options for the Select component */
31
- options: SelectOption[];
32
- /** Handle change events on the input */
33
- onInputChange?: Props['onInputChange'];
34
- /** HTML data-testid attribute used in e2e tests */
35
- testId?: string;
36
- }
37
- /** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */
38
- declare const Select: ({ className, clearable, disabled, filterOption, inputValue, label: _label, loading, multiSelect, name, onInputChange, options, placeholder, testId: _testId, }: SelectProps) => react_jsx_runtime.JSX.Element;
39
-
40
- export { Select as S, type SelectProps as a };