@rjsf/primereact 6.4.1 → 6.5.0
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/index.cjs +17 -17
- package/dist/index.cjs.map +2 -2
- package/dist/primereact.esm.js +24 -20
- package/dist/primereact.esm.js.map +3 -3
- package/dist/primereact.umd.js +17 -17
- package/lib/RadioWidget/RadioWidget.js +4 -3
- package/lib/RadioWidget/RadioWidget.js.map +1 -1
- package/lib/SelectWidget/SelectWidget.js +13 -15
- package/lib/SelectWidget/SelectWidget.js.map +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/RadioWidget/RadioWidget.tsx +6 -3
- package/src/SelectWidget/SelectWidget.tsx +18 -16
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/primereact",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"description": "PrimeReact theme, fields and widgets for react-jsonschema-form",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -68,10 +68,10 @@
|
|
|
68
68
|
"react": ">=18"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@rjsf/core": "6.
|
|
72
|
-
"@rjsf/snapshot-tests": "6.
|
|
73
|
-
"@rjsf/utils": "6.
|
|
74
|
-
"@rjsf/validator-ajv8": "6.
|
|
71
|
+
"@rjsf/core": "6.5.0",
|
|
72
|
+
"@rjsf/snapshot-tests": "6.5.0",
|
|
73
|
+
"@rjsf/utils": "6.5.0",
|
|
74
|
+
"@rjsf/validator-ajv8": "6.5.0",
|
|
75
75
|
"@rollup/plugin-replace": "^6.0.3",
|
|
76
76
|
"eslint": "^8.57.1",
|
|
77
77
|
"primeflex": "^4.0.0",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ariaDescribedByIds,
|
|
3
|
+
enumOptionValueDecoder,
|
|
4
|
+
enumOptionValueEncoder,
|
|
3
5
|
enumOptionsIsSelected,
|
|
4
|
-
|
|
6
|
+
getOptionValueFormat,
|
|
5
7
|
optionId,
|
|
6
8
|
FormContextType,
|
|
7
9
|
RJSFSchema,
|
|
@@ -21,9 +23,10 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
21
23
|
const { id, htmlName, value, disabled, readonly, onChange, onBlur, onFocus, options } = props;
|
|
22
24
|
const primeProps = (options.prime || {}) as object;
|
|
23
25
|
const { enumOptions, enumDisabled, emptyValue } = options;
|
|
26
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
24
27
|
|
|
25
28
|
const _onChange = (e: RadioButtonChangeEvent) => {
|
|
26
|
-
onChange(
|
|
29
|
+
onChange(enumOptionValueDecoder<S>(e.value, enumOptions, optionValueFormat, emptyValue));
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
const _onBlur = () => onBlur(id, value);
|
|
@@ -44,7 +47,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
|
|
|
44
47
|
onFocus={_onFocus}
|
|
45
48
|
onBlur={_onBlur}
|
|
46
49
|
onChange={_onChange}
|
|
47
|
-
value={
|
|
50
|
+
value={enumOptionValueEncoder(option.value, index, optionValueFormat)}
|
|
48
51
|
checked={checked}
|
|
49
52
|
disabled={disabled || itemDisabled || readonly}
|
|
50
53
|
aria-describedby={ariaDescribedByIds(id)}
|
|
@@ -2,8 +2,10 @@ import { FocusEvent } from 'react';
|
|
|
2
2
|
import { Dropdown } from 'primereact/dropdown';
|
|
3
3
|
import {
|
|
4
4
|
ariaDescribedByIds,
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
enumOptionSelectedValue,
|
|
6
|
+
enumOptionValueDecoder,
|
|
7
|
+
enumOptionValueEncoder,
|
|
8
|
+
getOptionValueFormat,
|
|
7
9
|
FormContextType,
|
|
8
10
|
RJSFSchema,
|
|
9
11
|
StrictRJSFSchema,
|
|
@@ -50,19 +52,19 @@ function SingleSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
50
52
|
...dropdownProps
|
|
51
53
|
}: WidgetProps<T, S, F>) {
|
|
52
54
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
55
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
53
56
|
const primeProps = (options.prime || {}) as object;
|
|
54
57
|
|
|
55
58
|
multiple = typeof multiple === 'undefined' ? false : multiple;
|
|
56
59
|
|
|
57
60
|
const emptyValue = multiple ? [] : '';
|
|
58
|
-
const isEmpty = typeof value === 'undefined' || (multiple && value.length < 1) || (!multiple && value === emptyValue);
|
|
59
61
|
|
|
60
|
-
const _onChange = (e: { value: any }) =>
|
|
62
|
+
const _onChange = (e: { value: any }) =>
|
|
63
|
+
onChange(enumOptionValueDecoder<S>(e.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
61
64
|
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
62
|
-
onBlur(id,
|
|
65
|
+
onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
63
66
|
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
64
|
-
onFocus(id,
|
|
65
|
-
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
|
|
67
|
+
onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
66
68
|
const { ...dropdownRemainingProps } = dropdownProps;
|
|
67
69
|
|
|
68
70
|
return (
|
|
@@ -70,10 +72,10 @@ function SingleSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
70
72
|
id={id}
|
|
71
73
|
name={htmlName || id}
|
|
72
74
|
{...primeProps}
|
|
73
|
-
value={
|
|
75
|
+
value={enumOptionSelectedValue<S>(value, enumOptions, !!multiple, optionValueFormat, emptyValue)}
|
|
74
76
|
options={(enumOptions ?? []).map(({ value, label }, i: number) => ({
|
|
75
77
|
label,
|
|
76
|
-
value:
|
|
78
|
+
value: enumOptionValueEncoder(value, i, optionValueFormat),
|
|
77
79
|
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
78
80
|
}))}
|
|
79
81
|
onChange={_onChange}
|
|
@@ -103,27 +105,27 @@ function MultiSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
|
|
|
103
105
|
onFocus,
|
|
104
106
|
}: WidgetProps<T, S, F>) {
|
|
105
107
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
108
|
+
const optionValueFormat = getOptionValueFormat(options);
|
|
106
109
|
const primeProps = (options.prime || {}) as object;
|
|
107
110
|
|
|
108
111
|
const emptyValue = multiple ? [] : '';
|
|
109
|
-
const isEmpty = typeof value === 'undefined' || (multiple && value.length < 1) || (!multiple && value === emptyValue);
|
|
110
112
|
|
|
111
|
-
const _onChange = (e: { value: any }) =>
|
|
113
|
+
const _onChange = (e: { value: any }) =>
|
|
114
|
+
onChange(enumOptionValueDecoder<S>(e.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
112
115
|
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
113
|
-
onBlur(id,
|
|
116
|
+
onBlur(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
114
117
|
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) =>
|
|
115
|
-
onFocus(id,
|
|
116
|
-
const selectedIndexes = enumOptionsIndexForValue<S>(value, enumOptions, multiple);
|
|
118
|
+
onFocus(id, enumOptionValueDecoder<S>(target && target.value, enumOptions, optionValueFormat, optEmptyVal));
|
|
117
119
|
|
|
118
120
|
return (
|
|
119
121
|
<MultiSelect
|
|
120
122
|
id={id}
|
|
121
123
|
name={htmlName || id}
|
|
122
124
|
{...primeProps}
|
|
123
|
-
value={
|
|
125
|
+
value={enumOptionSelectedValue<S>(value, enumOptions, multiple, optionValueFormat, emptyValue)}
|
|
124
126
|
options={(enumOptions ?? []).map(({ value, label }, i: number) => ({
|
|
125
127
|
label,
|
|
126
|
-
value:
|
|
128
|
+
value: enumOptionValueEncoder(value, i, optionValueFormat),
|
|
127
129
|
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
128
130
|
}))}
|
|
129
131
|
onChange={_onChange}
|