@rjsf/react-bootstrap 6.0.0-beta.8 → 6.0.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.
Files changed (86) hide show
  1. package/README.md +6 -2
  2. package/dist/{index.js → index.cjs} +178 -86
  3. package/dist/index.cjs.map +7 -0
  4. package/dist/react-bootstrap.esm.js +177 -85
  5. package/dist/react-bootstrap.esm.js.map +4 -4
  6. package/dist/react-bootstrap.umd.js +125 -44
  7. package/lib/AddButton/AddButton.js +1 -1
  8. package/lib/AddButton/AddButton.js.map +1 -1
  9. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +2 -2
  10. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
  11. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +3 -4
  12. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
  13. package/lib/BaseInputTemplate/BaseInputTemplate.d.ts +1 -1
  14. package/lib/BaseInputTemplate/BaseInputTemplate.js +2 -2
  15. package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
  16. package/lib/CheckboxWidget/CheckboxWidget.js +2 -2
  17. package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
  18. package/lib/CheckboxesWidget/CheckboxesWidget.d.ts +1 -1
  19. package/lib/CheckboxesWidget/CheckboxesWidget.js +2 -2
  20. package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
  21. package/lib/FieldErrorTemplate/FieldErrorTemplate.js +2 -2
  22. package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
  23. package/lib/FieldHelpTemplate/FieldHelpTemplate.js +2 -2
  24. package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
  25. package/lib/FieldTemplate/FieldTemplate.d.ts +1 -1
  26. package/lib/FieldTemplate/FieldTemplate.js +2 -2
  27. package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
  28. package/lib/IconButton/IconButton.d.ts +6 -5
  29. package/lib/IconButton/IconButton.js +1 -1
  30. package/lib/IconButton/IconButton.js.map +1 -1
  31. package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +2 -0
  32. package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js +6 -0
  33. package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js.map +1 -0
  34. package/lib/MultiSchemaFieldTemplate/index.d.ts +2 -0
  35. package/lib/MultiSchemaFieldTemplate/index.js +3 -0
  36. package/lib/MultiSchemaFieldTemplate/index.js.map +1 -0
  37. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +1 -1
  38. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +3 -2
  39. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
  40. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +10 -0
  41. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +22 -0
  42. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -0
  43. package/lib/OptionalDataControlsTemplate/index.d.ts +2 -0
  44. package/lib/OptionalDataControlsTemplate/index.js +3 -0
  45. package/lib/OptionalDataControlsTemplate/index.js.map +1 -0
  46. package/lib/RadioWidget/RadioWidget.d.ts +1 -1
  47. package/lib/RadioWidget/RadioWidget.js +2 -2
  48. package/lib/RadioWidget/RadioWidget.js.map +1 -1
  49. package/lib/SelectWidget/SelectWidget.d.ts +1 -1
  50. package/lib/SelectWidget/SelectWidget.js +2 -2
  51. package/lib/SelectWidget/SelectWidget.js.map +1 -1
  52. package/lib/Templates/Templates.js +4 -0
  53. package/lib/Templates/Templates.js.map +1 -1
  54. package/lib/TextareaWidget/TextareaWidget.d.ts +1 -1
  55. package/lib/TextareaWidget/TextareaWidget.js +2 -2
  56. package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
  57. package/lib/TitleField/TitleField.d.ts +1 -1
  58. package/lib/TitleField/TitleField.js +9 -2
  59. package/lib/TitleField/TitleField.js.map +1 -1
  60. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +1 -1
  61. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +2 -3
  62. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
  63. package/lib/tsconfig.tsbuildinfo +1 -1
  64. package/package.json +16 -16
  65. package/src/AddButton/AddButton.tsx +1 -1
  66. package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +2 -2
  67. package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +22 -16
  68. package/src/BaseInputTemplate/BaseInputTemplate.tsx +5 -4
  69. package/src/CheckboxWidget/CheckboxWidget.tsx +4 -3
  70. package/src/CheckboxesWidget/CheckboxesWidget.tsx +15 -3
  71. package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +2 -2
  72. package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -2
  73. package/src/FieldTemplate/FieldTemplate.tsx +6 -4
  74. package/src/IconButton/IconButton.tsx +12 -6
  75. package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +15 -0
  76. package/src/MultiSchemaFieldTemplate/index.ts +2 -0
  77. package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +10 -6
  78. package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +47 -0
  79. package/src/OptionalDataControlsTemplate/index.ts +2 -0
  80. package/src/RadioWidget/RadioWidget.tsx +3 -2
  81. package/src/SelectWidget/SelectWidget.tsx +3 -2
  82. package/src/Templates/Templates.ts +4 -0
  83. package/src/TextareaWidget/TextareaWidget.tsx +3 -2
  84. package/src/TitleField/TitleField.tsx +19 -2
  85. package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +5 -7
  86. package/dist/index.js.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/react-bootstrap",
