@povio/ui 3.4.0-rc.1 → 3.4.0-rc.11
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/components/inputs/Checkbox/Checkbox.d.ts +2 -1
- package/dist/components/inputs/Checkbox/Checkbox.js +100 -93
- package/dist/components/inputs/Checkbox/CheckboxGroup.d.ts +2 -1
- package/dist/components/inputs/Checkbox/CheckboxGroup.js +113 -109
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +21 -14
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +22 -14
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +21 -14
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +294 -275
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +10 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +46 -43
- package/dist/components/inputs/File/FileUpload.d.ts +1 -1
- package/dist/components/inputs/File/FileUpload.js +17 -17
- package/dist/components/inputs/File/InputUpload.d.ts +1 -1
- package/dist/components/inputs/File/InputUpload.js +17 -17
- package/dist/components/inputs/File/fileUpload.types.d.ts +1 -1
- package/dist/components/inputs/File/inputUpload.types.d.ts +1 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +1 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +19 -19
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +1 -1
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +18 -18
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/inputs/Input/TextArea/TextArea.d.ts +1 -1
- package/dist/components/inputs/Input/TextArea/TextArea.js +18 -18
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +2 -2
- package/dist/components/inputs/Input/TextInput/TextInput.js +38 -36
- package/dist/components/inputs/Inputs/Form.d.ts +4 -4
- package/dist/components/inputs/Inputs/InputItem.d.ts +22 -22
- package/dist/components/inputs/Inputs/InputItem.js +36 -35
- package/dist/components/inputs/Inputs/Inputs.d.ts +2 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +2 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +111 -107
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +13 -13
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +19 -19
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/QuerySelect.js +19 -19
- package/dist/components/inputs/Selection/Select/Select.d.ts +1 -1
- package/dist/components/inputs/Selection/Select/Select.js +19 -19
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +1 -0
- package/dist/components/inputs/Selection/shared/SelectBase.js +37 -34
- package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/select.context.js +8 -4
- package/dist/components/inputs/Selection/shared/select.types.d.ts +1 -1
- package/dist/components/inputs/Slider/Slider.d.ts +1 -1
- package/dist/components/inputs/Slider/Slider.js +18 -18
- package/dist/components/inputs/TextEditor/TextEditor.d.ts +1 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +18 -18
- package/dist/components/inputs/Toggle/Toggle.d.ts +2 -1
- package/dist/components/inputs/Toggle/Toggle.js +63 -59
- package/dist/components/inputs/shared/form.types.d.ts +8 -9
- package/dist/components/segment/Segment.d.ts +1 -1
- package/dist/components/segment/Segment.js +17 -17
- package/dist/components/segment/segment.types.d.ts +1 -1
- package/dist/config/uiConfig.context.d.ts +5 -5
- package/dist/config/uiConfig.context.js +12 -3
- package/dist/helpers/dynamicColumns.d.ts +1 -1
- package/dist/helpers/dynamicInputs.d.ts +7 -7
- package/dist/hooks/useAutosave.d.ts +4 -4
- package/dist/hooks/useAutosave.js +49 -64
- package/dist/hooks/useAutosave.spec.d.ts +1 -0
- package/dist/hooks/useForm.d.ts +15 -39
- package/dist/hooks/useForm.js +43 -96
- package/dist/hooks/useFormAutosave.d.ts +9 -8
- package/dist/hooks/useFormAutosave.js +9 -23
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/package.json +3 -2
- package/dist/components/inputs/shared/form.binding.d.ts +0 -27
- package/dist/components/inputs/shared/form.binding.js +0 -57
- package/dist/components/inputs/shared/form.types.js +0 -8
package/dist/hooks/useForm.d.ts
CHANGED
|
@@ -1,42 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BrowserNativeObject, ExtractObjects, FieldValues, NestedValue, UseFormProps as UseReactHookFormProps } from 'react-hook-form';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
onBlur?: ({ value }: {
|
|
6
|
-
value: unknown;
|
|
7
|
-
}) => string | undefined;
|
|
8
|
-
onChange?: ({ value }: {
|
|
9
|
-
value: unknown;
|
|
10
|
-
}) => string | undefined;
|
|
11
|
-
};
|
|
12
|
-
export type FormSubmitHandler<TValues> = (values: TValues) => void | Promise<void>;
|
|
13
|
-
export type FormSubmitErrorHandler<TValues> = (errors: unknown, values: TValues) => unknown;
|
|
14
|
-
type TanStackForm<TFieldValues> = ReactFormExtendedApi<TFieldValues, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, never>;
|
|
15
|
-
export type UIForm<TFieldValues extends Record<string, unknown> = Record<string, unknown>> = Omit<TanStackForm<TFieldValues>, "handleSubmit"> & {
|
|
16
|
-
readonly disabled: boolean;
|
|
17
|
-
getFieldValidators: (name: DeepKeys<TFieldValues>) => FieldValidators | undefined;
|
|
18
|
-
notifyBlur: (name: DeepKeys<TFieldValues>) => void;
|
|
19
|
-
parseValues: (values: TFieldValues) => unknown;
|
|
20
|
-
subscribeBlur: (listener: (name: DeepKeys<TFieldValues>) => void) => () => void;
|
|
21
|
-
handleSubmit: (onValid: FormSubmitHandler<any>, onInvalid?: FormSubmitErrorHandler<TFieldValues>) => (event?: {
|
|
22
|
-
preventDefault?: () => void;
|
|
23
|
-
stopPropagation?: () => void;
|
|
24
|
-
}) => Promise<void>;
|
|
3
|
+
type DeepNullablePartial<T> = T extends BrowserNativeObject | NestedValue ? T : {
|
|
4
|
+
[K in keyof T]?: ExtractObjects<T[K]> extends never ? T[K] | null : DeepNullablePartial<T[K]>;
|
|
25
5
|
};
|
|
26
6
|
type AsyncDefaultValues<TFieldValues> = (payload?: unknown) => Promise<TFieldValues>;
|
|
27
|
-
type
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
export declare function useForm<TFieldValues extends Record<string, unknown> = Record<string, unknown>, _TContext = unknown, TTransformedValues = TFieldValues>({ defaultValues, disabled, mode, onSubmitAsync, zodSchema, }?: UseFormProps<TFieldValues, TTransformedValues>): UIForm<TFieldValues>;
|
|
40
|
-
export declare const useFormValue: <TFieldValues extends Record<string, unknown>, TSelected>(form: UIForm<TFieldValues>, selector: (values: TFieldValues) => TSelected) => TSelected;
|
|
41
|
-
export declare const useFormState: <TFieldValues extends Record<string, unknown>, TSelected>(form: UIForm<TFieldValues>, selector: (state: UIForm<TFieldValues>["state"]) => TSelected) => TSelected;
|
|
42
|
-
export type { AnyFormApi, DeepKeys, DeepValue };
|
|
7
|
+
type NullableDefaultValues<TFieldValues> = TFieldValues extends AsyncDefaultValues<TFieldValues> ? DeepNullablePartial<Awaited<TFieldValues>> : DeepNullablePartial<TFieldValues>;
|
|
8
|
+
export type UseFormResolverProps<TFieldValues extends FieldValues, TTransformedValues = TFieldValues> = {
|
|
9
|
+
zodSchema: z.ZodType<TTransformedValues, TFieldValues>;
|
|
10
|
+
resolver?: never;
|
|
11
|
+
} | {
|
|
12
|
+
zodSchema?: never;
|
|
13
|
+
};
|
|
14
|
+
export type UseFormProps<TFieldValues extends FieldValues, TContext, TTransformedValues = TFieldValues> = Omit<UseReactHookFormProps<TFieldValues, TContext, TTransformedValues>, "defaultValues"> & {
|
|
15
|
+
defaultValues?: NullableDefaultValues<TFieldValues> | AsyncDefaultValues<TFieldValues>;
|
|
16
|
+
};
|
|
17
|
+
export declare function useForm<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>({ resolver, zodSchema, defaultValues, ...props }: UseFormProps<TFieldValues, TContext, TTransformedValues> & UseFormResolverProps<TFieldValues, TTransformedValues>): import('react-hook-form').UseFormReturn<TFieldValues, TContext, TTransformedValues>;
|
|
18
|
+
export {};
|
package/dist/hooks/useForm.js
CHANGED
|
@@ -1,101 +1,48 @@
|
|
|
1
1
|
import { c } from "react/compiler-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useForm } from "react-hook-form";
|
|
3
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
4
|
//#region src/hooks/useForm.ts
|
|
5
|
-
function useForm$1(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} });
|
|
40
|
-
uiForm.getFieldValidators = (name) => {
|
|
41
|
-
const cached = fieldValidators.get(name);
|
|
42
|
-
if (cached || fieldValidators.has(name)) return cached;
|
|
43
|
-
const schema = zodSchema ? getSchemaAtPath(zodSchema, name) : void 0;
|
|
44
|
-
if (!schema || mode === "onSubmit") {
|
|
45
|
-
fieldValidators.set(name, void 0);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const validate = ({ value: value_2 }) => {
|
|
49
|
-
const result_0 = schema.safeParse(value_2);
|
|
50
|
-
return result_0.success ? void 0 : result_0.error.issues[0]?.message;
|
|
5
|
+
function useForm$1(t0) {
|
|
6
|
+
const $ = c(12);
|
|
7
|
+
let defaultValues;
|
|
8
|
+
let props;
|
|
9
|
+
let resolver;
|
|
10
|
+
let zodSchema;
|
|
11
|
+
if ($[0] !== t0) {
|
|
12
|
+
({resolver, zodSchema, defaultValues, ...props} = t0);
|
|
13
|
+
$[0] = t0;
|
|
14
|
+
$[1] = defaultValues;
|
|
15
|
+
$[2] = props;
|
|
16
|
+
$[3] = resolver;
|
|
17
|
+
$[4] = zodSchema;
|
|
18
|
+
} else {
|
|
19
|
+
defaultValues = $[1];
|
|
20
|
+
props = $[2];
|
|
21
|
+
resolver = $[3];
|
|
22
|
+
zodSchema = $[4];
|
|
23
|
+
}
|
|
24
|
+
let t1;
|
|
25
|
+
if ($[5] !== resolver || $[6] !== zodSchema) {
|
|
26
|
+
t1 = resolver ?? (zodSchema ? zodResolver(zodSchema) : void 0);
|
|
27
|
+
$[5] = resolver;
|
|
28
|
+
$[6] = zodSchema;
|
|
29
|
+
$[7] = t1;
|
|
30
|
+
} else t1 = $[7];
|
|
31
|
+
const formResolver = t1;
|
|
32
|
+
const t2 = defaultValues;
|
|
33
|
+
let t3;
|
|
34
|
+
if ($[8] !== formResolver || $[9] !== props || $[10] !== t2) {
|
|
35
|
+
t3 = {
|
|
36
|
+
...props,
|
|
37
|
+
resolver: formResolver,
|
|
38
|
+
defaultValues: t2
|
|
51
39
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
uiForm.parseValues = (values) => zodSchema ? zodSchema.parse(values) : values;
|
|
60
|
-
uiForm.subscribeBlur = (listener_0) => {
|
|
61
|
-
blurListenersRef.current.add(listener_0);
|
|
62
|
-
return () => blurListenersRef.current.delete(listener_0);
|
|
63
|
-
};
|
|
64
|
-
uiForm.handleSubmit = (onValid, onInvalid) => async (event) => {
|
|
65
|
-
event?.preventDefault?.();
|
|
66
|
-
event?.stopPropagation?.();
|
|
67
|
-
submitHandlerRef.current = onValid;
|
|
68
|
-
submitErrorHandlerRef.current = onInvalid;
|
|
69
|
-
await originalHandleSubmit();
|
|
70
|
-
};
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (typeof defaultValues === "function") defaultValues().then((values_0) => form.reset(values_0));
|
|
73
|
-
}, [defaultValues, form]);
|
|
74
|
-
return uiForm;
|
|
40
|
+
$[8] = formResolver;
|
|
41
|
+
$[9] = props;
|
|
42
|
+
$[10] = t2;
|
|
43
|
+
$[11] = t3;
|
|
44
|
+
} else t3 = $[11];
|
|
45
|
+
return useForm(t3);
|
|
75
46
|
}
|
|
76
|
-
var useFormValue = (form, selector) => {
|
|
77
|
-
const $ = c(2);
|
|
78
|
-
let t0;
|
|
79
|
-
if ($[0] !== selector) {
|
|
80
|
-
t0 = (state) => selector(state.values);
|
|
81
|
-
$[0] = selector;
|
|
82
|
-
$[1] = t0;
|
|
83
|
-
} else t0 = $[1];
|
|
84
|
-
return useStore(form.store, t0);
|
|
85
|
-
};
|
|
86
|
-
var useFormState = (form, selector) => {
|
|
87
|
-
return useStore(form.store, selector);
|
|
88
|
-
};
|
|
89
|
-
var getSchemaAtPath = (rootSchema, path) => {
|
|
90
|
-
let schema = rootSchema;
|
|
91
|
-
for (const segment of parsePath(path)) {
|
|
92
|
-
while (schema?.unwrap && !schema.shape && !schema.element && !schema.items) schema = schema.unwrap();
|
|
93
|
-
schema = typeof segment === "number" ? schema?.element ?? schema?.items?.[segment] : schema?.shape?.[segment];
|
|
94
|
-
if (!schema) return;
|
|
95
|
-
}
|
|
96
|
-
return schema;
|
|
97
|
-
};
|
|
98
|
-
var parsePath = (path) => path.replaceAll("[", ".").replaceAll("]", "").split(".").filter(Boolean).map((segment) => /^\d+$/.test(segment) ? Number(segment) : segment);
|
|
99
|
-
var pathToString = (path) => path.reduce((result, segment) => typeof segment === "number" ? `${result}[${segment}]` : result ? `${result}.${String(segment)}` : String(segment), "");
|
|
100
47
|
//#endregion
|
|
101
|
-
export { useForm$1 as useForm
|
|
48
|
+
export { useForm$1 as useForm };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { DependencyList } from 'react';
|
|
2
|
+
import { FieldValues } from 'react-hook-form';
|
|
2
3
|
import { UseAutosaveProps } from './useAutosave';
|
|
3
|
-
import { UseFormProps } from './useForm';
|
|
4
|
-
export type UseFormAutosaveProps<TFieldValues extends
|
|
5
|
-
autosaveDelay?: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>["delay"];
|
|
6
|
-
enableAutosave?: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>["enabled"];
|
|
7
|
-
autosaveOn?: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>["trigger"];
|
|
4
|
+
import { UseFormProps, UseFormResolverProps } from './useForm';
|
|
5
|
+
export type UseFormAutosaveProps<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues, TResponse = unknown> = Omit<UseFormProps<TFieldValues, TContext, TTransformedValues>, "defaultValues"> & UseFormResolverProps<TFieldValues, TTransformedValues> & {
|
|
6
|
+
autosaveDelay?: UseAutosaveProps<TFieldValues, TContext, TTransformedValues, TResponse>["delay"];
|
|
7
|
+
enableAutosave?: UseAutosaveProps<TFieldValues, TContext, TTransformedValues, TResponse>["enabled"];
|
|
8
|
+
autosaveOn?: UseAutosaveProps<TFieldValues, TContext, TTransformedValues, TResponse>["trigger"];
|
|
8
9
|
normalizeAutosaveData?: (data: Partial<TTransformedValues>) => Partial<TTransformedValues> | undefined;
|
|
9
|
-
onAutosave: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>["onSave"];
|
|
10
|
-
getResetValues: () => UseFormProps<TFieldValues, TTransformedValues>["defaultValues"];
|
|
10
|
+
onAutosave: UseAutosaveProps<TFieldValues, TContext, TTransformedValues, TResponse>["onSave"];
|
|
11
|
+
getResetValues: () => UseFormProps<TFieldValues, TContext, TTransformedValues>["defaultValues"];
|
|
11
12
|
resetDeps: DependencyList;
|
|
12
13
|
resetTimeout?: number;
|
|
13
14
|
};
|
|
14
|
-
export declare function useFormAutosave<TFieldValues extends
|
|
15
|
+
export declare function useFormAutosave<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues, TResponse = any>({ autosaveDelay, enableAutosave, autosaveOn, normalizeAutosaveData, onAutosave, getResetValues, resetDeps, resetTimeout, ...props }: UseFormAutosaveProps<TFieldValues, TContext, TTransformedValues, TResponse>): import('react-hook-form').UseFormReturn<TFieldValues, TContext, TTransformedValues>;
|
|
@@ -26,19 +26,15 @@ function useFormAutosave({ autosaveDelay, enableAutosave, autosaveOn = "change",
|
|
|
26
26
|
const resetValues = getResetValues();
|
|
27
27
|
if (resetValues === void 0) return;
|
|
28
28
|
const resetFormValues = async () => {
|
|
29
|
-
const
|
|
29
|
+
const keepStateOptions = shouldResetFormValuesRef.current ? { keepDirtyValues: true } : void 0;
|
|
30
30
|
shouldResetFormValuesRef.current = false;
|
|
31
|
-
let values;
|
|
31
|
+
let values = resetValues;
|
|
32
32
|
if (ObjectUtils.isFunction(resetValues)) values = await resetValues();
|
|
33
|
-
|
|
34
|
-
form.reset(keepCurrentValues ? {
|
|
35
|
-
...values,
|
|
36
|
-
...form.state.values
|
|
37
|
-
} : values);
|
|
33
|
+
form.reset(values, keepStateOptions);
|
|
38
34
|
};
|
|
39
35
|
resetFormValues();
|
|
40
36
|
}, [...resetDeps]);
|
|
41
|
-
const
|
|
37
|
+
const onSaveSuccess = () => {
|
|
42
38
|
shouldResetFormValuesRef.current = true;
|
|
43
39
|
if (resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
44
40
|
resetFormValuesTimeoutRef.current = setTimeout(() => {
|
|
@@ -50,22 +46,12 @@ function useFormAutosave({ autosaveDelay, enableAutosave, autosaveOn = "change",
|
|
|
50
46
|
delay: autosaveDelay,
|
|
51
47
|
enabled: enableAutosave,
|
|
52
48
|
trigger: autosaveOn,
|
|
53
|
-
onSave: useCallback(
|
|
49
|
+
onSave: useCallback((data) => {
|
|
54
50
|
const normalizedData = normalizeAutosaveData ? normalizeAutosaveData(data) : data;
|
|
55
|
-
if (!normalizedData || ObjectUtils.isEmpty(normalizedData)) return;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
} catch (error) {
|
|
60
|
-
shouldResetFormValuesRef.current = false;
|
|
61
|
-
if (resetFormValuesTimeoutRef.current) clearTimeout(resetFormValuesTimeoutRef.current);
|
|
62
|
-
throw error;
|
|
63
|
-
}
|
|
64
|
-
}, [
|
|
65
|
-
normalizeAutosaveData,
|
|
66
|
-
onAutosave,
|
|
67
|
-
resetTimeout
|
|
68
|
-
])
|
|
51
|
+
if (!normalizedData || ObjectUtils.isEmpty(normalizedData)) return Promise.resolve(void 0);
|
|
52
|
+
return onAutosave(normalizedData);
|
|
53
|
+
}, [normalizeAutosaveData, onAutosave]),
|
|
54
|
+
onSaveSuccess
|
|
69
55
|
});
|
|
70
56
|
return form;
|
|
71
57
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -230,8 +230,8 @@ export { useDebounceCallback } from './hooks/useDebounceCallback';
|
|
|
230
230
|
export { useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo } from './hooks/useDeepCompare';
|
|
231
231
|
export type { FilterStore } from './hooks/useFilters';
|
|
232
232
|
export { useFilters } from './hooks/useFilters';
|
|
233
|
-
export type {
|
|
234
|
-
export { useForm
|
|
233
|
+
export type { UseFormProps, UseFormResolverProps } from './hooks/useForm';
|
|
234
|
+
export { useForm } from './hooks/useForm';
|
|
235
235
|
export type { UseFormAutosaveProps } from './hooks/useFormAutosave';
|
|
236
236
|
export { useFormAutosave } from './hooks/useFormAutosave';
|
|
237
237
|
export { useIntersectionObserver } from './hooks/useIntersectionObserver';
|
package/dist/index.js
CHANGED
|
@@ -87,10 +87,10 @@ import { DateTimeUtils } from "./utils/date-time.utils.js";
|
|
|
87
87
|
import { datePickerInputContentRowDefinition } from "./components/inputs/DateTime/shared/datePickerInput.cva.js";
|
|
88
88
|
import { popoverDefinition } from "./components/shared/popover.cva.js";
|
|
89
89
|
import { tooltipWrapperTriggerDefinition } from "./components/inputs/shared/tooltipWrapper.cva.js";
|
|
90
|
+
import { useDebounceCallback } from "./hooks/useDebounceCallback.js";
|
|
90
91
|
import { DatePicker } from "./components/inputs/DateTime/DatePicker/DatePicker.js";
|
|
91
92
|
import { tagDefinition } from "./components/text/Tag/tag.cva.js";
|
|
92
93
|
import { Tag } from "./components/text/Tag/Tag.js";
|
|
93
|
-
import { useDebounceCallback } from "./hooks/useDebounceCallback.js";
|
|
94
94
|
import { selectInputTagsContentWrapperDefinition } from "./components/inputs/Selection/shared/selectInput.cva.js";
|
|
95
95
|
import { createKeyInteractionsHandler, getKeyInteractionAction, useKeyInteractions } from "./hooks/useKeyInteractions.js";
|
|
96
96
|
import { selectListBoxItemDefinition } from "./components/inputs/Selection/shared/selectItem.cva.js";
|
|
@@ -170,11 +170,11 @@ import { dynamicColumns } from "./helpers/dynamicColumns.js";
|
|
|
170
170
|
import { useAutosave } from "./hooks/useAutosave.js";
|
|
171
171
|
import { RoutingUtils } from "./utils/routing.utils.js";
|
|
172
172
|
import { useFilters } from "./hooks/useFilters.js";
|
|
173
|
-
import { useForm
|
|
173
|
+
import { useForm } from "./hooks/useForm.js";
|
|
174
174
|
import { useFormAutosave } from "./hooks/useFormAutosave.js";
|
|
175
175
|
import { usePagination } from "./hooks/usePagination.js";
|
|
176
176
|
import { useSorting } from "./hooks/useSorting.js";
|
|
177
177
|
import { useTableColumnConfig } from "./hooks/useTableColumnConfig.js";
|
|
178
178
|
import { ArrayUtils } from "./utils/array.utils.js";
|
|
179
179
|
import { QueriesUtils } from "./utils/queries.utils.js";
|
|
180
|
-
export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxGroup, CheckboxIndeterminateIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ClockIcon, CloseIcon, ColumnConfigModal, Confirmation, DatePicker, DateRangePicker, DateTimeIcon, DateTimePicker, DateTimeUtils, DateUtils, DomUtils, Drawer, FileUpload, FileUploadContainer, FileUtils, Form, FormField, HeaderText, HighlightIcon, HighlightOnIcon, HomeIcon, IconButton, InfiniteTable, InfoIcon, InlineIconButton, InputUpload, Inputs, IntlUtils, ItalicIcon, Link, LinkContext, LinkIcon, Loader, Menu, MenuIcon, MenuItem, MenuPopover, Modal, NumberInput, NumberRangeInput, NumberedListIcon, ObjectUtils, PaginatedTable, Pagination, PaginationList, PasswordInput, Pill, PillButton, PointerHorizontalIcon, PointerVerticalIcon, ProgressBar, QueriesUtils, QueryAutocomplete, QuerySelect, RadioGroup, ResponsivePopover, RestUtils, RoutingUtils, Segment, Select, SendIcon, Slider, SplitButton, Stepper, StrikethroughIcon, StringUtils, Table, Tag, TextArea, TextButton, TextColorIcon, TextInput, ThemeContext, TimePicker, Toast, ToastContainer, Toggle, ToggleButton, Tooltip, TooltipEllipsis, Typography, UIConfig, UIOverrides, UIRouter, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, ZodUtils, accordionChevronDefinition, accordionDefinition, accordionHeadingDefinition, accordionHeadingSubtitleDefinition, accordionHeadingTitleDefinition, accordionIconDefinition, accordionItemDefinition, accordionPanelContentDefinition, accordionPanelDefinition, accordionTriggerDefinition, alertDefinition, breadcrumbChevronDefinition, breadcrumbIconDefinition, breadcrumbItemDefinition, breadcrumbSegmentDefinition, breadcrumbsDefinition, buttonContentDefinition, buttonDefinition, buttonIconSizeDefinition, buttonSizeDefinition, checkboxContentRowDefinition, checkboxContentWrapperDefinition, checkboxDefinition, checkboxGroupLabelDefinition, checkboxIconDefinition, compoundMapper, createKeyInteractionsHandler, datePickerInputContentRowDefinition, dynamicColumns, dynamicInputs, fileUploadDropZoneDefinition, formFieldErrorDefinition, formFieldHeaderDefinition, formFieldHelperDefinition, getKeyInteractionAction, inputBaseDefinition, inputClearClassDefinition, inputContentWrapperDefinition, inputSideDefinition, inputSizeDefinition, inputUploadButtonDefinition, inputUploadDropZoneDefinition, isEqual, labelDefinition, linkDefinition, loaderDefinition, loaderWrapperDefinition, logger, menuDefinition, menuItemDefinition, menuPopoverDefinition, menuPopoverWrapperDefinition, modalContentDefinition, modalMainDefinition, modalOverlayDefinition, ns, pillButtonContentDefinition, pillButtonDefinition, popoverDefinition, progressBarDefinition, progressBarFillDefinition, progressBarTrackDefinition, progressBarTrackWrapperDefinition, progressBarValueDefinition, radioContentRowDefinition, radioContentWrapperDefinition, radioDefinition, resources, segmentDefinition, segmentItemDefinition, selectInputTagsContentWrapperDefinition, selectListBoxItemDefinition, selectPopoverDefinition, statusIconDefinition, statusSeparatorDefinition, stepperDefinition, stepperIconDefinition, stepperItemDefinition, stepperNumberDefinition, stepperSeparatorDefinition, stepperSubtextDefinition, stepperTitleDefinition, tableCellTextDefinition, tableDataDefinition, tableHeadDataDefinition, tableHeadRowDefinition, tableHeaderTextDefinition, tableRowDefinition, tagDefinition, textAreaWrapperDefinition, toastDefinition, statusIconDefinition$1 as toastStatusIconDefinition, statusSeparatorDefinition$1 as toastStatusSeparatorDefinition, toggleDefinition, tooltipDefinition, tooltipPointerHorizontalDefinition, tooltipPointerVerticalDefinition, tooltipTextDefinition, tooltipWrapperTriggerDefinition, typographyDefinition, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave,
|
|
180
|
+
export { Accordion, ActionModal, Alert, AlignCenterIcon, AlignLeftIcon, AlignLeftRightIcon, AlignRightIcon, ArrayUtils, ArrowDropDownIcon, ArrowDropUpIcon, ArrowLeftIcon, ArrowRightIcon, Autocomplete, BoldIcon, BottomSheet, Breadcrumbs, BulletedListIcon, Button, CalendarIcon, CellText, CheckIcon, Checkbox, CheckboxCheckmarkIcon, CheckboxGroup, CheckboxIndeterminateIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, ChevronsLeftIcon, ChevronsRightIcon, ClockIcon, CloseIcon, ColumnConfigModal, Confirmation, DatePicker, DateRangePicker, DateTimeIcon, DateTimePicker, DateTimeUtils, DateUtils, DomUtils, Drawer, FileUpload, FileUploadContainer, FileUtils, Form, FormField, HeaderText, HighlightIcon, HighlightOnIcon, HomeIcon, IconButton, InfiniteTable, InfoIcon, InlineIconButton, InputUpload, Inputs, IntlUtils, ItalicIcon, Link, LinkContext, LinkIcon, Loader, Menu, MenuIcon, MenuItem, MenuPopover, Modal, NumberInput, NumberRangeInput, NumberedListIcon, ObjectUtils, PaginatedTable, Pagination, PaginationList, PasswordInput, Pill, PillButton, PointerHorizontalIcon, PointerVerticalIcon, ProgressBar, QueriesUtils, QueryAutocomplete, QuerySelect, RadioGroup, ResponsivePopover, RestUtils, RoutingUtils, Segment, Select, SendIcon, Slider, SplitButton, Stepper, StrikethroughIcon, StringUtils, Table, Tag, TextArea, TextButton, TextColorIcon, TextInput, ThemeContext, TimePicker, Toast, ToastContainer, Toggle, ToggleButton, Tooltip, TooltipEllipsis, Typography, UIConfig, UIOverrides, UIRouter, UnderlinedIcon, VisibilityIcon, VisibilityOffIcon, ZodUtils, accordionChevronDefinition, accordionDefinition, accordionHeadingDefinition, accordionHeadingSubtitleDefinition, accordionHeadingTitleDefinition, accordionIconDefinition, accordionItemDefinition, accordionPanelContentDefinition, accordionPanelDefinition, accordionTriggerDefinition, alertDefinition, breadcrumbChevronDefinition, breadcrumbIconDefinition, breadcrumbItemDefinition, breadcrumbSegmentDefinition, breadcrumbsDefinition, buttonContentDefinition, buttonDefinition, buttonIconSizeDefinition, buttonSizeDefinition, checkboxContentRowDefinition, checkboxContentWrapperDefinition, checkboxDefinition, checkboxGroupLabelDefinition, checkboxIconDefinition, compoundMapper, createKeyInteractionsHandler, datePickerInputContentRowDefinition, dynamicColumns, dynamicInputs, fileUploadDropZoneDefinition, formFieldErrorDefinition, formFieldHeaderDefinition, formFieldHelperDefinition, getKeyInteractionAction, inputBaseDefinition, inputClearClassDefinition, inputContentWrapperDefinition, inputSideDefinition, inputSizeDefinition, inputUploadButtonDefinition, inputUploadDropZoneDefinition, isEqual, labelDefinition, linkDefinition, loaderDefinition, loaderWrapperDefinition, logger, menuDefinition, menuItemDefinition, menuPopoverDefinition, menuPopoverWrapperDefinition, modalContentDefinition, modalMainDefinition, modalOverlayDefinition, ns, pillButtonContentDefinition, pillButtonDefinition, popoverDefinition, progressBarDefinition, progressBarFillDefinition, progressBarTrackDefinition, progressBarTrackWrapperDefinition, progressBarValueDefinition, radioContentRowDefinition, radioContentWrapperDefinition, radioDefinition, resources, segmentDefinition, segmentItemDefinition, selectInputTagsContentWrapperDefinition, selectListBoxItemDefinition, selectPopoverDefinition, statusIconDefinition, statusSeparatorDefinition, stepperDefinition, stepperIconDefinition, stepperItemDefinition, stepperNumberDefinition, stepperSeparatorDefinition, stepperSubtextDefinition, stepperTitleDefinition, tableCellTextDefinition, tableDataDefinition, tableHeadDataDefinition, tableHeadRowDefinition, tableHeaderTextDefinition, tableRowDefinition, tagDefinition, textAreaWrapperDefinition, toastDefinition, statusIconDefinition$1 as toastStatusIconDefinition, statusSeparatorDefinition$1 as toastStatusSeparatorDefinition, toggleDefinition, tooltipDefinition, tooltipPointerHorizontalDefinition, tooltipPointerVerticalDefinition, tooltipTextDefinition, tooltipWrapperTriggerDefinition, typographyDefinition, uiOutlineClass, useAutosave, useBreakpoint, useDebounceCallback, useDeepCompareEffect, useDeepCompareLayoutEffect, useDeepCompareMemo, useFilters, useForm, useFormAutosave, useIntersectionObserver, useKeyInteractions, useLocalStorage, useLongPressRepeat, usePagination, useScrollableListBox, useSorting, useStateAndRef, useTableColumnConfig, useTableNav, useToast, useTranslationMemo };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@povio/ui",
|
|
3
|
-
"version": "3.4.0-rc.
|
|
3
|
+
"version": "3.4.0-rc.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@dnd-kit/modifiers": "^9.0.0",
|
|
21
21
|
"@dnd-kit/sortable": "^10.0.0",
|
|
22
22
|
"@dnd-kit/utilities": "^3.2.2",
|
|
23
|
+
"@hookform/resolvers": "^5.2.2",
|
|
23
24
|
"@internationalized/date": "^3.11.0",
|
|
24
25
|
"@react-aria/button": "^3.14.4",
|
|
25
26
|
"@react-aria/calendar": "^3.9.4",
|
|
@@ -29,7 +30,6 @@
|
|
|
29
30
|
"@react-stately/calendar": "^3.9.2",
|
|
30
31
|
"@react-stately/datepicker": "^3.16.0",
|
|
31
32
|
"@react-types/shared": "^3.33.0",
|
|
32
|
-
"@tanstack/react-form": "^1.33.2",
|
|
33
33
|
"@tanstack/react-table": "^8.21.3",
|
|
34
34
|
"axios": "^1.13.2",
|
|
35
35
|
"class-variance-authority": "^0.7.1",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"motion": "~12.23.24",
|
|
41
41
|
"react-aria": "^3.46.0",
|
|
42
42
|
"react-aria-components": "^1.15.1",
|
|
43
|
+
"react-hook-form": "^7.65.0",
|
|
43
44
|
"react-responsive": "^10.0.1",
|
|
44
45
|
"react-stately": "^3.44.0",
|
|
45
46
|
"react-toastify": "^11.0.5",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { DeepKeys, DeepValue, UIForm } from '../../../hooks/useForm';
|
|
2
|
-
export type FieldValues = Record<string, any>;
|
|
3
|
-
export type FieldPath<TFieldValues extends FieldValues> = DeepKeys<TFieldValues>;
|
|
4
|
-
export type FieldPathValue<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues>> = DeepValue<TFieldValues, TName>;
|
|
5
|
-
export type FormInstance<TFieldValues extends FieldValues> = UIForm<TFieldValues>;
|
|
6
|
-
interface FieldControllerProps<TFieldValues extends FieldValues> {
|
|
7
|
-
control: UIForm<TFieldValues>;
|
|
8
|
-
name: DeepKeys<TFieldValues>;
|
|
9
|
-
render: (props: {
|
|
10
|
-
field: {
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
name: string;
|
|
13
|
-
onBlur: () => void;
|
|
14
|
-
onChange: (value: any) => void;
|
|
15
|
-
ref: () => void;
|
|
16
|
-
value: any;
|
|
17
|
-
};
|
|
18
|
-
fieldState: {
|
|
19
|
-
error?: {
|
|
20
|
-
message: string;
|
|
21
|
-
};
|
|
22
|
-
isDirty: boolean;
|
|
23
|
-
};
|
|
24
|
-
}) => React.ReactNode;
|
|
25
|
-
}
|
|
26
|
-
export declare function FieldController<TFieldValues extends FieldValues>({ control: form, name, render, }: FieldControllerProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { getFieldError } from "./form.types.js";
|
|
2
|
-
import { c } from "react/compiler-runtime";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
//#region src/components/inputs/shared/form.binding.tsx
|
|
5
|
-
function FieldController(t0) {
|
|
6
|
-
const $ = c(12);
|
|
7
|
-
const { control: form, name, render } = t0;
|
|
8
|
-
const T0 = form.Field;
|
|
9
|
-
let t1;
|
|
10
|
-
if ($[0] !== form || $[1] !== name) {
|
|
11
|
-
t1 = form.getFieldValidators(name);
|
|
12
|
-
$[0] = form;
|
|
13
|
-
$[1] = name;
|
|
14
|
-
$[2] = t1;
|
|
15
|
-
} else t1 = $[2];
|
|
16
|
-
let t2;
|
|
17
|
-
if ($[3] !== form || $[4] !== name || $[5] !== render) {
|
|
18
|
-
t2 = (field) => render({
|
|
19
|
-
field: {
|
|
20
|
-
disabled: form.disabled,
|
|
21
|
-
name: field.name,
|
|
22
|
-
onBlur: () => {
|
|
23
|
-
field.handleBlur();
|
|
24
|
-
form.notifyBlur(name);
|
|
25
|
-
},
|
|
26
|
-
onChange: field.handleChange,
|
|
27
|
-
ref: _temp,
|
|
28
|
-
value: field.state.value
|
|
29
|
-
},
|
|
30
|
-
fieldState: {
|
|
31
|
-
error: getFieldError(field.state.meta.errors) ? { message: getFieldError(field.state.meta.errors) } : void 0,
|
|
32
|
-
isDirty: field.state.meta.isDirty
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
$[3] = form;
|
|
36
|
-
$[4] = name;
|
|
37
|
-
$[5] = render;
|
|
38
|
-
$[6] = t2;
|
|
39
|
-
} else t2 = $[6];
|
|
40
|
-
let t3;
|
|
41
|
-
if ($[7] !== form.Field || $[8] !== name || $[9] !== t1 || $[10] !== t2) {
|
|
42
|
-
t3 = /* @__PURE__ */ jsx(T0, {
|
|
43
|
-
name,
|
|
44
|
-
validators: t1,
|
|
45
|
-
children: t2
|
|
46
|
-
});
|
|
47
|
-
$[7] = form.Field;
|
|
48
|
-
$[8] = name;
|
|
49
|
-
$[9] = t1;
|
|
50
|
-
$[10] = t2;
|
|
51
|
-
$[11] = t3;
|
|
52
|
-
} else t3 = $[11];
|
|
53
|
-
return t3;
|
|
54
|
-
}
|
|
55
|
-
function _temp() {}
|
|
56
|
-
//#endregion
|
|
57
|
-
export { FieldController };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
//#region src/components/inputs/shared/form.types.ts
|
|
2
|
-
var getFieldError = (errors) => errors.flatMap((error) => {
|
|
3
|
-
if (typeof error === "string") return [error];
|
|
4
|
-
if (error && typeof error === "object" && "message" in error) return [String(error.message)];
|
|
5
|
-
return [];
|
|
6
|
-
}).at(0);
|
|
7
|
-
//#endregion
|
|
8
|
-
export { getFieldError };
|