@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.
@@ -1,239 +0,0 @@
1
- import {
2
- FieldCopyTestIdButton_default
3
- } from "./chunk-T3CCNJHK.js";
4
- import {
5
- FieldValidationError_default
6
- } from "./chunk-DBLODROX.js";
7
- import {
8
- useFormContext
9
- } from "./chunk-HWDQZO7X.js";
10
-
11
- // src/Select/Select.tsx
12
- import { Controller } from "react-hook-form";
13
- import ReactSelect, { components } from "react-select";
14
- import { useSelect } from "@nextui-org/select";
15
- import { cn, tv } from "@fuf-stack/pixel-utils";
16
- import { jsx, jsxs } from "react/jsx-runtime";
17
- var InputComponent = (props) => {
18
- const testId = `${props.selectProps["data-testid"]}_input`;
19
- return /* @__PURE__ */ jsx(components.Input, { "data-testid": testId, ...props });
20
- };
21
- var OptionComponent = (props) => {
22
- const testId = `${props.selectProps["data-testid"]}_option_${props?.data?.testId ?? props?.data?.value}`;
23
- return /* @__PURE__ */ jsx("div", { "data-testid": testId, children: /* @__PURE__ */ jsx(components.Option, { ...props }) });
24
- };
25
- var DropdownIndicatorComponent = (props) => {
26
- const testId = props?.selectProps["data-testid"];
27
- return /* @__PURE__ */ jsx("div", { "data-testid": `${testId}_dropdown`, children: /* @__PURE__ */ jsx(components.DropdownIndicator, { ...props }) });
28
- };
29
- var selectVariants = tv({
30
- slots: {
31
- clearIndicator: "rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500",
32
- control: "rounded-lg border-2 border-gray-200 shadow-sm !duration-150 transition-background hover:border-gray-400 motion-reduce:transition-none dark:border-default-200 hover:dark:border-default-400 focus:dark:border-default-400",
33
- crossIcon: "",
34
- downChevron: "",
35
- dropdownIndicator: "rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-black hover:dark:bg-default-200 hover:dark:text-default-500",
36
- group: "",
37
- groupHeading: "mb-1 ml-3 mt-2 text-sm text-neutral-500",
38
- indicatorsContainer: "gap-1 p-1",
39
- indicatorSeparator: "bg-gray-300 dark:bg-default-300",
40
- input: "py-0.5 pl-1",
41
- loadingIndicator: "",
42
- loadingMessage: "",
43
- menu: "mt-2 rounded-xl border border-gray-200 bg-default-50 p-1 shadow-sm dark:border-gray-900 dark:bg-default-50",
44
- menuList: "",
45
- // ensure menu has same z-index as modal so it is visible when rendered in modal
46
- // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)
47
- menuPortal: "!z-50",
48
- multiValue: "items-center gap-1.5 rounded bg-gray-100 py-0.5 pl-2 pr-1 dark:bg-default-100",
49
- multiValueContainer: "",
50
- multiValueLabel: "py-0.5 leading-6",
51
- multiValueRemove: "rounded text-neutral-500 hover:cursor-pointer hover:border-gray-300 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500",
52
- noOptionsMessage: "rounded-sm bg-gray-50 p-2 text-neutral-500 dark:bg-default-100",
53
- option: "rounded px-3 py-2 hover:cursor-pointer",
54
- placeholder: "py-0.5 pl-1 text-neutral-500",
55
- selectContainer: "",
56
- singleValue: "!ml-1 !leading-7",
57
- valueContainer: "gap-1 p-1"
58
- },
59
- variants: {
60
- invalid: {
61
- true: {
62
- control: "border-danger hover:border-danger dark:border-danger hover:dark:border-danger"
63
- }
64
- },
65
- focused: {
66
- true: {
67
- option: "bg-gray-100 active:bg-gray-200 dark:bg-default-100 dark:active:bg-default-200"
68
- }
69
- },
70
- optionSelected: {
71
- true: { option: "bg-gray-300 dark:bg-default-300" }
72
- }
73
- }
74
- });
75
- var Select = ({
76
- className = void 0,
77
- clearable = true,
78
- disabled = false,
79
- filterOption = void 0,
80
- inputValue = void 0,
81
- label: _label = void 0,
82
- loading = false,
83
- multiSelect = false,
84
- name,
85
- onInputChange = void 0,
86
- options,
87
- placeholder = void 0,
88
- testId: _testId = void 0
89
- }) => {
90
- const { control, getFieldState } = useFormContext();
91
- const { error, invalid, required, testId } = getFieldState(name, _testId);
92
- const {
93
- label,
94
- getLabelProps,
95
- getTriggerProps,
96
- getValueProps,
97
- getHelperWrapperProps,
98
- getErrorMessageProps
99
- } = useSelect({
100
- isLoading: loading,
101
- isInvalid: invalid,
102
- isRequired: required,
103
- isDisabled: disabled,
104
- errorMessage: JSON.stringify(error),
105
- label: _label,
106
- labelPlacement: "outside",
107
- children: []
108
- });
109
- const {
110
- clearIndicator: clearIndicatorSlot,
111
- control: controlSlot,
112
- dropdownIndicator: dropdownIndicatorSlot,
113
- groupHeading: groupHeadingSlot,
114
- indicatorsContainer: indicatorContainerSlot,
115
- indicatorSeparator: indicatorSeparatorSlot,
116
- input: inputSlot,
117
- menu: menuSlot,
118
- menuPortal: menuPortalSlot,
119
- multiValue: multiValueSlot,
120
- multiValueLabel: multiValueLabelSlot,
121
- multiValueRemove: multiValueRemoveSlot,
122
- noOptionsMessage: noOptionsMessageSlot,
123
- option: optionSlot,
124
- placeholder: placeholderSlot,
125
- singleValue: singleValueSlot,
126
- valueContainer: valueContainerSlot
127
- } = selectVariants({ invalid });
128
- return /* @__PURE__ */ jsx(
129
- Controller,
130
- {
131
- control,
132
- name,
133
- render: ({
134
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
135
- field: { onChange, value, ref, onBlur }
136
- }) => /* @__PURE__ */ jsxs("div", { className: cn(className, "mt-2"), "data-testid": `${testId}_select`, children: [
137
- label && /* @__PURE__ */ jsxs(
138
- "label",
139
- {
140
- htmlFor: `react-select-${name}-input`,
141
- className: `${getLabelProps().className} !pointer-events-auto !static -mb-1 ml-1`,
142
- children: [
143
- label,
144
- /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
145
- ]
146
- }
147
- ),
148
- /* @__PURE__ */ jsx(
149
- ReactSelect,
150
- {
151
- "aria-errormessage": "",
152
- "aria-invalid": invalid,
153
- "data-testid": `${testId}_select`,
154
- ...() => {
155
- const { className: _className, ...rest } = getTriggerProps();
156
- return rest;
157
- },
158
- "aria-labelledby": getTriggerProps()["aria-labelledby"]?.split(" ")[1],
159
- classNames: {
160
- control: ({ isFocused }) => (
161
- // border focus style
162
- controlSlot({
163
- className: !invalid && isFocused && "!border-primary"
164
- })
165
- ),
166
- placeholder: () => placeholderSlot(),
167
- input: () => inputSlot(),
168
- valueContainer: () => valueContainerSlot(),
169
- singleValue: () => singleValueSlot({
170
- className: `${getValueProps().className}`
171
- }),
172
- multiValue: () => multiValueSlot(),
173
- multiValueLabel: () => multiValueLabelSlot({
174
- className: `${getValueProps().className}`
175
- }),
176
- multiValueRemove: () => multiValueRemoveSlot(),
177
- indicatorsContainer: () => indicatorContainerSlot(),
178
- clearIndicator: () => clearIndicatorSlot(),
179
- indicatorSeparator: () => indicatorSeparatorSlot(),
180
- dropdownIndicator: () => dropdownIndicatorSlot(),
181
- menu: () => menuSlot(),
182
- groupHeading: () => groupHeadingSlot(),
183
- option: ({ isFocused, isSelected }) => optionSlot({
184
- focused: isFocused,
185
- optionSelected: isSelected
186
- }),
187
- noOptionsMessage: () => noOptionsMessageSlot(),
188
- menuPortal: () => menuPortalSlot()
189
- },
190
- components: {
191
- Input: InputComponent,
192
- Option: OptionComponent,
193
- DropdownIndicator: DropdownIndicatorComponent
194
- },
195
- filterOption,
196
- instanceId: name,
197
- inputValue,
198
- isClearable: clearable,
199
- isDisabled: disabled,
200
- isLoading: loading,
201
- isMulti: multiSelect,
202
- options,
203
- placeholder,
204
- unstyled: true,
205
- onChange: (option) => {
206
- if (multiSelect) {
207
- const transformedOptions = [];
208
- option?.forEach((o) => {
209
- transformedOptions.push(o.value);
210
- });
211
- onChange(transformedOptions);
212
- } else {
213
- onChange(option && option.value);
214
- }
215
- },
216
- onInputChange,
217
- menuPortalTarget: document.getElementById("modal_body")?.parentNode?.parentNode || document.body,
218
- value: options.find((option) => option.value === value),
219
- onBlur,
220
- name,
221
- ref
222
- }
223
- ),
224
- error && // eslint-disable-next-line react/jsx-props-no-spreading
225
- /* @__PURE__ */ jsx("div", { ...getHelperWrapperProps(), children: /* @__PURE__ */ jsx("div", { ...getErrorMessageProps(), children: /* @__PURE__ */ jsx(FieldValidationError_default, { error }) }) })
226
- ] })
227
- }
228
- );
229
- };
230
- var Select_default = Select;
231
-
232
- // src/Select/index.ts
233
- var Select_default2 = Select_default;
234
-
235
- export {
236
- Select_default,
237
- Select_default2
238
- };
239
- //# sourceMappingURL=chunk-C2AWFTC5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/Select/Select.tsx","../src/Select/index.ts"],"sourcesContent":["import type { Props } from 'react-select';\n\nimport { Controller } from 'react-hook-form';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\nexport interface SelectProps {\n /** CSS class name */\n className?: string; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\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\nexport const selectVariants = tv({\n slots: {\n clearIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n control:\n 'rounded-lg border-2 border-gray-200 shadow-sm !duration-150 transition-background hover:border-gray-400 motion-reduce:transition-none dark:border-default-200 hover:dark:border-default-400 focus:dark:border-default-400',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-black hover:dark:bg-default-200 hover:dark:text-default-500',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-neutral-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-gray-300 dark:bg-default-300',\n input: 'py-0.5 pl-1',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-gray-200 bg-default-50 p-1 shadow-sm dark:border-gray-900 dark:bg-default-50',\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:\n 'items-center gap-1.5 rounded bg-gray-100 py-0.5 pl-2 pr-1 dark:bg-default-100',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-neutral-500 hover:cursor-pointer hover:border-gray-300 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n noOptionsMessage:\n 'rounded-sm bg-gray-50 p-2 text-neutral-500 dark:bg-default-100',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-neutral-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n variants: {\n invalid: {\n true: {\n control:\n 'border-danger hover:border-danger dark:border-danger hover:dark:border-danger',\n },\n },\n focused: {\n true: {\n option:\n 'bg-gray-100 active:bg-gray-200 dark:bg-default-100 dark:active:bg-default-200',\n },\n },\n optionSelected: {\n true: { option: 'bg-gray-300 dark:bg-default-300' },\n },\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 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 {\n label,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n getHelperWrapperProps,\n getErrorMessageProps,\n } = useSelect({\n isLoading: loading,\n isInvalid: invalid,\n isRequired: required,\n isDisabled: disabled,\n errorMessage: JSON.stringify(error),\n label: _label,\n labelPlacement: 'outside',\n children: [],\n });\n\n const {\n clearIndicator: clearIndicatorSlot,\n control: controlSlot,\n dropdownIndicator: dropdownIndicatorSlot,\n groupHeading: groupHeadingSlot,\n indicatorsContainer: indicatorContainerSlot,\n indicatorSeparator: indicatorSeparatorSlot,\n input: inputSlot,\n menu: menuSlot,\n menuPortal: menuPortalSlot,\n multiValue: multiValueSlot,\n multiValueLabel: multiValueLabelSlot,\n multiValueRemove: multiValueRemoveSlot,\n noOptionsMessage: noOptionsMessageSlot,\n option: optionSlot,\n placeholder: placeholderSlot,\n singleValue: singleValueSlot,\n valueContainer: valueContainerSlot,\n } = selectVariants({ invalid });\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 className={cn(className, 'mt-2')} data-testid={`${testId}_select`}>\n {label && (\n <label\n htmlFor={`react-select-${name}-input`} // {getTriggerProps().id}\n className={`${getLabelProps().className} !pointer-events-auto !static -mb-1 ml-1`}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-invalid={invalid}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n const { className: _className, ...rest } = getTriggerProps();\n return rest;\n }}\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n classNames={{\n control: ({ isFocused }) =>\n // border focus style\n controlSlot({\n className: !invalid && isFocused && '!border-primary',\n }),\n placeholder: () => placeholderSlot(),\n input: () => inputSlot(),\n valueContainer: () => valueContainerSlot(),\n singleValue: () =>\n singleValueSlot({\n className: `${getValueProps().className}`,\n }),\n multiValue: () => multiValueSlot(),\n multiValueLabel: () =>\n multiValueLabelSlot({\n className: `${getValueProps().className}`,\n }),\n multiValueRemove: () => multiValueRemoveSlot(),\n indicatorsContainer: () => indicatorContainerSlot(),\n clearIndicator: () => clearIndicatorSlot(),\n indicatorSeparator: () => indicatorSeparatorSlot(),\n dropdownIndicator: () => dropdownIndicatorSlot(),\n menu: () => menuSlot(),\n groupHeading: () => groupHeadingSlot(),\n option: ({ isFocused, isSelected }) =>\n optionSlot({\n focused: isFocused,\n optionSelected: isSelected,\n }),\n noOptionsMessage: () => noOptionsMessageSlot(),\n menuPortal: () => menuPortalSlot(),\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n filterOption={filterOption}\n instanceId={name}\n inputValue={inputValue}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n options={options}\n placeholder={placeholder}\n unstyled\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 onInputChange={onInputChange}\n // attach menu modal or body so it works in card and modal\n menuPortalTarget={\n (document.getElementById('modal_body')?.parentNode\n ?.parentNode as HTMLElement) || document.body\n }\n value={options.find((option) => option.value === value)}\n onBlur={onBlur}\n name={name}\n ref={ref}\n />\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;;AAEA,SAAS,kBAAkB;AAC3B,OAAO,eAAe,kBAAkB;AAExC,SAAS,iBAAiB;AAE1B,SAAS,IAAI,UAAU;AAiDd,cAuJG,YAvJH;AALT,IAAM,iBAA0C,CAAC,UAAU;AAGzD,QAAM,SAAS,GAAG,MAAM,YAAY,aAAa,CAAC;AAElD,SAAO,oBAAC,WAAW,OAAX,EAAiB,eAAa,QAAS,G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kBAAkB,MAAM,qBAAqB;AAAA,cAC7C,YAAY,MAAM,eAAe;AAAA,YACnC;AAAA,YACA,YAAY;AAAA,cACV,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,mBAAmB;AAAA,YACrB;AAAA,YACA;AAAA,YACA,YAAY;AAAA,YACZ;AAAA,YACA,aAAa;AAAA,YACb,YAAY;AAAA,YACZ,WAAW;AAAA,YACX,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA,UAAQ;AAAA,YACR,UAAU,CAAC,WAAW;AACpB,kBAAI,aAAa;AACf,sBAAM,qBAA+B,CAAC;AAEtC,wBAAQ,QAAQ,CAAC,MAAyB;AACxC,qCAAmB,KAAK,EAAE,KAAK;AAAA,gBACjC,CAAC;AACD,yBAAS,kBAAkB;AAAA,cAC7B,OAAO;AAEL,yBAAS,UAAU,OAAO,KAAK;AAAA,cACjC;AAAA,YACF;AAAA,YACA;AAAA,YAEA,kBACG,SAAS,eAAe,YAAY,GAAG,YACpC,cAA8B,SAAS;AAAA,YAE7C,OAAO,QAAQ,KAAK,CAAC,WAAW,OAAO,UAAU,KAAK;AAAA,YACtD;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACF;AAAA,QACC;AAAA,QAEC,oBAAC,SAAK,GAAG,sBAAsB,GAE7B,8BAAC,SAAK,GAAG,qBAAqB,GAC5B,8BAAC,gCAAqB,OAAc,GACtC,GACF;AAAA,SAEJ;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,iBAAQ;;;ACtTf,IAAOA,kBAAQ;","names":["Select_default"]}
@@ -1,239 +0,0 @@
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 _reacthookform = require('react-hook-form');
13
- var _reactselect = require('react-select'); var _reactselect2 = _interopRequireDefault(_reactselect);
14
- var _select = require('@nextui-org/select');
15
- var _pixelutils = require('@fuf-stack/pixel-utils');
16
- var _jsxruntime = require('react/jsx-runtime');
17
- var InputComponent = (props) => {
18
- const testId = `${props.selectProps["data-testid"]}_input`;
19
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.Input, { "data-testid": testId, ...props });
20
- };
21
- var OptionComponent = (props) => {
22
- 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])))}`;
23
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-testid": testId, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.Option, { ...props }) });
24
- };
25
- var DropdownIndicatorComponent = (props) => {
26
- const testId = _optionalChain([props, 'optionalAccess', _5 => _5.selectProps, 'access', _6 => _6["data-testid"]]);
27
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-testid": `${testId}_dropdown`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactselect.components.DropdownIndicator, { ...props }) });
28
- };
29
- var selectVariants = _pixelutils.tv.call(void 0, {
30
- slots: {
31
- clearIndicator: "rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500",
32
- control: "rounded-lg border-2 border-gray-200 shadow-sm !duration-150 transition-background hover:border-gray-400 motion-reduce:transition-none dark:border-default-200 hover:dark:border-default-400 focus:dark:border-default-400",
33
- crossIcon: "",
34
- downChevron: "",
35
- dropdownIndicator: "rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-black hover:dark:bg-default-200 hover:dark:text-default-500",
36
- group: "",
37
- groupHeading: "mb-1 ml-3 mt-2 text-sm text-neutral-500",
38
- indicatorsContainer: "gap-1 p-1",
39
- indicatorSeparator: "bg-gray-300 dark:bg-default-300",
40
- input: "py-0.5 pl-1",
41
- loadingIndicator: "",
42
- loadingMessage: "",
43
- menu: "mt-2 rounded-xl border border-gray-200 bg-default-50 p-1 shadow-sm dark:border-gray-900 dark:bg-default-50",
44
- menuList: "",
45
- // ensure menu has same z-index as modal so it is visible when rendered in modal
46
- // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)
47
- menuPortal: "!z-50",
48
- multiValue: "items-center gap-1.5 rounded bg-gray-100 py-0.5 pl-2 pr-1 dark:bg-default-100",
49
- multiValueContainer: "",
50
- multiValueLabel: "py-0.5 leading-6",
51
- multiValueRemove: "rounded text-neutral-500 hover:cursor-pointer hover:border-gray-300 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500",
52
- noOptionsMessage: "rounded-sm bg-gray-50 p-2 text-neutral-500 dark:bg-default-100",
53
- option: "rounded px-3 py-2 hover:cursor-pointer",
54
- placeholder: "py-0.5 pl-1 text-neutral-500",
55
- selectContainer: "",
56
- singleValue: "!ml-1 !leading-7",
57
- valueContainer: "gap-1 p-1"
58
- },
59
- variants: {
60
- invalid: {
61
- true: {
62
- control: "border-danger hover:border-danger dark:border-danger hover:dark:border-danger"
63
- }
64
- },
65
- focused: {
66
- true: {
67
- option: "bg-gray-100 active:bg-gray-200 dark:bg-default-100 dark:active:bg-default-200"
68
- }
69
- },
70
- optionSelected: {
71
- true: { option: "bg-gray-300 dark:bg-default-300" }
72
- }
73
- }
74
- });
75
- var Select = ({
76
- className = void 0,
77
- clearable = true,
78
- disabled = false,
79
- filterOption = void 0,
80
- inputValue = void 0,
81
- label: _label = void 0,
82
- loading = false,
83
- multiSelect = false,
84
- name,
85
- onInputChange = void 0,
86
- options,
87
- placeholder = void 0,
88
- testId: _testId = void 0
89
- }) => {
90
- const { control, getFieldState } = _chunkLDCRR7FPcjs.useFormContext.call(void 0, );
91
- const { error, invalid, required, testId } = getFieldState(name, _testId);
92
- const {
93
- label,
94
- getLabelProps,
95
- getTriggerProps,
96
- getValueProps,
97
- getHelperWrapperProps,
98
- getErrorMessageProps
99
- } = _select.useSelect.call(void 0, {
100
- isLoading: loading,
101
- isInvalid: invalid,
102
- isRequired: required,
103
- isDisabled: disabled,
104
- errorMessage: JSON.stringify(error),
105
- label: _label,
106
- labelPlacement: "outside",
107
- children: []
108
- });
109
- const {
110
- clearIndicator: clearIndicatorSlot,
111
- control: controlSlot,
112
- dropdownIndicator: dropdownIndicatorSlot,
113
- groupHeading: groupHeadingSlot,
114
- indicatorsContainer: indicatorContainerSlot,
115
- indicatorSeparator: indicatorSeparatorSlot,
116
- input: inputSlot,
117
- menu: menuSlot,
118
- menuPortal: menuPortalSlot,
119
- multiValue: multiValueSlot,
120
- multiValueLabel: multiValueLabelSlot,
121
- multiValueRemove: multiValueRemoveSlot,
122
- noOptionsMessage: noOptionsMessageSlot,
123
- option: optionSlot,
124
- placeholder: placeholderSlot,
125
- singleValue: singleValueSlot,
126
- valueContainer: valueContainerSlot
127
- } = selectVariants({ invalid });
128
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
129
- _reacthookform.Controller,
130
- {
131
- control,
132
- name,
133
- render: ({
134
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
135
- field: { onChange, value, ref, onBlur }
136
- }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _pixelutils.cn.call(void 0, className, "mt-2"), "data-testid": `${testId}_select`, children: [
137
- label && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
138
- "label",
139
- {
140
- htmlFor: `react-select-${name}-input`,
141
- className: `${getLabelProps().className} !pointer-events-auto !static -mb-1 ml-1`,
142
- children: [
143
- label,
144
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkKMMS4G7Acjs.FieldCopyTestIdButton_default, { testId })
145
- ]
146
- }
147
- ),
148
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
149
- _reactselect2.default,
150
- {
151
- "aria-errormessage": "",
152
- "aria-invalid": invalid,
153
- "data-testid": `${testId}_select`,
154
- ...() => {
155
- const { className: _className, ...rest } = getTriggerProps();
156
- return rest;
157
- },
158
- "aria-labelledby": _optionalChain([getTriggerProps, 'call', _7 => _7(), 'access', _8 => _8["aria-labelledby"], 'optionalAccess', _9 => _9.split, 'call', _10 => _10(" "), 'access', _11 => _11[1]]),
159
- classNames: {
160
- control: ({ isFocused }) => (
161
- // border focus style
162
- controlSlot({
163
- className: !invalid && isFocused && "!border-primary"
164
- })
165
- ),
166
- placeholder: () => placeholderSlot(),
167
- input: () => inputSlot(),
168
- valueContainer: () => valueContainerSlot(),
169
- singleValue: () => singleValueSlot({
170
- className: `${getValueProps().className}`
171
- }),
172
- multiValue: () => multiValueSlot(),
173
- multiValueLabel: () => multiValueLabelSlot({
174
- className: `${getValueProps().className}`
175
- }),
176
- multiValueRemove: () => multiValueRemoveSlot(),
177
- indicatorsContainer: () => indicatorContainerSlot(),
178
- clearIndicator: () => clearIndicatorSlot(),
179
- indicatorSeparator: () => indicatorSeparatorSlot(),
180
- dropdownIndicator: () => dropdownIndicatorSlot(),
181
- menu: () => menuSlot(),
182
- groupHeading: () => groupHeadingSlot(),
183
- option: ({ isFocused, isSelected }) => optionSlot({
184
- focused: isFocused,
185
- optionSelected: isSelected
186
- }),
187
- noOptionsMessage: () => noOptionsMessageSlot(),
188
- menuPortal: () => menuPortalSlot()
189
- },
190
- components: {
191
- Input: InputComponent,
192
- Option: OptionComponent,
193
- DropdownIndicator: DropdownIndicatorComponent
194
- },
195
- filterOption,
196
- instanceId: name,
197
- inputValue,
198
- isClearable: clearable,
199
- isDisabled: disabled,
200
- isLoading: loading,
201
- isMulti: multiSelect,
202
- options,
203
- placeholder,
204
- unstyled: true,
205
- onChange: (option) => {
206
- if (multiSelect) {
207
- const transformedOptions = [];
208
- _optionalChain([option, 'optionalAccess', _12 => _12.forEach, 'call', _13 => _13((o) => {
209
- transformedOptions.push(o.value);
210
- })]);
211
- onChange(transformedOptions);
212
- } else {
213
- onChange(option && option.value);
214
- }
215
- },
216
- onInputChange,
217
- menuPortalTarget: _optionalChain([document, 'access', _14 => _14.getElementById, 'call', _15 => _15("modal_body"), 'optionalAccess', _16 => _16.parentNode, 'optionalAccess', _17 => _17.parentNode]) || document.body,
218
- value: options.find((option) => option.value === value),
219
- onBlur,
220
- name,
221
- ref
222
- }
223
- ),
224
- error && // eslint-disable-next-line react/jsx-props-no-spreading
225
- /* @__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 }) }) })
226
- ] })
227
- }
228
- );
229
- };
230
- var Select_default = Select;
231
-
232
- // src/Select/index.ts
233
- var Select_default2 = Select_default;
234
-
235
-
236
-
237
-
238
- exports.Select_default = Select_default; exports.Select_default2 = Select_default2;
239
- //# sourceMappingURL=chunk-WCQYZ5RI.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-WCQYZ5RI.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["Select_default"],"mappings":"A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YAAA;AAAA,UAAA;AACF,QAAA;AACC,QAAA;AAEC,wBAAA;AAOJ,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;ADtFW;AACA;AEjOXA;AFmOW;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-WCQYZ5RI.cjs","sourcesContent":[null,"import type { Props } from 'react-select';\n\nimport { Controller } from 'react-hook-form';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\nexport interface SelectProps {\n /** CSS class name */\n className?: string; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\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\nexport const selectVariants = tv({\n slots: {\n clearIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n control:\n 'rounded-lg border-2 border-gray-200 shadow-sm !duration-150 transition-background hover:border-gray-400 motion-reduce:transition-none dark:border-default-200 hover:dark:border-default-400 focus:dark:border-default-400',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-neutral-500 hover:cursor-pointer hover:bg-gray-200 hover:text-black hover:dark:bg-default-200 hover:dark:text-default-500',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-neutral-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-gray-300 dark:bg-default-300',\n input: 'py-0.5 pl-1',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-gray-200 bg-default-50 p-1 shadow-sm dark:border-gray-900 dark:bg-default-50',\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:\n 'items-center gap-1.5 rounded bg-gray-100 py-0.5 pl-2 pr-1 dark:bg-default-100',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-neutral-500 hover:cursor-pointer hover:border-gray-300 hover:text-neutral-800 hover:dark:bg-default-200 hover:dark:text-default-500',\n noOptionsMessage:\n 'rounded-sm bg-gray-50 p-2 text-neutral-500 dark:bg-default-100',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-neutral-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n variants: {\n invalid: {\n true: {\n control:\n 'border-danger hover:border-danger dark:border-danger hover:dark:border-danger',\n },\n },\n focused: {\n true: {\n option:\n 'bg-gray-100 active:bg-gray-200 dark:bg-default-100 dark:active:bg-default-200',\n },\n },\n optionSelected: {\n true: { option: 'bg-gray-300 dark:bg-default-300' },\n },\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 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 {\n label,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n getHelperWrapperProps,\n getErrorMessageProps,\n } = useSelect({\n isLoading: loading,\n isInvalid: invalid,\n isRequired: required,\n isDisabled: disabled,\n errorMessage: JSON.stringify(error),\n label: _label,\n labelPlacement: 'outside',\n children: [],\n });\n\n const {\n clearIndicator: clearIndicatorSlot,\n control: controlSlot,\n dropdownIndicator: dropdownIndicatorSlot,\n groupHeading: groupHeadingSlot,\n indicatorsContainer: indicatorContainerSlot,\n indicatorSeparator: indicatorSeparatorSlot,\n input: inputSlot,\n menu: menuSlot,\n menuPortal: menuPortalSlot,\n multiValue: multiValueSlot,\n multiValueLabel: multiValueLabelSlot,\n multiValueRemove: multiValueRemoveSlot,\n noOptionsMessage: noOptionsMessageSlot,\n option: optionSlot,\n placeholder: placeholderSlot,\n singleValue: singleValueSlot,\n valueContainer: valueContainerSlot,\n } = selectVariants({ invalid });\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 className={cn(className, 'mt-2')} data-testid={`${testId}_select`}>\n {label && (\n <label\n htmlFor={`react-select-${name}-input`} // {getTriggerProps().id}\n className={`${getLabelProps().className} !pointer-events-auto !static -mb-1 ml-1`}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-invalid={invalid}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention\n const { className: _className, ...rest } = getTriggerProps();\n return rest;\n }}\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n classNames={{\n control: ({ isFocused }) =>\n // border focus style\n controlSlot({\n className: !invalid && isFocused && '!border-primary',\n }),\n placeholder: () => placeholderSlot(),\n input: () => inputSlot(),\n valueContainer: () => valueContainerSlot(),\n singleValue: () =>\n singleValueSlot({\n className: `${getValueProps().className}`,\n }),\n multiValue: () => multiValueSlot(),\n multiValueLabel: () =>\n multiValueLabelSlot({\n className: `${getValueProps().className}`,\n }),\n multiValueRemove: () => multiValueRemoveSlot(),\n indicatorsContainer: () => indicatorContainerSlot(),\n clearIndicator: () => clearIndicatorSlot(),\n indicatorSeparator: () => indicatorSeparatorSlot(),\n dropdownIndicator: () => dropdownIndicatorSlot(),\n menu: () => menuSlot(),\n groupHeading: () => groupHeadingSlot(),\n option: ({ isFocused, isSelected }) =>\n optionSlot({\n focused: isFocused,\n optionSelected: isSelected,\n }),\n noOptionsMessage: () => noOptionsMessageSlot(),\n menuPortal: () => menuPortalSlot(),\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n filterOption={filterOption}\n instanceId={name}\n inputValue={inputValue}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n options={options}\n placeholder={placeholder}\n unstyled\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 onInputChange={onInputChange}\n // attach menu modal or body so it works in card and modal\n menuPortalTarget={\n (document.getElementById('modal_body')?.parentNode\n ?.parentNode as HTMLElement) || document.body\n }\n value={options.find((option) => option.value === value)}\n onBlur={onBlur}\n name={name}\n ref={ref}\n />\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"]}