@rjsf/core 6.0.0 → 6.0.2

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/dist/core.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/cloneDeep'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/set'), require('lodash/toPath'), require('lodash/isObject'), require('lodash/uniqueId'), require('react/jsx-runtime'), require('lodash/each'), require('lodash/flatten'), require('lodash/has'), require('lodash/includes'), require('lodash/intersection'), require('lodash/isFunction'), require('lodash/isEqual'), require('lodash/isPlainObject'), require('lodash/isString'), require('lodash/isUndefined'), require('lodash/last'), require('lodash/noop'), require('lodash/omit'), require('markdown-to-jsx'), require('lodash/unset'), require('@rjsf/validator-ajv8')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/isFunction', 'lodash/isEqual', 'lodash/isPlainObject', 'lodash/isString', 'lodash/isUndefined', 'lodash/last', 'lodash/noop', 'lodash/omit', 'markdown-to-jsx', 'lodash/unset', '@rjsf/validator-ajv8'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global.cloneDeep, global.get, global.isEmpty, global._pick, global.set, global._toPath, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isFunction, global.isEqual, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.Markdown, global.unset, global.validator));
5
- })(this, (function (exports, react, utils, cloneDeep, get, isEmpty, _pick, set, _toPath, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isFunction, isEqual, isPlainObject, isString, isUndefined, last, noop, omit3, Markdown, unset, validator) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@rjsf/utils'), require('lodash/cloneDeep'), require('lodash/get'), require('lodash/isEmpty'), require('lodash/pick'), require('lodash/set'), require('lodash/toPath'), require('lodash/unset'), require('lodash/isObject'), require('lodash/uniqueId'), require('react/jsx-runtime'), require('lodash/each'), require('lodash/flatten'), require('lodash/has'), require('lodash/includes'), require('lodash/intersection'), require('lodash/isFunction'), require('lodash/isEqual'), require('lodash/isPlainObject'), require('lodash/isString'), require('lodash/isUndefined'), require('lodash/last'), require('lodash/noop'), require('lodash/omit'), require('markdown-to-jsx'), require('@rjsf/validator-ajv8')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', '@rjsf/utils', 'lodash/cloneDeep', 'lodash/get', 'lodash/isEmpty', 'lodash/pick', 'lodash/set', 'lodash/toPath', 'lodash/unset', 'lodash/isObject', 'lodash/uniqueId', 'react/jsx-runtime', 'lodash/each', 'lodash/flatten', 'lodash/has', 'lodash/includes', 'lodash/intersection', 'lodash/isFunction', 'lodash/isEqual', 'lodash/isPlainObject', 'lodash/isString', 'lodash/isUndefined', 'lodash/last', 'lodash/noop', 'lodash/omit', 'markdown-to-jsx', '@rjsf/validator-ajv8'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSONSchemaForm = {}, global.react, global.utils, global.cloneDeep, global.get, global.isEmpty, global._pick, global.set, global._toPath, global._unset, global.isObject, global.uniqueId, global.jsxRuntime, global.each, global.flatten, global.has, global.includes, global.intersection, global.isFunction, global.isEqual, global.isPlainObject, global.isString, global.isUndefined, global.last, global.noop, global.omit3, global.Markdown, global.validator));
5
+ })(this, (function (exports, react, utils, cloneDeep, get, isEmpty, _pick, set, _toPath, _unset, isObject, uniqueId, jsxRuntime, each, flatten, has, includes, intersection, isFunction, isEqual, isPlainObject, isString, isUndefined, last, noop, omit3, Markdown, validator) { 'use strict';
6
6
 
7
7
  // src/components/Form.tsx
8
8
  function generateRowId() {
@@ -53,9 +53,11 @@
53
53
  }
54
54
  }
55
55
  function getNewFormDataRow(registry, schema) {
56
- const { schemaUtils } = registry;
56
+ const { schemaUtils, globalFormOptions } = registry;
57
57
  let itemSchema = schema.items;
58
- if (utils.isFixedItems(schema) && utils.allowAdditionalItems(schema)) {
58
+ if (globalFormOptions.useFallbackUiForUnsupportedType && !itemSchema) {
59
+ itemSchema = {};
60
+ } else if (utils.isFixedItems(schema) && utils.allowAdditionalItems(schema)) {
59
61
  itemSchema = schema.additionalItems;
60
62
  }
61
63
  return schemaUtils.getDefaultFormState(itemSchema);
@@ -590,7 +592,7 @@
590
592
  }
591
593
  function ArrayField(props) {
592
594
  const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
593
- const { schemaUtils, translateString } = registry;
595
+ const { globalFormOptions, schemaUtils, translateString } = registry;
594
596
  const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
595
597
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
596
598
  const handleAddItem = react.useCallback(
@@ -727,24 +729,14 @@
727
729
  },
728
730
  [onChange, childFieldPathId]
729
731
  );
730
- if (!(utils.ITEMS_KEY in schema)) {
731
- const uiOptions = utils.getUiOptions(uiSchema);
732
- const UnsupportedFieldTemplate = utils.getTemplate(
733
- "UnsupportedFieldTemplate",
734
- registry,
735
- uiOptions
736
- );
737
- return /* @__PURE__ */ jsxRuntime.jsx(
738
- UnsupportedFieldTemplate,
739
- {
740
- schema,
741
- fieldPathId,
742
- reason: translateString(utils.TranslatableString.MissingItems),
743
- registry
744
- }
745
- );
746
- }
732
+ const arrayAsMultiProps = {
733
+ ...props,
734
+ formData,
735
+ fieldPathId: childFieldPathId,
736
+ onSelectChange
737
+ };
747
738
  const arrayProps = {
739
+ ...props,
748
740
  handleAddItem,
749
741
  handleCopyItem,
750
742
  handleRemoveItem,
@@ -752,19 +744,41 @@
752
744
  keyedFormData,
753
745
  onChange: handleChange
754
746
  };
755
- if (schemaUtils.isMultiSelect(schema)) {
756
- return /* @__PURE__ */ jsxRuntime.jsx(ArrayAsMultiSelect, { ...props, fieldPathId: childFieldPathId, onSelectChange });
747
+ if (!(utils.ITEMS_KEY in schema)) {
748
+ if (!globalFormOptions.useFallbackUiForUnsupportedType) {
749
+ const uiOptions = utils.getUiOptions(uiSchema);
750
+ const UnsupportedFieldTemplate = utils.getTemplate(
751
+ "UnsupportedFieldTemplate",
752
+ registry,
753
+ uiOptions
754
+ );
755
+ return /* @__PURE__ */ jsxRuntime.jsx(
756
+ UnsupportedFieldTemplate,
757
+ {
758
+ schema,
759
+ fieldPathId,
760
+ reason: translateString(utils.TranslatableString.MissingItems),
761
+ registry
762
+ }
763
+ );
764
+ }
765
+ const fallbackSchema = { ...schema, [utils.ITEMS_KEY]: { type: void 0 } };
766
+ arrayAsMultiProps.schema = fallbackSchema;
767
+ arrayProps.schema = fallbackSchema;
768
+ }
769
+ if (schemaUtils.isMultiSelect(arrayAsMultiProps.schema)) {
770
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayAsMultiSelect, { ...arrayAsMultiProps });
757
771
  }
758
772
  if (utils.isCustomWidget(uiSchema)) {
759
- return /* @__PURE__ */ jsxRuntime.jsx(ArrayAsCustomWidget, { ...props, fieldPathId: childFieldPathId, onSelectChange });
773
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayAsCustomWidget, { ...arrayAsMultiProps });
760
774
  }
761
- if (utils.isFixedItems(schema)) {
762
- return /* @__PURE__ */ jsxRuntime.jsx(FixedArray, { ...props, ...arrayProps });
775
+ if (utils.isFixedItems(arrayAsMultiProps.schema)) {
776
+ return /* @__PURE__ */ jsxRuntime.jsx(FixedArray, { ...arrayProps });
763
777
  }
764
- if (schemaUtils.isFilesArray(schema, uiSchema)) {
765
- return /* @__PURE__ */ jsxRuntime.jsx(ArrayAsFiles, { ...props, fieldPathId: childFieldPathId, onSelectChange });
778
+ if (schemaUtils.isFilesArray(arrayAsMultiProps.schema, uiSchema)) {
779
+ return /* @__PURE__ */ jsxRuntime.jsx(ArrayAsFiles, { ...arrayAsMultiProps });
766
780
  }
767
- return /* @__PURE__ */ jsxRuntime.jsx(NormalArray, { ...props, ...arrayProps });
781
+ return /* @__PURE__ */ jsxRuntime.jsx(NormalArray, { ...arrayProps });
768
782
  }
769
783
  function BooleanField(props) {
770
784
  const {
@@ -868,7 +882,7 @@
868
882
  function getFallbackTypeSelectionSchema(title) {
869
883
  return {
870
884
  type: "string",
871
- enum: ["string", "number", "boolean"],
885
+ enum: ["string", "number", "boolean", "object", "array"],
872
886
  default: "string",
873
887
  title
874
888
  };
@@ -878,6 +892,9 @@
878
892
  if (dataType === "string" || dataType === "number" || dataType === "boolean") {
879
893
  return dataType;
880
894
  }
895
+ if (dataType === "object") {
896
+ return Array.isArray(formData) ? "array" : "object";
897
+ }
881
898
  return "string";
882
899
  }
883
900
  function castToNewType(formData, newType) {
@@ -927,20 +944,13 @@
927
944
  }
928
945
  };
929
946
  if (!globalFormOptions.useFallbackUiForUnsupportedType) {
947
+ const { reason = translateString(utils.TranslatableString.UnknownFieldType, [String(schema.type)]) } = props;
930
948
  const UnsupportedFieldTemplate = utils.getTemplate(
931
949
  "UnsupportedFieldTemplate",
932
950
  registry,
933
951
  uiOptions
934
952
  );
935
- return /* @__PURE__ */ jsxRuntime.jsx(
936
- UnsupportedFieldTemplate,
937
- {
938
- schema,
939
- fieldPathId,
940
- reason: translateString(utils.TranslatableString.UnknownFieldType, [String(schema.type)]),
941
- registry
942
- }
943
- );
953
+ return /* @__PURE__ */ jsxRuntime.jsx(UnsupportedFieldTemplate, { schema, fieldPathId, reason, registry });
944
954
  }
945
955
  const FallbackFieldTemplate2 = utils.getTemplate(
946
956
  "FallbackFieldTemplate",
@@ -971,7 +981,17 @@
971
981
  },
972
982
  formData ? utils.hashObject(formData) : "__empty__"
973
983
  ),
974
- schemaField: /* @__PURE__ */ jsxRuntime.jsx(SchemaField2, { ...props, schema: { type, title: translateString(utils.TranslatableString.Value) } })
984
+ schemaField: /* @__PURE__ */ jsxRuntime.jsx(
985
+ SchemaField2,
986
+ {
987
+ ...props,
988
+ schema: {
989
+ type,
990
+ title: translateString(utils.TranslatableString.Value),
991
+ ...type === "object" && { additionalProperties: true }
992
+ }
993
+ }
994
+ )
975
995
  }
976
996
  );
977
997
  }
