@rjsf/primereact 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/primereact",
3
- "version": "6.0.1",
3
+ "version": "6.1.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",
@@ -16,7 +16,7 @@ export default function ArrayFieldItemTemplate<
16
16
  S extends StrictRJSFSchema = RJSFSchema,
17
17
  F extends FormContextType = any,
18
18
  >(props: ArrayFieldItemTemplateProps<T, S, F>) {
19
- const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
19
+ const { children, buttonsProps, displayLabel, hasToolbar, uiSchema, registry } = props;
20
20
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
21
21
  const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
22
22
  'ArrayFieldItemButtonsTemplate',
@@ -26,7 +26,7 @@ export default function ArrayFieldItemTemplate<
26
26
  return (
27
27
  <div style={{ position: 'relative' }}>
28
28
  {hasToolbar && (
29
- <div style={{ position: 'absolute', right: 0, top: '-10px' }}>
29
+ <div style={{ position: 'absolute', right: 0, top: displayLabel ? '24px' : 0 }}>
30
30
  {hasToolbar && (
31
31
  <div style={{ flexDirection: 'row' }}>
32
32
  <ArrayFieldItemButtonsTemplate {...buttonsProps} />
@@ -1,4 +1,5 @@
1
1
  import { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, helpId } from '@rjsf/utils';
2
+ import { RichHelp } from '@rjsf/core';
2
3
 
3
4
  /** The `FieldHelpTemplate` component renders any help desired for a field
4
5
  *
@@ -9,10 +10,13 @@ export default function FieldHelpTemplate<
9
10
  S extends StrictRJSFSchema = RJSFSchema,
10
11
  F extends FormContextType = any,
11
12
  >(props: FieldHelpProps<T, S, F>) {
12
- const { fieldPathId, help } = props;
13
+ const { fieldPathId, help, uiSchema, registry } = props;
13
14
  if (help) {
14
- const id = helpId(fieldPathId);
15
- return <small id={id}>{help}</small>;
15
+ return (
16
+ <small id={helpId(fieldPathId)}>
17
+ <RichHelp help={help} registry={registry} uiSchema={uiSchema} />
18
+ </small>
19
+ );
16
20
  }
17
21
  return null;
18
22
  }
@@ -26,12 +26,13 @@ export default function FieldTemplate<
26
26
  return <div style={{ display: 'none' }}>{children}</div>;
27
27
  }
28
28
 
29
+ const isCheckbox = uiOptions.widget === 'checkbox';
29
30
  return (
30
31
  <WrapIfAdditionalTemplate {...props}>
31
32
  <div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem', marginBottom: '1rem' }}>
32
- {displayLabel && <Label id={props.id} text={props.label} required={props.required} />}
33
+ {displayLabel && !isCheckbox && <Label id={props.id} text={props.label} required={props.required} />}
33
34
  {children}
34
- {displayLabel && rawDescription && <small>{description}</small>}
35
+ {displayLabel && rawDescription && !isCheckbox && <small>{description}</small>}
35
36
  {errors}
36
37
  {help}
37
38
  </div>
@@ -23,10 +23,12 @@ export default function WrapIfAdditionalTemplate<
23
23
  style,
24
24
  children,
25
25
  disabled,
26
+ displayLabel,
26
27
  id,
27
28
  label,
28
29
  onRemoveProperty,
29
30
  onKeyRenameBlur,
31
+ rawDescription,
30
32
  readonly,
31
33
  required,
32
34
  schema,
@@ -36,6 +38,8 @@ export default function WrapIfAdditionalTemplate<
36
38
  const { RemoveButton } = templates.ButtonTemplates;
37
39
  const keyLabel = translateString(TranslatableString.KeyLabel, [label]);
38
40
  const additional = ADDITIONAL_PROPERTY_FLAG in schema;
41
+ const hasDescription = !!rawDescription;
42
+ const margin = hasDescription ? -8 : 12;
39
43
 
40
44
  if (!additional) {
41
45
  return (
@@ -48,13 +52,15 @@ export default function WrapIfAdditionalTemplate<
48
52
  return (
49
53
  <div
50
54
  className={classNames}
51
- style={{ ...style, display: 'flex', alignItems: 'center', gap: '1rem' }}
55
+ style={{ ...style, display: 'flex', alignItems: 'flex-start', gap: '1rem' }}
52
56
  key={`${id}-key`}
53
57
  >
54
58
  <div style={{ flex: 1 }}>
55
- <label htmlFor={`${id}-key`} style={{ display: 'block', marginBottom: '0.5rem' }}>
56
- {keyLabel}
57
- </label>
59
+ {displayLabel && (
60
+ <label htmlFor={`${id}-key`} style={{ display: 'block', marginBottom: '0.5rem' }}>
61
+ {keyLabel}
62
+ </label>
63
+ )}
58
64
  <InputText
59
65
  id={`${id}-key`}
60
66
  name={`${id}-key`}
@@ -66,7 +72,7 @@ export default function WrapIfAdditionalTemplate<
66
72
  />
67
73
  </div>
68
74
  <div style={{ flex: 1 }}>{children}</div>
69
- <div>
75
+ <div style={displayLabel ? { alignSelf: 'center', marginTop: `${margin}px` } : undefined}>
70
76
  <RemoveButton
71
77
  id={buttonId(id, 'remove')}
72
78
  className='rjsf-object-property-remove'