@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
|
@@ -1,6 +1,5 @@
|
|
|
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";
|
|
4
3
|
import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
|
|
5
4
|
import { FormField } from "../../FormField/FormField.js";
|
|
6
5
|
import { inputSideDefinition, inputSizeDefinition, useInputCva } from "../../shared/input.cva.js";
|
|
@@ -14,6 +13,7 @@ import { useRef } from "react";
|
|
|
14
13
|
import { TextArea } from "react-aria-components";
|
|
15
14
|
import { useTextField } from "react-aria";
|
|
16
15
|
import { mergeRefs } from "@react-aria/utils";
|
|
16
|
+
import { Controller } from "react-hook-form";
|
|
17
17
|
//#region src/components/inputs/Input/TextArea/TextArea.tsx
|
|
18
18
|
var TextAreaBase = (props) => {
|
|
19
19
|
const $ = c(83);
|
|
@@ -282,34 +282,34 @@ var TextAreaBase = (props) => {
|
|
|
282
282
|
};
|
|
283
283
|
var TextArea$1 = (props) => {
|
|
284
284
|
const $ = c(15);
|
|
285
|
-
if ("
|
|
286
|
-
let
|
|
285
|
+
if ("formControl" in props && props.formControl) {
|
|
286
|
+
let formControl;
|
|
287
287
|
let innerProps;
|
|
288
288
|
let ref;
|
|
289
289
|
if ($[0] !== props) {
|
|
290
|
-
({
|
|
290
|
+
({formControl, ref, ...innerProps} = props);
|
|
291
291
|
$[0] = props;
|
|
292
|
-
$[1] =
|
|
292
|
+
$[1] = formControl;
|
|
293
293
|
$[2] = innerProps;
|
|
294
294
|
$[3] = ref;
|
|
295
295
|
} else {
|
|
296
|
-
|
|
296
|
+
formControl = $[1];
|
|
297
297
|
innerProps = $[2];
|
|
298
298
|
ref = $[3];
|
|
299
299
|
}
|
|
300
300
|
let t0;
|
|
301
301
|
if ($[4] !== innerProps || $[5] !== props.error || $[6] !== props.isDisabled || $[7] !== ref) {
|
|
302
302
|
t0 = (t1) => {
|
|
303
|
-
const { field
|
|
303
|
+
const { field, fieldState: t2 } = t1;
|
|
304
304
|
const { error, isDirty } = t2;
|
|
305
305
|
return /* @__PURE__ */ jsx(TextAreaBase, {
|
|
306
306
|
...innerProps,
|
|
307
|
-
ref: mergeRefs(ref,
|
|
308
|
-
value:
|
|
309
|
-
onChange:
|
|
310
|
-
onBlur:
|
|
307
|
+
ref: mergeRefs(ref, field.ref),
|
|
308
|
+
value: field.value ?? "",
|
|
309
|
+
onChange: field.onChange,
|
|
310
|
+
onBlur: field.onBlur,
|
|
311
311
|
isDirty,
|
|
312
|
-
isDisabled:
|
|
312
|
+
isDisabled: field.disabled || props.isDisabled,
|
|
313
313
|
error: props.error ?? error?.message
|
|
314
314
|
});
|
|
315
315
|
};
|
|
@@ -320,14 +320,14 @@ var TextArea$1 = (props) => {
|
|
|
320
320
|
$[8] = t0;
|
|
321
321
|
} else t0 = $[8];
|
|
322
322
|
let t1;
|
|
323
|
-
if ($[9] !==
|
|
324
|
-
t1 = /* @__PURE__ */ jsx(
|
|
325
|
-
control:
|
|
326
|
-
name:
|
|
323
|
+
if ($[9] !== formControl.control || $[10] !== formControl.name || $[11] !== t0) {
|
|
324
|
+
t1 = /* @__PURE__ */ jsx(Controller, {
|
|
325
|
+
control: formControl.control,
|
|
326
|
+
name: formControl.name,
|
|
327
327
|
render: t0
|
|
328
328
|
});
|
|
329
|
-
$[9] =
|
|
330
|
-
$[10] =
|
|
329
|
+
$[9] = formControl.control;
|
|
330
|
+
$[10] = formControl.name;
|
|
331
331
|
$[11] = t0;
|
|
332
332
|
$[12] = t1;
|
|
333
333
|
} else t1 = $[12];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { AriaTextFieldProps } from 'react-aria';
|
|
3
3
|
import { InputProps as AriaInputProps } from 'react-aria-components';
|
|
4
|
+
import { FieldValues } from 'react-hook-form';
|
|
4
5
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
5
6
|
import { InputContentProps } from '../shared/InputContent';
|
|
6
|
-
import { FieldValues } from '../../shared/form.binding';
|
|
7
7
|
import { ControlProps } from '../../shared/form.types';
|
|
8
8
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
9
9
|
type AllowedHTMLInputTypeAttribute = "email" | "hidden" | "tel" | "text" | "url";
|
|
@@ -18,6 +18,6 @@ interface TextInputBaseProps extends FormFieldProps, InputVariantProps, Omit<Inp
|
|
|
18
18
|
export interface TextInputProps extends TextInputBaseProps {
|
|
19
19
|
renderStaticInput?: boolean;
|
|
20
20
|
}
|
|
21
|
-
export type ControlledTextInputProps<TFieldValues extends
|
|
21
|
+
export type ControlledTextInputProps<TFieldValues extends FieldValues> = ControlProps<TextInputProps, TFieldValues>;
|
|
22
22
|
export declare const TextInput: <TFieldValues extends FieldValues>({ renderStaticInput, ...props }: ControlledTextInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
23
23
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
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";
|
|
4
3
|
import { FormField } from "../../FormField/FormField.js";
|
|
5
4
|
import { inputBaseDefinition } from "../../shared/input.cva.js";
|
|
6
5
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
@@ -14,6 +13,7 @@ import { useEffect, useRef, useState } from "react";
|
|
|
14
13
|
import { Input } from "react-aria-components";
|
|
15
14
|
import { useFocusVisible, useTextField } from "react-aria";
|
|
16
15
|
import { mergeRefs } from "@react-aria/utils";
|
|
16
|
+
import { Controller } from "react-hook-form";
|
|
17
17
|
//#region src/components/inputs/Input/TextInput/TextInput.tsx
|
|
18
18
|
var TextInputBase = (props) => {
|
|
19
19
|
const $ = c(84);
|
|
@@ -377,7 +377,7 @@ var TextInputInner = (t0) => {
|
|
|
377
377
|
return t3;
|
|
378
378
|
};
|
|
379
379
|
var TextInput = (t0) => {
|
|
380
|
-
const $ = c(
|
|
380
|
+
const $ = c(21);
|
|
381
381
|
let props;
|
|
382
382
|
let renderStaticInput;
|
|
383
383
|
if ($[0] !== t0) {
|
|
@@ -389,70 +389,72 @@ var TextInput = (t0) => {
|
|
|
389
389
|
props = $[1];
|
|
390
390
|
renderStaticInput = $[2];
|
|
391
391
|
}
|
|
392
|
-
if ("
|
|
393
|
-
let
|
|
392
|
+
if ("formControl" in props && props.formControl) {
|
|
393
|
+
let formControl;
|
|
394
394
|
let innerProps;
|
|
395
395
|
let ref;
|
|
396
396
|
if ($[3] !== props) {
|
|
397
|
-
({
|
|
397
|
+
({formControl, ref, ...innerProps} = props);
|
|
398
398
|
$[3] = props;
|
|
399
|
-
$[4] =
|
|
399
|
+
$[4] = formControl;
|
|
400
400
|
$[5] = innerProps;
|
|
401
401
|
$[6] = ref;
|
|
402
402
|
} else {
|
|
403
|
-
|
|
403
|
+
formControl = $[4];
|
|
404
404
|
innerProps = $[5];
|
|
405
405
|
ref = $[6];
|
|
406
406
|
}
|
|
407
|
+
const controlWithOptions = formControl.control;
|
|
407
408
|
let t1;
|
|
408
|
-
if ($[7] !==
|
|
409
|
+
if ($[7] !== controlWithOptions._options?.disabled || $[8] !== innerProps || $[9] !== props.error || $[10] !== props.isDisabled || $[11] !== ref || $[12] !== renderStaticInput) {
|
|
409
410
|
t1 = (t2) => {
|
|
410
|
-
const { field
|
|
411
|
+
const { field, fieldState: t3 } = t2;
|
|
411
412
|
const { error, isDirty } = t3;
|
|
412
413
|
return /* @__PURE__ */ jsx(TextInputInner, {
|
|
413
414
|
...innerProps,
|
|
414
|
-
ref: mergeRefs(ref,
|
|
415
|
-
value:
|
|
416
|
-
onChange:
|
|
417
|
-
onBlur:
|
|
415
|
+
ref: mergeRefs(ref, field.ref),
|
|
416
|
+
value: field.value,
|
|
417
|
+
onChange: field.onChange,
|
|
418
|
+
onBlur: field.onBlur,
|
|
418
419
|
isDirty,
|
|
419
|
-
isDisabled:
|
|
420
|
-
isFormControlDisabled:
|
|
420
|
+
isDisabled: field.disabled || props.isDisabled,
|
|
421
|
+
isFormControlDisabled: !!controlWithOptions._options?.disabled,
|
|
421
422
|
error: props.error ?? error?.message,
|
|
422
423
|
renderStaticInput
|
|
423
424
|
});
|
|
424
425
|
};
|
|
425
|
-
$[7] =
|
|
426
|
-
$[8] =
|
|
427
|
-
$[9] = props.
|
|
428
|
-
$[10] =
|
|
429
|
-
$[11] =
|
|
430
|
-
$[12] =
|
|
431
|
-
|
|
426
|
+
$[7] = controlWithOptions._options?.disabled;
|
|
427
|
+
$[8] = innerProps;
|
|
428
|
+
$[9] = props.error;
|
|
429
|
+
$[10] = props.isDisabled;
|
|
430
|
+
$[11] = ref;
|
|
431
|
+
$[12] = renderStaticInput;
|
|
432
|
+
$[13] = t1;
|
|
433
|
+
} else t1 = $[13];
|
|
432
434
|
let t2;
|
|
433
|
-
if ($[
|
|
434
|
-
t2 = /* @__PURE__ */ jsx(
|
|
435
|
-
control:
|
|
436
|
-
name:
|
|
435
|
+
if ($[14] !== formControl.control || $[15] !== formControl.name || $[16] !== t1) {
|
|
436
|
+
t2 = /* @__PURE__ */ jsx(Controller, {
|
|
437
|
+
control: formControl.control,
|
|
438
|
+
name: formControl.name,
|
|
437
439
|
render: t1
|
|
438
440
|
});
|
|
439
|
-
$[
|
|
440
|
-
$[
|
|
441
|
-
$[
|
|
442
|
-
$[
|
|
443
|
-
} else t2 = $[
|
|
441
|
+
$[14] = formControl.control;
|
|
442
|
+
$[15] = formControl.name;
|
|
443
|
+
$[16] = t1;
|
|
444
|
+
$[17] = t2;
|
|
445
|
+
} else t2 = $[17];
|
|
444
446
|
return t2;
|
|
445
447
|
}
|
|
446
448
|
let t1;
|
|
447
|
-
if ($[
|
|
449
|
+
if ($[18] !== props || $[19] !== renderStaticInput) {
|
|
448
450
|
t1 = /* @__PURE__ */ jsx(TextInputInner, {
|
|
449
451
|
...props,
|
|
450
452
|
renderStaticInput
|
|
451
453
|
});
|
|
452
|
-
$[
|
|
453
|
-
$[
|
|
454
|
-
$[
|
|
455
|
-
} else t1 = $[
|
|
454
|
+
$[18] = props;
|
|
455
|
+
$[19] = renderStaticInput;
|
|
456
|
+
$[20] = t1;
|
|
457
|
+
} else t1 = $[20];
|
|
456
458
|
return t1;
|
|
457
459
|
};
|
|
458
460
|
function _temp(input) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { SubmitErrorHandler, SubmitHandler, UseFormReturn } from 'react-hook-form';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { InputComponentProps, InputDefBaseProps } from './InputItem';
|
|
4
5
|
import { AllowedComponentType, DefaultComponentType } from '../../../helpers/dynamicInputs';
|
|
5
|
-
import { FormSubmitErrorHandler, FormSubmitHandler, UIForm } from '../../../hooks/useForm';
|
|
6
6
|
type Capitalize<T extends string> = T extends `${infer First}${infer Rest}` ? `${Uppercase<First>}${Rest}` : T;
|
|
7
7
|
type FieldProps<TProps = {}> = {
|
|
8
8
|
label: string;
|
|
@@ -15,10 +15,10 @@ type FieldComponents<TSchema extends z.ZodObject<any>> = {
|
|
|
15
15
|
[K in keyof Required<z.infer<TSchema>> as Capitalize<K & string>]: <T extends AllowedComponentType<TSchema["shape"][K]> | undefined = undefined>(props: FieldComponentProps<TSchema, K, T>) => ReactNode;
|
|
16
16
|
};
|
|
17
17
|
interface FormProps<TSchema extends z.ZodObject<any>, TSchemaType extends Record<string, any> = z.infer<TSchema>> {
|
|
18
|
-
form:
|
|
18
|
+
form: UseFormReturn<TSchemaType>;
|
|
19
19
|
schema: TSchema;
|
|
20
|
-
onSubmit:
|
|
21
|
-
onError?:
|
|
20
|
+
onSubmit: SubmitHandler<TSchemaType>;
|
|
21
|
+
onError?: SubmitErrorHandler<TSchemaType>;
|
|
22
22
|
className?: string;
|
|
23
23
|
children: (components: FieldComponents<TSchema>) => ReactNode;
|
|
24
24
|
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
import { ComponentProps, JSXElementConstructor, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { Control, UseFormReturn } from 'react-hook-form';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { Autocomplete } from '../Selection/Autocomplete/Autocomplete';
|
|
4
5
|
import { Select } from '../Selection/Select/Select';
|
|
5
6
|
import { HasRequiredProperty } from '../../../types/common';
|
|
6
|
-
import { UIForm } from '../../../hooks/useForm';
|
|
7
7
|
declare const componentRegistry: {
|
|
8
|
-
readonly toggle: <TFieldValues extends import('
|
|
9
|
-
readonly checkbox: <TFieldValues extends import('
|
|
10
|
-
readonly checkboxGroup: <TFieldValues extends import('
|
|
11
|
-
readonly numberInput: <TFieldValues extends import('
|
|
12
|
-
readonly numberRangeInput: <TFieldValues extends import('
|
|
13
|
-
readonly slider: <TFieldValues extends import('
|
|
14
|
-
readonly textInput: <TFieldValues extends import('
|
|
15
|
-
readonly passwordInput: <TFieldValues extends import('
|
|
16
|
-
readonly textArea: <TFieldValues extends import('
|
|
8
|
+
readonly toggle: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Toggle/Toggle').ControlledToggleProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
readonly checkbox: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Checkbox/Checkbox').ControlledCheckboxProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
readonly checkboxGroup: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Checkbox/CheckboxGroup').ControlledCheckboxGroupProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
readonly numberInput: <TFieldValues extends import('react-hook-form').FieldValues>({ renderStaticInput, ...props }: import('../Input/NumberInput/NumberInput').ControlledNumberInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
readonly numberRangeInput: <TFieldValues extends import('react-hook-form').FieldValues>({ renderStaticInput, ...props }: import('../Input/NumberRangeInput/NumberRangeInput').ControlledNumberRangeInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
readonly slider: <TFieldValues extends import('react-hook-form').FieldValues, IsRange extends boolean = false>(props: import('../Slider/Slider').ControlledSliderProps<TFieldValues, IsRange>) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
readonly textInput: <TFieldValues extends import('react-hook-form').FieldValues>({ renderStaticInput, ...props }: import('../Input/TextInput/TextInput').ControlledTextInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
readonly passwordInput: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/PasswordInput/PasswordInput').ControlledPasswordInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
readonly textArea: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/TextArea/TextArea').ControlledTextAreaProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
readonly select: typeof Select;
|
|
18
|
-
readonly querySelect: <TFieldValues extends import('
|
|
18
|
+
readonly querySelect: <TFieldValues extends import('react-hook-form').FieldValues, TQueryFn extends import('../Selection/shared/querySelect.utils').QueryFn, TKey extends import('react-aria').Key = import('react-aria').Key, TInitialSelectItem = import('../../..').DefaultInitialSelectItem<TKey>>(props: import('../Selection/Select/QuerySelect').QuerySelectProps<TFieldValues, TQueryFn, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
|
|
19
19
|
readonly autocomplete: typeof Autocomplete;
|
|
20
|
-
readonly queryAutocomplete: <TFieldValues extends import('
|
|
21
|
-
readonly segment: <TFieldValues extends import('
|
|
22
|
-
readonly datePicker: <TFieldValues extends import('
|
|
23
|
-
readonly dateTimePicker: <TFieldValues extends import('
|
|
24
|
-
readonly timePicker: <TFieldValues extends import('
|
|
25
|
-
readonly dateRangePicker: <TFieldValues extends import('
|
|
20
|
+
readonly queryAutocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TSelectItem extends import('../../..').SelectItem<any>, TQueryFn extends import('../Selection/Autocomplete/queryAutocomplete.types').QueryFn>(props: import('../Selection/Autocomplete/queryAutocomplete.types').QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
readonly segment: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key>(props: import('../../..').ControlledSegmentProps<TFieldValues, TKey>) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
readonly datePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, granularity, minValue, maxValue, renderStaticInput, ...props }: import('../DateTime/DatePicker/DatePicker').ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
readonly dateTimePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, renderStaticInput, ...props }: import('../DateTime/DateTimePicker/DateTimePicker').ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
readonly timePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ renderStaticInput, ...props }: import('../DateTime/TimePicker/TimePicker').ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
readonly dateRangePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, renderStaticInput, ...props }: import('../DateTime/DateRangePicker/DateRangePicker').ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
26
26
|
readonly unknown: null;
|
|
27
27
|
};
|
|
28
28
|
export type InputComponentRegistry = typeof componentRegistry;
|
|
29
29
|
export type InputComponentType = keyof InputComponentRegistry;
|
|
30
30
|
interface InputItemProps<TSchema extends z.ZodObject<any>, TSchemaType extends Record<string, any> = z.infer<TSchema>> {
|
|
31
|
-
form:
|
|
31
|
+
form: UseFormReturn<TSchemaType>;
|
|
32
32
|
inputDef: InputDef<TSchemaType>;
|
|
33
33
|
}
|
|
34
34
|
export type InputDef<TSchemaType extends Record<string, any>> = {
|
|
@@ -55,13 +55,13 @@ interface RenderBasedInputDef<TSchemaType extends Record<string, any>, K extends
|
|
|
55
55
|
placeholder?: string;
|
|
56
56
|
props?: never;
|
|
57
57
|
inputWrapper?: never;
|
|
58
|
-
render: (
|
|
59
|
-
|
|
58
|
+
render: (formControl: {
|
|
59
|
+
control: Control<TSchemaType>;
|
|
60
60
|
name: K;
|
|
61
|
-
}, form:
|
|
61
|
+
}, form: UseFormReturn<TSchemaType>) => ReactElement;
|
|
62
62
|
}
|
|
63
63
|
export type InputWrapperType = (children: ReactNode, label: string) => ReactElement;
|
|
64
64
|
export type InputComponentProps<T extends InputComponentType> = InputComponentRegistry[T] extends keyof React.JSX.IntrinsicElements | JSXElementConstructor<any> ? ComponentProps<InputComponentRegistry[T]> : null;
|
|
65
|
-
export type InputDefBaseProps<TProps> = Omit<TProps, "
|
|
65
|
+
export type InputDefBaseProps<TProps> = Omit<TProps, "formControl" | "label" | "placeholder" | "children">;
|
|
66
66
|
export declare function InputItem<TSchema extends z.ZodObject<any>, TSchemaType extends Record<string, any> = z.infer<TSchema>>({ form, inputDef }: InputItemProps<TSchema, TSchemaType>): import("react/jsx-runtime").JSX.Element | null;
|
|
67
67
|
export {};
|
|
@@ -44,69 +44,70 @@ function InputItem(t0) {
|
|
|
44
44
|
const $ = c(18);
|
|
45
45
|
const { form, inputDef } = t0;
|
|
46
46
|
const { name, label, placeholder, props, inputWrapper, render, type } = inputDef;
|
|
47
|
-
|
|
48
|
-
let
|
|
47
|
+
const t1 = form.control;
|
|
48
|
+
let formControl;
|
|
49
|
+
let t2;
|
|
49
50
|
if ($[0] !== form || $[1] !== name || $[2] !== render) {
|
|
50
|
-
|
|
51
|
+
t2 = Symbol.for("react.early_return_sentinel");
|
|
51
52
|
bb0: {
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
formControl = {
|
|
54
|
+
control: t1,
|
|
54
55
|
name
|
|
55
56
|
};
|
|
56
57
|
if (render) {
|
|
57
|
-
|
|
58
|
+
t2 = render(formControl, form);
|
|
58
59
|
break bb0;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
$[0] = form;
|
|
62
63
|
$[1] = name;
|
|
63
64
|
$[2] = render;
|
|
64
|
-
$[3] =
|
|
65
|
-
$[4] =
|
|
65
|
+
$[3] = formControl;
|
|
66
|
+
$[4] = t2;
|
|
66
67
|
} else {
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
formControl = $[3];
|
|
69
|
+
t2 = $[4];
|
|
69
70
|
}
|
|
70
|
-
if (
|
|
71
|
+
if (t2 !== Symbol.for("react.early_return_sentinel")) return t2;
|
|
71
72
|
if (!type) return null;
|
|
72
73
|
const Component = componentRegistry[type];
|
|
73
74
|
const usesChildrenAsLabel = ["toggle", "checkbox"].includes(type);
|
|
74
|
-
let
|
|
75
|
+
let t3;
|
|
75
76
|
if ($[5] !== props) {
|
|
76
|
-
|
|
77
|
+
t3 = props ?? {};
|
|
77
78
|
$[5] = props;
|
|
78
|
-
$[6] =
|
|
79
|
-
} else
|
|
80
|
-
const inputProps =
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
let
|
|
84
|
-
if ($[7] !== Component || $[8] !==
|
|
85
|
-
|
|
79
|
+
$[6] = t3;
|
|
80
|
+
} else t3 = $[6];
|
|
81
|
+
const inputProps = t3;
|
|
82
|
+
const t4 = usesChildrenAsLabel ? void 0 : label;
|
|
83
|
+
const t5 = usesChildrenAsLabel ? label : void 0;
|
|
84
|
+
let t6;
|
|
85
|
+
if ($[7] !== Component || $[8] !== formControl || $[9] !== inputProps || $[10] !== placeholder || $[11] !== t4 || $[12] !== t5) {
|
|
86
|
+
t6 = /* @__PURE__ */ jsx(Component, {
|
|
86
87
|
...inputProps,
|
|
87
|
-
label:
|
|
88
|
+
label: t4,
|
|
88
89
|
placeholder,
|
|
89
|
-
|
|
90
|
-
children:
|
|
90
|
+
formControl,
|
|
91
|
+
children: t5
|
|
91
92
|
});
|
|
92
93
|
$[7] = Component;
|
|
93
|
-
$[8] =
|
|
94
|
+
$[8] = formControl;
|
|
94
95
|
$[9] = inputProps;
|
|
95
96
|
$[10] = placeholder;
|
|
96
|
-
$[11] =
|
|
97
|
-
$[12] =
|
|
98
|
-
$[13] =
|
|
99
|
-
} else
|
|
100
|
-
const inputComponent =
|
|
101
|
-
let
|
|
97
|
+
$[11] = t4;
|
|
98
|
+
$[12] = t5;
|
|
99
|
+
$[13] = t6;
|
|
100
|
+
} else t6 = $[13];
|
|
101
|
+
const inputComponent = t6;
|
|
102
|
+
let t7;
|
|
102
103
|
if ($[14] !== inputComponent || $[15] !== inputWrapper || $[16] !== label) {
|
|
103
|
-
|
|
104
|
+
t7 = inputWrapper ? inputWrapper(inputComponent, label) : inputComponent;
|
|
104
105
|
$[14] = inputComponent;
|
|
105
106
|
$[15] = inputWrapper;
|
|
106
107
|
$[16] = label;
|
|
107
|
-
$[17] =
|
|
108
|
-
} else
|
|
109
|
-
return
|
|
108
|
+
$[17] = t7;
|
|
109
|
+
} else t7 = $[17];
|
|
110
|
+
return t7;
|
|
110
111
|
}
|
|
111
112
|
//#endregion
|
|
112
113
|
export { InputItem };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
2
3
|
import { z } from 'zod';
|
|
3
|
-
import { UIForm } from '../../../hooks/useForm';
|
|
4
4
|
import { InputDef } from './InputItem';
|
|
5
5
|
export interface InputsProps<TSchema extends z.ZodObject<any>, TSchemaType extends Record<string, any> = z.infer<TSchema>> {
|
|
6
|
-
form:
|
|
6
|
+
form: UseFormReturn<TSchemaType>;
|
|
7
7
|
inputDefs: Array<InputDef<TSchemaType>>;
|
|
8
8
|
children?: (inputs: Record<keyof TSchemaType, ReactNode>) => ReactNode;
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement, Ref } from 'react';
|
|
2
2
|
import { RadioGroupProps as AriaRadioGroupProps } from 'react-aria-components';
|
|
3
|
-
import { FieldValues } from '
|
|
3
|
+
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { FormFieldProps } from '../FormField/FormField';
|
|
5
5
|
import { RadioVariantProps } from './radio.cva';
|
|
6
6
|
import { ControlProps } from '../shared/form.types';
|
|
@@ -14,6 +14,7 @@ interface RadioGroupBaseProps extends Omit<FormFieldProps, "variant">, RadioVari
|
|
|
14
14
|
isDirty?: boolean;
|
|
15
15
|
inputClassName?: string;
|
|
16
16
|
labelClassName?: string;
|
|
17
|
+
fireBlurOnChange?: boolean;
|
|
17
18
|
}
|
|
18
19
|
export interface RadioGroupProps extends RadioGroupBaseProps {
|
|
19
20
|
}
|