@@ -1704,6 +1724,10 @@
1704
1724
  return /* @__PURE__ */ jsxRuntime.jsx(StringField2, { ...props, formData: value, onChange: handleChange });
1705
1725
  }
1706
1726
  var NumberField_default = NumberField;
1727
+
1728
+ // src/components/constants.ts
1729
+ var ADDITIONAL_PROPERTY_KEY_REMOVE = Symbol("remove-this-key");
1730
+ var IS_RESET = Symbol("reset");
1707
1731
  function isRequired(schema, name) {
1708
1732
  return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
1709
1733
  }
@@ -1827,7 +1851,6 @@
1827
1851
  const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
1828
1852
  const uiOptions = utils.getUiOptions(uiSchema, globalUiOptions);
1829
1853
  const { properties: schemaProperties = {} } = schema;
1830
- const formDataHash = utils.hashObject(formData || {});
1831
1854
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
1832
1855
  const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
1833
1856
  const description = uiOptions.description ?? schema.description;
@@ -1900,11 +1923,9 @@
1900
1923
  );
1901
1924
  const handleRemoveProperty = react.useCallback(
1902
1925
  (key) => {
1903
- const copiedFormData = { ...formData };
1904
- unset(copiedFormData, key);
1905
- onChange(copiedFormData, childFieldPathId.path);
1926
+ onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
1906
1927
  },
1907
- [onChange, childFieldPathId, formData]
1928
+ [onChange, childFieldPathId]
1908
1929
  );
