@fuf-stack/uniform 1.6.3 → 1.6.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/Checkboxes/index.cjs +1 -1
- package/dist/Checkboxes/index.js +1 -1
- package/dist/FieldArray/index.cjs +3 -3
- package/dist/FieldArray/index.d.cts +2 -2
- package/dist/FieldArray/index.d.ts +2 -2
- package/dist/FieldArray/index.js +2 -2
- package/dist/{FieldArray-EP4otr2x.d.cts → FieldArray-Cql1zcch.d.cts} +1 -1
- package/dist/{FieldArray-EP4otr2x.d.ts → FieldArray-Cql1zcch.d.ts} +1 -1
- package/dist/Form/index.cjs +3 -3
- package/dist/Form/index.js +2 -2
- package/dist/Input/index.cjs +1 -1
- package/dist/Input/index.js +1 -1
- package/dist/RadioBoxes/index.cjs +1 -1
- package/dist/RadioBoxes/index.js +1 -1
- package/dist/RadioTabs/index.cjs +1 -1
- package/dist/RadioTabs/index.js +1 -1
- package/dist/Radios/index.cjs +1 -1
- package/dist/Radios/index.js +1 -1
- package/dist/Select/index.cjs +1 -1
- 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/SubmitButton/index.cjs +1 -1
- package/dist/SubmitButton/index.js +1 -1
- package/dist/Switch/index.cjs +1 -1
- 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/TextArea/index.cjs +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/{chunk-A2LFA4A7.cjs → chunk-3NNANHVC.cjs} +3 -3
- package/dist/{chunk-A2LFA4A7.cjs.map → chunk-3NNANHVC.cjs.map} +1 -1
- package/dist/{chunk-5BH5XTVC.cjs → chunk-CMTSX5UA.cjs} +22 -3
- package/dist/chunk-CMTSX5UA.cjs.map +1 -0
- package/dist/{chunk-46FKQWMF.js → chunk-M7TOCXYB.js} +2 -2
- package/dist/{chunk-T7S6RMCF.js → chunk-R6IWQWZ6.js} +22 -3
- package/dist/chunk-R6IWQWZ6.js.map +1 -0
- package/dist/{chunk-MOVNWZX5.cjs → chunk-VDTYZM6N.cjs} +8 -2
- package/dist/chunk-VDTYZM6N.cjs.map +1 -0
- package/dist/{chunk-FZQDAI7E.js → chunk-X37C4SVI.js} +8 -2
- package/dist/chunk-X37C4SVI.js.map +1 -0
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useFormContext/index.d.cts +2 -2
- package/dist/hooks/useFormContext/index.d.ts +2 -2
- package/dist/hooks/useUniformFieldArray/index.cjs +2 -2
- package/dist/hooks/useUniformFieldArray/index.js +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/package.json +3 -3
- package/dist/chunk-5BH5XTVC.cjs.map +0 -1
- package/dist/chunk-FZQDAI7E.js.map +0 -1
- package/dist/chunk-MOVNWZX5.cjs.map +0 -1
- package/dist/chunk-T7S6RMCF.js.map +0 -1
- package/dist/{Select-BEHwvmOf.d.cts → Select-CDkZmZp2.d.cts} +9 -9
- package/dist/{Select-BEHwvmOf.d.ts → Select-CDkZmZp2.d.ts} +9 -9
- package/dist/{Switch-BWu3JXl4.d.cts → Switch-Hr6PnK98.d.cts} +3 -3
- package/dist/{Switch-BWu3JXl4.d.ts → Switch-Hr6PnK98.d.ts} +3 -3
- /package/dist/{chunk-46FKQWMF.js.map → chunk-M7TOCXYB.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-CMTSX5UA.cjs","../src/Form/Form.tsx","../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/index.ts"],"names":["_a","jsx","jsxs","cn","Form_default"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACAA,oDAA4B;ADE5B;AACA;AERA,8BA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EAAoB;AACtB,CAAA,EAAA,GAAiB;AACf,EAAA,uBACEC,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,YAAA,EAAc,QAAQ,CAAA,EAAA,GAAM;AAvDtC,QAAA,IAAA,EAAA;AAwDQ,QAAA,uBACEC,8BAAAA,KAAC,EAAA,EAAI,SAAA,EAAU,4CAAA,EACb,QAAA,EAAA;AAAA,0BAAAD,6BAAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAWE,4BAAAA,MAAG,EAAQ,SAAS,CAAA;AAAA,cAC/B,oBAAA,EAAoB,OAAA;AAAA,cACpB,aAAA,EAAa,iCAAA,CAAQ,GAAA,EAAA,OAAA,GAAA,KAAA,EAAA,OAAA,EAAU,IAAA,EAAA,GAAV,KAAA,EAAA,GAAA,EAAkB,EAAE,CAAA;AAAA,cACzC,IAAA;AAAA,cACA,QAAA,EAAU,YAAA;AAAA,cAET;AAAA,YAAA;AAAA,UACH,CAAA;AAAA,UAEC,CAAC,QAAA,GAAW,CAAA,CAAC,MAAA,GAAA,KAAA,EAAA,KAAA,EAAA,EAAA,KAAA,CAAO,OAAA,EAAA,mBACnBF,6BAAAA,uBAAC,EAAA,EAAgB,SAAA,EAAU,cAAA,CAAc;AAAA,QAAA,EAAA,CAE7C,CAAA;AAAA,MAEJ;AAAA,IAAA;AAAA,EACF,CAAA;AAEJ,CAAA;AAEA,IAAO,aAAA,EAAQ,IAAA;ADmFf;AACA;AG5JA,IAAOG,cAAAA,EAAQ,YAAA;AH8Jf;AACA;AACE;AACA;AACF,2EAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-CMTSX5UA.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, slugify } from '@fuf-stack/pixel-utils';\n\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, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\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 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import { 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 } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\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: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>({});\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n // Initialize with current values when debug card is opened\n setValues(getValues() ?? {});\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\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 color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-B62HKKMS.js";
|
|
4
4
|
import {
|
|
5
5
|
useUniformFieldArray
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-X37C4SVI.js";
|
|
7
7
|
import {
|
|
8
8
|
useUniformField
|
|
9
9
|
} from "./chunk-D3JYMGTB.js";
|
|
@@ -696,4 +696,4 @@ export {
|
|
|
696
696
|
FieldArray_default,
|
|
697
697
|
FieldArray_default2
|
|
698
698
|
};
|
|
699
|
-
//# sourceMappingURL=chunk-
|
|
699
|
+
//# sourceMappingURL=chunk-M7TOCXYB.js.map
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { cn as cn2, slugify } from "@fuf-stack/pixel-utils";
|
|
8
8
|
|
|
9
9
|
// src/Form/subcomponents/FormDebugViewer.tsx
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
10
11
|
import { FaTimes } from "react-icons/fa";
|
|
11
12
|
import { FaBug, FaBullseye } from "react-icons/fa6";
|
|
12
13
|
import { cn } from "@fuf-stack/pixel-utils";
|
|
@@ -19,14 +20,32 @@ var FormDebugViewer = ({ className = void 0 }) => {
|
|
|
19
20
|
const {
|
|
20
21
|
debugMode,
|
|
21
22
|
formState: { isValid, isSubmitting, submitCount, isSubmitSuccessful },
|
|
23
|
+
getValues,
|
|
22
24
|
setDebugMode,
|
|
23
25
|
validation: { errors },
|
|
24
|
-
|
|
26
|
+
subscribe
|
|
25
27
|
} = useFormContext();
|
|
26
28
|
const showDebugButton = debugMode === "off";
|
|
27
29
|
const showDebugCard = debugMode === "debug" || debugMode === "debug-testids";
|
|
28
30
|
const showDebugTestIds = debugMode === "debug-testids";
|
|
29
|
-
const values =
|
|
31
|
+
const [values, setValues] = useState({});
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
var _a;
|
|
34
|
+
if (!showDebugCard) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
setValues((_a = getValues()) != null ? _a : {});
|
|
38
|
+
const subscription = subscribe({
|
|
39
|
+
formState: { values: true },
|
|
40
|
+
callback: (state) => {
|
|
41
|
+
var _a2;
|
|
42
|
+
setValues((_a2 = state.values) != null ? _a2 : {});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return () => {
|
|
46
|
+
subscription();
|
|
47
|
+
};
|
|
48
|
+
}, [showDebugCard]);
|
|
30
49
|
if (showDebugButton) {
|
|
31
50
|
return /* @__PURE__ */ jsx(
|
|
32
51
|
Button,
|
|
@@ -148,4 +167,4 @@ export {
|
|
|
148
167
|
Form_default,
|
|
149
168
|
Form_default2
|
|
150
169
|
};
|
|
151
|
-
//# sourceMappingURL=chunk-
|
|
170
|
+
//# sourceMappingURL=chunk-R6IWQWZ6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/Form/Form.tsx","../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/index.ts"],"sourcesContent":["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, slugify } from '@fuf-stack/pixel-utils';\n\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, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\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 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import { 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 } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\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: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n getValues,\n setDebugMode,\n validation: { errors },\n subscribe,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // Use subscribe instead of watch() to avoid triggering re-renders on parent components.\n // This component manages its own state and only updates itself when form values change.\n const [values, setValues] = useState<Record<string, unknown>>({});\n\n useEffect(() => {\n // Only subscribe when debug card is visible\n if (!showDebugCard) {\n return undefined;\n }\n\n // Initialize with current values when debug card is opened\n setValues(getValues() ?? {});\n\n const subscription = subscribe({\n formState: { values: true },\n callback: (state) => {\n setValues(state.values ?? {});\n },\n });\n\n return () => {\n subscription();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showDebugCard]);\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\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 color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import Form from './Form';\n\nexport type {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;AAAA,MAEC,WAAC,EAAE,cAAc,QAAQ,MAAM;AAvDtC;AAwDQ,eACE,gBAAAC,MAAC,SAAI,WAAU,8CACb;AAAA,0BAAAD;AAAA,YAAC;AAAA;AAAA,cACC,WAAWE,IAAG,QAAQ,SAAS;AAAA,cAC/B,sBAAoB;AAAA,cACpB,eAAa,SAAQ,+BAAU,SAAV,YAAkB,EAAE;AAAA,cACzC;AAAA,cACA,UAAU;AAAA,cAET;AAAA;AAAA,UACH;AAAA,UAEC,CAAC,WAAW,EAAC,+BAAO,YACnB,gBAAAF,KAAC,2BAAgB,WAAU,eAAc;AAAA,WAE7C;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,eAAQ;;;AExEf,IAAOG,gBAAQ;","names":["cn","_a","jsx","jsxs","cn","Form_default"]}
|
|
@@ -36,7 +36,9 @@ var useUniformFieldArray = ({
|
|
|
36
36
|
name
|
|
37
37
|
});
|
|
38
38
|
const { trigger, setValue } = _chunk42NCLEX4cjs.useFormContext.call(void 0, );
|
|
39
|
-
const needsInitialize =
|
|
39
|
+
const needsInitialize = _react.useMemo.call(void 0, () => {
|
|
40
|
+
return lastElementNotRemovable && fields.length === 0;
|
|
41
|
+
}, [lastElementNotRemovable, fields.length]);
|
|
40
42
|
const hasInitialized = _react.useRef.call(void 0, !needsInitialize);
|
|
41
43
|
_react.useEffect.call(void 0, () => {
|
|
42
44
|
if (needsInitialize) {
|
|
@@ -79,6 +81,10 @@ var useUniformFieldArray = ({
|
|
|
79
81
|
}
|
|
80
82
|
},
|
|
81
83
|
// Run when needsInitialize changes (initial mount or reset)
|
|
84
|
+
// needsInitialize is memoized based on fields.length and lastElementNotRemovable
|
|
85
|
+
// Other dependencies are intentionally omitted:
|
|
86
|
+
// - append, setValue, trigger, setDisableAnimation are stable refs/functions
|
|
87
|
+
// - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values
|
|
82
88
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
89
|
[needsInitialize]
|
|
84
90
|
);
|
|
@@ -97,4 +103,4 @@ var useUniformFieldArray = ({
|
|
|
97
103
|
|
|
98
104
|
|
|
99
105
|
exports.useUniformFieldArray = useUniformFieldArray;
|
|
100
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-VDTYZM6N.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-VDTYZM6N.cjs","../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,8BAAqD;AACrD,gDAAkD;AAElD,sDAAiC;AAqC1B,IAAM,qBAAA,EAAuB,CAElC;AAAA,EACA,IAAA;AAAA,EACA,KAAA,EAAO,KAAA;AAAA,EACP,mBAAA,EAAqB,qBAAA,EAAuB,IAAA;AAAA,EAC5C,wBAAA,EAA0B,KAAA;AAAA,EAC1B,QAAA;AAAA,EACA,MAAA,EAAQ,cAAA;AAAA,EACR;AACF,CAAA,EAAA,GAA+C;AAE7C,EAAA,MAAM,aAAA,EAAe,+CAAA;AAA8B,IACjD,IAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA,EAAQ,cAAA;AAAA,IACR;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,EAAE,QAAQ,EAAA,EAAI,YAAA;AAEpB,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,KAAK,EAAA,EAAI,0CAAA;AAAiB,IAChE,OAAA;AAAA,IACA;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,EAAE,OAAA,EAAS,SAAS,EAAA,EAAI,8CAAA,CAA6B;AAQ3D,EAAA,MAAM,gBAAA,EAAkB,4BAAA,CAAQ,EAA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A,EAAG,CAAC,IAAA,EAAM,oBAAoB,CAAC,CAAA;AAU/B,EAAA,8BAAA;AAAA,IACE,CAAA,EAAA,GAAM;AACJ,MAAA,GAAA,CAAI,eAAA,EAAiB;AAInB,QAAA,GAAA,CAAI,CAAC,gBAAA,EAAkB;AACrB,UAAA,mBAAA,CAAoB,IAAI,CAAA;AAAA,QAC1B;AAIA,QAAA,QAAA,CAAS,IAAA,EAA4B,CAAC,mBAAmB,CAAA,EAAU;AAAA,UACjE,WAAA,EAAa,KAAA;AAAA,UACb,WAAA,EAAa;AAAA,QACf,CAAC,CAAA;AAGD,QAAA,cAAA,CAAe,QAAA,EAAU,IAAA;AAKzB,QAAA,GAAA,CAAI,CAAC,oBAAA,EAAsB;AACzB,UAAA,UAAA,CAAW,CAAA,EAAA,GAAM;AACf,YAAA,mBAAA,CAAoB,KAAK,CAAA;AAAA,UAC3B,CAAA,EAAG,CAAC,CAAA;AAAA,QACN;AAAA,MACF;AAAA,IACF,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,CAAC,eAAe;AAAA,EAClB,CAAA;AAEA,EAAA,OAAO,8CAAA;AAAA;AAAA,IAEL,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,EAAA,CAAA,EAEG,YAAA,CAAA;AAEP,CAAA;AD3FA;AACA;AACE;AACF,oDAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-VDTYZM6N.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // Disable animations if they're currently enabled (important for reset scenario).\n // During initial mount, animations are already disabled, but after a form reset\n // animations might be enabled, so we need to disable them before adding the element.\n if (!disableAnimation) {\n setDisableAnimation(true);\n }\n\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a 1ms delay (unless user prefers reduced motion).\n // The delay ensures the setValue completes before animations turn on,\n // preventing the initial element from animating in.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n"]}
|
|
@@ -36,7 +36,9 @@ var useUniformFieldArray = ({
|
|
|
36
36
|
name
|
|
37
37
|
});
|
|
38
38
|
const { trigger, setValue } = useFormContext();
|
|
39
|
-
const needsInitialize =
|
|
39
|
+
const needsInitialize = useMemo(() => {
|
|
40
|
+
return lastElementNotRemovable && fields.length === 0;
|
|
41
|
+
}, [lastElementNotRemovable, fields.length]);
|
|
40
42
|
const hasInitialized = useRef(!needsInitialize);
|
|
41
43
|
useEffect(() => {
|
|
42
44
|
if (needsInitialize) {
|
|
@@ -79,6 +81,10 @@ var useUniformFieldArray = ({
|
|
|
79
81
|
}
|
|
80
82
|
},
|
|
81
83
|
// Run when needsInitialize changes (initial mount or reset)
|
|
84
|
+
// needsInitialize is memoized based on fields.length and lastElementNotRemovable
|
|
85
|
+
// Other dependencies are intentionally omitted:
|
|
86
|
+
// - append, setValue, trigger, setDisableAnimation are stable refs/functions
|
|
87
|
+
// - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values
|
|
82
88
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
89
|
[needsInitialize]
|
|
84
90
|
);
|
|
@@ -97,4 +103,4 @@ var useUniformFieldArray = ({
|
|
|
97
103
|
export {
|
|
98
104
|
useUniformFieldArray
|
|
99
105
|
};
|
|
100
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-X37C4SVI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // Disable animations if they're currently enabled (important for reset scenario).\n // During initial mount, animations are already disabled, but after a form reset\n // animations might be enabled, so we need to disable them before adding the element.\n if (!disableAnimation) {\n setDisableAnimation(true);\n }\n\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a 1ms delay (unless user prefers reduced motion).\n // The delay ensures the setValue completes before animations turn on,\n // preventing the initial element from animating in.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAGA,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AACrD,SAAS,iBAAiB,wBAAwB;AAElD,SAAS,wBAAwB;AAqC1B,IAAM,uBAAuB,CAElC;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,qBAAqB,uBAAuB;AAAA,EAC5C,0BAA0B;AAAA,EAC1B;AAAA,EACA,QAAQ;AAAA,EACR;AACF,MAA+C;AAE7C,QAAM,eAAe,gBAA8B;AAAA,IACjD;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,EACF,CAAC;AAED,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,KAAK,IAAI,iBAAiB;AAAA,IAChE;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,EAAE,SAAS,SAAS,IAAI,eAA6B;AAQ3D,QAAM,kBAAkB,QAAQ,MAAM;AACpC,WAAO,2BAA2B,OAAO,WAAW;AAAA,EACtD,GAAG,CAAC,yBAAyB,OAAO,MAAM,CAAC;AAS3C,QAAM,iBAAiB,OAAO,CAAC,eAAe;AAK9C,YAAU,MAAM;AACd,QAAI,iBAAiB;AACnB,qBAAe,UAAU;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,eAAe,CAAC;AAIpB,YAAU,M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|
|
|
10
|
-
var
|
|
10
|
+
var _chunkVDTYZM6Ncjs = require('../chunk-VDTYZM6N.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
var _chunkSOQ6GCN3cjs = require('../chunk-SOQ6GCN3.cjs');
|
|
@@ -40,5 +40,5 @@ require('../chunk-555JRYCS.cjs');
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
exports.checkFieldIsRequired = _chunk42NCLEX4cjs.checkFieldIsRequired; exports.clientValidationSchemaByName = _chunkD3EZXJQHcjs.clientValidationSchemaByName; exports.useClientValidation = _chunkD3EZXJQHcjs.useClientValidation; exports.useController = _chunkJMFDNTVCcjs.useController; exports.useFormContext = _chunk42NCLEX4cjs.useFormContext; exports.useInput = _chunkPCTYJUY7cjs.useInput; exports.useInputValueDebounce = _chunkBZ5OMN4Ycjs.useInputValueDebounce; exports.useInputValueTransform = _chunk4WYC2RBEcjs.useInputValueTransform; exports.useUniformField = _chunkSOQ6GCN3cjs.useUniformField; exports.useUniformFieldArray =
|
|
43
|
+
exports.checkFieldIsRequired = _chunk42NCLEX4cjs.checkFieldIsRequired; exports.clientValidationSchemaByName = _chunkD3EZXJQHcjs.clientValidationSchemaByName; exports.useClientValidation = _chunkD3EZXJQHcjs.useClientValidation; exports.useController = _chunkJMFDNTVCcjs.useController; exports.useFormContext = _chunk42NCLEX4cjs.useFormContext; exports.useInput = _chunkPCTYJUY7cjs.useInput; exports.useInputValueDebounce = _chunkBZ5OMN4Ycjs.useInputValueDebounce; exports.useInputValueTransform = _chunk4WYC2RBEcjs.useInputValueTransform; exports.useUniformField = _chunkSOQ6GCN3cjs.useUniformField; exports.useUniformFieldArray = _chunkVDTYZM6Ncjs.useUniformFieldArray;
|
|
44
44
|
//# sourceMappingURL=index.cjs.map
|
package/dist/hooks/index.js
CHANGED
|
@@ -24,10 +24,10 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
|
|
|
24
24
|
getValues: react_hook_form.UseFormGetValues<TFieldValues>;
|
|
25
25
|
subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
|
|
26
26
|
watch: react_hook_form.UseFormWatch<TFieldValues>;
|
|
27
|
-
debugMode: "
|
|
27
|
+
debugMode: "debug" | "debug-testids" | "off" | "disabled";
|
|
28
28
|
debugModeSettings?: DebugModeSettings;
|
|
29
29
|
preventSubmit: (prevent: boolean) => void;
|
|
30
|
-
setDebugMode: (debugMode: "
|
|
30
|
+
setDebugMode: (debugMode: "debug" | "debug-testids" | "off" | "disabled") => void;
|
|
31
31
|
triggerSubmit: (e?: React.BaseSyntheticEvent) => Promise<void> | void;
|
|
32
32
|
validation: {
|
|
33
33
|
baseInstance?: VetoInstance;
|
|
@@ -24,10 +24,10 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
|
|
|
24
24
|
getValues: react_hook_form.UseFormGetValues<TFieldValues>;
|
|
25
25
|
subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
|
|
26
26
|
watch: react_hook_form.UseFormWatch<TFieldValues>;
|
|
27
|
-
debugMode: "
|
|
27
|
+
debugMode: "debug" | "debug-testids" | "off" | "disabled";
|
|
28
28
|
debugModeSettings?: DebugModeSettings;
|
|
29
29
|
preventSubmit: (prevent: boolean) => void;
|
|
30
|
-
setDebugMode: (debugMode: "
|
|
30
|
+
setDebugMode: (debugMode: "debug" | "debug-testids" | "off" | "disabled") => void;
|
|
31
31
|
triggerSubmit: (e?: React.BaseSyntheticEvent) => Promise<void> | void;
|
|
32
32
|
validation: {
|
|
33
33
|
baseInstance?: VetoInstance;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkVDTYZM6Ncjs = require('../../chunk-VDTYZM6N.cjs');
|
|
4
4
|
require('../../chunk-SOQ6GCN3.cjs');
|
|
5
5
|
require('../../chunk-NHEZXA4H.cjs');
|
|
6
6
|
require('../../chunk-JMFDNTVC.cjs');
|
|
@@ -11,5 +11,5 @@ require('../../chunk-Z353BLWI.cjs');
|
|
|
11
11
|
require('../../chunk-555JRYCS.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.useUniformFieldArray =
|
|
14
|
+
exports.useUniformFieldArray = _chunkVDTYZM6Ncjs.useUniformFieldArray;
|
|
15
15
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs
CHANGED
|
@@ -18,10 +18,10 @@ var _chunkHANR2BDXcjs = require('./chunk-HANR2BDX.cjs');
|
|
|
18
18
|
var _chunkHEGORLRFcjs = require('./chunk-HEGORLRF.cjs');
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunk3NNANHVCcjs = require('./chunk-3NNANHVC.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _chunkCMTSX5UAcjs = require('./chunk-CMTSX5UA.cjs');
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
var _chunkTTD3KL6Ecjs = require('./chunk-TTD3KL6E.cjs');
|
|
@@ -43,7 +43,7 @@ var _chunkBZ5OMN4Ycjs = require('./chunk-BZ5OMN4Y.cjs');
|
|
|
43
43
|
var _chunk4WYC2RBEcjs = require('./chunk-4WYC2RBE.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _chunkVDTYZM6Ncjs = require('./chunk-VDTYZM6N.cjs');
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
var _chunkSOQ6GCN3cjs = require('./chunk-SOQ6GCN3.cjs');
|
|
@@ -105,5 +105,5 @@ require('./chunk-555JRYCS.cjs');
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
exports.Checkboxes = _chunkHEGORLRFcjs.Checkboxes_default; exports.FieldArray =
|
|
108
|
+
exports.Checkboxes = _chunkHEGORLRFcjs.Checkboxes_default; exports.FieldArray = _chunk3NNANHVCcjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkOE5BOGGXcjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkNHEZXA4Hcjs.FieldValidationError_default; exports.Form = _chunkCMTSX5UAcjs.Form_default; exports.Grid = _chunkTTD3KL6Ecjs.Grid_default; exports.Input = _chunk7NZVPVK3cjs.Input_default; exports.RadioBoxes = _chunkV3NNJJHYcjs.RadioBoxes_default; exports.RadioTabs = _chunk4Z7LIJHZcjs.RadioTabs_default; exports.Radios = _chunk4ATOAQOFcjs.Radios_default; exports.Select = _chunkQAQ3UP7Wcjs.Select_default; exports.SubmitButton = _chunkPC3VCEGMcjs.SubmitButton_default; exports.Switch = _chunkHX2JJ2ZKcjs.Switch_default; exports.TextArea = _chunkHANR2BDXcjs.TextArea_default; exports.checkFieldIsRequired = _chunk42NCLEX4cjs.checkFieldIsRequired; exports.clientValidationSchemaByName = _chunkD3EZXJQHcjs.clientValidationSchemaByName; exports.flatArrayKey = _chunkZ353BLWIcjs.flatArrayKey; exports.fromNullishString = _chunkZ353BLWIcjs.fromNullishString; exports.toFormFormat = _chunkZ353BLWIcjs.toFormFormat; exports.toNullishString = _chunkZ353BLWIcjs.toNullishString; exports.toValidationFormat = _chunkZ353BLWIcjs.toValidationFormat; exports.useClientValidation = _chunkD3EZXJQHcjs.useClientValidation; exports.useController = _chunkJMFDNTVCcjs.useController; exports.useFormContext = _chunk42NCLEX4cjs.useFormContext; exports.useInput = _chunkPCTYJUY7cjs.useInput; exports.useInputValueDebounce = _chunkBZ5OMN4Ycjs.useInputValueDebounce; exports.useInputValueTransform = _chunk4WYC2RBEcjs.useInputValueTransform; exports.useUniformField = _chunkSOQ6GCN3cjs.useUniformField; exports.useUniformFieldArray = _chunkVDTYZM6Ncjs.useUniformFieldArray;
|
|
109
109
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { b as CheckboxOption, C as Checkboxes, a as CheckboxesProps } from './Checkboxes-CR0Uu2g9.cjs';
|
|
2
|
-
export { F as FieldArray, a as FieldArrayChildrenRenderFn, b as FieldArrayFeatures, c as FieldArrayProps } from './FieldArray-
|
|
2
|
+
export { F as FieldArray, a as FieldArrayChildrenRenderFn, b as FieldArrayFeatures, c as FieldArrayProps } from './FieldArray-Cql1zcch.cjs';
|
|
3
3
|
export { F as Form, a as FormProps } from './Form-Cu0lWRDN.cjs';
|
|
4
4
|
export { G as Grid, a as GridProps } from './Grid-DF3L9NF3.cjs';
|
|
5
5
|
export { flatArrayKey, fromNullishString, toFormFormat, toNullishString, toValidationFormat } from './helpers/index.cjs';
|
|
@@ -17,9 +17,9 @@ export { F as FieldValidationError, a as FieldValidationErrorProps } from './Fie
|
|
|
17
17
|
export { R as RadioBoxes, a as RadioBoxesProps } from './RadioBoxes-DpkI28l0.cjs';
|
|
18
18
|
export { R as Radios, a as RadiosProps } from './Radios-DprlJhoq.cjs';
|
|
19
19
|
export { R as RadioTabs, a as RadioTabsProps } from './RadioTabs-DTDcAZoH.cjs';
|
|
20
|
-
export { S as Select, a as SelectProps } from './Select-
|
|
20
|
+
export { S as Select, a as SelectProps } from './Select-CDkZmZp2.cjs';
|
|
21
21
|
export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-DqaxyVpp.cjs';
|
|
22
|
-
export { S as Switch, a as SwitchProps } from './Switch-
|
|
22
|
+
export { S as Switch, a as SwitchProps } from './Switch-Hr6PnK98.cjs';
|
|
23
23
|
export { T as TextArea, a as TextAreaProps } from './TextArea-DhxNWYNg.cjs';
|
|
24
24
|
import 'react/jsx-runtime';
|
|
25
25
|
import 'tailwind-variants';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { b as CheckboxOption, C as Checkboxes, a as CheckboxesProps } from './Checkboxes-CR0Uu2g9.js';
|
|
2
|
-
export { F as FieldArray, a as FieldArrayChildrenRenderFn, b as FieldArrayFeatures, c as FieldArrayProps } from './FieldArray-
|
|
2
|
+
export { F as FieldArray, a as FieldArrayChildrenRenderFn, b as FieldArrayFeatures, c as FieldArrayProps } from './FieldArray-Cql1zcch.js';
|
|
3
3
|
export { F as Form, a as FormProps } from './Form-C_11i6PA.js';
|
|
4
4
|
export { G as Grid, a as GridProps } from './Grid-DF3L9NF3.js';
|
|
5
5
|
export { flatArrayKey, fromNullishString, toFormFormat, toNullishString, toValidationFormat } from './helpers/index.js';
|
|
@@ -17,9 +17,9 @@ export { F as FieldValidationError, a as FieldValidationErrorProps } from './Fie
|
|
|
17
17
|
export { R as RadioBoxes, a as RadioBoxesProps } from './RadioBoxes-DpkI28l0.js';
|
|
18
18
|
export { R as Radios, a as RadiosProps } from './Radios-DprlJhoq.js';
|
|
19
19
|
export { R as RadioTabs, a as RadioTabsProps } from './RadioTabs-DTDcAZoH.js';
|
|
20
|
-
export { S as Select, a as SelectProps } from './Select-
|
|
20
|
+
export { S as Select, a as SelectProps } from './Select-CDkZmZp2.js';
|
|
21
21
|
export { S as SubmitButton, a as SubmitButtonProps } from './SubmitButton-DqaxyVpp.js';
|
|
22
|
-
export { S as Switch, a as SwitchProps } from './Switch-
|
|
22
|
+
export { S as Switch, a as SwitchProps } from './Switch-Hr6PnK98.js';
|
|
23
23
|
export { T as TextArea, a as TextAreaProps } from './TextArea-DhxNWYNg.js';
|
|
24
24
|
import 'react/jsx-runtime';
|
|
25
25
|
import 'tailwind-variants';
|
package/dist/index.js
CHANGED
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
} from "./chunk-TB5WXGWX.js";
|
|
19
19
|
import {
|
|
20
20
|
FieldArray_default
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-M7TOCXYB.js";
|
|
22
22
|
import {
|
|
23
23
|
Form_default
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-R6IWQWZ6.js";
|
|
25
25
|
import {
|
|
26
26
|
Grid_default
|
|
27
27
|
} from "./chunk-B62HKKMS.js";
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
} from "./chunk-7KLFK2IT.js";
|
|
44
44
|
import {
|
|
45
45
|
useUniformFieldArray
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-X37C4SVI.js";
|
|
47
47
|
import {
|
|
48
48
|
useUniformField
|
|
49
49
|
} from "./chunk-D3JYMGTB.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Fröhlich ∧ Frei",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/pixels#readme",
|
|
@@ -175,8 +175,8 @@
|
|
|
175
175
|
"react-select": "5.10.2",
|
|
176
176
|
"@fuf-stack/pixel-motion": "1.0.26",
|
|
177
177
|
"@fuf-stack/pixel-utils": "1.0.5",
|
|
178
|
-
"@fuf-stack/
|
|
179
|
-
"@fuf-stack/
|
|
178
|
+
"@fuf-stack/veto": "0.12.6",
|
|
179
|
+
"@fuf-stack/pixels": "1.3.8"
|
|
180
180
|
},
|
|
181
181
|
"devDependencies": {
|
|
182
182
|
"@types/debug": "4.1.12",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-5BH5XTVC.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;AACA;ACAA,oDAA4B;ADE5B;AACA;AERA,oCAAwB;AACxB,sCAAkC;AAElC;AACA,kDAAuB;AACvB,8CAAqB;AACrB,8CAAqB;AAKrB,sCAAO;AA8BO,+CAAA;AAtBd,IAAM,gBAAA,EAAkB,CAAC,EAAE,UAAA,EAAY,KAAA,EAAU,CAAA,EAAA,GAA4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AA;AAAA,EACF,CAAA;AAEJ,CAAA;AAEA,IAAO,aAAA,EAAQ,IAAA;ADgEf;AACA;AGzIA,IAAOG,cAAAA,EAAQ,YAAA;AH2If;AACA;AACE;AACA;AACF,2EAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-5BH5XTVC.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, slugify } from '@fuf-stack/pixel-utils';\n\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, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\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 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\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: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n setDebugMode,\n validation: { errors },\n watch,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // TODO: maybe use new Watch component?\n // see: https://github.com/react-hook-form/react-hook-form/pull/12986\n const values = watch();\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\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 color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n const needsInitialize = lastElementNotRemovable && fields.length === 0;\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // Disable animations if they're currently enabled (important for reset scenario).\n // During initial mount, animations are already disabled, but after a form reset\n // animations might be enabled, so we need to disable them before adding the element.\n if (!disableAnimation) {\n setDisableAnimation(true);\n }\n\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a 1ms delay (unless user prefers reduced motion).\n // The delay ensures the setValue completes before animations turn on,\n // preventing the initial element from animating in.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n"],"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GAAG,CAAC,MAAM,oBAAoB,CAAC;AAU/B;AAAA,IACE,MAAM;AACJ,UAAI,iBAAiB;AAInB,YAAI,CAAC,kBAAkB;AACrB,8BAAoB,IAAI;AAAA,QAC1B;AAIA,iBAAS,MAA4B,CAAC,mBAAmB,GAAU;AAAA,UACjE,aAAa;AAAA,UACb,aAAa;AAAA,QACf,CAAC;AAGD,uBAAe,UAAU;AAKzB,YAAI,CAAC,sBAAsB;AACzB,qBAAW,MAAM;AACf,gCAAoB,KAAK;AAAA,UAC3B,GAAG,CAAC;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA,IAGA,CAAC,eAAe;AAAA,EAClB;AAEA,SAAO;AAAA;AAAA,IAEL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEG;AAEP;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MOVNWZX5.cjs","../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,8BAAqD;AACrD,gDAAkD;AAElD,sDAAiC;AAqC1B,IAAM,qBAAA,EAAuB,CAElC;AAAA,EACA,IAAA;AAAA,EACA,KAAA,EAAO,KAAA;AAAA,EACP,mBAAA,EAAqB,qBAAA,EAAuB,IAAA;AAAA,EAC5C,wBAAA,EAA0B,KAAA;AAAA,EAC1B,QAAA;AAAA,EACA,MAAA,EAAQ,cAAA;AAAA,EACR;AACF,CAAA,EAAA,GAA+C;AAE7C,EAAA,MAAM,aAAA,EAAe,+CAAA;AAA8B,IACjD,IAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA,EAAQ,cAAA;AAAA,IACR;AAAA,EACF,CAAC,CAAA;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AQ,EAAA,GAAM;AACxC,IAAA,OAAO,KAAA,EACH,EAAE,CAAC,8BAAY,CAAA,EAAG,qBAAA,GAAA,KAAA,EAAA,qBAAA,EAAwB,KAAK,EAAA,EAC9C,qBAAA,GAAA,KAAA,EAAA,qBAAA,EAAwB,CAAC,CAAA;AAAA,EAChC,CAAA,EAAG,CAAC,IAAA,EAAM,oBAAoB,CAAC,CAAA;AAU/B,EAAA,8BAAA;AAAA,IACE,CAAA,EAAA,GAAM;AACJ,MAAA,GAAA,CAAI,eAAA,EAAiB;AAInB,QAAA,GAAA,CAAI,CAAC,gBAAA,EAAkB;AACrB,UAAA,mBAAA,CAAoB,IAAI,CAAA;AAAA,QAC1B;AAIA,QAAA,QAAA,CAAS,IAAA,EAA4B,CAAC,mBAAmB,CAAA,EAAU;AAAA,UACjE,WAAA,EAAa,KAAA;AAAA,UACb,WAAA,EAAa;AAAA,QACf,CAAC,CAAA;AAGD,QAAA,cAAA,CAAe,QAAA,EAAU,IAAA;AAKzB,QAAA,GAAA,CAAI,CAAC,oBAAA,EAAsB;AACzB,UAAA,UAAA,CAAW,CAAA,EAAA,GAAM;AACf,YAAA,mBAAA,CAAoB,KAAK,CAAA;AAAA,UAC3B,CAAA,EAAG,CAAC,CAAA;AAAA,QACN;AAAA,MACF;AAAA,IACF,CAAA;AAAA;AAAA;AAAA,IAGA,CAAC,eAAe;AAAA,EAClB,CAAA;AAEA,EAAA,OAAO,8CAAA;AAAA;AAAA,IAEL,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,EAAA,CAAA,EAEG,YAAA,CAAA;AAEP,CAAA;AD1FA;AACA;AACE;AACF,oDAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MOVNWZX5.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n const needsInitialize = lastElementNotRemovable && fields.length === 0;\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // Disable animations if they're currently enabled (important for reset scenario).\n // During initial mount, animations are already disabled, but after a form reset\n // animations might be enabled, so we need to disable them before adding the element.\n if (!disableAnimation) {\n setDisableAnimation(true);\n }\n\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a 1ms delay (unless user prefers reduced motion).\n // The delay ensures the setValue completes before animations turn on,\n // preventing the initial element from animating in.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Form/Form.tsx","../src/Form/subcomponents/FormDebugViewer.tsx","../src/Form/index.ts"],"sourcesContent":["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, slugify } from '@fuf-stack/pixel-utils';\n\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, isValid }) => {\n return (\n <div className=\"flex w-full flex-row justify-between gap-6\">\n <form\n className={cn('grow', className)}\n data-form-is-valid={isValid}\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 shrink\" />\n )}\n </div>\n );\n }}\n </FormProvider>\n );\n};\n\nexport default Form;\n","import { FaTimes } from 'react-icons/fa';\nimport { FaBug, FaBullseye } from 'react-icons/fa6';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels/Button';\nimport { Card } from '@fuf-stack/pixels/Card';\nimport { Json } from '@fuf-stack/pixels/Json';\n\nimport { useFormContext } from '../../hooks';\n\n// import Json css (theme)\nimport '@fuf-stack/pixels/Json.css';\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: { isValid, isSubmitting, submitCount, isSubmitSuccessful },\n setDebugMode,\n validation: { errors },\n watch,\n } = useFormContext();\n\n const showDebugButton = debugMode === 'off';\n const showDebugCard = debugMode === 'debug' || debugMode === 'debug-testids';\n const showDebugTestIds = debugMode === 'debug-testids';\n\n // TODO: maybe use new Watch component?\n // see: https://github.com/react-hook-form/react-hook-form/pull/12986\n const values = watch();\n\n if (showDebugButton) {\n return (\n <Button\n ariaLabel=\"Enable form debug mode\"\n className=\"fixed bottom-2.5 right-2.5 w-5 text-default-400\"\n icon={<FaBug />}\n variant=\"light\"\n onClick={() => {\n setDebugMode('debug');\n }}\n />\n );\n }\n\n // do not show card\n if (!showDebugCard) {\n return null;\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 color=\"danger\"\n icon={<FaTimes />}\n size=\"sm\"\n variant=\"light\"\n onClick={() => {\n setDebugMode('off');\n }}\n />\n </div>\n }\n >\n <Button\n className=\"mb-4 ml-auto mr-auto\"\n icon={<FaBullseye />}\n variant={showDebugTestIds ? 'solid' : 'light'}\n onClick={() => {\n setDebugMode(debugMode === 'debug' ? 'debug-testids' : 'debug');\n }}\n >\n {showDebugTestIds ? 'Hide CopyButton' : 'Show CopyButton'}\n </Button>\n <Json\n value={{\n values,\n errors: errors ?? null,\n submit: {\n isValid,\n isSubmitting,\n isSubmitSuccessful,\n submitCount,\n },\n }}\n />\n </Card>\n );\n};\n\nexport default FormDebugViewer;\n","import Form from './Form';\n\nexport type { FormProps } from './Form';\n\nexport { Form };\n\nexport default Form;\n"],"mappings":";;;;;;AAKA,SAAS,MAAAA,KAAI,eAAe;;;ACL5B,SAAS,eAAe;AACxB,SAAS,OAAO,kBAAkB;AAElC,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AAKrB,OAAO;AA8BO,cAkBN,YAlBM;AAtBd,IAAM,kBAAkB,CAAC,EAAE,YAAY,OAAU,MAA4B;AAC3E,QA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A,gBACA;AAAA,cACF;AAAA,YACF;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,0BAAQ;;;AD1CL,SACE,OAAAC,MADF,QAAAC,aAAA;AA/CV,IAAM,UAAU,QAAQ,IAAI,aAAa;AA0BzC,IAAM,OAAO,CAAC;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AAAA,EACb,oBAAoB;AACtB,MAAiB;AACf,SACE,gBAAAD;AAAA,IAAC;AAAA;AAAA,MACC,mBAAmB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC,WAAC,EAAE,cAAc,QAAQ,MAAM;AAvDtC;AAwDQ,eACE,gBAAAC,MAAC,SAAI,WAAU,8CACb;AAAA,0BAAAD;AAAA,YAAC;AAAA;AAAA,cACC,WAAWE,IAAG,QAAQ,SAAS;AAAA,cAC/B,sBAAoB;AAAA,cACpB,eAAa,SAAQ,+BAAU,SAAV,YAAkB,EAAE;AAAA,cACzC;AAAA,cACA,UAAU;AAAA,cAET;AAAA;AAAA,UACH;AAAA,UAEC,CAAC,WAAW,EAAC,+BAAO,YACnB,gBAAAF,KAAC,2BAAgB,WAAU,eAAc;AAAA,WAE7C;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,eAAQ;;;AExEf,IAAOG,gBAAQ;","names":["cn","jsx","jsxs","cn","Form_default"]}
|
|
@@ -6,13 +6,13 @@ import { Props } from 'react-select';
|
|
|
6
6
|
declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
7
7
|
[key: string]: {
|
|
8
8
|
[key: string]: tailwind_variants.ClassValue | {
|
|
9
|
-
base?: tailwind_variants.ClassValue;
|
|
10
|
-
label?: tailwind_variants.ClassValue;
|
|
11
|
-
group?: tailwind_variants.ClassValue;
|
|
12
9
|
control?: tailwind_variants.ClassValue;
|
|
10
|
+
base?: tailwind_variants.ClassValue;
|
|
13
11
|
input?: tailwind_variants.ClassValue;
|
|
12
|
+
label?: tailwind_variants.ClassValue;
|
|
14
13
|
menu?: tailwind_variants.ClassValue;
|
|
15
14
|
option?: tailwind_variants.ClassValue;
|
|
15
|
+
group?: tailwind_variants.ClassValue;
|
|
16
16
|
placeholder?: tailwind_variants.ClassValue;
|
|
17
17
|
clearIndicator?: tailwind_variants.ClassValue;
|
|
18
18
|
control_focused?: tailwind_variants.ClassValue;
|
|
@@ -41,13 +41,13 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
41
41
|
} | {
|
|
42
42
|
[x: string]: {
|
|
43
43
|
[x: string]: tailwind_variants.ClassValue | {
|
|
44
|
-
base?: tailwind_variants.ClassValue;
|
|
45
|
-
label?: tailwind_variants.ClassValue;
|
|
46
|
-
group?: tailwind_variants.ClassValue;
|
|
47
44
|
control?: tailwind_variants.ClassValue;
|
|
45
|
+
base?: tailwind_variants.ClassValue;
|
|
48
46
|
input?: tailwind_variants.ClassValue;
|
|
47
|
+
label?: tailwind_variants.ClassValue;
|
|
49
48
|
menu?: tailwind_variants.ClassValue;
|
|
50
49
|
option?: tailwind_variants.ClassValue;
|
|
50
|
+
group?: tailwind_variants.ClassValue;
|
|
51
51
|
placeholder?: tailwind_variants.ClassValue;
|
|
52
52
|
clearIndicator?: tailwind_variants.ClassValue;
|
|
53
53
|
control_focused?: tailwind_variants.ClassValue;
|
|
@@ -107,13 +107,13 @@ declare const selectVariants: tailwind_variants.TVReturnType<{
|
|
|
107
107
|
}, undefined, {
|
|
108
108
|
[key: string]: {
|
|
109
109
|
[key: string]: tailwind_variants.ClassValue | {
|
|
110
|
-
base?: tailwind_variants.ClassValue;
|
|
111
|
-
label?: tailwind_variants.ClassValue;
|
|
112
|
-
group?: tailwind_variants.ClassValue;
|
|
113
110
|
control?: tailwind_variants.ClassValue;
|
|
111
|
+
base?: tailwind_variants.ClassValue;
|
|
114
112
|
input?: tailwind_variants.ClassValue;
|
|
113
|
+
label?: tailwind_variants.ClassValue;
|
|
115
114
|
menu?: tailwind_variants.ClassValue;
|
|
116
115
|
option?: tailwind_variants.ClassValue;
|
|
116
|
+
group?: tailwind_variants.ClassValue;
|
|
117
117
|
placeholder?: tailwind_variants.ClassValue;
|
|
118
118
|
clearIndicator?: tailwind_variants.ClassValue;
|
|
119
119
|
control_focused?: tailwind_variants.ClassValue;
|