@rjsf/core 6.6.2 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -0
- package/dist/core.umd.js +274 -245
- package/dist/index.cjs +911 -873
- package/dist/index.cjs.map +4 -4
- package/dist/index.esm.js +702 -659
- package/dist/index.esm.js.map +4 -4
- package/lib/components/Form.d.ts +2 -2
- package/lib/components/Form.d.ts.map +1 -1
- package/lib/components/Form.js +30 -15
- package/lib/components/RichDescription.d.ts +1 -1
- package/lib/components/RichDescription.d.ts.map +1 -1
- package/lib/components/RichHelp.d.ts +1 -1
- package/lib/components/RichHelp.d.ts.map +1 -1
- package/lib/components/SchemaExamples.d.ts +1 -1
- package/lib/components/SchemaExamples.d.ts.map +1 -1
- package/lib/components/fields/ArrayField.d.ts +1 -1
- package/lib/components/fields/ArrayField.d.ts.map +1 -1
- package/lib/components/fields/BooleanField.d.ts +1 -1
- package/lib/components/fields/BooleanField.d.ts.map +1 -1
- package/lib/components/fields/CyclicSchemaField.d.ts +8 -0
- package/lib/components/fields/CyclicSchemaField.d.ts.map +1 -0
- package/lib/components/fields/CyclicSchemaField.js +21 -0
- package/lib/components/fields/FallbackField.d.ts +1 -1
- package/lib/components/fields/FallbackField.d.ts.map +1 -1
- package/lib/components/fields/LayoutGridField.d.ts +1 -1
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -1
- package/lib/components/fields/LayoutHeaderField.d.ts +1 -1
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts +1 -1
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.d.ts +1 -46
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -1
- package/lib/components/fields/MultiSchemaField.js +111 -135
- package/lib/components/fields/NumberField.d.ts +1 -1
- package/lib/components/fields/NumberField.d.ts.map +1 -1
- package/lib/components/fields/NumberField.js +1 -1
- package/lib/components/fields/ObjectField.d.ts +1 -1
- package/lib/components/fields/ObjectField.d.ts.map +1 -1
- package/lib/components/fields/ObjectField.js +2 -2
- package/lib/components/fields/OptionalDataControlsField.d.ts +1 -1
- package/lib/components/fields/OptionalDataControlsField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.d.ts +13 -7
- package/lib/components/fields/SchemaField.d.ts.map +1 -1
- package/lib/components/fields/SchemaField.js +37 -24
- package/lib/components/fields/StringField.d.ts +1 -1
- package/lib/components/fields/StringField.d.ts.map +1 -1
- package/lib/components/fields/index.d.ts.map +1 -1
- package/lib/components/fields/index.js +2 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +1 -1
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -1
- package/lib/components/templates/BaseInputTemplate.js +2 -2
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +6 -6
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -1
- package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts +7 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.d.ts.map +1 -0
- package/lib/components/templates/CyclicSchemaExpandTemplate.js +12 -0
- package/lib/components/templates/DescriptionField.d.ts +1 -1
- package/lib/components/templates/DescriptionField.d.ts.map +1 -1
- package/lib/components/templates/ErrorList.d.ts +1 -1
- package/lib/components/templates/ErrorList.d.ts.map +1 -1
- package/lib/components/templates/FallbackFieldTemplate.d.ts +1 -1
- package/lib/components/templates/FallbackFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +1 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts +1 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/FieldTemplate/Label.d.ts +1 -1
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -1
- package/lib/components/templates/GridTemplate.d.ts +1 -1
- package/lib/components/templates/GridTemplate.d.ts.map +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts +1 -1
- package/lib/components/templates/MultiSchemaFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -1
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts +1 -1
- package/lib/components/templates/OptionalDataControlsTemplate.d.ts.map +1 -1
- package/lib/components/templates/TitleField.d.ts +1 -1
- package/lib/components/templates/TitleField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.d.ts +1 -1
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -1
- package/lib/components/templates/UnsupportedField.js +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -1
- package/lib/components/templates/index.d.ts.map +1 -1
- package/lib/components/templates/index.js +2 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts +1 -1
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -1
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -1
- package/lib/components/widgets/CheckboxesWidget.js +2 -2
- package/lib/components/widgets/ColorWidget.d.ts +1 -1
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -1
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/DateWidget.d.ts +1 -1
- package/lib/components/widgets/DateWidget.d.ts.map +1 -1
- package/lib/components/widgets/EmailWidget.d.ts +1 -1
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -1
- package/lib/components/widgets/FileWidget.d.ts +1 -1
- package/lib/components/widgets/FileWidget.d.ts.map +1 -1
- package/lib/components/widgets/HiddenWidget.d.ts +1 -1
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts +1 -1
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.d.ts +1 -1
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -1
- package/lib/components/widgets/RadioWidget.js +2 -2
- package/lib/components/widgets/RangeWidget.d.ts +1 -1
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -1
- package/lib/components/widgets/RatingWidget.d.ts +1 -1
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.d.ts +1 -1
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -1
- package/lib/components/widgets/SelectWidget.js +9 -8
- package/lib/components/widgets/TextWidget.d.ts +1 -1
- package/lib/components/widgets/TextWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts +1 -1
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -1
- package/lib/components/widgets/TextareaWidget.js +3 -3
- package/lib/components/widgets/TimeWidget.d.ts +1 -1
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/URLWidget.d.ts +1 -1
- package/lib/components/widgets/URLWidget.d.ts.map +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts +1 -1
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -27
- package/src/components/Form.tsx +34 -15
- package/src/components/fields/CyclicSchemaField.tsx +40 -0
- package/src/components/fields/MultiSchemaField.tsx +201 -230
- package/src/components/fields/NumberField.tsx +1 -1
- package/src/components/fields/ObjectField.tsx +5 -2
- package/src/components/fields/SchemaField.tsx +46 -34
- package/src/components/fields/index.ts +2 -0
- package/src/components/templates/BaseInputTemplate.tsx +2 -5
- package/src/components/templates/CyclicSchemaExpandTemplate.tsx +31 -0
- package/src/components/templates/UnsupportedField.tsx +1 -1
- package/src/components/templates/index.ts +2 -0
- package/src/components/widgets/CheckboxesWidget.tsx +2 -2
- package/src/components/widgets/RadioWidget.tsx +2 -2
- package/src/components/widgets/SelectWidget.tsx +45 -30
- package/src/components/widgets/TextareaWidget.tsx +3 -3
package/dist/index.cjs
CHANGED
|
@@ -41,8 +41,8 @@ __export(index_exports, {
|
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
42
|
|
|
43
43
|
// src/components/Form.tsx
|
|
44
|
-
var
|
|
45
|
-
var
|
|
44
|
+
var import_react28 = require("react");
|
|
45
|
+
var import_utils52 = require("@rjsf/utils");
|
|
46
46
|
var import_cloneDeep2 = __toESM(require("lodash/cloneDeep"), 1);
|
|
47
47
|
var import_get5 = __toESM(require("lodash/get"), 1);
|
|
48
48
|
var import_isEmpty4 = __toESM(require("lodash/isEmpty"), 1);
|
|
@@ -52,7 +52,7 @@ var import_toPath = __toESM(require("lodash/toPath"), 1);
|
|
|
52
52
|
var import_unset = __toESM(require("lodash/unset"), 1);
|
|
53
53
|
|
|
54
54
|
// src/getDefaultRegistry.ts
|
|
55
|
-
var
|
|
55
|
+
var import_utils51 = require("@rjsf/utils");
|
|
56
56
|
|
|
57
57
|
// src/components/fields/ArrayField.tsx
|
|
58
58
|
var import_react = require("react");
|
|
@@ -962,10 +962,42 @@ function BooleanField(props) {
|
|
|
962
962
|
}
|
|
963
963
|
var BooleanField_default = BooleanField;
|
|
964
964
|
|
|
965
|
-
// src/components/fields/
|
|
965
|
+
// src/components/fields/CyclicSchemaField.tsx
|
|
966
966
|
var import_react3 = require("react");
|
|
967
967
|
var import_utils3 = require("@rjsf/utils");
|
|
968
968
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
969
|
+
function CyclicSchemaField(props) {
|
|
970
|
+
const [expanded, setExpanded] = (0, import_react3.useState)(false);
|
|
971
|
+
const { name, registry, schema, uiSchema, fieldPathId } = props;
|
|
972
|
+
const { globalUiOptions } = registry;
|
|
973
|
+
const uiOptions = (0, import_utils3.getUiOptions)(uiSchema, globalUiOptions);
|
|
974
|
+
const CyclicSchemaExpandTemplate2 = (0, import_utils3.getTemplate)(
|
|
975
|
+
"CyclicSchemaExpandTemplate",
|
|
976
|
+
registry,
|
|
977
|
+
uiOptions
|
|
978
|
+
);
|
|
979
|
+
if (!expanded) {
|
|
980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
981
|
+
CyclicSchemaExpandTemplate2,
|
|
982
|
+
{
|
|
983
|
+
registry,
|
|
984
|
+
schema,
|
|
985
|
+
uiSchema,
|
|
986
|
+
name,
|
|
987
|
+
fieldPathId,
|
|
988
|
+
onExpand: () => setExpanded(true)
|
|
989
|
+
}
|
|
990
|
+
);
|
|
991
|
+
}
|
|
992
|
+
const { fields: fields2 } = registry;
|
|
993
|
+
const { SchemaField: SchemaField2 } = fields2;
|
|
994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SchemaField2, { ...props, schema: { ...schema, [import_utils3.RJSF_REF_CYCLE_KEY]: false } });
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
// src/components/fields/FallbackField.tsx
|
|
998
|
+
var import_react4 = require("react");
|
|
999
|
+
var import_utils4 = require("@rjsf/utils");
|
|
1000
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
969
1001
|
function getFallbackTypeSelectionSchema(title) {
|
|
970
1002
|
return {
|
|
971
1003
|
type: "string",
|
|
@@ -1017,13 +1049,13 @@ function FallbackField(props) {
|
|
|
1017
1049
|
errorSchema
|
|
1018
1050
|
} = props;
|
|
1019
1051
|
const { translateString, fields: fields2, globalFormOptions } = registry;
|
|
1020
|
-
const [type, setType] = (0,
|
|
1021
|
-
const uiOptions = (0,
|
|
1022
|
-
const typeSelectorInnerFieldPathId = (0,
|
|
1023
|
-
(0,
|
|
1052
|
+
const [type, setType] = (0, import_react4.useState)(getTypeOfFormData(formData));
|
|
1053
|
+
const uiOptions = (0, import_utils4.getUiOptions)(uiSchema);
|
|
1054
|
+
const typeSelectorInnerFieldPathId = (0, import_utils4.useDeepCompareMemo)(
|
|
1055
|
+
(0, import_utils4.toFieldPathId)("__internal_type_selector", globalFormOptions, fieldPathId)
|
|
1024
1056
|
);
|
|
1025
|
-
const schemaTitle = translateString(
|
|
1026
|
-
const typesOptionSchema = (0,
|
|
1057
|
+
const schemaTitle = translateString(import_utils4.TranslatableString.Type);
|
|
1058
|
+
const typesOptionSchema = (0, import_react4.useMemo)(() => getFallbackTypeSelectionSchema(schemaTitle), [schemaTitle]);
|
|
1027
1059
|
const onTypeChange = (newType) => {
|
|
1028
1060
|
if (newType != null) {
|
|
1029
1061
|
setType(newType);
|
|
@@ -1031,26 +1063,26 @@ function FallbackField(props) {
|
|
|
1031
1063
|
}
|
|
1032
1064
|
};
|
|
1033
1065
|
if (!globalFormOptions.useFallbackUiForUnsupportedType) {
|
|
1034
|
-
const { reason = translateString(
|
|
1035
|
-
const UnsupportedFieldTemplate = (0,
|
|
1066
|
+
const { reason = translateString(import_utils4.TranslatableString.UnknownFieldType, [String(schema.type)]) } = props;
|
|
1067
|
+
const UnsupportedFieldTemplate = (0, import_utils4.getTemplate)(
|
|
1036
1068
|
"UnsupportedFieldTemplate",
|
|
1037
1069
|
registry,
|
|
1038
1070
|
uiOptions
|
|
1039
1071
|
);
|
|
1040
|
-
return /* @__PURE__ */ (0,
|
|
1072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(UnsupportedFieldTemplate, { schema, fieldPathId, reason, registry });
|
|
1041
1073
|
}
|
|
1042
|
-
const FallbackFieldTemplate2 = (0,
|
|
1074
|
+
const FallbackFieldTemplate2 = (0, import_utils4.getTemplate)(
|
|
1043
1075
|
"FallbackFieldTemplate",
|
|
1044
1076
|
registry,
|
|
1045
1077
|
uiOptions
|
|
1046
1078
|
);
|
|
1047
1079
|
const { SchemaField: SchemaField2 } = fields2;
|
|
1048
|
-
return /* @__PURE__ */ (0,
|
|
1080
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1049
1081
|
FallbackFieldTemplate2,
|
|
1050
1082
|
{
|
|
1051
1083
|
schema,
|
|
1052
1084
|
registry,
|
|
1053
|
-
typeSelector: /* @__PURE__ */ (0,
|
|
1085
|
+
typeSelector: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1054
1086
|
SchemaField2,
|
|
1055
1087
|
{
|
|
1056
1088
|
fieldPathId: typeSelectorInnerFieldPathId,
|
|
@@ -1066,15 +1098,15 @@ function FallbackField(props) {
|
|
|
1066
1098
|
readonly,
|
|
1067
1099
|
required
|
|
1068
1100
|
},
|
|
1069
|
-
formData ? (0,
|
|
1101
|
+
formData ? (0, import_utils4.hashObject)(formData) : "__empty__"
|
|
1070
1102
|
),
|
|
1071
|
-
schemaField: /* @__PURE__ */ (0,
|
|
1103
|
+
schemaField: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1072
1104
|
SchemaField2,
|
|
1073
1105
|
{
|
|
1074
1106
|
...props,
|
|
1075
1107
|
schema: {
|
|
1076
1108
|
type,
|
|
1077
|
-
title: translateString(
|
|
1109
|
+
title: translateString(import_utils4.TranslatableString.Value),
|
|
1078
1110
|
...type === "object" && { additionalProperties: true }
|
|
1079
1111
|
}
|
|
1080
1112
|
}
|
|
@@ -1084,7 +1116,7 @@ function FallbackField(props) {
|
|
|
1084
1116
|
}
|
|
1085
1117
|
|
|
1086
1118
|
// src/components/fields/LayoutGridField.tsx
|
|
1087
|
-
var
|
|
1119
|
+
var import_utils5 = require("@rjsf/utils");
|
|
1088
1120
|
var import_each = __toESM(require("lodash/each"), 1);
|
|
1089
1121
|
var import_flatten = __toESM(require("lodash/flatten"), 1);
|
|
1090
1122
|
var import_get = __toESM(require("lodash/get"), 1);
|
|
@@ -1100,8 +1132,8 @@ var import_isString = __toESM(require("lodash/isString"), 1);
|
|
|
1100
1132
|
var import_isUndefined = __toESM(require("lodash/isUndefined"), 1);
|
|
1101
1133
|
var import_last = __toESM(require("lodash/last"), 1);
|
|
1102
1134
|
var import_set2 = __toESM(require("lodash/set"), 1);
|
|
1103
|
-
var
|
|
1104
|
-
var
|
|
1135
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1136
|
+
var import_react5 = require("react");
|
|
1105
1137
|
var LOOKUP_REGEX = /^\$lookup=(.+)/;
|
|
1106
1138
|
var LAYOUT_GRID_UI_OPTION = "layoutGrid";
|
|
1107
1139
|
var LAYOUT_GRID_OPTION = `ui:${LAYOUT_GRID_UI_OPTION}`;
|
|
@@ -1111,25 +1143,25 @@ function getNonNullishValue(value, fallback) {
|
|
|
1111
1143
|
function isNumericIndex(str) {
|
|
1112
1144
|
return /^\d+?$/.test(str);
|
|
1113
1145
|
}
|
|
1114
|
-
var LAYOUT_GRID_FIELD_TEST_IDS = (0,
|
|
1146
|
+
var LAYOUT_GRID_FIELD_TEST_IDS = (0, import_utils5.getTestIds)();
|
|
1115
1147
|
function computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
|
|
1116
|
-
const globalUiOptions = (0, import_get.default)(uiSchema, [
|
|
1148
|
+
const globalUiOptions = (0, import_get.default)(uiSchema, [import_utils5.UI_GLOBAL_OPTIONS_KEY], {});
|
|
1117
1149
|
const localUiSchema = (0, import_get.default)(uiSchema, field);
|
|
1118
|
-
const localUiOptions = { ...(0, import_get.default)(localUiSchema, [
|
|
1150
|
+
const localUiOptions = { ...(0, import_get.default)(localUiSchema, [import_utils5.UI_OPTIONS_KEY], {}), ...uiProps, ...globalUiOptions };
|
|
1119
1151
|
const fieldUiSchema = { ...localUiSchema };
|
|
1120
1152
|
if (!(0, import_isEmpty.default)(localUiOptions)) {
|
|
1121
|
-
(0, import_set2.default)(fieldUiSchema, [
|
|
1153
|
+
(0, import_set2.default)(fieldUiSchema, [import_utils5.UI_OPTIONS_KEY], localUiOptions);
|
|
1122
1154
|
}
|
|
1123
1155
|
if (!(0, import_isEmpty.default)(globalUiOptions)) {
|
|
1124
|
-
(0, import_set2.default)(fieldUiSchema, [
|
|
1156
|
+
(0, import_set2.default)(fieldUiSchema, [import_utils5.UI_GLOBAL_OPTIONS_KEY], globalUiOptions);
|
|
1125
1157
|
}
|
|
1126
|
-
let { readonly: uiReadonly } = (0,
|
|
1158
|
+
let { readonly: uiReadonly } = (0, import_utils5.getUiOptions)(fieldUiSchema);
|
|
1127
1159
|
if (forceReadonly === true || (0, import_isUndefined.default)(uiReadonly) && schemaReadonly === true) {
|
|
1128
1160
|
uiReadonly = true;
|
|
1129
|
-
if ((0, import_has.default)(localUiOptions,
|
|
1130
|
-
(0, import_set2.default)(fieldUiSchema, [
|
|
1161
|
+
if ((0, import_has.default)(localUiOptions, import_utils5.READONLY_KEY)) {
|
|
1162
|
+
(0, import_set2.default)(fieldUiSchema, [import_utils5.UI_OPTIONS_KEY, import_utils5.READONLY_KEY], true);
|
|
1131
1163
|
} else {
|
|
1132
|
-
(0, import_set2.default)(fieldUiSchema, `ui:${
|
|
1164
|
+
(0, import_set2.default)(fieldUiSchema, `ui:${import_utils5.READONLY_KEY}`, true);
|
|
1133
1165
|
}
|
|
1134
1166
|
}
|
|
1135
1167
|
return { fieldUiSchema, uiReadonly };
|
|
@@ -1156,7 +1188,7 @@ function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
|
1156
1188
|
children = elements;
|
|
1157
1189
|
if (toMapClassNames) {
|
|
1158
1190
|
const classes = toMapClassNames.split(" ");
|
|
1159
|
-
const className = classes.map((ele) => (0,
|
|
1191
|
+
const className = classes.map((ele) => (0, import_utils5.lookupFromFormContext)(registry, ele, ele)).join(" ");
|
|
1160
1192
|
gridProps = { ...otherProps, className };
|
|
1161
1193
|
} else {
|
|
1162
1194
|
gridProps = otherProps;
|
|
@@ -1170,9 +1202,9 @@ function findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
|
1170
1202
|
function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
1171
1203
|
let rawSchema;
|
|
1172
1204
|
let resultPathId = fieldPathId;
|
|
1173
|
-
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && (0, import_has.default)(schema,
|
|
1205
|
+
if (isNumericIndex(potentialIndex) && schema && schema?.type === "array" && (0, import_has.default)(schema, import_utils5.ITEMS_KEY)) {
|
|
1174
1206
|
const index = Number(potentialIndex);
|
|
1175
|
-
const items = schema[
|
|
1207
|
+
const items = schema[import_utils5.ITEMS_KEY];
|
|
1176
1208
|
if (Array.isArray(items)) {
|
|
1177
1209
|
if (index > items.length) {
|
|
1178
1210
|
rawSchema = (0, import_last.default)(items);
|
|
@@ -1183,7 +1215,7 @@ function computeArraySchemasIfPresent(schema, fieldPathId, potentialIndex) {
|
|
|
1183
1215
|
rawSchema = items;
|
|
1184
1216
|
}
|
|
1185
1217
|
resultPathId = {
|
|
1186
|
-
[
|
|
1218
|
+
[import_utils5.ID_KEY]: fieldPathId[import_utils5.ID_KEY],
|
|
1187
1219
|
path: [...fieldPathId.path.slice(0, fieldPathId.path.length - 1), index]
|
|
1188
1220
|
};
|
|
1189
1221
|
}
|
|
@@ -1199,13 +1231,13 @@ function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData,
|
|
|
1199
1231
|
let innerData = formData;
|
|
1200
1232
|
let isReadonly = schema.readOnly;
|
|
1201
1233
|
parts.forEach((part) => {
|
|
1202
|
-
fieldPathId = (0,
|
|
1203
|
-
if ((0, import_has.default)(schema,
|
|
1204
|
-
rawSchema = (0, import_get.default)(schema, [
|
|
1205
|
-
} else if (schema && ((0, import_has.default)(schema,
|
|
1206
|
-
const xxx = (0, import_has.default)(schema,
|
|
1234
|
+
fieldPathId = (0, import_utils5.toFieldPathId)(part, globalFormOptions, fieldPathId);
|
|
1235
|
+
if ((0, import_has.default)(schema, import_utils5.PROPERTIES_KEY)) {
|
|
1236
|
+
rawSchema = (0, import_get.default)(schema, [import_utils5.PROPERTIES_KEY, part], {});
|
|
1237
|
+
} else if (schema && ((0, import_has.default)(schema, import_utils5.ONE_OF_KEY) || (0, import_has.default)(schema, import_utils5.ANY_OF_KEY))) {
|
|
1238
|
+
const xxx = (0, import_has.default)(schema, import_utils5.ONE_OF_KEY) ? import_utils5.ONE_OF_KEY : import_utils5.ANY_OF_KEY;
|
|
1207
1239
|
const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
|
|
1208
|
-
rawSchema = (0, import_get.default)(selectedSchema, [
|
|
1240
|
+
rawSchema = (0, import_get.default)(selectedSchema, [import_utils5.PROPERTIES_KEY, part], {});
|
|
1209
1241
|
} else {
|
|
1210
1242
|
const result = computeArraySchemasIfPresent(schema, fieldPathId, part);
|
|
1211
1243
|
rawSchema = result.rawSchema ?? {};
|
|
@@ -1221,24 +1253,24 @@ function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData,
|
|
|
1221
1253
|
schema = void 0;
|
|
1222
1254
|
}
|
|
1223
1255
|
if (schema && leafPath) {
|
|
1224
|
-
if (schema && ((0, import_has.default)(schema,
|
|
1225
|
-
const xxx = (0, import_has.default)(schema,
|
|
1256
|
+
if (schema && ((0, import_has.default)(schema, import_utils5.ONE_OF_KEY) || (0, import_has.default)(schema, import_utils5.ANY_OF_KEY))) {
|
|
1257
|
+
const xxx = (0, import_has.default)(schema, import_utils5.ONE_OF_KEY) ? import_utils5.ONE_OF_KEY : import_utils5.ANY_OF_KEY;
|
|
1226
1258
|
schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
|
|
1227
1259
|
}
|
|
1228
|
-
fieldPathId = (0,
|
|
1260
|
+
fieldPathId = (0, import_utils5.toFieldPathId)(leafPath, globalFormOptions, fieldPathId);
|
|
1229
1261
|
isRequired2 = schema !== void 0 && Array.isArray(schema.required) && (0, import_includes.default)(schema.required, leafPath);
|
|
1230
1262
|
const result = computeArraySchemasIfPresent(schema, fieldPathId, leafPath);
|
|
1231
1263
|
if (result.rawSchema) {
|
|
1232
1264
|
schema = result.rawSchema;
|
|
1233
1265
|
fieldPathId = result.fieldPathId;
|
|
1234
1266
|
} else {
|
|
1235
|
-
schema = (0, import_get.default)(schema, [
|
|
1267
|
+
schema = (0, import_get.default)(schema, [import_utils5.PROPERTIES_KEY, leafPath]);
|
|
1236
1268
|
schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
|
|
1237
1269
|
}
|
|
1238
1270
|
isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
|
|
1239
|
-
if (schema && ((0, import_has.default)(schema,
|
|
1240
|
-
const xxx = (0, import_has.default)(schema,
|
|
1241
|
-
const discriminator = (0,
|
|
1271
|
+
if (schema && ((0, import_has.default)(schema, import_utils5.ONE_OF_KEY) || (0, import_has.default)(schema, import_utils5.ANY_OF_KEY))) {
|
|
1272
|
+
const xxx = (0, import_has.default)(schema, import_utils5.ONE_OF_KEY) ? import_utils5.ONE_OF_KEY : import_utils5.ANY_OF_KEY;
|
|
1273
|
+
const discriminator = (0, import_utils5.getDiscriminatorFieldFromSchema)(schema);
|
|
1242
1274
|
optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
|
|
1243
1275
|
}
|
|
1244
1276
|
}
|
|
@@ -1247,7 +1279,7 @@ function getSchemaDetailsForField(registry, dottedPath, initialSchema, formData,
|
|
|
1247
1279
|
function getCustomRenderComponent(render, registry) {
|
|
1248
1280
|
let customRenderer = render;
|
|
1249
1281
|
if ((0, import_isString.default)(customRenderer)) {
|
|
1250
|
-
customRenderer = (0,
|
|
1282
|
+
customRenderer = (0, import_utils5.lookupFromFormContext)(registry, customRenderer);
|
|
1251
1283
|
}
|
|
1252
1284
|
if ((0, import_isFunction.default)(customRenderer)) {
|
|
1253
1285
|
return customRenderer;
|
|
@@ -1271,14 +1303,14 @@ function computeUIComponentPropsFromGridSchema(registry, gridSchema) {
|
|
|
1271
1303
|
const match = LOOKUP_REGEX.exec(prop);
|
|
1272
1304
|
if (Array.isArray(match) && match.length > 1) {
|
|
1273
1305
|
const lookupName = match[1];
|
|
1274
|
-
uiProps[key] = (0,
|
|
1306
|
+
uiProps[key] = (0, import_utils5.lookupFromFormContext)(registry, lookupName, lookupName);
|
|
1275
1307
|
}
|
|
1276
1308
|
}
|
|
1277
1309
|
});
|
|
1278
1310
|
}
|
|
1279
1311
|
UIComponent = getCustomRenderComponent(render, registry);
|
|
1280
1312
|
if (!innerName && UIComponent) {
|
|
1281
|
-
rendered = /* @__PURE__ */ (0,
|
|
1313
|
+
rendered = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UIComponent, { ...innerProps, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.uiComponent });
|
|
1282
1314
|
}
|
|
1283
1315
|
}
|
|
1284
1316
|
return { name, UIComponent, uiProps, rendered };
|
|
@@ -1288,11 +1320,11 @@ function LayoutGridFieldChildren(props) {
|
|
|
1288
1320
|
const { registry, schema: rawSchema, formData } = layoutGridFieldProps;
|
|
1289
1321
|
const { schemaUtils } = registry;
|
|
1290
1322
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1291
|
-
return childrenLayoutGridSchemaId.map((layoutGridSchema) => /* @__PURE__ */ (0,
|
|
1323
|
+
return childrenLayoutGridSchemaId.map((layoutGridSchema) => /* @__PURE__ */ (0, import_react5.createElement)(
|
|
1292
1324
|
LayoutGridField,
|
|
1293
1325
|
{
|
|
1294
1326
|
...layoutGridFieldProps,
|
|
1295
|
-
key: `layoutGrid-${(0,
|
|
1327
|
+
key: `layoutGrid-${(0, import_utils5.hashObject)(layoutGridSchema)}`,
|
|
1296
1328
|
schema,
|
|
1297
1329
|
layoutGridSchema
|
|
1298
1330
|
}
|
|
@@ -1305,7 +1337,7 @@ function LayoutGridCondition(props) {
|
|
|
1305
1337
|
const { operator, field = "", value } = gridProps;
|
|
1306
1338
|
const fieldData = (0, import_get.default)(formData, field, null);
|
|
1307
1339
|
if (conditionMatches(operator, fieldData, value)) {
|
|
1308
|
-
return /* @__PURE__ */ (0,
|
|
1340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children });
|
|
1309
1341
|
}
|
|
1310
1342
|
return null;
|
|
1311
1343
|
}
|
|
@@ -1313,34 +1345,34 @@ function LayoutGridCol(props) {
|
|
|
1313
1345
|
const { layoutGridSchema, ...layoutGridFieldProps } = props;
|
|
1314
1346
|
const { registry, uiSchema } = layoutGridFieldProps;
|
|
1315
1347
|
const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:col" /* COLUMN */, registry);
|
|
1316
|
-
const uiOptions = (0,
|
|
1317
|
-
const GridTemplate2 = (0,
|
|
1318
|
-
return /* @__PURE__ */ (0,
|
|
1348
|
+
const uiOptions = (0, import_utils5.getUiOptions)(uiSchema);
|
|
1349
|
+
const GridTemplate2 = (0, import_utils5.getTemplate)("GridTemplate", registry, uiOptions);
|
|
1350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GridTemplate2, { column: true, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.col, ...gridProps, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children }) });
|
|
1319
1351
|
}
|
|
1320
1352
|
function LayoutGridColumns(props) {
|
|
1321
1353
|
const { layoutGridSchema, ...layoutGridFieldProps } = props;
|
|
1322
1354
|
const { registry, uiSchema } = layoutGridFieldProps;
|
|
1323
1355
|
const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:columns" /* COLUMNS */, registry);
|
|
1324
|
-
const uiOptions = (0,
|
|
1325
|
-
const GridTemplate2 = (0,
|
|
1326
|
-
return children.map((child) => /* @__PURE__ */ (0,
|
|
1356
|
+
const uiOptions = (0, import_utils5.getUiOptions)(uiSchema);
|
|
1357
|
+
const GridTemplate2 = (0, import_utils5.getTemplate)("GridTemplate", registry, uiOptions);
|
|
1358
|
+
return children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1327
1359
|
GridTemplate2,
|
|
1328
1360
|
{
|
|
1329
1361
|
column: true,
|
|
1330
1362
|
"data-testid": LAYOUT_GRID_FIELD_TEST_IDS.col,
|
|
1331
1363
|
...gridProps,
|
|
1332
|
-
children: /* @__PURE__ */ (0,
|
|
1364
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: [child] })
|
|
1333
1365
|
},
|
|
1334
|
-
`column-${(0,
|
|
1366
|
+
`column-${(0, import_utils5.hashObject)(child)}`
|
|
1335
1367
|
));
|
|
1336
1368
|
}
|
|
1337
1369
|
function LayoutGridRow(props) {
|
|
1338
1370
|
const { layoutGridSchema, ...layoutGridFieldProps } = props;
|
|
1339
1371
|
const { registry, uiSchema } = layoutGridFieldProps;
|
|
1340
1372
|
const { children, gridProps } = findChildrenAndProps(layoutGridSchema, "ui:row" /* ROW */, registry);
|
|
1341
|
-
const uiOptions = (0,
|
|
1342
|
-
const GridTemplate2 = (0,
|
|
1343
|
-
return /* @__PURE__ */ (0,
|
|
1373
|
+
const uiOptions = (0, import_utils5.getUiOptions)(uiSchema);
|
|
1374
|
+
const GridTemplate2 = (0, import_utils5.getTemplate)("GridTemplate", registry, uiOptions);
|
|
1375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GridTemplate2, { ...gridProps, "data-testid": LAYOUT_GRID_FIELD_TEST_IDS.row, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridFieldChildren, { ...layoutGridFieldProps, childrenLayoutGridSchemaId: children }) });
|
|
1344
1376
|
}
|
|
1345
1377
|
function LayoutGridFieldComponent(props) {
|
|
1346
1378
|
const {
|
|
@@ -1370,14 +1402,14 @@ function LayoutGridFieldComponent(props) {
|
|
|
1370
1402
|
optionsInfo,
|
|
1371
1403
|
fieldPathId: fieldIdSchema
|
|
1372
1404
|
} = getSchemaDetailsForField(registry, name, initialSchema, formData, fieldPathId);
|
|
1373
|
-
const memoFieldPathId = (0,
|
|
1405
|
+
const memoFieldPathId = (0, import_utils5.useDeepCompareMemo)(fieldIdSchema);
|
|
1374
1406
|
if (uiComponentProps.rendered) {
|
|
1375
1407
|
return uiComponentProps.rendered;
|
|
1376
1408
|
}
|
|
1377
1409
|
if (schema) {
|
|
1378
1410
|
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1379
1411
|
const { fieldUiSchema, uiReadonly } = computeFieldUiSchema(name, uiProps, uiSchema, isReadonly, readonly);
|
|
1380
|
-
return /* @__PURE__ */ (0,
|
|
1412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1381
1413
|
Field,
|
|
1382
1414
|
{
|
|
1383
1415
|
"data-testid": optionsInfo?.hasDiscriminator ? LAYOUT_GRID_FIELD_TEST_IDS.layoutMultiSchemaField : LAYOUT_GRID_FIELD_TEST_IDS.field,
|
|
@@ -1399,7 +1431,7 @@ function LayoutGridFieldComponent(props) {
|
|
|
1399
1431
|
);
|
|
1400
1432
|
}
|
|
1401
1433
|
if (UIComponent) {
|
|
1402
|
-
return /* @__PURE__ */ (0,
|
|
1434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1403
1435
|
UIComponent,
|
|
1404
1436
|
{
|
|
1405
1437
|
"data-testid": LAYOUT_GRID_FIELD_TEST_IDS.uiComponent,
|
|
@@ -1424,49 +1456,49 @@ function LayoutGridFieldComponent(props) {
|
|
|
1424
1456
|
function LayoutGridField(props) {
|
|
1425
1457
|
const { uiSchema } = props;
|
|
1426
1458
|
let { layoutGridSchema } = props;
|
|
1427
|
-
const uiOptions = (0,
|
|
1459
|
+
const uiOptions = (0, import_utils5.getUiOptions)(uiSchema);
|
|
1428
1460
|
if (!layoutGridSchema && LAYOUT_GRID_UI_OPTION in uiOptions && (0, import_isObject3.default)(uiOptions[LAYOUT_GRID_UI_OPTION])) {
|
|
1429
1461
|
layoutGridSchema = uiOptions[LAYOUT_GRID_UI_OPTION];
|
|
1430
1462
|
}
|
|
1431
1463
|
if ((0, import_isObject3.default)(layoutGridSchema)) {
|
|
1432
1464
|
if ("ui:row" /* ROW */ in layoutGridSchema) {
|
|
1433
|
-
return /* @__PURE__ */ (0,
|
|
1465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridRow, { ...props, layoutGridSchema });
|
|
1434
1466
|
}
|
|
1435
1467
|
if ("ui:col" /* COLUMN */ in layoutGridSchema) {
|
|
1436
|
-
return /* @__PURE__ */ (0,
|
|
1468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridCol, { ...props, layoutGridSchema });
|
|
1437
1469
|
}
|
|
1438
1470
|
if ("ui:columns" /* COLUMNS */ in layoutGridSchema) {
|
|
1439
|
-
return /* @__PURE__ */ (0,
|
|
1471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridColumns, { ...props, layoutGridSchema });
|
|
1440
1472
|
}
|
|
1441
1473
|
if ("ui:condition" /* CONDITION */ in layoutGridSchema) {
|
|
1442
|
-
return /* @__PURE__ */ (0,
|
|
1474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridCondition, { ...props, layoutGridSchema });
|
|
1443
1475
|
}
|
|
1444
1476
|
}
|
|
1445
|
-
return /* @__PURE__ */ (0,
|
|
1477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LayoutGridFieldComponent, { ...props, gridSchema: layoutGridSchema });
|
|
1446
1478
|
}
|
|
1447
1479
|
LayoutGridField.TEST_IDS = LAYOUT_GRID_FIELD_TEST_IDS;
|
|
1448
1480
|
|
|
1449
1481
|
// src/components/fields/LayoutHeaderField.tsx
|
|
1450
|
-
var
|
|
1451
|
-
var
|
|
1482
|
+
var import_utils6 = require("@rjsf/utils");
|
|
1483
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1452
1484
|
function LayoutHeaderField(props) {
|
|
1453
1485
|
const { fieldPathId, title, schema, uiSchema, required, registry, name } = props;
|
|
1454
|
-
const options = (0,
|
|
1486
|
+
const options = (0, import_utils6.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
1455
1487
|
const { title: uiTitle } = options;
|
|
1456
1488
|
const { title: schemaTitle } = schema;
|
|
1457
1489
|
const fieldTitle = uiTitle || title || schemaTitle || name;
|
|
1458
1490
|
if (!fieldTitle) {
|
|
1459
1491
|
return null;
|
|
1460
1492
|
}
|
|
1461
|
-
const TitleFieldTemplate = (0,
|
|
1493
|
+
const TitleFieldTemplate = (0, import_utils6.getTemplate)(
|
|
1462
1494
|
"TitleFieldTemplate",
|
|
1463
1495
|
registry,
|
|
1464
1496
|
options
|
|
1465
1497
|
);
|
|
1466
|
-
return /* @__PURE__ */ (0,
|
|
1498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1467
1499
|
TitleFieldTemplate,
|
|
1468
1500
|
{
|
|
1469
|
-
id: (0,
|
|
1501
|
+
id: (0, import_utils6.titleId)(fieldPathId),
|
|
1470
1502
|
title: fieldTitle,
|
|
1471
1503
|
required,
|
|
1472
1504
|
schema,
|
|
@@ -1477,33 +1509,33 @@ function LayoutHeaderField(props) {
|
|
|
1477
1509
|
}
|
|
1478
1510
|
|
|
1479
1511
|
// src/components/fields/LayoutMultiSchemaField.tsx
|
|
1480
|
-
var
|
|
1481
|
-
var
|
|
1512
|
+
var import_react6 = require("react");
|
|
1513
|
+
var import_utils7 = require("@rjsf/utils");
|
|
1482
1514
|
var import_get2 = __toESM(require("lodash/get"), 1);
|
|
1483
1515
|
var import_has2 = __toESM(require("lodash/has"), 1);
|
|
1484
1516
|
var import_isEmpty2 = __toESM(require("lodash/isEmpty"), 1);
|
|
1485
1517
|
var import_noop = __toESM(require("lodash/noop"), 1);
|
|
1486
1518
|
var import_omit = __toESM(require("lodash/omit"), 1);
|
|
1487
1519
|
var import_set3 = __toESM(require("lodash/set"), 1);
|
|
1488
|
-
var
|
|
1520
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1489
1521
|
function getSelectedOption(options, selectorField, value) {
|
|
1490
1522
|
const defaultValue = "!@#!@$@#$!@$#";
|
|
1491
1523
|
const schemaOptions = options.map(({ schema }) => schema);
|
|
1492
1524
|
return schemaOptions.find((option) => {
|
|
1493
|
-
const selector = (0, import_get2.default)(option, [
|
|
1494
|
-
const result = (0, import_get2.default)(selector,
|
|
1525
|
+
const selector = (0, import_get2.default)(option, [import_utils7.PROPERTIES_KEY, selectorField]);
|
|
1526
|
+
const result = (0, import_get2.default)(selector, import_utils7.DEFAULT_KEY, (0, import_get2.default)(selector, import_utils7.CONST_KEY, defaultValue));
|
|
1495
1527
|
return result === value;
|
|
1496
1528
|
});
|
|
1497
1529
|
}
|
|
1498
1530
|
function computeEnumOptions(schema, options, schemaUtils, uiSchema, formData) {
|
|
1499
1531
|
const realOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
1500
1532
|
let tempSchema = schema;
|
|
1501
|
-
if ((0, import_has2.default)(schema,
|
|
1502
|
-
tempSchema = { ...schema, [
|
|
1503
|
-
} else if ((0, import_has2.default)(schema,
|
|
1504
|
-
tempSchema = { ...schema, [
|
|
1533
|
+
if ((0, import_has2.default)(schema, import_utils7.ONE_OF_KEY)) {
|
|
1534
|
+
tempSchema = { ...schema, [import_utils7.ONE_OF_KEY]: realOptions };
|
|
1535
|
+
} else if ((0, import_has2.default)(schema, import_utils7.ANY_OF_KEY)) {
|
|
1536
|
+
tempSchema = { ...schema, [import_utils7.ANY_OF_KEY]: realOptions };
|
|
1505
1537
|
}
|
|
1506
|
-
const enumOptions = (0,
|
|
1538
|
+
const enumOptions = (0, import_utils7.optionsList)(tempSchema, uiSchema);
|
|
1507
1539
|
if (!enumOptions) {
|
|
1508
1540
|
throw new Error(`No enumOptions were computed from the schema ${JSON.stringify(tempSchema)}`);
|
|
1509
1541
|
}
|
|
@@ -1530,16 +1562,16 @@ function LayoutMultiSchemaField(props) {
|
|
|
1530
1562
|
hideError = false
|
|
1531
1563
|
} = props;
|
|
1532
1564
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1533
|
-
const [enumOptions, setEnumOptions] = (0,
|
|
1534
|
-
const id = (0, import_get2.default)(fieldPathId,
|
|
1535
|
-
const discriminator = (0,
|
|
1536
|
-
const FieldErrorTemplate2 = (0,
|
|
1537
|
-
const FieldTemplate2 = (0,
|
|
1538
|
-
const schemaHash = (0,
|
|
1539
|
-
const optionsHash = (0,
|
|
1540
|
-
const uiSchemaHash = uiSchema ? (0,
|
|
1541
|
-
const formDataHash = formData ? (0,
|
|
1542
|
-
(0,
|
|
1565
|
+
const [enumOptions, setEnumOptions] = (0, import_react6.useState)(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1566
|
+
const id = (0, import_get2.default)(fieldPathId, import_utils7.ID_KEY);
|
|
1567
|
+
const discriminator = (0, import_utils7.getDiscriminatorFieldFromSchema)(schema);
|
|
1568
|
+
const FieldErrorTemplate2 = (0, import_utils7.getTemplate)("FieldErrorTemplate", registry, options);
|
|
1569
|
+
const FieldTemplate2 = (0, import_utils7.getTemplate)("FieldTemplate", registry, options);
|
|
1570
|
+
const schemaHash = (0, import_utils7.hashObject)(schema);
|
|
1571
|
+
const optionsHash = (0, import_utils7.hashObject)(options);
|
|
1572
|
+
const uiSchemaHash = uiSchema ? (0, import_utils7.hashObject)(uiSchema) : "";
|
|
1573
|
+
const formDataHash = formData ? (0, import_utils7.hashObject)(formData) : "";
|
|
1574
|
+
(0, import_react6.useEffect)(() => {
|
|
1543
1575
|
setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1544
1576
|
}, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
|
|
1545
1577
|
const {
|
|
@@ -1549,18 +1581,18 @@ function LayoutMultiSchemaField(props) {
|
|
|
1549
1581
|
optionsSchemaSelector: selectorField = discriminator,
|
|
1550
1582
|
hideError: uiSchemaHideError,
|
|
1551
1583
|
...uiOptions
|
|
1552
|
-
} = (0,
|
|
1584
|
+
} = (0, import_utils7.getUiOptions)(uiSchema);
|
|
1553
1585
|
if (!selectorField) {
|
|
1554
1586
|
throw new Error("No selector field provided for the LayoutMultiSchemaField");
|
|
1555
1587
|
}
|
|
1556
1588
|
const selectedOption = (0, import_get2.default)(formData, selectorField);
|
|
1557
|
-
let optionSchema = (0, import_get2.default)(enumOptions[0]?.schema, [
|
|
1589
|
+
let optionSchema = (0, import_get2.default)(enumOptions[0]?.schema, [import_utils7.PROPERTIES_KEY, selectorField], {});
|
|
1558
1590
|
const option = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
1559
1591
|
optionSchema = optionSchema?.type ? optionSchema : { ...optionSchema, type: option?.type || baseType };
|
|
1560
|
-
const Widget = (0,
|
|
1592
|
+
const Widget = (0, import_utils7.getWidget)(optionSchema, widget, widgets2);
|
|
1561
1593
|
const hideFieldError = uiSchemaHideError === void 0 ? hideError : Boolean(uiSchemaHideError);
|
|
1562
|
-
const rawErrors = (0, import_get2.default)(errorSchema, [
|
|
1563
|
-
const fieldErrorSchema = (0, import_omit.default)(errorSchema, [
|
|
1594
|
+
const rawErrors = (0, import_get2.default)(errorSchema, [import_utils7.ERRORS_KEY], []);
|
|
1595
|
+
const fieldErrorSchema = (0, import_omit.default)(errorSchema, [import_utils7.ERRORS_KEY]);
|
|
1564
1596
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1565
1597
|
const onOptionChange = (opt) => {
|
|
1566
1598
|
if (disabled || readonly) {
|
|
@@ -1578,8 +1610,8 @@ function LayoutMultiSchemaField(props) {
|
|
|
1578
1610
|
onChange(newFormData, fieldPathId.path, void 0, id);
|
|
1579
1611
|
};
|
|
1580
1612
|
const widgetOptions = { enumOptions, ...uiOptions };
|
|
1581
|
-
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ (0,
|
|
1582
|
-
return /* @__PURE__ */ (0,
|
|
1613
|
+
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FieldErrorTemplate2, { fieldPathId, schema, errors: rawErrors, registry }) : void 0;
|
|
1614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1583
1615
|
FieldTemplate2,
|
|
1584
1616
|
{
|
|
1585
1617
|
fieldPathId,
|
|
@@ -1597,7 +1629,7 @@ function LayoutMultiSchemaField(props) {
|
|
|
1597
1629
|
onKeyRename: import_noop.default,
|
|
1598
1630
|
onKeyRenameBlur: import_noop.default,
|
|
1599
1631
|
onRemoveProperty: import_noop.default,
|
|
1600
|
-
children: /* @__PURE__ */ (0,
|
|
1632
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1601
1633
|
Widget,
|
|
1602
1634
|
{
|
|
1603
1635
|
id,
|
|
@@ -1629,230 +1661,192 @@ function LayoutMultiSchemaField(props) {
|
|
|
1629
1661
|
}
|
|
1630
1662
|
|
|
1631
1663
|
// src/components/fields/MultiSchemaField.tsx
|
|
1632
|
-
var
|
|
1633
|
-
var
|
|
1664
|
+
var import_react7 = require("react");
|
|
1665
|
+
var import_utils8 = require("@rjsf/utils");
|
|
1634
1666
|
var import_get3 = __toESM(require("lodash/get"), 1);
|
|
1635
1667
|
var import_isEmpty3 = __toESM(require("lodash/isEmpty"), 1);
|
|
1636
1668
|
var import_omit2 = __toESM(require("lodash/omit"), 1);
|
|
1637
|
-
var
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
const
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1669
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1670
|
+
function AnyOfField(props) {
|
|
1671
|
+
const {
|
|
1672
|
+
name,
|
|
1673
|
+
disabled = false,
|
|
1674
|
+
errorSchema = {},
|
|
1675
|
+
formData,
|
|
1676
|
+
fieldPathId,
|
|
1677
|
+
onBlur,
|
|
1678
|
+
onChange,
|
|
1679
|
+
onFocus,
|
|
1680
|
+
options,
|
|
1681
|
+
readonly,
|
|
1682
|
+
registry,
|
|
1683
|
+
required = false,
|
|
1684
|
+
schema,
|
|
1685
|
+
uiSchema
|
|
1686
|
+
} = props;
|
|
1687
|
+
const { schemaUtils } = registry;
|
|
1688
|
+
const formDataHash = (0, import_utils8.hashObject)(formData ?? null);
|
|
1689
|
+
const retrievedOptions = (0, import_react7.useMemo)(
|
|
1690
|
+
() => options.map((opt) => schemaUtils.retrieveSchema(opt, formData)),
|
|
1691
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps -- formDataHash is the value-stable proxy for formData
|
|
1692
|
+
[options, schemaUtils, formDataHash]
|
|
1693
|
+
);
|
|
1694
|
+
const [selectedOption, setSelectedOption] = (0, import_react7.useState)(() => {
|
|
1695
|
+
const discriminator = (0, import_utils8.getDiscriminatorFieldFromSchema)(schema);
|
|
1696
|
+
return schemaUtils.getClosestMatchingOption(formData, retrievedOptions, 0, discriminator);
|
|
1697
|
+
});
|
|
1698
|
+
const skipNextOptionRecalculation = (0, import_react7.useRef)(false);
|
|
1699
|
+
const prevFormDataRef = (0, import_react7.useRef)(formData);
|
|
1700
|
+
const prevFieldIdRef = (0, import_react7.useRef)(fieldPathId.$id);
|
|
1701
|
+
(0, import_react7.useEffect)(() => {
|
|
1702
|
+
const prevFormData = prevFormDataRef.current;
|
|
1703
|
+
const prevFieldId = prevFieldIdRef.current;
|
|
1704
|
+
prevFormDataRef.current = formData;
|
|
1705
|
+
prevFieldIdRef.current = fieldPathId.$id;
|
|
1706
|
+
if (!(0, import_utils8.deepEquals)(formData, prevFormData) && fieldPathId.$id === prevFieldId) {
|
|
1707
|
+
if (skipNextOptionRecalculation.current) {
|
|
1708
|
+
skipNextOptionRecalculation.current = false;
|
|
1709
|
+
return;
|
|
1710
|
+
}
|
|
1711
|
+
const discriminator = (0, import_utils8.getDiscriminatorFieldFromSchema)(schema);
|
|
1712
|
+
const matchingOption = schemaUtils.getClosestMatchingOption(
|
|
1713
|
+
formData,
|
|
1714
|
+
retrievedOptions,
|
|
1715
|
+
selectedOption,
|
|
1716
|
+
discriminator
|
|
1717
|
+
);
|
|
1718
|
+
if (matchingOption !== selectedOption) {
|
|
1719
|
+
setSelectedOption(matchingOption);
|
|
1720
|
+
}
|
|
1678
1721
|
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
if (prevState && matchingOption !== selectedOption) {
|
|
1686
|
-
newState = { selectedOption: matchingOption, retrievedOptions };
|
|
1687
|
-
}
|
|
1722
|
+
});
|
|
1723
|
+
const fieldId = `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
|
|
1724
|
+
const onOptionChange = (0, import_react7.useCallback)(
|
|
1725
|
+
(option2) => {
|
|
1726
|
+
if (disabled || readonly) {
|
|
1727
|
+
return;
|
|
1688
1728
|
}
|
|
1729
|
+
const intOption = option2 !== void 0 ? parseInt(option2, 10) : -1;
|
|
1730
|
+
if (intOption === selectedOption) {
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
|
|
1734
|
+
const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
|
|
1735
|
+
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
1736
|
+
if (newOption) {
|
|
1737
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1738
|
+
}
|
|
1739
|
+
setSelectedOption(intOption);
|
|
1740
|
+
skipNextOptionRecalculation.current = true;
|
|
1741
|
+
onChange(newFormData, fieldPathId.path, void 0, fieldId);
|
|
1742
|
+
},
|
|
1743
|
+
// setSelectedOption is stable (guaranteed by useState); skipNextOptionRecalculation is a ref
|
|
1744
|
+
[selectedOption, retrievedOptions, disabled, readonly, schemaUtils, formData, fieldPathId, onChange, fieldId]
|
|
1745
|
+
);
|
|
1746
|
+
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions } = registry;
|
|
1747
|
+
const { SchemaField: SchemaFieldComponent } = fields2;
|
|
1748
|
+
const MultiSchemaFieldTemplate2 = (0, import_utils8.getTemplate)(
|
|
1749
|
+
"MultiSchemaFieldTemplate",
|
|
1750
|
+
registry,
|
|
1751
|
+
globalUiOptions
|
|
1752
|
+
);
|
|
1753
|
+
const isOptionalRender = (0, import_utils8.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
1754
|
+
const hasFormData = (0, import_utils8.isFormDataAvailable)(formData);
|
|
1755
|
+
const {
|
|
1756
|
+
widget = "select",
|
|
1757
|
+
placeholder,
|
|
1758
|
+
autofocus,
|
|
1759
|
+
autocomplete,
|
|
1760
|
+
title = schema.title,
|
|
1761
|
+
...uiOptions
|
|
1762
|
+
} = (0, import_utils8.getUiOptions)(uiSchema, globalUiOptions);
|
|
1763
|
+
const Widget = (0, import_utils8.getWidget)({ type: "number" }, widget, widgets2);
|
|
1764
|
+
const rawErrors = (0, import_get3.default)(errorSchema, import_utils8.ERRORS_KEY, []);
|
|
1765
|
+
const fieldErrorSchema = (0, import_omit2.default)(errorSchema, [import_utils8.ERRORS_KEY]);
|
|
1766
|
+
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1767
|
+
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1768
|
+
let optionSchema;
|
|
1769
|
+
if (option) {
|
|
1770
|
+
const { required: schemaRequired, type: schemaType } = schema;
|
|
1771
|
+
const parentProps = {};
|
|
1772
|
+
if (schemaRequired) {
|
|
1773
|
+
parentProps.required = schemaRequired;
|
|
1689
1774
|
}
|
|
1690
|
-
if (
|
|
1691
|
-
|
|
1775
|
+
if (schemaType !== void 0 && !("type" in option)) {
|
|
1776
|
+
parentProps.type = schemaType;
|
|
1692
1777
|
}
|
|
1778
|
+
optionSchema = Object.keys(parentProps).length > 0 ? (0, import_utils8.mergeSchemas)(parentProps, option) : option;
|
|
1693
1779
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
getMatchingOption(selectedOption, formData, options) {
|
|
1701
|
-
const {
|
|
1702
|
-
schema,
|
|
1703
|
-
registry: { schemaUtils }
|
|
1704
|
-
} = this.props;
|
|
1705
|
-
const discriminator = (0, import_utils7.getDiscriminatorFieldFromSchema)(schema);
|
|
1706
|
-
const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
|
|
1707
|
-
return option;
|
|
1708
|
-
}
|
|
1709
|
-
/** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
|
|
1710
|
-
* to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
|
|
1711
|
-
* the `onChange` handler.
|
|
1712
|
-
*
|
|
1713
|
-
* @param option - The new option value being selected
|
|
1714
|
-
*/
|
|
1715
|
-
onOptionChange = (option) => {
|
|
1716
|
-
const { selectedOption, retrievedOptions } = this.state;
|
|
1717
|
-
const { disabled = false, formData, onChange, readonly = false, registry, fieldPathId } = this.props;
|
|
1718
|
-
if (disabled || readonly) {
|
|
1719
|
-
return;
|
|
1720
|
-
}
|
|
1721
|
-
const { schemaUtils } = registry;
|
|
1722
|
-
const intOption = option !== void 0 ? parseInt(option, 10) : -1;
|
|
1723
|
-
if (intOption === selectedOption) {
|
|
1724
|
-
return;
|
|
1780
|
+
let optionsUiSchema = [];
|
|
1781
|
+
if (import_utils8.ONE_OF_KEY in schema && uiSchema && import_utils8.ONE_OF_KEY in uiSchema) {
|
|
1782
|
+
if (Array.isArray(uiSchema[import_utils8.ONE_OF_KEY])) {
|
|
1783
|
+
optionsUiSchema = uiSchema[import_utils8.ONE_OF_KEY];
|
|
1784
|
+
} else {
|
|
1785
|
+
console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
|
|
1725
1786
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1787
|
+
} else if (import_utils8.ANY_OF_KEY in schema && uiSchema && import_utils8.ANY_OF_KEY in uiSchema) {
|
|
1788
|
+
if (Array.isArray(uiSchema[import_utils8.ANY_OF_KEY])) {
|
|
1789
|
+
optionsUiSchema = uiSchema[import_utils8.ANY_OF_KEY];
|
|
1790
|
+
} else {
|
|
1791
|
+
console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
|
|
1731
1792
|
}
|
|
1732
|
-
this.setState({ selectedOption: intOption }, () => {
|
|
1733
|
-
this.skipNextOptionRecalculation = true;
|
|
1734
|
-
onChange(newFormData, fieldPathId.path, void 0, this.getFieldId());
|
|
1735
|
-
});
|
|
1736
|
-
};
|
|
1737
|
-
getFieldId() {
|
|
1738
|
-
const { fieldPathId, schema } = this.props;
|
|
1739
|
-
return `${fieldPathId.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
|
|
1740
1793
|
}
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1794
|
+
let optionUiSchema = uiSchema;
|
|
1795
|
+
if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
|
|
1796
|
+
optionUiSchema = optionsUiSchema[selectedOption];
|
|
1797
|
+
}
|
|
1798
|
+
const translateEnum = title ? import_utils8.TranslatableString.TitleOptionPrefix : import_utils8.TranslatableString.OptionPrefix;
|
|
1799
|
+
const translateParams = title ? [title] : [];
|
|
1800
|
+
const enumOptions = retrievedOptions.map((opt, index) => {
|
|
1801
|
+
const { title: uiTitle = opt.title } = (0, import_utils8.getUiOptions)(optionsUiSchema[index]);
|
|
1802
|
+
return {
|
|
1803
|
+
label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1804
|
+
value: index
|
|
1805
|
+
};
|
|
1806
|
+
});
|
|
1807
|
+
const selector = !isOptionalRender || hasFormData ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1808
|
+
Widget,
|
|
1809
|
+
{
|
|
1810
|
+
id: fieldId,
|
|
1811
|
+
name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
|
|
1812
|
+
schema: { type: "number", default: 0 },
|
|
1813
|
+
onChange: onOptionChange,
|
|
1749
1814
|
onBlur,
|
|
1750
1815
|
onFocus,
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
|
|
1758
|
-
const { SchemaField: SchemaFieldComponent } = fields2;
|
|
1759
|
-
const MultiSchemaFieldTemplate2 = (0, import_utils7.getTemplate)(
|
|
1760
|
-
"MultiSchemaFieldTemplate",
|
|
1816
|
+
disabled: disabled || (0, import_isEmpty3.default)(enumOptions),
|
|
1817
|
+
multiple: false,
|
|
1818
|
+
rawErrors,
|
|
1819
|
+
errorSchema: fieldErrorSchema,
|
|
1820
|
+
value: selectedOption >= 0 ? selectedOption : void 0,
|
|
1821
|
+
options: { enumOptions, ...uiOptions },
|
|
1761
1822
|
registry,
|
|
1762
|
-
globalUiOptions
|
|
1763
|
-
);
|
|
1764
|
-
const isOptionalRender = (0, import_utils7.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
1765
|
-
const hasFormData = (0, import_utils7.isFormDataAvailable)(formData);
|
|
1766
|
-
const { selectedOption, retrievedOptions } = this.state;
|
|
1767
|
-
const {
|
|
1768
|
-
widget = "select",
|
|
1769
1823
|
placeholder,
|
|
1770
|
-
autofocus,
|
|
1771
1824
|
autocomplete,
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
const rawErrors = (0, import_get3.default)(errorSchema, import_utils7.ERRORS_KEY, []);
|
|
1777
|
-
const fieldErrorSchema = (0, import_omit2.default)(errorSchema, [import_utils7.ERRORS_KEY]);
|
|
1778
|
-
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1779
|
-
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1780
|
-
let optionSchema;
|
|
1781
|
-
if (option) {
|
|
1782
|
-
const { required: schemaRequired } = schema;
|
|
1783
|
-
optionSchema = schemaRequired ? (0, import_utils7.mergeSchemas)({ required: schemaRequired }, option) : option;
|
|
1784
|
-
}
|
|
1785
|
-
let optionsUiSchema = [];
|
|
1786
|
-
if (import_utils7.ONE_OF_KEY in schema && uiSchema && import_utils7.ONE_OF_KEY in uiSchema) {
|
|
1787
|
-
if (Array.isArray(uiSchema[import_utils7.ONE_OF_KEY])) {
|
|
1788
|
-
optionsUiSchema = uiSchema[import_utils7.ONE_OF_KEY];
|
|
1789
|
-
} else {
|
|
1790
|
-
console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
|
|
1791
|
-
}
|
|
1792
|
-
} else if (import_utils7.ANY_OF_KEY in schema && uiSchema && import_utils7.ANY_OF_KEY in uiSchema) {
|
|
1793
|
-
if (Array.isArray(uiSchema[import_utils7.ANY_OF_KEY])) {
|
|
1794
|
-
optionsUiSchema = uiSchema[import_utils7.ANY_OF_KEY];
|
|
1795
|
-
} else {
|
|
1796
|
-
console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
|
|
1797
|
-
}
|
|
1825
|
+
autofocus,
|
|
1826
|
+
label: title ?? name,
|
|
1827
|
+
hideLabel: !displayLabel,
|
|
1828
|
+
readonly
|
|
1798
1829
|
}
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1830
|
+
) : void 0;
|
|
1831
|
+
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SchemaFieldComponent, { ...props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1833
|
+
MultiSchemaFieldTemplate2,
|
|
1834
|
+
{
|
|
1835
|
+
schema,
|
|
1836
|
+
registry,
|
|
1837
|
+
uiSchema,
|
|
1838
|
+
selector,
|
|
1839
|
+
optionSchemaField: optionsSchemaField
|
|
1802
1840
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
const enumOptions = retrievedOptions.map((opt, index) => {
|
|
1806
|
-
const { title: uiTitle = opt.title } = (0, import_utils7.getUiOptions)(optionsUiSchema[index]);
|
|
1807
|
-
return {
|
|
1808
|
-
label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1809
|
-
value: index
|
|
1810
|
-
};
|
|
1811
|
-
});
|
|
1812
|
-
const selector = !isOptionalRender || hasFormData ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1813
|
-
Widget,
|
|
1814
|
-
{
|
|
1815
|
-
id: this.getFieldId(),
|
|
1816
|
-
name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
|
|
1817
|
-
schema: { type: "number", default: 0 },
|
|
1818
|
-
onChange: this.onOptionChange,
|
|
1819
|
-
onBlur,
|
|
1820
|
-
onFocus,
|
|
1821
|
-
disabled: disabled || (0, import_isEmpty3.default)(enumOptions),
|
|
1822
|
-
multiple: false,
|
|
1823
|
-
rawErrors,
|
|
1824
|
-
errorSchema: fieldErrorSchema,
|
|
1825
|
-
value: selectedOption >= 0 ? selectedOption : void 0,
|
|
1826
|
-
options: { enumOptions, ...uiOptions },
|
|
1827
|
-
registry,
|
|
1828
|
-
placeholder,
|
|
1829
|
-
autocomplete,
|
|
1830
|
-
autofocus,
|
|
1831
|
-
label: title ?? name,
|
|
1832
|
-
hideLabel: !displayLabel,
|
|
1833
|
-
readonly
|
|
1834
|
-
}
|
|
1835
|
-
) : void 0;
|
|
1836
|
-
const optionsSchemaField = optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SchemaFieldComponent, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema }) || null;
|
|
1837
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1838
|
-
MultiSchemaFieldTemplate2,
|
|
1839
|
-
{
|
|
1840
|
-
schema,
|
|
1841
|
-
registry,
|
|
1842
|
-
uiSchema,
|
|
1843
|
-
selector,
|
|
1844
|
-
optionSchemaField: optionsSchemaField
|
|
1845
|
-
}
|
|
1846
|
-
);
|
|
1847
|
-
}
|
|
1848
|
-
};
|
|
1841
|
+
);
|
|
1842
|
+
}
|
|
1849
1843
|
var MultiSchemaField_default = AnyOfField;
|
|
1850
1844
|
|
|
1851
1845
|
// src/components/fields/NullField.tsx
|
|
1852
|
-
var
|
|
1846
|
+
var import_react8 = require("react");
|
|
1853
1847
|
function NullField(props) {
|
|
1854
1848
|
const { formData, onChange, fieldPathId } = props;
|
|
1855
|
-
(0,
|
|
1849
|
+
(0, import_react8.useEffect)(() => {
|
|
1856
1850
|
if (formData === void 0) {
|
|
1857
1851
|
onChange(null, fieldPathId.path);
|
|
1858
1852
|
}
|
|
@@ -1862,21 +1856,21 @@ function NullField(props) {
|
|
|
1862
1856
|
var NullField_default = NullField;
|
|
1863
1857
|
|
|
1864
1858
|
// src/components/fields/NumberField.tsx
|
|
1865
|
-
var
|
|
1866
|
-
var
|
|
1867
|
-
var
|
|
1859
|
+
var import_react9 = require("react");
|
|
1860
|
+
var import_utils9 = require("@rjsf/utils");
|
|
1861
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1868
1862
|
var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
|
|
1869
1863
|
var trailingCharMatcher = /[0.]0*$/;
|
|
1870
1864
|
function NumberField(props) {
|
|
1871
1865
|
const { registry, onChange, formData, value: initialValue } = props;
|
|
1872
|
-
const [lastValue, setLastValue] = (0,
|
|
1866
|
+
const [lastValue, setLastValue] = (0, import_react9.useState)(initialValue);
|
|
1873
1867
|
const { StringField: StringField2 } = registry.fields;
|
|
1874
1868
|
let value = formData;
|
|
1875
|
-
const handleChange = (0,
|
|
1869
|
+
const handleChange = (0, import_react9.useCallback)(
|
|
1876
1870
|
(newValue, path, errorSchema, id) => {
|
|
1877
1871
|
setLastValue(newValue);
|
|
1878
1872
|
const normalizedValue = `${newValue}`.startsWith(".") ? `0${newValue}` : newValue;
|
|
1879
|
-
const processed = typeof normalizedValue === "string" &&
|
|
1873
|
+
const processed = typeof normalizedValue === "string" && trailingCharMatcherWithPrefix.exec(normalizedValue) ? (0, import_utils9.asNumber)(normalizedValue.replace(trailingCharMatcher, "")) : (0, import_utils9.asNumber)(normalizedValue);
|
|
1880
1874
|
onChange(processed, path, errorSchema, id);
|
|
1881
1875
|
},
|
|
1882
1876
|
[onChange]
|
|
@@ -1887,25 +1881,25 @@ function NumberField(props) {
|
|
|
1887
1881
|
value = lastValue;
|
|
1888
1882
|
}
|
|
1889
1883
|
}
|
|
1890
|
-
return /* @__PURE__ */ (0,
|
|
1884
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StringField2, { ...props, formData: value, onChange: handleChange });
|
|
1891
1885
|
}
|
|
1892
1886
|
var NumberField_default = NumberField;
|
|
1893
1887
|
|
|
1894
1888
|
// src/components/fields/ObjectField.tsx
|
|
1895
|
-
var
|
|
1896
|
-
var
|
|
1889
|
+
var import_react10 = require("react");
|
|
1890
|
+
var import_utils10 = require("@rjsf/utils");
|
|
1897
1891
|
var import_get4 = __toESM(require("lodash/get"), 1);
|
|
1898
1892
|
var import_has3 = __toESM(require("lodash/has"), 1);
|
|
1899
1893
|
var import_isObject4 = __toESM(require("lodash/isObject"), 1);
|
|
1900
1894
|
var import_set4 = __toESM(require("lodash/set"), 1);
|
|
1901
|
-
var
|
|
1895
|
+
var import_react11 = require("markdown-to-jsx/react");
|
|
1902
1896
|
|
|
1903
1897
|
// src/components/constants.ts
|
|
1904
1898
|
var ADDITIONAL_PROPERTY_KEY_REMOVE = /* @__PURE__ */ Symbol("remove-this-key");
|
|
1905
1899
|
var IS_RESET = /* @__PURE__ */ Symbol("reset");
|
|
1906
1900
|
|
|
1907
1901
|
// src/components/fields/ObjectField.tsx
|
|
1908
|
-
var
|
|
1902
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1909
1903
|
function isRequired(schema, name) {
|
|
1910
1904
|
return Array.isArray(schema.required) && schema.required.includes(name);
|
|
1911
1905
|
}
|
|
@@ -1923,7 +1917,7 @@ function getDefaultValue(translateString, type) {
|
|
|
1923
1917
|
return {};
|
|
1924
1918
|
case "string":
|
|
1925
1919
|
default:
|
|
1926
|
-
return translateString(
|
|
1920
|
+
return translateString(import_utils10.TranslatableString.NewStringDefault);
|
|
1927
1921
|
}
|
|
1928
1922
|
}
|
|
1929
1923
|
function ObjectFieldPropertyFn(props) {
|
|
@@ -1946,13 +1940,13 @@ function ObjectFieldPropertyFn(props) {
|
|
|
1946
1940
|
handleRemoveProperty,
|
|
1947
1941
|
addedByAdditionalProperties
|
|
1948
1942
|
} = props;
|
|
1949
|
-
const [wasPropertyKeyModified, setWasPropertyKeyModified] = (0,
|
|
1943
|
+
const [wasPropertyKeyModified, setWasPropertyKeyModified] = (0, import_react10.useState)(false);
|
|
1950
1944
|
const { globalFormOptions, fields: fields2 } = registry;
|
|
1951
1945
|
const { SchemaField: SchemaField2 } = fields2;
|
|
1952
|
-
const innerFieldIdPathId = (0,
|
|
1953
|
-
(0,
|
|
1946
|
+
const innerFieldIdPathId = (0, import_utils10.useDeepCompareMemo)(
|
|
1947
|
+
(0, import_utils10.toFieldPathId)(propertyName, globalFormOptions, fieldPathId.path)
|
|
1954
1948
|
);
|
|
1955
|
-
const onPropertyChange = (0,
|
|
1949
|
+
const onPropertyChange = (0, import_react10.useCallback)(
|
|
1956
1950
|
(value, path, newErrorSchema, id) => {
|
|
1957
1951
|
let normalizedValue = value;
|
|
1958
1952
|
if (value === void 0 && addedByAdditionalProperties) {
|
|
@@ -1962,7 +1956,7 @@ function ObjectFieldPropertyFn(props) {
|
|
|
1962
1956
|
},
|
|
1963
1957
|
[onChange, addedByAdditionalProperties]
|
|
1964
1958
|
);
|
|
1965
|
-
const onKeyRename = (0,
|
|
1959
|
+
const onKeyRename = (0, import_react10.useCallback)(
|
|
1966
1960
|
(value) => {
|
|
1967
1961
|
if (propertyName !== value) {
|
|
1968
1962
|
setWasPropertyKeyModified(true);
|
|
@@ -1971,7 +1965,7 @@ function ObjectFieldPropertyFn(props) {
|
|
|
1971
1965
|
},
|
|
1972
1966
|
[propertyName, handleKeyRename]
|
|
1973
1967
|
);
|
|
1974
|
-
const onKeyRenameBlur = (0,
|
|
1968
|
+
const onKeyRenameBlur = (0, import_react10.useCallback)(
|
|
1975
1969
|
(event) => {
|
|
1976
1970
|
const {
|
|
1977
1971
|
target: { value }
|
|
@@ -1980,10 +1974,10 @@ function ObjectFieldPropertyFn(props) {
|
|
|
1980
1974
|
},
|
|
1981
1975
|
[onKeyRename]
|
|
1982
1976
|
);
|
|
1983
|
-
const onRemoveProperty = (0,
|
|
1977
|
+
const onRemoveProperty = (0, import_react10.useCallback)(() => {
|
|
1984
1978
|
handleRemoveProperty(propertyName);
|
|
1985
1979
|
}, [propertyName, handleRemoveProperty]);
|
|
1986
|
-
return /* @__PURE__ */ (0,
|
|
1980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1987
1981
|
SchemaField2,
|
|
1988
1982
|
{
|
|
1989
1983
|
name: propertyName,
|
|
@@ -2007,7 +2001,7 @@ function ObjectFieldPropertyFn(props) {
|
|
|
2007
2001
|
}
|
|
2008
2002
|
);
|
|
2009
2003
|
}
|
|
2010
|
-
var ObjectFieldProperty = (0,
|
|
2004
|
+
var ObjectFieldProperty = (0, import_react10.memo)(ObjectFieldPropertyFn);
|
|
2011
2005
|
function ObjectField(props) {
|
|
2012
2006
|
const {
|
|
2013
2007
|
schema: rawSchema,
|
|
@@ -2028,24 +2022,24 @@ function ObjectField(props) {
|
|
|
2028
2022
|
} = props;
|
|
2029
2023
|
const { fields: fields2, schemaUtils, translateString, globalUiOptions } = registry;
|
|
2030
2024
|
const { OptionalDataControlsField: OptionalDataControlsField2 } = fields2;
|
|
2031
|
-
const formDataRef = (0,
|
|
2025
|
+
const formDataRef = (0, import_react10.useRef)(formData);
|
|
2032
2026
|
formDataRef.current = formData;
|
|
2033
|
-
const schema = (0,
|
|
2027
|
+
const schema = (0, import_react10.useMemo)(
|
|
2034
2028
|
() => schemaUtils.retrieveSchema(rawSchema, formData, true),
|
|
2035
2029
|
[schemaUtils, rawSchema, formData]
|
|
2036
2030
|
);
|
|
2037
|
-
const uiOptions = (0,
|
|
2031
|
+
const uiOptions = (0, import_react10.useMemo)(() => (0, import_utils10.getUiOptions)(uiSchema, globalUiOptions), [uiSchema, globalUiOptions]);
|
|
2038
2032
|
const { properties: schemaProperties = {} } = schema;
|
|
2039
2033
|
const childFieldPathId = props.childFieldPathId ?? fieldPathId;
|
|
2040
|
-
const lastRenamedProperty = (0,
|
|
2034
|
+
const lastRenamedProperty = (0, import_react10.useRef)({ previousKey: "", currentKey: void 0 });
|
|
2041
2035
|
const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
|
|
2042
2036
|
const description = uiOptions.description ?? schema.description;
|
|
2043
|
-
const renderOptionalField = (0,
|
|
2044
|
-
const hasFormData = (0,
|
|
2037
|
+
const renderOptionalField = (0, import_utils10.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
2038
|
+
const hasFormData = (0, import_utils10.isFormDataAvailable)(formData);
|
|
2045
2039
|
let orderedProperties = [];
|
|
2046
|
-
const getAvailableKey = (0,
|
|
2040
|
+
const getAvailableKey = (0, import_react10.useCallback)(
|
|
2047
2041
|
(preferredKey, existingFormData) => {
|
|
2048
|
-
const { duplicateKeySuffixSeparator = "-" } = (0,
|
|
2042
|
+
const { duplicateKeySuffixSeparator = "-" } = (0, import_utils10.getUiOptions)(uiSchema, globalUiOptions);
|
|
2049
2043
|
let index = 0;
|
|
2050
2044
|
let newKey = preferredKey;
|
|
2051
2045
|
while ((0, import_has3.default)(existingFormData, newKey)) {
|
|
@@ -2056,7 +2050,7 @@ function ObjectField(props) {
|
|
|
2056
2050
|
},
|
|
2057
2051
|
[uiSchema, globalUiOptions]
|
|
2058
2052
|
);
|
|
2059
|
-
const onAddProperty = (0,
|
|
2053
|
+
const onAddProperty = (0, import_react10.useCallback)(() => {
|
|
2060
2054
|
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
2061
2055
|
return;
|
|
2062
2056
|
}
|
|
@@ -2073,13 +2067,13 @@ function ObjectField(props) {
|
|
|
2073
2067
|
constValue = schema.additionalProperties.const;
|
|
2074
2068
|
defaultValue = schema.additionalProperties.default;
|
|
2075
2069
|
let apSchema = schema.additionalProperties;
|
|
2076
|
-
if (
|
|
2077
|
-
apSchema = schemaUtils.retrieveSchema({ [
|
|
2070
|
+
if (import_utils10.REF_KEY in apSchema) {
|
|
2071
|
+
apSchema = schemaUtils.retrieveSchema({ [import_utils10.REF_KEY]: apSchema[import_utils10.REF_KEY] }, formData);
|
|
2078
2072
|
type = apSchema.type;
|
|
2079
2073
|
constValue = apSchema.const;
|
|
2080
|
-
defaultValue = apSchema
|
|
2074
|
+
defaultValue = schemaUtils.getDefaultFormState(apSchema, defaultValue);
|
|
2081
2075
|
}
|
|
2082
|
-
if (!type && (
|
|
2076
|
+
if (!type && (import_utils10.ANY_OF_KEY in apSchema || import_utils10.ONE_OF_KEY in apSchema)) {
|
|
2083
2077
|
type = "object";
|
|
2084
2078
|
}
|
|
2085
2079
|
}
|
|
@@ -2092,7 +2086,7 @@ function ObjectField(props) {
|
|
|
2092
2086
|
}
|
|
2093
2087
|
onChange(newFormData, childFieldPathId.path);
|
|
2094
2088
|
}, [formData, onChange, translateString, schemaUtils, childFieldPathId, getAvailableKey, schema]);
|
|
2095
|
-
const handleKeyRename = (0,
|
|
2089
|
+
const handleKeyRename = (0, import_react10.useCallback)(
|
|
2096
2090
|
(oldKey, newKey) => {
|
|
2097
2091
|
if (oldKey !== newKey) {
|
|
2098
2092
|
const currentFormData = formDataRef.current;
|
|
@@ -2116,13 +2110,13 @@ function ObjectField(props) {
|
|
|
2116
2110
|
},
|
|
2117
2111
|
[onChange, childFieldPathId, getAvailableKey]
|
|
2118
2112
|
);
|
|
2119
|
-
const handleRemoveProperty = (0,
|
|
2113
|
+
const handleRemoveProperty = (0, import_react10.useCallback)(
|
|
2120
2114
|
(key) => {
|
|
2121
2115
|
onChange(ADDITIONAL_PROPERTY_KEY_REMOVE, [...childFieldPathId.path, key]);
|
|
2122
2116
|
},
|
|
2123
2117
|
[onChange, childFieldPathId]
|
|
2124
2118
|
);
|
|
2125
|
-
const getStableKey = (0,
|
|
2119
|
+
const getStableKey = (0, import_react10.useCallback)((property) => {
|
|
2126
2120
|
if (lastRenamedProperty.current.currentKey === property) {
|
|
2127
2121
|
return lastRenamedProperty.current.previousKey;
|
|
2128
2122
|
}
|
|
@@ -2131,30 +2125,32 @@ function ObjectField(props) {
|
|
|
2131
2125
|
if (!renderOptionalField || hasFormData) {
|
|
2132
2126
|
try {
|
|
2133
2127
|
const properties = Object.keys(schemaProperties);
|
|
2134
|
-
orderedProperties = (0,
|
|
2128
|
+
orderedProperties = (0, import_utils10.orderProperties)(properties, uiOptions.order);
|
|
2135
2129
|
} catch (err) {
|
|
2136
|
-
return /* @__PURE__ */ (0,
|
|
2137
|
-
/* @__PURE__ */ (0,
|
|
2138
|
-
/* @__PURE__ */ (0,
|
|
2130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
|
|
2131
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react11.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(import_utils10.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
2132
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("pre", { children: JSON.stringify(schema) })
|
|
2139
2133
|
] });
|
|
2140
2134
|
}
|
|
2141
2135
|
}
|
|
2142
|
-
const Template = (0,
|
|
2143
|
-
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ (0,
|
|
2136
|
+
const Template = (0, import_utils10.getTemplate)("ObjectFieldTemplate", registry, uiOptions);
|
|
2137
|
+
const optionalDataControl = renderOptionalField ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(OptionalDataControlsField2, { ...props, fieldPathId: childFieldPathId, schema }) : void 0;
|
|
2144
2138
|
const templateProps = {
|
|
2145
2139
|
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
2146
2140
|
title: uiOptions.label === false ? "" : templateTitle,
|
|
2147
2141
|
description: uiOptions.label === false ? void 0 : description,
|
|
2148
2142
|
properties: orderedProperties.map((propertyName) => {
|
|
2149
|
-
const addedByAdditionalProperties = (
|
|
2143
|
+
const addedByAdditionalProperties = Boolean(
|
|
2144
|
+
schema.properties?.[propertyName]?.[import_utils10.ADDITIONAL_PROPERTY_FLAG]
|
|
2145
|
+
);
|
|
2150
2146
|
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[propertyName];
|
|
2151
|
-
const hidden = (0,
|
|
2152
|
-
const content = /* @__PURE__ */ (0,
|
|
2147
|
+
const hidden = (0, import_utils10.getUiOptions)(fieldUiSchema).widget === "hidden";
|
|
2148
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2153
2149
|
ObjectFieldProperty,
|
|
2154
2150
|
{
|
|
2155
2151
|
propertyName,
|
|
2156
2152
|
required: isRequired(schema, propertyName),
|
|
2157
|
-
schema: (0, import_get4.default)(schema, [
|
|
2153
|
+
schema: (0, import_get4.default)(schema, [import_utils10.PROPERTIES_KEY, propertyName], {}),
|
|
2158
2154
|
uiSchema: fieldUiSchema,
|
|
2159
2155
|
errorSchema: (0, import_get4.default)(errorSchema, [propertyName]),
|
|
2160
2156
|
fieldPathId: childFieldPathId,
|
|
@@ -2193,12 +2189,12 @@ function ObjectField(props) {
|
|
|
2193
2189
|
optionalDataControl,
|
|
2194
2190
|
className: renderOptionalField ? "rjsf-optional-object-field" : void 0
|
|
2195
2191
|
};
|
|
2196
|
-
return /* @__PURE__ */ (0,
|
|
2192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Template, { ...templateProps, onAddProperty });
|
|
2197
2193
|
}
|
|
2198
2194
|
|
|
2199
2195
|
// src/components/fields/OptionalDataControlsField.tsx
|
|
2200
|
-
var
|
|
2201
|
-
var
|
|
2196
|
+
var import_utils11 = require("@rjsf/utils");
|
|
2197
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2202
2198
|
function OptionalDataControlsField(props) {
|
|
2203
2199
|
const {
|
|
2204
2200
|
schema,
|
|
@@ -2212,38 +2208,38 @@ function OptionalDataControlsField(props) {
|
|
|
2212
2208
|
registry
|
|
2213
2209
|
} = props;
|
|
2214
2210
|
const { globalUiOptions = {}, schemaUtils, translateString } = registry;
|
|
2215
|
-
const uiOptions = (0,
|
|
2216
|
-
const OptionalDataControlsTemplate2 = (0,
|
|
2211
|
+
const uiOptions = (0, import_utils11.getUiOptions)(uiSchema, globalUiOptions);
|
|
2212
|
+
const OptionalDataControlsTemplate2 = (0, import_utils11.getTemplate)(
|
|
2217
2213
|
"OptionalDataControlsTemplate",
|
|
2218
2214
|
registry,
|
|
2219
2215
|
uiOptions
|
|
2220
2216
|
);
|
|
2221
|
-
const hasFormData = (0,
|
|
2217
|
+
const hasFormData = (0, import_utils11.isFormDataAvailable)(formData);
|
|
2222
2218
|
let id;
|
|
2223
2219
|
let label;
|
|
2224
2220
|
let onAddClick;
|
|
2225
2221
|
let onRemoveClick;
|
|
2226
2222
|
if (disabled || readonly) {
|
|
2227
|
-
id = (0,
|
|
2228
|
-
label = hasFormData ? void 0 : translateString(
|
|
2223
|
+
id = (0, import_utils11.optionalControlsId)(fieldPathId, "Msg");
|
|
2224
|
+
label = hasFormData ? void 0 : translateString(import_utils11.TranslatableString.OptionalObjectEmptyMsg);
|
|
2229
2225
|
} else {
|
|
2230
|
-
const labelEnum = hasFormData ?
|
|
2226
|
+
const labelEnum = hasFormData ? import_utils11.TranslatableString.OptionalObjectRemove : import_utils11.TranslatableString.OptionalObjectAdd;
|
|
2231
2227
|
label = translateString(labelEnum);
|
|
2232
2228
|
if (hasFormData) {
|
|
2233
|
-
id = (0,
|
|
2229
|
+
id = (0, import_utils11.optionalControlsId)(fieldPathId, "Remove");
|
|
2234
2230
|
onRemoveClick = () => onChange(void 0, fieldPathId.path, errorSchema);
|
|
2235
2231
|
} else {
|
|
2236
|
-
id = (0,
|
|
2232
|
+
id = (0, import_utils11.optionalControlsId)(fieldPathId, "Add");
|
|
2237
2233
|
onAddClick = () => {
|
|
2238
2234
|
let newFormData = schemaUtils.getDefaultFormState(schema, formData, "excludeObjectChildren");
|
|
2239
2235
|
if (newFormData === void 0) {
|
|
2240
|
-
newFormData = (0,
|
|
2236
|
+
newFormData = (0, import_utils11.getSchemaType)(schema) === "array" ? [] : {};
|
|
2241
2237
|
}
|
|
2242
2238
|
onChange(newFormData, fieldPathId.path, errorSchema);
|
|
2243
2239
|
};
|
|
2244
2240
|
}
|
|
2245
2241
|
}
|
|
2246
|
-
return label && /* @__PURE__ */ (0,
|
|
2242
|
+
return label && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2247
2243
|
OptionalDataControlsTemplate2,
|
|
2248
2244
|
{
|
|
2249
2245
|
id,
|
|
@@ -2258,11 +2254,11 @@ function OptionalDataControlsField(props) {
|
|
|
2258
2254
|
}
|
|
2259
2255
|
|
|
2260
2256
|
// src/components/fields/SchemaField.tsx
|
|
2261
|
-
var
|
|
2262
|
-
var
|
|
2257
|
+
var import_react12 = require("react");
|
|
2258
|
+
var import_utils12 = require("@rjsf/utils");
|
|
2263
2259
|
var import_isObject5 = __toESM(require("lodash/isObject"), 1);
|
|
2264
2260
|
var import_omit3 = __toESM(require("lodash/omit"), 1);
|
|
2265
|
-
var
|
|
2261
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2266
2262
|
var COMPONENT_TYPES = {
|
|
2267
2263
|
array: "ArrayField",
|
|
2268
2264
|
boolean: "BooleanField",
|
|
@@ -2274,21 +2270,21 @@ var COMPONENT_TYPES = {
|
|
|
2274
2270
|
};
|
|
2275
2271
|
function getFieldComponent(schema, uiOptions, registry) {
|
|
2276
2272
|
const { field } = uiOptions;
|
|
2277
|
-
const { fields: fields2 } = registry;
|
|
2273
|
+
const { fields: fields2, schemaUtils } = registry;
|
|
2278
2274
|
if (typeof field === "function") {
|
|
2279
2275
|
return field;
|
|
2280
2276
|
}
|
|
2281
2277
|
if (typeof field === "string" && field in fields2) {
|
|
2282
2278
|
return fields2[field];
|
|
2283
2279
|
}
|
|
2284
|
-
const schemaType = (0,
|
|
2280
|
+
const schemaType = (0, import_utils12.getSchemaType)(schema);
|
|
2285
2281
|
const type = Array.isArray(schemaType) ? schemaType[0] : schemaType || "";
|
|
2286
2282
|
const schemaId = schema.$id;
|
|
2287
2283
|
let componentName = COMPONENT_TYPES[type];
|
|
2288
2284
|
if (schemaId && schemaId in fields2) {
|
|
2289
2285
|
componentName = schemaId;
|
|
2290
2286
|
}
|
|
2291
|
-
if (
|
|
2287
|
+
if ((schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) && componentName !== "ObjectField") {
|
|
2292
2288
|
return () => null;
|
|
2293
2289
|
}
|
|
2294
2290
|
return componentName in fields2 ? fields2[componentName] : fields2.FallbackField;
|
|
@@ -2310,26 +2306,29 @@ function SchemaFieldRender(props) {
|
|
|
2310
2306
|
wasPropertyKeyModified = false
|
|
2311
2307
|
} = props;
|
|
2312
2308
|
const { schemaUtils, globalFormOptions, globalUiOptions, fields: fields2 } = registry;
|
|
2313
|
-
const { AnyOfField: _AnyOfField, OneOfField: _OneOfField } = fields2;
|
|
2314
|
-
const
|
|
2315
|
-
const
|
|
2316
|
-
const FieldTemplate2 = (0, import_utils11.getTemplate)("FieldTemplate", registry, uiOptions);
|
|
2317
|
-
const DescriptionFieldTemplate = (0, import_utils11.getTemplate)(
|
|
2318
|
-
"DescriptionFieldTemplate",
|
|
2319
|
-
registry,
|
|
2320
|
-
uiOptions
|
|
2321
|
-
);
|
|
2322
|
-
const FieldHelpTemplate2 = (0, import_utils11.getTemplate)("FieldHelpTemplate", registry, uiOptions);
|
|
2323
|
-
const FieldErrorTemplate2 = (0, import_utils11.getTemplate)("FieldErrorTemplate", registry, uiOptions);
|
|
2324
|
-
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2325
|
-
const fieldId = fieldPathId[import_utils11.ID_KEY];
|
|
2326
|
-
const handleFieldComponentChange = (0, import_react11.useCallback)(
|
|
2309
|
+
const { AnyOfField: _AnyOfField, OneOfField: _OneOfField, CyclicSchemaField: CyclicSchemaField2 } = fields2;
|
|
2310
|
+
const fieldId = fieldPathId[import_utils12.ID_KEY];
|
|
2311
|
+
const handleFieldComponentChange = (0, import_react12.useCallback)(
|
|
2327
2312
|
(newFormData, path, newErrorSchema, id2) => {
|
|
2328
2313
|
const theId = id2 || fieldId;
|
|
2329
2314
|
return onChange(newFormData, path, newErrorSchema, theId);
|
|
2330
2315
|
},
|
|
2331
2316
|
[fieldId, onChange]
|
|
2332
2317
|
);
|
|
2318
|
+
if (_schema[import_utils12.RJSF_REF_CYCLE_KEY]) {
|
|
2319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CyclicSchemaField2, { ...props });
|
|
2320
|
+
}
|
|
2321
|
+
const uiSchema = (0, import_utils12.resolveUiSchema)(_schema, _uiSchema, registry);
|
|
2322
|
+
const uiOptions = (0, import_utils12.getUiOptions)(uiSchema, globalUiOptions);
|
|
2323
|
+
const FieldTemplate2 = (0, import_utils12.getTemplate)("FieldTemplate", registry, uiOptions);
|
|
2324
|
+
const DescriptionFieldTemplate = (0, import_utils12.getTemplate)(
|
|
2325
|
+
"DescriptionFieldTemplate",
|
|
2326
|
+
registry,
|
|
2327
|
+
uiOptions
|
|
2328
|
+
);
|
|
2329
|
+
const FieldHelpTemplate2 = (0, import_utils12.getTemplate)("FieldHelpTemplate", registry, uiOptions);
|
|
2330
|
+
const FieldErrorTemplate2 = (0, import_utils12.getTemplate)("FieldErrorTemplate", registry, uiOptions);
|
|
2331
|
+
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
2333
2332
|
const FieldComponent = getFieldComponent(schema, uiOptions, registry);
|
|
2334
2333
|
const isDeprecated = Boolean(schema.deprecated);
|
|
2335
2334
|
const deprecatedHandling = isDeprecated ? uiOptions.deprecatedHandling ?? "label" : void 0;
|
|
@@ -2346,34 +2345,34 @@ function SchemaFieldRender(props) {
|
|
|
2346
2345
|
let XxxOfField;
|
|
2347
2346
|
let XxxOfOptions;
|
|
2348
2347
|
let fieldPathIdProps = { fieldPathId };
|
|
2349
|
-
if ((
|
|
2350
|
-
if (schema[
|
|
2348
|
+
if ((import_utils12.ANY_OF_KEY in schema || import_utils12.ONE_OF_KEY in schema) && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema)) {
|
|
2349
|
+
if (schema[import_utils12.ANY_OF_KEY]) {
|
|
2351
2350
|
XxxOfField = _AnyOfField;
|
|
2352
|
-
XxxOfOptions = schema[
|
|
2351
|
+
XxxOfOptions = schema[import_utils12.ANY_OF_KEY].map(
|
|
2353
2352
|
(xxxOfSchema) => schemaUtils.retrieveSchema((0, import_isObject5.default)(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2354
2353
|
);
|
|
2355
|
-
} else if (schema[
|
|
2354
|
+
} else if (schema[import_utils12.ONE_OF_KEY]) {
|
|
2356
2355
|
XxxOfField = _OneOfField;
|
|
2357
|
-
XxxOfOptions = schema[
|
|
2356
|
+
XxxOfOptions = schema[import_utils12.ONE_OF_KEY].map(
|
|
2358
2357
|
(xxxOfSchema) => schemaUtils.retrieveSchema((0, import_isObject5.default)(xxxOfSchema) ? xxxOfSchema : {}, formData)
|
|
2359
2358
|
);
|
|
2360
2359
|
}
|
|
2361
|
-
const isOptionalRender = (0,
|
|
2362
|
-
const hasFormData = (0,
|
|
2360
|
+
const isOptionalRender = (0, import_utils12.shouldRenderOptionalField)(registry, schema, required, uiSchema);
|
|
2361
|
+
const hasFormData = (0, import_utils12.isFormDataAvailable)(formData);
|
|
2363
2362
|
displayLabel = displayLabel && (!isOptionalRender || hasFormData);
|
|
2364
2363
|
fieldPathIdProps = {
|
|
2365
2364
|
childFieldPathId: fieldPathId,
|
|
2366
2365
|
// The main FieldComponent will add `XxxOf` onto the fieldPathId to avoid duplication with the rendering of the
|
|
2367
2366
|
// same FieldComponent by the `XxxOfField`
|
|
2368
|
-
fieldPathId: (0,
|
|
2367
|
+
fieldPathId: (0, import_utils12.toFieldPathId)("XxxOf", globalFormOptions, fieldPathId)
|
|
2369
2368
|
};
|
|
2370
2369
|
}
|
|
2371
2370
|
const { __errors, ...fieldErrorSchema } = errorSchema || {};
|
|
2372
2371
|
const fieldUiSchema = (0, import_omit3.default)(uiSchema, ["ui:classNames", "classNames", "ui:style"]);
|
|
2373
|
-
if (
|
|
2374
|
-
fieldUiSchema[
|
|
2372
|
+
if (import_utils12.UI_OPTIONS_KEY in fieldUiSchema) {
|
|
2373
|
+
fieldUiSchema[import_utils12.UI_OPTIONS_KEY] = (0, import_omit3.default)(fieldUiSchema[import_utils12.UI_OPTIONS_KEY], ["classNames", "style"]);
|
|
2375
2374
|
}
|
|
2376
|
-
const field = /* @__PURE__ */ (0,
|
|
2375
|
+
const field = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2377
2376
|
FieldComponent,
|
|
2378
2377
|
{
|
|
2379
2378
|
...props,
|
|
@@ -2389,27 +2388,27 @@ function SchemaFieldRender(props) {
|
|
|
2389
2388
|
rawErrors: __errors
|
|
2390
2389
|
}
|
|
2391
2390
|
);
|
|
2392
|
-
const id = fieldPathId[
|
|
2391
|
+
const id = fieldPathId[import_utils12.ID_KEY];
|
|
2393
2392
|
let label;
|
|
2394
2393
|
if (wasPropertyKeyModified) {
|
|
2395
2394
|
label = name;
|
|
2396
2395
|
} else {
|
|
2397
|
-
label =
|
|
2396
|
+
label = import_utils12.ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || props.title || name;
|
|
2398
2397
|
}
|
|
2399
2398
|
if (deprecatedHandling === "label") {
|
|
2400
|
-
label = registry.translateString(
|
|
2399
|
+
label = registry.translateString(import_utils12.TranslatableString.DeprecatedLabel, [label]);
|
|
2401
2400
|
}
|
|
2402
2401
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
2403
2402
|
const { help } = uiOptions;
|
|
2404
2403
|
const hidden = uiOptions.widget === "hidden" || deprecatedHandling === "hide";
|
|
2405
|
-
const classNames = ["rjsf-field", `rjsf-field-${(0,
|
|
2404
|
+
const classNames = ["rjsf-field", `rjsf-field-${(0, import_utils12.getSchemaType)(schema)}`];
|
|
2406
2405
|
if (!hideError && __errors && __errors.length > 0) {
|
|
2407
2406
|
classNames.push("rjsf-field-error");
|
|
2408
2407
|
}
|
|
2409
2408
|
if (uiOptions.classNames) {
|
|
2410
2409
|
classNames.push(uiOptions.classNames);
|
|
2411
2410
|
}
|
|
2412
|
-
const helpComponent = /* @__PURE__ */ (0,
|
|
2411
|
+
const helpComponent = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2413
2412
|
FieldHelpTemplate2,
|
|
2414
2413
|
{
|
|
2415
2414
|
help,
|
|
@@ -2420,7 +2419,7 @@ function SchemaFieldRender(props) {
|
|
|
2420
2419
|
registry
|
|
2421
2420
|
}
|
|
2422
2421
|
);
|
|
2423
|
-
const errorsComponent = hideError || XxxOfField && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ (0,
|
|
2422
|
+
const errorsComponent = hideError || XxxOfField && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2424
2423
|
FieldErrorTemplate2,
|
|
2425
2424
|
{
|
|
2426
2425
|
errors: __errors,
|
|
@@ -2432,10 +2431,10 @@ function SchemaFieldRender(props) {
|
|
|
2432
2431
|
}
|
|
2433
2432
|
);
|
|
2434
2433
|
const fieldProps = {
|
|
2435
|
-
description: /* @__PURE__ */ (0,
|
|
2434
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2436
2435
|
DescriptionFieldTemplate,
|
|
2437
2436
|
{
|
|
2438
|
-
id: (0,
|
|
2437
|
+
id: (0, import_utils12.descriptionId)(id),
|
|
2439
2438
|
description,
|
|
2440
2439
|
schema,
|
|
2441
2440
|
uiSchema,
|
|
@@ -2467,9 +2466,9 @@ function SchemaFieldRender(props) {
|
|
|
2467
2466
|
uiSchema,
|
|
2468
2467
|
registry
|
|
2469
2468
|
};
|
|
2470
|
-
return /* @__PURE__ */ (0,
|
|
2469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
2471
2470
|
field,
|
|
2472
|
-
XxxOfField && /* @__PURE__ */ (0,
|
|
2471
|
+
XxxOfField && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2473
2472
|
XxxOfField,
|
|
2474
2473
|
{
|
|
2475
2474
|
name,
|
|
@@ -2491,24 +2490,22 @@ function SchemaFieldRender(props) {
|
|
|
2491
2490
|
)
|
|
2492
2491
|
] }) });
|
|
2493
2492
|
}
|
|
2494
|
-
var SchemaField =
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
} = this.props;
|
|
2499
|
-
const { experimental_componentUpdateStrategy = "customDeep" } = globalFormOptions;
|
|
2500
|
-
return (0, import_utils11.shouldRender)(this, nextProps, this.state, experimental_componentUpdateStrategy);
|
|
2493
|
+
var SchemaField = (0, import_react12.memo)(SchemaFieldRender, (prevProps, nextProps) => {
|
|
2494
|
+
const { experimental_componentUpdateStrategy = "customDeep" } = nextProps.registry.globalFormOptions;
|
|
2495
|
+
if (experimental_componentUpdateStrategy === "always") {
|
|
2496
|
+
return false;
|
|
2501
2497
|
}
|
|
2502
|
-
|
|
2503
|
-
return
|
|
2498
|
+
if (experimental_componentUpdateStrategy === "shallow") {
|
|
2499
|
+
return (0, import_utils12.shallowEquals)(prevProps, nextProps);
|
|
2504
2500
|
}
|
|
2505
|
-
|
|
2501
|
+
return (0, import_utils12.deepEquals)(prevProps, nextProps);
|
|
2502
|
+
});
|
|
2506
2503
|
var SchemaField_default = SchemaField;
|
|
2507
2504
|
|
|
2508
2505
|
// src/components/fields/StringField.tsx
|
|
2509
|
-
var
|
|
2510
|
-
var
|
|
2511
|
-
var
|
|
2506
|
+
var import_react13 = require("react");
|
|
2507
|
+
var import_utils13 = require("@rjsf/utils");
|
|
2508
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2512
2509
|
function StringField(props) {
|
|
2513
2510
|
const {
|
|
2514
2511
|
schema,
|
|
@@ -2530,20 +2527,20 @@ function StringField(props) {
|
|
|
2530
2527
|
} = props;
|
|
2531
2528
|
const { title: schemaTitle, format } = schema;
|
|
2532
2529
|
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
2533
|
-
const enumOptions = schemaUtils.isSelect(schema) ? (0,
|
|
2530
|
+
const enumOptions = schemaUtils.isSelect(schema) ? (0, import_utils13.optionsList)(schema, uiSchema) : void 0;
|
|
2534
2531
|
let defaultWidget = enumOptions ? "select" : "text";
|
|
2535
|
-
if (format && (0,
|
|
2532
|
+
if (format && (0, import_utils13.hasWidget)(schema, format, widgets2)) {
|
|
2536
2533
|
defaultWidget = format;
|
|
2537
2534
|
}
|
|
2538
|
-
const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = (0,
|
|
2535
|
+
const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = (0, import_utils13.getUiOptions)(uiSchema);
|
|
2539
2536
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
2540
2537
|
const label = uiTitle ?? title ?? schemaTitle ?? name;
|
|
2541
|
-
const Widget = (0,
|
|
2542
|
-
const onWidgetChange = (0,
|
|
2538
|
+
const Widget = (0, import_utils13.getWidget)(schema, widget, widgets2);
|
|
2539
|
+
const onWidgetChange = (0, import_react13.useCallback)(
|
|
2543
2540
|
(value, errorSchema, id) => onChange(value, fieldPathId.path, errorSchema, id),
|
|
2544
2541
|
[onChange, fieldPathId]
|
|
2545
2542
|
);
|
|
2546
|
-
return /* @__PURE__ */ (0,
|
|
2543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2547
2544
|
Widget,
|
|
2548
2545
|
{
|
|
2549
2546
|
options: { ...options, enumOptions },
|
|
@@ -2578,6 +2575,7 @@ function fields() {
|
|
|
2578
2575
|
ArrayField,
|
|
2579
2576
|
// ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
|
|
2580
2577
|
BooleanField: BooleanField_default,
|
|
2578
|
+
CyclicSchemaField,
|
|
2581
2579
|
FallbackField,
|
|
2582
2580
|
LayoutGridField,
|
|
2583
2581
|
LayoutHeaderField,
|
|
@@ -2594,24 +2592,24 @@ function fields() {
|
|
|
2594
2592
|
var fields_default = fields;
|
|
2595
2593
|
|
|
2596
2594
|
// src/components/templates/ArrayFieldDescriptionTemplate.tsx
|
|
2597
|
-
var
|
|
2598
|
-
var
|
|
2595
|
+
var import_utils14 = require("@rjsf/utils");
|
|
2596
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2599
2597
|
function ArrayFieldDescriptionTemplate(props) {
|
|
2600
2598
|
const { fieldPathId, description, registry, schema, uiSchema } = props;
|
|
2601
|
-
const options = (0,
|
|
2599
|
+
const options = (0, import_utils14.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
2602
2600
|
const { label: displayLabel = true } = options;
|
|
2603
2601
|
if (!description || !displayLabel) {
|
|
2604
2602
|
return null;
|
|
2605
2603
|
}
|
|
2606
|
-
const DescriptionFieldTemplate = (0,
|
|
2604
|
+
const DescriptionFieldTemplate = (0, import_utils14.getTemplate)(
|
|
2607
2605
|
"DescriptionFieldTemplate",
|
|
2608
2606
|
registry,
|
|
2609
2607
|
options
|
|
2610
2608
|
);
|
|
2611
|
-
return /* @__PURE__ */ (0,
|
|
2609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2612
2610
|
DescriptionFieldTemplate,
|
|
2613
2611
|
{
|
|
2614
|
-
id: (0,
|
|
2612
|
+
id: (0, import_utils14.descriptionId)(fieldPathId),
|
|
2615
2613
|
description,
|
|
2616
2614
|
schema,
|
|
2617
2615
|
uiSchema,
|
|
@@ -2621,8 +2619,8 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
2621
2619
|
}
|
|
2622
2620
|
|
|
2623
2621
|
// src/components/templates/ArrayFieldItemButtonsTemplate.tsx
|
|
2624
|
-
var
|
|
2625
|
-
var
|
|
2622
|
+
var import_utils15 = require("@rjsf/utils");
|
|
2623
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2626
2624
|
function ArrayFieldItemButtonsTemplate(props) {
|
|
2627
2625
|
const {
|
|
2628
2626
|
disabled,
|
|
@@ -2640,11 +2638,11 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2640
2638
|
uiSchema
|
|
2641
2639
|
} = props;
|
|
2642
2640
|
const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
|
|
2643
|
-
return /* @__PURE__ */ (0,
|
|
2644
|
-
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0,
|
|
2641
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
2642
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2645
2643
|
MoveUpButton2,
|
|
2646
2644
|
{
|
|
2647
|
-
id: (0,
|
|
2645
|
+
id: (0, import_utils15.buttonId)(fieldPathId, "moveUp"),
|
|
2648
2646
|
className: "rjsf-array-item-move-up",
|
|
2649
2647
|
disabled: disabled || readonly || !hasMoveUp,
|
|
2650
2648
|
onClick: onMoveUpItem,
|
|
@@ -2652,10 +2650,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2652
2650
|
registry
|
|
2653
2651
|
}
|
|
2654
2652
|
),
|
|
2655
|
-
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0,
|
|
2653
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2656
2654
|
MoveDownButton2,
|
|
2657
2655
|
{
|
|
2658
|
-
id: (0,
|
|
2656
|
+
id: (0, import_utils15.buttonId)(fieldPathId, "moveDown"),
|
|
2659
2657
|
className: "rjsf-array-item-move-down",
|
|
2660
2658
|
disabled: disabled || readonly || !hasMoveDown,
|
|
2661
2659
|
onClick: onMoveDownItem,
|
|
@@ -2663,10 +2661,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2663
2661
|
registry
|
|
2664
2662
|
}
|
|
2665
2663
|
),
|
|
2666
|
-
hasCopy && /* @__PURE__ */ (0,
|
|
2664
|
+
hasCopy && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2667
2665
|
CopyButton2,
|
|
2668
2666
|
{
|
|
2669
|
-
id: (0,
|
|
2667
|
+
id: (0, import_utils15.buttonId)(fieldPathId, "copy"),
|
|
2670
2668
|
className: "rjsf-array-item-copy",
|
|
2671
2669
|
disabled: disabled || readonly,
|
|
2672
2670
|
onClick: onCopyItem,
|
|
@@ -2674,10 +2672,10 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2674
2672
|
registry
|
|
2675
2673
|
}
|
|
2676
2674
|
),
|
|
2677
|
-
hasRemove && /* @__PURE__ */ (0,
|
|
2675
|
+
hasRemove && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2678
2676
|
RemoveButton2,
|
|
2679
2677
|
{
|
|
2680
|
-
id: (0,
|
|
2678
|
+
id: (0, import_utils15.buttonId)(fieldPathId, "remove"),
|
|
2681
2679
|
className: "rjsf-array-item-remove",
|
|
2682
2680
|
disabled: disabled || readonly,
|
|
2683
2681
|
onClick: onRemoveItem,
|
|
@@ -2689,12 +2687,12 @@ function ArrayFieldItemButtonsTemplate(props) {
|
|
|
2689
2687
|
}
|
|
2690
2688
|
|
|
2691
2689
|
// src/components/templates/ArrayFieldItemTemplate.tsx
|
|
2692
|
-
var
|
|
2693
|
-
var
|
|
2690
|
+
var import_utils16 = require("@rjsf/utils");
|
|
2691
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2694
2692
|
function ArrayFieldItemTemplate(props) {
|
|
2695
2693
|
const { children, className, buttonsProps, displayLabel, hasDescription, hasToolbar, registry, uiSchema } = props;
|
|
2696
|
-
const uiOptions = (0,
|
|
2697
|
-
const ArrayFieldItemButtonsTemplate2 = (0,
|
|
2694
|
+
const uiOptions = (0, import_utils16.getUiOptions)(uiSchema);
|
|
2695
|
+
const ArrayFieldItemButtonsTemplate2 = (0, import_utils16.getTemplate)(
|
|
2698
2696
|
"ArrayFieldItemButtonsTemplate",
|
|
2699
2697
|
registry,
|
|
2700
2698
|
uiOptions
|
|
@@ -2708,15 +2706,15 @@ function ArrayFieldItemTemplate(props) {
|
|
|
2708
2706
|
const margin = hasDescription ? 31 : 9;
|
|
2709
2707
|
const containerStyle = { display: "flex", alignItems: displayLabel ? "center" : "baseline" };
|
|
2710
2708
|
const toolbarStyle = { display: "flex", justifyContent: "flex-end", marginTop: displayLabel ? `${margin}px` : 0 };
|
|
2711
|
-
return /* @__PURE__ */ (0,
|
|
2712
|
-
/* @__PURE__ */ (0,
|
|
2713
|
-
hasToolbar && /* @__PURE__ */ (0,
|
|
2709
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className, style: containerStyle, children: [
|
|
2710
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: hasToolbar ? "col-xs-9 col-md-10 col-xl-11" : "col-xs-12", children }),
|
|
2711
|
+
hasToolbar && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "col-xs-3 col-md-2 col-xl-1 array-item-toolbox", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "btn-group", style: toolbarStyle, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ArrayFieldItemButtonsTemplate2, { ...buttonsProps, style: btnStyle }) }) })
|
|
2714
2712
|
] });
|
|
2715
2713
|
}
|
|
2716
2714
|
|
|
2717
2715
|
// src/components/templates/ArrayFieldTemplate.tsx
|
|
2718
|
-
var
|
|
2719
|
-
var
|
|
2716
|
+
var import_utils17 = require("@rjsf/utils");
|
|
2717
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2720
2718
|
function ArrayFieldTemplate(props) {
|
|
2721
2719
|
const {
|
|
2722
2720
|
canAdd,
|
|
@@ -2733,13 +2731,13 @@ function ArrayFieldTemplate(props) {
|
|
|
2733
2731
|
schema,
|
|
2734
2732
|
title
|
|
2735
2733
|
} = props;
|
|
2736
|
-
const uiOptions = (0,
|
|
2737
|
-
const ArrayFieldDescriptionTemplate2 = (0,
|
|
2734
|
+
const uiOptions = (0, import_utils17.getUiOptions)(uiSchema);
|
|
2735
|
+
const ArrayFieldDescriptionTemplate2 = (0, import_utils17.getTemplate)(
|
|
2738
2736
|
"ArrayFieldDescriptionTemplate",
|
|
2739
2737
|
registry,
|
|
2740
2738
|
uiOptions
|
|
2741
2739
|
);
|
|
2742
|
-
const ArrayFieldTitleTemplate2 = (0,
|
|
2740
|
+
const ArrayFieldTitleTemplate2 = (0, import_utils17.getTemplate)(
|
|
2743
2741
|
"ArrayFieldTitleTemplate",
|
|
2744
2742
|
registry,
|
|
2745
2743
|
uiOptions
|
|
@@ -2748,8 +2746,8 @@ function ArrayFieldTemplate(props) {
|
|
|
2748
2746
|
const {
|
|
2749
2747
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
2750
2748
|
} = registry.templates;
|
|
2751
|
-
return /* @__PURE__ */ (0,
|
|
2752
|
-
/* @__PURE__ */ (0,
|
|
2749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("fieldset", { className, id: fieldPathId.$id, children: [
|
|
2750
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2753
2751
|
ArrayFieldTitleTemplate2,
|
|
2754
2752
|
{
|
|
2755
2753
|
fieldPathId,
|
|
@@ -2761,7 +2759,7 @@ function ArrayFieldTemplate(props) {
|
|
|
2761
2759
|
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
2762
2760
|
}
|
|
2763
2761
|
),
|
|
2764
|
-
/* @__PURE__ */ (0,
|
|
2762
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2765
2763
|
ArrayFieldDescriptionTemplate2,
|
|
2766
2764
|
{
|
|
2767
2765
|
fieldPathId,
|
|
@@ -2772,11 +2770,11 @@ function ArrayFieldTemplate(props) {
|
|
|
2772
2770
|
}
|
|
2773
2771
|
),
|
|
2774
2772
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
2775
|
-
/* @__PURE__ */ (0,
|
|
2776
|
-
canAdd && /* @__PURE__ */ (0,
|
|
2773
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "row array-item-list", children: items }),
|
|
2774
|
+
canAdd && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2777
2775
|
AddButton2,
|
|
2778
2776
|
{
|
|
2779
|
-
id: (0,
|
|
2777
|
+
id: (0, import_utils17.buttonId)(fieldPathId, "add"),
|
|
2780
2778
|
className: "rjsf-array-item-add",
|
|
2781
2779
|
onClick: onAddClick,
|
|
2782
2780
|
disabled: disabled || readonly,
|
|
@@ -2788,24 +2786,24 @@ function ArrayFieldTemplate(props) {
|
|
|
2788
2786
|
}
|
|
2789
2787
|
|
|
2790
2788
|
// src/components/templates/ArrayFieldTitleTemplate.tsx
|
|
2791
|
-
var
|
|
2792
|
-
var
|
|
2789
|
+
var import_utils18 = require("@rjsf/utils");
|
|
2790
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2793
2791
|
function ArrayFieldTitleTemplate(props) {
|
|
2794
2792
|
const { fieldPathId, title, schema, uiSchema, required, registry, optionalDataControl } = props;
|
|
2795
|
-
const options = (0,
|
|
2793
|
+
const options = (0, import_utils18.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
2796
2794
|
const { label: displayLabel = true } = options;
|
|
2797
2795
|
if (!title || !displayLabel) {
|
|
2798
2796
|
return null;
|
|
2799
2797
|
}
|
|
2800
|
-
const TitleFieldTemplate = (0,
|
|
2798
|
+
const TitleFieldTemplate = (0, import_utils18.getTemplate)(
|
|
2801
2799
|
"TitleFieldTemplate",
|
|
2802
2800
|
registry,
|
|
2803
2801
|
options
|
|
2804
2802
|
);
|
|
2805
|
-
return /* @__PURE__ */ (0,
|
|
2803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2806
2804
|
TitleFieldTemplate,
|
|
2807
2805
|
{
|
|
2808
|
-
id: (0,
|
|
2806
|
+
id: (0, import_utils18.titleId)(fieldPathId),
|
|
2809
2807
|
title,
|
|
2810
2808
|
required,
|
|
2811
2809
|
schema,
|
|
@@ -2817,12 +2815,12 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
2817
2815
|
}
|
|
2818
2816
|
|
|
2819
2817
|
// src/components/templates/BaseInputTemplate.tsx
|
|
2820
|
-
var
|
|
2821
|
-
var
|
|
2818
|
+
var import_react14 = require("react");
|
|
2819
|
+
var import_utils20 = require("@rjsf/utils");
|
|
2822
2820
|
|
|
2823
2821
|
// src/components/SchemaExamples.tsx
|
|
2824
|
-
var
|
|
2825
|
-
var
|
|
2822
|
+
var import_utils19 = require("@rjsf/utils");
|
|
2823
|
+
var import_jsx_runtime19 = (
|
|
2826
2824
|
// oxlint-disable-next-line jsx-a11y/control-has-associated-label
|
|
2827
2825
|
require("react/jsx-runtime")
|
|
2828
2826
|
);
|
|
@@ -2832,13 +2830,13 @@ function SchemaExamples(props) {
|
|
|
2832
2830
|
if (!Array.isArray(examples)) {
|
|
2833
2831
|
return null;
|
|
2834
2832
|
}
|
|
2835
|
-
return /* @__PURE__ */ (0,
|
|
2833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("datalist", { id: (0, import_utils19.examplesId)(id), children: examples.concat(
|
|
2836
2834
|
schemaDefault !== void 0 && !examples.map(String).includes(String(schemaDefault)) ? [schemaDefault] : []
|
|
2837
|
-
).map((example) => /* @__PURE__ */ (0,
|
|
2835
|
+
).map((example) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: example }, String(example))) }, `datalist_${id}`);
|
|
2838
2836
|
}
|
|
2839
2837
|
|
|
2840
2838
|
// src/components/templates/BaseInputTemplate.tsx
|
|
2841
|
-
var
|
|
2839
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2842
2840
|
function BaseInputTemplate(props) {
|
|
2843
2841
|
const {
|
|
2844
2842
|
id,
|
|
@@ -2872,7 +2870,7 @@ function BaseInputTemplate(props) {
|
|
|
2872
2870
|
}
|
|
2873
2871
|
const inputProps = {
|
|
2874
2872
|
...rest,
|
|
2875
|
-
...(0,
|
|
2873
|
+
...(0, import_utils20.getInputProps)(schema, type, options)
|
|
2876
2874
|
};
|
|
2877
2875
|
let inputValue;
|
|
2878
2876
|
if (inputProps.type === "number" || inputProps.type === "integer") {
|
|
@@ -2880,19 +2878,16 @@ function BaseInputTemplate(props) {
|
|
|
2880
2878
|
} else {
|
|
2881
2879
|
inputValue = value == null ? "" : value;
|
|
2882
2880
|
}
|
|
2883
|
-
const handleChange = (0,
|
|
2881
|
+
const handleChange = (0, import_react14.useCallback)(
|
|
2884
2882
|
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
2885
2883
|
[onChange, options]
|
|
2886
2884
|
);
|
|
2887
|
-
const handleBlur = (0,
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
);
|
|
2891
|
-
const handleFocus = (0, import_react13.useCallback)(
|
|
2892
|
-
({ target }) => onFocus(id, target && target.value),
|
|
2885
|
+
const handleBlur = (0, import_react14.useCallback)(({ target }) => onBlur(id, target?.value), [onBlur, id]);
|
|
2886
|
+
const handleFocus = (0, import_react14.useCallback)(
|
|
2887
|
+
({ target }) => onFocus(id, target?.value),
|
|
2893
2888
|
[onFocus, id]
|
|
2894
2889
|
);
|
|
2895
|
-
const handleClear = (0,
|
|
2890
|
+
const handleClear = (0, import_react14.useCallback)(
|
|
2896
2891
|
(e) => {
|
|
2897
2892
|
e.preventDefault();
|
|
2898
2893
|
e.stopPropagation();
|
|
@@ -2900,8 +2895,8 @@ function BaseInputTemplate(props) {
|
|
|
2900
2895
|
},
|
|
2901
2896
|
[onChange, options.emptyValue]
|
|
2902
2897
|
);
|
|
2903
|
-
return /* @__PURE__ */ (0,
|
|
2904
|
-
/* @__PURE__ */ (0,
|
|
2898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2899
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2905
2900
|
"input",
|
|
2906
2901
|
{
|
|
2907
2902
|
id,
|
|
@@ -2912,59 +2907,59 @@ function BaseInputTemplate(props) {
|
|
|
2912
2907
|
autoFocus: autofocus,
|
|
2913
2908
|
value: inputValue,
|
|
2914
2909
|
...inputProps,
|
|
2915
|
-
list: schema.examples ? (0,
|
|
2910
|
+
list: schema.examples ? (0, import_utils20.examplesId)(id) : void 0,
|
|
2916
2911
|
onChange: onChangeOverride || handleChange,
|
|
2917
2912
|
onBlur: handleBlur,
|
|
2918
2913
|
onFocus: handleFocus,
|
|
2919
|
-
"aria-describedby": (0,
|
|
2914
|
+
"aria-describedby": (0, import_utils20.ariaDescribedByIds)(id, !!schema.examples)
|
|
2920
2915
|
}
|
|
2921
2916
|
),
|
|
2922
|
-
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ (0,
|
|
2923
|
-
/* @__PURE__ */ (0,
|
|
2917
|
+
options.allowClearTextInputs && !readonly && !disabled && inputValue && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ClearButton2, { registry, onClick: handleClear }),
|
|
2918
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SchemaExamples, { id, schema })
|
|
2924
2919
|
] });
|
|
2925
2920
|
}
|
|
2926
2921
|
|
|
2927
2922
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
2928
|
-
var
|
|
2923
|
+
var import_utils22 = require("@rjsf/utils");
|
|
2929
2924
|
|
|
2930
2925
|
// src/components/templates/ButtonTemplates/IconButton.tsx
|
|
2931
|
-
var
|
|
2932
|
-
var
|
|
2933
|
-
var
|
|
2926
|
+
var import_react15 = require("react");
|
|
2927
|
+
var import_utils21 = require("@rjsf/utils");
|
|
2928
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2934
2929
|
function IconButtonFn(props) {
|
|
2935
2930
|
const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
|
|
2936
|
-
return /* @__PURE__ */ (0,
|
|
2931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("i", { className: `glyphicon glyphicon-${icon}` }) });
|
|
2937
2932
|
}
|
|
2938
|
-
var IconButton = (0,
|
|
2933
|
+
var IconButton = (0, import_react15.memo)(IconButtonFn);
|
|
2939
2934
|
var IconButton_default = IconButton;
|
|
2940
2935
|
function CopyButtonFn(props) {
|
|
2941
2936
|
const {
|
|
2942
2937
|
registry: { translateString }
|
|
2943
2938
|
} = props;
|
|
2944
|
-
return /* @__PURE__ */ (0,
|
|
2939
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(IconButton, { title: translateString(import_utils21.TranslatableString.CopyButton), ...props, icon: "copy" });
|
|
2945
2940
|
}
|
|
2946
|
-
var CopyButton = (0,
|
|
2941
|
+
var CopyButton = (0, import_react15.memo)(CopyButtonFn);
|
|
2947
2942
|
function MoveDownButtonFn(props) {
|
|
2948
2943
|
const {
|
|
2949
2944
|
registry: { translateString }
|
|
2950
2945
|
} = props;
|
|
2951
|
-
return /* @__PURE__ */ (0,
|
|
2946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(IconButton, { title: translateString(import_utils21.TranslatableString.MoveDownButton), ...props, icon: "arrow-down" });
|
|
2952
2947
|
}
|
|
2953
|
-
var MoveDownButton = (0,
|
|
2948
|
+
var MoveDownButton = (0, import_react15.memo)(MoveDownButtonFn);
|
|
2954
2949
|
function MoveUpButtonFn(props) {
|
|
2955
2950
|
const {
|
|
2956
2951
|
registry: { translateString }
|
|
2957
2952
|
} = props;
|
|
2958
|
-
return /* @__PURE__ */ (0,
|
|
2953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(IconButton, { title: translateString(import_utils21.TranslatableString.MoveUpButton), ...props, icon: "arrow-up" });
|
|
2959
2954
|
}
|
|
2960
|
-
var MoveUpButton = (0,
|
|
2955
|
+
var MoveUpButton = (0, import_react15.memo)(MoveUpButtonFn);
|
|
2961
2956
|
function RemoveButtonFn(props) {
|
|
2962
2957
|
const {
|
|
2963
2958
|
registry: { translateString }
|
|
2964
2959
|
} = props;
|
|
2965
|
-
return /* @__PURE__ */ (0,
|
|
2960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(IconButton, { title: translateString(import_utils21.TranslatableString.RemoveButton), ...props, iconType: "danger", icon: "remove" });
|
|
2966
2961
|
}
|
|
2967
|
-
var RemoveButton = (0,
|
|
2962
|
+
var RemoveButton = (0, import_react15.memo)(RemoveButtonFn);
|
|
2968
2963
|
function ClearButtonFn({
|
|
2969
2964
|
id,
|
|
2970
2965
|
className,
|
|
@@ -2974,14 +2969,14 @@ function ClearButtonFn({
|
|
|
2974
2969
|
...props
|
|
2975
2970
|
}) {
|
|
2976
2971
|
const { translateString } = registry;
|
|
2977
|
-
return /* @__PURE__ */ (0,
|
|
2972
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2978
2973
|
IconButton,
|
|
2979
2974
|
{
|
|
2980
2975
|
id,
|
|
2981
2976
|
iconType: "default",
|
|
2982
2977
|
icon: "remove",
|
|
2983
2978
|
className: "btn-clear col-xs-12",
|
|
2984
|
-
title: translateString(
|
|
2979
|
+
title: translateString(import_utils21.TranslatableString.ClearButton),
|
|
2985
2980
|
onClick,
|
|
2986
2981
|
disabled,
|
|
2987
2982
|
registry,
|
|
@@ -2989,10 +2984,10 @@ function ClearButtonFn({
|
|
|
2989
2984
|
}
|
|
2990
2985
|
);
|
|
2991
2986
|
}
|
|
2992
|
-
var ClearButton = (0,
|
|
2987
|
+
var ClearButton = (0, import_react15.memo)(ClearButtonFn);
|
|
2993
2988
|
|
|
2994
2989
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
2995
|
-
var
|
|
2990
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2996
2991
|
function AddButton({
|
|
2997
2992
|
id,
|
|
2998
2993
|
className,
|
|
@@ -3001,18 +2996,18 @@ function AddButton({
|
|
|
3001
2996
|
registry
|
|
3002
2997
|
}) {
|
|
3003
2998
|
const { translateString } = registry;
|
|
3004
|
-
return /* @__PURE__ */ (0,
|
|
2999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "row", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3005
3000
|
"p",
|
|
3006
3001
|
{
|
|
3007
3002
|
className: `col-xs-4 col-sm-2 col-lg-1 col-xs-offset-8 col-sm-offset-10 col-lg-offset-11 text-right ${className}`,
|
|
3008
|
-
children: /* @__PURE__ */ (0,
|
|
3003
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
3009
3004
|
IconButton_default,
|
|
3010
3005
|
{
|
|
3011
3006
|
id,
|
|
3012
3007
|
iconType: "info",
|
|
3013
3008
|
icon: "plus",
|
|
3014
3009
|
className: "btn-add col-xs-12",
|
|
3015
|
-
title: translateString(
|
|
3010
|
+
title: translateString(import_utils22.TranslatableString.AddButton),
|
|
3016
3011
|
onClick,
|
|
3017
3012
|
disabled,
|
|
3018
3013
|
registry
|
|
@@ -3023,14 +3018,14 @@ function AddButton({
|
|
|
3023
3018
|
}
|
|
3024
3019
|
|
|
3025
3020
|
// src/components/templates/ButtonTemplates/SubmitButton.tsx
|
|
3026
|
-
var
|
|
3027
|
-
var
|
|
3021
|
+
var import_utils23 = require("@rjsf/utils");
|
|
3022
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3028
3023
|
function SubmitButton({ uiSchema }) {
|
|
3029
|
-
const { submitText, norender, props: submitButtonProps = {} } = (0,
|
|
3024
|
+
const { submitText, norender, props: submitButtonProps = {} } = (0, import_utils23.getSubmitButtonOptions)(uiSchema);
|
|
3030
3025
|
if (norender) {
|
|
3031
3026
|
return null;
|
|
3032
3027
|
}
|
|
3033
|
-
return /* @__PURE__ */ (0,
|
|
3028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("button", { type: "submit", ...submitButtonProps, className: `btn btn-info ${submitButtonProps.className || ""}`, children: submitText }) });
|
|
3034
3029
|
}
|
|
3035
3030
|
|
|
3036
3031
|
// src/components/templates/ButtonTemplates/index.ts
|
|
@@ -3047,58 +3042,83 @@ function buttonTemplates() {
|
|
|
3047
3042
|
}
|
|
3048
3043
|
var ButtonTemplates_default = buttonTemplates;
|
|
3049
3044
|
|
|
3045
|
+
// src/components/templates/CyclicSchemaExpandTemplate.tsx
|
|
3046
|
+
var import_utils24 = require("@rjsf/utils");
|
|
3047
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3048
|
+
function CyclicSchemaExpandTemplate(props) {
|
|
3049
|
+
const { name, fieldPathId, registry, onExpand } = props;
|
|
3050
|
+
const { translateString } = registry;
|
|
3051
|
+
const buttonId5 = `${fieldPathId[import_utils24.ID_KEY]}-button`;
|
|
3052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { style: { marginTop: "1rem" }, children: [
|
|
3053
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "text-danger", children: translateString(import_utils24.TranslatableString.CycleDetected, [name]) }),
|
|
3054
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { children: [
|
|
3055
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
3056
|
+
"button",
|
|
3057
|
+
{
|
|
3058
|
+
id: buttonId5,
|
|
3059
|
+
type: "button",
|
|
3060
|
+
className: "btn btn-sm btn-warning",
|
|
3061
|
+
onClick: () => onExpand(fieldPathId[import_utils24.ID_KEY]),
|
|
3062
|
+
children: translateString(import_utils24.TranslatableString.ExpandButton)
|
|
3063
|
+
}
|
|
3064
|
+
),
|
|
3065
|
+
" "
|
|
3066
|
+
] })
|
|
3067
|
+
] });
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3050
3070
|
// src/components/RichDescription.tsx
|
|
3051
|
-
var
|
|
3052
|
-
var
|
|
3053
|
-
var
|
|
3054
|
-
var TEST_IDS = (0,
|
|
3071
|
+
var import_utils25 = require("@rjsf/utils");
|
|
3072
|
+
var import_react16 = require("markdown-to-jsx/react");
|
|
3073
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3074
|
+
var TEST_IDS = (0, import_utils25.getTestIds)();
|
|
3055
3075
|
function RichDescription({ description, registry, uiSchema = {} }) {
|
|
3056
3076
|
const { globalUiOptions } = registry;
|
|
3057
|
-
const uiOptions = (0,
|
|
3077
|
+
const uiOptions = (0, import_utils25.getUiOptions)(uiSchema, globalUiOptions);
|
|
3058
3078
|
if (uiOptions.enableMarkdownInDescription && typeof description === "string") {
|
|
3059
|
-
return /* @__PURE__ */ (0,
|
|
3079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react16.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
|
|
3060
3080
|
}
|
|
3061
3081
|
return description;
|
|
3062
3082
|
}
|
|
3063
3083
|
RichDescription.TEST_IDS = TEST_IDS;
|
|
3064
3084
|
|
|
3065
3085
|
// src/components/templates/DescriptionField.tsx
|
|
3066
|
-
var
|
|
3086
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3067
3087
|
function DescriptionField(props) {
|
|
3068
3088
|
const { id, description, registry, uiSchema } = props;
|
|
3069
3089
|
if (!description) {
|
|
3070
3090
|
return null;
|
|
3071
3091
|
}
|
|
3072
|
-
return /* @__PURE__ */ (0,
|
|
3092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { id, className: "field-description", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(RichDescription, { description, registry, uiSchema }) });
|
|
3073
3093
|
}
|
|
3074
3094
|
|
|
3075
3095
|
// src/components/templates/ErrorList.tsx
|
|
3076
|
-
var
|
|
3077
|
-
var
|
|
3096
|
+
var import_utils26 = require("@rjsf/utils");
|
|
3097
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3078
3098
|
function ErrorList({
|
|
3079
3099
|
errors,
|
|
3080
3100
|
registry
|
|
3081
3101
|
}) {
|
|
3082
3102
|
const { translateString } = registry;
|
|
3083
|
-
return /* @__PURE__ */ (0,
|
|
3084
|
-
/* @__PURE__ */ (0,
|
|
3085
|
-
/* @__PURE__ */ (0,
|
|
3103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "panel panel-danger errors", children: [
|
|
3104
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "panel-heading", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h3", { className: "panel-title", children: translateString(import_utils26.TranslatableString.ErrorsLabel) }) }),
|
|
3105
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("ul", { className: "list-group", children: errors.map((error, i) => (
|
|
3086
3106
|
// oxlint-disable-next-line react/no-array-index-key
|
|
3087
|
-
/* @__PURE__ */ (0,
|
|
3107
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("li", { className: "list-group-item text-danger", children: error.stack }, i)
|
|
3088
3108
|
)) })
|
|
3089
3109
|
] });
|
|
3090
3110
|
}
|
|
3091
3111
|
|
|
3092
3112
|
// src/components/templates/FallbackFieldTemplate.tsx
|
|
3093
|
-
var
|
|
3094
|
-
var
|
|
3113
|
+
var import_utils27 = require("@rjsf/utils");
|
|
3114
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3095
3115
|
function FallbackFieldTemplate(props) {
|
|
3096
3116
|
const { schema, registry, typeSelector, schemaField } = props;
|
|
3097
|
-
const MultiSchemaFieldTemplate2 = (0,
|
|
3117
|
+
const MultiSchemaFieldTemplate2 = (0, import_utils27.getTemplate)(
|
|
3098
3118
|
"MultiSchemaFieldTemplate",
|
|
3099
3119
|
registry
|
|
3100
3120
|
);
|
|
3101
|
-
return /* @__PURE__ */ (0,
|
|
3121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3102
3122
|
MultiSchemaFieldTemplate2,
|
|
3103
3123
|
{
|
|
3104
3124
|
selector: typeSelector,
|
|
@@ -3110,8 +3130,8 @@ function FallbackFieldTemplate(props) {
|
|
|
3110
3130
|
}
|
|
3111
3131
|
|
|
3112
3132
|
// src/components/templates/FieldErrorTemplate.tsx
|
|
3113
|
-
var
|
|
3114
|
-
var
|
|
3133
|
+
var import_utils28 = require("@rjsf/utils");
|
|
3134
|
+
var import_jsx_runtime29 = (
|
|
3115
3135
|
// oxlint-disable-next-line react/no-array-index-key
|
|
3116
3136
|
require("react/jsx-runtime")
|
|
3117
3137
|
);
|
|
@@ -3120,75 +3140,75 @@ function FieldErrorTemplate(props) {
|
|
|
3120
3140
|
if (errors.length === 0) {
|
|
3121
3141
|
return null;
|
|
3122
3142
|
}
|
|
3123
|
-
const id = (0,
|
|
3124
|
-
return /* @__PURE__ */ (0,
|
|
3143
|
+
const id = (0, import_utils28.errorId)(fieldPathId);
|
|
3144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("li", { className: "text-danger", children: error }, index)) }) });
|
|
3125
3145
|
}
|
|
3126
3146
|
|
|
3127
3147
|
// src/components/templates/FieldHelpTemplate.tsx
|
|
3128
|
-
var
|
|
3148
|
+
var import_utils30 = require("@rjsf/utils");
|
|
3129
3149
|
|
|
3130
3150
|
// src/components/RichHelp.tsx
|
|
3131
|
-
var
|
|
3132
|
-
var
|
|
3133
|
-
var
|
|
3134
|
-
var TEST_IDS2 = (0,
|
|
3151
|
+
var import_utils29 = require("@rjsf/utils");
|
|
3152
|
+
var import_react17 = require("markdown-to-jsx/react");
|
|
3153
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3154
|
+
var TEST_IDS2 = (0, import_utils29.getTestIds)();
|
|
3135
3155
|
function RichHelp({
|
|
3136
3156
|
help,
|
|
3137
3157
|
registry,
|
|
3138
3158
|
uiSchema = {}
|
|
3139
3159
|
}) {
|
|
3140
3160
|
const { globalUiOptions } = registry;
|
|
3141
|
-
const uiOptions = (0,
|
|
3161
|
+
const uiOptions = (0, import_utils29.getUiOptions)(uiSchema, globalUiOptions);
|
|
3142
3162
|
if (uiOptions.enableMarkdownInHelp && typeof help === "string") {
|
|
3143
|
-
return /* @__PURE__ */ (0,
|
|
3163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_react17.Markdown, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS2.markdown, children: help });
|
|
3144
3164
|
}
|
|
3145
3165
|
return help;
|
|
3146
3166
|
}
|
|
3147
3167
|
RichHelp.TEST_IDS = TEST_IDS2;
|
|
3148
3168
|
|
|
3149
3169
|
// src/components/templates/FieldHelpTemplate.tsx
|
|
3150
|
-
var
|
|
3170
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3151
3171
|
function FieldHelpTemplate(props) {
|
|
3152
3172
|
const { fieldPathId, help, uiSchema, registry } = props;
|
|
3153
3173
|
if (!help) {
|
|
3154
3174
|
return null;
|
|
3155
3175
|
}
|
|
3156
|
-
return /* @__PURE__ */ (0,
|
|
3176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { id: (0, import_utils30.helpId)(fieldPathId), className: "help-block", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(RichHelp, { help, registry, uiSchema }) });
|
|
3157
3177
|
}
|
|
3158
3178
|
|
|
3159
3179
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
3160
|
-
var
|
|
3180
|
+
var import_utils31 = require("@rjsf/utils");
|
|
3161
3181
|
|
|
3162
3182
|
// src/components/templates/FieldTemplate/Label.tsx
|
|
3163
|
-
var
|
|
3183
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3164
3184
|
var REQUIRED_FIELD_SYMBOL = "*";
|
|
3165
3185
|
function Label(props) {
|
|
3166
3186
|
const { label, required, id } = props;
|
|
3167
3187
|
if (!label) {
|
|
3168
3188
|
return null;
|
|
3169
3189
|
}
|
|
3170
|
-
return /* @__PURE__ */ (0,
|
|
3190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("label", { className: "control-label", htmlFor: id, children: [
|
|
3171
3191
|
label,
|
|
3172
|
-
required && /* @__PURE__ */ (0,
|
|
3192
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "required", children: REQUIRED_FIELD_SYMBOL })
|
|
3173
3193
|
] });
|
|
3174
3194
|
}
|
|
3175
3195
|
|
|
3176
3196
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
3177
|
-
var
|
|
3197
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3178
3198
|
function FieldTemplate(props) {
|
|
3179
3199
|
const { id, label, children, errors, help, description, hidden, required, displayLabel, registry, uiSchema } = props;
|
|
3180
|
-
const uiOptions = (0,
|
|
3181
|
-
const WrapIfAdditionalTemplate2 = (0,
|
|
3200
|
+
const uiOptions = (0, import_utils31.getUiOptions)(uiSchema);
|
|
3201
|
+
const WrapIfAdditionalTemplate2 = (0, import_utils31.getTemplate)(
|
|
3182
3202
|
"WrapIfAdditionalTemplate",
|
|
3183
3203
|
registry,
|
|
3184
3204
|
uiOptions
|
|
3185
3205
|
);
|
|
3186
3206
|
if (hidden) {
|
|
3187
|
-
return /* @__PURE__ */ (0,
|
|
3207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "hidden", children });
|
|
3188
3208
|
}
|
|
3189
3209
|
const isCheckbox = uiOptions.widget === "checkbox";
|
|
3190
|
-
return /* @__PURE__ */ (0,
|
|
3191
|
-
displayLabel && !isCheckbox && /* @__PURE__ */ (0,
|
|
3210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(WrapIfAdditionalTemplate2, { ...props, children: [
|
|
3211
|
+
displayLabel && !isCheckbox && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Label, { label, required, id }),
|
|
3192
3212
|
displayLabel && description ? description : null,
|
|
3193
3213
|
children,
|
|
3194
3214
|
errors,
|
|
@@ -3200,25 +3220,25 @@ function FieldTemplate(props) {
|
|
|
3200
3220
|
var FieldTemplate_default = FieldTemplate;
|
|
3201
3221
|
|
|
3202
3222
|
// src/components/templates/GridTemplate.tsx
|
|
3203
|
-
var
|
|
3223
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3204
3224
|
function GridTemplate(props) {
|
|
3205
3225
|
const { children, column, className, ...rest } = props;
|
|
3206
|
-
return /* @__PURE__ */ (0,
|
|
3226
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className, ...rest, children });
|
|
3207
3227
|
}
|
|
3208
3228
|
|
|
3209
3229
|
// src/components/templates/MultiSchemaFieldTemplate.tsx
|
|
3210
|
-
var
|
|
3230
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3211
3231
|
function MultiSchemaFieldTemplate(props) {
|
|
3212
3232
|
const { selector, optionSchemaField } = props;
|
|
3213
|
-
return /* @__PURE__ */ (0,
|
|
3214
|
-
/* @__PURE__ */ (0,
|
|
3233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "panel panel-default panel-body", children: [
|
|
3234
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "form-group", children: selector }),
|
|
3215
3235
|
optionSchemaField
|
|
3216
3236
|
] });
|
|
3217
3237
|
}
|
|
3218
3238
|
|
|
3219
3239
|
// src/components/templates/ObjectFieldTemplate.tsx
|
|
3220
|
-
var
|
|
3221
|
-
var
|
|
3240
|
+
var import_utils32 = require("@rjsf/utils");
|
|
3241
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3222
3242
|
function ObjectFieldTemplate(props) {
|
|
3223
3243
|
const {
|
|
3224
3244
|
className,
|
|
@@ -3236,9 +3256,9 @@ function ObjectFieldTemplate(props) {
|
|
|
3236
3256
|
title,
|
|
3237
3257
|
uiSchema
|
|
3238
3258
|
} = props;
|
|
3239
|
-
const options = (0,
|
|
3240
|
-
const TitleFieldTemplate = (0,
|
|
3241
|
-
const DescriptionFieldTemplate = (0,
|
|
3259
|
+
const options = (0, import_utils32.getUiOptions)(uiSchema);
|
|
3260
|
+
const TitleFieldTemplate = (0, import_utils32.getTemplate)("TitleFieldTemplate", registry, options);
|
|
3261
|
+
const DescriptionFieldTemplate = (0, import_utils32.getTemplate)(
|
|
3242
3262
|
"DescriptionFieldTemplate",
|
|
3243
3263
|
registry,
|
|
3244
3264
|
options
|
|
@@ -3251,11 +3271,11 @@ function ObjectFieldTemplate(props) {
|
|
|
3251
3271
|
const {
|
|
3252
3272
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
3253
3273
|
} = registry.templates;
|
|
3254
|
-
return /* @__PURE__ */ (0,
|
|
3255
|
-
title && /* @__PURE__ */ (0,
|
|
3274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("fieldset", { className, id: fieldPathId.$id, children: [
|
|
3275
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3256
3276
|
TitleFieldTemplate,
|
|
3257
3277
|
{
|
|
3258
|
-
id: (0,
|
|
3278
|
+
id: (0, import_utils32.titleId)(fieldPathId),
|
|
3259
3279
|
title,
|
|
3260
3280
|
required,
|
|
3261
3281
|
schema,
|
|
@@ -3264,10 +3284,10 @@ function ObjectFieldTemplate(props) {
|
|
|
3264
3284
|
optionalDataControl: showOptionalDataControlInTitle ? optionalDataControl : void 0
|
|
3265
3285
|
}
|
|
3266
3286
|
),
|
|
3267
|
-
description && /* @__PURE__ */ (0,
|
|
3287
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3268
3288
|
DescriptionFieldTemplate,
|
|
3269
3289
|
{
|
|
3270
|
-
id: (0,
|
|
3290
|
+
id: (0, import_utils32.descriptionId)(fieldPathId),
|
|
3271
3291
|
description,
|
|
3272
3292
|
schema,
|
|
3273
3293
|
uiSchema,
|
|
@@ -3276,10 +3296,10 @@ function ObjectFieldTemplate(props) {
|
|
|
3276
3296
|
),
|
|
3277
3297
|
!showOptionalDataControlInTitle ? optionalDataControl : void 0,
|
|
3278
3298
|
properties.map((prop) => prop.content),
|
|
3279
|
-
(0,
|
|
3299
|
+
(0, import_utils32.canExpand)(schema, uiSchema, formData) && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3280
3300
|
AddButton2,
|
|
3281
3301
|
{
|
|
3282
|
-
id: (0,
|
|
3302
|
+
id: (0, import_utils32.buttonId)(fieldPathId, "add"),
|
|
3283
3303
|
className: "rjsf-object-property-expand",
|
|
3284
3304
|
onClick: onAddProperty,
|
|
3285
3305
|
disabled: disabled || readonly,
|
|
@@ -3291,11 +3311,11 @@ function ObjectFieldTemplate(props) {
|
|
|
3291
3311
|
}
|
|
3292
3312
|
|
|
3293
3313
|
// src/components/templates/OptionalDataControlsTemplate.tsx
|
|
3294
|
-
var
|
|
3314
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3295
3315
|
function OptionalDataControlsTemplate(props) {
|
|
3296
3316
|
const { id, registry, label, onAddClick, onRemoveClick } = props;
|
|
3297
3317
|
if (onAddClick) {
|
|
3298
|
-
return /* @__PURE__ */ (0,
|
|
3318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3299
3319
|
IconButton_default,
|
|
3300
3320
|
{
|
|
3301
3321
|
id,
|
|
@@ -3308,7 +3328,7 @@ function OptionalDataControlsTemplate(props) {
|
|
|
3308
3328
|
);
|
|
3309
3329
|
}
|
|
3310
3330
|
if (onRemoveClick) {
|
|
3311
|
-
return /* @__PURE__ */ (0,
|
|
3331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3312
3332
|
IconButton_default,
|
|
3313
3333
|
{
|
|
3314
3334
|
id,
|
|
@@ -3320,48 +3340,48 @@ function OptionalDataControlsTemplate(props) {
|
|
|
3320
3340
|
}
|
|
3321
3341
|
);
|
|
3322
3342
|
}
|
|
3323
|
-
return /* @__PURE__ */ (0,
|
|
3343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("em", { id, children: label });
|
|
3324
3344
|
}
|
|
3325
3345
|
|
|
3326
3346
|
// src/components/templates/TitleField.tsx
|
|
3327
|
-
var
|
|
3347
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3328
3348
|
var REQUIRED_FIELD_SYMBOL2 = "*";
|
|
3329
3349
|
function TitleField(props) {
|
|
3330
3350
|
const { id, title, required, optionalDataControl } = props;
|
|
3331
|
-
return /* @__PURE__ */ (0,
|
|
3351
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("legend", { id, children: [
|
|
3332
3352
|
title,
|
|
3333
|
-
required && /* @__PURE__ */ (0,
|
|
3334
|
-
optionalDataControl && /* @__PURE__ */ (0,
|
|
3353
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "required", children: REQUIRED_FIELD_SYMBOL2 }),
|
|
3354
|
+
optionalDataControl && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "pull-right", style: { marginBottom: "2px" }, children: optionalDataControl })
|
|
3335
3355
|
] });
|
|
3336
3356
|
}
|
|
3337
3357
|
|
|
3338
3358
|
// src/components/templates/UnsupportedField.tsx
|
|
3339
|
-
var
|
|
3340
|
-
var
|
|
3341
|
-
var
|
|
3359
|
+
var import_utils33 = require("@rjsf/utils");
|
|
3360
|
+
var import_react18 = require("markdown-to-jsx/react");
|
|
3361
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3342
3362
|
function UnsupportedField(props) {
|
|
3343
3363
|
const { schema, fieldPathId, reason, registry } = props;
|
|
3344
3364
|
const { translateString } = registry;
|
|
3345
|
-
let translateEnum =
|
|
3365
|
+
let translateEnum = import_utils33.TranslatableString.UnsupportedField;
|
|
3346
3366
|
const translateParams = [];
|
|
3347
|
-
if (fieldPathId
|
|
3348
|
-
translateEnum =
|
|
3367
|
+
if (fieldPathId?.$id) {
|
|
3368
|
+
translateEnum = import_utils33.TranslatableString.UnsupportedFieldWithId;
|
|
3349
3369
|
translateParams.push(fieldPathId.$id);
|
|
3350
3370
|
}
|
|
3351
3371
|
if (reason) {
|
|
3352
|
-
translateEnum = translateEnum ===
|
|
3372
|
+
translateEnum = translateEnum === import_utils33.TranslatableString.UnsupportedField ? import_utils33.TranslatableString.UnsupportedFieldWithReason : import_utils33.TranslatableString.UnsupportedFieldWithIdAndReason;
|
|
3353
3373
|
translateParams.push(reason);
|
|
3354
3374
|
}
|
|
3355
|
-
return /* @__PURE__ */ (0,
|
|
3356
|
-
/* @__PURE__ */ (0,
|
|
3357
|
-
schema && /* @__PURE__ */ (0,
|
|
3375
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "unsupported-field", children: [
|
|
3376
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react18.Markdown, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3377
|
+
schema && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("pre", { children: JSON.stringify(schema, null, 2) })
|
|
3358
3378
|
] });
|
|
3359
3379
|
}
|
|
3360
3380
|
var UnsupportedField_default = UnsupportedField;
|
|
3361
3381
|
|
|
3362
3382
|
// src/components/templates/WrapIfAdditionalTemplate.tsx
|
|
3363
|
-
var
|
|
3364
|
-
var
|
|
3383
|
+
var import_utils34 = require("@rjsf/utils");
|
|
3384
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
3365
3385
|
function WrapIfAdditionalTemplate(props) {
|
|
3366
3386
|
const {
|
|
3367
3387
|
id,
|
|
@@ -3384,8 +3404,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3384
3404
|
} = props;
|
|
3385
3405
|
const { templates: templates2, translateString } = registry;
|
|
3386
3406
|
const { RemoveButton: RemoveButton2 } = templates2.ButtonTemplates;
|
|
3387
|
-
const keyLabel = translateString(
|
|
3388
|
-
const additional =
|
|
3407
|
+
const keyLabel = translateString(import_utils34.TranslatableString.KeyLabel, [label]);
|
|
3408
|
+
const additional = import_utils34.ADDITIONAL_PROPERTY_FLAG in schema;
|
|
3389
3409
|
const hasDescription = !!rawDescription;
|
|
3390
3410
|
const classNamesList = ["form-group", classNames];
|
|
3391
3411
|
if (!hideError && rawErrors && rawErrors.length > 0) {
|
|
@@ -3393,14 +3413,14 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3393
3413
|
}
|
|
3394
3414
|
const uiClassNames = classNamesList.join(" ").trim();
|
|
3395
3415
|
if (!additional) {
|
|
3396
|
-
return /* @__PURE__ */ (0,
|
|
3416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: uiClassNames, style, children });
|
|
3397
3417
|
}
|
|
3398
3418
|
const margin = hasDescription ? 46 : 26;
|
|
3399
|
-
return /* @__PURE__ */ (0,
|
|
3400
|
-
/* @__PURE__ */ (0,
|
|
3401
|
-
displayLabel && /* @__PURE__ */ (0,
|
|
3402
|
-
displayLabel && rawDescription && /* @__PURE__ */ (0,
|
|
3403
|
-
/* @__PURE__ */ (0,
|
|
3419
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: uiClassNames, style, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "row", children: [
|
|
3420
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "form-group", children: [
|
|
3421
|
+
displayLabel && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Label, { label: keyLabel, required, id: `${id}-key` }),
|
|
3422
|
+
displayLabel && rawDescription && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { children: "\xA0" }),
|
|
3423
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3404
3424
|
"input",
|
|
3405
3425
|
{
|
|
3406
3426
|
className: "form-control",
|
|
@@ -3412,11 +3432,11 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
3412
3432
|
label
|
|
3413
3433
|
)
|
|
3414
3434
|
] }) }),
|
|
3415
|
-
/* @__PURE__ */ (0,
|
|
3416
|
-
/* @__PURE__ */ (0,
|
|
3435
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "form-additional form-group col-xs-5", children }),
|
|
3436
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "col-xs-2", style: { marginTop: displayLabel ? `${margin}px` : void 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
3417
3437
|
RemoveButton2,
|
|
3418
3438
|
{
|
|
3419
|
-
id: (0,
|
|
3439
|
+
id: (0, import_utils34.buttonId)(id, "remove"),
|
|
3420
3440
|
className: "rjsf-object-property-remove btn-block",
|
|
3421
3441
|
style: { border: "0" },
|
|
3422
3442
|
disabled: disabled || readonly,
|
|
@@ -3438,6 +3458,7 @@ function templates() {
|
|
|
3438
3458
|
ArrayFieldTitleTemplate,
|
|
3439
3459
|
ButtonTemplates: ButtonTemplates_default(),
|
|
3440
3460
|
BaseInputTemplate,
|
|
3461
|
+
CyclicSchemaExpandTemplate,
|
|
3441
3462
|
DescriptionFieldTemplate: DescriptionField,
|
|
3442
3463
|
ErrorListTemplate: ErrorList,
|
|
3443
3464
|
FallbackFieldTemplate,
|
|
@@ -3456,28 +3477,28 @@ function templates() {
|
|
|
3456
3477
|
var templates_default = templates;
|
|
3457
3478
|
|
|
3458
3479
|
// src/components/widgets/AltDateTimeWidget.tsx
|
|
3459
|
-
var
|
|
3480
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
3460
3481
|
function AltDateTimeWidget({
|
|
3461
3482
|
time = true,
|
|
3462
3483
|
...props
|
|
3463
3484
|
}) {
|
|
3464
3485
|
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
3465
|
-
return /* @__PURE__ */ (0,
|
|
3486
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(AltDateWidget2, { time, ...props });
|
|
3466
3487
|
}
|
|
3467
3488
|
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
3468
3489
|
|
|
3469
3490
|
// src/components/widgets/AltDateWidget.tsx
|
|
3470
|
-
var
|
|
3471
|
-
var
|
|
3491
|
+
var import_utils35 = require("@rjsf/utils");
|
|
3492
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
3472
3493
|
function AltDateWidget(props) {
|
|
3473
3494
|
const { disabled = false, readonly = false, autofocus = false, options, id, name, registry, onBlur, onFocus } = props;
|
|
3474
3495
|
const { translateString } = registry;
|
|
3475
|
-
const { elements, handleChange, handleClear, handleSetNow } = (0,
|
|
3476
|
-
return /* @__PURE__ */ (0,
|
|
3496
|
+
const { elements, handleChange, handleClear, handleSetNow } = (0, import_utils35.useAltDateWidgetProps)(props);
|
|
3497
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("ul", { className: "list-inline", children: [
|
|
3477
3498
|
elements.map((elemProps, i) => (
|
|
3478
3499
|
// oxlint-disable-next-line react/no-array-index-key
|
|
3479
|
-
/* @__PURE__ */ (0,
|
|
3480
|
-
|
|
3500
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
3501
|
+
import_utils35.DateElement,
|
|
3481
3502
|
{
|
|
3482
3503
|
rootId: id,
|
|
3483
3504
|
name,
|
|
@@ -3492,16 +3513,16 @@ function AltDateWidget(props) {
|
|
|
3492
3513
|
}
|
|
3493
3514
|
) }, i)
|
|
3494
3515
|
)),
|
|
3495
|
-
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ (0,
|
|
3496
|
-
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ (0,
|
|
3516
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(import_utils35.TranslatableString.NowLabel) }) }),
|
|
3517
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(import_utils35.TranslatableString.ClearLabel) }) })
|
|
3497
3518
|
] });
|
|
3498
3519
|
}
|
|
3499
3520
|
var AltDateWidget_default = AltDateWidget;
|
|
3500
3521
|
|
|
3501
3522
|
// src/components/widgets/CheckboxesWidget.tsx
|
|
3502
|
-
var
|
|
3503
|
-
var
|
|
3504
|
-
var
|
|
3523
|
+
var import_react19 = require("react");
|
|
3524
|
+
var import_utils36 = require("@rjsf/utils");
|
|
3525
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
3505
3526
|
function CheckboxesWidget({
|
|
3506
3527
|
id,
|
|
3507
3528
|
disabled,
|
|
@@ -3515,55 +3536,55 @@ function CheckboxesWidget({
|
|
|
3515
3536
|
htmlName
|
|
3516
3537
|
}) {
|
|
3517
3538
|
const { inline = false, enumOptions, enumDisabled, emptyValue } = options;
|
|
3518
|
-
const optionValueFormat = (0,
|
|
3539
|
+
const optionValueFormat = (0, import_utils36.getOptionValueFormat)(options);
|
|
3519
3540
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
3520
|
-
const handleBlur = (0,
|
|
3521
|
-
({ target }) => onBlur(id, (0,
|
|
3541
|
+
const handleBlur = (0, import_react19.useCallback)(
|
|
3542
|
+
({ target }) => onBlur(id, (0, import_utils36.enumOptionValueDecoder)(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3522
3543
|
[onBlur, id, enumOptions, emptyValue, optionValueFormat]
|
|
3523
3544
|
);
|
|
3524
|
-
const handleFocus = (0,
|
|
3525
|
-
({ target }) => onFocus(id, (0,
|
|
3545
|
+
const handleFocus = (0, import_react19.useCallback)(
|
|
3546
|
+
({ target }) => onFocus(id, (0, import_utils36.enumOptionValueDecoder)(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3526
3547
|
[onFocus, id, enumOptions, emptyValue, optionValueFormat]
|
|
3527
3548
|
);
|
|
3528
|
-
return /* @__PURE__ */ (0,
|
|
3529
|
-
const checked = (0,
|
|
3549
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3550
|
+
const checked = (0, import_utils36.enumOptionsIsSelected)(option.value, checkboxesValues);
|
|
3530
3551
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3531
3552
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3532
3553
|
const handleChange = (event) => {
|
|
3533
3554
|
if (event.target.checked) {
|
|
3534
|
-
onChange((0,
|
|
3555
|
+
onChange((0, import_utils36.enumOptionsSelectValue)(index, checkboxesValues, enumOptions));
|
|
3535
3556
|
} else {
|
|
3536
|
-
onChange((0,
|
|
3557
|
+
onChange((0, import_utils36.enumOptionsDeselectValue)(index, checkboxesValues, enumOptions));
|
|
3537
3558
|
}
|
|
3538
3559
|
};
|
|
3539
|
-
const checkbox = /* @__PURE__ */ (0,
|
|
3540
|
-
/* @__PURE__ */ (0,
|
|
3560
|
+
const checkbox = /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { children: [
|
|
3561
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
3541
3562
|
"input",
|
|
3542
3563
|
{
|
|
3543
3564
|
type: "checkbox",
|
|
3544
|
-
id: (0,
|
|
3565
|
+
id: (0, import_utils36.optionId)(id, index),
|
|
3545
3566
|
name: htmlName || id,
|
|
3546
3567
|
checked,
|
|
3547
|
-
value: (0,
|
|
3568
|
+
value: (0, import_utils36.enumOptionValueEncoder)(option.value, index, optionValueFormat),
|
|
3548
3569
|
disabled: disabled || itemDisabled || readonly,
|
|
3549
3570
|
autoFocus: autofocus && index === 0,
|
|
3550
3571
|
onChange: handleChange,
|
|
3551
3572
|
onBlur: handleBlur,
|
|
3552
3573
|
onFocus: handleFocus,
|
|
3553
|
-
"aria-describedby": (0,
|
|
3574
|
+
"aria-describedby": (0, import_utils36.ariaDescribedByIds)(id)
|
|
3554
3575
|
}
|
|
3555
3576
|
),
|
|
3556
|
-
/* @__PURE__ */ (0,
|
|
3577
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { children: option.label })
|
|
3557
3578
|
] });
|
|
3558
|
-
return inline ? /* @__PURE__ */ (0,
|
|
3579
|
+
return inline ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, String(option.value)) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("label", { children: checkbox }) }, String(option.value));
|
|
3559
3580
|
}) });
|
|
3560
3581
|
}
|
|
3561
3582
|
var CheckboxesWidget_default = CheckboxesWidget;
|
|
3562
3583
|
|
|
3563
3584
|
// src/components/widgets/CheckboxWidget.tsx
|
|
3564
|
-
var
|
|
3565
|
-
var
|
|
3566
|
-
var
|
|
3585
|
+
var import_react20 = require("react");
|
|
3586
|
+
var import_utils37 = require("@rjsf/utils");
|
|
3587
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
3567
3588
|
function CheckboxWidget({
|
|
3568
3589
|
schema,
|
|
3569
3590
|
uiSchema,
|
|
@@ -3581,40 +3602,40 @@ function CheckboxWidget({
|
|
|
3581
3602
|
registry,
|
|
3582
3603
|
htmlName
|
|
3583
3604
|
}) {
|
|
3584
|
-
const DescriptionFieldTemplate = (0,
|
|
3605
|
+
const DescriptionFieldTemplate = (0, import_utils37.getTemplate)(
|
|
3585
3606
|
"DescriptionFieldTemplate",
|
|
3586
3607
|
registry,
|
|
3587
3608
|
options
|
|
3588
3609
|
);
|
|
3589
|
-
const required = (0,
|
|
3590
|
-
const handleChange = (0,
|
|
3610
|
+
const required = (0, import_utils37.schemaRequiresTrueValue)(schema);
|
|
3611
|
+
const handleChange = (0, import_react20.useCallback)(
|
|
3591
3612
|
(event) => onChange(event.target.checked),
|
|
3592
3613
|
[onChange]
|
|
3593
3614
|
);
|
|
3594
|
-
const handleBlur = (0,
|
|
3615
|
+
const handleBlur = (0, import_react20.useCallback)(
|
|
3595
3616
|
(event) => onBlur(id, event.target.checked),
|
|
3596
3617
|
[onBlur, id]
|
|
3597
3618
|
);
|
|
3598
|
-
const handleFocus = (0,
|
|
3619
|
+
const handleFocus = (0, import_react20.useCallback)(
|
|
3599
3620
|
(event) => onFocus(id, event.target.checked),
|
|
3600
3621
|
[onFocus, id]
|
|
3601
3622
|
);
|
|
3602
|
-
const uiOptions = (0,
|
|
3623
|
+
const uiOptions = (0, import_utils37.getUiOptions)(uiSchema);
|
|
3603
3624
|
const isCheckboxWidget = uiOptions.widget === "checkbox";
|
|
3604
3625
|
const description = isCheckboxWidget ? void 0 : options.description ?? schema.description;
|
|
3605
|
-
return /* @__PURE__ */ (0,
|
|
3606
|
-
!hideLabel && description && /* @__PURE__ */ (0,
|
|
3626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
|
|
3627
|
+
!hideLabel && description && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3607
3628
|
DescriptionFieldTemplate,
|
|
3608
3629
|
{
|
|
3609
|
-
id: (0,
|
|
3630
|
+
id: (0, import_utils37.descriptionId)(id),
|
|
3610
3631
|
description,
|
|
3611
3632
|
schema,
|
|
3612
3633
|
uiSchema,
|
|
3613
3634
|
registry
|
|
3614
3635
|
}
|
|
3615
3636
|
),
|
|
3616
|
-
/* @__PURE__ */ (0,
|
|
3617
|
-
/* @__PURE__ */ (0,
|
|
3637
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("label", { children: [
|
|
3638
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3618
3639
|
"input",
|
|
3619
3640
|
{
|
|
3620
3641
|
type: "checkbox",
|
|
@@ -3627,65 +3648,65 @@ function CheckboxWidget({
|
|
|
3627
3648
|
onChange: handleChange,
|
|
3628
3649
|
onBlur: handleBlur,
|
|
3629
3650
|
onFocus: handleFocus,
|
|
3630
|
-
"aria-describedby": (0,
|
|
3651
|
+
"aria-describedby": (0, import_utils37.ariaDescribedByIds)(id)
|
|
3631
3652
|
}
|
|
3632
3653
|
),
|
|
3633
|
-
(0,
|
|
3654
|
+
(0, import_utils37.labelValue)(/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: label }), hideLabel)
|
|
3634
3655
|
] })
|
|
3635
3656
|
] });
|
|
3636
3657
|
}
|
|
3637
3658
|
var CheckboxWidget_default = CheckboxWidget;
|
|
3638
3659
|
|
|
3639
3660
|
// src/components/widgets/ColorWidget.tsx
|
|
3640
|
-
var
|
|
3641
|
-
var
|
|
3661
|
+
var import_utils38 = require("@rjsf/utils");
|
|
3662
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
3642
3663
|
function ColorWidget(props) {
|
|
3643
3664
|
const { disabled, readonly, options, registry } = props;
|
|
3644
|
-
const BaseInputTemplate2 = (0,
|
|
3645
|
-
return /* @__PURE__ */ (0,
|
|
3665
|
+
const BaseInputTemplate2 = (0, import_utils38.getTemplate)("BaseInputTemplate", registry, options);
|
|
3666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
|
|
3646
3667
|
}
|
|
3647
3668
|
|
|
3648
3669
|
// src/components/widgets/DateTimeWidget.tsx
|
|
3649
|
-
var
|
|
3650
|
-
var
|
|
3670
|
+
var import_utils39 = require("@rjsf/utils");
|
|
3671
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
3651
3672
|
function DateTimeWidget(props) {
|
|
3652
3673
|
const { onChange, value, options, registry } = props;
|
|
3653
|
-
const BaseInputTemplate2 = (0,
|
|
3654
|
-
return /* @__PURE__ */ (0,
|
|
3674
|
+
const BaseInputTemplate2 = (0, import_utils39.getTemplate)("BaseInputTemplate", registry, options);
|
|
3675
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
3655
3676
|
BaseInputTemplate2,
|
|
3656
3677
|
{
|
|
3657
3678
|
type: "datetime-local",
|
|
3658
3679
|
...props,
|
|
3659
|
-
value: (0,
|
|
3660
|
-
onChange: (newValue) => onChange((0,
|
|
3680
|
+
value: (0, import_utils39.utcToLocal)(value),
|
|
3681
|
+
onChange: (newValue) => onChange((0, import_utils39.localToUTC)(newValue))
|
|
3661
3682
|
}
|
|
3662
3683
|
);
|
|
3663
3684
|
}
|
|
3664
3685
|
|
|
3665
3686
|
// src/components/widgets/DateWidget.tsx
|
|
3666
|
-
var
|
|
3667
|
-
var
|
|
3668
|
-
var
|
|
3687
|
+
var import_react21 = require("react");
|
|
3688
|
+
var import_utils40 = require("@rjsf/utils");
|
|
3689
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
3669
3690
|
function DateWidget(props) {
|
|
3670
3691
|
const { onChange, options, registry } = props;
|
|
3671
|
-
const BaseInputTemplate2 = (0,
|
|
3672
|
-
const handleChange = (0,
|
|
3673
|
-
return /* @__PURE__ */ (0,
|
|
3692
|
+
const BaseInputTemplate2 = (0, import_utils40.getTemplate)("BaseInputTemplate", registry, options);
|
|
3693
|
+
const handleChange = (0, import_react21.useCallback)((value) => onChange(value || void 0), [onChange]);
|
|
3694
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
3674
3695
|
}
|
|
3675
3696
|
|
|
3676
3697
|
// src/components/widgets/EmailWidget.tsx
|
|
3677
|
-
var
|
|
3678
|
-
var
|
|
3698
|
+
var import_utils41 = require("@rjsf/utils");
|
|
3699
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
3679
3700
|
function EmailWidget(props) {
|
|
3680
3701
|
const { options, registry } = props;
|
|
3681
|
-
const BaseInputTemplate2 = (0,
|
|
3682
|
-
return /* @__PURE__ */ (0,
|
|
3702
|
+
const BaseInputTemplate2 = (0, import_utils41.getTemplate)("BaseInputTemplate", registry, options);
|
|
3703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(BaseInputTemplate2, { type: "email", ...props });
|
|
3683
3704
|
}
|
|
3684
3705
|
|
|
3685
3706
|
// src/components/widgets/FileWidget.tsx
|
|
3686
|
-
var
|
|
3687
|
-
var
|
|
3688
|
-
var
|
|
3707
|
+
var import_utils42 = require("@rjsf/utils");
|
|
3708
|
+
var import_react22 = require("markdown-to-jsx/react");
|
|
3709
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
3689
3710
|
function FileInfoPreview({
|
|
3690
3711
|
fileInfo,
|
|
3691
3712
|
registry
|
|
@@ -3695,13 +3716,13 @@ function FileInfoPreview({
|
|
|
3695
3716
|
if (!dataURL) {
|
|
3696
3717
|
return null;
|
|
3697
3718
|
}
|
|
3698
|
-
const previewLabel = translateString(
|
|
3719
|
+
const previewLabel = translateString(import_utils42.TranslatableString.PreviewLabel);
|
|
3699
3720
|
if (["image/jpeg", "image/png"].includes(type)) {
|
|
3700
|
-
return /* @__PURE__ */ (0,
|
|
3721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("img", { src: dataURL, alt: previewLabel, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
3701
3722
|
}
|
|
3702
|
-
return /* @__PURE__ */ (0,
|
|
3723
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
|
|
3703
3724
|
" ",
|
|
3704
|
-
/* @__PURE__ */ (0,
|
|
3725
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: previewLabel })
|
|
3705
3726
|
] });
|
|
3706
3727
|
}
|
|
3707
3728
|
function FilesInfo({
|
|
@@ -3715,31 +3736,31 @@ function FilesInfo({
|
|
|
3715
3736
|
return null;
|
|
3716
3737
|
}
|
|
3717
3738
|
const { translateString } = registry;
|
|
3718
|
-
const { RemoveButton: RemoveButton2 } = (0,
|
|
3719
|
-
return /* @__PURE__ */ (0,
|
|
3739
|
+
const { RemoveButton: RemoveButton2 } = (0, import_utils42.getTemplate)("ButtonTemplates", registry, options);
|
|
3740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
|
|
3720
3741
|
const { name, size, type } = fileInfo;
|
|
3721
3742
|
const handleRemove = () => onRemove(key);
|
|
3722
3743
|
return (
|
|
3723
3744
|
// oxlint-disable-next-line react/no-array-index-key
|
|
3724
|
-
/* @__PURE__ */ (0,
|
|
3725
|
-
/* @__PURE__ */ (0,
|
|
3726
|
-
preview && /* @__PURE__ */ (0,
|
|
3727
|
-
/* @__PURE__ */ (0,
|
|
3745
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("li", { children: [
|
|
3746
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_react22.Markdown, { children: translateString(import_utils42.TranslatableString.FilesInfo, [name, type, String(size)]) }),
|
|
3747
|
+
preview && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(FileInfoPreview, { fileInfo, registry }),
|
|
3748
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(RemoveButton2, { onClick: handleRemove, registry })
|
|
3728
3749
|
] }, key)
|
|
3729
3750
|
);
|
|
3730
3751
|
}) });
|
|
3731
3752
|
}
|
|
3732
3753
|
function FileWidget(props) {
|
|
3733
3754
|
const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
|
|
3734
|
-
const { filesInfo, handleChange, handleRemove } = (0,
|
|
3735
|
-
const BaseInputTemplate2 = (0,
|
|
3755
|
+
const { filesInfo, handleChange, handleRemove } = (0, import_utils42.useFileWidgetProps)(value, onChange, multiple);
|
|
3756
|
+
const BaseInputTemplate2 = (0, import_utils42.getTemplate)("BaseInputTemplate", registry, options);
|
|
3736
3757
|
const handleOnChangeEvent = (event) => {
|
|
3737
3758
|
if (event.target.files) {
|
|
3738
3759
|
void handleChange(event.target.files);
|
|
3739
3760
|
}
|
|
3740
3761
|
};
|
|
3741
|
-
return /* @__PURE__ */ (0,
|
|
3742
|
-
/* @__PURE__ */ (0,
|
|
3762
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { children: [
|
|
3763
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3743
3764
|
BaseInputTemplate2,
|
|
3744
3765
|
{
|
|
3745
3766
|
...props,
|
|
@@ -3751,7 +3772,7 @@ function FileWidget(props) {
|
|
|
3751
3772
|
accept: options.accept ? String(options.accept) : void 0
|
|
3752
3773
|
}
|
|
3753
3774
|
),
|
|
3754
|
-
/* @__PURE__ */ (0,
|
|
3775
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
3755
3776
|
FilesInfo,
|
|
3756
3777
|
{
|
|
3757
3778
|
filesInfo,
|
|
@@ -3766,29 +3787,29 @@ function FileWidget(props) {
|
|
|
3766
3787
|
var FileWidget_default = FileWidget;
|
|
3767
3788
|
|
|
3768
3789
|
// src/components/widgets/HiddenWidget.tsx
|
|
3769
|
-
var
|
|
3790
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
3770
3791
|
function HiddenWidget({
|
|
3771
3792
|
id,
|
|
3772
3793
|
value,
|
|
3773
3794
|
htmlName
|
|
3774
3795
|
}) {
|
|
3775
|
-
return /* @__PURE__ */ (0,
|
|
3796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("input", { type: "hidden", id, name: htmlName || id, value: typeof value === "undefined" ? "" : value });
|
|
3776
3797
|
}
|
|
3777
3798
|
var HiddenWidget_default = HiddenWidget;
|
|
3778
3799
|
|
|
3779
3800
|
// src/components/widgets/PasswordWidget.tsx
|
|
3780
|
-
var
|
|
3781
|
-
var
|
|
3801
|
+
var import_utils43 = require("@rjsf/utils");
|
|
3802
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
3782
3803
|
function PasswordWidget(props) {
|
|
3783
3804
|
const { options, registry } = props;
|
|
3784
|
-
const BaseInputTemplate2 = (0,
|
|
3785
|
-
return /* @__PURE__ */ (0,
|
|
3805
|
+
const BaseInputTemplate2 = (0, import_utils43.getTemplate)("BaseInputTemplate", registry, options);
|
|
3806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(BaseInputTemplate2, { type: "password", ...props });
|
|
3786
3807
|
}
|
|
3787
3808
|
|
|
3788
3809
|
// src/components/widgets/RadioWidget.tsx
|
|
3789
|
-
var
|
|
3790
|
-
var
|
|
3791
|
-
var
|
|
3810
|
+
var import_react23 = require("react");
|
|
3811
|
+
var import_utils44 = require("@rjsf/utils");
|
|
3812
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
3792
3813
|
function RadioWidget({
|
|
3793
3814
|
options,
|
|
3794
3815
|
value,
|
|
@@ -3803,47 +3824,47 @@ function RadioWidget({
|
|
|
3803
3824
|
htmlName
|
|
3804
3825
|
}) {
|
|
3805
3826
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
3806
|
-
const optionValueFormat = (0,
|
|
3807
|
-
const handleBlur = (0,
|
|
3808
|
-
({ target }) => onBlur(id, (0,
|
|
3827
|
+
const optionValueFormat = (0, import_utils44.getOptionValueFormat)(options);
|
|
3828
|
+
const handleBlur = (0, import_react23.useCallback)(
|
|
3829
|
+
({ target }) => onBlur(id, (0, import_utils44.enumOptionValueDecoder)(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3809
3830
|
[onBlur, enumOptions, emptyValue, id, optionValueFormat]
|
|
3810
3831
|
);
|
|
3811
|
-
const handleFocus = (0,
|
|
3812
|
-
({ target }) => onFocus(id, (0,
|
|
3832
|
+
const handleFocus = (0, import_react23.useCallback)(
|
|
3833
|
+
({ target }) => onFocus(id, (0, import_utils44.enumOptionValueDecoder)(target?.value, enumOptions, optionValueFormat, emptyValue)),
|
|
3813
3834
|
[onFocus, enumOptions, emptyValue, id, optionValueFormat]
|
|
3814
3835
|
);
|
|
3815
|
-
return /* @__PURE__ */ (0,
|
|
3816
|
-
const checked = (0,
|
|
3836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
3837
|
+
const checked = (0, import_utils44.enumOptionsIsSelected)(option.value, value);
|
|
3817
3838
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.includes(option.value);
|
|
3818
3839
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
3819
3840
|
const handleChange = () => onChange(option.value);
|
|
3820
|
-
const radio = /* @__PURE__ */ (0,
|
|
3821
|
-
/* @__PURE__ */ (0,
|
|
3841
|
+
const radio = /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("span", { children: [
|
|
3842
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
3822
3843
|
"input",
|
|
3823
3844
|
{
|
|
3824
3845
|
type: "radio",
|
|
3825
|
-
id: (0,
|
|
3846
|
+
id: (0, import_utils44.optionId)(id, i),
|
|
3826
3847
|
checked,
|
|
3827
3848
|
name: htmlName || id,
|
|
3828
3849
|
required,
|
|
3829
|
-
value: (0,
|
|
3850
|
+
value: (0, import_utils44.enumOptionValueEncoder)(option.value, i, optionValueFormat),
|
|
3830
3851
|
disabled: disabled || itemDisabled || readonly,
|
|
3831
3852
|
autoFocus: autofocus && i === 0,
|
|
3832
3853
|
onChange: handleChange,
|
|
3833
3854
|
onBlur: handleBlur,
|
|
3834
3855
|
onFocus: handleFocus,
|
|
3835
|
-
"aria-describedby": (0,
|
|
3856
|
+
"aria-describedby": (0, import_utils44.ariaDescribedByIds)(id)
|
|
3836
3857
|
}
|
|
3837
3858
|
),
|
|
3838
|
-
/* @__PURE__ */ (0,
|
|
3859
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("span", { children: option.label })
|
|
3839
3860
|
] });
|
|
3840
|
-
return inline ? /* @__PURE__ */ (0,
|
|
3861
|
+
return inline ? /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("label", { className: `radio-inline ${disabledCls}`, children: radio }, String(option.value)) : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("label", { children: radio }) }, String(option.value));
|
|
3841
3862
|
}) });
|
|
3842
3863
|
}
|
|
3843
3864
|
var RadioWidget_default = RadioWidget;
|
|
3844
3865
|
|
|
3845
3866
|
// src/components/widgets/RangeWidget.tsx
|
|
3846
|
-
var
|
|
3867
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
3847
3868
|
function RangeWidget(props) {
|
|
3848
3869
|
const {
|
|
3849
3870
|
value,
|
|
@@ -3851,15 +3872,15 @@ function RangeWidget(props) {
|
|
|
3851
3872
|
templates: { BaseInputTemplate: BaseInputTemplate2 }
|
|
3852
3873
|
}
|
|
3853
3874
|
} = props;
|
|
3854
|
-
return /* @__PURE__ */ (0,
|
|
3855
|
-
/* @__PURE__ */ (0,
|
|
3856
|
-
/* @__PURE__ */ (0,
|
|
3875
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "field-range-wrapper", children: [
|
|
3876
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(BaseInputTemplate2, { type: "range", ...props }),
|
|
3877
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "range-view", children: value })
|
|
3857
3878
|
] });
|
|
3858
3879
|
}
|
|
3859
3880
|
|
|
3860
3881
|
// src/components/widgets/RatingWidget.tsx
|
|
3861
|
-
var
|
|
3862
|
-
var
|
|
3882
|
+
var import_react24 = require("react");
|
|
3883
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
3863
3884
|
function RatingWidget({
|
|
3864
3885
|
id,
|
|
3865
3886
|
value,
|
|
@@ -3877,7 +3898,7 @@ function RatingWidget({
|
|
|
3877
3898
|
const { stars = 5, shape = "star" } = options;
|
|
3878
3899
|
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
3879
3900
|
const min = schema.minimum || 0;
|
|
3880
|
-
const handleStarClick = (0,
|
|
3901
|
+
const handleStarClick = (0, import_react24.useCallback)(
|
|
3881
3902
|
(starValue) => {
|
|
3882
3903
|
if (!disabled && !readonly) {
|
|
3883
3904
|
onChange(starValue);
|
|
@@ -3885,7 +3906,7 @@ function RatingWidget({
|
|
|
3885
3906
|
},
|
|
3886
3907
|
[onChange, disabled, readonly]
|
|
3887
3908
|
);
|
|
3888
|
-
const handleFocus = (0,
|
|
3909
|
+
const handleFocus = (0, import_react24.useCallback)(
|
|
3889
3910
|
(event) => {
|
|
3890
3911
|
if (onFocus) {
|
|
3891
3912
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3894,7 +3915,7 @@ function RatingWidget({
|
|
|
3894
3915
|
},
|
|
3895
3916
|
[onFocus, id]
|
|
3896
3917
|
);
|
|
3897
|
-
const handleBlur = (0,
|
|
3918
|
+
const handleBlur = (0, import_react24.useCallback)(
|
|
3898
3919
|
(event) => {
|
|
3899
3920
|
if (onBlur) {
|
|
3900
3921
|
const starValue = Number(event.target.dataset.value);
|
|
@@ -3909,7 +3930,7 @@ function RatingWidget({
|
|
|
3909
3930
|
}
|
|
3910
3931
|
return isFilled ? "\u2605" : "\u2606";
|
|
3911
3932
|
};
|
|
3912
|
-
return /* @__PURE__ */ (0,
|
|
3933
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
|
|
3913
3934
|
"div",
|
|
3914
3935
|
{
|
|
3915
3936
|
className: "rating-widget",
|
|
@@ -3922,7 +3943,7 @@ function RatingWidget({
|
|
|
3922
3943
|
[...Array(numStars)].map((_, index) => {
|
|
3923
3944
|
const starValue = min + index;
|
|
3924
3945
|
const isFilled = starValue <= value;
|
|
3925
|
-
return /* @__PURE__ */ (0,
|
|
3946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
3926
3947
|
"span",
|
|
3927
3948
|
{
|
|
3928
3949
|
onClick: () => handleStarClick(starValue),
|
|
@@ -3945,7 +3966,7 @@ function RatingWidget({
|
|
|
3945
3966
|
index
|
|
3946
3967
|
);
|
|
3947
3968
|
}),
|
|
3948
|
-
/* @__PURE__ */ (0,
|
|
3969
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
3949
3970
|
"input",
|
|
3950
3971
|
{
|
|
3951
3972
|
type: "hidden",
|
|
@@ -3963,12 +3984,9 @@ function RatingWidget({
|
|
|
3963
3984
|
}
|
|
3964
3985
|
|
|
3965
3986
|
// src/components/widgets/SelectWidget.tsx
|
|
3966
|
-
var
|
|
3967
|
-
var
|
|
3968
|
-
var
|
|
3969
|
-
// oxlint-disable-next-line jsx-a11y/no-autofocus
|
|
3970
|
-
require("react/jsx-runtime")
|
|
3971
|
-
);
|
|
3987
|
+
var import_react25 = require("react");
|
|
3988
|
+
var import_utils45 = require("@rjsf/utils");
|
|
3989
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
3972
3990
|
function getValue(event, multiple) {
|
|
3973
3991
|
if (multiple) {
|
|
3974
3992
|
return Array.from(event.target.options).slice().filter((o) => o.selected).map((o) => o.value);
|
|
@@ -3989,76 +4007,92 @@ function SelectWidget({
|
|
|
3989
4007
|
onBlur,
|
|
3990
4008
|
onFocus,
|
|
3991
4009
|
placeholder,
|
|
3992
|
-
htmlName
|
|
4010
|
+
htmlName,
|
|
4011
|
+
registry,
|
|
4012
|
+
uiSchema
|
|
3993
4013
|
}) {
|
|
3994
4014
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
3995
4015
|
const emptyValue = multiple ? [] : "";
|
|
3996
|
-
const optionValueFormat = (0,
|
|
3997
|
-
const handleFocus = (0,
|
|
4016
|
+
const optionValueFormat = (0, import_utils45.getOptionValueFormat)(options);
|
|
4017
|
+
const handleFocus = (0, import_react25.useCallback)(
|
|
3998
4018
|
(event) => {
|
|
3999
4019
|
const newValue = getValue(event, multiple);
|
|
4000
|
-
return onFocus(id, (0,
|
|
4020
|
+
return onFocus(id, (0, import_utils45.enumOptionValueDecoder)(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
4001
4021
|
},
|
|
4002
4022
|
[onFocus, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
4003
4023
|
);
|
|
4004
|
-
const handleBlur = (0,
|
|
4024
|
+
const handleBlur = (0, import_react25.useCallback)(
|
|
4005
4025
|
(event) => {
|
|
4006
4026
|
const newValue = getValue(event, multiple);
|
|
4007
|
-
return onBlur(id, (0,
|
|
4027
|
+
return onBlur(id, (0, import_utils45.enumOptionValueDecoder)(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
4008
4028
|
},
|
|
4009
4029
|
[onBlur, id, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
4010
4030
|
);
|
|
4011
|
-
const handleChange = (0,
|
|
4031
|
+
const handleChange = (0, import_react25.useCallback)(
|
|
4012
4032
|
(event) => {
|
|
4013
4033
|
const newValue = getValue(event, multiple);
|
|
4014
|
-
return onChange((0,
|
|
4034
|
+
return onChange((0, import_utils45.enumOptionValueDecoder)(newValue, enumOptions, optionValueFormat, optEmptyVal));
|
|
4015
4035
|
},
|
|
4016
4036
|
[onChange, multiple, enumOptions, optEmptyVal, optionValueFormat]
|
|
4017
4037
|
);
|
|
4018
|
-
const selectValue = (0,
|
|
4038
|
+
const selectValue = (0, import_utils45.enumOptionSelectedValue)(value, enumOptions, multiple, optionValueFormat, emptyValue);
|
|
4019
4039
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
"
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4040
|
+
(0, import_utils45.logUnsupportedDefaultForEnum)(id, schema, enumOptions, multiple);
|
|
4041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
|
|
4042
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
4043
|
+
import_utils45.SelectedOptionDescription,
|
|
4044
|
+
{
|
|
4045
|
+
id,
|
|
4046
|
+
multiple,
|
|
4047
|
+
options,
|
|
4048
|
+
registry,
|
|
4049
|
+
uiSchema,
|
|
4050
|
+
value
|
|
4051
|
+
}
|
|
4052
|
+
),
|
|
4053
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
4054
|
+
"select",
|
|
4055
|
+
{
|
|
4056
|
+
id,
|
|
4057
|
+
name: htmlName || id,
|
|
4058
|
+
multiple,
|
|
4059
|
+
className: "form-control",
|
|
4060
|
+
value: selectValue,
|
|
4061
|
+
required,
|
|
4062
|
+
disabled: disabled || readonly,
|
|
4063
|
+
autoFocus: autofocus,
|
|
4064
|
+
onBlur: handleBlur,
|
|
4065
|
+
onFocus: handleFocus,
|
|
4066
|
+
onChange: handleChange,
|
|
4067
|
+
"aria-describedby": (0, import_utils45.ariaDescribedByIds)(id),
|
|
4068
|
+
children: [
|
|
4069
|
+
showPlaceholderOption && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("option", { value: "", children: placeholder }),
|
|
4070
|
+
Array.isArray(enumOptions) && enumOptions.map(({ value: enumValue, label: enumLabel }, i) => {
|
|
4071
|
+
const isDisabled = enumDisabled && enumDisabled.includes(enumValue);
|
|
4072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
4073
|
+
"option",
|
|
4074
|
+
{
|
|
4075
|
+
value: (0, import_utils45.enumOptionValueEncoder)(enumValue, i, optionValueFormat),
|
|
4076
|
+
disabled: isDisabled,
|
|
4077
|
+
children: enumLabel
|
|
4078
|
+
},
|
|
4079
|
+
String(enumValue)
|
|
4080
|
+
);
|
|
4081
|
+
})
|
|
4082
|
+
]
|
|
4083
|
+
}
|
|
4084
|
+
)
|
|
4085
|
+
] });
|
|
4052
4086
|
}
|
|
4053
4087
|
var SelectWidget_default = SelectWidget;
|
|
4054
4088
|
|
|
4055
4089
|
// src/components/widgets/TextareaWidget.tsx
|
|
4056
|
-
var
|
|
4057
|
-
var
|
|
4058
|
-
var
|
|
4090
|
+
var import_react26 = require("react");
|
|
4091
|
+
var import_utils46 = require("@rjsf/utils");
|
|
4092
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
4059
4093
|
function TextareaWidget({
|
|
4060
4094
|
id,
|
|
4061
|
-
options
|
|
4095
|
+
options,
|
|
4062
4096
|
placeholder,
|
|
4063
4097
|
value,
|
|
4064
4098
|
required,
|
|
@@ -4070,19 +4104,19 @@ function TextareaWidget({
|
|
|
4070
4104
|
onFocus,
|
|
4071
4105
|
htmlName
|
|
4072
4106
|
}) {
|
|
4073
|
-
const handleChange = (0,
|
|
4107
|
+
const handleChange = (0, import_react26.useCallback)(
|
|
4074
4108
|
({ target: { value: newValue } }) => onChange(newValue === "" ? options.emptyValue : newValue),
|
|
4075
4109
|
[onChange, options.emptyValue]
|
|
4076
4110
|
);
|
|
4077
|
-
const handleBlur = (0,
|
|
4078
|
-
({ target }) => onBlur(id, target
|
|
4111
|
+
const handleBlur = (0, import_react26.useCallback)(
|
|
4112
|
+
({ target }) => onBlur(id, target?.value),
|
|
4079
4113
|
[onBlur, id]
|
|
4080
4114
|
);
|
|
4081
|
-
const handleFocus = (0,
|
|
4082
|
-
({ target }) => onFocus(id, target
|
|
4115
|
+
const handleFocus = (0, import_react26.useCallback)(
|
|
4116
|
+
({ target }) => onFocus(id, target?.value),
|
|
4083
4117
|
[id, onFocus]
|
|
4084
4118
|
);
|
|
4085
|
-
return /* @__PURE__ */ (0,
|
|
4119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
4086
4120
|
"textarea",
|
|
4087
4121
|
{
|
|
4088
4122
|
id,
|
|
@@ -4098,48 +4132,48 @@ function TextareaWidget({
|
|
|
4098
4132
|
onBlur: handleBlur,
|
|
4099
4133
|
onFocus: handleFocus,
|
|
4100
4134
|
onChange: handleChange,
|
|
4101
|
-
"aria-describedby": (0,
|
|
4135
|
+
"aria-describedby": (0, import_utils46.ariaDescribedByIds)(id)
|
|
4102
4136
|
}
|
|
4103
4137
|
);
|
|
4104
4138
|
}
|
|
4105
4139
|
var TextareaWidget_default = TextareaWidget;
|
|
4106
4140
|
|
|
4107
4141
|
// src/components/widgets/TextWidget.tsx
|
|
4108
|
-
var
|
|
4109
|
-
var
|
|
4142
|
+
var import_utils47 = require("@rjsf/utils");
|
|
4143
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
4110
4144
|
function TextWidget(props) {
|
|
4111
4145
|
const { options, registry } = props;
|
|
4112
|
-
const BaseInputTemplate2 = (0,
|
|
4113
|
-
return /* @__PURE__ */ (0,
|
|
4146
|
+
const BaseInputTemplate2 = (0, import_utils47.getTemplate)("BaseInputTemplate", registry, options);
|
|
4147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(BaseInputTemplate2, { ...props });
|
|
4114
4148
|
}
|
|
4115
4149
|
|
|
4116
4150
|
// src/components/widgets/TimeWidget.tsx
|
|
4117
|
-
var
|
|
4118
|
-
var
|
|
4119
|
-
var
|
|
4151
|
+
var import_react27 = require("react");
|
|
4152
|
+
var import_utils48 = require("@rjsf/utils");
|
|
4153
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
4120
4154
|
function TimeWidget(props) {
|
|
4121
4155
|
const { onChange, options, registry } = props;
|
|
4122
|
-
const BaseInputTemplate2 = (0,
|
|
4123
|
-
const handleChange = (0,
|
|
4124
|
-
return /* @__PURE__ */ (0,
|
|
4156
|
+
const BaseInputTemplate2 = (0, import_utils48.getTemplate)("BaseInputTemplate", registry, options);
|
|
4157
|
+
const handleChange = (0, import_react27.useCallback)((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
4158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
|
|
4125
4159
|
}
|
|
4126
4160
|
|
|
4127
4161
|
// src/components/widgets/UpDownWidget.tsx
|
|
4128
|
-
var
|
|
4129
|
-
var
|
|
4162
|
+
var import_utils49 = require("@rjsf/utils");
|
|
4163
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
4130
4164
|
function UpDownWidget(props) {
|
|
4131
4165
|
const { options, registry } = props;
|
|
4132
|
-
const BaseInputTemplate2 = (0,
|
|
4133
|
-
return /* @__PURE__ */ (0,
|
|
4166
|
+
const BaseInputTemplate2 = (0, import_utils49.getTemplate)("BaseInputTemplate", registry, options);
|
|
4167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(BaseInputTemplate2, { type: "number", ...props });
|
|
4134
4168
|
}
|
|
4135
4169
|
|
|
4136
4170
|
// src/components/widgets/URLWidget.tsx
|
|
4137
|
-
var
|
|
4138
|
-
var
|
|
4171
|
+
var import_utils50 = require("@rjsf/utils");
|
|
4172
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
4139
4173
|
function URLWidget(props) {
|
|
4140
4174
|
const { options, registry } = props;
|
|
4141
|
-
const BaseInputTemplate2 = (0,
|
|
4142
|
-
return /* @__PURE__ */ (0,
|
|
4175
|
+
const BaseInputTemplate2 = (0, import_utils50.getTemplate)("BaseInputTemplate", registry, options);
|
|
4176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(BaseInputTemplate2, { type: "url", ...props });
|
|
4143
4177
|
}
|
|
4144
4178
|
|
|
4145
4179
|
// src/components/widgets/index.ts
|
|
@@ -4177,24 +4211,24 @@ function getDefaultRegistry() {
|
|
|
4177
4211
|
widgets: widgets_default(),
|
|
4178
4212
|
rootSchema: {},
|
|
4179
4213
|
formContext: {},
|
|
4180
|
-
translateString:
|
|
4214
|
+
translateString: import_utils51.englishStringTranslator,
|
|
4181
4215
|
globalFormOptions: {
|
|
4182
|
-
idPrefix:
|
|
4183
|
-
idSeparator:
|
|
4216
|
+
idPrefix: import_utils51.DEFAULT_ID_PREFIX,
|
|
4217
|
+
idSeparator: import_utils51.DEFAULT_ID_SEPARATOR,
|
|
4184
4218
|
useFallbackUiForUnsupportedType: false
|
|
4185
4219
|
}
|
|
4186
4220
|
};
|
|
4187
4221
|
}
|
|
4188
4222
|
|
|
4189
4223
|
// src/components/Form.tsx
|
|
4190
|
-
var
|
|
4224
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
4191
4225
|
function toIChangeEvent(state, status) {
|
|
4192
4226
|
return {
|
|
4193
4227
|
...(0, import_pick.default)(state, ["schema", "uiSchema", "fieldPathId", "schemaUtils", "formData", "edit", "errors", "errorSchema"]),
|
|
4194
4228
|
...status !== void 0 && { status }
|
|
4195
4229
|
};
|
|
4196
4230
|
}
|
|
4197
|
-
var Form = class _Form extends
|
|
4231
|
+
var Form = class _Form extends import_react28.Component {
|
|
4198
4232
|
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
4199
4233
|
* provide any possible type here
|
|
4200
4234
|
*/
|
|
@@ -4221,10 +4255,10 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4221
4255
|
};
|
|
4222
4256
|
let { errors, errorSchema } = baseErrors;
|
|
4223
4257
|
if (props.extraErrors) {
|
|
4224
|
-
({ errors, errorSchema } = (0,
|
|
4258
|
+
({ errors, errorSchema } = (0, import_utils52.validationDataMerge)(baseErrors, props.extraErrors));
|
|
4225
4259
|
}
|
|
4226
4260
|
if (state.customErrors) {
|
|
4227
|
-
({ errors, errorSchema } = (0,
|
|
4261
|
+
({ errors, errorSchema } = (0, import_utils52.validationDataMerge)(
|
|
4228
4262
|
{ errors, errorSchema },
|
|
4229
4263
|
state.customErrors.ErrorSchema,
|
|
4230
4264
|
true
|
|
@@ -4251,10 +4285,10 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4251
4285
|
...this.getStateFromProps(props, formData, void 0, void 0, void 0, true),
|
|
4252
4286
|
prevExtraErrors: props.extraErrors
|
|
4253
4287
|
};
|
|
4254
|
-
if (onChange && !(0,
|
|
4288
|
+
if (onChange && !(0, import_utils52.deepEquals)(this.state.formData, formData)) {
|
|
4255
4289
|
onChange(toIChangeEvent(this.state));
|
|
4256
4290
|
}
|
|
4257
|
-
this.formElement = (0,
|
|
4291
|
+
this.formElement = (0, import_react28.createRef)();
|
|
4258
4292
|
}
|
|
4259
4293
|
/**
|
|
4260
4294
|
* `getSnapshotBeforeUpdate` is a React lifecycle method that is invoked right before the most recently rendered
|
|
@@ -4275,12 +4309,12 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4275
4309
|
* with a flag indicating that an update is not necessary.
|
|
4276
4310
|
*/
|
|
4277
4311
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
4278
|
-
if (!(0,
|
|
4279
|
-
const formDataChangedFields = (0,
|
|
4280
|
-
const stateDataChangedFields = (0,
|
|
4281
|
-
const isSchemaChanged = !(0,
|
|
4282
|
-
const isFormDataChanged = formDataChangedFields.length > 0 || !(0,
|
|
4283
|
-
const isStateDataChanged = stateDataChangedFields.length > 0 || !(0,
|
|
4312
|
+
if (!(0, import_utils52.deepEquals)(this.props, prevProps)) {
|
|
4313
|
+
const formDataChangedFields = (0, import_utils52.getChangedFields)(this.props.formData, prevProps.formData);
|
|
4314
|
+
const stateDataChangedFields = (0, import_utils52.getChangedFields)(this.props.formData, this.state.formData);
|
|
4315
|
+
const isSchemaChanged = !(0, import_utils52.deepEquals)(prevProps.schema, this.props.schema);
|
|
4316
|
+
const isFormDataChanged = formDataChangedFields.length > 0 || !(0, import_utils52.deepEquals)(prevProps.formData, this.props.formData);
|
|
4317
|
+
const isStateDataChanged = stateDataChangedFields.length > 0 || !(0, import_utils52.deepEquals)(this.state.formData, this.props.formData);
|
|
4284
4318
|
const nextState = this.getStateFromProps(
|
|
4285
4319
|
this.props,
|
|
4286
4320
|
this.props.formData,
|
|
@@ -4293,7 +4327,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4293
4327
|
// Skip live validation for this request if no form data has changed from the last state
|
|
4294
4328
|
!isStateDataChanged
|
|
4295
4329
|
);
|
|
4296
|
-
const shouldUpdate = !(0,
|
|
4330
|
+
const shouldUpdate = !(0, import_utils52.deepEquals)(nextState, prevState);
|
|
4297
4331
|
return { nextState, shouldUpdate };
|
|
4298
4332
|
}
|
|
4299
4333
|
return { shouldUpdate: false };
|
|
@@ -4313,13 +4347,13 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4313
4347
|
componentDidUpdate(_, prevState, snapshot) {
|
|
4314
4348
|
if (snapshot.shouldUpdate) {
|
|
4315
4349
|
const { nextState } = snapshot;
|
|
4316
|
-
const nextStateDiffersFromProps = !(0,
|
|
4350
|
+
const nextStateDiffersFromProps = !(0, import_utils52.deepEquals)(nextState.formData, this.props.formData);
|
|
4317
4351
|
const wasProcessingUserChange = this.isProcessingUserChange;
|
|
4318
4352
|
this.isProcessingUserChange = false;
|
|
4319
4353
|
if (wasProcessingUserChange && nextStateDiffersFromProps) {
|
|
4320
4354
|
return;
|
|
4321
4355
|
}
|
|
4322
|
-
if (nextStateDiffersFromProps && !(0,
|
|
4356
|
+
if (nextStateDiffersFromProps && !(0, import_utils52.deepEquals)(nextState.formData, prevState.formData) && this.props.onChange) {
|
|
4323
4357
|
this.props.onChange(toIChangeEvent(nextState));
|
|
4324
4358
|
}
|
|
4325
4359
|
this.setState(nextState);
|
|
@@ -4356,7 +4390,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4356
4390
|
experimental_defaultFormStateBehavior,
|
|
4357
4391
|
experimental_customMergeAllOf
|
|
4358
4392
|
)) {
|
|
4359
|
-
schemaUtils = (0,
|
|
4393
|
+
schemaUtils = (0, import_utils52.createSchemaUtils)(
|
|
4360
4394
|
validator2,
|
|
4361
4395
|
schema,
|
|
4362
4396
|
experimental_defaultFormStateBehavior,
|
|
@@ -4381,21 +4415,21 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4381
4415
|
false,
|
|
4382
4416
|
state.initialDefaultsGenerated
|
|
4383
4417
|
);
|
|
4384
|
-
const formHash = shouldSanitize ? (0,
|
|
4418
|
+
const formHash = shouldSanitize ? (0, import_utils52.hashObject)({ formData }) : "";
|
|
4385
4419
|
computedRetrievedSchema = this.updateRetrievedSchema(
|
|
4386
4420
|
retrievedSchema ?? schemaUtils.retrieveSchema(rootSchema, formData)
|
|
4387
4421
|
);
|
|
4388
|
-
if (shouldSanitize && !preventInfiniteSanitize.includes(formHash) && !(0,
|
|
4422
|
+
if (shouldSanitize && !preventInfiniteSanitize.includes(formHash) && !(0, import_utils52.deepEquals)(computedRetrievedSchema, state.retrievedSchema)) {
|
|
4389
4423
|
const sanitizedFormData = schemaUtils.sanitizeDataForNewSchema(
|
|
4390
4424
|
computedRetrievedSchema,
|
|
4391
4425
|
state.retrievedSchema,
|
|
4392
4426
|
formData
|
|
4393
4427
|
);
|
|
4394
|
-
wasSanitized = !(0,
|
|
4428
|
+
wasSanitized = !(0, import_utils52.deepEquals)(sanitizedFormData, formData);
|
|
4395
4429
|
if (wasSanitized) {
|
|
4396
4430
|
formData = sanitizedFormData;
|
|
4397
4431
|
defaultsFormData = sanitizedFormData;
|
|
4398
|
-
const sanitizedFormHash = (0,
|
|
4432
|
+
const sanitizedFormHash = (0, import_utils52.hashObject)({ formData: sanitizedFormData });
|
|
4399
4433
|
wasSanitized = !preventInfiniteSanitize.includes(sanitizedFormHash);
|
|
4400
4434
|
preventInfiniteSanitize.push(sanitizedFormHash);
|
|
4401
4435
|
}
|
|
@@ -4448,7 +4482,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4448
4482
|
acc[key] = void 0;
|
|
4449
4483
|
return acc;
|
|
4450
4484
|
}, {});
|
|
4451
|
-
schemaValidationErrorSchema = (0,
|
|
4485
|
+
schemaValidationErrorSchema = (0, import_utils52.mergeObjects)(
|
|
4452
4486
|
currentErrors.errorSchema,
|
|
4453
4487
|
newErrorSchema,
|
|
4454
4488
|
"preventDuplicates"
|
|
@@ -4460,8 +4494,8 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4460
4494
|
errorSchema = mergedErrors.errorSchema;
|
|
4461
4495
|
}
|
|
4462
4496
|
const newRegistry = _Form.getRegistry(props, rootSchema, schemaUtils);
|
|
4463
|
-
const registry = (0,
|
|
4464
|
-
const fieldPathId = state.fieldPathId && state.fieldPathId?.[
|
|
4497
|
+
const registry = (0, import_utils52.deepEquals)(state.registry, newRegistry) ? state.registry : newRegistry;
|
|
4498
|
+
const fieldPathId = state.fieldPathId && state.fieldPathId?.[import_utils52.ID_KEY] === registry.globalFormOptions.idPrefix ? state.fieldPathId : (0, import_utils52.toFieldPathId)("", registry.globalFormOptions);
|
|
4465
4499
|
const nextState = {
|
|
4466
4500
|
schemaUtils,
|
|
4467
4501
|
schema: rootSchema,
|
|
@@ -4487,7 +4521,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4487
4521
|
*/
|
|
4488
4522
|
shouldComponentUpdate(nextProps, nextState) {
|
|
4489
4523
|
const { experimental_componentUpdateStrategy = "customDeep" } = this.props;
|
|
4490
|
-
return (0,
|
|
4524
|
+
return (0, import_utils52.shouldRender)(this, nextProps, nextState, experimental_componentUpdateStrategy);
|
|
4491
4525
|
}
|
|
4492
4526
|
/** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
|
|
4493
4527
|
* `schemaUtils` in the state), returning the results.
|
|
@@ -4501,15 +4535,16 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4501
4535
|
const schemaUtils = altSchemaUtils || this.state.schemaUtils;
|
|
4502
4536
|
const { customValidate, transformErrors, uiSchema } = this.props;
|
|
4503
4537
|
const validationSchema = retrievedSchema ?? schema;
|
|
4504
|
-
|
|
4538
|
+
const validationFormData = formData ? JSON.parse(JSON.stringify(formData)) : void 0;
|
|
4539
|
+
return schemaUtils.getValidator().validateFormData(validationFormData, validationSchema, customValidate, transformErrors, uiSchema);
|
|
4505
4540
|
}
|
|
4506
4541
|
/** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
|
|
4507
4542
|
renderErrors(registry) {
|
|
4508
4543
|
const { errors, errorSchema, schema, uiSchema } = this.state;
|
|
4509
|
-
const options = (0,
|
|
4510
|
-
const ErrorListTemplate = (0,
|
|
4511
|
-
if (errors
|
|
4512
|
-
return /* @__PURE__ */ (0,
|
|
4544
|
+
const options = (0, import_utils52.getUiOptions)(uiSchema);
|
|
4545
|
+
const ErrorListTemplate = (0, import_utils52.getTemplate)("ErrorListTemplate", registry, options);
|
|
4546
|
+
if (errors?.length) {
|
|
4547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
4513
4548
|
ErrorListTemplate,
|
|
4514
4549
|
{
|
|
4515
4550
|
errors,
|
|
@@ -4533,12 +4568,12 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4533
4568
|
static mergeErrors(schemaValidation, extraErrors, customErrors) {
|
|
4534
4569
|
let { errorSchema, errors } = schemaValidation;
|
|
4535
4570
|
if (extraErrors) {
|
|
4536
|
-
const merged = (0,
|
|
4571
|
+
const merged = (0, import_utils52.validationDataMerge)(schemaValidation, extraErrors);
|
|
4537
4572
|
errorSchema = merged.errorSchema;
|
|
4538
4573
|
errors = merged.errors;
|
|
4539
4574
|
}
|
|
4540
4575
|
if (customErrors) {
|
|
4541
|
-
const merged = (0,
|
|
4576
|
+
const merged = (0, import_utils52.validationDataMerge)({ errors, errorSchema }, customErrors.ErrorSchema, true);
|
|
4542
4577
|
errorSchema = merged.errorSchema;
|
|
4543
4578
|
errors = merged.errors;
|
|
4544
4579
|
}
|
|
@@ -4563,7 +4598,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4563
4598
|
const { errors } = schemaValidation;
|
|
4564
4599
|
let { errorSchema } = schemaValidation;
|
|
4565
4600
|
if (mergeIntoOriginalErrorSchema) {
|
|
4566
|
-
errorSchema = (0,
|
|
4601
|
+
errorSchema = (0, import_utils52.mergeObjects)(
|
|
4567
4602
|
originalErrorSchema,
|
|
4568
4603
|
schemaValidation.errorSchema,
|
|
4569
4604
|
"preventDuplicates"
|
|
@@ -4581,7 +4616,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4581
4616
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4582
4617
|
*/
|
|
4583
4618
|
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4584
|
-
getUsedFormData = (formData, fields2) => (0,
|
|
4619
|
+
getUsedFormData = (formData, fields2) => (0, import_utils52.getUsedFormData)(formData, fields2);
|
|
4585
4620
|
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
4586
4621
|
*
|
|
4587
4622
|
* @param pathSchema - The `PathSchema` object for the form
|
|
@@ -4589,7 +4624,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4589
4624
|
* @deprecated - To be removed as an exported `Form` function in a future release; there isn't a planned replacement
|
|
4590
4625
|
*/
|
|
4591
4626
|
// oxlint-disable-next-line class-methods-use-this, typescript/no-deprecated
|
|
4592
|
-
getFieldNames = (pathSchema, formData) => (0,
|
|
4627
|
+
getFieldNames = (pathSchema, formData) => (0, import_utils52.getFieldNames)(pathSchema, formData);
|
|
4593
4628
|
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
4594
4629
|
*
|
|
4595
4630
|
* @param formData - The data for the `Form`
|
|
@@ -4611,8 +4646,8 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4611
4646
|
setFieldValue = (fieldPath, newValue) => {
|
|
4612
4647
|
const { registry } = this.state;
|
|
4613
4648
|
const path = Array.isArray(fieldPath) ? fieldPath : fieldPath.split(".");
|
|
4614
|
-
const fieldPathId = (0,
|
|
4615
|
-
this.onChange(newValue, path, void 0, fieldPathId[
|
|
4649
|
+
const fieldPathId = (0, import_utils52.toFieldPathId)("", registry.globalFormOptions, path);
|
|
4650
|
+
this.onChange(newValue, path, void 0, fieldPathId[import_utils52.ID_KEY]);
|
|
4616
4651
|
};
|
|
4617
4652
|
/** Pushes the given change information into the `pendingChanges` array and then calls `processPendingChanges()` if
|
|
4618
4653
|
* the array only contains a single pending change.
|
|
@@ -4651,14 +4686,14 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4651
4686
|
const rootPathId = fieldPathId.path[0] || "";
|
|
4652
4687
|
const isRootPath = !path || path.length === 0 || path.length === 1 && path[0] === rootPathId;
|
|
4653
4688
|
let formData = isRootPath ? newValue : (0, import_cloneDeep2.default)(oldFormData);
|
|
4654
|
-
const hasOnlyUndefinedValues = (0,
|
|
4689
|
+
const hasOnlyUndefinedValues = (0, import_utils52.isObject)(formData) && Object.keys(formData).length > 0 && Object.values(formData).every((v) => v === void 0);
|
|
4655
4690
|
const wasPreviouslyNull = oldFormData === null || oldFormData === void 0;
|
|
4656
4691
|
const inputForDefaults = hasOnlyUndefinedValues && wasPreviouslyNull ? void 0 : formData;
|
|
4657
|
-
if ((0,
|
|
4692
|
+
if ((0, import_utils52.isObject)(formData) || Array.isArray(formData)) {
|
|
4693
|
+
let plainLeafWasCleared = false;
|
|
4658
4694
|
if (newValue === ADDITIONAL_PROPERTY_KEY_REMOVE) {
|
|
4659
4695
|
(0, import_unset.default)(formData, path);
|
|
4660
4696
|
} else if (!isRootPath) {
|
|
4661
|
-
let unsetPath = false;
|
|
4662
4697
|
let valueForPath = newValue;
|
|
4663
4698
|
if (newValue === void 0) {
|
|
4664
4699
|
const lastSegment = path[path.length - 1];
|
|
@@ -4667,19 +4702,19 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4667
4702
|
} else {
|
|
4668
4703
|
const { field } = schemaUtils.findFieldInSchema(schema, path, oldFormData);
|
|
4669
4704
|
const leaf = field;
|
|
4670
|
-
const isOneOfOrAnyOfLeaf = leaf && (
|
|
4705
|
+
const isOneOfOrAnyOfLeaf = leaf && (import_utils52.ONE_OF_KEY in leaf || import_utils52.ANY_OF_KEY in leaf);
|
|
4671
4706
|
if (!isOneOfOrAnyOfLeaf && leaf !== void 0) {
|
|
4672
|
-
|
|
4707
|
+
plainLeafWasCleared = true;
|
|
4673
4708
|
}
|
|
4674
4709
|
}
|
|
4675
4710
|
}
|
|
4676
|
-
if (
|
|
4677
|
-
(0,
|
|
4711
|
+
if (plainLeafWasCleared) {
|
|
4712
|
+
(0, import_set5.default)(formData, path, void 0);
|
|
4678
4713
|
} else {
|
|
4679
4714
|
(0, import_set5.default)(formData, path, valueForPath);
|
|
4680
4715
|
}
|
|
4681
4716
|
}
|
|
4682
|
-
const shouldSanitize = retrievedSchema && !isRootPath && !(0,
|
|
4717
|
+
const shouldSanitize = retrievedSchema && !isRootPath && !(0, import_utils52.isObject)(newValue) && !Array.isArray(newValue) && !disabled && !readonly;
|
|
4683
4718
|
const newState = this.getStateFromProps(
|
|
4684
4719
|
this.props,
|
|
4685
4720
|
inputForDefaults,
|
|
@@ -4691,6 +4726,9 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4691
4726
|
);
|
|
4692
4727
|
formData = newState.formData;
|
|
4693
4728
|
retrievedSchema = newState.retrievedSchema;
|
|
4729
|
+
if (plainLeafWasCleared && formData) {
|
|
4730
|
+
(0, import_set5.default)(formData, path, void 0);
|
|
4731
|
+
}
|
|
4694
4732
|
}
|
|
4695
4733
|
const mustValidate = !noValidate && (liveValidate === true || liveValidate === "onChange");
|
|
4696
4734
|
let state = { formData, retrievedSchema };
|
|
@@ -4710,10 +4748,10 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4710
4748
|
}
|
|
4711
4749
|
} else {
|
|
4712
4750
|
if (!customErrors) {
|
|
4713
|
-
customErrors = new
|
|
4751
|
+
customErrors = new import_utils52.ErrorSchemaBuilder();
|
|
4714
4752
|
}
|
|
4715
4753
|
if (isRootPath) {
|
|
4716
|
-
const pathErrors = (0, import_get5.default)(newErrorSchema,
|
|
4754
|
+
const pathErrors = (0, import_get5.default)(newErrorSchema, import_utils52.ERRORS_KEY);
|
|
4717
4755
|
if (pathErrors) {
|
|
4718
4756
|
customErrors.setErrors(pathErrors);
|
|
4719
4757
|
}
|
|
@@ -4721,7 +4759,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4721
4759
|
(0, import_set5.default)(customErrors.ErrorSchema, path, newErrorSchema);
|
|
4722
4760
|
}
|
|
4723
4761
|
}
|
|
4724
|
-
} else if (customErrors && (0, import_get5.default)(customErrors.ErrorSchema, [...path,
|
|
4762
|
+
} else if (customErrors && (0, import_get5.default)(customErrors.ErrorSchema, [...path, import_utils52.ERRORS_KEY])) {
|
|
4725
4763
|
customErrors.clearErrors(path);
|
|
4726
4764
|
}
|
|
4727
4765
|
if (mustValidate && this.pendingChanges.length === 1) {
|
|
@@ -4761,7 +4799,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4761
4799
|
* @returns The new retrieved schema if it has changed, else the old retrieved schema.
|
|
4762
4800
|
*/
|
|
4763
4801
|
updateRetrievedSchema(retrievedSchema) {
|
|
4764
|
-
const isTheSame = (0,
|
|
4802
|
+
const isTheSame = (0, import_utils52.deepEquals)(retrievedSchema, this.state?.retrievedSchema);
|
|
4765
4803
|
return isTheSame ? this.state.retrievedSchema : retrievedSchema;
|
|
4766
4804
|
}
|
|
4767
4805
|
/**
|
|
@@ -4790,7 +4828,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4790
4828
|
initialDefaultsGenerated: false,
|
|
4791
4829
|
customErrors: void 0
|
|
4792
4830
|
};
|
|
4793
|
-
this.setState(state, () => onChange
|
|
4831
|
+
this.setState(state, () => onChange?.(toIChangeEvent({ ...this.state, ...state })));
|
|
4794
4832
|
};
|
|
4795
4833
|
/** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
|
|
4796
4834
|
* was provided. Also runs any live validation and/or live omit operations if the flags indicate they should happen
|
|
@@ -4829,7 +4867,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4829
4867
|
const hasChanges = Object.keys(state).filter((key) => !key.startsWith("schemaValidation")).some((key) => {
|
|
4830
4868
|
const oldData = (0, import_get5.default)(this.state, key);
|
|
4831
4869
|
const newData = (0, import_get5.default)(state, key);
|
|
4832
|
-
return !(0,
|
|
4870
|
+
return !(0, import_utils52.deepEquals)(oldData, newData);
|
|
4833
4871
|
});
|
|
4834
4872
|
this.setState(state, () => {
|
|
4835
4873
|
if (onChange && hasChanges) {
|
|
@@ -4871,7 +4909,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4871
4909
|
}
|
|
4872
4910
|
if (noValidate || this.validateFormWithFormData(newFormData)) {
|
|
4873
4911
|
const errorSchema = extraErrors || {};
|
|
4874
|
-
const errors = extraErrors ? (0,
|
|
4912
|
+
const errors = extraErrors ? (0, import_utils52.toErrorList)(extraErrors) : [];
|
|
4875
4913
|
this.setState(
|
|
4876
4914
|
{
|
|
4877
4915
|
formData: newFormData,
|
|
@@ -4898,8 +4936,8 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4898
4936
|
const {
|
|
4899
4937
|
uiSchema = {},
|
|
4900
4938
|
experimental_componentUpdateStrategy,
|
|
4901
|
-
idSeparator =
|
|
4902
|
-
idPrefix =
|
|
4939
|
+
idSeparator = import_utils52.DEFAULT_ID_SEPARATOR,
|
|
4940
|
+
idPrefix = import_utils52.DEFAULT_ID_PREFIX,
|
|
4903
4941
|
nameGenerator,
|
|
4904
4942
|
useFallbackUiForUnsupportedType = false
|
|
4905
4943
|
} = props;
|
|
@@ -4931,9 +4969,9 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4931
4969
|
formContext: props.formContext || formContext,
|
|
4932
4970
|
schemaUtils,
|
|
4933
4971
|
translateString: customTranslateString || translateString,
|
|
4934
|
-
globalUiOptions: uiSchema[
|
|
4972
|
+
globalUiOptions: uiSchema[import_utils52.UI_GLOBAL_OPTIONS_KEY],
|
|
4935
4973
|
globalFormOptions: _Form.getGlobalFormOptions(props),
|
|
4936
|
-
uiSchemaDefinitions: uiSchema[
|
|
4974
|
+
uiSchemaDefinitions: uiSchema[import_utils52.UI_DEFINITIONS_KEY] ?? {}
|
|
4937
4975
|
};
|
|
4938
4976
|
}
|
|
4939
4977
|
/** Provides a function that can be used to programmatically submit the `Form` */
|
|
@@ -4967,7 +5005,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
4967
5005
|
if (!field) {
|
|
4968
5006
|
field = this.formElement.current.querySelector(`input[id^="${elementId}"], button[id^="${elementId}"]`);
|
|
4969
5007
|
}
|
|
4970
|
-
if (field
|
|
5008
|
+
if (field?.length) {
|
|
4971
5009
|
field = field[0];
|
|
4972
5010
|
}
|
|
4973
5011
|
if (field) {
|
|
@@ -5067,12 +5105,12 @@ var Form = class _Form extends import_react27.Component {
|
|
|
5067
5105
|
const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
|
|
5068
5106
|
const as = _internalFormWrapper ? tagName : void 0;
|
|
5069
5107
|
const FormTag = _internalFormWrapper || tagName || "form";
|
|
5070
|
-
let { [
|
|
5108
|
+
let { [import_utils52.SUBMIT_BTN_OPTIONS_KEY]: submitOptions = {} } = (0, import_utils52.getUiOptions)(uiSchema);
|
|
5071
5109
|
if (disabled) {
|
|
5072
5110
|
submitOptions = { ...submitOptions, props: { ...submitOptions.props, disabled: true } };
|
|
5073
5111
|
}
|
|
5074
|
-
const submitUiSchema = { [
|
|
5075
|
-
return /* @__PURE__ */ (0,
|
|
5112
|
+
const submitUiSchema = { [import_utils52.UI_OPTIONS_KEY]: { [import_utils52.SUBMIT_BTN_OPTIONS_KEY]: submitOptions } };
|
|
5113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
|
|
5076
5114
|
FormTag,
|
|
5077
5115
|
{
|
|
5078
5116
|
className: className || "rjsf",
|
|
@@ -5090,7 +5128,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
5090
5128
|
ref: this.formElement,
|
|
5091
5129
|
children: [
|
|
5092
5130
|
showErrorList === "top" && this.renderErrors(registry),
|
|
5093
|
-
/* @__PURE__ */ (0,
|
|
5131
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
5094
5132
|
SchemaFieldComponent,
|
|
5095
5133
|
{
|
|
5096
5134
|
name: "",
|
|
@@ -5107,7 +5145,7 @@ var Form = class _Form extends import_react27.Component {
|
|
|
5107
5145
|
readonly
|
|
5108
5146
|
}
|
|
5109
5147
|
),
|
|
5110
|
-
children || /* @__PURE__ */ (0,
|
|
5148
|
+
children || /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(SubmitButton2, { uiSchema: submitUiSchema, registry }),
|
|
5111
5149
|
showErrorList === "bottom" && this.renderErrors(registry)
|
|
5112
5150
|
]
|
|
5113
5151
|
}
|
|
@@ -5116,15 +5154,15 @@ var Form = class _Form extends import_react27.Component {
|
|
|
5116
5154
|
};
|
|
5117
5155
|
|
|
5118
5156
|
// src/getTestRegistry.tsx
|
|
5119
|
-
var
|
|
5157
|
+
var import_utils53 = require("@rjsf/utils");
|
|
5120
5158
|
var import_validator_ajv8 = __toESM(require("@rjsf/validator-ajv8"), 1);
|
|
5121
5159
|
function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {}, formContext = {}, globalFormOptions = {
|
|
5122
|
-
idPrefix:
|
|
5123
|
-
idSeparator:
|
|
5160
|
+
idPrefix: import_utils53.DEFAULT_ID_PREFIX,
|
|
5161
|
+
idSeparator: import_utils53.DEFAULT_ID_SEPARATOR,
|
|
5124
5162
|
useFallbackUiForUnsupportedType: false
|
|
5125
5163
|
}) {
|
|
5126
5164
|
const defaults = getDefaultRegistry();
|
|
5127
|
-
const schemaUtils = (0,
|
|
5165
|
+
const schemaUtils = (0, import_utils53.createSchemaUtils)(import_validator_ajv8.default, rootSchema);
|
|
5128
5166
|
return {
|
|
5129
5167
|
fields: { ...defaults.fields, ...fields2 },
|
|
5130
5168
|
templates: { ...defaults.templates, ...templates2 },
|
|
@@ -5132,16 +5170,16 @@ function getTestRegistry(rootSchema, fields2 = {}, templates2 = {}, widgets2 = {
|
|
|
5132
5170
|
formContext,
|
|
5133
5171
|
rootSchema,
|
|
5134
5172
|
schemaUtils,
|
|
5135
|
-
translateString:
|
|
5173
|
+
translateString: import_utils53.englishStringTranslator,
|
|
5136
5174
|
globalFormOptions
|
|
5137
5175
|
};
|
|
5138
5176
|
}
|
|
5139
5177
|
|
|
5140
5178
|
// src/withTheme.tsx
|
|
5141
|
-
var
|
|
5142
|
-
var
|
|
5179
|
+
var import_react29 = require("react");
|
|
5180
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
5143
5181
|
function withTheme(themeProps) {
|
|
5144
|
-
return (0,
|
|
5182
|
+
return (0, import_react29.forwardRef)(
|
|
5145
5183
|
({ fields: propFields, widgets: propWidgets, templates: propTemplates, ...directProps }, ref) => {
|
|
5146
5184
|
const fields2 = { ...themeProps?.fields, ...propFields };
|
|
5147
5185
|
const widgets2 = { ...themeProps?.widgets, ...propWidgets };
|
|
@@ -5153,7 +5191,7 @@ function withTheme(themeProps) {
|
|
|
5153
5191
|
...propTemplates?.ButtonTemplates
|
|
5154
5192
|
}
|
|
5155
5193
|
};
|
|
5156
|
-
return /* @__PURE__ */ (0,
|
|
5194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
5157
5195
|
Form,
|
|
5158
5196
|
{
|
|
5159
5197
|
...themeProps,
|