1909
1930
  if (!renderOptionalField || hasFormData) {
1910
1931
  try {
@@ -1948,7 +1969,7 @@
1948
1969
  readonly,
1949
1970
  hideError
1950
1971
  },
1951
- addedByAdditionalProperties ? `${name2}-${formDataHash}` : name2
1972
+ name2
1952
1973
  );
1953
1974
  return {
1954
1975
  content,
@@ -2781,8 +2802,9 @@
2781
2802
  if (hidden) {
2782
2803
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden", children });
2783
2804
  }
2805
+ const isCheckbox = uiOptions.widget === "checkbox";
2784
2806
  return /* @__PURE__ */ jsxRuntime.jsxs(WrapIfAdditionalTemplate2, { ...props, children: [
2785
- displayLabel && /* @__PURE__ */ jsxRuntime.jsx(Label, { label, required, id }),
2807
+ displayLabel && !isCheckbox && /* @__PURE__ */ jsxRuntime.jsx(Label, { label, required, id }),
2786
2808
  displayLabel && description ? description : null,
2787
2809
  children,
2788
2810
  errors,
@@ -3101,7 +3123,9 @@
3101
3123
  (event) => onFocus(id, event.target.checked),
3102
3124
  [onFocus, id]
3103
3125
  );
3104
- const description = options.description ?? schema.description;
3126
+ const uiOptions = utils.getUiOptions(uiSchema);
3127
+ const isCheckboxWidget = uiOptions.widget === "checkbox";
3128
+ const description = isCheckboxWidget ? void 0 : options.description ?? schema.description;
3105
3129
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
3106
3130
  !hideLabel && description && /* @__PURE__ */ jsxRuntime.jsx(
3107
3131
  DescriptionFieldTemplate,
@@ -3659,7 +3683,6 @@
3659
3683
  }
3660
3684
  };
3661
3685
  }
3662
- var IS_RESET = Symbol("reset");
3663
3686
  function toIChangeEvent(state, status) {
3664
3687
  return {
3665
3688
  ..._pick(state, ["schema", "uiSchema", "fieldPathId", "schemaUtils", "formData", "edit", "errors", "errorSchema"]),
@@ -4091,7 +4114,9 @@
4091
4114
  let retrievedSchema = this.state.retrievedSchema;
4092
4115
  let formData = isRootPath ? newValue : cloneDeep(oldFormData);
4093
4116
  if (utils.isObject(formData) || Array.isArray(formData)) {
4094
- if (!isRootPath) {
4117
+ if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
4118
+ _unset(formData, path);
4119
+ } else if (!isRootPath) {
4095
4120
  set(formData, path, newValue);
4096
4121
  }
4097
4122
  const newState = this.getStateFromProps(this.props, formData, void 0, void 0, void 0, true);
package/dist/index.cjs CHANGED
@@ -47,6 +47,7 @@ var import_isEmpty4 = __toESM(require("lodash/isEmpty"), 1);
47
47
  var import_pick = __toESM(require("lodash/pick"), 1);
48
48
  var import_set5 = __toESM(require("lodash/set"), 1);
49
49
  var import_toPath = __toESM(require("lodash/toPath"), 1);
50
+ var import_unset = __toESM(require("lodash/unset"), 1);
50
51
 
51
52
  // src/getDefaultRegistry.ts
52
53
  var import_utils47 = require("@rjsf/utils");
@@ -107,9 +108,11 @@ function computeItemUiSchema(uiSchema, item, index, formContext) {
107
108
  }
108
109
  }
109
110
  function getNewFormDataRow(registry, schema) {
110
- const { schemaUtils } = registry;
111
+ const { schemaUtils, globalFormOptions } = registry;
111
112
  let itemSchema = schema.items;
112
- if ((0, import_utils.isFixedItems)(schema) && (0, import_utils.allowAdditionalItems)(schema)) {
113
+ if (globalFormOptions.useFallbackUiForUnsupportedType && !itemSchema) {
114
+ itemSchema = {};
115
+ } else if ((0, import_utils.isFixedItems)(schema) && (0, import_utils.allowAdditionalItems)(schema)) {
113
116
  itemSchema = schema.additionalItems;
114
117
  }
115
118
  return schemaUtils.getDefaultFormState(itemSchema);
@@ -644,7 +647,7 @@ function useKeyedFormData(formData = []) {
644
647
  }
645
648
  function ArrayField(props) {
646
649
  const { schema, uiSchema, errorSchema, fieldPathId, registry, formData, onChange } = props;
647
- const { schemaUtils, translateString } = registry;
650
+ const { globalFormOptions, schemaUtils, translateString } = registry;
648
651
  const { keyedFormData, updateKeyedFormData } = useKeyedFormData(formData);
649
652
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
650
653
  const handleAddItem = (0, import_react.useCallback)(
@@ -781,24 +784,14 @@ function ArrayField(props) {
781
784
  },
782
785
  [onChange, childFieldPathId]
783
786
  );
784
- if (!(import_utils.ITEMS_KEY in schema)) {
785
- const uiOptions = (0, import_utils.getUiOptions)(uiSchema);
786
- const UnsupportedFieldTemplate = (0, import_utils.getTemplate)(
787
- "UnsupportedFieldTemplate",
788
- registry,
789
- uiOptions
790
- );
791
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
792
- UnsupportedFieldTemplate,
793
- {
794
- schema,
795
- fieldPathId,
796
- reason: translateString(import_utils.TranslatableString.MissingItems),
797
- registry
798
- }
799
- );
800
- }
787
+ const arrayAsMultiProps = {
788
+ ...props,
789
+ formData,
790
+ fieldPathId: childFieldPathId,
791
+ onSelectChange
792
+ };
801
793
  const arrayProps = {
794
+ ...props,
802
795
  handleAddItem,
803
796
  handleCopyItem,
804
797
  handleRemoveItem,
@@ -806,19 +799,41 @@ function ArrayField(props) {
806
799
  keyedFormData,
807
800
  onChange: handleChange
808
801
  };
809
- if (schemaUtils.isMultiSelect(schema)) {
810
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrayAsMultiSelect, { ...props, fieldPathId: childFieldPathId, onSelectChange });
802
+ if (!(import_utils.ITEMS_KEY in schema)) {
803
+ if (!globalFormOptions.useFallbackUiForUnsupportedType) {
804
+ const uiOptions = (0, import_utils.getUiOptions)(uiSchema);
805
+ const UnsupportedFieldTemplate = (0, import_utils.getTemplate)(
806
+ "UnsupportedFieldTemplate",
807
+ registry,
808
+ uiOptions
809
+ );
810
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
811
+ UnsupportedFieldTemplate,
812
+ {
813
+ schema,
814
+ fieldPathId,
815
+ reason: translateString(import_utils.TranslatableString.MissingItems),
816
+ registry
817
+ }
818
+ );
819
+ }
820
+ const fallbackSchema = { ...schema, [import_utils.ITEMS_KEY]: { type: void 0 } };
821
+ arrayAsMultiProps.schema = fallbackSchema;
822
+ arrayProps.schema = fallbackSchema;
823
+ }
824
+ if (schemaUtils.isMultiSelect(arrayAsMultiProps.schema)) {
825
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrayAsMultiSelect, { ...arrayAsMultiProps });
811
826
  }
812
827
  if ((0, import_utils.isCustomWidget)(uiSchema)) {
813
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrayAsCustomWidget, { ...props, fieldPathId: childFieldPathId, onSelectChange });
828
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrayAsCustomWidget, { ...arrayAsMultiProps });
814
829
  }
815
- if ((0, import_utils.isFixedItems)(schema)) {
816
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FixedArray, { ...props, ...arrayProps });
830
+ if ((0, import_utils.isFixedItems)(arrayAsMultiProps.schema)) {
831
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FixedArray, { ...arrayProps });
817
832
  }
818
- if (schemaUtils.isFilesArray(schema, uiSchema)) {
819
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrayAsFiles, { ...props, fieldPathId: childFieldPathId, onSelectChange });
833
+ if (schemaUtils.isFilesArray(arrayAsMultiProps.schema, uiSchema)) {
834
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrayAsFiles, { ...arrayAsMultiProps });
820
835
  }
