@rjsf/primereact 6.0.0-beta.20 → 6.0.0-beta.22

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 (63) hide show
  1. package/dist/index.cjs +141 -91
  2. package/dist/index.cjs.map +4 -4
  3. package/dist/primereact.esm.js +133 -84
  4. package/dist/primereact.esm.js.map +4 -4
  5. package/dist/primereact.umd.js +87 -40
  6. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +3 -3
  7. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +1 -1
  8. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
  9. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
  10. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +5 -14
  11. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
  12. package/lib/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.d.ts +1 -1
  13. package/lib/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js +7 -3
  14. package/lib/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js.map +1 -1
  15. package/lib/BaseInputTemplate/BaseInputTemplate.js +2 -2
  16. package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
  17. package/lib/CheckboxWidget/CheckboxWidget.js +2 -2
  18. package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
  19. package/lib/CheckboxesWidget/CheckboxesWidget.js +2 -2
  20. package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
  21. package/lib/IconButton/IconButton.d.ts +7 -6
  22. package/lib/IconButton/IconButton.js +1 -2
  23. package/lib/IconButton/IconButton.js.map +1 -1
  24. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +3 -2
  25. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -1
  26. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.d.ts +10 -0
  27. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js +21 -0
  28. package/lib/OptionalDataControlsTemplate/OptionalDataControlsTemplate.js.map +1 -0
  29. package/lib/OptionalDataControlsTemplate/index.d.ts +2 -0
  30. package/lib/OptionalDataControlsTemplate/index.js +3 -0
  31. package/lib/OptionalDataControlsTemplate/index.js.map +1 -0
  32. package/lib/RadioWidget/RadioWidget.js +2 -2
  33. package/lib/RadioWidget/RadioWidget.js.map +1 -1
  34. package/lib/SelectWidget/SelectWidget.js +5 -5
  35. package/lib/SelectWidget/SelectWidget.js.map +1 -1
  36. package/lib/Templates/Templates.js +2 -0
  37. package/lib/Templates/Templates.js.map +1 -1
  38. package/lib/TextareaWidget/TextareaWidget.js +2 -2
  39. package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
  40. package/lib/TitleField/TitleField.d.ts +1 -1
  41. package/lib/TitleField/TitleField.js +6 -2
  42. package/lib/TitleField/TitleField.js.map +1 -1
  43. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +1 -1
  44. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +2 -3
  45. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
  46. package/lib/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +7 -7
  48. package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +3 -3
  49. package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +6 -18
  50. package/src/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.tsx +11 -2
  51. package/src/BaseInputTemplate/BaseInputTemplate.tsx +2 -1
  52. package/src/CheckboxWidget/CheckboxWidget.tsx +2 -1
  53. package/src/CheckboxesWidget/CheckboxesWidget.tsx +2 -1
  54. package/src/IconButton/IconButton.tsx +13 -9
  55. package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +6 -2
  56. package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +44 -0
  57. package/src/OptionalDataControlsTemplate/index.ts +2 -0
  58. package/src/RadioWidget/RadioWidget.tsx +2 -2
  59. package/src/SelectWidget/SelectWidget.tsx +4 -3
  60. package/src/Templates/Templates.ts +2 -0
  61. package/src/TextareaWidget/TextareaWidget.tsx +2 -1
  62. package/src/TitleField/TitleField.tsx +15 -3
  63. package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +4 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/primereact",
3
- "version": "6.0.0-beta.20",
3
+ "version": "6.0.0-beta.22",
4
4
  "description": "PrimeReact theme, fields and widgets for react-jsonschema-form",
5
5
  "main": "dist/index.js",
6
6
  "module": "lib/index.js",
@@ -61,17 +61,17 @@
61
61
  "node": ">=20"
62
62
  },
63
63
  "peerDependencies": {
64
- "@rjsf/core": "^6.0.0-beta.20",
65
- "@rjsf/utils": "^6.0.0-beta.20",
64
+ "@rjsf/core": "^6.0.0-beta.22",
65
+ "@rjsf/utils": "^6.0.0-beta.22",
66
66
  "primeicons": ">=6.0.0",
67
67
  "primereact": ">=8.0.0",
68
68
  "react": ">=18"
69
69
  },
