@rjsf/react-bootstrap 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/react-bootstrap",
3
- "version": "6.0.2",
3
+ "version": "6.1.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -15,7 +15,7 @@ export default function ArrayFieldItemTemplate<
15
15
  S extends StrictRJSFSchema = RJSFSchema,
16
16
  F extends FormContextType = any,
17
17
  >(props: ArrayFieldItemTemplateProps<T, S, F>) {
18
- const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
18
+ const { children, buttonsProps, displayLabel, hasDescription, hasToolbar, uiSchema, registry } = props;
19
19
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
20
20
  const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
21
21
  'ArrayFieldItemButtonsTemplate',
@@ -28,13 +28,14 @@ export default function ArrayFieldItemTemplate<
28
28
  paddingRight: 6,
29
29
  fontWeight: 'bold',
30
30
  };
31
+ const padding = hasDescription ? 'pb-1' : 'pt-4 mt-2';
31
32
  return (
32
33
  <div>
33
34
  <Row className='mb-2 d-flex align-items-center'>
34
- <Col xs='9' lg='9'>
35
+ <Col xs='8' md='9' lg='10'>
35
36
  {children}
36
37
  </Col>
37
- <Col xs='3' lg='3' className='py-4'>
38
+ <Col xs='4' md='3' lg='2' className={displayLabel ? padding : 'py-4'}>
38
39
  {hasToolbar && (
39
40
  <div className='d-flex flex-row'>
40
41
  <ArrayFieldItemButtonsTemplate {...buttonsProps} style={btnStyle} />
@@ -72,8 +72,8 @@ export default function ArrayFieldTemplate<
72
72
  {canAdd && (
73
73
  <Container className=''>
74
74
  <Row className='mt-2'>
75
- <Col xs={9}></Col>
76
- <Col xs={3} className='py-4 col-lg-3 col-3'>
75
+ <Col xs={9} md={10} lg={11}></Col>
76
+ <Col xs={3} md={2} lg={1} className='py-4'>
77
77
  <AddButton
78
78
  id={buttonId(fieldPathId, 'add')}
79
79
  className='rjsf-array-item-add'
@@ -1,4 +1,5 @@
1
1
  import { FieldHelpProps, FormContextType, RJSFSchema, StrictRJSFSchema, helpId } from '@rjsf/utils';
2
+ import { RichHelp } from '@rjsf/core';
2
3
  import Form from 'react-bootstrap/Form';
3
4
 
4
5
  /** The `FieldHelpTemplate` component renders any help desired for a field
@@ -10,14 +11,13 @@ 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, hasErrors } = props;
14
+ const { fieldPathId, help, uiSchema, registry, hasErrors } = props;
14
15
  if (!help) {
15
16
  return null;
16
17
  }
17
- const id = helpId(fieldPathId);
18
18
  return (
19
- <Form.Text className={hasErrors ? 'text-danger' : 'text-muted'} id={id}>
20
- {help}
19
+ <Form.Text id={helpId(fieldPathId)} className={hasErrors ? 'text-danger' : 'text-muted'}>
20
+ <RichHelp help={help} registry={registry} uiSchema={uiSchema} />
21
21
  </Form.Text>
22
22
  );
23
23
  }
@@ -53,6 +53,8 @@ export default function FieldTemplate<
53
53
  disabled={disabled}
54
54
  id={id}
55
55
  label={label}
56
+ displayLabel={displayLabel}
57
+ rawDescription={rawDescription}
56
58
  onKeyRename={onKeyRename}
57
59
  onKeyRenameBlur={onKeyRenameBlur}
58
60
  onRemoveProperty={onRemoveProperty}
@@ -77,7 +77,7 @@ export default function ObjectFieldTemplate<
77
77
  ))}
78
78
  {canExpand(schema, uiSchema, formData) ? (
79
79
  <Row>
80
- <Col xs={{ offset: 9, span: 3 }} className='py-4'>
80
+ <Col xs={{ offset: 11, span: 1 }} className='py-0.5'>
81
81
  <AddButton
82
82
  id={buttonId(fieldPathId, 'add')}
83
83
  onClick={onAddProperty}
@@ -23,8 +23,10 @@ export default function WrapIfAdditionalTemplate<
23
23
  disabled,
24
24
  id,
25
25
  label,
26
+ displayLabel,
26
27
  onRemoveProperty,
27
28
  onKeyRenameBlur,
29
+ rawDescription,
28
30
  readonly,
29
31
  required,
30
32
  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 descPadding = rawDescription ? 1 : 0;
42
+ const descMargin = rawDescription ? -24 : 0;
39
43
 
40
44
  if (!additional) {
41
45
  return (
@@ -46,12 +50,14 @@ export default function WrapIfAdditionalTemplate<
46
50
  }
47
51
 
48
52
  const keyId = `${id}-key`;
53
+ const margin = displayLabel ? 12 + descMargin : 0;
54
+ const padding = displayLabel ? 4 + descPadding : 1;
49
55
 
50
56
  return (
51
57
  <Row className={classNames} style={style} key={keyId}>
52
58
  <Col xs={5}>
53
59
  <Form.Group>
54
- <Form.Label htmlFor={keyId}>{keyLabel}</Form.Label>
60
+ {displayLabel && <Form.Label htmlFor={keyId}>{keyLabel}</Form.Label>}
55
61
  <Form.Control
56
62
  required={required}
57
63
  defaultValue={label}
@@ -63,8 +69,8 @@ export default function WrapIfAdditionalTemplate<
63
69
  />
64
70
  </Form.Group>
65
71
  </Col>
66
- <Col xs={5}>{children}</Col>
67
- <Col xs={2} className='py-4 d-grid gap-2'>
72
+ <Col xs={6}>{children}</Col>
73
+ <Col xs={1} className={`py-${padding} d-grid gap-2`} style={{ marginTop: `${margin}px` }}>
68
74
  <RemoveButton
69
75
  id={buttonId(id, 'remove')}
70
76
  className='rjsf-object-property-remove w-100'