821
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NormalArray, { ...props, ...arrayProps });
836
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(NormalArray, { ...arrayProps });
822
837
  }
823
838
 
824
839
  // src/components/fields/BooleanField.tsx
@@ -933,7 +948,7 @@ var import_jsx_runtime3 = require("react/jsx-runtime");
933
948
  function getFallbackTypeSelectionSchema(title) {
934
949
  return {
935
950
  type: "string",
936
- enum: ["string", "number", "boolean"],
951
+ enum: ["string", "number", "boolean", "object", "array"],
937
952
  default: "string",
938
953
  title
939
954
  };
@@ -943,6 +958,9 @@ function getTypeOfFormData(formData) {
943
958
  if (dataType === "string" || dataType === "number" || dataType === "boolean") {
944
959
  return dataType;
945
960
  }
961
+ if (dataType === "object") {
962
+ return Array.isArray(formData) ? "array" : "object";
963
+ }
946
964
  return "string";
947
965
  }
948
966
  function castToNewType(formData, newType) {
@@ -992,20 +1010,13 @@ function FallbackField(props) {
992
1010
  }
993
1011
  };
994
1012
  if (!globalFormOptions.useFallbackUiForUnsupportedType) {
1013
+ const { reason = translateString(import_utils3.TranslatableString.UnknownFieldType, [String(schema.type)]) } = props;
995
1014
  const UnsupportedFieldTemplate = (0, import_utils3.getTemplate)(
996
1015
  "UnsupportedFieldTemplate",
997
1016
  registry,
998
1017
  uiOptions
999
1018
  );
1000
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1001
- UnsupportedFieldTemplate,
1002
- {
1003
- schema,
1004
- fieldPathId,
1005
- reason: translateString(import_utils3.TranslatableString.UnknownFieldType, [String(schema.type)]),
1006
- registry
1007
- }
1008
- );
1019
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UnsupportedFieldTemplate, { schema, fieldPathId, reason, registry });
1009
1020
  }