70
70
  "devDependencies": {
71
- "@rjsf/core": "^6.0.0-beta.20",
72
- "@rjsf/snapshot-tests": "^6.0.0-beta.20",
73
- "@rjsf/utils": "^6.0.0-beta.20",
74
- "@rjsf/validator-ajv8": "^6.0.0-beta.20",
71
+ "@rjsf/core": "^6.0.0-beta.22",
72
+ "@rjsf/snapshot-tests": "^6.0.0-beta.22",
73
+ "@rjsf/utils": "^6.0.0-beta.22",
74
+ "@rjsf/validator-ajv8": "^6.0.0-beta.22",
75
75
  "@rollup/plugin-replace": "^6.0.2",
76
76
  "eslint": "^8.57.1",
77
77
  "primeflex": "^4.0.0",
@@ -1,5 +1,5 @@
1
1
  import {
2
- ArrayFieldItemTemplateType,
2
+ ArrayFieldItemTemplateProps,
3
3
  FormContextType,
4
4
  getTemplate,
5
5
  getUiOptions,
@@ -9,13 +9,13 @@ import {
9
9
 
10
10
  /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
11
11
  *
12
- * @param props - The `ArrayFieldItemTemplateType` props for the component
12
+ * @param props - The `ArrayFieldItemTemplateProps` props for the component
13
13
  */
14
14
  export default function ArrayFieldItemTemplate<
15
15
  T = any,
16
16
  S extends StrictRJSFSchema = RJSFSchema,
17
17
  F extends FormContextType = any,
18
- >(props: ArrayFieldItemTemplateType<T, S, F>) {
18
+ >(props: ArrayFieldItemTemplateProps<T, S, F>) {
19
19
  const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
20
20
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
21
21
  const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
@@ -3,11 +3,9 @@ import {
3
3
  getUiOptions,
4
4
  isFixedItems,
5
5
  ArrayFieldTemplateProps,
6
- ArrayFieldItemTemplateType,
7
6
  FormContextType,
8
7
  RJSFSchema,
9
8
  StrictRJSFSchema,
10
- UI_OPTIONS_KEY,
11
9
  buttonId,
12
10
  } from '@rjsf/utils';
13
11
  import { Fieldset } from 'primereact/fieldset';
@@ -15,7 +13,7 @@ import AddButton from '../AddButton';
15
13
 
16
14
  /** The `ArrayFieldTemplate` component is the template used to render all items in an array.
17
15
  *
18
- * @param props - The `ArrayFieldItemTemplateType` props for the component
16
+ * @param props - The `ArrayFieldTemplateProps` props for the component
19
17
  */
20
18
  export default function ArrayFieldTemplate<
21
19
  T = any,
@@ -29,6 +27,7 @@ export default function ArrayFieldTemplate<
29
27
  className,
30
28
  disabled,
31
29
  items,
30
+ optionalDataControl,
32
31
  onAddClick,
33
32
  readonly,
34
33
  schema,
@@ -44,16 +43,12 @@ export default function ArrayFieldTemplate<
44
43
  registry,
45
44
  uiOptions,
46
45
  );
47
- const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
48
- 'ArrayFieldItemTemplate',
49
- registry,
50
- uiOptions,
51
- );
52
46
  const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
53
47
  'ArrayFieldTitleTemplate',
54
48
  registry,
55
49
  uiOptions,
56
50
  );
51
+ const showOptionalDataControlInTitle = !readonly && !disabled;
57
52
 
58
53
  return (
59
54
  <>
@@ -64,6 +59,7 @@ export default function ArrayFieldTemplate<
64
59
  uiSchema={uiSchema}
65
60
  required={required}
66
61
  registry={registry}
62
+ optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
67
63
  />
68
64
  <Fieldset
69
65
  {...rest}
@@ -79,16 +75,8 @@ export default function ArrayFieldTemplate<
79
75
  />
80
76
  <div key={`array-item-list-${fieldPathId.$id}`}>
81
77
  <div>
82
- {items &&
83
- items.map(({ key, uiSchema: itemUiSchema = {}, ...props }: ArrayFieldItemTemplateType<T, S, F>) => {
84
- const mergedUiSchema = {
85
- ...itemUiSchema,
86
- [UI_OPTIONS_KEY]: {
87
- ...itemUiSchema[UI_OPTIONS_KEY],
88
- },
89
- };
90
- return <ArrayFieldItemTemplate key={key} {...props} uiSchema={mergedUiSchema} />;
91
- })}
78
+ {!showOptionalDataControlInTitle ? optionalDataControl : undefined}
79
+ {items}
92
80
  </div>
93
81
  {canAdd && (
94
82
  <div
@@ -15,11 +15,20 @@ export default function ArrayFieldTitleTemplate<
15
15
  T = any,
16
16
  S extends StrictRJSFSchema = RJSFSchema,
17
17
  F extends FormContextType = any,
18
- >({ title, uiSchema, required, fieldPathId }: ArrayFieldTitleProps<T, S, F>) {
18
+ >({ title, uiSchema, required, fieldPathId, optionalDataControl }: ArrayFieldTitleProps<T, S, F>) {
19
19
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
20
- return (
20
+ let heading = (
21
21
  <h5 id={titleId(fieldPathId)} style={{ margin: 0, fontSize: '1.5rem', marginBottom: '0.2rem' }}>
22
22
  {uiOptions.title || title} {required ? '*' : ''}
23
23
  </h5>
24
24
  );
25
+ if (optionalDataControl) {
26
+ heading = (
27
+ <div style={{ display: 'flex' }}>
28
+ <div style={{ flexGrow: 1 }}>{heading}</div>
29
+ <div>{optionalDataControl}</div>
30
+ </div>
31
+ );
32
+ }
33
+ return heading;
25
34
  }
@@ -19,6 +19,7 @@ export default function BaseInputTemplate<
19
19
  >(props: BaseInputTemplateProps<T, S, F>) {
20
20
  const {
21
21
  id,
22
+ htmlName,
22
23
  placeholder,
23
24
  value,
24
25
  required,
@@ -52,7 +53,7 @@ export default function BaseInputTemplate<
52
53
  return (
53
54
  <InputText
54
55
  id={id}
55
- name={id}
56
+ name={htmlName || id}
56
57
  placeholder={placeholder}
57
58
  {...primeProps}
58
59
  {...inputProps}
@@ -25,6 +25,7 @@ export default function CheckboxWidget<
25
25
  >(props: WidgetProps<T, S, F>) {
26
26
  const {
27
27
  id,
28
+ htmlName,
28
29
  value,
29
30
  disabled,
30
31
  readonly,
@@ -68,7 +69,7 @@ export default function CheckboxWidget<
68
69
  <div style={{ display: 'flex', flexDirection: 'row', gap: '0.5rem', alignItems: 'center' }}>
69
70
  <Checkbox
70
71
  inputId={id}
71
- name={id}
72
+ name={htmlName || id}
72
73
  {...primeProps}
73
74
  disabled={disabled || readonly}
74
75
  autoFocus={autofocus}
@@ -27,6 +27,7 @@ export default function CheckboxesWidget<
27
27
  >(props: WidgetProps<T, S, F>) {
28
28
  const {
29
29
  id,
30
+ htmlName,
30
31
  disabled,
31
32
  options,
32
33
  value,
@@ -85,7 +86,7 @@ export default function CheckboxesWidget<
85
86
  <div key={index} style={{ display: 'flex', flexDirection: 'row', gap: '0.5rem', alignItems: 'center' }}>
86
87
  <Checkbox
87
88
  inputId={optionId(id, index)}
88
- name={id}
89
+ name={htmlName || id}
89
90
  {...primeProps}
90
91
  value={option.value}
91
92
  checked={checked}
@@ -1,17 +1,21 @@
1
- import { Button } from 'primereact/button';
1
+ import { Button, ButtonProps } from 'primereact/button';
2
2
  import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
3
3
 
4
- function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
5
- props: IconButtonProps<T, S, F>,
4
+ export type PrimeIconButtonProps<
5
+ T = any,
6
+ S extends StrictRJSFSchema = RJSFSchema,
7
+ F extends FormContextType = any,
8
+ > = IconButtonProps<T, S, F> & Omit<ButtonProps, 'onClick'>;
9
+
10
+ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
11
+ props: PrimeIconButtonProps<T, S, F>,
6
12
  ) {
7
13
  const { icon, iconType, uiSchema, registry, ...otherProps } = props;
8
14
  return <Button icon={`pi pi-${icon}`} rounded text severity='secondary' {...otherProps} />;
9
15
  }
10
16
 
11
- export default IconButton;
12
-
13
17
  export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
14
- props: IconButtonProps<T, S, F>,
18
+ props: PrimeIconButtonProps<T, S, F>,
15
19
  ) {
16
20
  const {
17
21
  registry: { translateString },
@@ -20,7 +24,7 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
20
24
  }
21
25
 
22
26
  export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
23
- props: IconButtonProps<T, S, F>,
27
+ props: PrimeIconButtonProps<T, S, F>,
24
28
  ) {
25
29
  const {
26
30
  registry: { translateString },
@@ -29,7 +33,7 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
29
33
  }
30
34
 
31
35
  export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
32
- props: IconButtonProps<T, S, F>,
36
+ props: PrimeIconButtonProps<T, S, F>,
33
37
  ) {
34
38
  const {
35
39
  registry: { translateString },
@@ -38,7 +42,7 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
38
42
  }
39
43
 
40
44
  export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
41
- props: IconButtonProps<T, S, F>,
45
+ props: PrimeIconButtonProps<T, S, F>,
42
46
  ) {
43
47
  const {
44
48
  registry: { translateString },
@@ -24,7 +24,8 @@ export default function ObjectFieldTemplate<
24
24
  >(props: ObjectFieldTemplateProps<T, S, F>) {
25
25
  const {
26
26
  description,
27
- onAddClick,
27
+ optionalDataControl,
28
+ onAddProperty,
28
29
  title,
29
30
  properties,
30
31
  disabled,
@@ -43,6 +44,7 @@ export default function ObjectFieldTemplate<
43
44
  registry,
44
45
  uiOptions,
45
46
  );
47
+ const showOptionalDataControlInTitle = !readonly && !disabled;
46
48
  // Button templates are not overridden in the uiSchema
47
49
  const {
48
50
  ButtonTemplates: { AddButton },
@@ -57,6 +59,7 @@ export default function ObjectFieldTemplate<
57
59
  schema={schema}
58
60
  uiSchema={uiSchema}
59
61
  registry={registry}
62
+ optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
60
63
  />
61
64
  )}
62
65
  {description && (
@@ -70,6 +73,7 @@ export default function ObjectFieldTemplate<
70
73
  />
71
74
  </div>
72
75
  )}
76
+ {!showOptionalDataControlInTitle ? optionalDataControl : undefined}
73
77
  {properties.map((prop) => prop.content)}
74
78
  {canExpand<T, S, F>(schema, uiSchema, formData) && (
75
79
  <div style={{ marginTop: '1rem', textAlign: 'right' }}>
@@ -77,7 +81,7 @@ export default function ObjectFieldTemplate<
77
81
  id={buttonId(fieldPathId, 'add')}
78
82
  className='rjsf-object-property-expand'
79
83
  icon='pi pi-plus'
80
- onClick={onAddClick(schema)}
84
+ onClick={onAddProperty}
81
85
  disabled={disabled || readonly}
82
86
  registry={registry}
83
87
  />
@@ -0,0 +1,44 @@
1
+ import { FormContextType, OptionalDataControlsTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+
3
+ import IconButton, { RemoveButton } from '../IconButton';
4
+
5
+ /** The OptionalDataControlsTemplate renders one of three different states. If
6
+ * there is an `onAddClick()` function, it renders the "Add" button. If there is
7
+ * an `onRemoveClick()` function, it renders the "Remove" button. Otherwise it
8
+ * renders the "No data found" section. All of them use the `label` as either
9
+ * the `title` of buttons or simply outputting it.
10
+ *
11
+ * @param props - The `OptionalDataControlsTemplateProps` for the template
12
+ */
13
+ export default function OptionalDataControlsTemplate<
14
+ T = any,
15
+ S extends StrictRJSFSchema = RJSFSchema,
16
+ F extends FormContextType = any,
17
+ >(props: OptionalDataControlsTemplateProps<T, S, F>) {
18
+ const { id, registry, label, onAddClick, onRemoveClick } = props;
19
+ if (onAddClick) {
20
+ return (
21
+ <IconButton
22
+ id={id}
23
+ registry={registry}
24
+ className='rjsf-add-optional-data'
25
+ onClick={onAddClick}
26
+ title={label}
27
+ icon='pi pi-plus'
28
+ style={{ height: '1.5rem', width: '1.5rem' }} // Shrink the button
29
+ />
30
+ );
31
+ } else if (onRemoveClick) {
32
+ return (
33
+ <RemoveButton
34
+ id={id}
35
+ registry={registry}
36
+ className='rjsf-remove-optional-data'
37
+ onClick={onRemoveClick}
38
+ title={label}
39
+ style={{ height: '1.5rem', width: '1.5rem' }} // Shrink the button
40
+ />
41
+ );
42
+ }
43
+ return <em id={id}>{label}</em>;
44
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './OptionalDataControlsTemplate';
2
+ export * from './OptionalDataControlsTemplate';
@@ -18,7 +18,7 @@ import { RadioButton, RadioButtonChangeEvent } from 'primereact/radiobutton';
18
18
  export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
19
19
  props: WidgetProps<T, S, F>,
20
20
  ) {
21
- const { id, value, disabled, readonly, onChange, onBlur, onFocus, options } = props;
21
+ const { id, htmlName, value, disabled, readonly, onChange, onBlur, onFocus, options } = props;
22
22
  const primeProps = (options.prime || {}) as object;
23
23
  const { enumOptions, enumDisabled, emptyValue } = options;
24
24
 
@@ -39,7 +39,7 @@ export default function RadioWidget<T = any, S extends StrictRJSFSchema = RJSFSc
39
39
  <div key={index} style={{ display: 'flex', alignItems: 'center' }}>
40
40
  <RadioButton
41
41
  inputId={optionId(id, index)}
42
- name={id}
42
+ name={htmlName || id}
43
43
  {...primeProps}
44
44
  onFocus={_onFocus}
45
45
  onBlur={_onBlur}
@@ -27,6 +27,7 @@ export default function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFS
27
27
  function SingleSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
28
28
  schema,
29
29
  id,
30
+ htmlName,
30
31
  name, // remove this from dropdownProps
31
32
  options,
32
33
  label,
@@ -46,7 +47,6 @@ function SingleSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F
46
47
  registry,
47
48
  uiSchema,
48
49
  hideError,
49
- formContext,
50
50
  ...dropdownProps
51
51
  }: WidgetProps<T, S, F>) {
52
52
  const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
@@ -68,7 +68,7 @@ function SingleSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F
68
68
  return (
69
69
  <Dropdown
70
70
  id={id}
71
- name={id}
71
+ name={htmlName || id}
72
72
  {...primeProps}
73
73
  value={!isEmpty && typeof selectedIndexes !== 'undefined' ? selectedIndexes : emptyValue}
74
74
  options={(enumOptions ?? []).map(({ value, label }, i: number) => ({
@@ -90,6 +90,7 @@ function SingleSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F
90
90
 
91
91
  function MultiSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>({
92
92
  id,
93
+ htmlName,
93
94
  options,
94
95
  disabled,
95
96
  placeholder,
@@ -117,7 +118,7 @@ function MultiSelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
117
118
  return (
118
119
  <MultiSelect
119
120
  id={id}
120
- name={id}
121
+ name={htmlName || id}
121
122
  {...primeProps}
122
123
  value={!isEmpty && typeof selectedIndexes !== 'undefined' ? selectedIndexes : emptyValue}
123
124
  options={(enumOptions ?? []).map(({ value, label }, i: number) => ({
@@ -12,6 +12,7 @@ import FieldHelpTemplate from '../FieldHelpTemplate';
12
12
  import FieldTemplate from '../FieldTemplate';
13
13
  import MultiSchemaFieldTemplate from '../MultiSchemaFieldTemplate';
14
14
  import ObjectFieldTemplate from '../ObjectFieldTemplate';
15
+ import OptionalDataControlsTemplate from '../OptionalDataControlsTemplate';
15
16
  import SubmitButton from '../SubmitButton';
16
17
  import TitleField from '../TitleField';
17
18
  import WrapIfAdditionalTemplate from '../WrapIfAdditionalTemplate';
@@ -43,6 +44,7 @@ export function generateTemplates<
43
44
  FieldTemplate,
44
45
  MultiSchemaFieldTemplate,
45
46
  ObjectFieldTemplate,
47
+ OptionalDataControlsTemplate,
46
48
  TitleFieldTemplate: TitleField,
47
49
  WrapIfAdditionalTemplate,
48
50
  GridTemplate,
@@ -11,7 +11,7 @@ export default function TextareaWidget<
11
11
  S extends StrictRJSFSchema = RJSFSchema,
12
12
  F extends FormContextType = any,
13
13
  >(props: WidgetProps<T, S, F>) {
14
- const { id, value, required, disabled, readonly, autofocus, onChange, onBlur, onFocus, options } = props;
14
+ const { id, htmlName, value, required, disabled, readonly, autofocus, onChange, onBlur, onFocus, options } = props;
15
15
  const primeProps = (options.prime || {}) as object;
16
16
 
17
17
  let rows = 5;
@@ -27,6 +27,7 @@ export default function TextareaWidget<
27
27
  return (
28
28
  <InputTextarea
29
29
  id={id}
30
+ name={htmlName || id}
30
31
  {...primeProps}
31
32
  value={value || ''}
32
33
  required={required}
@@ -10,13 +10,25 @@ export default function TitleField<T = any, S extends StrictRJSFSchema = RJSFSch
10
10
  title,
11
11
  uiSchema,
12
12
  required,
13
+ optionalDataControl,
13
14
  }: TitleFieldProps<T, S, F>) {
14
15
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
16
+ let heading = (
17
+ <h5 style={{ margin: 0, fontSize: id === titleId('root') ? '1.5rem' : '1.2rem' }}>
18
+ {uiOptions.title || title} {required ? '*' : ''}
19
+ </h5>
20
+ );
21
+ if (optionalDataControl) {
22
+ heading = (
23
+ <div style={{ display: 'flex' }}>
24
+ <div style={{ flexGrow: 1 }}>{heading}</div>
25
+ <div style={{ marginLeft: '-5px' }}>{optionalDataControl}</div>
26
+ </div>
27
+ );
28
+ }
15
29
  return (
16
30
  <div id={id}>
17
- <h5 style={{ margin: 0, fontSize: id === titleId('root') ? '1.5rem' : '1.2rem' }}>
18
- {uiOptions.title || title} {required ? '*' : ''}
19
- </h5>
31
+ {heading}
20
32
  <Divider pt={{ root: { style: { marginTop: '0.5rem' } } }} />
21
33
  </div>
22
34
  );
@@ -1,4 +1,3 @@
1
- import { FocusEvent } from 'react';
2
1
  import {
3
2
  ADDITIONAL_PROPERTY_FLAG,
4
3
  buttonId,
@@ -26,8 +25,8 @@ export default function WrapIfAdditionalTemplate<
26
25
  disabled,
27
26
  id,
28
27
  label,
29
- onDropPropertyClick,
30
- onKeyChange,
28
+ onRemoveProperty,
29
+ onKeyRenameBlur,
31
30
  readonly,
32
31
  required,
33
32
  schema,
@@ -46,8 +45,6 @@ export default function WrapIfAdditionalTemplate<
46
45
  );
47
46
  }
48
47
 
49
- const handleBlur = ({ target }: FocusEvent<HTMLInputElement>) => onKeyChange(target.value);
50
-
51
48
  return (
52
49
  <div
53
50
  className={classNames}
@@ -63,7 +60,7 @@ export default function WrapIfAdditionalTemplate<
63
60
  name={`${id}-key`}
64
61
  defaultValue={label}
65
62
  disabled={disabled || readonly}
66
- onBlur={!readonly ? handleBlur : undefined}
63
+ onBlur={!readonly ? onKeyRenameBlur : undefined}
67
64
  required={required}
68
65
  style={{ width: '100%' }}
69
66
  />
@@ -74,7 +71,7 @@ export default function WrapIfAdditionalTemplate<
74
71
  id={buttonId(id, 'remove')}
75
72
  className='rjsf-object-property-remove'
76
73
  disabled={disabled || readonly}
77
- onClick={onDropPropertyClick(label)}
74
+ onClick={onRemoveProperty}
78
75
  registry={registry}
79
76
  />
80
77
  </div>