@rjsf/fluentui-rc 6.0.1 → 6.1.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/core.umd.js +35 -12
- package/dist/index.cjs +38 -14
- package/dist/index.cjs.map +3 -3
- package/dist/index.esm.js +36 -12
- package/dist/index.esm.js.map +2 -2
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +2 -2
- package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js +3 -3
- package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
- package/lib/FieldTemplate/FieldTemplate.js +2 -1
- package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +24 -4
- package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +3 -3
- package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +8 -3
- package/src/FieldTemplate/FieldTemplate.tsx +4 -1
- package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +29 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rjsf/fluentui-rc",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
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",
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"react": ">=18"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@fluentui/react-components": "^9.72.
|
|
76
|
+
"@fluentui/react-components": "^9.72.4",
|
|
77
77
|
"@fluentui/react-icons": "^2.0.313",
|
|
78
|
-
"@fluentui/react-migration-v0-v9": "^9.6.
|
|
78
|
+
"@fluentui/react-migration-v0-v9": "^9.6.12",
|
|
79
79
|
"@rjsf/core": "^6.x",
|
|
80
80
|
"@rjsf/snapshot-tests": "^6.x",
|
|
81
81
|
"@rjsf/utils": "^6.x",
|
|
@@ -27,7 +27,7 @@ export default function ArrayFieldItemTemplate<
|
|
|
27
27
|
F extends FormContextType = any,
|
|
28
28
|
>(props: ArrayFieldItemTemplateProps<T, S, F>) {
|
|
29
29
|
const classes = useStyles();
|
|
30
|
-
const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
|
|
30
|
+
const { children, buttonsProps, displayLabel, hasToolbar, uiSchema, registry } = props;
|
|
31
31
|
const uiOptions = getUiOptions<T, S, F>(uiSchema);
|
|
32
32
|
const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
|
|
33
33
|
'ArrayFieldItemButtonsTemplate',
|
|
@@ -36,12 +36,12 @@ export default function ArrayFieldItemTemplate<
|
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
|
-
<Flex vAlign='
|
|
39
|
+
<Flex vAlign='start'>
|
|
40
40
|
<Flex fill className={classes.arrayFieldItem}>
|
|
41
41
|
{children}
|
|
42
42
|
</Flex>
|
|
43
43
|
{hasToolbar && (
|
|
44
|
-
<Flex style={{ marginLeft: '8px' }}>
|
|
44
|
+
<Flex style={{ marginLeft: '8px', marginTop: displayLabel ? '26px' : 0 }}>
|
|
45
45
|
<ArrayFieldItemButtonsTemplate {...buttonsProps} />
|
|
46
46
|
</Flex>
|
|
47
47
|
)}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Caption1 } from '@fluentui/react-components';
|
|
2
2
|
import { helpId, FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
|
|
3
|
+
import { RichHelp } from '@rjsf/core';
|
|
3
4
|
|
|
4
5
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
5
6
|
*
|
|
@@ -10,10 +11,14 @@ export default function FieldHelpTemplate<
|
|
|
10
11
|
S extends StrictRJSFSchema = RJSFSchema,
|
|
11
12
|
F extends FormContextType = any,
|
|
12
13
|
>(props: FieldHelpProps<T, S, F>) {
|
|
13
|
-
const { fieldPathId, help } = props;
|
|
14
|
+
const { fieldPathId, help, uiSchema = {}, registry } = props;
|
|
15
|
+
|
|
14
16
|
if (!help) {
|
|
15
17
|
return null;
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
return (
|
|
20
|
+
<Caption1 id={helpId(fieldPathId)}>
|
|
21
|
+
<RichHelp help={help} registry={registry} uiSchema={uiSchema} />
|
|
22
|
+
</Caption1>
|
|
23
|
+
);
|
|
19
24
|
}
|
|
@@ -51,6 +51,7 @@ export default function FieldTemplate<
|
|
|
51
51
|
if (hidden) {
|
|
52
52
|
return <div style={{ display: 'none' }}>{children}</div>;
|
|
53
53
|
}
|
|
54
|
+
const isCheckbox = uiOptions.widget === 'checkbox';
|
|
54
55
|
return (
|
|
55
56
|
<WrapIfAdditionalTemplate
|
|
56
57
|
classNames={classNames}
|
|
@@ -58,6 +59,8 @@ export default function FieldTemplate<
|
|
|
58
59
|
disabled={disabled}
|
|
59
60
|
id={id}
|
|
60
61
|
label={label}
|
|
62
|
+
displayLabel={displayLabel}
|
|
63
|
+
rawDescription={rawDescription}
|
|
61
64
|
onKeyRename={onKeyRename}
|
|
62
65
|
onKeyRenameBlur={onKeyRenameBlur}
|
|
63
66
|
onRemoveProperty={onRemoveProperty}
|
|
@@ -69,7 +72,7 @@ export default function FieldTemplate<
|
|
|
69
72
|
>
|
|
70
73
|
<Field validationState={rawErrors.length ? 'error' : undefined} required={required}>
|
|
71
74
|
{children}
|
|
72
|
-
{displayLabel && rawDescription ? (
|
|
75
|
+
{displayLabel && rawDescription && !isCheckbox ? (
|
|
73
76
|
<Text as='p' block style={{ marginTop: 0, marginBottom: 0 }}>
|
|
74
77
|
{description}
|
|
75
78
|
</Text>
|
|
@@ -15,11 +15,28 @@ const useStyles = makeStyles({
|
|
|
15
15
|
input: {
|
|
16
16
|
width: '100%',
|
|
17
17
|
},
|
|
18
|
+
grow: {
|
|
19
|
+
flexGrow: 1,
|
|
20
|
+
},
|
|
21
|
+
halfWidth: {
|
|
22
|
+
width: '46%',
|
|
23
|
+
},
|
|
24
|
+
alignEnd: {
|
|
25
|
+
alignSelf: 'flex-end',
|
|
26
|
+
justifyContent: 'flex-end',
|
|
27
|
+
},
|
|
28
|
+
alignCenter: {
|
|
29
|
+
alignSelf: 'center',
|
|
30
|
+
marginTop: '-14px',
|
|
31
|
+
justifyContent: 'flex-end',
|
|
32
|
+
},
|
|
18
33
|
label: {
|
|
19
34
|
marginBottom: '4px',
|
|
20
35
|
},
|
|
21
36
|
});
|
|
22
37
|
|
|
38
|
+
const containerTypes = ['object', 'array'];
|
|
39
|
+
|
|
23
40
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
24
41
|
* part of an `additionalProperties` part of a schema.
|
|
25
42
|
*
|
|
@@ -37,8 +54,10 @@ export default function WrapIfAdditionalTemplate<
|
|
|
37
54
|
disabled,
|
|
38
55
|
id,
|
|
39
56
|
label,
|
|
57
|
+
displayLabel,
|
|
40
58
|
onRemoveProperty,
|
|
41
59
|
onKeyRenameBlur,
|
|
60
|
+
rawDescription,
|
|
42
61
|
readonly,
|
|
43
62
|
required,
|
|
44
63
|
schema,
|
|
@@ -51,6 +70,7 @@ export default function WrapIfAdditionalTemplate<
|
|
|
51
70
|
const { RemoveButton } = templates.ButtonTemplates;
|
|
52
71
|
const keyLabel = translateString(TranslatableString.KeyLabel, [label]);
|
|
53
72
|
const additional = ADDITIONAL_PROPERTY_FLAG in schema;
|
|
73
|
+
const hasDescription = !!rawDescription;
|
|
54
74
|
const btnStyle: CSSProperties = {
|
|
55
75
|
flex: 1,
|
|
56
76
|
paddingLeft: 6,
|
|
@@ -59,17 +79,20 @@ export default function WrapIfAdditionalTemplate<
|
|
|
59
79
|
};
|
|
60
80
|
|
|
61
81
|
if (!additional) {
|
|
82
|
+
const { type } = schema;
|
|
83
|
+
// Flex grow only non container classes
|
|
84
|
+
const className = containerTypes.includes(type as string) ? classNames : `${classes.grow} ${classNames}`;
|
|
62
85
|
return (
|
|
63
|
-
<div className={
|
|
86
|
+
<div className={className} style={style}>
|
|
64
87
|
{children}
|
|
65
88
|
</div>
|
|
66
89
|
);
|
|
67
90
|
}
|
|
68
91
|
|
|
69
92
|
return (
|
|
70
|
-
<Flex gap='gap.medium' vAlign='
|
|
71
|
-
<div>
|
|
72
|
-
<Field label={keyLabel} required={required}>
|
|
93
|
+
<Flex gap='gap.medium' vAlign='start' key={`${id}-key`} className={classNames} style={style}>
|
|
94
|
+
<div className={classes.halfWidth}>
|
|
95
|
+
<Field label={displayLabel ? keyLabel : undefined} required={required}>
|
|
73
96
|
<Input
|
|
74
97
|
required={required}
|
|
75
98
|
defaultValue={label}
|
|
@@ -84,8 +107,8 @@ export default function WrapIfAdditionalTemplate<
|
|
|
84
107
|
/>
|
|
85
108
|
</Field>
|
|
86
109
|
</div>
|
|
87
|
-
<div>{children}</div>
|
|
88
|
-
<div>
|
|
110
|
+
<div className={classes.halfWidth}>{children}</div>
|
|
111
|
+
<div className={hasDescription ? classes.alignCenter : classes.alignEnd}>
|
|
89
112
|
<RemoveButton
|
|
90
113
|
id={buttonId(id, 'remove')}
|
|
91
114
|
iconType='default'
|