1010
1021
  const FallbackFieldTemplate2 = (0, import_utils3.getTemplate)(
1011
1022
  "FallbackFieldTemplate",
@@ -1036,7 +1047,17 @@ function FallbackField(props) {
1036
1047
  },
1037
1048
  formData ? (0, import_utils3.hashObject)(formData) : "__empty__"
1038
1049
  ),
1039
- schemaField: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SchemaField2, { ...props, schema: { type, title: translateString(import_utils3.TranslatableString.Value) } })
1050
+ schemaField: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1051
+ SchemaField2,
1052
+ {
1053
+ ...props,
1054
+ schema: {
1055
+ type,
1056
+ title: translateString(import_utils3.TranslatableString.Value),
1057
+ ...type === "object" && { additionalProperties: true }
1058
+ }
1059
+ }
1060
+ )
1040
1061
  }
1041
1062
  );
1042
1063
  }
@@ -1827,7 +1848,12 @@ var import_get4 = __toESM(require("lodash/get"), 1);
1827
1848
  var import_has3 = __toESM(require("lodash/has"), 1);
1828
1849
  var import_isObject4 = __toESM(require("lodash/isObject"), 1);
1829
1850
  var import_set4 = __toESM(require("lodash/set"), 1);
1830
- var import_unset = __toESM(require("lodash/unset"), 1);
1851
+
1852
+ // src/components/constants.ts
1853
+ var ADDITIONAL_PROPERTY_KEY_REMOVE = Symbol("remove-this-key");
1854
+ var IS_RESET = Symbol("reset");
1855
+
1856
+ // src/components/fields/ObjectField.tsx
1831
1857
  var import_jsx_runtime9 = require("react/jsx-runtime");
