@rjsf/fluentui-rc 6.1.2 → 6.2.3
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/core.umd.js +27 -2
- package/dist/index.cjs +30 -4
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +35 -3
- package/dist/index.esm.js.map +3 -3
- package/lib/BaseInputTemplate/BaseInputTemplate.js +10 -2
- package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
- package/lib/IconButton/IconButton.d.ts +1 -0
- package/lib/IconButton/IconButton.js +5 -1
- 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/BaseInputTemplate/BaseInputTemplate.tsx +14 -1
- package/src/IconButton/IconButton.tsx +22 -1
- package/src/Templates/Templates.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/fluentui-rc",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.3",
|
|
4
4
|
"description": "FluentUI React Components theme, fields and widgets for react-jsonschema-form",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
@@ -68,18 +68,18 @@
|
|
|
68
68
|
"@fluentui/react-components": "^9.63.0",
|
|
69
69
|
"@fluentui/react-icons": "^2.0.298",
|
|
70
70
|
"@fluentui/react-migration-v0-v9": "^9.3.10",
|
|
71
|
-
"@rjsf/core": "^6.x",
|
|
72
|
-
"@rjsf/utils": "^6.x",
|
|
71
|
+
"@rjsf/core": "^6.2.x",
|
|
72
|
+
"@rjsf/utils": "^6.2.x",
|
|
73
73
|
"react": ">=18"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@fluentui/react-components": "^9.72.4",
|
|
77
77
|
"@fluentui/react-icons": "^2.0.313",
|
|
78
78
|
"@fluentui/react-migration-v0-v9": "^9.6.12",
|
|
79
|
-
"@rjsf/core": "^6.
|
|
80
|
-
"@rjsf/snapshot-tests": "^6.
|
|
81
|
-
"@rjsf/utils": "^6.
|
|
82
|
-
"@rjsf/validator-ajv8": "^6.
|
|
79
|
+
"@rjsf/core": "^6.2.0",
|
|
80
|
+
"@rjsf/snapshot-tests": "^6.2.0",
|
|
81
|
+
"@rjsf/utils": "^6.2.0",
|
|
82
|
+
"@rjsf/validator-ajv8": "^6.2.0",
|
|
83
83
|
"eslint": "^8.57.1"
|
|
84
84
|
},
|
|
85
85
|
"directories": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, FocusEvent } from 'react';
|
|
1
|
+
import { ChangeEvent, FocusEvent, MouseEvent, useCallback } from 'react';
|
|
2
2
|
import { Input, InputProps, Label, makeStyles } from '@fluentui/react-components';
|
|
3
3
|
import {
|
|
4
4
|
ariaDescribedByIds,
|
|
@@ -51,7 +51,9 @@ export default function BaseInputTemplate<
|
|
|
51
51
|
autofocus,
|
|
52
52
|
options,
|
|
53
53
|
schema,
|
|
54
|
+
registry,
|
|
54
55
|
} = props;
|
|
56
|
+
const { ClearButton } = registry.templates.ButtonTemplates;
|
|
55
57
|
const classes = useStyles();
|
|
56
58
|
const inputProps = getInputProps<T, S, F>(schema, type, options);
|
|
57
59
|
// Now we need to pull out the step, min, max into an inner `inputProps` for fluentui-rc
|
|
@@ -59,6 +61,14 @@ export default function BaseInputTemplate<
|
|
|
59
61
|
onChange(value === '' ? options.emptyValue : value);
|
|
60
62
|
const _onBlur = ({ target }: FocusEvent<HTMLInputElement>) => onBlur(id, target && target.value);
|
|
61
63
|
const _onFocus = ({ target }: FocusEvent<HTMLInputElement>) => onFocus(id, target && target.value);
|
|
64
|
+
const _onClear = useCallback(
|
|
65
|
+
(e: MouseEvent) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
onChange(options.emptyValue ?? '');
|
|
69
|
+
},
|
|
70
|
+
[onChange, options.emptyValue],
|
|
71
|
+
);
|
|
62
72
|
return (
|
|
63
73
|
<>
|
|
64
74
|
{labelValue(
|
|
@@ -86,6 +96,9 @@ export default function BaseInputTemplate<
|
|
|
86
96
|
onBlur={_onBlur}
|
|
87
97
|
aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
|
|
88
98
|
/>
|
|
99
|
+
{options.allowClearTextInputs && !readonly && !disabled && value && (
|
|
100
|
+
<ClearButton registry={registry} onClick={_onClear} />
|
|
101
|
+
)}
|
|
89
102
|
{Array.isArray(schema.examples) && (
|
|
90
103
|
<datalist id={examplesId(id)}>
|
|
91
104
|
{(schema.examples as string[])
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Button, ButtonProps } from '@fluentui/react-components';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ArrowSortUpRegular,
|
|
4
|
+
ArrowSortDownRegular,
|
|
5
|
+
CopyRegular,
|
|
6
|
+
SubtractRegular,
|
|
7
|
+
DismissRegular,
|
|
8
|
+
} from '@fluentui/react-icons';
|
|
3
9
|
import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
|
|
4
10
|
|
|
5
11
|
export type FluentIconButtonProps<
|
|
@@ -77,3 +83,18 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
|
|
|
77
83
|
/>
|
|
78
84
|
);
|
|
79
85
|
}
|
|
86
|
+
|
|
87
|
+
export function ClearButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
|
|
88
|
+
props: FluentIconButtonProps<T, S, F>,
|
|
89
|
+
) {
|
|
90
|
+
const {
|
|
91
|
+
registry: { translateString },
|
|
92
|
+
} = props;
|
|
93
|
+
return (
|
|
94
|
+
<FluentIconButton<T, S, F>
|
|
95
|
+
title={translateString(TranslatableString.ClearButton)}
|
|
96
|
+
{...props}
|
|
97
|
+
icon={<DismissRegular />}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
@@ -4,7 +4,7 @@ import ArrayFieldTemplate from '../ArrayFieldTemplate';
|
|
|
4
4
|
import BaseInputTemplate from '../BaseInputTemplate/BaseInputTemplate';
|
|
5
5
|
import DescriptionField from '../DescriptionField';
|
|
6
6
|
import ErrorList from '../ErrorList';
|
|
7
|
-
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton } from '../IconButton';
|
|
7
|
+
import { CopyButton, MoveDownButton, MoveUpButton, RemoveButton, ClearButton } from '../IconButton';
|
|
8
8
|
import FieldErrorTemplate from '../FieldErrorTemplate';
|
|
9
9
|
import FieldHelpTemplate from '../FieldHelpTemplate';
|
|
10
10
|
import FieldTemplate from '../FieldTemplate';
|
|
@@ -33,6 +33,7 @@ export function generateTemplates<
|
|
|
33
33
|
MoveUpButton,
|
|
34
34
|
RemoveButton,
|
|
35
35
|
SubmitButton,
|
|
36
|
+
ClearButton,
|
|
36
37
|
},
|
|
37
38
|
DescriptionFieldTemplate: DescriptionField,
|
|
38
39
|
ErrorListTemplate: ErrorList,
|