@fuf-stack/uniform 0.9.2 → 0.9.4
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/Select/index.cjs +2 -2
- package/dist/Select/index.d.cts +2 -2
- package/dist/Select/index.d.ts +2 -2
- package/dist/Select/index.js +1 -1
- package/dist/{Select-fR2SSJSx.d.cts → Select-C08Oftdr.d.cts} +6 -0
- package/dist/{Select-fR2SSJSx.d.ts → Select-C08Oftdr.d.ts} +6 -0
- package/dist/{chunk-HQLY2H3C.js → chunk-OCXF3U6L.js} +10 -7
- package/dist/chunk-OCXF3U6L.js.map +1 -0
- package/dist/{chunk-KN7JXFK5.cjs → chunk-UHFAY5XK.cjs} +10 -7
- package/dist/chunk-UHFAY5XK.cjs.map +1 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/package.json +2 -2
- package/dist/chunk-HQLY2H3C.js.map +0 -1
- package/dist/chunk-KN7JXFK5.cjs.map +0 -1
package/dist/Select/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkUHFAY5XKcjs = require('../chunk-UHFAY5XK.cjs');
|
|
5
5
|
require('../chunk-KMMS4G7A.cjs');
|
|
6
6
|
require('../chunk-QTL5FREE.cjs');
|
|
7
7
|
require('../chunk-LDCRR7FP.cjs');
|
|
@@ -9,5 +9,5 @@ require('../chunk-BBB4FEY6.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.Select =
|
|
12
|
+
exports.Select = _chunkUHFAY5XKcjs.Select_default; exports.default = _chunkUHFAY5XKcjs.Select_default2;
|
|
13
13
|
//# sourceMappingURL=index.cjs.map
|
package/dist/Select/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Select } from '../Select-
|
|
2
|
-
export { a as SelectProps } from '../Select-
|
|
1
|
+
import { S as Select } from '../Select-C08Oftdr.cjs';
|
|
2
|
+
export { a as SelectProps } from '../Select-C08Oftdr.cjs';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'tailwind-variants';
|
|
5
5
|
import 'tailwind-variants/dist/config.js';
|
package/dist/Select/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Select } from '../Select-
|
|
2
|
-
export { a as SelectProps } from '../Select-
|
|
1
|
+
import { S as Select } from '../Select-C08Oftdr.js';
|
|
2
|
+
export { a as SelectProps } from '../Select-C08Oftdr.js';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import 'tailwind-variants';
|
|
5
5
|
import 'tailwind-variants/dist/config.js';
|
package/dist/Select/index.js
CHANGED
|
@@ -23,10 +23,12 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
23
23
|
indicatorsContainer: string;
|
|
24
24
|
indicatorSeparator: string;
|
|
25
25
|
input: string;
|
|
26
|
+
label: string;
|
|
26
27
|
loadingIndicator: string;
|
|
27
28
|
loadingMessage: string;
|
|
28
29
|
menu: string;
|
|
29
30
|
menuList: string;
|
|
31
|
+
menuPortal: string;
|
|
30
32
|
multiValue: string;
|
|
31
33
|
multiValueContainer: string;
|
|
32
34
|
multiValueLabel: string;
|
|
@@ -70,10 +72,12 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
70
72
|
indicatorsContainer: string;
|
|
71
73
|
indicatorSeparator: string;
|
|
72
74
|
input: string;
|
|
75
|
+
label: string;
|
|
73
76
|
loadingIndicator: string;
|
|
74
77
|
loadingMessage: string;
|
|
75
78
|
menu: string;
|
|
76
79
|
menuList: string;
|
|
80
|
+
menuPortal: string;
|
|
77
81
|
multiValue: string;
|
|
78
82
|
multiValueContainer: string;
|
|
79
83
|
multiValueLabel: string;
|
|
@@ -105,10 +109,12 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
105
109
|
indicatorsContainer: string;
|
|
106
110
|
indicatorSeparator: string;
|
|
107
111
|
input: string;
|
|
112
|
+
label: string;
|
|
108
113
|
loadingIndicator: string;
|
|
109
114
|
loadingMessage: string;
|
|
110
115
|
menu: string;
|
|
111
116
|
menuList: string;
|
|
117
|
+
menuPortal: string;
|
|
112
118
|
multiValue: string;
|
|
113
119
|
multiValueContainer: string;
|
|
114
120
|
multiValueLabel: string;
|
|
@@ -23,10 +23,12 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
23
23
|
indicatorsContainer: string;
|
|
24
24
|
indicatorSeparator: string;
|
|
25
25
|
input: string;
|
|
26
|
+
label: string;
|
|
26
27
|
loadingIndicator: string;
|
|
27
28
|
loadingMessage: string;
|
|
28
29
|
menu: string;
|
|
29
30
|
menuList: string;
|
|
31
|
+
menuPortal: string;
|
|
30
32
|
multiValue: string;
|
|
31
33
|
multiValueContainer: string;
|
|
32
34
|
multiValueLabel: string;
|
|
@@ -70,10 +72,12 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
70
72
|
indicatorsContainer: string;
|
|
71
73
|
indicatorSeparator: string;
|
|
72
74
|
input: string;
|
|
75
|
+
label: string;
|
|
73
76
|
loadingIndicator: string;
|
|
74
77
|
loadingMessage: string;
|
|
75
78
|
menu: string;
|
|
76
79
|
menuList: string;
|
|
80
|
+
menuPortal: string;
|
|
77
81
|
multiValue: string;
|
|
78
82
|
multiValueContainer: string;
|
|
79
83
|
multiValueLabel: string;
|
|
@@ -105,10 +109,12 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
105
109
|
indicatorsContainer: string;
|
|
106
110
|
indicatorSeparator: string;
|
|
107
111
|
input: string;
|
|
112
|
+
label: string;
|
|
108
113
|
loadingIndicator: string;
|
|
109
114
|
loadingMessage: string;
|
|
110
115
|
menu: string;
|
|
111
116
|
menuList: string;
|
|
117
|
+
menuPortal: string;
|
|
112
118
|
multiValue: string;
|
|
113
119
|
multiValueContainer: string;
|
|
114
120
|
multiValueLabel: string;
|
|
@@ -19,7 +19,7 @@ var selectVariants = tv({
|
|
|
19
19
|
slots: {
|
|
20
20
|
base: "",
|
|
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
|
|
22
|
+
control: "rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 motion-reduce:transition-none",
|
|
23
23
|
control_focused: "border-primary hover:border-primary",
|
|
24
24
|
crossIcon: "",
|
|
25
25
|
downChevron: "",
|
|
@@ -29,10 +29,14 @@ var selectVariants = tv({
|
|
|
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
33
|
loadingIndicator: "",
|
|
33
34
|
loadingMessage: "",
|
|
34
35
|
menu: "mt-2 rounded-xl border border-default-200 bg-background p-1 shadow-lg",
|
|
35
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",
|
|
36
40
|
multiValue: "items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1",
|
|
37
41
|
multiValueContainer: "",
|
|
38
42
|
multiValueLabel: "py-0.5 leading-6",
|
|
@@ -128,10 +132,7 @@ var Select = ({
|
|
|
128
132
|
"label",
|
|
129
133
|
{
|
|
130
134
|
htmlFor: `react-select-${name}-input`,
|
|
131
|
-
className: cn(
|
|
132
|
-
getLabelProps().className.replace("absolute", "relative").replace("block", ""),
|
|
133
|
-
"!pointer-events-auto bottom-2 ml-1"
|
|
134
|
-
),
|
|
135
|
+
className: cn(getLabelProps().className, classNames.label),
|
|
135
136
|
children: [
|
|
136
137
|
label,
|
|
137
138
|
/* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
|
|
@@ -155,6 +156,8 @@ var Select = ({
|
|
|
155
156
|
indicatorSeparator: () => classNames.indicatorSeparator,
|
|
156
157
|
input: () => classNames.input,
|
|
157
158
|
menu: () => classNames.menu,
|
|
159
|
+
menuList: () => classNames.menuList,
|
|
160
|
+
menuPortal: () => classNames.menuPortal,
|
|
158
161
|
multiValue: () => classNames.multiValue,
|
|
159
162
|
multiValueLabel: () => cn(
|
|
160
163
|
classNames.multiValueLabel,
|
|
@@ -192,7 +195,6 @@ var Select = ({
|
|
|
192
195
|
menuShouldBlockScroll: true,
|
|
193
196
|
options,
|
|
194
197
|
placeholder,
|
|
195
|
-
value: options.find((option) => option.value === value),
|
|
196
198
|
onBlur: (_e) => {
|
|
197
199
|
setIsFocused(false);
|
|
198
200
|
return onBlur();
|
|
@@ -213,6 +215,7 @@ var Select = ({
|
|
|
213
215
|
},
|
|
214
216
|
onInputChange,
|
|
215
217
|
ref,
|
|
218
|
+
value: options.find((option) => option.value === value),
|
|
216
219
|
unstyled: true
|
|
217
220
|
}
|
|
218
221
|
)
|
|
@@ -234,4 +237,4 @@ export {
|
|
|
234
237
|
Select_default,
|
|
235
238
|
Select_default2
|
|
236
239
|
};
|
|
237
|
-
//# sourceMappingURL=chunk-
|
|
240
|
+
//# sourceMappingURL=chunk-OCXF3U6L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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-background 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,iBAAiB;AAE1B,SAAS,IAAI,IAAI,4BAA4B;AAsGpC,cA8FO,YA9FP;AAhGF,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,gBACE;AAAA,IACF,SACE;AAAA,IACF,iBAAiB;AAAA,IACjB,WAAW;AAAA,IACX,aAAa;AAAA,IACb,mBACE;AAAA,IACF,OAAO;AAAA,IACP,cAAc;AAAA,IACd,qBAAqB;AAAA,IACrB,oBAAoB;AAAA,IACpB,OAAO;AAAA,IACP,OAAO;AAAA,IACP,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,MAAM;AAAA,IACN,UAAU;AAAA;AAAA;AAAA,IAGV,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,qBAAqB;AAAA,IACrB,iBAAiB;AAAA,IACjB,kBACE;AAAA,IACF,kBAAkB;AAAA,IAClB,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,gBAAgB;AAAA,EAClB;AAAA,EACA,UAAU;AAAA,IACR,SAAS;AAAA,MACP,MAAM;AAAA,QACJ,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF,CAAC;AA6CD,IAAM,iBAA0C,CAAC,UAAU;AAGzD,QAAM,SAAS,GAAG,MAAM,YAAY,aAAa,CAAC;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;AAAA,kBACA;AAAA,kBAEA,OAAO,QAAQ,KAAK,CAAC,WAAW,OAAO,UAAU,KAAK;AAAA,kBACtD,UAAQ;AAAA;AAAA,cACV;AAAA,eACF;AAAA,YACC;AAAA,YAEC,oBAAC,SAAK,GAAG,sBAAsB,GAE7B,8BAAC,SAAK,GAAG,qBAAqB,GAC5B,8BAAC,gCAAqB,OAAc,GACtC,GACF;AAAA,aAEJ;AAAA;AAAA,MACF;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,iBAAQ;;;AC1Tf,IAAOA,kBAAQ;","names":["Select_default"]}
|
|
@@ -19,7 +19,7 @@ var selectVariants = _pixelutils.tv.call(void 0, {
|
|
|
19
19
|
slots: {
|
|
20
20
|
base: "",
|
|
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
|
|
22
|
+
control: "rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 motion-reduce:transition-none",
|
|
23
23
|
control_focused: "border-primary hover:border-primary",
|
|
24
24
|
crossIcon: "",
|
|
25
25
|
downChevron: "",
|
|
@@ -29,10 +29,14 @@ 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
33
|
loadingIndicator: "",
|
|
33
34
|
loadingMessage: "",
|
|
34
35
|
menu: "mt-2 rounded-xl border border-default-200 bg-background p-1 shadow-lg",
|
|
35
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",
|
|
36
40
|
multiValue: "items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1",
|
|
37
41
|
multiValueContainer: "",
|
|
38
42
|
multiValueLabel: "py-0.5 leading-6",
|
|
@@ -128,10 +132,7 @@ var Select = ({
|
|
|
128
132
|
"label",
|
|
129
133
|
{
|
|
130
134
|
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
|
+
className: _pixelutils.cn.call(void 0, getLabelProps().className, classNames.label),
|
|
135
136
|
children: [
|
|
136
137
|
label,
|
|
137
138
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkKMMS4G7Acjs.FieldCopyTestIdButton_default, { testId })
|
|
@@ -155,6 +156,8 @@ var Select = ({
|
|
|
155
156
|
indicatorSeparator: () => classNames.indicatorSeparator,
|
|
156
157
|
input: () => classNames.input,
|
|
157
158
|
menu: () => classNames.menu,
|
|
159
|
+
menuList: () => classNames.menuList,
|
|
160
|
+
menuPortal: () => classNames.menuPortal,
|
|
158
161
|
multiValue: () => classNames.multiValue,
|
|
159
162
|
multiValueLabel: () => _pixelutils.cn.call(void 0,
|
|
160
163
|
classNames.multiValueLabel,
|
|
@@ -192,7 +195,6 @@ var Select = ({
|
|
|
192
195
|
menuShouldBlockScroll: true,
|
|
193
196
|
options,
|
|
194
197
|
placeholder,
|
|
195
|
-
value: options.find((option) => option.value === value),
|
|
196
198
|
onBlur: (_e) => {
|
|
197
199
|
setIsFocused(false);
|
|
198
200
|
return onBlur();
|
|
@@ -213,6 +215,7 @@ var Select = ({
|
|
|
213
215
|
},
|
|
214
216
|
onInputChange,
|
|
215
217
|
ref,
|
|
218
|
+
value: options.find((option) => option.value === value),
|
|
216
219
|
unstyled: true
|
|
217
220
|
}
|
|
218
221
|
)
|
|
@@ -234,4 +237,4 @@ var Select_default2 = Select_default;
|
|
|
234
237
|
|
|
235
238
|
|
|
236
239
|
exports.Select_default = Select_default; exports.Select_default2 = Select_default2;
|
|
237
|
-
//# sourceMappingURL=chunk-
|
|
240
|
+
//# sourceMappingURL=chunk-UHFAY5XK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-UHFAY5XK.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;AAAA,IACd,mBAAA,EAAqB,WAAA;AAAA,IACrB,kBAAA,EAAoB,gBAAA;AAAA,IACpB,KAAA,EAAO,aAAA;AAAA,IACP,KAAA,EAAO,oDAAA;AAAA,IACP,gBAAA,EAAkB,EAAA;AAAA,IAClB,cAAA,EAAgB,EAAA;AAAA,IAChB,IAAA,EAAM,uEAAA;AAAA,IACN,QAAA,EAAU,EAAA;AAAA;AAAA;AAAA,IAGV,UAAA,EAAY,OAAA;AAAA,IACZ,UAAA,EAAY,8DAAA;AAAA,IACZ,mBAAA,EAAqB,EAAA;AAAA,IACrB,eAAA,EAAiB,kBAAA;AAAA,IACjB,gBAAA,EACE,+FAAA;AAAA,IACF,gBAAA,EAAkB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ADzFW;AACA;AElOXA;AFoOW;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-UHFAY5XK.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-background 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"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkUHFAY5XKcjs = require('./chunk-UHFAY5XK.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunk3XNW2VQ7cjs = require('./chunk-3XNW2VQ7.cjs');
|
|
@@ -12,10 +12,10 @@ var _chunkOCR2UWG2cjs = require('./chunk-OCR2UWG2.cjs');
|
|
|
12
12
|
var _chunkW24WP5YEcjs = require('./chunk-W24WP5YE.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkQYZV7ZUYcjs = require('./chunk-QYZV7ZUY.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunkTNELIBCVcjs = require('./chunk-TNELIBCV.cjs');
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
var _chunk6GN255GPcjs = require('./chunk-6GN255GP.cjs');
|
|
@@ -27,15 +27,15 @@ var _chunk5UHHZ7KYcjs = require('./chunk-5UHHZ7KY.cjs');
|
|
|
27
27
|
var _chunkYUAJN6HWcjs = require('./chunk-YUAJN6HW.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var _chunkKN7JXFK5cjs = require('./chunk-KN7JXFK5.cjs');
|
|
31
|
-
|
|
32
|
-
|
|
33
30
|
var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
|
|
34
31
|
|
|
35
32
|
|
|
36
33
|
var _chunkQTL5FREEcjs = require('./chunk-QTL5FREE.cjs');
|
|
37
34
|
|
|
38
35
|
|
|
36
|
+
var _chunkMKM7ZYRNcjs = require('./chunk-MKM7ZYRN.cjs');
|
|
37
|
+
|
|
38
|
+
|
|
39
39
|
|
|
40
40
|
var _chunkLDCRR7FPcjs = require('./chunk-LDCRR7FP.cjs');
|
|
41
41
|
|
|
@@ -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 =
|
|
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 = _chunkUHFAY5XKcjs.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-
|
|
11
|
+
export { S as Select, a as SelectProps } from './Select-C08Oftdr.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';
|
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-
|
|
11
|
+
export { S as Select, a as SelectProps } from './Select-C08Oftdr.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';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
Select_default
|
|
3
|
+
} from "./chunk-OCXF3U6L.js";
|
|
4
4
|
import {
|
|
5
5
|
Switch_default
|
|
6
6
|
} from "./chunk-ZOVKQ7MN.js";
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
CheckboxGroup_default
|
|
12
12
|
} from "./chunk-4AHVJWTB.js";
|
|
13
|
-
import {
|
|
14
|
-
FieldArray_default
|
|
15
|
-
} from "./chunk-FMQNL3RT.js";
|
|
16
13
|
import {
|
|
17
14
|
Form_default
|
|
18
15
|
} from "./chunk-DF77NLWL.js";
|
|
16
|
+
import {
|
|
17
|
+
FieldArray_default
|
|
18
|
+
} from "./chunk-FMQNL3RT.js";
|
|
19
19
|
import {
|
|
20
20
|
Grid_default
|
|
21
21
|
} from "./chunk-PDCEKC3G.js";
|
|
@@ -25,15 +25,15 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
RadioGroup_default
|
|
27
27
|
} from "./chunk-ARUVDZFG.js";
|
|
28
|
-
import {
|
|
29
|
-
Select_default
|
|
30
|
-
} from "./chunk-HQLY2H3C.js";
|
|
31
28
|
import {
|
|
32
29
|
FieldCopyTestIdButton_default
|
|
33
30
|
} from "./chunk-T3CCNJHK.js";
|
|
34
31
|
import {
|
|
35
32
|
FieldValidationError_default
|
|
36
33
|
} from "./chunk-DBLODROX.js";
|
|
34
|
+
import {
|
|
35
|
+
SubmitButton_default
|
|
36
|
+
} from "./chunk-4GVPJYZW.js";
|
|
37
37
|
import {
|
|
38
38
|
recursiveFieldKeySearch,
|
|
39
39
|
useFormContext
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Hannes Tiede",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/uniform#readme",
|
|
@@ -135,9 +135,9 @@
|
|
|
135
135
|
"@types/slug": "5.0.9",
|
|
136
136
|
"react": "18.3.1",
|
|
137
137
|
"react-dom": "18.3.1",
|
|
138
|
+
"@repo/tsup-config": "0.0.1",
|
|
138
139
|
"@repo/storybook-config": "0.0.1",
|
|
139
140
|
"@repo/tailwind-config": "0.0.1",
|
|
140
|
-
"@repo/tsup-config": "0.0.1",
|
|
141
141
|
"@repo/vite-config": "0.0.1"
|
|
142
142
|
},
|
|
143
143
|
"scripts": {
|
|
@@ -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 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"],"mappings":";;;;;;;;;;;AAGA,SAAS,gBAAgB;AACzB,SAAS,kBAAk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default"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAQ,wCAAA;AAAA,IACR,WAAA,EAAa,iCAAA;AAAA,IACb,eAAA,EAAiB,EAAA;AAAA,IACjB,WAAA,EAAa,kBAAA;AAAA,IAC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AAGA,kBAAA;AACA,kBAAA;AAAY,oBAAA;AAEe,sBAAA;AACuB,oBAAA;AAC7C,oBAAA;AAC8B,oBAAA;AACG,oBAAA;AACL,oBAAA;AACO,oBAAA;AACD,oBAAA;AACb,oBAAA;AACD,oBAAA;AACM,oBAAA;AAE3B,sBAAA;AACa,sBAAA;AACiB,oBAAA;AAC9B,oBAAA;AACiC,oBAAA;AACA,oBAAA;AAC1B,sBAAA;AACI,sBAAA;AACC,oBAAA;AAEU,sBAAA;AACS,sBAAA;AACC,oBAAA;AAC/B,oBAAA;AAC2B,oBAAA;AAE6B,oBAAA;AAE7D,kBAAA;AACA,kBAAA;AAAY,oBAAA;AACH,oBAAA;AACC,oBAAA;AAEV,kBAAA;AAEA,kBAAA;AACA,kBAAA;AACA,kBAAA;AACA,kBAAA;AACA,kBAAA;AACA,kBAAA;AACA,kBAAA;AACA,kBAAA;AACA,kBAAA;AACA,kBAAA;AAIA,kBAAA;AACA,kBAAA;AACA,kBAAA;AACA,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;AACA,kBAAA;AAAQ,gBAAA;AACV,cAAA;AACF,YAAA;AACC,YAAA;AAEC,4BAAA;AAOJ,UAAA;AAAA,QAAA;AACF,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;AD1FW;AACA;AE/NXA;AFiOW;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/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"]}
|