@rjsf/fluentui-rc 6.0.2 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/fluentui-rc",
3
- "version": "6.0.2",
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",
@@ -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='end'>
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
- const id = helpId(fieldPathId);
18
- return <Caption1 id={id}>{help}</Caption1>;
19
+ return (
20
+ <Caption1 id={helpId(fieldPathId)}>
21
+ <RichHelp help={help} registry={registry} uiSchema={uiSchema} />
22
+ </Caption1>
23
+ );
19
24
  }
@@ -59,6 +59,8 @@ export default function FieldTemplate<
59
59
  disabled={disabled}
60
60
  id={id}
61
61
  label={label}
62
+ displayLabel={displayLabel}
63
+ rawDescription={rawDescription}
62
64
  onKeyRename={onKeyRename}
63
65
  onKeyRenameBlur={onKeyRenameBlur}
64
66
  onRemoveProperty={onRemoveProperty}
@@ -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={classNames} style={style}>
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='center' key={`${id}-key`} className={classNames} style={style}>
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'