@fuf-stack/uniform 0.14.4 → 0.15.0
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/CheckboxGroup/index.cjs +7 -6
- package/dist/CheckboxGroup/index.cjs.map +1 -1
- package/dist/CheckboxGroup/index.js +6 -5
- package/dist/Controller/index.cjs +4 -2
- package/dist/Controller/index.cjs.map +1 -1
- package/dist/Controller/index.d.cts +7 -3
- package/dist/Controller/index.d.ts +7 -3
- package/dist/Controller/index.js +7 -5
- package/dist/Controller-8Nqugui5.d.cts +37 -0
- package/dist/Controller-8Nqugui5.d.ts +37 -0
- package/dist/FieldArray/index.cjs +6 -5
- package/dist/FieldArray/index.cjs.map +1 -1
- package/dist/FieldArray/index.d.cts +5 -3
- package/dist/FieldArray/index.d.ts +5 -3
- package/dist/FieldArray/index.js +5 -4
- package/dist/FieldArray-AqM2XKIh.d.cts +151 -0
- package/dist/FieldArray-AqM2XKIh.d.ts +151 -0
- package/dist/Form/index.cjs +5 -4
- package/dist/Form/index.cjs.map +1 -1
- package/dist/Form/index.js +4 -3
- package/dist/Grid/index.cjs +1 -0
- package/dist/Grid/index.cjs.map +1 -1
- package/dist/Grid/index.js +1 -0
- package/dist/Input/index.cjs +7 -6
- package/dist/Input/index.cjs.map +1 -1
- package/dist/Input/index.js +6 -5
- package/dist/RadioGroup/index.cjs +7 -6
- package/dist/RadioGroup/index.cjs.map +1 -1
- package/dist/RadioGroup/index.js +6 -5
- package/dist/Select/index.cjs +7 -6
- package/dist/Select/index.cjs.map +1 -1
- package/dist/Select/index.js +6 -5
- package/dist/SubmitButton/index.cjs +5 -4
- package/dist/SubmitButton/index.cjs.map +1 -1
- package/dist/SubmitButton/index.js +4 -3
- package/dist/Switch/index.cjs +7 -6
- package/dist/Switch/index.cjs.map +1 -1
- package/dist/Switch/index.js +6 -5
- package/dist/TextArea/index.cjs +7 -6
- package/dist/TextArea/index.cjs.map +1 -1
- package/dist/TextArea/index.js +6 -5
- package/dist/{chunk-DDZMDOSG.js → chunk-2LAPLELO.js} +21 -17
- package/dist/{chunk-DDZMDOSG.js.map → chunk-2LAPLELO.js.map} +1 -1
- package/dist/chunk-2NSCPLAA.cjs +133 -0
- package/dist/chunk-2NSCPLAA.cjs.map +1 -0
- package/dist/{chunk-TR2J3OKH.js → chunk-3Q37222E.js} +20 -13
- package/dist/chunk-3Q37222E.js.map +1 -0
- package/dist/chunk-4AXNPSXG.cjs +82 -0
- package/dist/chunk-4AXNPSXG.cjs.map +1 -0
- package/dist/chunk-4DAZAO6Y.cjs +59 -0
- package/dist/chunk-4DAZAO6Y.cjs.map +1 -0
- package/dist/chunk-4EJS5FXY.js +51 -0
- package/dist/chunk-4EJS5FXY.js.map +1 -0
- package/dist/chunk-4EP3IGSK.cjs +372 -0
- package/dist/chunk-4EP3IGSK.cjs.map +1 -0
- package/dist/{chunk-25LLM544.cjs → chunk-4M6F2O2K.cjs} +11 -9
- package/dist/chunk-4M6F2O2K.cjs.map +1 -0
- package/dist/{chunk-XJGJ5ZNM.js → chunk-7HK64PN5.js} +38 -22
- package/dist/chunk-7HK64PN5.js.map +1 -0
- package/dist/{chunk-OHJYXA6R.cjs → chunk-C4RM2JSD.cjs} +3 -3
- package/dist/{chunk-OHJYXA6R.cjs.map → chunk-C4RM2JSD.cjs.map} +1 -1
- package/dist/chunk-CRTRMMJ7.js +59 -0
- package/dist/chunk-CRTRMMJ7.js.map +1 -0
- package/dist/{chunk-EKE5URXQ.cjs → chunk-F6KTQXWG.cjs} +15 -12
- package/dist/chunk-F6KTQXWG.cjs.map +1 -0
- package/dist/{chunk-RY4F5YDS.cjs → chunk-FLX6VIO7.cjs} +42 -26
- package/dist/chunk-FLX6VIO7.cjs.map +1 -0
- package/dist/chunk-IEF2GJ22.js +82 -0
- package/dist/chunk-IEF2GJ22.js.map +1 -0
- package/dist/chunk-K43U2JVG.cjs +248 -0
- package/dist/chunk-K43U2JVG.cjs.map +1 -0
- package/dist/{chunk-XJZAS7NG.cjs → chunk-MF4JB3YT.cjs} +25 -21
- package/dist/chunk-MF4JB3YT.cjs.map +1 -0
- package/dist/{chunk-BZAPTLMC.js → chunk-MRXNKY72.js} +49 -49
- package/dist/chunk-MRXNKY72.js.map +1 -0
- package/dist/chunk-OBQDQ4RX.js +372 -0
- package/dist/chunk-OBQDQ4RX.js.map +1 -0
- package/dist/{chunk-VP7WDLJM.js → chunk-P4PRVNCH.js} +17 -13
- package/dist/chunk-P4PRVNCH.js.map +1 -0
- package/dist/{chunk-PZ4LZQI4.cjs → chunk-QLQR44AD.cjs} +19 -15
- package/dist/chunk-QLQR44AD.cjs.map +1 -0
- package/dist/{chunk-AQHKELUR.js → chunk-U26GTLKF.js} +10 -8
- package/dist/chunk-U26GTLKF.js.map +1 -0
- package/dist/{chunk-GN5NJ6ZU.js → chunk-UJYXA5AD.js} +3 -3
- package/dist/chunk-V5HTEMWZ.cjs +51 -0
- package/dist/chunk-V5HTEMWZ.cjs.map +1 -0
- package/dist/{chunk-VZ5MMFIF.cjs → chunk-V7LRZ5GK.cjs} +5 -5
- package/dist/{chunk-VZ5MMFIF.cjs.map → chunk-V7LRZ5GK.cjs.map} +1 -1
- package/dist/{chunk-WKM2D7LF.js → chunk-VX76MJAI.js} +2 -2
- package/dist/chunk-W66BVPTB.js +248 -0
- package/dist/{chunk-IUNDGVMC.js.map → chunk-W66BVPTB.js.map} +1 -1
- package/dist/{chunk-BS52M4SZ.js → chunk-WAXJ64P7.js} +14 -11
- package/dist/chunk-WAXJ64P7.js.map +1 -0
- package/dist/{chunk-U6VUNJZG.cjs → chunk-Y4AUJ2YA.cjs} +21 -14
- package/dist/chunk-Y4AUJ2YA.cjs.map +1 -0
- package/dist/helpers/index.cjs +11 -2
- package/dist/helpers/index.cjs.map +1 -1
- package/dist/helpers/index.d.cts +68 -1
- package/dist/helpers/index.d.ts +68 -1
- package/dist/helpers/index.js +12 -3
- package/dist/hooks/index.cjs +6 -3
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +3 -2
- package/dist/hooks/index.d.ts +3 -2
- package/dist/hooks/index.js +7 -4
- package/dist/index.cjs +25 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +33 -22
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.cjs.map +1 -1
- package/dist/partials/FieldCopyTestIdButton/index.js +1 -0
- package/dist/partials/FieldValidationError/index.cjs +4 -3
- package/dist/partials/FieldValidationError/index.cjs.map +1 -1
- package/dist/partials/FieldValidationError/index.js +3 -2
- package/package.json +18 -18
- package/dist/FieldArray-DD9z-xZ3.d.cts +0 -37
- package/dist/FieldArray-DD9z-xZ3.d.ts +0 -37
- package/dist/chunk-25LLM544.cjs.map +0 -1
- package/dist/chunk-AQHKELUR.js.map +0 -1
- package/dist/chunk-BBB4FEY6.cjs +0 -22
- package/dist/chunk-BBB4FEY6.cjs.map +0 -1
- package/dist/chunk-BS52M4SZ.js.map +0 -1
- package/dist/chunk-BZAPTLMC.js.map +0 -1
- package/dist/chunk-EKE5URXQ.cjs.map +0 -1
- package/dist/chunk-HOETR36J.cjs +0 -299
- package/dist/chunk-HOETR36J.cjs.map +0 -1
- package/dist/chunk-HZP3EXGR.cjs +0 -241
- package/dist/chunk-HZP3EXGR.cjs.map +0 -1
- package/dist/chunk-IUNDGVMC.js +0 -241
- package/dist/chunk-KOKIM2ND.js +0 -9
- package/dist/chunk-KOKIM2ND.js.map +0 -1
- package/dist/chunk-PZ4LZQI4.cjs.map +0 -1
- package/dist/chunk-RY4F5YDS.cjs.map +0 -1
- package/dist/chunk-TR2J3OKH.js.map +0 -1
- package/dist/chunk-U6VUNJZG.cjs.map +0 -1
- package/dist/chunk-V46BHM2U.js +0 -22
- package/dist/chunk-V46BHM2U.js.map +0 -1
- package/dist/chunk-VP7WDLJM.js.map +0 -1
- package/dist/chunk-VQWKXSHW.cjs +0 -9
- package/dist/chunk-VQWKXSHW.cjs.map +0 -1
- package/dist/chunk-XJGJ5ZNM.js.map +0 -1
- package/dist/chunk-XJWEUCV3.cjs +0 -133
- package/dist/chunk-XJWEUCV3.cjs.map +0 -1
- package/dist/chunk-XJZAS7NG.cjs.map +0 -1
- package/dist/chunk-Y53IHK6B.js +0 -299
- package/dist/chunk-Y53IHK6B.js.map +0 -1
- /package/dist/{chunk-GN5NJ6ZU.js.map → chunk-UJYXA5AD.js.map} +0 -0
- /package/dist/{chunk-WKM2D7LF.js.map → chunk-VX76MJAI.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-QLQR44AD.cjs","../src/Form/Form.tsx","../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/index.ts"],"names":["jsx","jsxs","cn","Form_default"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACPA,oDAAmB;ADSnB;AACA;AEbA,8BAAoC;AACpC,oCAAwB;AACxB,sCAAkC;AAElC;AACA,2CAAmC;AAiDrB,+CAAA;AAtCd,IAAM,gBAAA,EAAkB,CAAC,EAAE,UAAA,EAAY,KAAA,EAAU,CAAA,EAAA,GAA4B;AAC3E,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,SAAA,EAAW,EAAE,WAAA,EAAa,OAAA,EAAS,aAAa,CAAA;AAAA,IAChD,YAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,EACF,EAAA,EAAI,8CAAA,CAAe;AAEnB,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,EAAA,EAAI,6BAAA,IAE1C,CAAA;AAEN,EAAA,MAAM,iBAAA,EAAmB,kDAAA,KAAmB,CAAM,CAAC,CAAA;AACnD,EAAA,MAAM,oBAAA,EAAsB,UAAA,IAAc,eAAA;AAE1C,E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AA,CAAA;AAAA,EAChB,KAAA,EAAO,KAAA,CAAA;AAAA,EACP,QAAA;AAAA,EACA,OAAA,EAAS,KAAA,CAAA;AAAA,EACT,WAAA,EAAa,KAAA,CAAA;AAAA,EACb,kBAAA,EAAoB;AACtB,CAAA,EAAA,GAAiB;AACf,EAAA,uBACEA,6BAAAA;AAAA,IAAC,qCAAA;AAAA,IAAA;AAAA,MACC,iBAAA,EAAmB,KAAA;AAAA,MACnB,aAAA;AAAA,MACA,QAAA;AAAA,MACA,UAAA;AAAA,MACA,iBAAA;AAAA,MAEC,QAAA,EAAA,CAAC,EAAE,aAAa,CAAA,EAAA,mBACfC,8BAAAA,KAAC,EAAA,EAAI,SAAA,EAAU,4CAAA,EACb,QAAA,EAAA;AAAA,wBAAAD,6BAAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAWE,4BAAAA,WAAG,EAAa,SAAS,CAAA;AAAA,YACpC,aAAA,EAAa,uCAAA,OAAQ,GAAU,KAAA,GAAQ,EAAE,CAAA;AAAA,YACzC,IAAA;AAAA,YACA,QAAA,EAAU,YAAA;AAAA,YAET;AAAA,UAAA;AAAA,QACH,CAAA;AAAA,QAEC,CAAC,QAAA,GAAW,CAAA,CAAC,MAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,KAAA,CAAO,OAAA,EAAA,mBACnBF,6BAAAA,uBAAC,EAAA,EAAgB,SAAA,EAAU,mBAAA,CAAmB;AAAA,MAAA,EAAA,CAElD;AAAA,IAAA;AAAA,EAEJ,CAAA;AAEJ,CAAA;AAEA,IAAO,aAAA,EAAQ,IAAA;ADkEf;AACA;AGzIA,IAAOG,cAAAA,EAAQ,YAAA;AH2If;AACA;AACE;AACA;AACF,2EAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-QLQR44AD.cjs","sourcesContent":[null,"import type { VetoInstance } from '@fuf-stack/veto';\nimport type { ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\nimport type { DebugModeSettings } from './subcomponents/FormContext';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { slugify } from '../helpers';\nimport FormProvider from './subcomponents/FormContext';\nimport FormDebugViewer from './subcomponents/FormDebugViewer';\n\nconst IS_TEST = process.env.NODE_ENV === 'test';\n\nexport interface FormProps {\n /** form children */\n children: ReactNode | ReactNode[];\n /** CSS class name */\n className?: string | string[];\n /** settings for from debug mode */\n debug?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** name of the form */\n name?: string;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** veto validation schema */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * Form component that has to wrap every uniform\n */\nconst Form = ({\n children,\n className = undefined,\n debug = undefined,\n initialValues = undefined,\n name = undefined,\n onSubmit,\n testId = undefined,\n validation = undefined,\n validationTrigger = 'all',\n}: FormProps) => {\n return (\n <FormProvider\n debugModeSettings={debug}\n initialValues={initialValues}\n onSubmit={onSubmit}\n validation={validation}\n validationTrigger={validationTrigger}\n >\n {({ handleSubmit }) => (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('flex-grow', className)}\n data-testid={slugify(testId || name || '')}\n name={name}\n onSubmit={handleSubmit}\n >\n {children}\n </form>\n {/* render debug viewer when not in test environment and debug not disabled */}\n {!IS_TEST && !debug?.disable && (\n <FormDebugViewer className=\"w-96 flex-shrink\" />\n )}\n </div>\n )}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import type { VetoError } from '@fuf-stack/veto';\n\nimport { useEffect, useState } from 'react';\nimport { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button, Card, Json } from '@fuf-stack/pixels';\n\nimport { toValidationFormat } from '../../helpers';\nimport { useFormContext } from '../../hooks';\n\ninterface FormDebugViewerProps {\n /** CSS class name */\n className?: string;\n}\n\n/** Renders a form debug panel with information about the current form state */\nconst FormDebugViewer = ({ className = undefined }: FormDebugViewerProps) => {\n const {\n debugMode,\n formState: { dirtyFields, isValid, isSubmitting },\n setDebugMode,\n validation,\n watch,\n } = useFormContext();\n\n const [validationErrors, setValidationErrors] = useState<\n VetoError['errors'] | null\n >(null);\n\n const validationValues = toValidationFormat(watch());\n const debugTestIdsEnabled = debugMode === 'debug-testids';\n\n useEffect(\n () => {\n const updateValidationErrors = async () => {\n if (validation) {\n const validateResult =\n await validation?.validateAsync(validationValues);\n setValidationErrors(validateResult?.errors);\n }\n };\n updateValidationErrors();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [JSON.stringify(validationValues)],\n );\n\n if (!debugMode || debugMode === 'off') {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n onClick={() => setDebugMode('debug')}\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n variant=\"light\"\n icon={<FaBug />}\n />\n );\n }\n\n return (\n <Card\n className={cn(className)}\n header={\n <div className=\"flex w-full flex-row justify-between\">\n <span className=\"text-lg\">Debug Mode</span>\n <Button\n icon={<FaTimes className=\"text-danger\" />}\n onClick={() => setDebugMode('off')}\n size=\"sm\"\n variant=\"flat\"\n />\n </div>\n }\n >\n <Button\n variant={debugTestIdsEnabled ? 'solid' : 'light'}\n icon={<FaBullseye />}\n className=\"mb-4 ml-auto mr-auto\"\n onClick={() =>\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug')\n }\n >\n {debugTestIdsEnabled ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values: validationValues,\n errors: validationErrors,\n dirtyFields,\n isValid,\n isSubmitting,\n }}\n />\n </Card>\n );\n};\nexport default FormDebugViewer;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
Controller_default
|
|
3
|
+
} from "./chunk-4EJS5FXY.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldCopyTestIdButton_default
|
|
6
6
|
} from "./chunk-2CRY7VDQ.js";
|
|
7
7
|
import {
|
|
8
8
|
FieldValidationError_default
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VX76MJAI.js";
|
|
10
10
|
import {
|
|
11
11
|
useFormContext
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-MRXNKY72.js";
|
|
13
13
|
|
|
14
14
|
// src/TextArea/TextArea.tsx
|
|
15
15
|
import { Textarea as NextTextArea } from "@nextui-org/input";
|
|
@@ -29,14 +29,16 @@ var TextArea = ({
|
|
|
29
29
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
30
30
|
const showLabel = label || showTestIdCopyButton;
|
|
31
31
|
return /* @__PURE__ */ jsx(
|
|
32
|
-
|
|
32
|
+
Controller_default,
|
|
33
33
|
{
|
|
34
34
|
control,
|
|
35
35
|
name,
|
|
36
36
|
disabled,
|
|
37
37
|
render: ({
|
|
38
|
-
field: { disabled: isDisabled, onChange, onBlur, value, ref }
|
|
38
|
+
field: { disabled: isDisabled, onChange, onBlur, value = "", ref }
|
|
39
39
|
}) => {
|
|
40
|
+
var _a;
|
|
41
|
+
const displayValue = (_a = value == null ? void 0 : value.toString()) != null ? _a : "";
|
|
40
42
|
return /* @__PURE__ */ jsx(
|
|
41
43
|
NextTextArea,
|
|
42
44
|
{
|
|
@@ -56,7 +58,7 @@ var TextArea = ({
|
|
|
56
58
|
labelPlacement: "outside",
|
|
57
59
|
placeholder,
|
|
58
60
|
name,
|
|
59
|
-
value,
|
|
61
|
+
value: displayValue,
|
|
60
62
|
onChange,
|
|
61
63
|
onBlur,
|
|
62
64
|
ref,
|
|
@@ -77,4 +79,4 @@ export {
|
|
|
77
79
|
TextArea_default,
|
|
78
80
|
TextArea_default2
|
|
79
81
|
};
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-U26GTLKF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/TextArea/TextArea.tsx","../src/TextArea/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { Textarea as NextTextArea } from '@nextui-org/input';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { Controller } from '../Controller';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport interface TextAreaProps {\n /** Child components. The content of the textarea. */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** Determines if the TextArea is disabled or not. */\n disabled?: boolean;\n /** Label displayed above the TextArea. */\n label?: ReactNode;\n /** Name the TextArea is registered at in HTML forms (react-hook-form). */\n name: string;\n /** placeholder for the textArea content. */\n placeholder?: string;\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * TextArea component based on [NextUI TextArea](https://nextui.org/docs/components/textarea)\n */\nconst TextArea = ({\n children = null,\n className = undefined,\n disabled = false,\n label = undefined,\n name,\n placeholder = ' ',\n testId: _testId = undefined,\n}: TextAreaProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <Controller\n control={control}\n name={name}\n disabled={disabled}\n render={({\n field: { disabled: isDisabled, onChange, onBlur, value = '', ref },\n }) => {\n /**\n * Ensures the textarea always has a defined string value to prevent uncontrolled to\n * controlled component warnings:\n *\n * 1. Warning Prevention:\n * - Sets default value to '' in field destructuring\n * - Guarantees the value prop is never undefined/null\n * - Prevents React warning: \"A component is changing from uncontrolled to controlled\"\n *\n * 2. Value Handling:\n * - Converts undefined/null to empty string\n * - Converts non-string values to strings\n * - Maintains existing string values\n *\n * Examples:\n * - undefined → \"\" (prevents uncontrolled warning)\n * - null → \"\" (prevents uncontrolled warning)\n * - \"hello\" → \"hello\" (maintains string value)\n * - 123 → \"123\" (converts to string)\n *\n * Without this handling, the textarea could switch between controlled/uncontrolled\n * states when the form value changes from undefined to defined, causing React warnings\n * and potential rendering issues.\n */\n const displayValue = value?.toString() ?? '';\n\n return (\n <NextTextArea\n className={cn(className)}\n classNames={{\n inputWrapper: 'group-data-[focus=true]:border-focus',\n }}\n data-testid={testId}\n errorMessage={error && <FieldValidationError error={error} />}\n isDisabled={isDisabled}\n isRequired={required}\n isInvalid={invalid}\n label={\n showLabel && (\n <>\n {label}\n {showTestIdCopyButton && (\n <FieldCopyTestIdButton testId={testId} />\n )}\n </>\n )\n }\n labelPlacement=\"outside\"\n placeholder={placeholder}\n name={name}\n value={displayValue}\n onChange={onChange}\n onBlur={onBlur}\n ref={ref}\n variant=\"bordered\"\n >\n {children}\n </NextTextArea>\n );\n }}\n />\n );\n};\n\nexport default TextArea;\n","import TextArea from './TextArea';\n\nexport type { TextAreaProps } from './TextArea';\n\nexport { TextArea };\n\nexport default TextArea;\n"],"mappings":";;;;;;;;;;;;;;AAEA,SAAS,YAAY,oBAAoB;AAEzC,SAAS,UAAU;AAmFgB,SAMnB,UANmB,KAMnB,YANmB;AAxDnC,IAAM,WAAW,CAAC;AAAA,EAChB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,QAAQ;AAAA,EACR;AAAA,EACA,cAAc;AAAA,EACd,QAAQ,UAAU;AACpB,MAAqB;AACnB,QAAM,EAAE,SAAS,WAAW,cAAc,IAAI,eAAe;AAC7D,QAAM,EAAE,OAAO,SAAS,UAAU,OAAO,IAAI,cAAc,MAAM,OAAO;AAExE,QAAM,uBAAuB,cAAc;AAC3C,QAAM,YAAY,SAAS;AAE3B,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,CAAC;AAAA,QACP,OAAO,EAAE,UAAU,YAAY,UAAU,QAAQ,QAAQ,IAAI,IAAI;AAAA,MACnE,MAAM;AArDZ;AA8EQ,cAAM,gBAAe,oCAAO,eAAP,YAAqB;AAE1C,eACE;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,GAAG,SAAS;AAAA,YACvB,YAAY;AAAA,cACV,cAAc;AAAA,YAChB;AAAA,YACA,eAAa;AAAA,YACb,cAAc,SAAS,oBAAC,gCAAqB,OAAc;AAAA,YAC3D;AAAA,YACA,YAAY;AAAA,YACZ,WAAW;AAAA,YACX,OACE,aACE,iCACG;AAAA;AAAA,cACA,wBACC,oBAAC,iCAAsB,QAAgB;AAAA,eAE3C;AAAA,YAGJ,gBAAe;AAAA,YACf;AAAA,YACA;AAAA,YACA,OAAO;AAAA,YACP;AAAA,YACA;AAAA,YACA;AAAA,YACA,SAAQ;AAAA,YAEP;AAAA;AAAA,QACH;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,mBAAQ;;;AChHf,IAAOA,oBAAQ;","names":["TextArea_default"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useFormContext
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MRXNKY72.js";
|
|
4
4
|
import {
|
|
5
5
|
slugify
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-IEF2GJ22.js";
|
|
7
7
|
|
|
8
8
|
// src/SubmitButton/SubmitButton.tsx
|
|
9
9
|
import { cn } from "@fuf-stack/pixel-utils";
|
|
@@ -45,4 +45,4 @@ export {
|
|
|
45
45
|
SubmitButton_default,
|
|
46
46
|
SubmitButton_default2
|
|
47
47
|
};
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-UJYXA5AD.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunk4AXNPSXGcjs = require('./chunk-4AXNPSXG.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk4DAZAO6Ycjs = require('./chunk-4DAZAO6Y.cjs');
|
|
10
|
+
|
|
11
|
+
// src/Controller/Controller.tsx
|
|
12
|
+
var _reacthookform = require('react-hook-form');
|
|
13
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
14
|
+
var Controller = (_a) => {
|
|
15
|
+
var _b = _a, {
|
|
16
|
+
render
|
|
17
|
+
} = _b, props = _chunk4DAZAO6Ycjs.__objRest.call(void 0, _b, [
|
|
18
|
+
"render"
|
|
19
|
+
]);
|
|
20
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
21
|
+
_reacthookform.Controller,
|
|
22
|
+
_chunk4DAZAO6Ycjs.__spreadProps.call(void 0, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, props), {
|
|
23
|
+
render: (_a2) => {
|
|
24
|
+
var _b2 = _a2, { field } = _b2, rest = _chunk4DAZAO6Ycjs.__objRest.call(void 0, _b2, ["field"]);
|
|
25
|
+
return render(_chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {
|
|
26
|
+
field: _chunk4DAZAO6Ycjs.__spreadProps.call(void 0, _chunk4DAZAO6Ycjs.__spreadValues.call(void 0, {}, field), {
|
|
27
|
+
// Handles both direct values (onChange("value")) and events (onChange(event))
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
onChange: (...event) => {
|
|
30
|
+
var _a3, _b3, _c;
|
|
31
|
+
const value = (_c = (_b3 = (_a3 = event[0]) == null ? void 0 : _a3.target) == null ? void 0 : _b3.value) != null ? _c : event[0];
|
|
32
|
+
field.onChange(_chunk4AXNPSXGcjs.toNullishString.call(void 0, value));
|
|
33
|
+
},
|
|
34
|
+
// Convert null/undefined to empty string for UI display
|
|
35
|
+
value: _chunk4AXNPSXGcjs.fromNullishString.call(void 0, field.value)
|
|
36
|
+
})
|
|
37
|
+
}, rest));
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
var Controller_default = Controller;
|
|
43
|
+
|
|
44
|
+
// src/Controller/index.ts
|
|
45
|
+
var Controller_default2 = Controller_default;
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
exports.Controller_default = Controller_default; exports.Controller_default2 = Controller_default2;
|
|
51
|
+
//# sourceMappingURL=chunk-V5HTEMWZ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-V5HTEMWZ.cjs","../src/Controller/Controller.tsx","../src/Controller/index.ts"],"names":["_a","_b","Controller_default"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACHA,gDAA4C;AA8CxC,+CAAA;AALJ,IAAM,WAAA,EAAa,CAAuC,EAAA,EAAA,GAGrB;AAHqB,EAAA,IAAA,GAAA,EAAA,EAAA,EACxD;AAAA,IAAA;AAAA,EAjDF,EAAA,EAgD0D,EAAA,EAErD,MAAA,EAAA,yCAAA,EAFqD,EAErD;AAAA,IADH;AAAA,EAAA,CAAA,CAAA;AAGA,EAAA,uBACE,6BAAA;AAAA,IAAC,yBAAA;AAAA,IAAA,6CAAA,8CAAA,CAAA,CAAA,EAEK,KAAA,CAAA,EAFL;AAAA,MAGC,MAAA,EAAQ,CAACA,GAAAA,EAAAA,GAAuB;AAAvB,QAAA,IAAAC,IAAAA,EAAAD,GAAAA,EAAE,EAAA,MAxDjB,EAAA,EAwDeC,GAAAA,EAAY,KAAA,EAAA,yCAAA,GAAZA,EAAY,CAAV,OAAA,CAAA,CAAA;AACT,QAAA,OAAO,MAAA,CAAO,8CAAA;AAAA,UACZ,KAAA,EAAO,6CAAA,8CAAA,CAAA,CAAA,EACF,KAAA,CAAA,EADE;AAAA;AAAA;AAAA,YAIL,QAAA,EAAU,CAAA,GAAI,KAAA,EAAA,GAAiB;AA9D3C,cAAA,IAAAD,GAAAA,EAAAC,GAAAA,EAAA,EAAA;AA+Dc,cAAA,MAAM,MAAA,EAAA,CAAQ,GAAA,EAAA,CAAAA,IAAAA,EAAAA,CAAAD,IAAAA,EAAA,KAAA,CAAM,CAAC,CAAA,EAAA,GAAP,KAAA,EAAA,KAAA,EAAA,EAAAA,GAAAA,CAAU,MAAA,EAAA,GAAV,KAAA,EAAA,KAAA,EAAA,EAAAC,GAAAA,CAAkB,KAAA,EAAA,GAAlB,KAAA,EAAA,GAAA,EAA2B,KAAA,CAAM,CAAC,CAAA;AAChD,cAAA,KAAA,CAAM,QAAA,CAAS,+CAAA,KAAqB,CAAC,CAAA;AAAA,YACvC,CAAA;AAAA;AAAA,YAEA,KAAA,EAAO,iDAAA,KAAkB,CAAM,KAAK;AAAA,UACtC,CAAA;AAAA,QAAA,CAAA,EACG,IAAA,CACJ,CAAA;AAAA,MACH;AAAA,IAAA,CAAA;AAAA,EACF,CAAA;AAEJ,CAAA;AAEA,IAAO,mBAAA,EAAQ,UAAA;ADlCf;AACA;AErCA,IAAOC,oBAAAA,EAAQ,kBAAA;AFuCf;AACA;AACE;AACA;AACF,mGAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-V5HTEMWZ.cjs","sourcesContent":[null,"import type {\n ControllerFieldState,\n ControllerRenderProps,\n ControllerProps as RHFControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { Controller as RHFController } from 'react-hook-form';\n\nimport { fromNullishString, toNullishString } from '../helpers';\n\nexport type ControllerProps<TFieldValues extends object = object> = Omit<\n RHFControllerProps<TFieldValues>,\n 'render'\n> & {\n /**\n * Render prop that receives the form control props with nullish string handling.\n * The field object contains all the properties needed to control an input:\n * - onChange: Handles both direct value changes and event objects\n * - value: Always provides a string value, converting null/undefined to empty string\n * - name, ref, etc: Other standard field properties from react-hook-form\n */\n render: (props: {\n field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {\n // Using any[] to support both direct value changes and React synthetic events\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n value: string;\n };\n formState: UseFormStateReturn<TFieldValues>;\n fieldState: ControllerFieldState;\n }) => React.ReactElement;\n};\n\n/**\n * A wrapper around react-hook-form's Controller that transparently handles nullish string conversions.\n *\n * Key features:\n * 1. Empty strings ('') in the UI are stored as null in form state\n * 2. Null/undefined values in form state are displayed as empty strings in the UI\n * 3. Handles both direct value changes and React synthetic events\n * 4. Maintains the same API as react-hook-form's Controller\n *\n * This enables consistent handling of empty/null values while keeping a clean API\n * for form inputs that expect string values.\n *\n * @see https://react-hook-form.com/docs/usecontroller/controller\n */\nconst Controller = <TFieldValues extends object = object>({\n render,\n ...props\n}: ControllerProps<TFieldValues>) => {\n return (\n <RHFController<TFieldValues>\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...props}\n render={({ field, ...rest }) => {\n return render({\n field: {\n ...field,\n // Handles both direct values (onChange(\"value\")) and events (onChange(event))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => {\n const value = event[0]?.target?.value ?? event[0];\n field.onChange(toNullishString(value));\n },\n // Convert null/undefined to empty string for UI display\n value: fromNullishString(field.value) as string,\n },\n ...rest,\n });\n }}\n />\n );\n};\n\nexport default Controller;\n","import Controller from './Controller';\n\nexport type { ControllerProps } from './Controller';\n\nexport { Controller };\n\nexport default Controller;\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk2NSCPLAAcjs = require('./chunk-2NSCPLAA.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk4AXNPSXGcjs = require('./chunk-4AXNPSXG.cjs');
|
|
7
7
|
|
|
8
8
|
// src/SubmitButton/SubmitButton.tsx
|
|
9
9
|
var _pixelutils = require('@fuf-stack/pixel-utils');
|
|
@@ -20,13 +20,13 @@ var SubmitButton = ({
|
|
|
20
20
|
}) => {
|
|
21
21
|
const {
|
|
22
22
|
formState: { isSubmitting, isValidating }
|
|
23
|
-
} =
|
|
23
|
+
} = _chunk2NSCPLAAcjs.useFormContext.call(void 0, );
|
|
24
24
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
25
25
|
_pixels.Button,
|
|
26
26
|
{
|
|
27
27
|
className: _pixelutils.cn.call(void 0, className),
|
|
28
28
|
color,
|
|
29
|
-
testId:
|
|
29
|
+
testId: _chunk4AXNPSXGcjs.slugify.call(void 0, testId),
|
|
30
30
|
disabled: isSubmitting || isValidating,
|
|
31
31
|
loading,
|
|
32
32
|
onClick,
|
|
@@ -45,4 +45,4 @@ var SubmitButton_default2 = SubmitButton_default;
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
exports.SubmitButton_default = SubmitButton_default; exports.SubmitButton_default2 = SubmitButton_default2;
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-V7LRZ5GK.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-V7LRZ5GK.cjs","../src/SubmitButton/SubmitButton.tsx","../src/SubmitButton/index.ts"],"names":["SubmitButton_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,oDAAmB;AACnB,2CAAuB;AAsCnB,+CAAA;AAbJ,IAAM,aAAA,EAAe,CAAC;AAAA,EACpB,SAAA,EAAW,QAAA;AAAA,EACX,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,MAAA,EAAQ,SAAA;AAAA,EACR,QAAA,EAAU,KAAA;AAAA,EACV,QAAA,EAAU,KAAA,CAAA;AAAA,EACV,KAAA,EAAO,IAAA;AAAA,EACP,OAAA,EAAS;AACX,CAAA,EAAA,GAAyB;AACvB,EAAA,MAAM;AAAA,IACJ,SAAA,EAAW,EAAE,YAAA,EAAc,aAAa;AAAA,EAC1C,EAAA,EAAI,8CAAA,CAAe;AACnB,EAAA,uBACE,6BAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,4BAAA,SAAY,CAAA;AAAA,MACvB,KAAA;AAAA,MACA,MAAA,EAAQ,uCAAA,MAAc,CAAA;AAAA,MACtB,QAAA,EAAU,aAAA,GAAgB,YAAA;AAAA,MAC1B,OAAA;AAAA,MACA,OAAA;AAAA,MACA,IAAA;AAAA,MACA,IAAA,EAAK,QAAA;AAAA,MAEJ;AAAA,IAAA;AAAA,EACH,CAAA;AAEJ,CAAA;AAEA,IAAO,qBAAA,EAAQ,YAAA;ADlBf;AACA;AElCA,IAAOA,sBAAAA,EAAQ,oBAAA;AFoCf;AACA;AACE;AACA;AACF,2GAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-V7LRZ5GK.cjs","sourcesContent":[null,"import type { ButtonProps } from '@fuf-stack/pixels';\nimport type { ReactNode } from 'react';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\n\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\n\nexport interface SubmitButtonProps {\n /** child components */\n children?: ReactNode;\n /** CSS class name */\n className?: string;\n /** color of the button */\n color?: ButtonProps['color'];\n /** If set loading animation is shown */\n loading?: boolean;\n /** function called when the button is pressed. */\n onClick?: ButtonProps['onClick'];\n /** size of the button */\n size?: ButtonProps['size'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * From SubmitButton\n */\nconst SubmitButton = ({\n children = 'Submit',\n className = undefined,\n color = 'success',\n loading = false,\n onClick = undefined,\n size = 'md',\n testId = 'form_submit_button',\n}: SubmitButtonProps) => {\n const {\n formState: { isSubmitting, isValidating },\n } = useFormContext();\n return (\n <Button\n className={cn(className)}\n color={color}\n testId={slugify(testId)}\n disabled={isSubmitting || isValidating}\n loading={loading}\n onClick={onClick}\n size={size}\n type=\"submit\"\n >\n {children}\n </Button>\n );\n};\n\nexport default SubmitButton;\n","import SubmitButton from './SubmitButton';\n\nexport type { SubmitButtonProps } from './SubmitButton';\n\nexport { SubmitButton };\n\nexport default SubmitButton;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
slugify
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IEF2GJ22.js";
|
|
4
4
|
|
|
5
5
|
// src/partials/FieldValidationError/FieldValidationError.tsx
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -44,4 +44,4 @@ export {
|
|
|
44
44
|
FieldValidationError_default,
|
|
45
45
|
FieldValidationError_default2
|
|
46
46
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-VX76MJAI.js.map
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Controller_default
|
|
3
|
+
} from "./chunk-4EJS5FXY.js";
|
|
4
|
+
import {
|
|
5
|
+
FieldCopyTestIdButton_default
|
|
6
|
+
} from "./chunk-2CRY7VDQ.js";
|
|
7
|
+
import {
|
|
8
|
+
FieldValidationError_default
|
|
9
|
+
} from "./chunk-VX76MJAI.js";
|
|
10
|
+
import {
|
|
11
|
+
useFormContext
|
|
12
|
+
} from "./chunk-MRXNKY72.js";
|
|
13
|
+
import {
|
|
14
|
+
slugify
|
|
15
|
+
} from "./chunk-IEF2GJ22.js";
|
|
16
|
+
import {
|
|
17
|
+
__spreadProps,
|
|
18
|
+
__spreadValues
|
|
19
|
+
} from "./chunk-CRTRMMJ7.js";
|
|
20
|
+
|
|
21
|
+
// src/Select/Select.tsx
|
|
22
|
+
import { useState } from "react";
|
|
23
|
+
import ReactSelect, { components } from "react-select";
|
|
24
|
+
import { useSelect } from "@nextui-org/select";
|
|
25
|
+
import { cn, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
26
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
+
var selectVariants = tv({
|
|
28
|
+
slots: {
|
|
29
|
+
base: "group leading-normal",
|
|
30
|
+
clearIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800",
|
|
31
|
+
control: "rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none",
|
|
32
|
+
control_focused: "border-focus",
|
|
33
|
+
crossIcon: "",
|
|
34
|
+
downChevron: "",
|
|
35
|
+
dropdownIndicator: "rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black",
|
|
36
|
+
group: "",
|
|
37
|
+
groupHeading: "mb-1 ml-3 mt-2 text-sm text-foreground-500",
|
|
38
|
+
indicatorsContainer: "gap-1 p-1",
|
|
39
|
+
indicatorSeparator: "bg-default-300",
|
|
40
|
+
input: "py-0.5 pl-1",
|
|
41
|
+
// See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts
|
|
42
|
+
label: 'pointer-events-auto relative bottom-1.5 ml-1 text-small subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-["*"]',
|
|
43
|
+
loadingIndicator: "",
|
|
44
|
+
loadingMessage: "",
|
|
45
|
+
menu: "mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg",
|
|
46
|
+
menuList: "",
|
|
47
|
+
// ensure menu has same z-index as modal so it is visible when rendered in modal
|
|
48
|
+
// see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)
|
|
49
|
+
menuPortal: "!z-50",
|
|
50
|
+
multiValue: "items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1",
|
|
51
|
+
multiValueContainer: "",
|
|
52
|
+
multiValueLabel: "py-0.5 leading-6",
|
|
53
|
+
multiValueRemove: "rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800",
|
|
54
|
+
noOptionsMessage: "rounded-sm p-2 text-foreground-500",
|
|
55
|
+
option_focused: "bg-default-100 active:bg-default-200",
|
|
56
|
+
option_selected: "bg-default-300",
|
|
57
|
+
option: "rounded px-3 py-2 hover:cursor-pointer",
|
|
58
|
+
placeholder: "ml-1 py-0.5 pl-1 text-sm text-foreground-500",
|
|
59
|
+
selectContainer: "",
|
|
60
|
+
singleValue: "!ml-1 !leading-7",
|
|
61
|
+
valueContainer: "gap-1 p-1"
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
var InputComponent = (props) => {
|
|
65
|
+
const testId = `${props.selectProps["data-testid"]}`;
|
|
66
|
+
return /* @__PURE__ */ jsx(components.Input, __spreadValues({ "data-testid": testId }, props));
|
|
67
|
+
};
|
|
68
|
+
var ControlComponent = (props) => {
|
|
69
|
+
const testId = `${props.selectProps["data-testid"]}_select`;
|
|
70
|
+
return /* @__PURE__ */ jsx("div", { "data-testid": testId, children: /* @__PURE__ */ jsx(components.Control, __spreadValues({}, props)) });
|
|
71
|
+
};
|
|
72
|
+
var OptionComponent = (props) => {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
const testId = `${props.selectProps["data-testid"]}_select_option_${slugify((_c = (_a = props == null ? void 0 : props.data) == null ? void 0 : _a.testId) != null ? _c : (_b = props == null ? void 0 : props.data) == null ? void 0 : _b.value)}`;
|
|
75
|
+
return /* @__PURE__ */ jsx("div", { "data-testid": testId, children: /* @__PURE__ */ jsx(components.Option, __spreadValues({}, props)) });
|
|
76
|
+
};
|
|
77
|
+
var DropdownIndicatorComponent = (props) => {
|
|
78
|
+
const testId = props == null ? void 0 : props.selectProps["data-testid"];
|
|
79
|
+
return /* @__PURE__ */ jsx("div", { "data-testid": `${testId}_select_dropdown`, children: /* @__PURE__ */ jsx(components.DropdownIndicator, __spreadValues({}, props)) });
|
|
80
|
+
};
|
|
81
|
+
var Select = ({
|
|
82
|
+
className = void 0,
|
|
83
|
+
clearable = true,
|
|
84
|
+
disabled = false,
|
|
85
|
+
filterOption = void 0,
|
|
86
|
+
renderOptionLabel = void 0,
|
|
87
|
+
inputValue = void 0,
|
|
88
|
+
label: _label = void 0,
|
|
89
|
+
loading = false,
|
|
90
|
+
multiSelect = false,
|
|
91
|
+
name,
|
|
92
|
+
onInputChange = void 0,
|
|
93
|
+
options,
|
|
94
|
+
placeholder = void 0,
|
|
95
|
+
testId: _testId = void 0
|
|
96
|
+
}) => {
|
|
97
|
+
const { control, debugMode, getFieldState } = useFormContext();
|
|
98
|
+
const { error, invalid, required, testId } = getFieldState(name, _testId);
|
|
99
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
100
|
+
const variants = selectVariants();
|
|
101
|
+
const classNames = variantsToClassNames(variants, className, "base");
|
|
102
|
+
const {
|
|
103
|
+
getBaseProps,
|
|
104
|
+
getErrorMessageProps,
|
|
105
|
+
getHelperWrapperProps,
|
|
106
|
+
getLabelProps,
|
|
107
|
+
getTriggerProps,
|
|
108
|
+
getValueProps,
|
|
109
|
+
label
|
|
110
|
+
} = useSelect({
|
|
111
|
+
children: [],
|
|
112
|
+
classNames,
|
|
113
|
+
errorMessage: JSON.stringify(error),
|
|
114
|
+
isDisabled: disabled,
|
|
115
|
+
isInvalid: invalid,
|
|
116
|
+
isLoading: loading,
|
|
117
|
+
isRequired: required,
|
|
118
|
+
label: _label,
|
|
119
|
+
labelPlacement: "outside",
|
|
120
|
+
placeholder: " "
|
|
121
|
+
});
|
|
122
|
+
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
123
|
+
const showLabel = label || showTestIdCopyButton;
|
|
124
|
+
return /* @__PURE__ */ jsx(
|
|
125
|
+
Controller_default,
|
|
126
|
+
{
|
|
127
|
+
control,
|
|
128
|
+
name,
|
|
129
|
+
render: ({
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
131
|
+
field: { onChange, value, ref, onBlur }
|
|
132
|
+
}) => {
|
|
133
|
+
var _a;
|
|
134
|
+
return /* @__PURE__ */ jsxs(
|
|
135
|
+
"div",
|
|
136
|
+
__spreadProps(__spreadValues({}, getBaseProps()), {
|
|
137
|
+
className: cn(classNames.base),
|
|
138
|
+
"data-testid": `${testId}_wrapper`,
|
|
139
|
+
"data-required": required,
|
|
140
|
+
children: [
|
|
141
|
+
showLabel && /* @__PURE__ */ jsxs(
|
|
142
|
+
"label",
|
|
143
|
+
{
|
|
144
|
+
className: classNames.label,
|
|
145
|
+
"data-slot": "label",
|
|
146
|
+
htmlFor: `react-select-${name}-input`,
|
|
147
|
+
id: getLabelProps().id,
|
|
148
|
+
children: [
|
|
149
|
+
label,
|
|
150
|
+
showTestIdCopyButton && /* @__PURE__ */ jsx(FieldCopyTestIdButton_default, { testId })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
/* @__PURE__ */ jsx(
|
|
155
|
+
ReactSelect,
|
|
156
|
+
{
|
|
157
|
+
"aria-errormessage": "",
|
|
158
|
+
"aria-labelledby": (_a = getTriggerProps()["aria-labelledby"]) == null ? void 0 : _a.split(" ")[1],
|
|
159
|
+
"aria-invalid": invalid,
|
|
160
|
+
classNames: {
|
|
161
|
+
control: () => cn(classNames.control, {
|
|
162
|
+
[classNames.control_focused]: isFocused && !invalid
|
|
163
|
+
}),
|
|
164
|
+
clearIndicator: () => classNames.clearIndicator,
|
|
165
|
+
dropdownIndicator: () => classNames.dropdownIndicator,
|
|
166
|
+
groupHeading: () => classNames.groupHeading,
|
|
167
|
+
indicatorsContainer: () => classNames.indicatorsContainer,
|
|
168
|
+
indicatorSeparator: () => classNames.indicatorSeparator,
|
|
169
|
+
input: () => classNames.input,
|
|
170
|
+
menu: () => classNames.menu,
|
|
171
|
+
menuList: () => classNames.menuList,
|
|
172
|
+
menuPortal: () => classNames.menuPortal,
|
|
173
|
+
multiValue: () => classNames.multiValue,
|
|
174
|
+
multiValueLabel: () => cn(classNames.multiValueLabel, `${getValueProps().className}`),
|
|
175
|
+
multiValueRemove: () => classNames.multiValueRemove,
|
|
176
|
+
noOptionsMessage: () => classNames.noOptionsMessage,
|
|
177
|
+
option: ({
|
|
178
|
+
isFocused: optionIsFocused,
|
|
179
|
+
isSelected: optionIsSelected
|
|
180
|
+
}) => cn(classNames.option, {
|
|
181
|
+
[classNames.option_focused]: optionIsFocused,
|
|
182
|
+
[classNames.option_selected]: optionIsSelected
|
|
183
|
+
}),
|
|
184
|
+
placeholder: () => classNames.placeholder,
|
|
185
|
+
singleValue: () => cn(classNames.singleValue, `${getValueProps().className}`),
|
|
186
|
+
valueContainer: () => classNames.valueContainer
|
|
187
|
+
},
|
|
188
|
+
components: {
|
|
189
|
+
Input: InputComponent,
|
|
190
|
+
Option: OptionComponent,
|
|
191
|
+
DropdownIndicator: DropdownIndicatorComponent,
|
|
192
|
+
Control: ControlComponent
|
|
193
|
+
},
|
|
194
|
+
"data-testid": testId,
|
|
195
|
+
filterOption,
|
|
196
|
+
formatOptionLabel: renderOptionLabel,
|
|
197
|
+
inputValue,
|
|
198
|
+
instanceId: name,
|
|
199
|
+
isClearable: clearable,
|
|
200
|
+
isDisabled: disabled,
|
|
201
|
+
isLoading: loading,
|
|
202
|
+
isMulti: multiSelect,
|
|
203
|
+
name,
|
|
204
|
+
menuPosition: "fixed",
|
|
205
|
+
menuShouldBlockScroll: true,
|
|
206
|
+
options,
|
|
207
|
+
placeholder,
|
|
208
|
+
onBlur: (_e) => {
|
|
209
|
+
setIsFocused(false);
|
|
210
|
+
return onBlur();
|
|
211
|
+
},
|
|
212
|
+
onChange: (option) => {
|
|
213
|
+
if (multiSelect) {
|
|
214
|
+
onChange(
|
|
215
|
+
option == null ? void 0 : option.map((_option) => _option.value)
|
|
216
|
+
);
|
|
217
|
+
} else {
|
|
218
|
+
onChange(option == null ? void 0 : option.value);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
onFocus: (_e) => {
|
|
222
|
+
setIsFocused(true);
|
|
223
|
+
},
|
|
224
|
+
onInputChange,
|
|
225
|
+
ref,
|
|
226
|
+
value: options.find((option) => option.value === value),
|
|
227
|
+
unstyled: true
|
|
228
|
+
}
|
|
229
|
+
),
|
|
230
|
+
error && // eslint-disable-next-line react/jsx-props-no-spreading
|
|
231
|
+
/* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, getHelperWrapperProps()), { children: /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, getErrorMessageProps()), { children: /* @__PURE__ */ jsx(FieldValidationError_default, { error }) })) }))
|
|
232
|
+
]
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
};
|
|
239
|
+
var Select_default = Select;
|
|
240
|
+
|
|
241
|
+
// src/Select/index.ts
|
|
242
|
+
var Select_default2 = Select_default;
|
|
243
|
+
|
|
244
|
+
export {
|
|
245
|
+
Select_default,
|
|
246
|
+
Select_default2
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=chunk-W66BVPTB.js.map
|
|
@@ -1 +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 ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { Controller } from '../Controller';\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\n // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'pointer-events-auto relative bottom-1.5 ml-1 text-small subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: '!z-50',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'ml-1 py-0.5 pl-1 text-sm text-foreground-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n renderOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst ControlComponent: typeof components.Control = (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']}_select`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Control {...props} />\n </div>\n );\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']}_select_option_${slugify(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}_select_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n label,\n } = useSelect({\n children: [],\n classNames,\n errorMessage: JSON.stringify(error),\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <Controller\n control={control}\n name={name}\n render={({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n field: { onChange, value, ref, onBlur },\n }) => (\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(classNames.base)}\n data-testid={`${testId}_wrapper`}\n // See NextUI styles for group-data condition (data-invalid), e.g.: https://github.com/nextui-org/nextui/blob/main/packages/components/select/src/use-select.ts\n data-required={required}\n >\n {showLabel && (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n {showTestIdCopyButton && (\n <FieldCopyTestIdButton testId={testId} />\n )}\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n aria-invalid={invalid}\n classNames={{\n control: () =>\n cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n }),\n clearIndicator: () => classNames.clearIndicator,\n dropdownIndicator: () => classNames.dropdownIndicator,\n groupHeading: () => classNames.groupHeading,\n indicatorsContainer: () => classNames.indicatorsContainer,\n indicatorSeparator: () => classNames.indicatorSeparator,\n input: () => classNames.input,\n menu: () => classNames.menu,\n menuList: () => classNames.menuList,\n menuPortal: () => classNames.menuPortal,\n multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(classNames.multiValueLabel, `${getValueProps().className}`),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Control: ControlComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={testId}\n filterOption={filterOption}\n formatOptionLabel={renderOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n options={options}\n placeholder={placeholder}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => _option.value),\n );\n } else {\n onChange((option as SelectOption)?.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n onInputChange={onInputChange}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n unstyled\n />\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,SAAS,gBAAgB;AACzB,OAAO,eAAe,kBAAkB;AAExC,SAAS,iBAAiB;AAE1B,SAAS,IAAI,IAAI,4BAA4B;AAmGpC,cA2GG,YA3GH;AA3FF,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;AAAA,IAEP,OACE;AAAA,IACF,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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BAIA,cAAa;AAAA,gBACb,uBAAqB;AAAA,gBACrB;AAAA,gBACA;AAAA,gBACA,QAAQ,CAAC,OAAO;AACd,+BAAa,KAAK;AAClB,yBAAO,OAAO;AAAA,gBAChB;AAAA,gBACA,UAAU,CAAC,WAAW;AACpB,sBAAI,aAAa;AACf;AAAA,sBACG,QAA2B,IAAI,CAAC,YAAY,QAAQ,KAAK;AAAA,oBAC5D;AAAA,kBACF,OAAO;AACL,6BAAU,QAAyB,KAAK;AAAA,kBAC1C;AAAA,gBACF;AAAA,gBACA,SAAS,CAAC,OAAO;AACf,+BAAa,IAAI;AAAA,gBACnB;AAAA,gBACA;AAAA,gBACA;AAAA,gBAEA,OAAO,QAAQ,KAAK,CAAC,WAAW,OAAO,UAAU,KAAK;AAAA,gBACtD,UAAQ;AAAA;AAAA,YACV;AAAA,YACC;AAAA,YAEC,oBAAC,SAAK,GAAG,sBAAsB,GAE7B,8BAAC,SAAK,GAAG,qBAAqB,GAC5B,8BAAC,gCAAqB,OAAc,GACtC,GACF;AAAA;AAAA;AAAA,MAEJ;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,iBAAQ;;;AC/Tf,IAAOA,kBAAQ;","names":["Select_default"]}
|
|
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 ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@nextui-org/select';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { Controller } from '../Controller';\nimport { slugify } from '../helpers';\nimport { useFormContext } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'rounded-lg border-2 border-default-200 !duration-150 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\n // See NextUI styles for group-data condition, e.g.: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'pointer-events-auto relative bottom-1.5 ml-1 text-small subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n loadingIndicator: '',\n loadingMessage: '',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/nextui-org/nextui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: '!z-50',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n placeholder: 'ml-1 py-0.5 pl-1 text-sm text-foreground-500',\n selectContainer: '',\n singleValue: '!ml-1 !leading-7',\n valueContainer: 'gap-1 p-1',\n },\n});\n\ntype SelectOption = {\n /** option label */\n label?: React.ReactNode;\n /** option value */\n value: string;\n};\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** Format the label of the option */\n renderOptionLabel?: undefined | Props['formatOptionLabel'];\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: React.ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** The options for the Select component */\n options: SelectOption[];\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/prop-types, react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst ControlComponent: typeof components.Control = (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']}_select`;\n return (\n <div data-testid={testId}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.Control {...props} />\n </div>\n );\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']}_select_option_${slugify(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}_select_dropdown`}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [NextUI Select](https://nextui.org/docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n disabled = false,\n filterOption = undefined,\n renderOptionLabel = undefined,\n inputValue = undefined,\n label: _label = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n testId: _testId = undefined,\n}: SelectProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, invalid, required, testId } = getFieldState(name, _testId);\n\n const [isFocused, setIsFocused] = useState(false);\n\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n const {\n getBaseProps,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getTriggerProps,\n getValueProps,\n label,\n } = useSelect({\n children: [],\n classNames,\n errorMessage: JSON.stringify(error),\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const showLabel = label || showTestIdCopyButton;\n\n return (\n <Controller\n control={control}\n name={name}\n render={({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n field: { onChange, value, ref, onBlur },\n }) => (\n <div\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...getBaseProps()}\n className={cn(classNames.base)}\n data-testid={`${testId}_wrapper`}\n // See NextUI styles for group-data condition (data-invalid), e.g.: https://github.com/nextui-org/nextui/blob/main/packages/components/select/src/use-select.ts\n data-required={required}\n >\n {showLabel && (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n {showTestIdCopyButton && (\n <FieldCopyTestIdButton testId={testId} />\n )}\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={\n getTriggerProps()['aria-labelledby']?.split(' ')[1]\n }\n aria-invalid={invalid}\n classNames={{\n control: () =>\n cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n }),\n clearIndicator: () => classNames.clearIndicator,\n dropdownIndicator: () => classNames.dropdownIndicator,\n groupHeading: () => classNames.groupHeading,\n indicatorsContainer: () => classNames.indicatorsContainer,\n indicatorSeparator: () => classNames.indicatorSeparator,\n input: () => classNames.input,\n menu: () => classNames.menu,\n menuList: () => classNames.menuList,\n menuPortal: () => classNames.menuPortal,\n multiValue: () => classNames.multiValue,\n multiValueLabel: () =>\n cn(classNames.multiValueLabel, `${getValueProps().className}`),\n multiValueRemove: () => classNames.multiValueRemove,\n noOptionsMessage: () => classNames.noOptionsMessage,\n option: ({\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }) =>\n cn(classNames.option, {\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n }),\n placeholder: () => classNames.placeholder,\n singleValue: () =>\n cn(classNames.singleValue, `${getValueProps().className}`),\n valueContainer: () => classNames.valueContainer,\n }}\n components={{\n Input: InputComponent,\n Option: OptionComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Control: ControlComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={testId}\n filterOption={filterOption}\n formatOptionLabel={renderOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n name={name}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n options={options}\n placeholder={placeholder}\n onBlur={(_e) => {\n setIsFocused(false);\n return onBlur();\n }}\n onChange={(option) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => _option.value),\n );\n } else {\n onChange((option as SelectOption)?.value);\n }\n }}\n onFocus={(_e) => {\n setIsFocused(true);\n }}\n onInputChange={onInputChange}\n ref={ref}\n // set complete option as value by current field value\n value={options.find((option) => option.value === value)}\n unstyled\n />\n {error && (\n // eslint-disable-next-line react/jsx-props-no-spreading\n <div {...getHelperWrapperProps()}>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} />\n </div>\n </div>\n )}\n </div>\n )}\n />\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,SAAS,gBAAgB;AACzB,OAAO,eAAe,kBAAkB;AAExC,SAAS,iBAAiB;AAE1B,SAAS,IAAI,IAAI,4BAA4B;AAmGpC,cA2GG,YA3GH;AA3FF,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;AAAA,IAEP,OACE;AAAA,IACF,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,EACl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U,CAAC,WAAW;AACpB,wBAAI,aAAa;AACf;AAAA,wBACG,iCAA2B,IAAI,CAAC,YAAY,QAAQ;AAAA,sBACvD;AAAA,oBACF,OAAO;AACL,+BAAU,iCAAyB,KAAK;AAAA,oBAC1C;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,cACC;AAAA,cAEC,oBAAC,wCAAQ,sBAAsB,IAA9B,EAEC,8BAAC,wCAAQ,qBAAqB,IAA7B,EACC,8BAAC,gCAAqB,OAAc,IACtC,IACF;AAAA;AAAA;AAAA,QAEJ;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,iBAAQ;;;AC/Tf,IAAOA,kBAAQ;","names":["Select_default"]}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
Controller_default
|
|
3
|
+
} from "./chunk-4EJS5FXY.js";
|
|
4
4
|
import {
|
|
5
5
|
FieldCopyTestIdButton_default
|
|
6
6
|
} from "./chunk-2CRY7VDQ.js";
|
|
7
7
|
import {
|
|
8
8
|
FieldValidationError_default
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VX76MJAI.js";
|
|
10
10
|
import {
|
|
11
|
-
useFormContext
|
|
12
|
-
|
|
11
|
+
useFormContext,
|
|
12
|
+
useInput
|
|
13
|
+
} from "./chunk-MRXNKY72.js";
|
|
14
|
+
import {
|
|
15
|
+
__spreadProps,
|
|
16
|
+
__spreadValues
|
|
17
|
+
} from "./chunk-CRTRMMJ7.js";
|
|
13
18
|
|
|
14
19
|
// src/Switch/Switch.tsx
|
|
15
|
-
import { useInput } from "@nextui-org/input";
|
|
16
20
|
import { Switch as NextSwitch } from "@nextui-org/switch";
|
|
17
21
|
import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
|
|
18
22
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -51,7 +55,7 @@ var Switch = ({
|
|
|
51
55
|
const classNames = variantsToClassNames(variants, className, "outerWrapper");
|
|
52
56
|
const showTestIdCopyButton = debugMode === "debug-testids";
|
|
53
57
|
return /* @__PURE__ */ jsx(
|
|
54
|
-
|
|
58
|
+
Controller_default,
|
|
55
59
|
{
|
|
56
60
|
name,
|
|
57
61
|
control,
|
|
@@ -83,10 +87,9 @@ var Switch = ({
|
|
|
83
87
|
),
|
|
84
88
|
error && /* @__PURE__ */ jsx("div", { className: classNames.errorMessage, children: /* @__PURE__ */ jsx(
|
|
85
89
|
"div",
|
|
86
|
-
{
|
|
87
|
-
...getErrorMessageProps(),
|
|
90
|
+
__spreadProps(__spreadValues({}, getErrorMessageProps()), {
|
|
88
91
|
children: /* @__PURE__ */ jsx(FieldValidationError_default, { error })
|
|
89
|
-
}
|
|
92
|
+
})
|
|
90
93
|
) })
|
|
91
94
|
] })
|
|
92
95
|
}
|
|
@@ -101,4 +104,4 @@ export {
|
|
|
101
104
|
Switch_default,
|
|
102
105
|
Switch_default2
|
|
103
106
|
};
|
|
104
|
-
//# sourceMappingURL=chunk-
|
|
107
|
+
//# sourceMappingURL=chunk-WAXJ64P7.js.map
|