@fuf-stack/uniform 0.21.0 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CheckboxGroup/index.cjs +3 -3
- package/dist/CheckboxGroup/index.js +2 -2
- package/dist/FieldArray/index.cjs +3 -3
- package/dist/FieldArray/index.js +2 -2
- package/dist/Form/index.cjs +3 -3
- package/dist/Form/index.js +2 -2
- package/dist/Input/index.cjs +3 -3
- package/dist/Input/index.js +2 -2
- package/dist/RadioBoxes/index.cjs +3 -3
- package/dist/RadioBoxes/index.js +2 -2
- package/dist/RadioGroup/index.cjs +3 -3
- package/dist/RadioGroup/index.js +2 -2
- package/dist/RadioTabs/index.cjs +3 -3
- package/dist/RadioTabs/index.js +2 -2
- package/dist/Select/index.cjs +3 -3
- package/dist/Select/index.js +2 -2
- package/dist/SubmitButton/index.cjs +3 -3
- package/dist/SubmitButton/index.js +2 -2
- package/dist/Switch/index.cjs +3 -3
- package/dist/Switch/index.js +2 -2
- package/dist/TextArea/index.cjs +3 -3
- package/dist/TextArea/index.js +2 -2
- package/dist/{chunk-WGUKDO53.cjs → chunk-34SC6752.cjs} +7 -7
- package/dist/{chunk-WGUKDO53.cjs.map → chunk-34SC6752.cjs.map} +1 -1
- package/dist/{chunk-DOU4QUFP.cjs → chunk-3CZLX3GW.cjs} +4 -4
- package/dist/{chunk-DOU4QUFP.cjs.map → chunk-3CZLX3GW.cjs.map} +1 -1
- package/dist/{chunk-GQ7PNPVN.js → chunk-4YF424NV.js} +3 -3
- package/dist/{chunk-GQ7PNPVN.js.map → chunk-4YF424NV.js.map} +1 -1
- package/dist/{chunk-WU7AHUO6.cjs → chunk-6DZMJL6A.cjs} +5 -5
- package/dist/{chunk-WU7AHUO6.cjs.map → chunk-6DZMJL6A.cjs.map} +1 -1
- package/dist/{chunk-SXYWWUMK.cjs → chunk-EHQPOPGR.cjs} +4 -4
- package/dist/{chunk-SXYWWUMK.cjs.map → chunk-EHQPOPGR.cjs.map} +1 -1
- package/dist/{chunk-5PNXBS5K.cjs → chunk-G4GCGAMX.cjs} +3 -3
- package/dist/{chunk-5PNXBS5K.cjs.map → chunk-G4GCGAMX.cjs.map} +1 -1
- package/dist/{chunk-C5LVVYXY.js → chunk-GFXPCQYY.js} +2 -2
- package/dist/{chunk-W5F54CXQ.js → chunk-HJDFEGSC.js} +3 -3
- package/dist/{chunk-W5F54CXQ.js.map → chunk-HJDFEGSC.js.map} +1 -1
- package/dist/{chunk-UTKY3KL2.js → chunk-HUYCOUFA.js} +2 -2
- package/dist/{chunk-JQGCMXUB.js → chunk-L4F26TIF.js} +2 -2
- package/dist/{chunk-P44L3XR4.js → chunk-LASW5L3O.js} +2 -2
- package/dist/{chunk-KNP3VJSM.js → chunk-LUHX3EP6.js} +2 -2
- package/dist/{chunk-4AWDOV7M.js → chunk-MC56FOMX.js} +1 -1
- package/dist/chunk-MC56FOMX.js.map +1 -0
- package/dist/{chunk-TEDFGOE4.cjs → chunk-MQFKDXKT.cjs} +5 -5
- package/dist/chunk-MQFKDXKT.cjs.map +1 -0
- package/dist/{chunk-SIUB4YCG.js → chunk-N4V3GR6P.js} +3 -3
- package/dist/chunk-N4V3GR6P.js.map +1 -0
- package/dist/{chunk-ZZ4Q3FLC.cjs → chunk-NFMNQHP7.cjs} +1 -1
- package/dist/chunk-NFMNQHP7.cjs.map +1 -0
- package/dist/{chunk-K2B7NTWK.cjs → chunk-RJ4DYKAV.cjs} +4 -4
- package/dist/{chunk-K2B7NTWK.cjs.map → chunk-RJ4DYKAV.cjs.map} +1 -1
- package/dist/{chunk-J7NVQTEW.cjs → chunk-T7PSOKMV.cjs} +5 -5
- package/dist/{chunk-J7NVQTEW.cjs.map → chunk-T7PSOKMV.cjs.map} +1 -1
- package/dist/{chunk-CK5D6TE5.cjs → chunk-TPID3SYN.cjs} +4 -4
- package/dist/{chunk-CK5D6TE5.cjs.map → chunk-TPID3SYN.cjs.map} +1 -1
- package/dist/{chunk-TZ2CW6AS.cjs → chunk-XB3XIDVB.cjs} +5 -5
- package/dist/{chunk-TZ2CW6AS.cjs.map → chunk-XB3XIDVB.cjs.map} +1 -1
- package/dist/{chunk-BUNJMA4O.cjs → chunk-YCM5J5E4.cjs} +4 -4
- package/dist/{chunk-BUNJMA4O.cjs.map → chunk-YCM5J5E4.cjs.map} +1 -1
- package/dist/{chunk-4WCWNYCA.js → chunk-YQQ3DYKS.js} +2 -2
- package/dist/{chunk-KF57IEIV.js → chunk-ZRI45CRF.js} +2 -2
- package/dist/{chunk-IWHBCTIB.js → chunk-ZZ72IA34.js} +2 -2
- package/dist/hooks/index.cjs +2 -2
- package/dist/hooks/index.d.cts +18 -18
- package/dist/hooks/index.d.ts +18 -18
- package/dist/hooks/index.js +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.js +12 -12
- package/package.json +5 -5
- package/dist/chunk-4AWDOV7M.js.map +0 -1
- package/dist/chunk-SIUB4YCG.js.map +0 -1
- package/dist/chunk-TEDFGOE4.cjs.map +0 -1
- package/dist/chunk-ZZ4Q3FLC.cjs.map +0 -1
- /package/dist/{chunk-C5LVVYXY.js.map → chunk-GFXPCQYY.js.map} +0 -0
- /package/dist/{chunk-UTKY3KL2.js.map → chunk-HUYCOUFA.js.map} +0 -0
- /package/dist/{chunk-JQGCMXUB.js.map → chunk-L4F26TIF.js.map} +0 -0
- /package/dist/{chunk-P44L3XR4.js.map → chunk-LASW5L3O.js.map} +0 -0
- /package/dist/{chunk-KNP3VJSM.js.map → chunk-LUHX3EP6.js.map} +0 -0
- /package/dist/{chunk-4WCWNYCA.js.map → chunk-YQQ3DYKS.js.map} +0 -0
- /package/dist/{chunk-KF57IEIV.js.map → chunk-ZRI45CRF.js.map} +0 -0
- /package/dist/{chunk-IWHBCTIB.js.map → chunk-ZZ72IA34.js.map} +0 -0
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _fuf_stack_veto from '@fuf-stack/veto';
|
|
2
2
|
import { VetoTypeAny, VetoInstance } from '@fuf-stack/veto';
|
|
3
3
|
import * as react_hook_form from 'react-hook-form';
|
|
4
|
-
import { UseControllerProps as UseControllerProps$1, ControllerRenderProps, UseFormStateReturn, ControllerFieldState, FieldError } from 'react-hook-form';
|
|
4
|
+
import { UseControllerProps as UseControllerProps$1, ControllerRenderProps, UseFormStateReturn, ControllerFieldState, FieldValues, Path, FieldError } from 'react-hook-form';
|
|
5
5
|
export { useFieldArray } from 'react-hook-form';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { D as DebugModeSettings } from '../FormContext-ldCpxKnY.js';
|
|
@@ -65,8 +65,8 @@ declare const checkFieldIsRequired: (validation: VetoInstance, path: string[]) =
|
|
|
65
65
|
/**
|
|
66
66
|
* Custom hook that extends react-hook-form's useFormContext to add validation and state management.
|
|
67
67
|
*/
|
|
68
|
-
declare const useFormContext: () => {
|
|
69
|
-
getFieldState: (name:
|
|
68
|
+
declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>() => {
|
|
69
|
+
getFieldState: (name: Path<TFieldValues>, testId?: string) => {
|
|
70
70
|
error: FieldError[] | undefined;
|
|
71
71
|
required: boolean;
|
|
72
72
|
testId: string;
|
|
@@ -75,7 +75,7 @@ declare const useFormContext: () => {
|
|
|
75
75
|
isTouched: boolean;
|
|
76
76
|
isValidating: boolean;
|
|
77
77
|
};
|
|
78
|
-
formState: react_hook_form.FormState<
|
|
78
|
+
formState: react_hook_form.FormState<TFieldValues>;
|
|
79
79
|
debugMode: "debug" | "debug-testids" | "off" | "disabled";
|
|
80
80
|
debugModeSettings?: DebugModeSettings;
|
|
81
81
|
preventSubmit: (prevent: boolean) => void;
|
|
@@ -86,20 +86,20 @@ declare const useFormContext: () => {
|
|
|
86
86
|
errors?: _fuf_stack_veto.VetoFormattedError;
|
|
87
87
|
setClientValidationSchema: (key: string, schema: _fuf_stack_veto.VetoTypeAny | null) => void;
|
|
88
88
|
};
|
|
89
|
-
watch: react_hook_form.UseFormWatch<
|
|
90
|
-
getValues: react_hook_form.UseFormGetValues<
|
|
91
|
-
setError: react_hook_form.UseFormSetError<
|
|
92
|
-
clearErrors: react_hook_form.UseFormClearErrors<
|
|
93
|
-
setValue: react_hook_form.UseFormSetValue<
|
|
94
|
-
trigger: react_hook_form.UseFormTrigger<
|
|
95
|
-
resetField: react_hook_form.UseFormResetField<
|
|
96
|
-
reset: react_hook_form.UseFormReset<
|
|
97
|
-
handleSubmit: react_hook_form.UseFormHandleSubmit<
|
|
98
|
-
unregister: react_hook_form.UseFormUnregister<
|
|
99
|
-
control: react_hook_form.Control<
|
|
100
|
-
register: react_hook_form.UseFormRegister<
|
|
101
|
-
setFocus: react_hook_form.UseFormSetFocus<
|
|
102
|
-
subscribe: react_hook_form.UseFromSubscribe<
|
|
89
|
+
watch: react_hook_form.UseFormWatch<TFieldValues>;
|
|
90
|
+
getValues: react_hook_form.UseFormGetValues<TFieldValues>;
|
|
91
|
+
setError: react_hook_form.UseFormSetError<TFieldValues>;
|
|
92
|
+
clearErrors: react_hook_form.UseFormClearErrors<TFieldValues>;
|
|
93
|
+
setValue: react_hook_form.UseFormSetValue<TFieldValues>;
|
|
94
|
+
trigger: react_hook_form.UseFormTrigger<TFieldValues>;
|
|
95
|
+
resetField: react_hook_form.UseFormResetField<TFieldValues>;
|
|
96
|
+
reset: react_hook_form.UseFormReset<TFieldValues>;
|
|
97
|
+
handleSubmit: react_hook_form.UseFormHandleSubmit<TFieldValues, TTransformedValues>;
|
|
98
|
+
unregister: react_hook_form.UseFormUnregister<TFieldValues>;
|
|
99
|
+
control: react_hook_form.Control<TFieldValues, TContext, TTransformedValues>;
|
|
100
|
+
register: react_hook_form.UseFormRegister<TFieldValues>;
|
|
101
|
+
setFocus: react_hook_form.UseFormSetFocus<TFieldValues>;
|
|
102
|
+
subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
export { type UseControllerProps, type UseControllerReturn, checkFieldIsRequired, useClientValidation, useController, useFormContext };
|
package/dist/hooks/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkRJ4DYKAVcjs = require('./chunk-RJ4DYKAV.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkMQFKDXKTcjs = require('./chunk-MQFKDXKT.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkG4GCGAMXcjs = require('./chunk-G4GCGAMX.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkT7PSOKMVcjs = require('./chunk-T7PSOKMV.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunk6DZMJL6Acjs = require('./chunk-6DZMJL6A.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _chunk3CZLX3GWcjs = require('./chunk-3CZLX3GW.cjs');
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunk34SC6752cjs = require('./chunk-34SC6752.cjs');
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _chunkYCM5J5E4cjs = require('./chunk-YCM5J5E4.cjs');
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
var _chunkTTD3KL6Ecjs = require('./chunk-TTD3KL6E.cjs');
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var
|
|
30
|
+
var _chunkXB3XIDVBcjs = require('./chunk-XB3XIDVB.cjs');
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var _chunkTPID3SYNcjs = require('./chunk-TPID3SYN.cjs');
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunkEHQPOPGRcjs = require('./chunk-EHQPOPGR.cjs');
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
var _chunkGNYQC5IJcjs = require('./chunk-GNYQC5IJ.cjs');
|
|
@@ -47,7 +47,7 @@ var _chunkPA2DQCBYcjs = require('./chunk-PA2DQCBY.cjs');
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _chunkNFMNQHP7cjs = require('./chunk-NFMNQHP7.cjs');
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
|
|
@@ -80,5 +80,5 @@ require('./chunk-555JRYCS.cjs');
|
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
exports.CheckboxGroup =
|
|
83
|
+
exports.CheckboxGroup = _chunk3CZLX3GWcjs.CheckboxGroup_default; exports.FieldArray = _chunk34SC6752cjs.FieldArray_default; exports.FieldCopyTestIdButton = _chunkPA2DQCBYcjs.FieldCopyTestIdButton_default; exports.FieldValidationError = _chunkGNYQC5IJcjs.FieldValidationError_default; exports.Form = _chunkYCM5J5E4cjs.Form_default; exports.Grid = _chunkTTD3KL6Ecjs.Grid_default; exports.Input = _chunkXB3XIDVBcjs.Input_default; exports.RadioBoxes = _chunkTPID3SYNcjs.RadioBoxes_default; exports.RadioGroup = _chunkEHQPOPGRcjs.RadioGroup_default; exports.RadioTabs = _chunkRJ4DYKAVcjs.RadioTabs_default; exports.Select = _chunkMQFKDXKTcjs.Select_default; exports.SubmitButton = _chunkG4GCGAMXcjs.SubmitButton_default; exports.Switch = _chunkT7PSOKMVcjs.Switch_default; exports.TextArea = _chunk6DZMJL6Acjs.TextArea_default; exports.checkFieldIsRequired = _chunkNFMNQHP7cjs.checkFieldIsRequired; exports.fromNullishString = _chunkCESGUF6Fcjs.fromNullishString; exports.toFormFormat = _chunkCESGUF6Fcjs.toFormFormat; exports.toNullishString = _chunkCESGUF6Fcjs.toNullishString; exports.toValidationFormat = _chunkCESGUF6Fcjs.toValidationFormat; exports.useClientValidation = _chunkNFMNQHP7cjs.useClientValidation; exports.useController = _chunkNFMNQHP7cjs.useController; exports.useFieldArray = _chunkNFMNQHP7cjs.useFieldArray; exports.useFormContext = _chunkNFMNQHP7cjs.useFormContext; exports.useInput = _chunkNFMNQHP7cjs.useInput;
|
|
84
84
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RadioTabs_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HUYCOUFA.js";
|
|
4
4
|
import {
|
|
5
5
|
Select_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-N4V3GR6P.js";
|
|
7
7
|
import {
|
|
8
8
|
SubmitButton_default
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LASW5L3O.js";
|
|
10
10
|
import {
|
|
11
11
|
Switch_default
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GFXPCQYY.js";
|
|
13
13
|
import {
|
|
14
14
|
TextArea_default
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4YF424NV.js";
|
|
16
16
|
import {
|
|
17
17
|
CheckboxGroup_default
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-L4F26TIF.js";
|
|
19
19
|
import {
|
|
20
20
|
FieldArray_default
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-ZZ72IA34.js";
|
|
22
22
|
import {
|
|
23
23
|
Form_default
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-LUHX3EP6.js";
|
|
25
25
|
import {
|
|
26
26
|
Grid_default
|
|
27
27
|
} from "./chunk-B62HKKMS.js";
|
|
28
28
|
import {
|
|
29
29
|
Input_default
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-HJDFEGSC.js";
|
|
31
31
|
import {
|
|
32
32
|
RadioBoxes_default
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-ZRI45CRF.js";
|
|
34
34
|
import {
|
|
35
35
|
RadioGroup_default
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-YQQ3DYKS.js";
|
|
37
37
|
import {
|
|
38
38
|
FieldValidationError_default
|
|
39
39
|
} from "./chunk-UTFZRBBS.js";
|
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
useFieldArray,
|
|
48
48
|
useFormContext,
|
|
49
49
|
useInput
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-MC56FOMX.js";
|
|
51
51
|
import {
|
|
52
52
|
fromNullishString,
|
|
53
53
|
toFormFormat,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Hannes Tiede",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/pixels#readme",
|
|
@@ -133,9 +133,9 @@
|
|
|
133
133
|
"react-icons": "5.5.0",
|
|
134
134
|
"react-hook-form": "7.55.0",
|
|
135
135
|
"react-select": "5.10.1",
|
|
136
|
+
"@fuf-stack/pixels": "0.43.10",
|
|
136
137
|
"@fuf-stack/pixel-utils": "0.5.5",
|
|
137
|
-
"@fuf-stack/veto": "0.12.1"
|
|
138
|
-
"@fuf-stack/pixels": "0.43.9"
|
|
138
|
+
"@fuf-stack/veto": "0.12.1"
|
|
139
139
|
},
|
|
140
140
|
"devDependencies": {
|
|
141
141
|
"@types/debug": "4.1.12",
|
|
@@ -144,9 +144,9 @@
|
|
|
144
144
|
"react": "19.0.0",
|
|
145
145
|
"react-dom": "19.0.0",
|
|
146
146
|
"@repo/storybook-config": "0.0.1",
|
|
147
|
-
"@repo/
|
|
147
|
+
"@repo/tsup-config": "0.0.1",
|
|
148
148
|
"@repo/vite-config": "0.0.1",
|
|
149
|
-
"@repo/
|
|
149
|
+
"@repo/tailwind-config": "0.0.1"
|
|
150
150
|
},
|
|
151
151
|
"scripts": {
|
|
152
152
|
"build": "tsup --config node_modules/@repo/tsup-config/config.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useClientValidation/useClientValidation.ts","../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx","../src/Form/subcomponents/FormResolver.ts","../src/hooks/useController/useController.ts","../src/hooks/useFieldArray/useFieldArray.ts","../src/hooks/useInput/useInput.ts"],"sourcesContent":["/* eslint-disable import/prefer-default-export */\n\nimport type { VetoTypeAny } from '@fuf-stack/veto';\n\nimport { useEffect, useId } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\n/**\n * Hook for adding dynamic client-side validation to forms.\n *\n * Automatically manages validation schema lifecycle: sets schema when data is provided,\n * clears schema when data is null/undefined, and cleans up on unmount.\n *\n * When the client validation schema changes, automatically re-validates all touched\n * fields to ensure they are validated against the new schema.\n *\n * @param data - Data to create validation schema from (or null/undefined to clear validation)\n * @param schemaFactory - Function that creates a validation schema from the data.\n *\n * @example\n * ```tsx\n * const { data: teamData } = useTeamQuery(teamId);\n *\n * useClientValidation(teamData, (data) =>\n * vt.object({\n * username: vt.string().refine(\n * (value) => !data.existingUsers.includes(value),\n * { message: 'Username already exists' }\n * )\n * })\n * );\n * ```\n */\nexport const useClientValidation = <TData = unknown>(\n data: TData | null | undefined,\n schemaFactory: (data: TData) => VetoTypeAny,\n): void => {\n const {\n formState: { touchedFields },\n validation: { setClientValidationSchema },\n trigger,\n } = useFormContext();\n\n // Auto-generate unique key\n const key = useId();\n\n // Use data hash instead of object reference to avoid unnecessary re-runs\n // when data object reference changes but data remains the same\n const dataHash = JSON.stringify(data);\n\n // Single effect to manage validation schema lifecycle\n useEffect(() => {\n // Set validation schema when data is available\n if (data != null) {\n const validationSchema = schemaFactory(data);\n setClientValidationSchema(key, validationSchema);\n } else {\n // Clear validation schema when no data\n setClientValidationSchema(key, null);\n }\n\n // Re-validate all touched fields when client validation schema changes\n const touchedFieldNames = Object.keys(touchedFields);\n if (touchedFieldNames.length > 0) {\n // Use setTimeout to ensure the client validation schema update has propagated\n // before triggering re-validation (fixes race condition)\n setTimeout(() => trigger(touchedFieldNames), 1);\n }\n\n // Cleanup on unmount or when dependencies change\n return () => {\n setClientValidationSchema(key, null);\n };\n // Only re-run when data (dataHash) or key changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataHash, key]);\n};\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { FieldError } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { slugify } from '@fuf-stack/pixel-utils';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\n\n/** Schema check whether a field is required or optional */\nexport const checkFieldIsRequired = (\n validation: VetoInstance,\n path: string[],\n): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const checkRequired = (schema: any) => {\n // arrays with minLength are required\n if (schema.type === 'array' && schema?.minLength) {\n return true;\n }\n // all other fields are required if they are\n // not optional and not nullable\n return !schema.isOptional && !schema.isNullable;\n };\n\n return validation.checkSchemaPath(checkRequired, path);\n};\n\n/**\n * Custom hook that extends react-hook-form's useFormContext to add validation and state management.\n */\nexport const useFormContext = () => {\n const {\n formState,\n // https://react-hook-form.com/docs/useform/getfieldstate\n // for getFieldState a subscription to formState properties is needed!\n getFieldState: getFieldStateOrig,\n ...otherMethods\n } = useHookFormContext();\n\n const uniformContext = useContext(UniformContext);\n\n /**\n * Updated getFieldState method which returns:\n * - Whether the field is required by checking the validation schema\n * - Existing field state information (errors, etc.)\n */\n const getFieldState = (name: string, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n // Check if the field is required using the validation schema\n const required = uniformContext?.validation.instance\n ? checkFieldIsRequired(uniformContext.validation.instance, fieldPath)\n : false;\n\n // Get the original field state (errors, etc.) from react-hook-form\n const { error, ...rest } = getFieldStateOrig(name, formState);\n\n return {\n ...rest,\n error: error as FieldError[] | undefined, // Ensure correct type for error\n required,\n testId: slugify(testId || name, { replaceDots: true }),\n };\n };\n\n return {\n ...otherMethods,\n ...uniformContext,\n getFieldState,\n formState,\n };\n};\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { BaseSyntheticEvent, ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\n\nimport React, { useMemo, useState } from 'react';\nimport { FormProvider as HookFormProvider, useForm } from 'react-hook-form';\n\nimport { useLocalStorage } from '@fuf-stack/pixels';\n\nimport { useExtendedValidation, useFormResolver } from './FormResolver';\n\ntype DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';\n\nexport type DebugModeSettings = {\n /** disable form debug completely */\n disable?: boolean;\n /** custom localStorage key to save debug mode state */\n localStorageKey?: string;\n};\n\nconst DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = 'uniform:debug-mode';\n\n/**\n * The `UniformContext` provides control over the form's submission behavior and may optionally include\n * a Veto validation schema for form validation.\n *\n * Specifically, this context offers:\n * 1. **Form Submission Control**: The `preventSubmit` function allows components to enable or disable\n * form submissions.\n * 2. **Optional Validation Schema**: The `validation` property may hold a Veto validation schema instance\n * that can be used to validate form fields and handle validation logic.\n * 3. **Client Validation**: The `setClientValidationSchema` function allows setting dynamic client-side\n * validation schemas that complement the base Veto validation.\n *\n * This context is useful for components that need to interact with or control the form submission state,\n * or access the validation schema for managing form validation logic.\n */\nexport const UniformContext = React.createContext<{\n /** Form debug mode enabled or not */\n debugMode: DebugMode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** Function to update if the form can currently be submitted */\n preventSubmit: (prevent: boolean) => void;\n /** Setter to enable or disable form debug mode */\n setDebugMode: (debugMode: DebugMode) => void;\n /** Function to trigger form submit programmatically */\n triggerSubmit: (e?: BaseSyntheticEvent) => Promise<void> | void;\n /** Form validation configuration */\n validation: {\n /** Veto validation schema instance for form validation */\n instance?: VetoInstance;\n /** Current validation errors in form */\n errors?: VetoFormattedError;\n /** Function to set client validation schema for a specific key */\n setClientValidationSchema: (\n key: string,\n schema: VetoTypeAny | null,\n ) => void;\n };\n}>({\n debugMode: 'off',\n preventSubmit: () => undefined,\n setDebugMode: () => undefined,\n triggerSubmit: () => undefined,\n validation: {\n setClientValidationSchema: () => undefined,\n },\n});\n\n// Define props for the FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** Veto validation schema instance */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * FormProvider component provides:\n * - Veto validation schema context\n * - Client validation schema management\n * - Submit handler creation and submission control with preventSubmit\n * - Form Debug Mode state\n * - React Hook Form context\n */\nconst FormProvider: React.FC<FormProviderProps> = ({\n children,\n debugModeSettings = undefined,\n initialValues = undefined,\n onSubmit,\n validation: baseValidation = undefined,\n validationTrigger,\n}) => {\n // Form Debug mode state is handled in the form context\n const [debugMode, setDebugMode] = useLocalStorage<DebugMode>(\n debugModeSettings?.localStorageKey || DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT,\n 'off',\n );\n\n // Create extended validation combining base + client validations\n const { extendedValidation, setClientValidationSchema } =\n useExtendedValidation(baseValidation);\n\n // Create resolver from extended validation + get current validation errors\n const { resolver, validationErrors, validationErrorsHash } =\n useFormResolver(extendedValidation);\n\n // Initialize react hook form with the resolver\n const methods = useForm({\n defaultValues: initialValues,\n // set rhf mode\n // see: https://react-hook-form.com/docs/useform#mode\n mode: validationTrigger,\n resolver,\n });\n\n // Get isValid from React Hook Form's formState\n const isValid = methods.formState?.isValid;\n\n // Control if the form can currently be submitted\n const [preventSubmit, setPreventSubmit] = useState(false);\n\n // Create submit handler\n // eslint-disable-next-line consistent-return\n const handleSubmit = async (e?: React.BaseSyntheticEvent) => {\n // only prevent submit when form state is valid, because otherwise\n // submit will only trigger validation and add errors / focus invalid fields\n if (methods.formState.isValid && preventSubmit) {\n console.warn(\n '[FormProvider] form submit was prevented because preventSubmit is true...',\n );\n e?.preventDefault();\n return Promise.resolve();\n }\n await methods.handleSubmit(onSubmit)(e);\n };\n\n // Memoize the context value to prevent re-renders\n const contextValue = useMemo(\n () => ({\n // set debugMode to disabled when debugModeSettings.disable is true\n // otherwise use current debug mode from localStorage\n debugMode: debugModeSettings?.disable ? 'disabled' : debugMode,\n preventSubmit: (prevent: boolean) => {\n setPreventSubmit(prevent);\n },\n setClientValidationSchema,\n setDebugMode,\n triggerSubmit: handleSubmit,\n validation: {\n instance: extendedValidation,\n errors: validationErrors,\n setClientValidationSchema,\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [debugMode, debugModeSettings?.disable, validationErrorsHash],\n );\n\n return (\n <UniformContext.Provider value={contextValue}>\n {/* Spread all hook form props into HookFormProvider */}\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <HookFormProvider {...methods}>\n {children({ handleSubmit, isValid })}\n </HookFormProvider>\n </UniformContext.Provider>\n );\n};\n\nexport default FormProvider;\n","/* eslint-disable import/prefer-default-export */\n\nimport type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { useMemo, useRef, useState } from 'react';\n\nimport { and, serializeSchema, veto } from '@fuf-stack/veto';\n\n/**\n * Hook that manages client validation schemas state.\n *\n * Provides a centralized way to add/remove dynamic validation schemas\n * that can be combined with base form validation.\n *\n * @returns Object with client validation state and memoized setter function\n */\nexport const useClientValidationManager = () => {\n // Client validation schemas state\n const [clientValidationSchemas, setClientValidationSchemas] = useState<\n Record<string, VetoTypeAny>\n >({});\n\n // Memoized function to set/clear client validation schema\n const setClientValidationSchema = useMemo(\n () => {\n return (key: string, schema: VetoTypeAny | null) => {\n // update client validation schemas\n setClientValidationSchemas((prev) => {\n // if no schema and no existing client validation schema for this key, do nothing\n if (!prev[key] && !schema) {\n return prev;\n }\n // if no schema, remove the client validation schema for this key\n if (!schema) {\n const { [key]: _removed, ...rest } = prev;\n return rest;\n }\n // if schema, add or update the client validation schema for this key\n return { ...prev, [key]: schema };\n });\n };\n },\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n return {\n clientValidationSchemas,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates an extended validation instance combining base Veto validation with dynamic client validation.\n *\n * @param baseValidation - Optional base Veto validation schema\n * @returns Combined validation instance and client schema setter\n */\nexport const useExtendedValidation = (baseValidation?: VetoInstance) => {\n // Setup client validation schemas\n const { clientValidationSchemas, setClientValidationSchema } =\n useClientValidationManager();\n\n // Create client schema hash for optimized memoization\n const clientValidationSchemasHash = JSON.stringify(\n Object.values(clientValidationSchemas).map((schema) =>\n serializeSchema(schema),\n ),\n );\n\n // Create a stable dependency array from the client validation schemas\n const clientSchemaValues = useMemo(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys.map((key) => clientValidationSchemas[key]).filter(Boolean);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [clientValidationSchemasHash],\n );\n\n // Memoized extended validation instance\n const extendedValidation = useMemo(\n () => {\n const hasBaseValidation = !!baseValidation;\n const hasClientSchemas = clientSchemaValues.length > 0;\n\n // If no base validation and no client schemas, return undefined\n if (!hasBaseValidation && !hasClientSchemas) {\n return undefined;\n }\n\n // If no client schemas, return base validation\n if (!hasClientSchemas) {\n return baseValidation;\n }\n\n // Combine client validation schemas\n const clientSchemasCombined = clientSchemaValues.reduce(\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (hasBaseValidation && clientSchemasCombined) {\n return veto(\n and((baseValidation as VetoInstance).schema, clientSchemasCombined),\n );\n }\n\n // If we only have client schemas, return them as a veto instance\n if (clientSchemasCombined) {\n return veto(clientSchemasCombined);\n }\n\n // This should not happen due to the conditions above, but just in case\n return baseValidation;\n },\n // Using hash-based dependency to optimize performance\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [clientValidationSchemasHash],\n );\n\n return {\n extendedValidation,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates a React Hook Form resolver from an extended validation instance.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Object containing resolver function, current validation errors, and optimization hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Use ref to store validation errors without triggering re-renders\n const validationErrors = useRef<VetoFormattedError>(undefined);\n\n // Memoized resolver function for React Hook Form\n const resolver = useMemo(() => {\n if (!extendedValidation) {\n return undefined;\n }\n\n return async (values: FieldValues) => {\n const result = await extendedValidation.validateAsync(values);\n validationErrors.current = result.errors;\n\n // Transform veto result to React Hook Form format\n return {\n values: result.data || {},\n errors: result.errors || {},\n };\n };\n }, [extendedValidation]);\n\n // Hash for memo dependency optimization in consuming components\n const validationErrorsHash = JSON.stringify(validationErrors.current);\n\n return {\n resolver,\n validationErrors: validationErrors.current,\n validationErrorsHash,\n };\n};\n","/* eslint-disable import/prefer-default-export */\n\nimport type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useController as useRHFController } from 'react-hook-form';\n\nimport { fromNullishString, toNullishString } from '../../helpers';\n\nexport type UseControllerProps<TFieldValues extends object = object> =\n RHFUseControllerProps<TFieldValues>;\n\nexport type UseControllerReturn<TFieldValues extends object = object> = {\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};\n\n/**\n * A wrapper around react-hook-form's useController 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 useController\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\n */\nexport const useController = <TFieldValues extends object = object>(\n props: UseControllerProps<TFieldValues>,\n): UseControllerReturn<TFieldValues> => {\n const { field, formState, fieldState } = useRHFController(props);\n\n return {\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 formState,\n fieldState,\n };\n};\n","/* eslint-disable import/prefer-default-export */\n\n/** @see https://react-hook-form.com/docs/usefieldarray */\nexport { useFieldArray } from 'react-hook-form';\n","/* eslint-disable import/prefer-default-export */\nexport { useInput } from '@heroui/input';\n"],"mappings":";;;;;;;;;;;;;AAIA,SAAS,WAAW,aAAa;;;ACDjC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB,0BAA0B;AAErD,SAAS,eAAe;;;ACExB,OAAO,SAAS,WAAAA,UAAS,YAAAC,iBAAgB;AACzC,SAAS,gBAAgB,kBAAkB,eAAe;AAE1D,SAAS,uBAAuB;;;ACFhC,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,SAAS,KAAK,iBAAiB,YAAY;AAUpC,IAAM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A0B,KAAK,IAAI;AAAA,IACrC;AAGA,UAAM,oBAAoB,OAAO,KAAK,aAAa;AACnD,QAAI,kBAAkB,SAAS,GAAG;AAGhC,iBAAW,MAAM,QAAQ,iBAAiB,GAAG,CAAC;AAAA,IAChD;AAGA,WAAO,MAAM;AACX,gCAA0B,KAAK,IAAI;AAAA,IACrC;AAAA,EAGF,GAAG,CAAC,UAAU,GAAG,CAAC;AACpB;;;AIpEA,SAAS,iBAAiB,wBAAwB;AAgC3C,IAAM,gBAAgB,CAC3B,UACsC;AACtC,QAAM,EAAE,OAAO,WAAW,WAAW,IAAI,iBAAiB,KAAK;AAE/D,SAAO;AAAA,IACL,OAAO,iCACF,QADE;AAAA;AAAA;AAAA,MAIL,UAAU,IAAI,UAAiB;AAnDrC;AAoDQ,cAAM,SAAQ,uBAAM,CAAC,MAAP,mBAAU,WAAV,mBAAkB,UAAlB,YAA2B,MAAM,CAAC;AAChD,cAAM,SAAS,gBAAgB,KAAK,CAAC;AAAA,MACvC;AAAA;AAAA,MAEA,OAAO,kBAAkB,MAAM,KAAK;AAAA,IACtC;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;AC1DA,SAAS,qBAAqB;;;ACF9B,SAAS,gBAAgB;","names":["useMemo","useState","useState","useMemo","_a"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Select/Select.tsx","../src/Select/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { Props } from 'react-select';\n\nimport { useState } from 'react';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@heroui/select';\n\nimport { cn, slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useController, 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 HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/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: 'rounded-sm p-2 text-foreground-500',\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/heroui-inc/heroui/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, { replaceDots: true })}`;\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 [HeroUI Select](https://www.heroui.com//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 { field } = useController({ control, disabled, name });\n const { onChange, value, ref, onBlur } = field;\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 <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 HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/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 && <FieldCopyTestIdButton testId={testId} />}\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={getTriggerProps()['aria-labelledby']?.split(' ')[1]}\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 loadingIndicator: () => classNames.loadingIndicator,\n loadingMessage: () => classNames.loadingMessage,\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} testId={testId} />\n </div>\n </div>\n )}\n </div>\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,SAAS,IAAI,4BAA4B;AAkG7C,cAwGD,YAxGC;AA5FF,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;AAAA,IAGP,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,Q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YACA,QAAQ,CAAC,OAAO;AACd,2BAAa,KAAK;AAClB,qBAAO,OAAO;AAAA,YAChB;AAAA,YACA,UAAU,CAAC,WAAW;AACpB,kBAAI,aAAa;AACf;AAAA,kBACG,iCAA2B,IAAI,CAAC,YAAY,QAAQ;AAAA,gBACvD;AAAA,cACF,OAAO;AACL,yBAAU,iCAAyB,KAAK;AAAA,cAC1C;AAAA,YACF;AAAA,YACA,SAAS,CAAC,OAAO;AACf,2BAAa,IAAI;AAAA,YACnB;AAAA,YACA;AAAA,YACA;AAAA,YAEA,OAAO,QAAQ,KAAK,CAAC,WAAW,OAAO,UAAU,KAAK;AAAA,YACtD,UAAQ;AAAA;AAAA,QACV;AAAA,QACC;AAAA,QAEC,oBAAC,wCAAQ,sBAAsB,IAA9B,EAEC,8BAAC,wCAAQ,qBAAqB,IAA7B,EACC,8BAAC,gCAAqB,OAAc,QAAgB,IACtD,IACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAEA,IAAO,iBAAQ;;;ACvTf,IAAOA,kBAAQ;","names":["Select_default"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-TEDFGOE4.cjs","../src/Select/Select.tsx","../src/Select/index.ts"],"names":["Select_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACZA,8BAAyB;AACzB,qGAAwC;AAExC,wCAA0B;AAE1B,oDAAsD;AAkG7C,+CAAA;AA5FF,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,sBAAA;AAAA,IACN,cAAA,EACE,wGAAA;AAAA,IACF,OAAA,EACE,yNAAA;AAAA,IACF,eAAA,EAAiB,cAAA;AAAA,IACjB,SAAA,EAAW,EAAA;AAAA,IACX,WAAA,EA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;AACF,gBAAA;AACG,kBAAA;AACH,gBAAA;AACF,cAAA;AACE,gBAAA;AACF,cAAA;AACF,YAAA;AACA,YAAA;AACE,cAAA;AACF,YAAA;AACA,YAAA;AACA,YAAA;AAEA,YAAA;AACA,YAAA;AAAQ,UAAA;AACV,QAAA;AACC,QAAA;AAEC,wBAAA;AAKA,MAAA;AAAA,IAAA;AAEJ,EAAA;AAEJ;AAEO;AD1FW;AACA;AE9NXA;AFgOW;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-TEDFGOE4.cjs","sourcesContent":[null,"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 '@heroui/select';\n\nimport { cn, slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useController, 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 HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/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: 'rounded-sm p-2 text-foreground-500',\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/heroui-inc/heroui/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, { replaceDots: true })}`;\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 [HeroUI Select](https://www.heroui.com//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 { field } = useController({ control, disabled, name });\n const { onChange, value, ref, onBlur } = field;\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 <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 HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/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 && <FieldCopyTestIdButton testId={testId} />}\n </label>\n )}\n <ReactSelect\n aria-errormessage=\"\"\n aria-labelledby={getTriggerProps()['aria-labelledby']?.split(' ')[1]}\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 loadingIndicator: () => classNames.loadingIndicator,\n loadingMessage: () => classNames.loadingMessage,\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} testId={testId} />\n </div>\n </div>\n )}\n </div>\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps } from './Select';\n\nexport { Select };\n\nexport default Select;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-ZZ4Q3FLC.cjs","../src/hooks/useClientValidation/useClientValidation.ts","../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx","../src/Form/subcomponents/FormResolver.ts","../src/hooks/useController/useController.ts","../src/hooks/useFieldArray/useFieldArray.ts","../src/hooks/useInput/useInput.ts"],"names":["useState","useMemo","_a"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACRA,4EAAiC;ADUjC;AACA;AEZA;AACA,gDAAqD;AAErD,oDAAwB;AFaxB;AACA;AGZA;AACA;AAEA,2CAAgC;AHahC;AACA;AIhBA;AAEA,uCAA2C;AAUpC,IAAM,2BAAA,EAA6B,CAAA,EAAA,GAAM;AAE9C,EAAA,MAAM,CAAC,uBAAA,EAAyB,0BAA0B,EAAA,EAAI,6BAAA,CAE3D,CAAC,CAAA;AAGJ,EAAA,MAAM,0BAAA,EAA4B,4BAAA;AAAA,IAChC,CAAA,EAAA,GAAM;AACJ,MAAA,OAAO,CAAC,GAAA,EAAa,MAAA,EAAA,GAA+B;AAElD,QAAA,0BAAA,CAA2B,CAAC,IAAA,EAAA,GAAS;AAEnC,UAAA,GAAA,CAAI,CAAC,IAAA,CAAK,GAAG,EAAA,GAAK,CAAC,MAAA,EAAQ;AACzB,YAAA,OAAO,IAAA;AAAA,UACT;AAEA,UAAA,GAAA,CAAI,CAAC,MAAA,EAAQ;AACX,YAAA,MAAqC,GAAA,EAAA,IAAA,EAA5B,EAvCrB,CAuCqB,GAAA,CAAA,EAAM,SAvC3B,EAAA,EAuCiD,EAAA,EAAT,KAAA,EAAA,yCAAA,EAAS,EAAT,CAAnB,yCAAA,GAAA,CAAA,CAAA,CAAA;AACT,YAAA,OAAO,IAAA;AAAA,UACT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A,EAAgB,CAC3B,KAAA,EAAA,GACsC;AACtC,EAAA,MAAM,EAAE,KAAA,EAAO,SAAA,EAAW,WAAW,EAAA,EAAI,0CAAA,KAAsB,CAAA;AAE/D,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,6CAAA,8CAAA,CAAA,CAAA,EACF,KAAA,CAAA,EADE;AAAA;AAAA;AAAA,MAIL,QAAA,EAAU,CAAA,GAAI,KAAA,EAAA,GAAiB;AAnDrC,QAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAoDQ,QAAA,MAAM,MAAA,EAAA,CAAQ,GAAA,EAAA,CAAA,GAAA,EAAA,CAAA,GAAA,EAAA,KAAA,CAAM,CAAC,CAAA,EAAA,GAAP,KAAA,EAAA,KAAA,EAAA,EAAA,EAAA,CAAU,MAAA,EAAA,GAAV,KAAA,EAAA,KAAA,EAAA,EAAA,EAAA,CAAkB,KAAA,EAAA,GAAlB,KAAA,EAAA,GAAA,EAA2B,KAAA,CAAM,CAAC,CAAA;AAChD,QAAA,KAAA,CAAM,QAAA,CAAS,+CAAA,KAAqB,CAAC,CAAA;AAAA,MACvC,CAAA;AAAA;AAAA,MAEA,KAAA,EAAO,iDAAA,KAAkB,CAAM,KAAK;AAAA,IACtC,CAAA,CAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,EACF,CAAA;AACF,CAAA;AL2NA;AACA;AMtRA;ANwRA;AACA;AO3RA,sCAAyB;AP6RzB;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,oUAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-ZZ4Q3FLC.cjs","sourcesContent":[null,"/* eslint-disable import/prefer-default-export */\n\nimport type { VetoTypeAny } from '@fuf-stack/veto';\n\nimport { useEffect, useId } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\n/**\n * Hook for adding dynamic client-side validation to forms.\n *\n * Automatically manages validation schema lifecycle: sets schema when data is provided,\n * clears schema when data is null/undefined, and cleans up on unmount.\n *\n * When the client validation schema changes, automatically re-validates all touched\n * fields to ensure they are validated against the new schema.\n *\n * @param data - Data to create validation schema from (or null/undefined to clear validation)\n * @param schemaFactory - Function that creates a validation schema from the data.\n *\n * @example\n * ```tsx\n * const { data: teamData } = useTeamQuery(teamId);\n *\n * useClientValidation(teamData, (data) =>\n * vt.object({\n * username: vt.string().refine(\n * (value) => !data.existingUsers.includes(value),\n * { message: 'Username already exists' }\n * )\n * })\n * );\n * ```\n */\nexport const useClientValidation = <TData = unknown>(\n data: TData | null | undefined,\n schemaFactory: (data: TData) => VetoTypeAny,\n): void => {\n const {\n formState: { touchedFields },\n validation: { setClientValidationSchema },\n trigger,\n } = useFormContext();\n\n // Auto-generate unique key\n const key = useId();\n\n // Use data hash instead of object reference to avoid unnecessary re-runs\n // when data object reference changes but data remains the same\n const dataHash = JSON.stringify(data);\n\n // Single effect to manage validation schema lifecycle\n useEffect(() => {\n // Set validation schema when data is available\n if (data != null) {\n const validationSchema = schemaFactory(data);\n setClientValidationSchema(key, validationSchema);\n } else {\n // Clear validation schema when no data\n setClientValidationSchema(key, null);\n }\n\n // Re-validate all touched fields when client validation schema changes\n const touchedFieldNames = Object.keys(touchedFields);\n if (touchedFieldNames.length > 0) {\n // Use setTimeout to ensure the client validation schema update has propagated\n // before triggering re-validation (fixes race condition)\n setTimeout(() => trigger(touchedFieldNames), 1);\n }\n\n // Cleanup on unmount or when dependencies change\n return () => {\n setClientValidationSchema(key, null);\n };\n // Only re-run when data (dataHash) or key changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataHash, key]);\n};\n","import type { VetoInstance } from '@fuf-stack/veto';\nimport type { FieldError } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { slugify } from '@fuf-stack/pixel-utils';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\n\n/** Schema check whether a field is required or optional */\nexport const checkFieldIsRequired = (\n validation: VetoInstance,\n path: string[],\n): boolean => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const checkRequired = (schema: any) => {\n // arrays with minLength are required\n if (schema.type === 'array' && schema?.minLength) {\n return true;\n }\n // all other fields are required if they are\n // not optional and not nullable\n return !schema.isOptional && !schema.isNullable;\n };\n\n return validation.checkSchemaPath(checkRequired, path);\n};\n\n/**\n * Custom hook that extends react-hook-form's useFormContext to add validation and state management.\n */\nexport const useFormContext = () => {\n const {\n formState,\n // https://react-hook-form.com/docs/useform/getfieldstate\n // for getFieldState a subscription to formState properties is needed!\n getFieldState: getFieldStateOrig,\n ...otherMethods\n } = useHookFormContext();\n\n const uniformContext = useContext(UniformContext);\n\n /**\n * Updated getFieldState method which returns:\n * - Whether the field is required by checking the validation schema\n * - Existing field state information (errors, etc.)\n */\n const getFieldState = (name: string, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n // Check if the field is required using the validation schema\n const required = uniformContext?.validation.instance\n ? checkFieldIsRequired(uniformContext.validation.instance, fieldPath)\n : false;\n\n // Get the original field state (errors, etc.) from react-hook-form\n const { error, ...rest } = getFieldStateOrig(name, formState);\n\n return {\n ...rest,\n error: error as FieldError[] | undefined, // Ensure correct type for error\n required,\n testId: slugify(testId || name, { replaceDots: true }),\n };\n };\n\n return {\n ...otherMethods,\n ...uniformContext,\n getFieldState,\n formState,\n };\n};\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { BaseSyntheticEvent, ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\n\nimport React, { useMemo, useState } from 'react';\nimport { FormProvider as HookFormProvider, useForm } from 'react-hook-form';\n\nimport { useLocalStorage } from '@fuf-stack/pixels';\n\nimport { useExtendedValidation, useFormResolver } from './FormResolver';\n\ntype DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';\n\nexport type DebugModeSettings = {\n /** disable form debug completely */\n disable?: boolean;\n /** custom localStorage key to save debug mode state */\n localStorageKey?: string;\n};\n\nconst DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = 'uniform:debug-mode';\n\n/**\n * The `UniformContext` provides control over the form's submission behavior and may optionally include\n * a Veto validation schema for form validation.\n *\n * Specifically, this context offers:\n * 1. **Form Submission Control**: The `preventSubmit` function allows components to enable or disable\n * form submissions.\n * 2. **Optional Validation Schema**: The `validation` property may hold a Veto validation schema instance\n * that can be used to validate form fields and handle validation logic.\n * 3. **Client Validation**: The `setClientValidationSchema` function allows setting dynamic client-side\n * validation schemas that complement the base Veto validation.\n *\n * This context is useful for components that need to interact with or control the form submission state,\n * or access the validation schema for managing form validation logic.\n */\nexport const UniformContext = React.createContext<{\n /** Form debug mode enabled or not */\n debugMode: DebugMode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** Function to update if the form can currently be submitted */\n preventSubmit: (prevent: boolean) => void;\n /** Setter to enable or disable form debug mode */\n setDebugMode: (debugMode: DebugMode) => void;\n /** Function to trigger form submit programmatically */\n triggerSubmit: (e?: BaseSyntheticEvent) => Promise<void> | void;\n /** Form validation configuration */\n validation: {\n /** Veto validation schema instance for form validation */\n instance?: VetoInstance;\n /** Current validation errors in form */\n errors?: VetoFormattedError;\n /** Function to set client validation schema for a specific key */\n setClientValidationSchema: (\n key: string,\n schema: VetoTypeAny | null,\n ) => void;\n };\n}>({\n debugMode: 'off',\n preventSubmit: () => undefined,\n setDebugMode: () => undefined,\n triggerSubmit: () => undefined,\n validation: {\n setClientValidationSchema: () => undefined,\n },\n});\n\n// Define props for the FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** Veto validation schema instance */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * FormProvider component provides:\n * - Veto validation schema context\n * - Client validation schema management\n * - Submit handler creation and submission control with preventSubmit\n * - Form Debug Mode state\n * - React Hook Form context\n */\nconst FormProvider: React.FC<FormProviderProps> = ({\n children,\n debugModeSettings = undefined,\n initialValues = undefined,\n onSubmit,\n validation: baseValidation = undefined,\n validationTrigger,\n}) => {\n // Form Debug mode state is handled in the form context\n const [debugMode, setDebugMode] = useLocalStorage<DebugMode>(\n debugModeSettings?.localStorageKey || DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT,\n 'off',\n );\n\n // Create extended validation combining base + client validations\n const { extendedValidation, setClientValidationSchema } =\n useExtendedValidation(baseValidation);\n\n // Create resolver from extended validation + get current validation errors\n const { resolver, validationErrors, validationErrorsHash } =\n useFormResolver(extendedValidation);\n\n // Initialize react hook form with the resolver\n const methods = useForm({\n defaultValues: initialValues,\n // set rhf mode\n // see: https://react-hook-form.com/docs/useform#mode\n mode: validationTrigger,\n resolver,\n });\n\n // Get isValid from React Hook Form's formState\n const isValid = methods.formState?.isValid;\n\n // Control if the form can currently be submitted\n const [preventSubmit, setPreventSubmit] = useState(false);\n\n // Create submit handler\n // eslint-disable-next-line consistent-return\n const handleSubmit = async (e?: React.BaseSyntheticEvent) => {\n // only prevent submit when form state is valid, because otherwise\n // submit will only trigger validation and add errors / focus invalid fields\n if (methods.formState.isValid && preventSubmit) {\n console.warn(\n '[FormProvider] form submit was prevented because preventSubmit is true...',\n );\n e?.preventDefault();\n return Promise.resolve();\n }\n await methods.handleSubmit(onSubmit)(e);\n };\n\n // Memoize the context value to prevent re-renders\n const contextValue = useMemo(\n () => ({\n // set debugMode to disabled when debugModeSettings.disable is true\n // otherwise use current debug mode from localStorage\n debugMode: debugModeSettings?.disable ? 'disabled' : debugMode,\n preventSubmit: (prevent: boolean) => {\n setPreventSubmit(prevent);\n },\n setClientValidationSchema,\n setDebugMode,\n triggerSubmit: handleSubmit,\n validation: {\n instance: extendedValidation,\n errors: validationErrors,\n setClientValidationSchema,\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [debugMode, debugModeSettings?.disable, validationErrorsHash],\n );\n\n return (\n <UniformContext.Provider value={contextValue}>\n {/* Spread all hook form props into HookFormProvider */}\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <HookFormProvider {...methods}>\n {children({ handleSubmit, isValid })}\n </HookFormProvider>\n </UniformContext.Provider>\n );\n};\n\nexport default FormProvider;\n","/* eslint-disable import/prefer-default-export */\n\nimport type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { useMemo, useRef, useState } from 'react';\n\nimport { and, serializeSchema, veto } from '@fuf-stack/veto';\n\n/**\n * Hook that manages client validation schemas state.\n *\n * Provides a centralized way to add/remove dynamic validation schemas\n * that can be combined with base form validation.\n *\n * @returns Object with client validation state and memoized setter function\n */\nexport const useClientValidationManager = () => {\n // Client validation schemas state\n const [clientValidationSchemas, setClientValidationSchemas] = useState<\n Record<string, VetoTypeAny>\n >({});\n\n // Memoized function to set/clear client validation schema\n const setClientValidationSchema = useMemo(\n () => {\n return (key: string, schema: VetoTypeAny | null) => {\n // update client validation schemas\n setClientValidationSchemas((prev) => {\n // if no schema and no existing client validation schema for this key, do nothing\n if (!prev[key] && !schema) {\n return prev;\n }\n // if no schema, remove the client validation schema for this key\n if (!schema) {\n const { [key]: _removed, ...rest } = prev;\n return rest;\n }\n // if schema, add or update the client validation schema for this key\n return { ...prev, [key]: schema };\n });\n };\n },\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n return {\n clientValidationSchemas,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates an extended validation instance combining base Veto validation with dynamic client validation.\n *\n * @param baseValidation - Optional base Veto validation schema\n * @returns Combined validation instance and client schema setter\n */\nexport const useExtendedValidation = (baseValidation?: VetoInstance) => {\n // Setup client validation schemas\n const { clientValidationSchemas, setClientValidationSchema } =\n useClientValidationManager();\n\n // Create client schema hash for optimized memoization\n const clientValidationSchemasHash = JSON.stringify(\n Object.values(clientValidationSchemas).map((schema) =>\n serializeSchema(schema),\n ),\n );\n\n // Create a stable dependency array from the client validation schemas\n const clientSchemaValues = useMemo(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys.map((key) => clientValidationSchemas[key]).filter(Boolean);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [clientValidationSchemasHash],\n );\n\n // Memoized extended validation instance\n const extendedValidation = useMemo(\n () => {\n const hasBaseValidation = !!baseValidation;\n const hasClientSchemas = clientSchemaValues.length > 0;\n\n // If no base validation and no client schemas, return undefined\n if (!hasBaseValidation && !hasClientSchemas) {\n return undefined;\n }\n\n // If no client schemas, return base validation\n if (!hasClientSchemas) {\n return baseValidation;\n }\n\n // Combine client validation schemas\n const clientSchemasCombined = clientSchemaValues.reduce(\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (hasBaseValidation && clientSchemasCombined) {\n return veto(\n and((baseValidation as VetoInstance).schema, clientSchemasCombined),\n );\n }\n\n // If we only have client schemas, return them as a veto instance\n if (clientSchemasCombined) {\n return veto(clientSchemasCombined);\n }\n\n // This should not happen due to the conditions above, but just in case\n return baseValidation;\n },\n // Using hash-based dependency to optimize performance\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [clientValidationSchemasHash],\n );\n\n return {\n extendedValidation,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates a React Hook Form resolver from an extended validation instance.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Object containing resolver function, current validation errors, and optimization hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Use ref to store validation errors without triggering re-renders\n const validationErrors = useRef<VetoFormattedError>(undefined);\n\n // Memoized resolver function for React Hook Form\n const resolver = useMemo(() => {\n if (!extendedValidation) {\n return undefined;\n }\n\n return async (values: FieldValues) => {\n const result = await extendedValidation.validateAsync(values);\n validationErrors.current = result.errors;\n\n // Transform veto result to React Hook Form format\n return {\n values: result.data || {},\n errors: result.errors || {},\n };\n };\n }, [extendedValidation]);\n\n // Hash for memo dependency optimization in consuming components\n const validationErrorsHash = JSON.stringify(validationErrors.current);\n\n return {\n resolver,\n validationErrors: validationErrors.current,\n validationErrorsHash,\n };\n};\n","/* eslint-disable import/prefer-default-export */\n\nimport type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useController as useRHFController } from 'react-hook-form';\n\nimport { fromNullishString, toNullishString } from '../../helpers';\n\nexport type UseControllerProps<TFieldValues extends object = object> =\n RHFUseControllerProps<TFieldValues>;\n\nexport type UseControllerReturn<TFieldValues extends object = object> = {\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};\n\n/**\n * A wrapper around react-hook-form's useController 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 useController\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\n */\nexport const useController = <TFieldValues extends object = object>(\n props: UseControllerProps<TFieldValues>,\n): UseControllerReturn<TFieldValues> => {\n const { field, formState, fieldState } = useRHFController(props);\n\n return {\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 formState,\n fieldState,\n };\n};\n","/* eslint-disable import/prefer-default-export */\n\n/** @see https://react-hook-form.com/docs/usefieldarray */\nexport { useFieldArray } from 'react-hook-form';\n","/* eslint-disable import/prefer-default-export */\nexport { useInput } from '@heroui/input';\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|