@rjsf/semantic-ui 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 (89) hide show
  1. package/README.md +7 -3
  2. package/dist/{index.js → index.cjs} +159 -111
  3. package/dist/index.cjs.map +7 -0
  4. package/dist/semantic-ui.esm.js +160 -113
  5. package/dist/semantic-ui.esm.js.map +4 -4
  6. package/dist/semantic-ui.umd.js +122 -80
  7. package/lib/AddButton/AddButton.d.ts +3 -2
  8. package/lib/AddButton/AddButton.js +1 -1
  9. package/lib/AddButton/AddButton.js.map +1 -1
  10. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +3 -3
  11. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +9 -5
  12. package/lib/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -1
  13. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +1 -1
  14. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js +8 -26
  15. package/lib/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -1
  16. package/lib/BaseInputTemplate/BaseInputTemplate.js +3 -3
  17. package/lib/BaseInputTemplate/BaseInputTemplate.js.map +1 -1
  18. package/lib/CheckboxWidget/CheckboxWidget.js +4 -4
  19. package/lib/CheckboxWidget/CheckboxWidget.js.map +1 -1
  20. package/lib/CheckboxesWidget/CheckboxesWidget.js +4 -4
  21. package/lib/CheckboxesWidget/CheckboxesWidget.js.map +1 -1
  22. package/lib/FieldErrorTemplate/FieldErrorTemplate.d.ts +1 -1
  23. package/lib/FieldErrorTemplate/FieldErrorTemplate.js +4 -4
  24. package/lib/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -1
  25. package/lib/FieldHelpTemplate/FieldHelpTemplate.js +2 -2
  26. package/lib/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -1
  27. package/lib/FieldTemplate/FieldTemplate.js +4 -1
  28. package/lib/FieldTemplate/FieldTemplate.js.map +1 -1
  29. package/lib/IconButton/IconButton.d.ts +7 -6
  30. package/lib/IconButton/IconButton.js +1 -2
  31. package/lib/IconButton/IconButton.js.map +1 -1
  32. package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.d.ts +2 -0
  33. package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js +6 -0
  34. package/lib/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.js.map +1 -0
  35. package/lib/MultiSchemaFieldTemplate/index.d.ts +2 -0
  36. package/lib/MultiSchemaFieldTemplate/index.js +3 -0
  37. package/lib/MultiSchemaFieldTemplate/index.js.map +1 -0
  38. package/lib/ObjectFieldTemplate/ObjectFieldTemplate.js +4 -3
  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.js +3 -3
  47. package/lib/RadioWidget/RadioWidget.js.map +1 -1
  48. package/lib/RangeWidget/RangeWidget.js +2 -2
  49. package/lib/RangeWidget/RangeWidget.js.map +1 -1
  50. package/lib/SelectWidget/SelectWidget.js +3 -3
  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.js +3 -3
  55. package/lib/TextareaWidget/TextareaWidget.js.map +1 -1
  56. package/lib/TitleField/TitleField.d.ts +1 -1
  57. package/lib/TitleField/TitleField.js +7 -6
  58. package/lib/TitleField/TitleField.js.map +1 -1
  59. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +2 -3
  60. package/lib/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -1
  61. package/lib/index.d.ts +3 -0
  62. package/lib/index.js +3 -0
  63. package/lib/index.js.map +1 -1
  64. package/lib/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +16 -17
  66. package/src/AddButton/AddButton.tsx +5 -3
  67. package/src/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +11 -8
  68. package/src/ArrayFieldTemplate/ArrayFieldTemplate.tsx +12 -34
  69. package/src/BaseInputTemplate/BaseInputTemplate.tsx +7 -6
  70. package/src/CheckboxWidget/CheckboxWidget.tsx +8 -8
  71. package/src/CheckboxesWidget/CheckboxesWidget.tsx +6 -6
  72. package/src/FieldErrorTemplate/FieldErrorTemplate.tsx +4 -4
  73. package/src/FieldHelpTemplate/FieldHelpTemplate.tsx +2 -2
  74. package/src/FieldTemplate/FieldTemplate.tsx +4 -1
  75. package/src/IconButton/IconButton.tsx +12 -8
  76. package/src/MultiSchemaFieldTemplate/MultiSchemaFieldTemplate.tsx +16 -0
  77. package/src/MultiSchemaFieldTemplate/index.ts +2 -0
  78. package/src/ObjectFieldTemplate/ObjectFieldTemplate.tsx +10 -6
  79. package/src/OptionalDataControlsTemplate/OptionalDataControlsTemplate.tsx +44 -0
  80. package/src/OptionalDataControlsTemplate/index.ts +2 -0
  81. package/src/RadioWidget/RadioWidget.tsx +5 -4
  82. package/src/RangeWidget/RangeWidget.tsx +3 -3
  83. package/src/SelectWidget/SelectWidget.tsx +5 -4
  84. package/src/Templates/Templates.ts +4 -0
  85. package/src/TextareaWidget/TextareaWidget.tsx +5 -4
  86. package/src/TitleField/TitleField.tsx +16 -6
  87. package/src/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +5 -8
  88. package/src/index.ts +3 -0
  89. package/dist/index.js.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rjsf/semantic-ui",
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/semantic-ui.esm.js --sourcemap --packages=external --format=esm",
49
49
  "build:umd": "rollup dist/semantic-ui.esm.js --format=umd --file=dist/semantic-ui.umd.js --name=@rjsf/semantic-ui",