3
- "version": "6.0.0-beta.8",
3
+ "version": "6.0.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -9,27 +9,27 @@
9
9
  "exports": {
10
10
  ".": {
11
11
  "types": "./lib/index.d.ts",
12
- "require": "./dist/index.js",
12
+ "require": "./dist/index.cjs",
13
13
  "import": "./lib/index.js"
14
14
  },
15
15
  "./lib": {
16
16
  "types": "./lib/index.d.ts",
17
- "require": "./dist/index.js",
17
+ "require": "./dist/index.cjs",
18
18
  "import": "./lib/index.js"
19
19
  },
20
20
  "./lib/*.js": {
21
21
  "types": "./lib/*.d.ts",
22
- "require": "./dist/*.js",
22
+ "require": "./dist/*.cjs",
23
23
  "import": "./lib/*.js"
24
24
  },
25
25
  "./dist": {
26
26
  "types": "./lib/index.d.ts",
27
- "require": "./dist/index.js",
27
+ "require": "./dist/index.cjs",
28
28
  "import": "./lib/index.js"
29
29
  },
30
- "./dist/*.js": {
30
+ "./dist/*.cjs": {
31
31
  "types": "./lib/*.d.ts",
32
- "require": "./dist/*.js",
32
+ "require": "./dist/*.cjs",
33
33
  "import": "./lib/*.js"
34
34
  }
35
35
  },
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "scripts": {
46
46
  "build:ts": "tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
47
- "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
47
+ "build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.cjs --sourcemap --packages=external --format=cjs",
48
48
  "build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/react-bootstrap.esm.js --sourcemap --packages=external --format=esm",
49
49
  "build:umd": "rollup dist/react-bootstrap.esm.js --format=umd --file=dist/react-bootstrap.umd.js --name=@rjsf/react-bootstrap",
50
50
  "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
@@ -61,8 +61,8 @@
61
61
  ]
62
62
  },
63
63
  "peerDependencies": {
64
- "@rjsf/core": "^6.0.0-beta",
65
- "@rjsf/utils": "^6.0.0-beta",
64
+ "@rjsf/core": "^6.0.0-beta.23",
65
+ "@rjsf/utils": "^6.0.0-beta.23",
66
66
  "react": ">=18",
67
67
  "react-bootstrap": "^2.x"
68
68
  },
@@ -71,12 +71,12 @@
71
71
  "node": ">=20"
72
72
  },
73
73
  "devDependencies": {
74
- "@rjsf/core": "^6.0.0-beta.8",
75
- "@rjsf/snapshot-tests": "^6.0.0-beta.8",
76
- "@rjsf/utils": "^6.0.0-beta.8",
77
- "@rjsf/validator-ajv8": "^6.0.0-beta.8",
78
- "eslint": "^8.56.0",
79
- "react-bootstrap": "^2.10.9"
74
+ "@rjsf/core": "^6.0.0-beta.23",
75
+ "@rjsf/snapshot-tests": "^6.0.0-beta.23",
76
+ "@rjsf/utils": "^6.0.0-beta.23",
77
+ "@rjsf/validator-ajv8": "^6.0.0-beta.23",
78
+ "eslint": "^8.57.1",
79
+ "react-bootstrap": "^2.10.10"
80
80
  },