1832
1858
  function isRequired(schema, name) {
1833
1859
  return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
@@ -1952,7 +1978,6 @@ function ObjectField(props) {
1952
1978
  const schema = schemaUtils.retrieveSchema(rawSchema, formData, true);
1953
1979
  const uiOptions = (0, import_utils9.getUiOptions)(uiSchema, globalUiOptions);
1954
1980
  const { properties: schemaProperties = {} } = schema;
1955
- const formDataHash = (0, import_utils9.hashObject)(formData || {});
1956
1981
  const childFieldPathId = props.childFieldPathId ?? fieldPathId;
1957
1982
  const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
1958
1983
  const description = uiOptions.description ?? schema.description;
@@ -2025,11 +2050,9 @@ function ObjectField(props) {
2025
2050
  );
2026
2051
  const handleRemoveProperty = (0, import_react8.useCallback)(
2027
2052
  (key) => {
2028
- const copiedFormData = { ...formData };
2029
- (0, import_unset.default)(copiedFormData, key);
2030
- onChange(copiedFormData, childFieldPathId.path);
2053
+ onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
2031
2054
  },
2032
- [onChange, childFieldPathId, formData]
2055
+ [onChange, childFieldPathId]
2033
2056
  );
2034
2057
  if (!renderOptionalField || hasFormData) {
2035
2058
  try {
@@ -2073,7 +2096,7 @@ function ObjectField(props) {
2073
2096
  readonly,
2074
2097
  hideError
2075
2098
  },
2076
- addedByAdditionalProperties ? `${name2}-${formDataHash}` : name2
2099
+ name2
2077
2100
  );
2078
2101
  return {
2079
2102
  content,
@@ -2989,8 +3012,9 @@ function FieldTemplate(props) {
2989
3012
  if (hidden) {
2990
3013
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "hidden", children });
2991
3014
  }
3015
+ const isCheckbox = uiOptions.widget === "checkbox";
2992
3016
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(WrapIfAdditionalTemplate2, { ...props, children: [
2993
- displayLabel && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Label, { label, required, id }),
3017
+ displayLabel && !isCheckbox && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Label, { label, required, id }),
2994
3018
  displayLabel && description ? description : null,
2995
3019
  children,
2996
3020
  errors,
@@ -3354,7 +3378,9 @@ function CheckboxWidget({
3354
3378
  (event) => onFocus(id, event.target.checked),
3355
3379
  [onFocus, id]
3356
3380
  );
3357
- const description = options.description ?? schema.description;
3381
+ const uiOptions = (0, import_utils32.getUiOptions)(uiSchema);
3382
+ const isCheckboxWidget = uiOptions.widget === "checkbox";
3383
+ const description = isCheckboxWidget ? void 0 : options.description ?? schema.description;
3358
3384
  return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
3359
3385
  !hideLabel && description && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3360
3386
  DescriptionFieldTemplate,
@@ -3988,7 +4014,6 @@ function getDefaultRegistry() {
3988
4014
 
3989
4015
  // src/components/Form.tsx
3990
4016
  var import_jsx_runtime57 = require("react/jsx-runtime");
3991
- var IS_RESET = Symbol("reset");
3992
4017
  function toIChangeEvent(state, status) {
3993
4018
  return {
3994
4019
  ...(0, import_pick.default)(state, ["schema", "uiSchema", "fieldPathId", "schemaUtils", "formData", "edit", "errors", "errorSchema"]),
@@ -4420,7 +4445,9 @@ var Form = class extends import_react21.Component {
4420
4445
  let retrievedSchema = this.state.retrievedSchema;
4421
4446
  let formData = isRootPath ? newValue : (0, import_cloneDeep2.default)(oldFormData);
4422
4447
  if ((0, import_utils48.isObject)(formData) || Array.isArray(formData)) {
4423
- if (!isRootPath) {
4448
+ if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
4449
+ (0, import_unset.default)(formData, path);
4450
+ } else if (!isRootPath) {
4424
4451
  (0, import_set5.default)(formData, path, newValue);
4425
4452
  }
4426
4453
  const newState = this.getStateFromProps(this.props, formData, void 0, void 0, void 0, true);