50
50
  "build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
@@ -61,20 +61,19 @@
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
  "semantic-ui-react": "^2.1.3"
68
68
  },
69
69
  "devDependencies": {
70
- "@rjsf/core": "^6.0.0-beta.8",
71
- "@rjsf/snapshot-tests": "^6.0.0-beta.8",
72
- "@rjsf/utils": "^6.0.0-beta.8",
73
- "@rjsf/validator-ajv8": "^6.0.0-beta.8",
70
+ "@rjsf/core": "^6.0.0-beta.23",
71
+ "@rjsf/snapshot-tests": "^6.0.0-beta.23",
72
+ "@rjsf/utils": "^6.0.0-beta.23",
73
+ "@rjsf/validator-ajv8": "^6.0.0-beta.23",
74
74
  "atob": "^2.1.2",
75
- "eslint": "^8.56.0",
76
- "nanoid": "^5.1.5",
77
- "semantic-ui-react": "^2.1.3"
75
+ "eslint": "^8.57.1",
76
+ "semantic-ui-react": "^2.1.5"
78
77
  },
79
78
  "publishConfig": {
80
79
  "access": "public"
@@ -1,5 +1,7 @@
1
1
  import { Button, Icon, ButtonProps } from 'semantic-ui-react';
2
- import { FormContextType, IconButtonProps, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
2
+ import { FormContextType, RJSFSchema, StrictRJSFSchema, TranslatableString } from '@rjsf/utils';
3
+
4
+ import { SemanticIconButtonProps } from '../IconButton';
3
5
 
4
6
  /** The `AddButton` renders a button that represent the `Add` action on a form
5
7
  */
@@ -8,15 +10,15 @@ export default function AddButton<T = any, S extends StrictRJSFSchema = RJSFSche
8
10
  registry,
9
11
  color,
10
12
  ...props
11
- }: IconButtonProps<T, S, F>) {
13
+ }: SemanticIconButtonProps<T, S, F>) {
12
14
  const { translateString } = registry;
13
15
  return (
14
16
  <Button
15
17
  title={translateString(TranslatableString.AddItemButton)}
16
18
  color={color as ButtonProps['color']}
19
+ size='tiny'
17
20
  {...props}
18
21
  icon
19
- size='tiny'
20
22
  >
21
23
  <Icon name='plus' />
22
24
  </Button>
@@ -1,7 +1,6 @@
1
1
  import {
2
- ArrayFieldItemTemplateType,
2
+ ArrayFieldItemTemplateProps,
3
3
  FormContextType,
4
- GenericObjectType,
5
4
  RJSFSchema,
6
5
  StrictRJSFSchema,
7
6
  getUiOptions,
@@ -9,7 +8,7 @@ import {
9
8
  } from '@rjsf/utils';
10
9
  import { Button, Grid, Segment } from 'semantic-ui-react';
11
10
 
12
- import { MaybeWrap } from '../util';
11
+ import { getSemanticProps, MaybeWrap } from '../util';
13
12
 
14
13
  const gridStyle = (vertical: boolean) => ({
15
14
  display: 'grid',
@@ -18,22 +17,26 @@ const gridStyle = (vertical: boolean) => ({
18
17
 
19
18
  /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
20
19
  *
21
- * @param props - The `ArrayFieldItemTemplateType` props for the component
20
+ * @param props - The `ArrayFieldItemTemplateProps` props for the component
22
21
  */
23
22
  export default function ArrayFieldItemTemplate<
24
23
  T = any,
25
24
  S extends StrictRJSFSchema = RJSFSchema,
26
25
  F extends FormContextType = any,
27
- >(props: ArrayFieldItemTemplateType<T, S, F>) {
28
- const { children, buttonsProps, hasToolbar, uiSchema, registry } = props;
26
+ >(props: ArrayFieldItemTemplateProps<T, S, F>) {
27
+ const { children, buttonsProps, hasToolbar, uiSchema, registry, parentUiSchema } = props;
29
28
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
30
29
  const ArrayFieldItemButtonsTemplate = getTemplate<'ArrayFieldItemButtonsTemplate', T, S, F>(
31
30
  'ArrayFieldItemButtonsTemplate',
32
31
  registry,
33
32
  uiOptions,
34
33
  );
35
- // Pull the semantic props out of the uiOptions that were put in via the ArrayFieldTemplate
36
- const { horizontalButtons = true, wrapItem = false } = uiOptions.semantic as GenericObjectType;
34
+ const semanticProps = getSemanticProps<T, S, F>({
35
+ uiSchema: parentUiSchema,
36
+ formContext: registry.formContext,
37
+ defaultSchemaProps: { horizontalButtons: true, wrapItem: false },
38
+ });
39
+ const { horizontalButtons = true, wrapItem = false } = semanticProps;
37
40
  return (
38
41
  <div className='rjsf-array-item'>
39
42
  <MaybeWrap wrap={wrapItem} component={Segment}>
@@ -3,19 +3,17 @@ 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
 
14
- import { cleanClassNames, getSemanticProps } from '../util';
12
+ import { cleanClassNames } from '../util';
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,
@@ -24,13 +22,13 @@ export default function ArrayFieldTemplate<
24
22
  >(props: ArrayFieldTemplateProps<T, S, F>) {
25
23
  const {
26
24
  uiSchema,
27
- idSchema,
25
+ fieldPathId,
28
26
  canAdd,
29
27
  className,
30
28
  // classNames, This is not part of the type, so it is likely never passed in
31
29
  disabled,
32
- formContext,
33
30
  items,
31
+ optionalDataControl,
34
32
  onAddClick,
35
33
  // options, This is not part of the type, so it is likely never passed in
36
34
  readonly,
@@ -39,29 +37,18 @@ export default function ArrayFieldTemplate<
39
37
  title,
40
38
  registry,
41
39
  } = props;
42
- const semanticProps = getSemanticProps<T, S, F>({
43
- uiSchema,
44
- formContext,
45
- defaultSchemaProps: { horizontalButtons: true, wrapItem: false },
46
- });
47
- const { horizontalButtons, wrapItem } = semanticProps;
48
- const semantic = { horizontalButtons, wrapItem };
49
40
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
50
41
  const ArrayFieldDescriptionTemplate = getTemplate<'ArrayFieldDescriptionTemplate', T, S, F>(
51
42
  'ArrayFieldDescriptionTemplate',
52
43
  registry,
53
44
  uiOptions,
54
45
  );
55
- const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate', T, S, F>(
56
- 'ArrayFieldItemTemplate',
57
- registry,
58
- uiOptions,
59
- );
60
46
  const ArrayFieldTitleTemplate = getTemplate<'ArrayFieldTitleTemplate', T, S, F>(
61
47
  'ArrayFieldTitleTemplate',
62
48
  registry,
63
49
  uiOptions,
64
50
  );
51
+ const showOptionalDataControlInTitle = !readonly && !disabled;
65
52
  // Button templates are not overridden in the uiSchema
66
53
  const {
67
54
  ButtonTemplates: { AddButton },
@@ -69,34 +56,25 @@ export default function ArrayFieldTemplate<
69
56
  return (
70
57
  <div className={cleanClassNames([className, isFixedItems<S>(schema) ? '' : 'sortable-form-fields'])}>
71
58
  <ArrayFieldTitleTemplate
72
- idSchema={idSchema}
59
+ fieldPathId={fieldPathId}
73
60
  title={uiOptions.title || title}
74
61
  schema={schema}
75
62
  uiSchema={uiSchema}
76
63
  required={required}
77
64
  registry={registry}
65
+ optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
78
66
  />
79
67
  <ArrayFieldDescriptionTemplate
80
- idSchema={idSchema}
68
+ fieldPathId={fieldPathId}
81
69
  description={uiOptions.description || schema.description}
82
70
  schema={schema}
83
71
  uiSchema={uiSchema}
84
72
  registry={registry}
85
73
  />
86
- <div key={`array-item-list-${idSchema.$id}`}>
74
+ <div key={`array-item-list-${fieldPathId.$id}`}>
87
75
  <div className='row array-item-list'>
88
- {items &&
89
- items.map(({ key, uiSchema: itemUiSchema = {}, ...props }: ArrayFieldItemTemplateType<T, S, F>) => {
90
- // Merge in the semantic props from the ArrayFieldTemplate into each of the items
91
- const mergedUiSchema = {
92
- ...itemUiSchema,
93
- [UI_OPTIONS_KEY]: {
94
- ...itemUiSchema[UI_OPTIONS_KEY],
95
- semantic,
96
- },
97
- };
98
- return <ArrayFieldItemTemplate key={key} {...props} uiSchema={mergedUiSchema} />;
99
- })}
76
+ {!showOptionalDataControlInTitle ? optionalDataControl : undefined}
77
+ {items}
100
78
  </div>
101
79
  {canAdd && (
102
80
  <div
@@ -107,7 +85,7 @@ export default function ArrayFieldTemplate<
107
85
  }}
108
86
  >
109
87
  <AddButton
110
- id={buttonId<T>(idSchema, 'add')}
88
+ id={buttonId(fieldPathId, 'add')}
111
89
  className='rjsf-array-item-add'
112
90
  onClick={onAddClick}
113
91
  disabled={disabled || readonly}
@@ -25,6 +25,7 @@ export default function BaseInputTemplate<
25
25
  >(props: BaseInputTemplateProps<T, S, F>) {
26
26
  const {
27
27
  id,
28
+ htmlName,
28
29
  placeholder,
29
30
  label,
30
31
  hideLabel,
@@ -40,14 +41,14 @@ export default function BaseInputTemplate<
40
41
  options,
41
42
  schema,
42
43
  uiSchema,
43
- formContext,
44
+ registry,
44
45
  type,
45
46
  rawErrors = [],
46
47
  } = props;
47
48
  const inputProps = getInputProps<T, S, F>(schema, type, options);
48
49
  const semanticProps = getSemanticProps<T, S, F>({
49
50
  uiSchema,
50
- formContext,
51
+ formContext: registry.formContext,
51
52
  options,
52
53
  });
53
54
  const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
@@ -60,24 +61,24 @@ export default function BaseInputTemplate<
60
61
  <Form.Input
61
62
  key={id}
62
63
  id={id}
63
- name={id}
64
+ name={htmlName || id}
64
65
  placeholder={placeholder}
65
66
  {...inputProps}
66
67
  label={labelValue(label || undefined, hideLabel, false)}
67
68
  required={required}
68
69
  autoFocus={autofocus}
69
70
  disabled={disabled || readonly}
70
- list={schema.examples ? examplesId<T>(id) : undefined}
71
+ list={schema.examples ? examplesId(id) : undefined}
71
72
  {...semanticProps}
72
73
  value={value || value === 0 ? value : ''}
73
74
  error={rawErrors.length > 0}
74
75
  onChange={onChangeOverride || _onChange}
75
76
  onBlur={_onBlur}
76
77
  onFocus={_onFocus}
77
- aria-describedby={ariaDescribedByIds<T>(id, !!schema.examples)}
78
+ aria-describedby={ariaDescribedByIds(id, !!schema.examples)}
78
79
  />
79
80
  {Array.isArray(schema.examples) && (
80
- <datalist id={examplesId<T>(id)}>
81
+ <datalist id={examplesId(id)}>
81
82
  {(schema.examples as string[])
82
83
  .concat(schema.default && !schema.examples.includes(schema.default) ? ([schema.default] as string[]) : [])
83
84
  .map((example) => {
@@ -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,
@@ -35,7 +36,6 @@ export default function CheckboxWidget<
35
36
  onBlur,
36
37
  options,
37
38
  onFocus,
38
- formContext,
39
39
  schema,
40
40
  uiSchema,
41
41
  rawErrors = [],
@@ -43,7 +43,7 @@ export default function CheckboxWidget<
43
43
  } = props;
44
44
  const semanticProps = getSemanticProps<T, S, F>({
45
45
  options,
46
- formContext,
46
+ formContext: registry.formContext,
47
47
  uiSchema,
48
48
  defaultSchemaProps: {
49
49
  inverted: 'false',
@@ -58,17 +58,17 @@ export default function CheckboxWidget<
58
58
  // the "required" attribute if the field value must be "true", due to the
59
59
  // "const" or "enum" keywords
60
60
  const required = schemaRequiresTrueValue<S>(schema);
61
- const _onChange = (_: FormEvent<HTMLInputElement>, data: CheckboxProps) => onChange && onChange(data.checked);
62
- const _onBlur = () => onBlur && onBlur(id, value);
63
- const _onFocus = () => onFocus && onFocus(id, value);
64
61
  const checked = value == 'true' || value == true;
62
+ const _onChange = (_: FormEvent<HTMLInputElement>, data: CheckboxProps) => onChange && onChange(data.checked);
63
+ const _onBlur: React.FocusEventHandler<HTMLInputElement> = () => onBlur && onBlur(id, value);
64
+ const _onFocus: React.FocusEventHandler<HTMLInputElement> = () => onFocus && onFocus(id, value);
65
65
  const description = options.description ?? schema.description;
66
66
 
67
67
  return (
68
68
  <>
69
69
  {!hideLabel && description && (
70
70
  <DescriptionFieldTemplate
71
- id={descriptionId<T>(id)}
71
+ id={descriptionId(id)}
72
72
  description={description}
73
73
  schema={schema}
74
74
  uiSchema={uiSchema}
@@ -77,7 +77,7 @@ export default function CheckboxWidget<
77
77
  )}
78
78
  <Form.Checkbox
79
79
  id={id}
80
- name={id}
80
+ name={htmlName || id}
81
81
  disabled={disabled || readonly}
82
82
  autoFocus={autofocus}
83
83
  {...semanticProps}
@@ -88,7 +88,7 @@ export default function CheckboxWidget<
88
88
  onFocus={_onFocus}
89
89
  required={required}
90
90
  label={labelValue(label, hideLabel, false)}
91
- aria-describedby={ariaDescribedByIds<T>(id)}
91
+ aria-describedby={ariaDescribedByIds(id)}
92
92
  />
93
93
  </>
94
94
  );
@@ -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,
@@ -37,7 +38,6 @@ export default function CheckboxesWidget<
37
38
  onChange,
38
39
  onBlur,
39
40
  onFocus,
40
- formContext,
41
41
  schema,
42
42
  uiSchema,
43
43
  rawErrors = [],
@@ -48,7 +48,7 @@ export default function CheckboxesWidget<
48
48
  const checkboxesValues = Array.isArray(value) ? value : [value];
49
49
  const semanticProps = getSemanticProps<T, S, F>({
50
50
  options,
51
- formContext,
51
+ formContext: registry.formContext,
52
52
  uiSchema,
53
53
  defaultSchemaProps: {
54
54
  inverted: 'false',
@@ -71,9 +71,9 @@ export default function CheckboxesWidget<
71
71
  return (
72
72
  <>
73
73
  {!hideLabel && !!label && (
74
- <TitleFieldTemplate id={titleId<T>(id)} title={label} schema={schema} uiSchema={uiSchema} registry={registry} />
74
+ <TitleFieldTemplate id={titleId(id)} title={label} schema={schema} uiSchema={uiSchema} registry={registry} />
75
75
  )}
76
- <Form.Group id={id} name={id} {...inlineOption}>
76
+ <Form.Group id={id} name={htmlName || id} {...inlineOption}>
77
77
  {Array.isArray(enumOptions) &&
78
78
  enumOptions.map((option, index) => {
79
79
  const checked = enumOptionsIsSelected<S>(option.value, checkboxesValues);
@@ -81,7 +81,7 @@ export default function CheckboxesWidget<
81
81
  return (
82
82
  <Form.Checkbox
83
83
  id={optionId(id, index)}
84
- name={id}
84
+ name={htmlName || id}
85
85
  key={index}
86
86
  label={option.label}
87
87
  {...semanticProps}
@@ -92,7 +92,7 @@ export default function CheckboxesWidget<
92
92
  onChange={_onChange(index)}
93
93
  onBlur={_onBlur}
94
94
  onFocus={_onFocus}
95
- aria-describedby={ariaDescribedByIds<T>(id)}
95
+ aria-describedby={ariaDescribedByIds(id)}
96
96
  />
97
97
  );
98
98
  })}
@@ -1,5 +1,5 @@
1
1
  import { errorId, FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
- import { nanoid } from 'nanoid';
2
+ import uniqueId from 'lodash/uniqueId';
3
3
  import { Label, List } from 'semantic-ui-react';
4
4
 
5
5
  import { getSemanticErrorProps } from '../util';
@@ -19,7 +19,7 @@ export default function FieldErrorTemplate<
19
19
  T = any,
20
20
  S extends StrictRJSFSchema = RJSFSchema,
21
21
  F extends FormContextType = any,
22
- >({ errors, idSchema, uiSchema, registry }: FieldErrorProps<T, S, F>) {
22
+ >({ errors, fieldPathId, uiSchema, registry }: FieldErrorProps<T, S, F>) {
23
23
  const { formContext } = registry;
24
24
  const options = getSemanticErrorProps<T, S, F>({
25
25
  formContext,
@@ -28,12 +28,12 @@ export default function FieldErrorTemplate<
28
28
  });
29
29
  const { pointing, size } = options;
30
30
  if (errors && errors.length > 0) {
31
- const id = errorId<T>(idSchema);
31
+ const id = errorId(fieldPathId);
32
32
  return (
33
33
  <Label id={id} color='red' pointing={pointing || 'above'} size={size || 'small'} basic>
34
34
  <List bulleted>
35
35
  {errors.map((error) => (
36
- <List.Item key={nanoid()}>{error}</List.Item>
36
+ <List.Item key={uniqueId('field-error-')}>{error}</List.Item>
37
37
  ))}
38
38
  </List>
39
39
  </Label>
@@ -10,9 +10,9 @@ 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 } = props;
13
+ const { fieldPathId, help } = props;
14
14
  if (help) {
15
- const id = helpId<T>(idSchema);
15
+ const id = helpId(fieldPathId);
16
16
  return <Message size='mini' info id={id} content={help} />;
17
17
  }
18
18
  return null;
@@ -36,7 +36,10 @@ export default function FieldTemplate<
36
36
  uiSchema,
37
37
  ...otherProps
38
38
  } = props;
39
- const semanticProps = getSemanticProps<T, S, F>(otherProps);
39
+ const semanticProps = getSemanticProps<T, S, F>({
40
+ ...otherProps,
41
+ formContext: registry.formContext,
42
+ });
40
43
  const { wrapLabel, wrapContent } = semanticProps;
41
44
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
42
45
  const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate', T, S, F>(
@@ -1,8 +1,14 @@
1
1
  import { Button, ButtonProps } from 'semantic-ui-react';
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 SemanticIconButtonProps<
5
+ T = any,
6
+ S extends StrictRJSFSchema = RJSFSchema,
7
+ F extends FormContextType = any,
8
+ > = IconButtonProps<T, S, F> & Omit<ButtonProps, 'onChange'>;
9
+
10
+ export default function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
11
+ props: SemanticIconButtonProps<T, S, F>,
6
12
  ) {
7
13
  const { icon, iconType, color, className, uiSchema, registry, ...otherProps } = props;
8
14
  return (
@@ -16,10 +22,8 @@ function IconButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends
16
22
  );
17
23
  }
18
24
 
19
- export default IconButton;
20
-
21
25
  export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
22
- props: IconButtonProps<T, S, F>,
26
+ props: SemanticIconButtonProps<T, S, F>,
23
27
  ) {
24
28
  const {
25
29
  registry: { translateString },
@@ -28,7 +32,7 @@ export function CopyButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F e
28
32
  }
29
33
 
30
34
  export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
31
- props: IconButtonProps<T, S, F>,
35
+ props: SemanticIconButtonProps<T, S, F>,
32
36
  ) {
33
37
  const {
34
38
  registry: { translateString },
@@ -37,7 +41,7 @@ export function MoveDownButton<T = any, S extends StrictRJSFSchema = RJSFSchema,
37
41
  }
38
42
 
39
43
  export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
40
- props: IconButtonProps<T, S, F>,
44
+ props: SemanticIconButtonProps<T, S, F>,
41
45
  ) {
42
46
  const {
43
47
  registry: { translateString },
@@ -46,7 +50,7 @@ export function MoveUpButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F
46
50
  }
47
51
 
48
52
  export function RemoveButton<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(
49
- props: IconButtonProps<T, S, F>,
53
+ props: SemanticIconButtonProps<T, S, F>,
50
54
  ) {
51
55
  const {
52
56
  registry: { translateString },
@@ -0,0 +1,16 @@
1
+ import { FormContextType, MultiSchemaFieldTemplateProps, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils';
2
+
3
+ export default function MultiSchemaFieldTemplate<
4
+ T = any,
5
+ S extends StrictRJSFSchema = RJSFSchema,
6
+ F extends FormContextType = any,
7
+ >(props: MultiSchemaFieldTemplateProps<T, S, F>) {
8
+ const { selector, optionSchemaField } = props;
9
+
10
+ return (
11
+ <div>
12
+ <div>{selector}</div>
13
+ {optionSchemaField}
14
+ </div>
15
+ );
16
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from './MultiSchemaFieldTemplate';
2
+ export * from './MultiSchemaFieldTemplate';
@@ -25,7 +25,8 @@ export default function ObjectFieldTemplate<
25
25
  >(props: ObjectFieldTemplateProps<T, S, F>) {
26
26
  const {
27
27
  description,
28
- onAddClick,
28
+ optionalDataControl,
29
+ onAddProperty,
29
30
  title,
30
31
  properties,
31
32
  disabled,
@@ -34,7 +35,7 @@ export default function ObjectFieldTemplate<
34
35
  uiSchema,
35
36
  schema,
36
37
  formData,
37
- idSchema,
38
+ fieldPathId,
38
39
  registry,
39
40
  } = props;
40
41
  const uiOptions = getUiOptions<T, S, F>(uiSchema);
@@ -44,6 +45,7 @@ export default function ObjectFieldTemplate<
44
45
  registry,
45
46
  uiOptions,
46
47
  );
48
+ const showOptionalDataControlInTitle = !readonly && !disabled;
47
49
  // Button templates are not overridden in the uiSchema
48
50
  const {
49
51
  ButtonTemplates: { AddButton },
@@ -52,23 +54,25 @@ export default function ObjectFieldTemplate<
52
54
  <>
53
55
  {title && (
54
56
  <TitleFieldTemplate
55
- id={titleId<T>(idSchema)}
57
+ id={titleId(fieldPathId)}
56
58
  title={title}
57
59
  required={required}
58
60
  schema={schema}
59
61
  uiSchema={uiSchema}
60
62
  registry={registry}
63
+ optionalDataControl={showOptionalDataControlInTitle ? optionalDataControl : undefined}
61
64
  />
62
65
  )}
63
66
  {description && (
64
67
  <DescriptionFieldTemplate
65
- id={descriptionId<T>(idSchema)}
68
+ id={descriptionId(fieldPathId)}
66
69
  description={description}
67
70
  schema={schema}
68
71
  uiSchema={uiSchema}
69
72
  registry={registry}
70
73
  />
71
74
  )}
75
+ {!showOptionalDataControlInTitle ? optionalDataControl : undefined}
72
76
  {properties.map((prop) => prop.content)}
73
77
  {canExpand<T, S, F>(schema, uiSchema, formData) && (
74
78
  <Grid.Column width={16} verticalAlign='middle'>
@@ -81,9 +85,9 @@ export default function ObjectFieldTemplate<
81
85
  }}
82
86
  >
83
87
  <AddButton
84
- id={buttonId<T>(idSchema, 'add')}
88
+ id={buttonId(fieldPathId, 'add')}
85
89
  className='rjsf-object-property-expand'
86
- onClick={onAddClick(schema)}
90
+ onClick={onAddProperty}
87
91
  disabled={disabled || readonly}
88
92
  uiSchema={uiSchema}
89
93
  registry={registry}