81
81
  "publishConfig": {
82
82
  "access": "public"
@@ -10,10 +10,10 @@ export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSche
10
10
  const { translateString } = registry;
11
11
  return (
12
12
  <Button
13
+ title={translateString(TranslatableString.AddItemButton)}
13
14
  {...props}
14
15
  style={{ width: '100%' }}
15
16
  className={`ml-1 ${props.className}`}
16
- title={translateString(TranslatableString.AddItemButton)}
17
17
  >
18
18
  <BsPlus />
19
19
  </Button>
@@ -2,7 +2,7 @@ import { CSSProperties } from 'react';
2
2
  import Row from 'react-bootstrap/Row';
3
3
  import Col from 'react-bootstrap/Col';
4
4
  import {
5
- ArrayFieldItemTemplateType,
5
+ ArrayFieldItemTemplateProps,
6
6
  FormContextType,
7
7
  getTemplate,
8
8
  getUiOptions,
@@ -14,7 +14,7 @@ export default function ArrayFieldItemTemplate<
14
14
  T = any,
15
15
  S extends StrictRJSFSchema = RJSFSchema,
16
16
  F extends FormContextType = any,
17
- >(props: ArrayFieldItemTemplateType<T, S, F>) {
17
+ >(props: ArrayFieldItemTemplateProps<T, S, F>) {
18
18
  const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
19
19
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
20
20
  const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
@@ -2,7 +2,6 @@ import Row from 'react-bootstrap/Row';
2
2
  import Col from 'react-bootstrap/Col';
3
3
  import Container from 'react-bootstrap/Container';
4
4
  import {
5
- ArrayFieldItemTemplateType,
6
5
  ArrayFieldTemplateProps,
7
6
  buttonId,
8
7
  FormContextType,
@@ -17,24 +16,32 @@ export default function ArrayFieldTemplate<
17
16
  S extends StrictRJSFSchema = RJSFSchema,
18
17
  F extends FormContextType = any,
19
18
  >(props: ArrayFieldTemplateProps<T, S, F>) {
20
- const { canAdd, disabled, idSchema, uiSchema, items, onAddClick, readonly, registry, required, schema, title } =
21
- props;
19
+ const {
20
+ canAdd,
21
+ disabled,
22
+ fieldPathId,
23
+ uiSchema,
24
+ items,
25
+ optionalDataControl,
26
+ onAddClick,
27
+ readonly,
28
+ registry,
29
+ required,
30
+ schema,
31
+ title,
32
+ } = props;
22
33
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
23
34
  const ArrayFieldDescriptionTemplate = getTemplate<'ArrayFieldDescriptionTemplate', T, S, F>(
24
35
  'ArrayFieldDescriptionTemplate',
25
36
  registry,
26
37
  uiOptions,
27
38
  );
28
- const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
29
- 'ArrayFieldItemTemplate',
30
- registry,
31
- uiOptions,
32
- );
33
39
  const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
34
40
  'ArrayFieldTitleTemplate',
35
41
  registry,
36
42
  uiOptions,
37
43
  );
44
+ const showOptionalDataControlInTitle = !readonly && !disabled;
38
45
  // Button templates are not overridden in the uiSchema
39
46
  const {
40
47
  ButtonTemplates: { AddButton },
@@ -44,32 +51,31 @@ export default function ArrayFieldTemplate<
44
51
  <Row className='p-0 m-0'>
45
52
  <Col className='p-0 m-0'>
46
53
  <ArrayFieldTitleTemplate
47
- idSchema={idSchema}
54
+ fieldPathId={fieldPathId}
48
55
  title={uiOptions.title || title}
49
56
  schema={schema}
50
57
  uiSchema={uiSchema}
51
58
  required={required}
52
59
  registry={registry}
60
+ optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
53
61
  />
54
62
  <ArrayFieldDescriptionTemplate
55
- idSchema={idSchema}
63
+ fieldPathId={fieldPathId}
56
64
  description={uiOptions.description || schema.description}
57
65
  schema={schema}
58
66
  uiSchema={uiSchema}
59
67
  registry={registry}
60
68
  />
61
- <Container fluid key={`array-item-list-${idSchema.$id}`} className='p-0 m-0'>
62
- {items &&
63
- items.map(({ key, ...itemProps }: ArrayFieldItemTemplateType<T, S, F>) => (
64
- <ArrayFieldItemTemplate key={key} {...itemProps} />
65
- ))}
69
+ <Container fluid key={`array-item-list-${fieldPathId.$id}`} className='p-0 m-0'>
70
+ {!showOptionalDataControlInTitle ? optionalDataControl : undefined}
71
+ {items}
66
72
  {canAdd && (
67
73
  <Container className=''>
68
74
  <Row className='mt-2'>
69
75
  <Col xs={9}></Col>
70
76
  <Col xs={3} className='py-4 col-lg-3 col-3'>
71
77
  <AddButton
72
- id={buttonId<T>(idSchema, 'add')}
78
+ id={buttonId(fieldPathId, 'add')}
73
79
  className='rjsf-array-item-add'
74
80
  onClick={onAddClick}
75
81
  disabled={disabled || readonly}
@@ -16,6 +16,7 @@ export default function BaseInputTemplate<
16
16
  F extends FormContextType = any,
17
17
  >({
18
18
  id,
19
+ htmlName,
19
20
  placeholder,
20
21
  required,
21
22
  readonly,
@@ -47,24 +48,24 @@ export default function BaseInputTemplate<
47
48
  <>
48
49
  <Form.Control
49
50
  id={id}
50
- name={id}
51
+ name={htmlName || id}
51
52
  placeholder={placeholder}
52
53
  autoFocus={autofocus}
53
54
  required={required}
54
55
  disabled={disabled}
55
56
  readOnly={readonly}
56
57
  className={rawErrors.length > 0 ? 'is-invalid' : ''}
57
- list={schema.examples ? examplesId<T>(id) : undefined}
58
+ list={schema.examples ? examplesId(id) : undefined}
58
59
  {...inputProps}
59
60
  value={value || value === 0 ? value : ''}
60
61
  onChange={onChangeOverride || _onChange}
61
62
  onBlur={_onBlur}
62
63
  onFocus={_onFocus}
63
- aria-describedby={ariaDescribedByIds<T>(id, !!schema.examples)}
64
+ aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
64
65
  />
65
66
  {children}
66
67
  {Array.isArray(schema.examples) ? (
67
- <datalist id={examplesId<T>(id)}>
68
+ <datalist id={examplesId(id)}>
68
69
  {(schema.examples as string[])
69
70
  .concat(schema.default && !schema.examples.includes(schema.default) ? ([schema.default] as string[]) : [])
70
71
  .map((example: any) => {
@@ -19,6 +19,7 @@ export default function CheckboxWidget<
19
19
  >(props: WidgetProps<T, S, F>) {
20
20
  const {
21
21
  id,
22
+ htmlName,
22
23
  value,
23
24
  disabled,
24
25
  readonly,
@@ -49,10 +50,10 @@ export default function CheckboxWidget<
49
50
 
50
51
  const description = options.description || schema.description;
51
52
  return (
52
- <Form.Group className={disabled || readonly ? 'disabled' : ''} aria-describedby={ariaDescribedByIds<T>(id)}>
53
+ <Form.Group className={disabled || readonly ? 'disabled' : ''} aria-describedby={ariaDescribedByIds(id)}>
53
54
  {!hideLabel && description && (
54
55
  <DescriptionFieldTemplate
55
- id={descriptionId<T>(id)}
56
+ id={descriptionId(id)}
56
57
  description={description}
57
58
  schema={schema}
58
59
  uiSchema={uiSchema}
@@ -61,7 +62,7 @@ export default function CheckboxWidget<
61
62
  )}
62
63
  <Form.Check
63
64
  id={id}
64
- name={id}
65
+ name={htmlName || id}
65
66
  label={labelValue(label, hideLabel || !label)}
66
67
  checked={typeof value === 'undefined' ? false : value}
67
68
  required={required}
@@ -17,7 +17,19 @@ export default function CheckboxesWidget<
17
17
  T = any,
18
18
  S extends StrictRJSFSchema = RJSFSchema,
19
19
  F extends FormContextType = any,
20
- >({ id, disabled, options, value, autofocus, readonly, required, onChange, onBlur, onFocus }: WidgetProps<T, S, F>) {
20
+ >({
21
+ id,
22
+ htmlName,
23
+ disabled,
24
+ options,
25
+ value,
26
+ autofocus,
27
+ readonly,
28
+ required,
29
+ onChange,
30
+ onBlur,
31
+ onFocus,
32
+ }: WidgetProps<T, S, F>) {
21
33
  const { enumOptions, enumDisabled, inline, emptyValue } = options;
22
34
  const checkboxesValues = Array.isArray(value) ? value : [value];
23
35
 
@@ -52,14 +64,14 @@ export default function CheckboxesWidget<
52
64
  className='bg-transparent border-0'
53
65
  type={'checkbox'}
54
66
  id={optionId(id, index)}
55
- name={id}
67
+ name={htmlName || id}
56
68
  label={option.label}
57
69
  autoFocus={autofocus && index === 0}
58
70
  onChange={_onChange(index)}
59
71
  onBlur={_onBlur}
60
72
  onFocus={_onFocus}
61
73
  disabled={disabled || itemDisabled || readonly}
62
- aria-describedby={ariaDescribedByIds<T>(id)}
74
+ aria-describedby={ariaDescribedByIds(id)}
63
75
  />
64
76
  );
65
77
  })}
@@ -10,11 +10,11 @@ export default function FieldErrorTemplate<
10
10
  S extends StrictRJSFSchema = RJSFSchema,
11
11
  F extends FormContextType = any,
12
12
  >(props: FieldErrorProps<T, S, F>) {
13
- const { errors = [], idSchema } = props;
13
+ const { errors = [], fieldPathId } = props;
14
14
  if (errors.length === 0) {
15
15
  return null;
16
16
  }
17
- const id = errorId<T>(idSchema);
17
+ const id = errorId(fieldPathId);
18
18
 
19
19
  return (
20
20
  <ListGroup as='ul' id={id}>
@@ -10,11 +10,11 @@ export default function FieldHelpTemplate<
10
10
  S extends StrictRJSFSchema = RJSFSchema,
11
11
  F extends FormContextType = any,
12
12
  >(props: FieldHelpProps<T, S, F>) {
13
- const { idSchema, help, hasErrors } = props;
13
+ const { fieldPathId, help, hasErrors } = props;
14
14
  if (!help) {
15
15
  return null;
16
16
  }
17
- const id = helpId<T>(idSchema);
17
+ const id = helpId(fieldPathId);
18
18
  return (
19
19
  <Form.Text className={hasErrors ? 'text-danger' : 'text-muted'} id={id}>
20
20
  {help}
@@ -26,8 +26,9 @@ export default function FieldTemplate<
26
26
  disabled,
27
27
  label,
28
28
  hidden,
29
- onDropPropertyClick,
30
- onKeyChange,
29
+ onKeyRename,
30
+ onKeyRenameBlur,
31
+ onRemoveProperty,
31
32
  readonly,
32
33
  required,
33
34
  schema,
@@ -50,8 +51,9 @@ export default function FieldTemplate<
50
51
  disabled={disabled}
51
52
  id={id}
52
53
  label={label}
53
- onDropPropertyClick={onDropPropertyClick}
54
- onKeyChange={onKeyChange}
54
+ onKeyRename={onKeyRename}
55
+ onKeyRenameBlur={onKeyRenameBlur}
56
+ onRemoveProperty={onRemoveProperty}
55
57
  readonly={readonly}
56
58
  required={required}
57
59
  schema={schema}
@@ -5,8 +5,14 @@ import { IoIosRemove } from '@react-icons/all-files/io/IoIosRemove';
5
5
  import { AiOutlineArrowUp } from '@react-icons/all-files/ai/AiOutlineArrowUp';
6
6
  import { AiOutlineArrowDown } from '@react-icons/all-files/ai/AiOutlineArrowDown';
7
7
 
8
+ export type BootstrapIconButtonProps<
9
+ T = any,
10
+ S extends StrictRJSFSchema = RJSFSchema,
11
+ F extends FormContextType = any,
12
+ > = IconButtonProps<T, S, F> & ButtonProps;
13
+
8
14
  export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
9
- props: IconButtonProps<T, S, F> & ButtonProps,
15
+ props: BootstrapIconButtonProps<T, S, F>,
10
16
  ) {
11
17
  const { icon, iconType, className, uiSchema, registry, ...otherProps } = props;
12
18
  return (
@@ -17,7 +23,7 @@ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSch
17
23
  }
18
24
 
19
25
  export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
20
- props: IconButtonProps<T, S, F>,
26
+ props: BootstrapIconButtonProps<T, S, F>,
21
27
  ) {
22
28
  const {
23
29
  registry: { translateString },
@@ -26,7 +32,7 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
26
32
  }
27
33
 
28
34
  export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
29
- props: IconButtonProps<T, S, F>,
35
+ props: BootstrapIconButtonProps<T, S, F>,
30
36
  ) {
31
37
  const {
32
38
  registry: { translateString },
@@ -37,7 +43,7 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
37
43
  }
38
44
 
39
45
  export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
40
- props: IconButtonProps<T, S, F>,
46
+ props: BootstrapIconButtonProps<T, S, F>,
41
47
  ) {
42
48
  const {
43
49
  registry: { translateString },
@@ -46,7 +52,7 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
46
52
  }
47
53
 
48
54
  export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
49
- props: IconButtonProps<T, S, F>,
55
+ props: BootstrapIconButtonProps<T, S, F>,
50
56
  ) {
51
57
  const {
52
58
  registry: { translateString },
@@ -54,8 +60,8 @@ export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
54
60
  return (
55
61
  <IconButton
56
62
  title={translateString(TranslatableString.RemoveButton)}
57
- {...props}
58
63
  variant='danger'
64
+ {...props}
59
65
  icon={<IoIosRemove />}
60
66
  />
61
67
  );
@@ -0,0 +1,15 @@
1
+ import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import Card from 'react-bootstrap/Card';
3
+
4
+ export default function MultiSchemaFieldTemplate<
5
+ T = any,
6
+ S extends StrictRJSFSchema = RJSFSchema,
7
+ F extends FormContextType = any,
8
+ >({ selector, optionSchemaField }: MultiSchemaFieldTemplateProps<T, S, F>) {
9
+ return (
10
+ <Card style={{ marginBottom: '1rem' }}>
11
+ <Card.Body>{selector}</Card.Body>
12
+ <Card.Body>{optionSchemaField}</Card.Body>
13
+ </Card>
14
+ );
15
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './MultiSchemaFieldTemplate';
2
+ export * from './MultiSchemaFieldTemplate';
@@ -25,10 +25,11 @@ export default function ObjectFieldTemplate<
25
25
  properties,
26
26
  required,
27
27
  uiSchema,
28
- idSchema,
28
+ fieldPathId,
29
29
  schema,
30
30
  formData,
31
- onAddClick,
31
+ optionalDataControl,
32
+ onAddProperty,
32
33
  disabled,
33
34
  readonly,
34
35
  registry,
@@ -40,6 +41,7 @@ export default function ObjectFieldTemplate<
40
41
  registry,
41
42
  uiOptions,
42
43
  );
44
+ const showOptionalDataControlInTitle = !readonly && !disabled;
43
45
  // Button templates are not overridden in the uiSchema
44
46
  const {
45
47
  ButtonTemplates: { AddButton },
@@ -48,17 +50,18 @@ export default function ObjectFieldTemplate<
48
50
  <>
49
51
  {title && (
50
52
  <TitleFieldTemplate
51
- id={titleId<T>(idSchema)}
53
+ id={titleId(fieldPathId)}
52
54
  title={title}
53
55
  required={required}
54
56
  schema={schema}
55
57
  uiSchema={uiSchema}
56
58
  registry={registry}
59
+ optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
57
60
  />
58
61
  )}
59
62
  {description && (
60
63
  <DescriptionFieldTemplate
61
- id={descriptionId<T>(idSchema)}
64
+ id={descriptionId(fieldPathId)}
62
65
  description={description}
63
66
  schema={schema}
64
67
  uiSchema={uiSchema}
@@ -66,6 +69,7 @@ export default function ObjectFieldTemplate<
66
69
  />
67
70
  )}
68
71
  <Container fluid className='p-0'>
72
+ {!showOptionalDataControlInTitle ? optionalDataControl : undefined}
69
73
  {properties.map((element: any, index: number) => (
70
74
  <Row key={index} style={{ marginBottom: '10px' }} className={element.hidden ? 'd-none' : undefined}>
71
75
  <Col xs={12}> {element.content}</Col>
@@ -75,8 +79,8 @@ export default function ObjectFieldTemplate<
75
79
  <Row>
76
80
  <Col xs={{ offset: 9, span: 3 }} className='py-4'>
77
81
  <AddButton
78
- id={buttonId<T>(idSchema, 'add')}
79
- onClick={onAddClick(schema)}
82
+ id={buttonId(fieldPathId, 'add')}
83
+ onClick={onAddProperty}
80
84
  disabled={disabled || readonly}
81
85
  className='rjsf-object-property-expand'
82
86
  uiSchema={uiSchema}
@@ -0,0 +1,47 @@
1
+ import { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+ import { BsPlus } from '@react-icons/all-files/bs/BsPlus';
3
+
4
+ import IconButton, { RemoveButton } from '../IconButton';
5
+
6
+ /** The OptionalDataControlsTemplate renders one of three different states. If
7
+ * there is an `onAddClick()` function, it renders the "Add" button. If there is
8
+ * an `onRemoveClick()` function, it renders the "Remove" button. Otherwise it
9
+ * renders the "No data found" section. All of them use the `label` as either
10
+ * the `title` of buttons or simply outputting it.
11
+ *
12
+ * @param props - The `OptionalDataControlsTemplateProps` for the template
13
+ */
14
+ export default function OptionalDataControlsTemplate<
15
+ T = any,
16
+ S extends StrictRJSFSchema = RJSFSchema,
17
+ F extends FormContextType = any,
18
+ >(props: OptionalDataControlsTemplateProps<T, S, F>) {
19
+ const { id, registry, label, onAddClick, onRemoveClick } = props;
20
+ if (onAddClick) {
21
+ return (
22
+ <IconButton
23
+ id={id}
24
+ registry={registry}
25
+ className='rjsf-add-optional-data'
26
+ icon={<BsPlus />}
27
+ onClick={onAddClick}
28
+ title={label}
29
+ size='sm'
30
+ variant='secondary'
31
+ />
32
+ );
33
+ } else if (onRemoveClick) {
34
+ return (
35
+ <RemoveButton
36
+ id={id}
37
+ registry={registry}
38
+ className='rjsf-remove-optional-data'
39
+ onClick={onRemoveClick}
40
+ title={label}
41
+ size='sm'
42
+ variant='secondary'
43
+ />
44
+ );
45
+ }
46
+ return <em id={id}>{label}</em>;
47
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './OptionalDataControlsTemplate';
2
+ export * from './OptionalDataControlsTemplate';
@@ -13,6 +13,7 @@ import {
13
13
 
14
14
  export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
15
15
  id,
16
+ htmlName,
16
17
  options,
17
18
  value,
18
19
  required,
@@ -46,7 +47,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
46
47
  label={option.label}
47
48
  id={optionId(id, index)}
48
49
  key={index}
49
- name={id}
50
+ name={htmlName || id}
50
51
  type='radio'
51
52
  disabled={disabled || itemDisabled || readonly}
52
53
  checked={checked}
@@ -55,7 +56,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
55
56
  onChange={_onChange}
56
57
  onBlur={_onBlur}
57
58
  onFocus={_onFocus}
58
- aria-describedby={ariaDescribedByIds<T>(id)}
59
+ aria-describedby={ariaDescribedByIds(id)}
59
60
  />
60
61
  );
61
62
  return radio;
@@ -17,6 +17,7 @@ export default function SelectWidget<
17
17
  >({
18
18
  schema,
19
19
  id,
20
+ htmlName,
20
21
  options,
21
22
  required,
22
23
  disabled,
@@ -50,7 +51,7 @@ export default function SelectWidget<
50
51
  return (
51
52
  <FormSelect
52
53
  id={id}
53
- name={id}
54
+ name={htmlName || id}
54
55
  value={typeof selectedIndexes === 'undefined' ? emptyValue : selectedIndexes}
55
56
  required={required}
56
57
  multiple={multiple}
@@ -75,7 +76,7 @@ export default function SelectWidget<
75
76
  const newValue = getValue(event, multiple);
76
77
  onChange(enumOptionsValueForIndex<S>(newValue, enumOptions, optEmptyValue));
77
78
  }}
78
- aria-describedby={ariaDescribedByIds<T>(id)}
79
+ aria-describedby={ariaDescribedByIds(id)}
79
80
  >
80
81
  {showPlaceholderOption && <option value=''>{placeholder}</option>}
81
82
  {(enumOptions as any).map(({ value, label }: any, i: number) => {
@@ -9,7 +9,9 @@ import FieldErrorTemplate from '../FieldErrorTemplate';
9
9
  import FieldHelpTemplate from '../FieldHelpTemplate';
10
10
  import FieldTemplate from '../FieldTemplate';
11
11
  import GridTemplate from '../GridTemplate';
12
+ import MultiSchemaFieldTemplate from '../MultiSchemaFieldTemplate';
12
13
  import ObjectFieldTemplate from '../ObjectFieldTemplate';
14
+ import OptionalDataControlsTemplate from '../OptionalDataControlsTemplate';
13
15
  import SubmitButton from '../SubmitButton';
14
16
  import TitleField from '../TitleField';
15
17
  import WrapIfAdditionalTemplate from '../WrapIfAdditionalTemplate';
@@ -38,7 +40,9 @@ export function generateTemplates<
38
40
  FieldHelpTemplate,
39
41
  FieldTemplate,
40
42
  GridTemplate,
43
+ MultiSchemaFieldTemplate,
41
44
  ObjectFieldTemplate,
45
+ OptionalDataControlsTemplate,
42
46
  TitleFieldTemplate: TitleField,
43
47
  WrapIfAdditionalTemplate,
44
48
  };
@@ -17,6 +17,7 @@ export default function TextareaWidget<
17
17
  F extends FormContextType = any,
18
18
  >({
19
19
  id,
20
+ htmlName,
20
21
  placeholder,
21
22
  value,
22
23
  required,
@@ -37,7 +38,7 @@ export default function TextareaWidget<
37
38
  <InputGroup>
38
39
  <FormControl
39
40
  id={id}
40
- name={id}
41
+ name={htmlName || id}
41
42
  as='textarea'
42
43
  placeholder={placeholder}
43
44
  disabled={disabled}
@@ -49,7 +50,7 @@ export default function TextareaWidget<
49
50
  onChange={_onChange}
50
51
  onBlur={_onBlur}
51
52
  onFocus={_onFocus}
52
- aria-describedby={ariaDescribedByIds<T>(id)}
53
+ aria-describedby={ariaDescribedByIds(id)}
53
54
  />
54
55
  </InputGroup>
55
56
  );