@fuf-stack/uniform 0.9.3 → 0.9.5
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-zUYKczzn.d.cts → Select-C08Oftdr.d.cts} +3 -0
- package/dist/{Select-zUYKczzn.d.ts → Select-C08Oftdr.d.ts} +3 -0
- package/dist/Switch/index.cjs +2 -2
- package/dist/Switch/index.d.cts +2 -2
- package/dist/Switch/index.d.ts +2 -2
- package/dist/Switch/index.js +1 -1
- package/dist/{Switch-DmjDKgKs.d.cts → Switch-OkO3GdPy.d.cts} +2 -2
- package/dist/{Switch-DmjDKgKs.d.ts → Switch-OkO3GdPy.d.ts} +2 -2
- package/dist/{chunk-ZOVKQ7MN.js → chunk-AVKEYJH7.js} +2 -2
- package/dist/chunk-AVKEYJH7.js.map +1 -0
- package/dist/{chunk-VEYDHNYQ.js → chunk-I5M2A3MN.js} +8 -3
- package/dist/chunk-I5M2A3MN.js.map +1 -0
- package/dist/{chunk-3XNW2VQ7.cjs → chunk-INTLZONV.cjs} +2 -2
- package/dist/chunk-INTLZONV.cjs.map +1 -0
- package/dist/{chunk-CVLA7A3Y.cjs → chunk-QVBZ5RLN.cjs} +8 -3
- package/dist/chunk-QVBZ5RLN.cjs.map +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/package.json +4 -4
- package/dist/chunk-3XNW2VQ7.cjs.map +0 -1
- package/dist/chunk-CVLA7A3Y.cjs.map +0 -1
- package/dist/chunk-VEYDHNYQ.js.map +0 -1
- package/dist/chunk-ZOVKQ7MN.js.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 _chunkQVBZ5RLNcjs = require('../chunk-QVBZ5RLN.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 = _chunkQVBZ5RLNcjs.Select_default; exports.default = _chunkQVBZ5RLNcjs.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
|
@@ -28,6 +28,7 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
28
28
|
loadingMessage: string;
|
|
29
29
|
menu: string;
|
|
30
30
|
menuList: string;
|
|
31
|
+
menuPortal: string;
|
|
31
32
|
multiValue: string;
|
|
32
33
|
multiValueContainer: string;
|
|
33
34
|
multiValueLabel: string;
|
|
@@ -76,6 +77,7 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
76
77
|
loadingMessage: string;
|
|
77
78
|
menu: string;
|
|
78
79
|
menuList: string;
|
|
80
|
+
menuPortal: string;
|
|
79
81
|
multiValue: string;
|
|
80
82
|
multiValueContainer: string;
|
|
81
83
|
multiValueLabel: string;
|
|
@@ -112,6 +114,7 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
112
114
|
loadingMessage: string;
|
|
113
115
|
menu: string;
|
|
114
116
|
menuList: string;
|
|
117
|
+
menuPortal: string;
|
|
115
118
|
multiValue: string;
|
|
116
119
|
multiValueContainer: string;
|
|
117
120
|
multiValueLabel: string;
|
|
@@ -28,6 +28,7 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
28
28
|
loadingMessage: string;
|
|
29
29
|
menu: string;
|
|
30
30
|
menuList: string;
|
|
31
|
+
menuPortal: string;
|
|
31
32
|
multiValue: string;
|
|
32
33
|
multiValueContainer: string;
|
|
33
34
|
multiValueLabel: string;
|
|
@@ -76,6 +77,7 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
76
77
|
loadingMessage: string;
|
|
77
78
|
menu: string;
|
|
78
79
|
menuList: string;
|
|
80
|
+
menuPortal: string;
|
|
79
81
|
multiValue: string;
|
|
80
82
|
multiValueContainer: string;
|
|
81
83
|
multiValueLabel: string;
|
|
@@ -112,6 +114,7 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
112
114
|
loadingMessage: string;
|
|
113
115
|
menu: string;
|
|
114
116
|
menuList: string;
|
|
117
|
+
menuPortal: string;
|
|
115
118
|
multiValue: string;
|
|
116
119
|
multiValueContainer: string;
|
|
117
120
|
multiValueLabel: string;
|
package/dist/Switch/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 _chunkINTLZONVcjs = require('../chunk-INTLZONV.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.Switch =
|
|
12
|
+
exports.Switch = _chunkINTLZONVcjs.Switch_default; exports.default = _chunkINTLZONVcjs.Switch_default2;
|
|
13
13
|
//# sourceMappingURL=index.cjs.map
|
package/dist/Switch/index.d.cts
CHANGED
package/dist/Switch/index.d.ts
CHANGED
package/dist/Switch/index.js
CHANGED
|
@@ -2,11 +2,11 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
|
|
3
3
|
interface SwitchProps {
|
|
4
4
|
/** CSS class name */
|
|
5
|
-
className
|
|
5
|
+
className?: string;
|
|
6
6
|
/** whether the select should be disabled */
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
/** component displayed next to the switch. */
|
|
9
|
-
label
|
|
9
|
+
label?: React.ReactNode;
|
|
10
10
|
/** name the field is registered under */
|
|
11
11
|
name: string;
|
|
12
12
|
/** HTML data-testid attribute used in e2e tests */
|
|
@@ -2,11 +2,11 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
|
|
3
3
|
interface SwitchProps {
|
|
4
4
|
/** CSS class name */
|
|
5
|
-
className
|
|
5
|
+
className?: string;
|
|
6
6
|
/** whether the select should be disabled */
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
/** component displayed next to the switch. */
|
|
9
|
-
label
|
|
9
|
+
label?: React.ReactNode;
|
|
10
10
|
/** name the field is registered under */
|
|
11
11
|
name: string;
|
|
12
12
|
/** HTML data-testid attribute used in e2e tests */
|
|
@@ -14,7 +14,7 @@ import { useInput } from "@nextui-org/input";
|
|
|
14
14
|
import { Switch as NextSwitch } from "@nextui-org/switch";
|
|
15
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
var Switch = ({
|
|
17
|
-
className,
|
|
17
|
+
className = void 0,
|
|
18
18
|
disabled = false,
|
|
19
19
|
label: _label = void 0,
|
|
20
20
|
name,
|
|
@@ -78,4 +78,4 @@ export {
|
|
|
78
78
|
Switch_default,
|
|
79
79
|
Switch_default2
|
|
80
80
|
};
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-AVKEYJH7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Switch/Switch.tsx","../src/Switch/index.ts"],"sourcesContent":["import { Controller } from 'react-hook-form';\n\nimport { useInput } from '@nextui-org/input';\nimport { Switch as NextSwitch } from '@nextui-org/switch';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface SwitchProps {\n /** CSS class name */\n className?: string;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** component displayed next to the switch. */\n label?: React.ReactNode;\n /** name the field is registered under */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Switch component based on [NextUI Switch](https://nextui.org/docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n disabled = false,\n label: _label = undefined,\n name,\n testId: _testId = undefined,\n}: SwitchProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { label, getInputProps, getHelperWrapperProps, getErrorMessageProps } =\n useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n name={name}\n control={control}\n disabled={disabled}\n render={({\n field: { disabled: isDisabled, value, ref, onBlur, onChange },\n }) => (\n <>\n <NextSwitch\n aria-describedby={getInputProps()['aria-describedby']}\n required={required}\n isSelected={!!value}\n className={className}\n classNames={{\n label: `text-bold block text-ellipsis text-small ${invalid ? 'text-danger' : ''}`,\n }}\n data-testid={testId}\n isDisabled={isDisabled}\n value={value}\n onChange={onChange}\n onBlur={onBlur}\n name={name}\n ref={ref}\n >\n {label}\n {!!required && !!_label && (\n <span className=\"!text-danger\">{' \\u002A'}</span>\n )}\n <FieldCopyTestIdButton testId={testId} />\n </NextSwitch>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </>\n )}\n />\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AACzB,SAAS,UAAU,kBAAkB;AAkD7B,mBAmBM,KAlBJ,YADF;AA5BR,IAAM,SAAS,CAAC;AAAA,EACd,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,OAAO,SAAS;AAAA,EAChB;AAAA,EACA,QAAQ,UAAU;AACpB,MAAmB;AACjB,QAAM,EAAE,SAAS,cAAc,IAAI,eAAe;AAClD,QAAM,EAAE,OAAO,UAAU,QAAQ,QAAQ,IAAI,cAAc,MAAM,OAAO;AAExE,QAAM,EAAE,OAAO,eAAe,uBAAuB,qBAAqB,IACxE,SAAS;AAAA,IACP,cAAc,KAAK,UAAU,KAAK;AAAA,IAClC,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,aAAa;AAAA,EACf,CAAC;AAEH,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,CAAC;AAAA,QACP,OAAO,EAAE,UAAU,YAAY,OAAO,KAAK,QAAQ,SAAS;AAAA,MAC9D,MACE,iCACE;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,oBAAkB,cAAc,EAAE,kBAAkB;AAAA,YACpD;AAAA,YACA,YAAY,CAAC,CAAC;AAAA,YACd;AAAA,YACA,YAAY;AAAA,cACV,OAAO,4CAA4C,UAAU,gBAAgB,EAAE;AAAA,YACjF;AAAA,YACA,eAAa;AAAA,YACb;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YAEC;AAAA;AAAA,cACA,CAAC,CAAC,YAAY,CAAC,CAAC,UACf,oBAAC,UAAK,WAAU,gBAAgB,gBAAU;AAAA,cAE5C,oBAAC,iCAAsB,QAAgB;AAAA;AAAA;AAAA,QACzC;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;;;ACrFf,IAAOA,kBAAQ;","names":["Switch_default"]}
|
|
@@ -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: "",
|
|
@@ -32,8 +32,11 @@ var selectVariants = tv({
|
|
|
32
32
|
label: "!pointer-events-auto relative bottom-2 ml-1 inline",
|
|
33
33
|
loadingIndicator: "",
|
|
34
34
|
loadingMessage: "",
|
|
35
|
-
menu: "mt-2 rounded-xl border border-default-200 bg-
|
|
35
|
+
menu: "mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg",
|
|
36
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",
|
|
37
40
|
multiValue: "items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1",
|
|
38
41
|
multiValueContainer: "",
|
|
39
42
|
multiValueLabel: "py-0.5 leading-6",
|
|
@@ -153,6 +156,8 @@ var Select = ({
|
|
|
153
156
|
indicatorSeparator: () => classNames.indicatorSeparator,
|
|
154
157
|
input: () => classNames.input,
|
|
155
158
|
menu: () => classNames.menu,
|
|
159
|
+
menuList: () => classNames.menuList,
|
|
160
|
+
menuPortal: () => classNames.menuPortal,
|
|
156
161
|
multiValue: () => classNames.multiValue,
|
|
157
162
|
multiValueLabel: () => cn(
|
|
158
163
|
classNames.multiValueLabel,
|
|
@@ -232,4 +237,4 @@ export {
|
|
|
232
237
|
Select_default,
|
|
233
238
|
Select_default2
|
|
234
239
|
};
|
|
235
|
-
//# sourceMappingURL=chunk-
|
|
240
|
+
//# sourceMappingURL=chunk-I5M2A3MN.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-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: '!z-50',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-foreground-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n variants: {\n invalid: {\n true: {\n control: 'border-danger hover:border-danger',\n },\n },\n },\n});\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n formatOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_input`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_option_${props?.data?.testId ?? props?.data?.value}`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n formatOptionLabel = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const variants = selectVariants({ invalid });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getMainWrapperProps,\n getTriggerProps,\n getValueProps,\n label,\n } = useSelect({\n children: [],\n classNames,\n errorMessage: JSON.stringify(error),\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n control={control}\n name={name}\n render={({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n field: { onChange, value, ref, onBlur },\n }) => (\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(classNames.base, 'group mt-2')}\n data-testid={testId}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getMainWrapperProps()}>\n <div className=\"relative\">\n {label && (\n <label\n htmlFor={`react-select-${name}-input`}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n aria-invalid={invalid}\n classNames={{\n control: () =>\n cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n }),\n clearIndicator: () => classNames.clearIndicator,\n dropdownIndicator: () => classNames.dropdownIndicator,\n groupHeading: () => classNames.groupHeading,\n indicatorsContainer: () => classNames.indicatorsContainer,\n indicatorSeparator: () => classNames.indicatorSeparator,\n input: () => classNames.input,\n menu: () => classNames.menu,\n menuList: () => classNames.menuList,\n menuPortal: () => classNames.menuPortal,\n multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(\n classNames.multiValueLabel,\n `${getValueProps().className}`,\n ),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n filterOption={filterOption}\n formatOptionLabel={formatOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n options={options}\n placeholder={placeholder}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n const transformedOptions: string[] = [];\n // @ts-expect-error in this case option is an array.\n option?.forEach((o: { value: string }) => {\n transformedOptions.push(o.value);\n });\n onChange(transformedOptions);\n } else {\n // @ts-expect-error in this case option is of type SelectOption and has the property value.\n onChange(option && option.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n onInputChange={onInputChange}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n unstyled\n />\n </div>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;;AAGA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,OAAO,eAAe,kBAAkB;AAExC,SAAS,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;AAElD,SAAO,oBAAC,WAAW,OAAX,EAAiB,eAAa,QAAS,GAAG,OAAO;AAC3D;AAEA,IAAM,kBAA4C,CAAC,UAAU;AAG3D,QAAM,SAAS,GAAG,M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,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"]}
|
|
@@ -14,7 +14,7 @@ var _input = require('@nextui-org/input');
|
|
|
14
14
|
var _switch = require('@nextui-org/switch');
|
|
15
15
|
var _jsxruntime = require('react/jsx-runtime');
|
|
16
16
|
var Switch = ({
|
|
17
|
-
className,
|
|
17
|
+
className = void 0,
|
|
18
18
|
disabled = false,
|
|
19
19
|
label: _label = void 0,
|
|
20
20
|
name,
|
|
@@ -78,4 +78,4 @@ var Switch_default2 = Switch_default;
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
exports.Switch_default = Switch_default; exports.Switch_default2 = Switch_default2;
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
81
|
+
//# sourceMappingURL=chunk-INTLZONV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-INTLZONV.cjs","../src/Switch/Switch.tsx","../src/Switch/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,gDAA2B;AAE3B,0CAAyB;AACzB,4CAAqC;AAkD7B,+CAAA;AA5BR,IAAM,OAAA,EAAS,CAAC;AAAA,EACd,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,SAAA,EAAW,KAAA;AAAA,EACX,KAAA,EAAO,OAAA,EAAS,KAAA,CAAA;AAAA,EAChB,IAAA;AAAA,EACA,MAAA,EAAQ,QAAA,EAAU,KAAA;AACpB,CAAA,EAAA,GAAmB;AACjB,EAAA,MAAM,EAAE,OAAA,EAAS,c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AACzC,QAAA;AACC,wBAAA;AAOC,MAAA;AAEJ,IAAA;AAAA,EAAA;AAIR;AAEA;ADnBA;AACA;AEnEA;AFqEA;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-INTLZONV.cjs","sourcesContent":[null,"import { Controller } from 'react-hook-form';\n\nimport { useInput } from '@nextui-org/input';\nimport { Switch as NextSwitch } from '@nextui-org/switch';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface SwitchProps {\n /** CSS class name */\n className?: string;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** component displayed next to the switch. */\n label?: React.ReactNode;\n /** name the field is registered under */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Switch component based on [NextUI Switch](https://nextui.org/docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n disabled = false,\n label: _label = undefined,\n name,\n testId: _testId = undefined,\n}: SwitchProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { label, getInputProps, getHelperWrapperProps, getErrorMessageProps } =\n useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n name={name}\n control={control}\n disabled={disabled}\n render={({\n field: { disabled: isDisabled, value, ref, onBlur, onChange },\n }) => (\n <>\n <NextSwitch\n aria-describedby={getInputProps()['aria-describedby']}\n required={required}\n isSelected={!!value}\n className={className}\n classNames={{\n label: `text-bold block text-ellipsis text-small ${invalid ? 'text-danger' : ''}`,\n }}\n data-testid={testId}\n isDisabled={isDisabled}\n value={value}\n onChange={onChange}\n onBlur={onBlur}\n name={name}\n ref={ref}\n >\n {label}\n {!!required && !!_label && (\n <span className=\"!text-danger\">{' \\u002A'}</span>\n )}\n <FieldCopyTestIdButton testId={testId} />\n </NextSwitch>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </>\n )}\n />\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"]}
|
|
@@ -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: "",
|
|
@@ -32,8 +32,11 @@ var selectVariants = _pixelutils.tv.call(void 0, {
|
|
|
32
32
|
label: "!pointer-events-auto relative bottom-2 ml-1 inline",
|
|
33
33
|
loadingIndicator: "",
|
|
34
34
|
loadingMessage: "",
|
|
35
|
-
menu: "mt-2 rounded-xl border border-default-200 bg-
|
|
35
|
+
menu: "mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg",
|
|
36
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",
|
|
37
40
|
multiValue: "items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1",
|
|
38
41
|
multiValueContainer: "",
|
|
39
42
|
multiValueLabel: "py-0.5 leading-6",
|
|
@@ -153,6 +156,8 @@ var Select = ({
|
|
|
153
156
|
indicatorSeparator: () => classNames.indicatorSeparator,
|
|
154
157
|
input: () => classNames.input,
|
|
155
158
|
menu: () => classNames.menu,
|
|
159
|
+
menuList: () => classNames.menuList,
|
|
160
|
+
menuPortal: () => classNames.menuPortal,
|
|
156
161
|
multiValue: () => classNames.multiValue,
|
|
157
162
|
multiValueLabel: () => _pixelutils.cn.call(void 0,
|
|
158
163
|
classNames.multiValueLabel,
|
|
@@ -232,4 +237,4 @@ var Select_default2 = Select_default;
|
|
|
232
237
|
|
|
233
238
|
|
|
234
239
|
exports.Select_default = Select_default; exports.Select_default2 = Select_default2;
|
|
235
|
-
//# sourceMappingURL=chunk-
|
|
240
|
+
//# sourceMappingURL=chunk-QVBZ5RLN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-QVBZ5RLN.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["Select_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACPA,8BAAyB;AACzB,gDAA2B;AAC3B,qGAAwC;AAExC,4CAA0B;AAE1B,oDAA6C;AAsGpC,+CAAA;AAhGF,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,EAAA;AAAA,IACN,cAAA,EACE,wGAAA;AAAA,IACF,OAAA,EACE,mIAAA;AAAA,IACF,eAAA,EAAiB,qCAAA;AAAA,IACjB,SAAA,EAAW,EAAA;AAAA,IACX,WAAA,EAAa,EAAA;AAAA,IACb,iBAAA,EACE,+FAAA;AAAA,IACF,KAAA,EAAO,EAAA;AAAA,IACP,YAAA,EAAc,4CAAA;AAAA,IACd,mBAAA,EAAqB,WAAA;AAAA,IACrB,kBAAA,EAAoB,gBAAA;AAAA,IACpB,KAAA,EAAO,aAAA;AAAA,IACP,KAAA,EAAO,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AA;AACE,wBAAA;AAA+B,sBAAA;AAEjC,sBAAA;AAA2B,oBAAA;AAG3B,sBAAA;AAA+B,oBAAA;AAEnC,kBAAA;AACA,kBAAA;AACE,oBAAA;AACF,kBAAA;AACA,kBAAA;AACA,kBAAA;AAEA,kBAAA;AACA,kBAAA;AAAQ,gBAAA;AACV,cAAA;AACF,YAAA;AACC,YAAA;AAEC,4BAAA;AAOJ,UAAA;AAAA,QAAA;AACF,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;ADzFW;AACA;AElOXA;AFoOW;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-QVBZ5RLN.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { Props } from 'react-select';\n\nimport { useState } from 'react';\nimport { Controller } from 'react-hook-form';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const selectVariants = tv({\n slots: {\n base: '',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 motion-reduce:transition-none',\n control_focused: 'border-primary hover:border-primary',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\n label: '!pointer-events-auto relative bottom-2 ml-1 inline',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: '!z-50',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'py-0.5 pl-1 text-foreground-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n variants: {\n invalid: {\n true: {\n control: 'border-danger hover:border-danger',\n },\n },\n },\n});\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n formatOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_input`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_option_${props?.data?.testId ?? props?.data?.value}`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n formatOptionLabel = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const variants = selectVariants({ invalid });\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getMainWrapperProps,\n getTriggerProps,\n getValueProps,\n label,\n } = useSelect({\n children: [],\n classNames,\n errorMessage: JSON.stringify(error),\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n control={control}\n name={name}\n render={({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n field: { onChange, value, ref, onBlur },\n }) => (\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(classNames.base, 'group mt-2')}\n data-testid={testId}\n >\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getMainWrapperProps()}>\n <div className=\"relative\">\n {label && (\n <label\n htmlFor={`react-select-${name}-input`}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {label}\n <FieldCopyTestIdButton testId={testId} />\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n aria-invalid={invalid}\n classNames={{\n control: () =>\n cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n }),\n clearIndicator: () => classNames.clearIndicator,\n dropdownIndicator: () => classNames.dropdownIndicator,\n groupHeading: () => classNames.groupHeading,\n indicatorsContainer: () => classNames.indicatorsContainer,\n indicatorSeparator: () => classNames.indicatorSeparator,\n input: () => classNames.input,\n menu: () => classNames.menu,\n menuList: () => classNames.menuList,\n menuPortal: () => classNames.menuPortal,\n multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(\n classNames.multiValueLabel,\n `${getValueProps().className}`,\n ),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n filterOption={filterOption}\n formatOptionLabel={formatOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n options={options}\n placeholder={placeholder}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n const transformedOptions: string[] = [];\n // @ts-expect-error in this case option is an array.\n option?.forEach((o: { value: string }) => {\n transformedOptions.push(o.value);\n });\n onChange(transformedOptions);\n } else {\n // @ts-expect-error in this case option is of type SelectOption and has the property value.\n onChange(option && option.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n onInputChange={onInputChange}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n unstyled\n />\n </div>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkMKM7ZYRNcjs = require('./chunk-MKM7ZYRN.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkINTLZONVcjs = require('./chunk-INTLZONV.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkOCR2UWG2cjs = require('./chunk-OCR2UWG2.cjs');
|
|
@@ -21,13 +21,13 @@ var _chunkQYZV7ZUYcjs = require('./chunk-QYZV7ZUY.cjs');
|
|
|
21
21
|
var _chunk6GN255GPcjs = require('./chunk-6GN255GP.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _chunkYUAJN6HWcjs = require('./chunk-YUAJN6HW.cjs');
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunk5UHHZ7KYcjs = require('./chunk-5UHHZ7KY.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkQVBZ5RLNcjs = require('./chunk-QVBZ5RLN.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
var _chunkKMMS4G7Acjs = require('./chunk-KMMS4G7A.cjs');
|
|
@@ -57,5 +57,5 @@ var _chunkBBB4FEY6cjs = require('./chunk-BBB4FEY6.cjs');
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
exports.CheckboxGroup = _chunkW24WP5YEcjs.CheckboxGroup_default; exports.FieldArray = _chunkTNELIBCVcjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkKMMS4G7Acjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkQTL5FREEcjs.FieldValidationError_default; exports.Form = _chunkQYZV7ZUYcjs.Form_default; exports.Grid = _chunk6GN255GPcjs.Grid_default; exports.Input = _chunk5UHHZ7KYcjs.Input_default; exports.RadioGroup = _chunkYUAJN6HWcjs.RadioGroup_default; exports.Select =
|
|
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 = _chunkQVBZ5RLNcjs.Select_default; exports.SubmitButton = _chunkMKM7ZYRNcjs.SubmitButton_default; exports.Switch = _chunkINTLZONVcjs.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,9 +8,9 @@ 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
|
-
export { S as Switch, a as SwitchProps } from './Switch-
|
|
13
|
+
export { S as Switch, a as SwitchProps } from './Switch-OkO3GdPy.cjs';
|
|
14
14
|
export { T as TextArea, a as TextAreaProps } from './TextArea-B-sKvTkd.cjs';
|
|
15
15
|
import 'react/jsx-runtime';
|
|
16
16
|
import 'react-hook-form';
|
package/dist/index.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ 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
|
-
export { S as Switch, a as SwitchProps } from './Switch-
|
|
13
|
+
export { S as Switch, a as SwitchProps } from './Switch-OkO3GdPy.js';
|
|
14
14
|
export { T as TextArea, a as TextAreaProps } from './TextArea-B-sKvTkd.js';
|
|
15
15
|
import 'react/jsx-runtime';
|
|
16
16
|
import 'react-hook-form';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-4GVPJYZW.js";
|
|
4
4
|
import {
|
|
5
5
|
Switch_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AVKEYJH7.js";
|
|
7
7
|
import {
|
|
8
8
|
TextArea_default
|
|
9
9
|
} from "./chunk-NHPQEYYN.js";
|
|
@@ -19,15 +19,15 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
Grid_default
|
|
21
21
|
} from "./chunk-PDCEKC3G.js";
|
|
22
|
-
import {
|
|
23
|
-
Input_default
|
|
24
|
-
} from "./chunk-DTSX7YON.js";
|
|
25
22
|
import {
|
|
26
23
|
RadioGroup_default
|
|
27
24
|
} from "./chunk-ARUVDZFG.js";
|
|
25
|
+
import {
|
|
26
|
+
Input_default
|
|
27
|
+
} from "./chunk-DTSX7YON.js";
|
|
28
28
|
import {
|
|
29
29
|
Select_default
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-I5M2A3MN.js";
|
|
31
31
|
import {
|
|
32
32
|
FieldCopyTestIdButton_default
|
|
33
33
|
} from "./chunk-T3CCNJHK.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Hannes Tiede",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/uniform#readme",
|
|
@@ -124,8 +124,8 @@
|
|
|
124
124
|
"react-hook-form": "7.53.0",
|
|
125
125
|
"react-select": "5.8.1",
|
|
126
126
|
"slug": "9.1.0",
|
|
127
|
-
"@fuf-stack/pixel-utils": "0.3.0",
|
|
128
127
|
"@fuf-stack/pixels": "0.24.0",
|
|
128
|
+
"@fuf-stack/pixel-utils": "0.3.0",
|
|
129
129
|
"@fuf-stack/veto": "0.5.0"
|
|
130
130
|
},
|
|
131
131
|
"devDependencies": {
|
|
@@ -135,10 +135,10 @@
|
|
|
135
135
|
"@types/slug": "5.0.9",
|
|
136
136
|
"react": "18.3.1",
|
|
137
137
|
"react-dom": "18.3.1",
|
|
138
|
+
"@repo/storybook-config": "0.0.1",
|
|
138
139
|
"@repo/tailwind-config": "0.0.1",
|
|
139
140
|
"@repo/tsup-config": "0.0.1",
|
|
140
|
-
"@repo/vite-config": "0.0.1"
|
|
141
|
-
"@repo/storybook-config": "0.0.1"
|
|
141
|
+
"@repo/vite-config": "0.0.1"
|
|
142
142
|
},
|
|
143
143
|
"scripts": {
|
|
144
144
|
"build": "tsup --config node_modules/@repo/tsup-config/config.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-3XNW2VQ7.cjs","../src/Switch/Switch.tsx","../src/Switch/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,gDAA2B;AAE3B,0CAAyB;AACzB,4CAAqC;AAkD7B,+CAAA;AA5BR,IAAM,OAAA,EAAS,CAAC;AAAA,EACd,SAAA;AAAA,EACA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B,EAAE,CAAA;AAAA,YAAA;AACjF,YAAA;AACa,YAAA;AACb,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AACA,YAAA;AAEC,cAAA;AAAA,cAAA;AAE2C,8BAAA;AAEL,YAAA;AAAA,UAAA;AAAA,QAAA;AACzC,QAAA;AACC,wBAAA;AAOC,MAAA;AAEJ,IAAA;AAAA,EAAA;AAIR;AAEA;ADnBA;AACA;AEnEA;AFqEA;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-3XNW2VQ7.cjs","sourcesContent":[null,"import { Controller } from 'react-hook-form';\n\nimport { useInput } from '@nextui-org/input';\nimport { Switch as NextSwitch } from '@nextui-org/switch';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface SwitchProps {\n /** CSS class name */\n className: string;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** component displayed next to the switch. */\n label: React.ReactNode;\n /** name the field is registered under */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Switch component based on [NextUI Switch](https://nextui.org/docs/components/switch)\n */\nconst Switch = ({\n className,\n disabled = false,\n label: _label = undefined,\n name,\n testId: _testId = undefined,\n}: SwitchProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { label, getInputProps, getHelperWrapperProps, getErrorMessageProps } =\n useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n name={name}\n control={control}\n disabled={disabled}\n render={({\n field: { disabled: isDisabled, value, ref, onBlur, onChange },\n }) => (\n <>\n <NextSwitch\n aria-describedby={getInputProps()['aria-describedby']}\n required={required}\n isSelected={!!value}\n className={className}\n classNames={{\n label: `text-bold block text-ellipsis text-small ${invalid ? 'text-danger' : ''}`,\n }}\n data-testid={testId}\n isDisabled={isDisabled}\n value={value}\n onChange={onChange}\n onBlur={onBlur}\n name={name}\n ref={ref}\n >\n {label}\n {!!required && !!_label && (\n <span className=\"!text-danger\">{' \\u002A'}</span>\n )}\n <FieldCopyTestIdButton testId={testId} />\n </NextSwitch>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </>\n )}\n />\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-CVLA7A3Y.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;AAmGpC,+CAAA;AA7FF,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,I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oBAAA;AAG3B,sBAAA;AAA+B,oBAAA;AAEnC,kBAAA;AACA,kBAAA;AACE,oBAAA;AACF,kBAAA;AACA,kBAAA;AACA,kBAAA;AAEA,kBAAA;AACA,kBAAA;AAAQ,gBAAA;AACV,cAAA;AACF,YAAA;AACC,YAAA;AAEC,4BAAA;AAOJ,UAAA;AAAA,QAAA;AACF,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;ADzFW;AACA;AE7NXA;AF+NW;AACA;AACA;AACA;AACA","file":"/home/runner/work/uniform/uniform/packages/uniform/dist/chunk-CVLA7A3Y.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 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 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 multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(\n classNames.multiValueLabel,\n `${getValueProps().className}`,\n ),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={`${testId}_select`}\n filterOption={filterOption}\n formatOptionLabel={formatOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n options={options}\n placeholder={placeholder}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n const transformedOptions: string[] = [];\n // @ts-expect-error in this case option is an array.\n option?.forEach((o: { value: string }) => {\n transformedOptions.push(o.value);\n });\n onChange(transformedOptions);\n } else {\n // @ts-expect-error in this case option is of type SelectOption and has the property value.\n onChange(option && option.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n onInputChange={onInputChange}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n unstyled\n />\n </div>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../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 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 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 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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AW;AAAA,kBACnC;AAAA,kBACA,YAAY;AAAA,oBACV,OAAO;AAAA,oBACP,QAAQ;AAAA,oBACR,mBAAmB;AAAA,kBACrB;AAAA,kBAEA,eAAa,GAAG,MAAM;AAAA,kBACtB;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA,YAAY;AAAA,kBACZ,aAAa;AAAA,kBACb,YAAY;AAAA,kBACZ,WAAW;AAAA,kBACX,SAAS;AAAA,kBACT;AAAA,kBAIA,cAAa;AAAA,kBACb,uBAAqB;AAAA,kBACrB;AAAA,kBACA;AAAA,kBACA,QAAQ,CAAC,OAAO;AACd,iCAAa,KAAK;AAClB,2BAAO,OAAO;AAAA,kBAChB;AAAA,kBACA,UAAU,CAAC,WAAW;AACpB,wBAAI,aAAa;AACf,4BAAM,qBAA+B,CAAC;AAEtC,8BAAQ,QAAQ,CAAC,MAAyB;AACxC,2CAAmB,KAAK,EAAE,KAAK;AAAA,sBACjC,CAAC;AACD,+BAAS,kBAAkB;AAAA,oBAC7B,OAAO;AAEL,+BAAS,UAAU,OAAO,KAAK;AAAA,oBACjC;AAAA,kBACF;AAAA,kBACA,SAAS,CAAC,OAAO;AACf,iCAAa,IAAI;AAAA,kBACnB;AAAA,kBACA;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;;;ACrTf,IAAOA,kBAAQ;","names":["Select_default"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Switch/Switch.tsx","../src/Switch/index.ts"],"sourcesContent":["import { Controller } from 'react-hook-form';\n\nimport { useInput } from '@nextui-org/input';\nimport { Switch as NextSwitch } from '@nextui-org/switch';\n\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface SwitchProps {\n /** CSS class name */\n className: string;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** component displayed next to the switch. */\n label: React.ReactNode;\n /** name the field is registered under */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * Switch component based on [NextUI Switch](https://nextui.org/docs/components/switch)\n */\nconst Switch = ({\n className,\n disabled = false,\n label: _label = undefined,\n name,\n testId: _testId = undefined,\n}: SwitchProps) => {\n const { control, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { label, getInputProps, getHelperWrapperProps, getErrorMessageProps } =\n useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n return (\n <Controller\n name={name}\n control={control}\n disabled={disabled}\n render={({\n field: { disabled: isDisabled, value, ref, onBlur, onChange },\n }) => (\n <>\n <NextSwitch\n aria-describedby={getInputProps()['aria-describedby']}\n required={required}\n isSelected={!!value}\n className={className}\n classNames={{\n label: `text-bold block text-ellipsis text-small ${invalid ? 'text-danger' : ''}`,\n }}\n data-testid={testId}\n isDisabled={isDisabled}\n value={value}\n onChange={onChange}\n onBlur={onBlur}\n name={name}\n ref={ref}\n >\n {label}\n {!!required && !!_label && (\n <span className=\"!text-danger\">{' \\u002A'}</span>\n )}\n <FieldCopyTestIdButton testId={testId} />\n </NextSwitch>\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </>\n )}\n />\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AACzB,SAAS,UAAU,kBAAkB;AAkD7B,mBAmBM,KAlBJ,YADF;AA5BR,IAAM,SAAS,CAAC;AAAA,EACd;AAAA,EACA,WAAW;AAAA,EACX,OAAO,SAAS;AAAA,EAChB;AAAA,EACA,QAAQ,UAAU;AACpB,MAAmB;AACjB,QAAM,EAAE,SAAS,cAAc,IAAI,eAAe;AAClD,QAAM,EAAE,OAAO,UAAU,QAAQ,QAAQ,IAAI,cAAc,MAAM,OAAO;AAExE,QAAM,EAAE,OAAO,eAAe,uBAAuB,qBAAqB,IACxE,SAAS;AAAA,IACP,cAAc,KAAK,UAAU,KAAK;AAAA,IAClC,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,aAAa;AAAA,EACf,CAAC;AAEH,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,CAAC;AAAA,QACP,OAAO,EAAE,UAAU,YAAY,OAAO,KAAK,QAAQ,SAAS;AAAA,MAC9D,MACE,iCACE;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,oBAAkB,cAAc,EAAE,kBAAkB;AAAA,YACpD;AAAA,YACA,YAAY,CAAC,CAAC;AAAA,YACd;AAAA,YACA,YAAY;AAAA,cACV,OAAO,4CAA4C,UAAU,gBAAgB,EAAE;AAAA,YACjF;AAAA,YACA,eAAa;AAAA,YACb;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YAEC;AAAA;AAAA,cACA,CAAC,CAAC,YAAY,CAAC,CAAC,UACf,oBAAC,UAAK,WAAU,gBAAgB,gBAAU;AAAA,cAE5C,oBAAC,iCAAsB,QAAgB;AAAA;AAAA;AAAA,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