@povio/ui 3.3.0 → 3.4.0-rc.1
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 +1 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +93 -100
- package/dist/components/inputs/Checkbox/CheckboxGroup.d.ts +1 -2
- package/dist/components/inputs/Checkbox/CheckboxGroup.js +109 -113
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +14 -21
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +14 -22
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +14 -21
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +1 -2
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +275 -294
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +1 -10
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +1 -2
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +43 -46
- 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 +36 -38
- 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 +35 -36
- package/dist/components/inputs/Inputs/Inputs.d.ts +2 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +1 -2
- package/dist/components/inputs/RadioGroup/RadioGroup.js +107 -111
- 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 +0 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +34 -37
- package/dist/components/inputs/Selection/shared/select.context.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/select.context.js +4 -8
- 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 +1 -2
- package/dist/components/inputs/Toggle/Toggle.js +59 -63
- package/dist/components/inputs/shared/form.binding.d.ts +27 -0
- package/dist/components/inputs/shared/form.binding.js +57 -0
- package/dist/components/inputs/shared/form.types.d.ts +9 -8
- package/dist/components/inputs/shared/form.types.js +8 -0
- 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 +3 -12
- 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 +64 -49
- package/dist/hooks/useForm.d.ts +39 -15
- package/dist/hooks/useForm.js +96 -43
- package/dist/hooks/useFormAutosave.d.ts +8 -9
- package/dist/hooks/useFormAutosave.js +23 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/package.json +2 -3
- package/dist/hooks/useAutosave.spec.d.ts +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UIOverrides } from "../../../config/uiOverrides.context.js";
|
|
2
2
|
import { UIConfig } from "../../../config/uiConfig.context.js";
|
|
3
|
+
import { FieldController } from "../shared/form.binding.js";
|
|
3
4
|
import { FormFieldError } from "../FormField/FormFieldError.js";
|
|
4
5
|
import { CheckContent } from "../shared/CheckContent.js";
|
|
5
6
|
import { toggleContentClassName, toggleDefinition, toggleTypography } from "./toggle.cva.js";
|
|
@@ -8,10 +9,9 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
8
9
|
import { clsx } from "clsx";
|
|
9
10
|
import { Switch } from "react-aria-components";
|
|
10
11
|
import { mergeRefs } from "@react-aria/utils";
|
|
11
|
-
import { Controller } from "react-hook-form";
|
|
12
12
|
//#region src/components/inputs/Toggle/Toggle.tsx
|
|
13
13
|
var ToggleBase = (props) => {
|
|
14
|
-
const $ = c(
|
|
14
|
+
const $ = c(48);
|
|
15
15
|
const ui = UIConfig.useConfig();
|
|
16
16
|
const toggleCva = UIOverrides.useCva("toggle.cva", toggleDefinition);
|
|
17
17
|
const toggleTypographyMap = UIOverrides.useMapper("toggle.typography", toggleTypography);
|
|
@@ -31,10 +31,9 @@ var ToggleBase = (props) => {
|
|
|
31
31
|
let t8;
|
|
32
32
|
let t9;
|
|
33
33
|
if ($[0] !== props || $[1] !== toggleContentClassNameMap || $[2] !== toggleCva || $[3] !== toggleTypographyMap || $[4] !== ui) {
|
|
34
|
-
const { className, children: t10, isDisabled, error, variant: variantProp,
|
|
34
|
+
const { className, children: t10, isDisabled, error, variant: variantProp, onChange, onBlur, ...rest } = props;
|
|
35
35
|
children = t10;
|
|
36
36
|
const variant = variantProp ?? ui.toggle.variant;
|
|
37
|
-
const fireBlurOnChange = fireBlurOnChangeProp ?? ui.toggle.fireBlurOnChange;
|
|
38
37
|
let t11;
|
|
39
38
|
if ($[19] !== error || $[20] !== isDisabled) {
|
|
40
39
|
t11 = {
|
|
@@ -47,16 +46,13 @@ var ToggleBase = (props) => {
|
|
|
47
46
|
} else t11 = $[21];
|
|
48
47
|
formFieldErrorProps = t11;
|
|
49
48
|
let t12;
|
|
50
|
-
if ($[22] !==
|
|
49
|
+
if ($[22] !== onChange) {
|
|
51
50
|
t12 = (isSelected) => {
|
|
52
51
|
onChange?.(isSelected);
|
|
53
|
-
if (fireBlurOnChange) onBlur?.({});
|
|
54
52
|
};
|
|
55
|
-
$[22] =
|
|
56
|
-
$[23] =
|
|
57
|
-
|
|
58
|
-
$[25] = t12;
|
|
59
|
-
} else t12 = $[25];
|
|
53
|
+
$[22] = onChange;
|
|
54
|
+
$[23] = t12;
|
|
55
|
+
} else t12 = $[23];
|
|
60
56
|
const handleChange = t12;
|
|
61
57
|
T1 = Switch;
|
|
62
58
|
t2 = rest;
|
|
@@ -66,12 +62,12 @@ var ToggleBase = (props) => {
|
|
|
66
62
|
t6 = handleChange;
|
|
67
63
|
t7 = onBlur;
|
|
68
64
|
const t13 = !isDisabled && "cursor-pointer";
|
|
69
|
-
if ($[
|
|
65
|
+
if ($[24] !== className || $[25] !== t13) {
|
|
70
66
|
t8 = clsx("group flex items-center gap-2", t13, className);
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
} else t8 = $[
|
|
67
|
+
$[24] = className;
|
|
68
|
+
$[25] = t13;
|
|
69
|
+
$[26] = t8;
|
|
70
|
+
} else t8 = $[26];
|
|
75
71
|
t9 = /* @__PURE__ */ jsx("div", { className: toggleCva({
|
|
76
72
|
variant,
|
|
77
73
|
...rest
|
|
@@ -121,20 +117,20 @@ var ToggleBase = (props) => {
|
|
|
121
117
|
t9 = $[18];
|
|
122
118
|
}
|
|
123
119
|
let t10;
|
|
124
|
-
if ($[
|
|
120
|
+
if ($[27] !== T0 || $[28] !== children || $[29] !== t0 || $[30] !== t1) {
|
|
125
121
|
t10 = /* @__PURE__ */ jsx(T0, {
|
|
126
122
|
typography: t0,
|
|
127
123
|
contentClassName: t1,
|
|
128
124
|
children
|
|
129
125
|
});
|
|
130
|
-
$[
|
|
131
|
-
$[
|
|
132
|
-
$[
|
|
133
|
-
$[
|
|
134
|
-
$[
|
|
135
|
-
} else t10 = $[
|
|
126
|
+
$[27] = T0;
|
|
127
|
+
$[28] = children;
|
|
128
|
+
$[29] = t0;
|
|
129
|
+
$[30] = t1;
|
|
130
|
+
$[31] = t10;
|
|
131
|
+
} else t10 = $[31];
|
|
136
132
|
let t11;
|
|
137
|
-
if ($[
|
|
133
|
+
if ($[32] !== T1 || $[33] !== t10 || $[34] !== t2 || $[35] !== t3 || $[36] !== t4 || $[37] !== t5 || $[38] !== t6 || $[39] !== t7 || $[40] !== t8 || $[41] !== t9) {
|
|
138
134
|
t11 = /* @__PURE__ */ jsxs(T1, {
|
|
139
135
|
...t2,
|
|
140
136
|
"data-is-dirty": t3,
|
|
@@ -145,64 +141,64 @@ var ToggleBase = (props) => {
|
|
|
145
141
|
className: t8,
|
|
146
142
|
children: [t9, t10]
|
|
147
143
|
});
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
$[
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
} else t11 = $[
|
|
144
|
+
$[32] = T1;
|
|
145
|
+
$[33] = t10;
|
|
146
|
+
$[34] = t2;
|
|
147
|
+
$[35] = t3;
|
|
148
|
+
$[36] = t4;
|
|
149
|
+
$[37] = t5;
|
|
150
|
+
$[38] = t6;
|
|
151
|
+
$[39] = t7;
|
|
152
|
+
$[40] = t8;
|
|
153
|
+
$[41] = t9;
|
|
154
|
+
$[42] = t11;
|
|
155
|
+
} else t11 = $[42];
|
|
160
156
|
let t12;
|
|
161
|
-
if ($[
|
|
157
|
+
if ($[43] !== formFieldErrorProps) {
|
|
162
158
|
t12 = /* @__PURE__ */ jsx(FormFieldError, { ...formFieldErrorProps });
|
|
163
|
-
$[
|
|
164
|
-
$[
|
|
165
|
-
} else t12 = $[
|
|
159
|
+
$[43] = formFieldErrorProps;
|
|
160
|
+
$[44] = t12;
|
|
161
|
+
} else t12 = $[44];
|
|
166
162
|
let t13;
|
|
167
|
-
if ($[
|
|
163
|
+
if ($[45] !== t11 || $[46] !== t12) {
|
|
168
164
|
t13 = /* @__PURE__ */ jsxs(Fragment, { children: [t11, t12] });
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
} else t13 = $[
|
|
165
|
+
$[45] = t11;
|
|
166
|
+
$[46] = t12;
|
|
167
|
+
$[47] = t13;
|
|
168
|
+
} else t13 = $[47];
|
|
173
169
|
return t13;
|
|
174
170
|
};
|
|
175
171
|
var Toggle = (props) => {
|
|
176
172
|
const $ = c(15);
|
|
177
|
-
if ("
|
|
178
|
-
let
|
|
173
|
+
if ("field" in props && props.field) {
|
|
174
|
+
let field;
|
|
179
175
|
let innerProps;
|
|
180
176
|
let ref;
|
|
181
177
|
if ($[0] !== props) {
|
|
182
|
-
({
|
|
178
|
+
({field, ref, ...innerProps} = props);
|
|
183
179
|
$[0] = props;
|
|
184
|
-
$[1] =
|
|
180
|
+
$[1] = field;
|
|
185
181
|
$[2] = innerProps;
|
|
186
182
|
$[3] = ref;
|
|
187
183
|
} else {
|
|
188
|
-
|
|
184
|
+
field = $[1];
|
|
189
185
|
innerProps = $[2];
|
|
190
186
|
ref = $[3];
|
|
191
187
|
}
|
|
192
188
|
let t0;
|
|
193
189
|
if ($[4] !== innerProps || $[5] !== props.error || $[6] !== props.isDisabled || $[7] !== ref) {
|
|
194
190
|
t0 = (t1) => {
|
|
195
|
-
const { field, fieldState: t2 } = t1;
|
|
191
|
+
const { field: field_0, fieldState: t2 } = t1;
|
|
196
192
|
const { error, isDirty } = t2;
|
|
197
193
|
return /* @__PURE__ */ jsx(ToggleBase, {
|
|
198
194
|
...innerProps,
|
|
199
|
-
ref: mergeRefs(ref,
|
|
200
|
-
isSelected:
|
|
201
|
-
onChange:
|
|
202
|
-
onBlur:
|
|
203
|
-
name:
|
|
195
|
+
ref: mergeRefs(ref, field_0.ref),
|
|
196
|
+
isSelected: field_0.value,
|
|
197
|
+
onChange: field_0.onChange,
|
|
198
|
+
onBlur: field_0.onBlur,
|
|
199
|
+
name: field_0.name,
|
|
204
200
|
isDirty,
|
|
205
|
-
isDisabled:
|
|
201
|
+
isDisabled: field_0.disabled || props.isDisabled,
|
|
206
202
|
error: props.error ?? error?.message
|
|
207
203
|
});
|
|
208
204
|
};
|
|
@@ -213,14 +209,14 @@ var Toggle = (props) => {
|
|
|
213
209
|
$[8] = t0;
|
|
214
210
|
} else t0 = $[8];
|
|
215
211
|
let t1;
|
|
216
|
-
if ($[9] !==
|
|
217
|
-
t1 = /* @__PURE__ */ jsx(
|
|
218
|
-
control:
|
|
219
|
-
name:
|
|
212
|
+
if ($[9] !== field.form || $[10] !== field.name || $[11] !== t0) {
|
|
213
|
+
t1 = /* @__PURE__ */ jsx(FieldController, {
|
|
214
|
+
control: field.form,
|
|
215
|
+
name: field.name,
|
|
220
216
|
render: t0
|
|
221
217
|
});
|
|
222
|
-
$[9] =
|
|
223
|
-
$[10] =
|
|
218
|
+
$[9] = field.form;
|
|
219
|
+
$[10] = field.name;
|
|
224
220
|
$[11] = t0;
|
|
225
221
|
$[12] = t1;
|
|
226
222
|
} else t1 = $[12];
|
|
@@ -0,0 +1,27 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,57 @@
|
|
|
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,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeepKeys, DeepValue, UIForm } from '../../../hooks/useForm';
|
|
2
2
|
export type ControlKeys<TProps, TValueProp extends keyof TProps = "value" extends keyof TProps ? "value" : never> = TValueProp | "onChange" | "onBlur";
|
|
3
|
-
export interface FormControl<TFieldValues extends
|
|
4
|
-
|
|
3
|
+
export interface FormControl<TFieldValues extends Record<string, unknown>, TType> {
|
|
4
|
+
form: UIForm<TFieldValues>;
|
|
5
5
|
name: {
|
|
6
|
-
[K in
|
|
7
|
-
}[
|
|
6
|
+
[K in DeepKeys<TFieldValues>]: DeepValue<TFieldValues, K> extends TType ? K : never;
|
|
7
|
+
}[DeepKeys<TFieldValues>];
|
|
8
8
|
}
|
|
9
|
-
export type FormControlProps<TProps, TFieldValues extends
|
|
10
|
-
|
|
9
|
+
export type FormControlProps<TProps, TFieldValues extends Record<string, unknown>, TValueProp extends keyof TProps = "value" extends keyof TProps ? "value" : never> = {
|
|
10
|
+
field: FormControl<TFieldValues, TProps[TValueProp] | null>;
|
|
11
11
|
} & Omit<TProps, ControlKeys<TProps, TValueProp>> & Partial<Record<ControlKeys<TProps, TValueProp>, never>>;
|
|
12
|
-
export type ControlProps<TProps, TFieldValues extends
|
|
12
|
+
export type ControlProps<TProps, TFieldValues extends Record<string, unknown>, TValueProp extends keyof TProps = "value" extends keyof TProps ? "value" : never> = FormControlProps<TProps, TFieldValues, TValueProp> | TProps;
|
|
13
|
+
export declare const getFieldError: (errors: unknown[]) => string | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Key } from 'react-aria-components';
|
|
2
|
-
import { FieldValues } from '
|
|
2
|
+
import { FieldValues } from '../inputs/shared/form.binding';
|
|
3
3
|
import { ControlledSegmentProps } from './segment.types';
|
|
4
4
|
export declare const Segment: <TFieldValues extends FieldValues, TKey extends Key = Key>(props: ControlledSegmentProps<TFieldValues, TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UIOverrides } from "../../config/uiOverrides.context.js";
|
|
2
|
+
import { FieldController } from "../inputs/shared/form.binding.js";
|
|
2
3
|
import { FormField } from "../inputs/FormField/FormField.js";
|
|
3
4
|
import { segmentDefinition } from "./segment.cva.js";
|
|
4
5
|
import { SegmentItem } from "./SegmentItem.js";
|
|
@@ -9,7 +10,6 @@ import { Fragment as Fragment$1, useRef } from "react";
|
|
|
9
10
|
import { ToggleButtonGroup } from "react-aria-components";
|
|
10
11
|
import { useToggleButtonGroup } from "react-aria";
|
|
11
12
|
import { mergeRefs } from "@react-aria/utils";
|
|
12
|
-
import { Controller } from "react-hook-form";
|
|
13
13
|
import { useToggleGroupState } from "react-stately";
|
|
14
14
|
//#region src/components/segment/Segment.tsx
|
|
15
15
|
var SegmentBase = (t0) => {
|
|
@@ -181,32 +181,32 @@ var SegmentBase = (t0) => {
|
|
|
181
181
|
};
|
|
182
182
|
var Segment = (props) => {
|
|
183
183
|
const $ = c(15);
|
|
184
|
-
if ("
|
|
185
|
-
let
|
|
184
|
+
if ("field" in props && props.field) {
|
|
185
|
+
let field;
|
|
186
186
|
let innerProps;
|
|
187
187
|
let ref;
|
|
188
188
|
if ($[0] !== props) {
|
|
189
|
-
({
|
|
189
|
+
({field, ref, ...innerProps} = props);
|
|
190
190
|
$[0] = props;
|
|
191
|
-
$[1] =
|
|
191
|
+
$[1] = field;
|
|
192
192
|
$[2] = innerProps;
|
|
193
193
|
$[3] = ref;
|
|
194
194
|
} else {
|
|
195
|
-
|
|
195
|
+
field = $[1];
|
|
196
196
|
innerProps = $[2];
|
|
197
197
|
ref = $[3];
|
|
198
198
|
}
|
|
199
199
|
let t0;
|
|
200
200
|
if ($[4] !== innerProps || $[5] !== props.error || $[6] !== props.isDisabled || $[7] !== ref) {
|
|
201
201
|
t0 = (t1) => {
|
|
202
|
-
const { field, fieldState: t2 } = t1;
|
|
202
|
+
const { field: field_0, fieldState: t2 } = t1;
|
|
203
203
|
const { error } = t2;
|
|
204
204
|
return /* @__PURE__ */ jsx(SegmentBase, {
|
|
205
205
|
...innerProps,
|
|
206
|
-
ref: mergeRefs(ref,
|
|
207
|
-
value:
|
|
208
|
-
onChange:
|
|
209
|
-
isDisabled:
|
|
206
|
+
ref: mergeRefs(ref, field_0.ref),
|
|
207
|
+
value: field_0.value,
|
|
208
|
+
onChange: field_0.onChange,
|
|
209
|
+
isDisabled: field_0.disabled || props.isDisabled,
|
|
210
210
|
error: props.error ?? error?.message
|
|
211
211
|
});
|
|
212
212
|
};
|
|
@@ -217,14 +217,14 @@ var Segment = (props) => {
|
|
|
217
217
|
$[8] = t0;
|
|
218
218
|
} else t0 = $[8];
|
|
219
219
|
let t1;
|
|
220
|
-
if ($[9] !==
|
|
221
|
-
t1 = /* @__PURE__ */ jsx(
|
|
222
|
-
control:
|
|
223
|
-
name:
|
|
220
|
+
if ($[9] !== field.form || $[10] !== field.name || $[11] !== t0) {
|
|
221
|
+
t1 = /* @__PURE__ */ jsx(FieldController, {
|
|
222
|
+
control: field.form,
|
|
223
|
+
name: field.name,
|
|
224
224
|
render: t0
|
|
225
225
|
});
|
|
226
|
-
$[9] =
|
|
227
|
-
$[10] =
|
|
226
|
+
$[9] = field.form;
|
|
227
|
+
$[10] = field.name;
|
|
228
228
|
$[11] = t0;
|
|
229
229
|
$[12] = t1;
|
|
230
230
|
} else t1 = $[12];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC, ReactElement, Ref, SVGProps } from 'react';
|
|
2
2
|
import { Key, ToggleButtonGroupProps, ToggleButtonProps } from 'react-aria-components';
|
|
3
|
-
import { FieldValues } from '
|
|
3
|
+
import { FieldValues } from '../inputs/shared/form.binding';
|
|
4
4
|
import { ControlProps } from '../inputs/shared/form.types';
|
|
5
5
|
import { SegmentItemVariantProps, SegmentVariantProps } from './segment.cva';
|
|
6
6
|
export interface SegmentItem<TKey extends Key = Key> extends ToggleButtonProps, SegmentItemVariantProps {
|
|
@@ -26,9 +26,9 @@ export declare namespace UIConfig {
|
|
|
26
26
|
};
|
|
27
27
|
button: Pick<ButtonProps, "variant" | "size">;
|
|
28
28
|
numberInput: Pick<NumberInputProps, "formatOptions">;
|
|
29
|
-
radioGroup: Pick<RadioGroupProps, "variant" | "hideLabel"
|
|
30
|
-
checkbox: Pick<CheckboxProps, "variant"
|
|
31
|
-
select: Pick<SelectBaseProps, "selectionMode" | "isSearchable" | "collapseAfter" | "selectedTagsType" | "hideSearchIcon" | "
|
|
29
|
+
radioGroup: Pick<RadioGroupProps, "variant" | "hideLabel">;
|
|
30
|
+
checkbox: Pick<CheckboxProps, "variant">;
|
|
31
|
+
select: Pick<SelectBaseProps, "selectionMode" | "isSearchable" | "collapseAfter" | "selectedTagsType" | "hideSearchIcon" | "multiSelectAutoConfirm">;
|
|
32
32
|
queryAutocomplete: {
|
|
33
33
|
isInitialQueryDisabled?: boolean;
|
|
34
34
|
resolveSelectedItemsWithIds?: boolean;
|
|
@@ -39,9 +39,9 @@ export declare namespace UIConfig {
|
|
|
39
39
|
resolveSelectedItemsWithIds?: boolean;
|
|
40
40
|
searchDebounceDelay?: number;
|
|
41
41
|
};
|
|
42
|
-
toggle: Pick<ToggleProps, "variant"
|
|
42
|
+
toggle: Pick<ToggleProps, "variant">;
|
|
43
43
|
slider: Pick<SliderProps, "minValue" | "maxValue">;
|
|
44
|
-
dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "todayIconPlacement" | "shouldForceLeadingZeros" | "disableManualEntry" | "shouldUpdateDateOnMonthYearChange" | "granularity" | "autoFixYear"
|
|
44
|
+
dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "todayIconPlacement" | "shouldForceLeadingZeros" | "disableManualEntry" | "shouldUpdateDateOnMonthYearChange" | "granularity" | "autoFixYear"> & {
|
|
45
45
|
calendarIcon?: ReactElement;
|
|
46
46
|
dateTimeIcon?: ReactElement;
|
|
47
47
|
timeIcon?: ReactElement;
|
|
@@ -28,20 +28,15 @@ var UIConfig;
|
|
|
28
28
|
} },
|
|
29
29
|
radioGroup: {
|
|
30
30
|
variant: "default",
|
|
31
|
-
hideLabel: false
|
|
32
|
-
fireBlurOnChange: false
|
|
33
|
-
},
|
|
34
|
-
checkbox: {
|
|
35
|
-
variant: "default",
|
|
36
|
-
fireBlurOnChange: false
|
|
31
|
+
hideLabel: false
|
|
37
32
|
},
|
|
33
|
+
checkbox: { variant: "default" },
|
|
38
34
|
select: {
|
|
39
35
|
selectionMode: "single",
|
|
40
36
|
isSearchable: false,
|
|
41
37
|
selectedTagsType: "list",
|
|
42
38
|
collapseAfter: 3,
|
|
43
39
|
hideSearchIcon: false,
|
|
44
|
-
fireBlurOnChange: false,
|
|
45
40
|
multiSelectAutoConfirm: false
|
|
46
41
|
},
|
|
47
42
|
queryAutocomplete: {
|
|
@@ -54,10 +49,7 @@ var UIConfig;
|
|
|
54
49
|
resolveSelectedItemsWithIds: false,
|
|
55
50
|
searchDebounceDelay: 500
|
|
56
51
|
},
|
|
57
|
-
toggle: {
|
|
58
|
-
variant: "default",
|
|
59
|
-
fireBlurOnChange: false
|
|
60
|
-
},
|
|
52
|
+
toggle: { variant: "default" },
|
|
61
53
|
slider: {
|
|
62
54
|
minValue: 0,
|
|
63
55
|
maxValue: 100
|
|
@@ -70,7 +62,6 @@ var UIConfig;
|
|
|
70
62
|
shouldForceLeadingZeros: false,
|
|
71
63
|
disableManualEntry: false,
|
|
72
64
|
autoFixYear: false,
|
|
73
|
-
fireBlurOnChange: false,
|
|
74
65
|
calendarIcon: /* @__PURE__ */ jsx(CalendarIcon, { className: "size-5" }),
|
|
75
66
|
dateTimeIcon: /* @__PURE__ */ jsx(DateTimeIcon, { className: "size-5" }),
|
|
76
67
|
timeIcon: /* @__PURE__ */ jsx(ClockIcon, { className: "size-6 text-interactive-text-secondary-idle" }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CellContext, ColumnDef, ColumnMeta } from '@tanstack/react-table';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { FieldPath } from '
|
|
3
|
+
import { FieldPath } from '../components/inputs/shared/form.binding';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
type NestedTypeFromKey<T, K extends string> = K extends keyof T ? T[K] : K extends `${infer First}.${infer Rest}` ? First extends keyof T ? NestedTypeFromKey<T[First], Rest> : never : never;
|
|
6
6
|
type SchemaType<TSchema extends z.ZodObject<any>> = z.infer<TSchema>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FormInstance } from '../components/inputs/shared/form.binding';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { InputComponentProps, InputComponentType, InputDef, InputDefBaseProps, InputWrapperType } from '../components/inputs/Inputs/InputItem';
|
|
5
5
|
import { ZodUtils } from '../utils/zod.utils';
|
|
@@ -47,17 +47,17 @@ type UnknownInputDef<TSchema extends z.ZodObject<any>, K extends keyof z.infer<T
|
|
|
47
47
|
} & DynamicInputDefBase<InputDefBaseProps<InputComponentProps<T>>>;
|
|
48
48
|
}[DefaultComponentType<TSchema["shape"][K]>];
|
|
49
49
|
type RenderInputDef<TSchema extends z.ZodObject<any>, K extends keyof z.infer<TSchema>> = {
|
|
50
|
-
render: (
|
|
51
|
-
|
|
50
|
+
render: (field: {
|
|
51
|
+
form: FormInstance<z.infer<TSchema>>;
|
|
52
52
|
name: K;
|
|
53
|
-
}, form:
|
|
53
|
+
}, form: FormInstance<z.infer<TSchema>>) => ReactElement;
|
|
54
54
|
} & DynamicInputDefBase<Record<string, never>>;
|
|
55
55
|
type DynamicInputDef<TSchema extends z.ZodObject<any>, K extends keyof z.infer<TSchema>> = ConfigInputDef<TSchema, K> | UnknownInputDef<TSchema, K> | RenderInputDef<TSchema, K>;
|
|
56
56
|
type InputsConfig<TSchema extends z.ZodObject<any>> = {
|
|
57
|
-
[K in keyof z.infer<TSchema>]?: DynamicInputDef<TSchema, K> | ((
|
|
58
|
-
|
|
57
|
+
[K in keyof z.infer<TSchema>]?: DynamicInputDef<TSchema, K> | ((field: {
|
|
58
|
+
form: FormInstance<z.infer<TSchema>>;
|
|
59
59
|
name: K;
|
|
60
|
-
}, form:
|
|
60
|
+
}, form: FormInstance<z.infer<TSchema>>) => ReactElement) | boolean;
|
|
61
61
|
};
|
|
62
62
|
type GlobalProps = {
|
|
63
63
|
[T in Exclude<InputComponentType, "unknown">]: InputDefBaseProps<InputComponentProps<T>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface UseAutosaveProps<TFieldValues extends
|
|
3
|
-
form:
|
|
1
|
+
import { UIForm } from './useForm';
|
|
2
|
+
export interface UseAutosaveProps<TFieldValues extends Record<string, unknown>, TTransformedValues = TFieldValues, TResponse = unknown> {
|
|
3
|
+
form: UIForm<TFieldValues>;
|
|
4
4
|
delay?: number;
|
|
5
5
|
enabled?: boolean;
|
|
6
6
|
trigger?: "change" | "blur";
|
|
7
7
|
onSave: (data: Partial<TTransformedValues>) => Promise<TResponse>;
|
|
8
8
|
onSaveSuccess?: () => void;
|
|
9
9
|
}
|
|
10
|
-
export declare function useAutosave<TFieldValues extends
|
|
10
|
+
export declare function useAutosave<TFieldValues extends Record<string, unknown>, TTransformedValues = TFieldValues, TResponse = unknown>({ form, delay, enabled, trigger, onSave, onSaveSuccess, }: UseAutosaveProps<TFieldValues, TTransformedValues, TResponse>): void;
|