@rjsf/primereact 6.1.2 → 6.2.4
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 +51 -28
- package/dist/index.cjs.map +3 -3
- package/dist/primereact.esm.js +80 -57
- package/dist/primereact.esm.js.map +3 -3
- package/dist/primereact.umd.js +49 -27
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +3 -1
- package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
- package/lib/BaseInputTemplate/BaseInputTemplate.js +13 -5
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/IconButton/IconButton.d.ts +1 -0
- package/lib/IconButton/IconButton.js +4 -0
- package/lib/IconButton/IconButton.js.map +1 -1
- package/lib/Templates/Templates.js +2 -1
- package/lib/Templates/Templates.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +3 -0
- package/src/BaseInputTemplate/BaseInputTemplate.tsx +36 -22
- package/src/IconButton/IconButton.tsx +9 -0
- package/src/Templates/Templates.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/primereact",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.4",
|
|
4
4
|
"description": "PrimeReact theme, fields and widgets for react-jsonschema-form",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -61,17 +61,17 @@
|
|
|
61
61
|
"node": ">=20"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@rjsf/core": "^6.x",
|
|
65
|
-
"@rjsf/utils": "^6.x",
|
|
64
|
+
"@rjsf/core": "^6.2.x",
|
|
65
|
+
"@rjsf/utils": "^6.2.x",
|
|
66
66
|
"primeicons": ">=6.0.0",
|
|
67
67
|
"primereact": ">=8.0.0",
|
|
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.2.0",
|
|
72
|
+
"@rjsf/snapshot-tests": "^6.2.0",
|
|
73
|
+
"@rjsf/utils": "^6.2.0",
|
|
74
|
+
"@rjsf/validator-ajv8": "^6.2.0",
|
|
75
75
|
"@rollup/plugin-replace": "^6.0.3",
|
|
76
76
|
"eslint": "^8.57.1",
|
|
77
77
|
"primeflex": "^4.0.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent } from 'react';
|
|
1
|
+
import { ChangeEvent, MouseEvent, useCallback } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ariaDescribedByIds,
|
|
4
4
|
BaseInputTemplateProps,
|
|
@@ -37,36 +37,50 @@ export default function BaseInputTemplate<
|
|
|
37
37
|
rawErrors = [],
|
|
38
38
|
} = props;
|
|
39
39
|
|
|
40
|
+
const { ClearButton } = registry.templates.ButtonTemplates;
|
|
40
41
|
const { AutoCompleteWidget } = registry.widgets;
|
|
41
42
|
|
|
42
|
-
if (Array.isArray(schema.examples)) {
|
|
43
|
-
return <AutoCompleteWidget {...props} />;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
43
|
const inputProps = getInputProps<T, S, F>(schema, type, options);
|
|
47
44
|
const primeProps = (options.prime || {}) as object;
|
|
48
45
|
const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
|
|
49
46
|
onChange(value === '' ? options.emptyValue : value);
|
|
50
47
|
const _onBlur = () => onBlur && onBlur(id, value);
|
|
51
48
|
const _onFocus = () => onFocus && onFocus(id, value);
|
|
49
|
+
const _onClear = useCallback(
|
|
50
|
+
(e: MouseEvent) => {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
onChange(options.emptyValue ?? '');
|
|
54
|
+
},
|
|
55
|
+
[onChange, options.emptyValue],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (Array.isArray(schema.examples)) {
|
|
59
|
+
return <AutoCompleteWidget {...props} />;
|
|
60
|
+
}
|
|
52
61
|
|
|
53
62
|
return (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
<>
|
|
64
|
+
<InputText
|
|
65
|
+
id={id}
|
|
66
|
+
name={htmlName || id}
|
|
67
|
+
placeholder={placeholder}
|
|
68
|
+
{...primeProps}
|
|
69
|
+
{...inputProps}
|
|
70
|
+
required={required}
|
|
71
|
+
autoFocus={autofocus}
|
|
72
|
+
disabled={disabled || readonly}
|
|
73
|
+
list={schema.examples ? examplesId(id) : undefined}
|
|
74
|
+
value={value || value === 0 ? value : ''}
|
|
75
|
+
invalid={rawErrors.length > 0}
|
|
76
|
+
onChange={onChangeOverride || _onChange}
|
|
77
|
+
onBlur={_onBlur}
|
|
78
|
+
onFocus={_onFocus}
|
|
79
|
+
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
80
|
+
/>
|
|
81
|
+
{options.allowClearTextInputs && !readonly && !disabled && value && (
|
|
82
|
+
<ClearButton registry={registry} onClick={_onClear} />
|
|
83
|
+
)}
|
|
84
|
+
</>
|
|
71
85
|
);
|
|
72
86
|
}
|
|
@@ -49,3 +49,12 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
49
49
|
} = props;
|
|
50
50
|
return <IconButton title={translateString(TranslatableString.RemoveButton)} {...props} icon='trash' />;
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
54
|
+
props: PrimeIconButtonProps<T, S, F>,
|
|
55
|
+
) {
|
|
56
|
+
const {
|
|
57
|
+
registry: { translateString },
|
|
58
|
+
} = props;
|
|
59
|
+
return <IconButton title={translateString(TranslatableString.ClearButton)} {...props} icon='times' />;
|
|
60
|
+
}
|
|
@@ -6,7 +6,7 @@ import ArrayFieldTemplate from '../ArrayFieldTemplate';
|
|
|
6
6
|
import BaseInputTemplate from '../BaseInputTemplate';
|
|
7
7
|
import DescriptionField from '../DescriptionField';
|
|
8
8
|
import ErrorList from '../ErrorList';
|
|
9
|
-
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from '../IconButton';
|
|
9
|
+
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton } from '../IconButton';
|
|
10
10
|
import FieldErrorTemplate from '../FieldErrorTemplate';
|
|
11
11
|
import FieldHelpTemplate from '../FieldHelpTemplate';
|
|
12
12
|
import FieldTemplate from '../FieldTemplate';
|
|
@@ -36,6 +36,7 @@ export function generateTemplates<
|
|
|
36
36
|
MoveUpButton,
|
|
37
37
|
RemoveButton,
|
|
38
38
|
SubmitButton,
|
|
39
|
+
ClearButton,
|
|
39
40
|
},
|
|
40
41
|
DescriptionFieldTemplate: DescriptionField,
|
|
41
42
|
ErrorListTemplate: ErrorList,
|