@pdg/react-form 1.1.4 → 1.1.6
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/@private/PrivateInputDatePicker/PrivateInputDatePicker.types.d.ts +2 -2
- package/dist/@private/PrivateMonthPicker/PrivateMonthPicker.types.d.ts +1 -1
- package/dist/@private/PrivateMonthPicker/PrivateMonthPickerMonth/PrivateMonthPickerMonth.types.d.ts +1 -1
- package/dist/@private/PrivateMonthPicker/PrivateMonthPickerMonthList/PrivateMonthPickerMonthList.types.d.ts +1 -1
- package/dist/@private/PrivateMonthRangePicker/PrivateMonthRangePicker.types.d.ts +1 -1
- package/dist/@private/PrivateMonthSelect/PrivateMonthSelect.types.d.ts +1 -1
- package/dist/@private/PrivateStaticDatePicker/PrivateStaticDatePicker.types.d.ts +2 -2
- package/dist/@private/PrivateStaticDateTimePicker/PrivateStaticDateTimePicker.types.d.ts +3 -3
- package/dist/@private/PrivateTimeSection/PrivateTimeSection.types.d.ts +2 -2
- package/dist/@private/PrivateTimeSelect/PrivateTimeSelect.types.d.ts +2 -2
- package/dist/@private/PrivateYearPicker/PrivateYearPicker.types.d.ts +1 -1
- package/dist/@private/PrivateYearPicker/PrivateYearPickerYearList/PrivateYearPickerYearList.types.d.ts +1 -1
- package/dist/@private/PrivateYearRangePicker/PrivateYearRangePicker.types.d.ts +1 -1
- package/dist/@private/PrivateYearRangePicker/PrivateYearRangePickerYearList/PrivateYearRangePickerYearList.types.d.ts +1 -1
- package/dist/@private/PrivateYearSelect/PrivateYearSelect.types.d.ts +1 -1
- package/dist/@types/types.d.ts +64 -64
- package/dist/PForm/PForm.types.d.ts +23 -23
- package/dist/PFormContext/PFormContext.types.d.ts +9 -9
- package/dist/PFormContext/useFormState.d.ts +1 -1
- package/dist/PFormContextProvider/PFormContextProvider.d.ts +1 -1
- package/dist/PFormContextProvider/PFormContextProvider.types.d.ts +2 -2
- package/dist/PFormItemCustom/PFormCheckbox/PFormCheckbox.types.d.ts +2 -2
- package/dist/PFormItemCustom/PFormDateRangePicker/PFormDateRangePicker.types.d.ts +2 -2
- package/dist/PFormItemCustom/PFormDateRangePicker/PFormDateRangePickerTooltipPickerContainer/PFormDateRangePickerTooltipPicker/PFormDateRangePickerTooltipPicker.types.d.ts +6 -6
- package/dist/PFormItemCustom/PFormDateRangePicker/PFormDateRangePickerTooltipPickerContainer/PFormDateRangePickerTooltipPickerContainer.types.d.ts +7 -7
- package/dist/PFormItemCustom/PFormDateTimePicker/PFormDateTimePicker.types.d.ts +2 -1
- package/dist/PFormItemCustom/PFormFile/PFormFile.types.d.ts +2 -2
- package/dist/PFormItemCustom/PFormRadioGroup/PFormRadioGroup.types.d.ts +2 -2
- package/dist/PFormItemCustom/PFormRating/PFormRating.types.d.ts +1 -1
- package/dist/PFormItemCustom/PFormSwitch/PFormSwitch.types.d.ts +1 -1
- package/dist/PFormItemCustom/PFormTextEditor/PFormTextEditor.types.d.ts +1 -1
- package/dist/PFormItemCustom/PFormTimePicker/PFormTimePicker.types.d.ts +2 -1
- package/dist/PFormItemTextFieldBase/PFormSelect/PFormSelect.d.ts +3 -3
- package/dist/PFormItemTextFieldBase/PFormTag/PFormTagText/PFormTagText.types.d.ts +1 -1
- package/dist/PFormItemTextFieldBase/PFormTextField/PFormTextField.types.d.ts +1 -1
- package/dist/PFormLayout/PFormDivider/PFormDivider.types.d.ts +1 -1
- package/dist/PSearch/PHashSearch/PHashSearch.types.d.ts +1 -1
- package/dist/index.esm.js +36 -6
- package/dist/index.js +36 -6
- package/package.json +2 -2
|
@@ -20,8 +20,8 @@ export interface PrivateInputDatePickerProps extends PCommonSxProps, Pick<Deskto
|
|
|
20
20
|
maxDate?: Dayjs;
|
|
21
21
|
align?: 'left' | 'center' | 'right';
|
|
22
22
|
enableKeyboardInput?: boolean;
|
|
23
|
-
onChange(newValue: PrivateInputDatePickerValue)
|
|
23
|
+
onChange: (newValue: PrivateInputDatePickerValue) => void;
|
|
24
24
|
onFocus: TextFieldProps['onFocus'];
|
|
25
25
|
onBlur?: TextFieldProps['onBlur'];
|
|
26
|
-
onError
|
|
26
|
+
onError?: (reason: DateValidationError, value: PrivateInputDatePickerValue) => void;
|
|
27
27
|
}
|
|
@@ -11,5 +11,5 @@ export interface PrivateMonthPickerProps {
|
|
|
11
11
|
disableFuture?: boolean;
|
|
12
12
|
selectFromValue?: PrivateMonthPickerValue;
|
|
13
13
|
selectToValue?: PrivateMonthPickerValue;
|
|
14
|
-
onChange(value: PrivateMonthPickerBaseValue, isMonthSelect: boolean)
|
|
14
|
+
onChange: (value: PrivateMonthPickerBaseValue, isMonthSelect: boolean) => void;
|
|
15
15
|
}
|
|
@@ -3,5 +3,5 @@ export interface PrivateMonthPickerMonthListProps extends Pick<PrivateMonthPicke
|
|
|
3
3
|
defaultValue?: PrivateMonthPickerValue;
|
|
4
4
|
minAvailableValue: PrivateMonthPickerBaseValue;
|
|
5
5
|
maxAvailableValue: PrivateMonthPickerBaseValue;
|
|
6
|
-
onChange(value: PrivateMonthPickerBaseValue)
|
|
6
|
+
onChange: (value: PrivateMonthPickerBaseValue) => void;
|
|
7
7
|
}
|
|
@@ -11,5 +11,5 @@ export interface PrivateMonthRangePickerProps {
|
|
|
11
11
|
maxValue?: PrivateMonthRangePickerBaseValue;
|
|
12
12
|
disablePast?: boolean;
|
|
13
13
|
disableFuture?: boolean;
|
|
14
|
-
onChange(value: PrivateMonthRangePickerValue, selectType: PrivateMonthRangePickerSelectType, isMonthSelect: boolean)
|
|
14
|
+
onChange: (value: PrivateMonthRangePickerValue, selectType: PrivateMonthRangePickerSelectType, isMonthSelect: boolean) => void;
|
|
15
15
|
}
|
|
@@ -12,8 +12,8 @@ export interface PrivateStaticDatePickerProps extends Omit<StaticDatePickerProps
|
|
|
12
12
|
seconds?: number[];
|
|
13
13
|
minuteInterval?: number;
|
|
14
14
|
secondInterval?: number;
|
|
15
|
-
onChange(unit: PrivateStaticDatePickerUnit, newValue: Dayjs | null)
|
|
16
|
-
onClose
|
|
15
|
+
onChange: (unit: PrivateStaticDatePickerUnit, newValue: Dayjs | null) => void;
|
|
16
|
+
onClose?: () => void;
|
|
17
17
|
}
|
|
18
18
|
export interface PrivateStaticDatePickerCommands {
|
|
19
19
|
}
|
|
@@ -12,10 +12,10 @@ export interface PrivateStaticDateTimePickerProps extends Omit<StaticDateTimePic
|
|
|
12
12
|
seconds?: number[];
|
|
13
13
|
minuteInterval?: number;
|
|
14
14
|
secondInterval?: number;
|
|
15
|
-
onChange(unit: PrivateStaticDateTimePickerUnit, newValue: Dayjs | null)
|
|
16
|
-
onClose
|
|
15
|
+
onChange: (unit: PrivateStaticDateTimePickerUnit, newValue: Dayjs | null) => void;
|
|
16
|
+
onClose?: () => void;
|
|
17
17
|
}
|
|
18
18
|
export type TimeSelectScrollToDateUnit = 'hour' | 'minute' | 'second';
|
|
19
19
|
export interface PrivateStaticDateTimePickerCommands {
|
|
20
|
-
timeSelectScrollToDate(date: Dayjs, times?: TimeSelectScrollToDateUnit[])
|
|
20
|
+
timeSelectScrollToDate: (date: Dayjs, times?: TimeSelectScrollToDateUnit[]) => void;
|
|
21
21
|
}
|
|
@@ -18,6 +18,6 @@ export interface PrivateTimeSectionProps {
|
|
|
18
18
|
minuteInterval?: number;
|
|
19
19
|
secondInterval?: number;
|
|
20
20
|
value?: Dayjs | null;
|
|
21
|
-
onChange(unit: PrivateStaticDateTimePickerUnit, newValue: Dayjs | null)
|
|
22
|
-
onClose
|
|
21
|
+
onChange: (unit: PrivateStaticDateTimePickerUnit, newValue: Dayjs | null) => void;
|
|
22
|
+
onClose?: () => void;
|
|
23
23
|
}
|
|
@@ -5,8 +5,8 @@ export interface PrivateTimeSelectProps {
|
|
|
5
5
|
cols?: 1 | 2 | 3;
|
|
6
6
|
disableList?: number[];
|
|
7
7
|
value?: number | null;
|
|
8
|
-
onSelect
|
|
8
|
+
onSelect?: (value: number) => void;
|
|
9
9
|
}
|
|
10
10
|
export interface PrivateTimeSelectCommands {
|
|
11
|
-
scrollToValue(value: number)
|
|
11
|
+
scrollToValue: (value: number) => void;
|
|
12
12
|
}
|
|
@@ -11,5 +11,5 @@ export interface PrivateYearPickerProps {
|
|
|
11
11
|
hideHeader?: boolean;
|
|
12
12
|
selectFromYear?: PrivateYearPickerValue;
|
|
13
13
|
selectToYear?: PrivateYearPickerValue;
|
|
14
|
-
onChange(value: PrivateYearPickerBaseValue, isClick: boolean)
|
|
14
|
+
onChange: (value: PrivateYearPickerBaseValue, isClick: boolean) => void;
|
|
15
15
|
}
|
|
@@ -2,5 +2,5 @@ import { PrivateYearPickerBaseValue, PrivateYearPickerProps, PrivateYearPickerVa
|
|
|
2
2
|
export interface PrivateYearPickerYearListProps extends Pick<PrivateYearPickerProps, 'value' | 'disablePast' | 'disableFuture'>, Required<Pick<PrivateYearPickerProps, 'minYear' | 'maxYear'>> {
|
|
3
3
|
selectFromYear?: PrivateYearPickerValue;
|
|
4
4
|
selectToYear?: PrivateYearPickerValue;
|
|
5
|
-
onChange(year: PrivateYearPickerBaseValue)
|
|
5
|
+
onChange: (year: PrivateYearPickerBaseValue) => void;
|
|
6
6
|
}
|
|
@@ -10,5 +10,5 @@ export interface PrivateYearRangePickerProps {
|
|
|
10
10
|
disablePast?: boolean;
|
|
11
11
|
disableFuture?: boolean;
|
|
12
12
|
hideHeader?: boolean;
|
|
13
|
-
onChange(value: PrivateYearRangePickerValue, selectType: PrivateYearRangePickerSelectType)
|
|
13
|
+
onChange: (value: PrivateYearRangePickerValue, selectType: PrivateYearRangePickerSelectType) => void;
|
|
14
14
|
}
|
|
@@ -2,5 +2,5 @@ import { PrivateYearRangePickerBaseValue, PrivateYearRangePickerProps, PrivateYe
|
|
|
2
2
|
export interface PrivateYearRangePickerYearListProps extends Pick<PrivateYearRangePickerProps, 'value' | 'disablePast' | 'disableFuture'>, Required<Pick<PrivateYearRangePickerProps, 'minYear' | 'maxYear'>> {
|
|
3
3
|
selectType: PrivateYearRangePickerSelectType;
|
|
4
4
|
displayValue: PrivateYearRangePickerBaseValue[];
|
|
5
|
-
onChange(year: number)
|
|
5
|
+
onChange: (year: number) => void;
|
|
6
6
|
}
|
package/dist/@types/types.d.ts
CHANGED
|
@@ -22,93 +22,93 @@ export interface PFormValueMap {
|
|
|
22
22
|
}
|
|
23
23
|
export type PFormValueItemData = Record<string, any>;
|
|
24
24
|
export interface PFormValueItemBaseCommands<T, AllowUndefinedValue extends boolean, V = AllowUndefinedValue extends true ? T | undefined : T> {
|
|
25
|
-
getType()
|
|
26
|
-
getName()
|
|
27
|
-
getReset()
|
|
28
|
-
reset()
|
|
29
|
-
getValue()
|
|
30
|
-
setValue(value: V)
|
|
31
|
-
getData()
|
|
32
|
-
setData(data?: PFormValueItemData)
|
|
33
|
-
isExceptValue()
|
|
34
|
-
isDisabled()
|
|
35
|
-
setDisabled(disabled: boolean)
|
|
36
|
-
isHidden()
|
|
37
|
-
setHidden(hidden: boolean)
|
|
38
|
-
focus()
|
|
39
|
-
focusValidate()
|
|
40
|
-
validate()
|
|
41
|
-
setError(error: boolean, errorText: ReactNode | undefined)
|
|
25
|
+
getType: () => 'default' | 'PFormCheckbox' | 'PFormToggleButtonGroup' | 'PFormRadioGroup' | 'PFormRating' | 'PFormTextEditor' | 'PFormAutocomplete' | 'PFormDatePicker' | 'PFormDateTimePicker' | 'PFormTimePicker' | 'PFormDateRangePicker' | 'PFormMonthPicker' | 'PFormMonthRangePicker' | 'PFormYearPicker' | 'PFormYearRangePicker' | 'PFormFile' | 'PFormSwitch';
|
|
26
|
+
getName: () => string;
|
|
27
|
+
getReset: () => V;
|
|
28
|
+
reset: () => void;
|
|
29
|
+
getValue: () => V;
|
|
30
|
+
setValue: (value: V) => void;
|
|
31
|
+
getData: () => PFormValueItemData | undefined;
|
|
32
|
+
setData: (data?: PFormValueItemData) => void;
|
|
33
|
+
isExceptValue: () => boolean;
|
|
34
|
+
isDisabled: () => boolean;
|
|
35
|
+
setDisabled: (disabled: boolean) => void;
|
|
36
|
+
isHidden: () => boolean;
|
|
37
|
+
setHidden: (hidden: boolean) => void;
|
|
38
|
+
focus: () => void;
|
|
39
|
+
focusValidate: () => void;
|
|
40
|
+
validate: () => boolean;
|
|
41
|
+
setError: (error: boolean, errorText: ReactNode | undefined) => void;
|
|
42
42
|
}
|
|
43
43
|
export interface PFormArrayValueItemCommands {
|
|
44
|
-
isFormValueSort()
|
|
45
|
-
getFormValueSeparator()
|
|
44
|
+
isFormValueSort: () => boolean;
|
|
45
|
+
getFormValueSeparator: () => string;
|
|
46
46
|
}
|
|
47
47
|
export interface PFormItemsValueItemCommands<T> {
|
|
48
|
-
getItems()
|
|
49
|
-
setItems(items: T[] | undefined)
|
|
48
|
+
getItems: () => T[] | undefined;
|
|
49
|
+
setItems: (items: T[] | undefined) => void;
|
|
50
50
|
}
|
|
51
51
|
export interface PFormCheckValueItemCommands<T> {
|
|
52
|
-
getChecked()
|
|
53
|
-
setChecked(checked: boolean, notFireOnChange?: boolean)
|
|
54
|
-
getUncheckedValue()
|
|
55
|
-
setUncheckedValue(uncheckedValue: T)
|
|
52
|
+
getChecked: () => boolean;
|
|
53
|
+
setChecked: (checked: boolean, notFireOnChange?: boolean) => void;
|
|
54
|
+
getUncheckedValue: () => T;
|
|
55
|
+
setUncheckedValue: (uncheckedValue: T) => void;
|
|
56
56
|
}
|
|
57
57
|
export interface PFormMultipleValueItemCommands {
|
|
58
|
-
isMultiple()
|
|
58
|
+
isMultiple: () => boolean;
|
|
59
59
|
}
|
|
60
60
|
export interface PFormLoadingValueItemCommands {
|
|
61
|
-
getLoading()
|
|
62
|
-
setLoading(loading: boolean)
|
|
61
|
+
getLoading: () => boolean;
|
|
62
|
+
setLoading: (loading: boolean) => void;
|
|
63
63
|
}
|
|
64
64
|
export interface PFormDateValueItemCommands {
|
|
65
|
-
getFormValueFormat()
|
|
65
|
+
getFormValueFormat: () => string;
|
|
66
66
|
}
|
|
67
67
|
export interface PFormRangeValueItemCommands<T> {
|
|
68
|
-
getFromValue()
|
|
69
|
-
setFromValue(value: T | null)
|
|
70
|
-
getToValue()
|
|
71
|
-
setToValue(value: T | null)
|
|
68
|
+
getFromValue: () => T | null;
|
|
69
|
+
setFromValue: (value: T | null) => void;
|
|
70
|
+
getToValue: () => T | null;
|
|
71
|
+
setToValue: (value: T | null) => void;
|
|
72
72
|
}
|
|
73
73
|
export interface PFormRangeValueItemNameCommands {
|
|
74
|
-
getFormValueFromNameSuffix()
|
|
75
|
-
getFormValueToNameSuffix()
|
|
76
|
-
getFormValueFromName()
|
|
77
|
-
getFormValueToName()
|
|
74
|
+
getFormValueFromNameSuffix: () => string;
|
|
75
|
+
getFormValueToNameSuffix: () => string;
|
|
76
|
+
getFormValueFromName: () => string;
|
|
77
|
+
getFormValueToName: () => string;
|
|
78
78
|
}
|
|
79
79
|
export interface PFormYearMonthValueItemCommands {
|
|
80
|
-
getYear()
|
|
81
|
-
setYear(year: number | null)
|
|
82
|
-
getMonth()
|
|
83
|
-
setMonth(month: number | null)
|
|
80
|
+
getYear: () => number | null;
|
|
81
|
+
setYear: (year: number | null) => void;
|
|
82
|
+
getMonth: () => number | null;
|
|
83
|
+
setMonth: (month: number | null) => void;
|
|
84
84
|
}
|
|
85
85
|
export interface PFormYearMonthValueItemNameCommands {
|
|
86
|
-
getFormValueYearNameSuffix()
|
|
87
|
-
getFormValueMonthNameSuffix()
|
|
88
|
-
getFormValueYearName()
|
|
89
|
-
getFormValueMonthName()
|
|
86
|
+
getFormValueYearNameSuffix: () => string;
|
|
87
|
+
getFormValueMonthNameSuffix: () => string;
|
|
88
|
+
getFormValueYearName: () => string;
|
|
89
|
+
getFormValueMonthName: () => string;
|
|
90
90
|
}
|
|
91
91
|
export interface PFormYearMonthRangeValueItemCommands {
|
|
92
|
-
getFromYear()
|
|
93
|
-
setFromYear(year: number | null)
|
|
94
|
-
getFromMonth()
|
|
95
|
-
setFromMonth(month: number | null)
|
|
96
|
-
getToYear()
|
|
97
|
-
setToYear(year: number | null)
|
|
98
|
-
getToMonth()
|
|
99
|
-
setToMonth(month: number | null)
|
|
92
|
+
getFromYear: () => number | null;
|
|
93
|
+
setFromYear: (year: number | null) => void;
|
|
94
|
+
getFromMonth: () => number | null;
|
|
95
|
+
setFromMonth: (month: number | null) => void;
|
|
96
|
+
getToYear: () => number | null;
|
|
97
|
+
setToYear: (year: number | null) => void;
|
|
98
|
+
getToMonth: () => number | null;
|
|
99
|
+
setToMonth: (month: number | null) => void;
|
|
100
100
|
}
|
|
101
101
|
export interface PFormYearMonthRangeValueItemNameCommands {
|
|
102
|
-
getFormValueFromYearNameSuffix()
|
|
103
|
-
getFormValueFromMonthNameSuffix()
|
|
104
|
-
getFormValueToYearNameSuffix()
|
|
105
|
-
getFormValueToMonthNameSuffix()
|
|
106
|
-
getFormValueFromYearName()
|
|
107
|
-
getFormValueFromMonthName()
|
|
108
|
-
getFormValueToYearName()
|
|
109
|
-
getFormValueToMonthName()
|
|
102
|
+
getFormValueFromYearNameSuffix: () => string;
|
|
103
|
+
getFormValueFromMonthNameSuffix: () => string;
|
|
104
|
+
getFormValueToYearNameSuffix: () => string;
|
|
105
|
+
getFormValueToMonthNameSuffix: () => string;
|
|
106
|
+
getFormValueFromYearName: () => string;
|
|
107
|
+
getFormValueFromMonthName: () => string;
|
|
108
|
+
getFormValueToYearName: () => string;
|
|
109
|
+
getFormValueToMonthName: () => string;
|
|
110
110
|
}
|
|
111
|
-
export interface PFormValueItemCommands<T, AllowUndefinedValue extends boolean = true, ItemType = any> extends PFormValueItemBaseCommands<T, AllowUndefinedValue>, Partial<PFormArrayValueItemCommands>, Partial<PFormItemsValueItemCommands<ItemType>>, Partial<PFormCheckValueItemCommands<T>>, Partial<PFormMultipleValueItemCommands>, Partial<PFormLoadingValueItemCommands>, Partial<PFormDateValueItemCommands>, Partial<PFormRangeValueItemCommands<
|
|
111
|
+
export interface PFormValueItemCommands<T, AllowUndefinedValue extends boolean = true, ItemType = any, RangeItemValue = any> extends PFormValueItemBaseCommands<T, AllowUndefinedValue>, Partial<PFormArrayValueItemCommands>, Partial<PFormItemsValueItemCommands<ItemType>>, Partial<PFormCheckValueItemCommands<T>>, Partial<PFormMultipleValueItemCommands>, Partial<PFormLoadingValueItemCommands>, Partial<PFormDateValueItemCommands>, Partial<PFormRangeValueItemCommands<RangeItemValue>>, Partial<PFormRangeValueItemNameCommands>, Partial<PFormYearMonthValueItemCommands>, Partial<PFormYearMonthValueItemNameCommands>, Partial<PFormYearMonthRangeValueItemCommands>, Partial<PFormYearMonthRangeValueItemNameCommands> {
|
|
112
112
|
}
|
|
113
113
|
export interface PFormValueItemCommandsMap<T, AllowUndefinedValue extends boolean = true, ItemType = any> {
|
|
114
114
|
[key: string]: PFormValueItemCommands<T, AllowUndefinedValue, ItemType> | undefined;
|
|
@@ -127,6 +127,6 @@ export interface PFormValueItemProps<T, AllowUndefinedValue extends boolean = tr
|
|
|
127
127
|
exceptValue?: boolean;
|
|
128
128
|
helperText?: ReactNode;
|
|
129
129
|
data?: PFormValueItemData;
|
|
130
|
-
onChange
|
|
131
|
-
onValidate
|
|
130
|
+
onChange?: (value: V) => void;
|
|
131
|
+
onValidate?: (value: V) => true | string;
|
|
132
132
|
}
|
|
@@ -13,29 +13,29 @@ export interface PFormProps extends PCommonSxProps, PartialPick<FormControlProps
|
|
|
13
13
|
formColGap?: number;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
submitWhenReturnKey?: boolean;
|
|
16
|
-
onSubmit
|
|
17
|
-
onInvalid
|
|
18
|
-
onValueChange
|
|
19
|
-
onValueChangeByUser
|
|
16
|
+
onSubmit?: (data: PFormValueMap) => void;
|
|
17
|
+
onInvalid?: (invalidItems: PFormInvalidItems) => void;
|
|
18
|
+
onValueChange?: (name: string, value: any) => void;
|
|
19
|
+
onValueChangeByUser?: (name: string, value: any) => void;
|
|
20
20
|
}
|
|
21
21
|
export interface PFormCommands {
|
|
22
|
-
submit()
|
|
23
|
-
getAllFormValue()
|
|
24
|
-
resetAll()
|
|
25
|
-
getItem<T extends PFormValueItemBaseCommands<any, true> = PFormValueItemCommands<any>>(name: string)
|
|
26
|
-
exists(name: string)
|
|
27
|
-
getReset(name: string)
|
|
28
|
-
getFormReset(name: string, subKey?: string)
|
|
29
|
-
reset(name: string)
|
|
30
|
-
getValue(name: string)
|
|
31
|
-
getFormValue(name: string, subKey?: string)
|
|
32
|
-
setValue(name: string, value: any)
|
|
33
|
-
isExceptValue(name: string)
|
|
34
|
-
isDisabled(name: string)
|
|
35
|
-
setDisabled(name: string, disabled: boolean)
|
|
36
|
-
isHidden(name: string)
|
|
37
|
-
setHidden(name: string, hidden: boolean)
|
|
38
|
-
focus(name: string)
|
|
39
|
-
validate(name: string)
|
|
40
|
-
setError(name: string, error: boolean, helperText: ReactNode)
|
|
22
|
+
submit: () => void;
|
|
23
|
+
getAllFormValue: () => PFormValueMap;
|
|
24
|
+
resetAll: () => void;
|
|
25
|
+
getItem: <T extends PFormValueItemBaseCommands<any, true> = PFormValueItemCommands<any>>(name: string) => T | undefined;
|
|
26
|
+
exists: (name: string) => boolean;
|
|
27
|
+
getReset: (name: string) => any;
|
|
28
|
+
getFormReset: (name: string, subKey?: string) => PFormValue;
|
|
29
|
+
reset: (name: string) => void;
|
|
30
|
+
getValue: (name: string) => any;
|
|
31
|
+
getFormValue: (name: string, subKey?: string) => PFormValue;
|
|
32
|
+
setValue: (name: string, value: any) => void;
|
|
33
|
+
isExceptValue: (name: string) => boolean;
|
|
34
|
+
isDisabled: (name: string) => boolean;
|
|
35
|
+
setDisabled: (name: string, disabled: boolean) => void;
|
|
36
|
+
isHidden: (name: string) => boolean;
|
|
37
|
+
setHidden: (name: string, hidden: boolean) => void;
|
|
38
|
+
focus: (name: string) => void;
|
|
39
|
+
validate: (name: string) => boolean;
|
|
40
|
+
setError: (name: string, error: boolean, helperText: ReactNode) => void;
|
|
41
41
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { PartialPick, PFormValueItemCommands } from '../@types';
|
|
2
2
|
import { PFormProps } from '../PForm/PForm.types';
|
|
3
|
-
export interface PFormContextValue<T = any, AllowUndefinedValue extends boolean = true> extends PartialPick<PFormProps, 'variant' | 'size' | 'color' | 'spacing' | 'formColGap' | 'focused' | 'labelShrink' | 'fullWidth'> {
|
|
3
|
+
export interface PFormContextValue<T = any, AllowUndefinedValue extends boolean = true, ItemValue = any, RangeItemValue = any> extends PartialPick<PFormProps, 'variant' | 'size' | 'color' | 'spacing' | 'formColGap' | 'focused' | 'labelShrink' | 'fullWidth'> {
|
|
4
4
|
id: string;
|
|
5
5
|
fullHeight?: boolean;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
submitWhenReturnKey?: boolean;
|
|
8
|
-
onAddValueItem(id: string, commands: PFormValueItemCommands<T, AllowUndefinedValue>)
|
|
9
|
-
onRemoveValueItem(id: string)
|
|
10
|
-
onValueChange(name: string, value: T)
|
|
11
|
-
onValueChangeByUser(name: string, value: T)
|
|
12
|
-
onRequestSubmit(name: string, value: T)
|
|
13
|
-
onRequestSearchSubmit(name: string, value: T)
|
|
8
|
+
onAddValueItem: (id: string, commands: PFormValueItemCommands<T, AllowUndefinedValue, ItemValue, RangeItemValue>) => void;
|
|
9
|
+
onRemoveValueItem: (id: string) => void;
|
|
10
|
+
onValueChange: (name: string, value: T) => void;
|
|
11
|
+
onValueChangeByUser: (name: string, value: T) => void;
|
|
12
|
+
onRequestSubmit: (name: string, value: T) => void;
|
|
13
|
+
onRequestSearchSubmit: (name: string, value: T) => void;
|
|
14
14
|
/** PFormRow */
|
|
15
15
|
formColAutoXs?: number;
|
|
16
16
|
formColWidth?: number;
|
|
17
|
-
onAddFormCol
|
|
18
|
-
onRemoveFormCol
|
|
17
|
+
onAddFormCol?: (id: string, xs: number | undefined) => void;
|
|
18
|
+
onRemoveFormCol?: (id: string) => void;
|
|
19
19
|
/** FormCol */
|
|
20
20
|
formColXs?: number;
|
|
21
21
|
formColWithLabel?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PFormContextValue } from './PFormContext.types';
|
|
2
|
-
export default function useFormState<T, AllowUndefinedValue extends boolean =
|
|
2
|
+
export default function useFormState<T, AllowUndefinedValue extends boolean, ItemValue = any, RangeItemValue = any>(): PFormContextValue<T, AllowUndefinedValue, ItemValue, RangeItemValue>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PFormContextProviderProps as Props } from './PFormContextProvider.types';
|
|
3
|
-
declare
|
|
3
|
+
declare function PFormContextProvider<T = any, AllowUndefinedValue extends boolean = true>({ children, value, }: Props<T, AllowUndefinedValue>): React.JSX.Element;
|
|
4
4
|
export default PFormContextProvider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { PFormContextValue } from '../PFormContext';
|
|
3
|
-
export interface PFormContextProviderProps {
|
|
4
|
-
value: PFormContextValue
|
|
3
|
+
export interface PFormContextProviderProps<T = any, AllowUndefinedValue extends boolean = true> {
|
|
4
|
+
value: PFormContextValue<T, AllowUndefinedValue>;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
}
|
|
@@ -3,7 +3,7 @@ import { ButtonBaseActions, CheckboxProps } from '@mui/material';
|
|
|
3
3
|
import { PCommonSxProps, PFormCheckValueItemCommands, PFormValueItemBaseCommands, PFormValueItemProps } from '../../@types';
|
|
4
4
|
export type PFormCheckboxValue = string | number | boolean;
|
|
5
5
|
export interface PFormCheckboxCommands extends Omit<PFormValueItemBaseCommands<PFormCheckboxValue, false>, 'getReset'>, PFormCheckValueItemCommands<PFormCheckboxValue> {
|
|
6
|
-
getReset()
|
|
6
|
+
getReset: () => boolean;
|
|
7
7
|
}
|
|
8
8
|
export interface PFormCheckboxProps extends PCommonSxProps, Omit<CheckboxProps, 'size' | 'color' | 'name' | 'inputRef' | 'action' | 'required' | 'onChange'>, Omit<PFormValueItemProps<PFormCheckboxValue, false>, 'value' | 'onChange'> {
|
|
9
9
|
value?: PFormCheckboxValue;
|
|
@@ -11,5 +11,5 @@ export interface PFormCheckboxProps extends PCommonSxProps, Omit<CheckboxProps,
|
|
|
11
11
|
text?: ReactNode;
|
|
12
12
|
inputRef?: RefObject<HTMLInputElement>;
|
|
13
13
|
action?: RefObject<ButtonBaseActions>;
|
|
14
|
-
onChange
|
|
14
|
+
onChange?: (checked: boolean) => void;
|
|
15
15
|
}
|
|
@@ -38,11 +38,11 @@ export interface PFormDateRangePickerProps extends PCommonSxProps, Omit<PFormVal
|
|
|
38
38
|
disableFuture?: boolean;
|
|
39
39
|
minDate?: Dayjs;
|
|
40
40
|
maxDate?: Dayjs;
|
|
41
|
-
onGetActionButtons
|
|
41
|
+
onGetActionButtons?: () => {
|
|
42
42
|
label: string;
|
|
43
43
|
start: Dayjs;
|
|
44
44
|
end: Dayjs;
|
|
45
45
|
}[];
|
|
46
46
|
}
|
|
47
|
-
export interface PFormDateRangePickerCommands extends PFormValueItemBaseCommands<PFormDateRangePickerValue, false>, PFormDateValueItemCommands, PFormRangeValueItemCommands<
|
|
47
|
+
export interface PFormDateRangePickerCommands extends PFormValueItemBaseCommands<PFormDateRangePickerValue, false>, PFormDateValueItemCommands, PFormRangeValueItemCommands<PFormDateRangePickerDateValue>, PFormRangeValueItemNameCommands {
|
|
48
48
|
}
|
|
@@ -14,12 +14,12 @@ export interface PFormDateRangePickerTooltipPickerProps {
|
|
|
14
14
|
disableFuture?: boolean;
|
|
15
15
|
minDate?: Dayjs;
|
|
16
16
|
maxDate?: Dayjs;
|
|
17
|
-
onValueChange
|
|
18
|
-
onMouseEnterPickersDay
|
|
19
|
-
onMonthChange
|
|
17
|
+
onValueChange?: (selectType: PFormDateRangePickerTooltipPickerSelectType, value: PFormDateRangePickerTooltipPickerDateValue) => void;
|
|
18
|
+
onMouseEnterPickersDay?: (date: PFormDateRangePickerTooltipPickerDateValue) => void;
|
|
19
|
+
onMonthChange?: (date: Dayjs) => void;
|
|
20
20
|
}
|
|
21
21
|
export interface PFormDateRangePickerTooltipPickerCommands {
|
|
22
|
-
previousMonth()
|
|
23
|
-
nextMonth()
|
|
24
|
-
activeMonth(month: Dayjs)
|
|
22
|
+
previousMonth: () => void;
|
|
23
|
+
nextMonth: () => void;
|
|
24
|
+
activeMonth: (month: Dayjs) => void;
|
|
25
25
|
}
|
|
@@ -11,17 +11,17 @@ export interface PFormDateRangePickerTooltipPickerContainerProps {
|
|
|
11
11
|
disableFuture?: boolean;
|
|
12
12
|
minDate?: Dayjs;
|
|
13
13
|
maxDate?: Dayjs;
|
|
14
|
-
onGetActionButtons
|
|
14
|
+
onGetActionButtons?: () => {
|
|
15
15
|
label: string;
|
|
16
16
|
start: Dayjs;
|
|
17
17
|
end: Dayjs;
|
|
18
18
|
}[];
|
|
19
|
-
onChange(newValue: PFormDateRangePickerTooltipPickerValue)
|
|
20
|
-
onValueChange(selectType: PFormDateRangePickerTooltipPickerSelectType, newValue: PFormDateRangePickerTooltipPickerDateValue)
|
|
21
|
-
onMonthsChange(months: PFormDateRangePickerTooltipPickerContainerMonths)
|
|
19
|
+
onChange: (newValue: PFormDateRangePickerTooltipPickerValue) => void;
|
|
20
|
+
onValueChange: (selectType: PFormDateRangePickerTooltipPickerSelectType, newValue: PFormDateRangePickerTooltipPickerDateValue) => void;
|
|
21
|
+
onMonthsChange: (months: PFormDateRangePickerTooltipPickerContainerMonths) => void;
|
|
22
22
|
}
|
|
23
23
|
export interface PFormDateRangePickerTooltipPickerContainerCommands {
|
|
24
|
-
previousMonth()
|
|
25
|
-
nextMonth()
|
|
26
|
-
activeMonth(month: Dayjs)
|
|
24
|
+
previousMonth: () => void;
|
|
25
|
+
nextMonth: () => void;
|
|
26
|
+
activeMonth: (month: Dayjs) => void;
|
|
27
27
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PrivateDateTimePickerProps, PrivateDateTimePickerCommands } from '../../@private';
|
|
1
|
+
import { PrivateDateTimePickerProps, PrivateDateTimePickerCommands, PrivateDateTimePickerValue } from '../../@private';
|
|
2
|
+
export type PFormDateTimePickerValue = PrivateDateTimePickerValue;
|
|
2
3
|
export interface PFormDateTimePickerProps extends Omit<PrivateDateTimePickerProps, 'type' | 'time'> {
|
|
3
4
|
time: Required<PrivateDateTimePickerProps['time']>;
|
|
4
5
|
}
|
|
@@ -21,7 +21,7 @@ export interface PFormFileProps extends PCommonSxProps, PFormValueItemProps<PFor
|
|
|
21
21
|
labelShrink?: boolean;
|
|
22
22
|
maxFileSize?: number;
|
|
23
23
|
preview?: ReactNode;
|
|
24
|
-
onFile
|
|
25
|
-
onLink
|
|
24
|
+
onFile?: (file: File) => Promise<string>;
|
|
25
|
+
onLink?: (url: string) => Promise<string>;
|
|
26
26
|
}
|
|
27
27
|
export type PFormFileCommands = PFormValueItemCommands<PFormFileValue, false>;
|
|
@@ -15,8 +15,8 @@ export interface PFormRadioGroupProps<T extends PFormRadioGroupSingleValue> exte
|
|
|
15
15
|
inline?: boolean;
|
|
16
16
|
loading?: boolean;
|
|
17
17
|
nowrap?: boolean;
|
|
18
|
-
onLoadItems
|
|
19
|
-
onValue
|
|
18
|
+
onLoadItems?: () => Promise<PFormRadioGroupItem<T>[]>;
|
|
19
|
+
onValue?: (value: PFormRadioGroupValue<T>) => PFormRadioGroupValue<T>;
|
|
20
20
|
}
|
|
21
21
|
export interface PFormRadioGroupCommands<T extends PFormRadioGroupSingleValue> extends PFormValueItemBaseCommands<T, true>, PFormItemsValueItemCommands<PFormRadioGroupItem<T>>, PFormLoadingValueItemCommands {
|
|
22
22
|
}
|
|
@@ -6,7 +6,7 @@ export interface PFormRatingProps extends PCommonSxProps, PartialPick<RatingProp
|
|
|
6
6
|
required?: boolean;
|
|
7
7
|
icon?: string;
|
|
8
8
|
emptyIcon?: string;
|
|
9
|
-
onValue
|
|
9
|
+
onValue?: (value: PFormRatingValue) => PFormRatingValue;
|
|
10
10
|
}
|
|
11
11
|
export interface PFormRatingCommands extends PFormValueItemBaseCommands<PFormRatingValue, false> {
|
|
12
12
|
}
|
|
@@ -5,7 +5,7 @@ import { FormControlLabelProps } from '@mui/material';
|
|
|
5
5
|
export interface PFormSwitchProps extends PCommonSxProps, Omit<PFormValueItemProps<boolean, false>, 'fullWidth'> {
|
|
6
6
|
switchLabel?: ReactNode;
|
|
7
7
|
switchLabelProps?: Omit<FormControlLabelProps, 'children' | 'control' | 'label' | 'required' | 'disabled'>;
|
|
8
|
-
onValue
|
|
8
|
+
onValue?: (value: boolean) => boolean;
|
|
9
9
|
}
|
|
10
10
|
export interface PFormSwitchCommands extends PFormValueItemBaseCommands<boolean, false> {
|
|
11
11
|
}
|
|
@@ -6,5 +6,5 @@ export interface PFormTextEditorProps extends PCommonSxProps, Omit<PFormValueIte
|
|
|
6
6
|
required?: boolean;
|
|
7
7
|
menubar?: boolean;
|
|
8
8
|
height?: number;
|
|
9
|
-
onImageUpload
|
|
9
|
+
onImageUpload?: (blob: Blob, success: (url: string) => void, failure: (err: string) => void, progress?: (percent: number) => void) => void;
|
|
10
10
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PrivateDateTimePickerProps, PrivateDateTimePickerCommands } from '../../@private';
|
|
1
|
+
import { PrivateDateTimePickerProps, PrivateDateTimePickerCommands, PrivateDateTimePickerValue } from '../../@private';
|
|
2
|
+
export type PFormTimePickerValue = PrivateDateTimePickerValue;
|
|
2
3
|
export interface PFormTimePickerProps extends Omit<PrivateDateTimePickerProps, 'type' | 'time'> {
|
|
3
4
|
time: Required<PrivateDateTimePickerProps['time']>;
|
|
4
5
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PFormSelectCommands, PFormSelectSingleValue } from './PFormSelect.types';
|
|
2
|
+
import { PFormSelectCommands, PFormSelectSingleValue, PFormSelectValue, PFormSelectItem } from './PFormSelect.types';
|
|
3
3
|
import './PFormSelect.scss';
|
|
4
|
-
declare const PFormSelect: (<T extends PFormSelectSingleValue, Multiple extends boolean | undefined>(props: Omit<import("../PFormTextField").PFormTextFieldProps<
|
|
4
|
+
declare const PFormSelect: (<T extends PFormSelectSingleValue, Multiple extends boolean | undefined>(props: Omit<import("../PFormTextField").PFormTextFieldProps<PFormSelectValue<T, Multiple>, false>, "type" | "clear"> & {
|
|
5
5
|
items?: import("./PFormSelect.types").PFormSelectItems<T> | undefined;
|
|
6
6
|
multiple?: Multiple | undefined;
|
|
7
7
|
checkbox?: boolean;
|
|
@@ -9,6 +9,6 @@ declare const PFormSelect: (<T extends PFormSelectSingleValue, Multiple extends
|
|
|
9
9
|
formValueSort?: boolean;
|
|
10
10
|
minWidth?: string | number;
|
|
11
11
|
loading?: boolean;
|
|
12
|
-
onLoadItems?: (() => Promise<
|
|
12
|
+
onLoadItems?: (() => Promise<PFormSelectItem<T>[]>) | undefined;
|
|
13
13
|
} & React.RefAttributes<PFormSelectCommands<T, Multiple>>) => React.ReactElement | null) & Pick<React.ForwardRefExoticComponent<any>, "displayName" | "propTypes" | "$$typeof">;
|
|
14
14
|
export default PFormSelect;
|
package/dist/index.esm.js
CHANGED
|
@@ -84,10 +84,10 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
84
84
|
throw new Error('useFormState should be used within FormContext.Provider');
|
|
85
85
|
}
|
|
86
86
|
return value;
|
|
87
|
-
}
|
|
87
|
+
}function PFormContextProvider(_a) {
|
|
88
88
|
var children = _a.children, value = _a.value;
|
|
89
89
|
return React.createElement(PFormContext.Provider, { value: value }, children);
|
|
90
|
-
}
|
|
90
|
+
}/********************************************************************************************************************
|
|
91
91
|
* getItemFormValue
|
|
92
92
|
* ******************************************************************************************************************/
|
|
93
93
|
var getItemFormValue = function (commands, reset) {
|
|
@@ -1463,7 +1463,9 @@ var PFormTag = React.forwardRef(function (_a, ref) {
|
|
|
1463
1463
|
* Function - getCommands
|
|
1464
1464
|
* ******************************************************************************************************************/
|
|
1465
1465
|
var getCommands = useCallback(function (baseCommands) {
|
|
1466
|
-
return __assign(__assign(__assign({}, baseCommands), { getReset: function () { return getFinalValue(initValue); }, reset: function () { return updateValue(initValue); }, getValue: function () { return valueRef.current; }, setValue: function (newValue) {
|
|
1466
|
+
return __assign(__assign(__assign({}, baseCommands), { getReset: function () { return getFinalValue(initValue); }, reset: function () { return updateValue(initValue); }, getValue: function () { return valueRef.current; }, setValue: function (newValue) {
|
|
1467
|
+
updateValue(newValue);
|
|
1468
|
+
}, validate: function () { return validate(valueRef.current); } }), getExtraCommands());
|
|
1467
1469
|
}, [getExtraCommands, getFinalValue, initValue, updateValue, valueRef, validate]);
|
|
1468
1470
|
/********************************************************************************************************************
|
|
1469
1471
|
* Function - appendTag, removeTag
|
|
@@ -1497,8 +1499,8 @@ var PFormTag = React.forwardRef(function (_a, ref) {
|
|
|
1497
1499
|
* Event Handler
|
|
1498
1500
|
* ******************************************************************************************************************/
|
|
1499
1501
|
var handleAddValueItem = useCallback(function (id, commands) {
|
|
1500
|
-
onAddValueItem(id,
|
|
1501
|
-
}, [onAddValueItem
|
|
1502
|
+
onAddValueItem(id, commands);
|
|
1503
|
+
}, [onAddValueItem]);
|
|
1502
1504
|
var handleRef = useCallback(function (commands) {
|
|
1503
1505
|
if (ref) {
|
|
1504
1506
|
var finalCommands = getCommands(commands);
|
|
@@ -1667,6 +1669,12 @@ PFormMobile.displayName = 'PFormMobile';var NumberFormatCustom = React.forwardRe
|
|
|
1667
1669
|
tabIndex,
|
|
1668
1670
|
thousandSeparator,
|
|
1669
1671
|
]);
|
|
1672
|
+
/********************************************************************************************************************
|
|
1673
|
+
* Function
|
|
1674
|
+
* ******************************************************************************************************************/
|
|
1675
|
+
var getFinalValue = useCallback(function (value) {
|
|
1676
|
+
return empty(value) || value === '-' || value === '.' ? undefined : Number(value);
|
|
1677
|
+
}, []);
|
|
1670
1678
|
/********************************************************************************************************************
|
|
1671
1679
|
* Event Handler
|
|
1672
1680
|
* ******************************************************************************************************************/
|
|
@@ -1718,10 +1726,32 @@ PFormMobile.displayName = 'PFormMobile';var NumberFormatCustom = React.forwardRe
|
|
|
1718
1726
|
return true;
|
|
1719
1727
|
}
|
|
1720
1728
|
}, [onValidate]);
|
|
1729
|
+
var handleRef = useCallback(function (commands) {
|
|
1730
|
+
if (ref) {
|
|
1731
|
+
var finalCommands = commands
|
|
1732
|
+
? __assign(__assign({}, commands), { getReset: function () { return initValue; }, getValue: function () { return getFinalValue(strValueRef.current); }, setValue: function (value) {
|
|
1733
|
+
var strValue = value !== undefined ? "".concat(value) : '';
|
|
1734
|
+
if (strValueRef.current === strValue) {
|
|
1735
|
+
strValueRef.current = "".concat(strValue, " ");
|
|
1736
|
+
}
|
|
1737
|
+
else {
|
|
1738
|
+
strValueRef.current = strValue;
|
|
1739
|
+
}
|
|
1740
|
+
onChange && onChange(value);
|
|
1741
|
+
forceUpdate();
|
|
1742
|
+
} }) : null;
|
|
1743
|
+
if (typeof ref === 'function') {
|
|
1744
|
+
return ref(finalCommands);
|
|
1745
|
+
}
|
|
1746
|
+
else {
|
|
1747
|
+
ref.current = finalCommands;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
}, [forceUpdate, getFinalValue, initValue, onChange, ref, strValueRef]);
|
|
1721
1751
|
/********************************************************************************************************************
|
|
1722
1752
|
* Render
|
|
1723
1753
|
* ******************************************************************************************************************/
|
|
1724
|
-
return (React.createElement(PFormTextField, __assign({ ref:
|
|
1754
|
+
return (React.createElement(PFormTextField, __assign({ ref: handleRef, className: classNames(className, 'PFormNumber'), disableReturnKey: true, labelShrink: strValueRef.current === '' || strValueRef.current === undefined ? labelShrink : true, slotProps: slotProps, readOnly: readOnly, clear: clear, value: strValueRef.current, onChange: handleChange, onValue: handleValue, onValidate: handleValidate }, props)));
|
|
1725
1755
|
});
|
|
1726
1756
|
PFormNumber.displayName = 'PFormNumber';insertStyle(".PFormSearch input[type=search]::-webkit-search-decoration,.PFormSearch input[type=search]::-webkit-search-cancel-button,.PFormSearch input[type=search]::-webkit-search-results-button,.PFormSearch input[type=search]::-webkit-search-results-decoration{-webkit-appearance:none}");var PFormSearch = React.forwardRef(function (_a, ref) {
|
|
1727
1757
|
var className = _a.className, props = __rest(_a, ["className"]);
|
package/dist/index.js
CHANGED
|
@@ -84,10 +84,10 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
84
84
|
throw new Error('useFormState should be used within FormContext.Provider');
|
|
85
85
|
}
|
|
86
86
|
return value;
|
|
87
|
-
}
|
|
87
|
+
}function PFormContextProvider(_a) {
|
|
88
88
|
var children = _a.children, value = _a.value;
|
|
89
89
|
return React.createElement(PFormContext.Provider, { value: value }, children);
|
|
90
|
-
}
|
|
90
|
+
}/********************************************************************************************************************
|
|
91
91
|
* getItemFormValue
|
|
92
92
|
* ******************************************************************************************************************/
|
|
93
93
|
var getItemFormValue = function (commands, reset) {
|
|
@@ -1463,7 +1463,9 @@ var PFormTag = React.forwardRef(function (_a, ref) {
|
|
|
1463
1463
|
* Function - getCommands
|
|
1464
1464
|
* ******************************************************************************************************************/
|
|
1465
1465
|
var getCommands = React.useCallback(function (baseCommands) {
|
|
1466
|
-
return __assign(__assign(__assign({}, baseCommands), { getReset: function () { return getFinalValue(initValue); }, reset: function () { return updateValue(initValue); }, getValue: function () { return valueRef.current; }, setValue: function (newValue) {
|
|
1466
|
+
return __assign(__assign(__assign({}, baseCommands), { getReset: function () { return getFinalValue(initValue); }, reset: function () { return updateValue(initValue); }, getValue: function () { return valueRef.current; }, setValue: function (newValue) {
|
|
1467
|
+
updateValue(newValue);
|
|
1468
|
+
}, validate: function () { return validate(valueRef.current); } }), getExtraCommands());
|
|
1467
1469
|
}, [getExtraCommands, getFinalValue, initValue, updateValue, valueRef, validate]);
|
|
1468
1470
|
/********************************************************************************************************************
|
|
1469
1471
|
* Function - appendTag, removeTag
|
|
@@ -1497,8 +1499,8 @@ var PFormTag = React.forwardRef(function (_a, ref) {
|
|
|
1497
1499
|
* Event Handler
|
|
1498
1500
|
* ******************************************************************************************************************/
|
|
1499
1501
|
var handleAddValueItem = React.useCallback(function (id, commands) {
|
|
1500
|
-
onAddValueItem(id,
|
|
1501
|
-
}, [onAddValueItem
|
|
1502
|
+
onAddValueItem(id, commands);
|
|
1503
|
+
}, [onAddValueItem]);
|
|
1502
1504
|
var handleRef = React.useCallback(function (commands) {
|
|
1503
1505
|
if (ref) {
|
|
1504
1506
|
var finalCommands = getCommands(commands);
|
|
@@ -1667,6 +1669,12 @@ PFormMobile.displayName = 'PFormMobile';var NumberFormatCustom = React.forwardRe
|
|
|
1667
1669
|
tabIndex,
|
|
1668
1670
|
thousandSeparator,
|
|
1669
1671
|
]);
|
|
1672
|
+
/********************************************************************************************************************
|
|
1673
|
+
* Function
|
|
1674
|
+
* ******************************************************************************************************************/
|
|
1675
|
+
var getFinalValue = React.useCallback(function (value) {
|
|
1676
|
+
return compare.empty(value) || value === '-' || value === '.' ? undefined : Number(value);
|
|
1677
|
+
}, []);
|
|
1670
1678
|
/********************************************************************************************************************
|
|
1671
1679
|
* Event Handler
|
|
1672
1680
|
* ******************************************************************************************************************/
|
|
@@ -1718,10 +1726,32 @@ PFormMobile.displayName = 'PFormMobile';var NumberFormatCustom = React.forwardRe
|
|
|
1718
1726
|
return true;
|
|
1719
1727
|
}
|
|
1720
1728
|
}, [onValidate]);
|
|
1729
|
+
var handleRef = React.useCallback(function (commands) {
|
|
1730
|
+
if (ref) {
|
|
1731
|
+
var finalCommands = commands
|
|
1732
|
+
? __assign(__assign({}, commands), { getReset: function () { return initValue; }, getValue: function () { return getFinalValue(strValueRef.current); }, setValue: function (value) {
|
|
1733
|
+
var strValue = value !== undefined ? "".concat(value) : '';
|
|
1734
|
+
if (strValueRef.current === strValue) {
|
|
1735
|
+
strValueRef.current = "".concat(strValue, " ");
|
|
1736
|
+
}
|
|
1737
|
+
else {
|
|
1738
|
+
strValueRef.current = strValue;
|
|
1739
|
+
}
|
|
1740
|
+
onChange && onChange(value);
|
|
1741
|
+
forceUpdate();
|
|
1742
|
+
} }) : null;
|
|
1743
|
+
if (typeof ref === 'function') {
|
|
1744
|
+
return ref(finalCommands);
|
|
1745
|
+
}
|
|
1746
|
+
else {
|
|
1747
|
+
ref.current = finalCommands;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
}, [forceUpdate, getFinalValue, initValue, onChange, ref, strValueRef]);
|
|
1721
1751
|
/********************************************************************************************************************
|
|
1722
1752
|
* Render
|
|
1723
1753
|
* ******************************************************************************************************************/
|
|
1724
|
-
return (React.createElement(PFormTextField, __assign({ ref:
|
|
1754
|
+
return (React.createElement(PFormTextField, __assign({ ref: handleRef, className: classNames(className, 'PFormNumber'), disableReturnKey: true, labelShrink: strValueRef.current === '' || strValueRef.current === undefined ? labelShrink : true, slotProps: slotProps, readOnly: readOnly, clear: clear, value: strValueRef.current, onChange: handleChange, onValue: handleValue, onValidate: handleValidate }, props)));
|
|
1725
1755
|
});
|
|
1726
1756
|
PFormNumber.displayName = 'PFormNumber';insertStyle(".PFormSearch input[type=search]::-webkit-search-decoration,.PFormSearch input[type=search]::-webkit-search-cancel-button,.PFormSearch input[type=search]::-webkit-search-results-button,.PFormSearch input[type=search]::-webkit-search-results-decoration{-webkit-appearance:none}");var PFormSearch = React.forwardRef(function (_a, ref) {
|
|
1727
1757
|
var className = _a.className, props = __rest(_a, ["className"]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdg/react-form",
|
|
3
3
|
"title": "React Form",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.6",
|
|
5
5
|
"description": "React Form",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@pdg/compare": "^1.0.6",
|
|
58
58
|
"@pdg/data": "^1.0.1",
|
|
59
59
|
"@pdg/formatting": "^1.0.5",
|
|
60
|
-
"@pdg/react-component": "^1.1.
|
|
60
|
+
"@pdg/react-component": "^1.1.1",
|
|
61
61
|
"@pdg/react-hook": "^1.0.32",
|
|
62
62
|
"@pdg/types": "^1.0.2",
|
|
63
63
|
"@tinymce/miniature": "^6.0.0",
|