@rjsf/core 6.0.0-alpha.0 → 6.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.umd.js +1680 -809
- package/dist/index.esm.js +2166 -1198
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +2221 -1299
- package/dist/index.js.map +4 -4
- package/lib/components/Form.d.ts +22 -9
- package/lib/components/Form.d.ts.map +1 -0
- package/lib/components/Form.js +368 -312
- package/lib/components/RichDescription.d.ts +20 -0
- package/lib/components/RichDescription.d.ts.map +1 -0
- package/lib/components/RichDescription.js +17 -0
- package/lib/components/fields/ArrayField.d.ts +20 -9
- package/lib/components/fields/ArrayField.d.ts.map +1 -0
- package/lib/components/fields/ArrayField.js +212 -206
- package/lib/components/fields/BooleanField.d.ts +1 -0
- package/lib/components/fields/BooleanField.d.ts.map +1 -0
- package/lib/components/fields/BooleanField.js +6 -14
- package/lib/components/fields/LayoutGridField.d.ts +480 -0
- package/lib/components/fields/LayoutGridField.d.ts.map +1 -0
- package/lib/components/fields/LayoutGridField.js +711 -0
- package/lib/components/fields/LayoutHeaderField.d.ts +12 -0
- package/lib/components/fields/LayoutHeaderField.d.ts.map +1 -0
- package/lib/components/fields/LayoutHeaderField.js +23 -0
- package/lib/components/fields/LayoutMultiSchemaField.d.ts +28 -0
- package/lib/components/fields/LayoutMultiSchemaField.d.ts.map +1 -0
- package/lib/components/fields/LayoutMultiSchemaField.js +114 -0
- package/lib/components/fields/MultiSchemaField.d.ts +1 -0
- package/lib/components/fields/MultiSchemaField.d.ts.map +1 -0
- package/lib/components/fields/MultiSchemaField.js +31 -31
- package/lib/components/fields/NullField.d.ts +1 -0
- package/lib/components/fields/NullField.d.ts.map +1 -0
- package/lib/components/fields/NullField.js +0 -1
- package/lib/components/fields/NumberField.d.ts +1 -0
- package/lib/components/fields/NumberField.d.ts.map +1 -0
- package/lib/components/fields/NumberField.js +2 -3
- package/lib/components/fields/ObjectField.d.ts +1 -0
- package/lib/components/fields/ObjectField.d.ts.map +1 -0
- package/lib/components/fields/ObjectField.js +146 -141
- package/lib/components/fields/SchemaField.d.ts +1 -0
- package/lib/components/fields/SchemaField.d.ts.map +1 -0
- package/lib/components/fields/SchemaField.js +10 -20
- package/lib/components/fields/StringField.d.ts +1 -0
- package/lib/components/fields/StringField.d.ts.map +1 -0
- package/lib/components/fields/StringField.js +1 -3
- package/lib/components/fields/index.d.ts +1 -0
- package/lib/components/fields/index.d.ts.map +1 -0
- package/lib/components/fields/index.js +14 -9
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js +0 -1
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts +8 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldItemButtonsTemplate.js +17 -0
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts +4 -3
- package/lib/components/templates/ArrayFieldItemTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldItemTemplate.js +7 -6
- package/lib/components/templates/ArrayFieldTemplate.d.ts +2 -1
- package/lib/components/templates/ArrayFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldTemplate.js +3 -4
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.d.ts.map +1 -0
- package/lib/components/templates/ArrayFieldTitleTemplate.js +0 -1
- package/lib/components/templates/BaseInputTemplate.d.ts +1 -0
- package/lib/components/templates/BaseInputTemplate.d.ts.map +1 -0
- package/lib/components/templates/BaseInputTemplate.js +0 -1
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/AddButton.js +1 -2
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/IconButton.js +4 -5
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/SubmitButton.js +0 -1
- package/lib/components/templates/ButtonTemplates/index.d.ts +1 -0
- package/lib/components/templates/ButtonTemplates/index.d.ts.map +1 -0
- package/lib/components/templates/ButtonTemplates/index.js +3 -4
- package/lib/components/templates/DescriptionField.d.ts +1 -0
- package/lib/components/templates/DescriptionField.d.ts.map +1 -0
- package/lib/components/templates/DescriptionField.js +3 -8
- package/lib/components/templates/ErrorList.d.ts +1 -0
- package/lib/components/templates/ErrorList.d.ts.map +1 -0
- package/lib/components/templates/ErrorList.js +0 -1
- package/lib/components/templates/FieldErrorTemplate.d.ts +1 -0
- package/lib/components/templates/FieldErrorTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldErrorTemplate.js +0 -1
- package/lib/components/templates/FieldHelpTemplate.d.ts +1 -0
- package/lib/components/templates/FieldHelpTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldHelpTemplate.js +0 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/FieldTemplate.js +1 -2
- package/lib/components/templates/FieldTemplate/Label.d.ts +1 -0
- package/lib/components/templates/FieldTemplate/Label.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/Label.js +0 -1
- package/lib/components/templates/FieldTemplate/index.d.ts +2 -1
- package/lib/components/templates/FieldTemplate/index.d.ts.map +1 -0
- package/lib/components/templates/FieldTemplate/index.js +1 -2
- package/lib/components/templates/GridTemplate.d.ts +8 -0
- package/lib/components/templates/GridTemplate.d.ts.map +1 -0
- package/lib/components/templates/GridTemplate.js +10 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts +1 -0
- package/lib/components/templates/ObjectFieldTemplate.d.ts.map +1 -0
- package/lib/components/templates/ObjectFieldTemplate.js +2 -3
- package/lib/components/templates/TitleField.d.ts +1 -0
- package/lib/components/templates/TitleField.d.ts.map +1 -0
- package/lib/components/templates/TitleField.js +0 -1
- package/lib/components/templates/UnsupportedField.d.ts +1 -0
- package/lib/components/templates/UnsupportedField.d.ts.map +1 -0
- package/lib/components/templates/UnsupportedField.js +0 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.d.ts.map +1 -0
- package/lib/components/templates/WrapIfAdditionalTemplate.js +10 -6
- package/lib/components/templates/index.d.ts +1 -0
- package/lib/components/templates/index.d.ts.map +1 -0
- package/lib/components/templates/index.js +19 -16
- package/lib/components/widgets/AltDateTimeWidget.d.ts +1 -0
- package/lib/components/widgets/AltDateTimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/AltDateTimeWidget.js +0 -1
- package/lib/components/widgets/AltDateWidget.d.ts +1 -0
- package/lib/components/widgets/AltDateWidget.d.ts.map +1 -0
- package/lib/components/widgets/AltDateWidget.js +0 -1
- package/lib/components/widgets/CheckboxWidget.d.ts +1 -0
- package/lib/components/widgets/CheckboxWidget.d.ts.map +1 -0
- package/lib/components/widgets/CheckboxWidget.js +2 -4
- package/lib/components/widgets/CheckboxesWidget.d.ts +1 -0
- package/lib/components/widgets/CheckboxesWidget.d.ts.map +1 -0
- package/lib/components/widgets/CheckboxesWidget.js +0 -1
- package/lib/components/widgets/ColorWidget.d.ts +1 -0
- package/lib/components/widgets/ColorWidget.d.ts.map +1 -0
- package/lib/components/widgets/ColorWidget.js +0 -1
- package/lib/components/widgets/DateTimeWidget.d.ts +1 -0
- package/lib/components/widgets/DateTimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/DateTimeWidget.js +0 -1
- package/lib/components/widgets/DateWidget.d.ts +1 -0
- package/lib/components/widgets/DateWidget.d.ts.map +1 -0
- package/lib/components/widgets/DateWidget.js +0 -1
- package/lib/components/widgets/EmailWidget.d.ts +1 -0
- package/lib/components/widgets/EmailWidget.d.ts.map +1 -0
- package/lib/components/widgets/EmailWidget.js +0 -1
- package/lib/components/widgets/FileWidget.d.ts +1 -0
- package/lib/components/widgets/FileWidget.d.ts.map +1 -0
- package/lib/components/widgets/FileWidget.js +3 -5
- package/lib/components/widgets/HiddenWidget.d.ts +1 -0
- package/lib/components/widgets/HiddenWidget.d.ts.map +1 -0
- package/lib/components/widgets/HiddenWidget.js +0 -1
- package/lib/components/widgets/PasswordWidget.d.ts +1 -0
- package/lib/components/widgets/PasswordWidget.d.ts.map +1 -0
- package/lib/components/widgets/PasswordWidget.js +0 -1
- package/lib/components/widgets/RadioWidget.d.ts +1 -0
- package/lib/components/widgets/RadioWidget.d.ts.map +1 -0
- package/lib/components/widgets/RadioWidget.js +3 -4
- package/lib/components/widgets/RangeWidget.d.ts +1 -0
- package/lib/components/widgets/RangeWidget.d.ts.map +1 -0
- package/lib/components/widgets/RangeWidget.js +0 -1
- package/lib/components/widgets/RatingWidget.d.ts +15 -0
- package/lib/components/widgets/RatingWidget.d.ts.map +1 -0
- package/lib/components/widgets/RatingWidget.js +63 -0
- package/lib/components/widgets/SelectWidget.d.ts +1 -0
- package/lib/components/widgets/SelectWidget.d.ts.map +1 -0
- package/lib/components/widgets/SelectWidget.js +4 -5
- package/lib/components/widgets/TextWidget.d.ts +1 -0
- package/lib/components/widgets/TextWidget.d.ts.map +1 -0
- package/lib/components/widgets/TextWidget.js +0 -1
- package/lib/components/widgets/TextareaWidget.d.ts +1 -0
- package/lib/components/widgets/TextareaWidget.d.ts.map +1 -0
- package/lib/components/widgets/TextareaWidget.js +0 -1
- package/lib/components/widgets/TimeWidget.d.ts +1 -0
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -0
- package/lib/components/widgets/TimeWidget.js +0 -1
- package/lib/components/widgets/URLWidget.d.ts +1 -0
- package/lib/components/widgets/URLWidget.d.ts.map +1 -0
- package/lib/components/widgets/URLWidget.js +0 -1
- package/lib/components/widgets/UpDownWidget.d.ts +1 -0
- package/lib/components/widgets/UpDownWidget.d.ts.map +1 -0
- package/lib/components/widgets/UpDownWidget.js +0 -1
- package/lib/components/widgets/index.d.ts +1 -0
- package/lib/components/widgets/index.d.ts.map +1 -0
- package/lib/components/widgets/index.js +21 -20
- package/lib/getDefaultRegistry.d.ts +1 -0
- package/lib/getDefaultRegistry.d.ts.map +1 -0
- package/lib/getDefaultRegistry.js +3 -4
- package/lib/index.d.ts +7 -5
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -5
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/withTheme.d.ts +2 -1
- package/lib/withTheme.d.ts.map +1 -0
- package/lib/withTheme.js +7 -8
- package/package.json +46 -37
- package/src/components/Form.tsx +127 -41
- package/src/components/RichDescription.tsx +50 -0
- package/src/components/fields/ArrayField.tsx +34 -24
- package/src/components/fields/BooleanField.tsx +6 -14
- package/src/components/fields/LayoutGridField.tsx +967 -0
- package/src/components/fields/LayoutHeaderField.tsx +49 -0
- package/src/components/fields/LayoutMultiSchemaField.tsx +228 -0
- package/src/components/fields/MultiSchemaField.tsx +9 -4
- package/src/components/fields/NullField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +5 -5
- package/src/components/fields/ObjectField.tsx +32 -24
- package/src/components/fields/SchemaField.tsx +17 -30
- package/src/components/fields/StringField.tsx +2 -2
- package/src/components/fields/index.ts +7 -1
- package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +2 -2
- package/src/components/templates/ArrayFieldItemButtonsTemplate.tsx +85 -0
- package/src/components/templates/ArrayFieldItemTemplate.tsx +18 -57
- package/src/components/templates/ArrayFieldTemplate.tsx +10 -8
- package/src/components/templates/ArrayFieldTitleTemplate.tsx +2 -2
- package/src/components/templates/BaseInputTemplate.tsx +4 -4
- package/src/components/templates/ButtonTemplates/IconButton.tsx +9 -36
- package/src/components/templates/ButtonTemplates/SubmitButton.tsx +1 -1
- package/src/components/templates/ButtonTemplates/index.ts +1 -1
- package/src/components/templates/DescriptionField.tsx +9 -15
- package/src/components/templates/FieldErrorTemplate.tsx +1 -1
- package/src/components/templates/FieldHelpTemplate.tsx +1 -1
- package/src/components/templates/FieldTemplate/FieldTemplate.tsx +2 -2
- package/src/components/templates/GridTemplate.tsx +15 -0
- package/src/components/templates/ObjectFieldTemplate.tsx +5 -3
- package/src/components/templates/TitleField.tsx +1 -1
- package/src/components/templates/UnsupportedField.tsx +1 -1
- package/src/components/templates/WrapIfAdditionalTemplate.tsx +14 -4
- package/src/components/templates/index.ts +4 -0
- package/src/components/widgets/AltDateWidget.tsx +9 -6
- package/src/components/widgets/CheckboxWidget.tsx +5 -5
- package/src/components/widgets/CheckboxesWidget.tsx +2 -2
- package/src/components/widgets/ColorWidget.tsx +1 -1
- package/src/components/widgets/DateTimeWidget.tsx +1 -1
- package/src/components/widgets/DateWidget.tsx +1 -1
- package/src/components/widgets/EmailWidget.tsx +1 -1
- package/src/components/widgets/FileWidget.tsx +5 -5
- package/src/components/widgets/PasswordWidget.tsx +1 -1
- package/src/components/widgets/RadioWidget.tsx +3 -3
- package/src/components/widgets/RangeWidget.tsx +1 -1
- package/src/components/widgets/RatingWidget.tsx +129 -0
- package/src/components/widgets/SelectWidget.tsx +4 -3
- package/src/components/widgets/TextWidget.tsx +1 -1
- package/src/components/widgets/TextareaWidget.tsx +3 -3
- package/src/components/widgets/TimeWidget.tsx +1 -1
- package/src/components/widgets/URLWidget.tsx +1 -1
- package/src/components/widgets/UpDownWidget.tsx +1 -1
- package/src/components/widgets/index.ts +3 -1
- package/src/getDefaultRegistry.ts +1 -1
- package/src/index.ts +3 -2
- package/src/tsconfig.json +14 -6
- package/src/withTheme.tsx +4 -3
- package/LICENSE.md +0 -201
- package/lib/components/Form.js.map +0 -1
- package/lib/components/fields/ArrayField.js.map +0 -1
- package/lib/components/fields/BooleanField.js.map +0 -1
- package/lib/components/fields/MultiSchemaField.js.map +0 -1
- package/lib/components/fields/NullField.js.map +0 -1
- package/lib/components/fields/NumberField.js.map +0 -1
- package/lib/components/fields/ObjectField.js.map +0 -1
- package/lib/components/fields/SchemaField.js.map +0 -1
- package/lib/components/fields/StringField.js.map +0 -1
- package/lib/components/fields/index.js.map +0 -1
- package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldItemTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldTemplate.js.map +0 -1
- package/lib/components/templates/ArrayFieldTitleTemplate.js.map +0 -1
- package/lib/components/templates/BaseInputTemplate.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/AddButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/IconButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +0 -1
- package/lib/components/templates/ButtonTemplates/index.js.map +0 -1
- package/lib/components/templates/DescriptionField.js.map +0 -1
- package/lib/components/templates/ErrorList.js.map +0 -1
- package/lib/components/templates/FieldErrorTemplate.js.map +0 -1
- package/lib/components/templates/FieldHelpTemplate.js.map +0 -1
- package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +0 -1
- package/lib/components/templates/FieldTemplate/Label.js.map +0 -1
- package/lib/components/templates/FieldTemplate/index.js.map +0 -1
- package/lib/components/templates/ObjectFieldTemplate.js.map +0 -1
- package/lib/components/templates/TitleField.js.map +0 -1
- package/lib/components/templates/UnsupportedField.js.map +0 -1
- package/lib/components/templates/WrapIfAdditionalTemplate.js.map +0 -1
- package/lib/components/templates/index.js.map +0 -1
- package/lib/components/widgets/AltDateTimeWidget.js.map +0 -1
- package/lib/components/widgets/AltDateWidget.js.map +0 -1
- package/lib/components/widgets/CheckboxWidget.js.map +0 -1
- package/lib/components/widgets/CheckboxesWidget.js.map +0 -1
- package/lib/components/widgets/ColorWidget.js.map +0 -1
- package/lib/components/widgets/DateTimeWidget.js.map +0 -1
- package/lib/components/widgets/DateWidget.js.map +0 -1
- package/lib/components/widgets/EmailWidget.js.map +0 -1
- package/lib/components/widgets/FileWidget.js.map +0 -1
- package/lib/components/widgets/HiddenWidget.js.map +0 -1
- package/lib/components/widgets/PasswordWidget.js.map +0 -1
- package/lib/components/widgets/RadioWidget.js.map +0 -1
- package/lib/components/widgets/RangeWidget.js.map +0 -1
- package/lib/components/widgets/SelectWidget.js.map +0 -1
- package/lib/components/widgets/TextWidget.js.map +0 -1
- package/lib/components/widgets/TextareaWidget.js.map +0 -1
- package/lib/components/widgets/TimeWidget.js.map +0 -1
- package/lib/components/widgets/URLWidget.js.map +0 -1
- package/lib/components/widgets/UpDownWidget.js.map +0 -1
- package/lib/components/widgets/index.js.map +0 -1
- package/lib/getDefaultRegistry.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/withTheme.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -28,33 +28,35 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
RichDescription: () => RichDescription,
|
|
34
|
+
default: () => index_default,
|
|
34
35
|
getDefaultRegistry: () => getDefaultRegistry,
|
|
35
36
|
withTheme: () => withTheme
|
|
36
37
|
});
|
|
37
|
-
module.exports = __toCommonJS(
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
39
|
|
|
39
40
|
// src/components/Form.tsx
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var import_forEach = __toESM(require("lodash/forEach"));
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
41
|
+
var import_react22 = require("react");
|
|
42
|
+
var import_utils45 = require("@rjsf/utils");
|
|
43
|
+
var import_forEach = __toESM(require("lodash/forEach"), 1);
|
|
44
|
+
var import_get6 = __toESM(require("lodash/get"), 1);
|
|
45
|
+
var import_isEmpty4 = __toESM(require("lodash/isEmpty"), 1);
|
|
46
|
+
var import_isNil = __toESM(require("lodash/isNil"), 1);
|
|
47
|
+
var import_pick = __toESM(require("lodash/pick"), 1);
|
|
48
|
+
var import_toPath = __toESM(require("lodash/toPath"), 1);
|
|
47
49
|
|
|
48
50
|
// src/getDefaultRegistry.ts
|
|
49
|
-
var
|
|
51
|
+
var import_utils44 = require("@rjsf/utils");
|
|
50
52
|
|
|
51
53
|
// src/components/fields/ArrayField.tsx
|
|
52
54
|
var import_react = require("react");
|
|
53
55
|
var import_utils = require("@rjsf/utils");
|
|
54
|
-
var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
|
|
55
|
-
var import_get = __toESM(require("lodash/get"));
|
|
56
|
-
var import_isObject = __toESM(require("lodash/isObject"));
|
|
57
|
-
var import_set = __toESM(require("lodash/set"));
|
|
56
|
+
var import_cloneDeep = __toESM(require("lodash/cloneDeep"), 1);
|
|
57
|
+
var import_get = __toESM(require("lodash/get"), 1);
|
|
58
|
+
var import_isObject = __toESM(require("lodash/isObject"), 1);
|
|
59
|
+
var import_set = __toESM(require("lodash/set"), 1);
|
|
58
60
|
var import_nanoid = require("nanoid");
|
|
59
61
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
60
62
|
function generateRowId() {
|
|
@@ -81,189 +83,6 @@ var ArrayField = class extends import_react.Component {
|
|
|
81
83
|
*/
|
|
82
84
|
constructor(props) {
|
|
83
85
|
super(props);
|
|
84
|
-
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
85
|
-
* that the schema is fixed and allows additional items.
|
|
86
|
-
*/
|
|
87
|
-
this._getNewFormDataRow = () => {
|
|
88
|
-
const { schema, registry } = this.props;
|
|
89
|
-
const { schemaUtils } = registry;
|
|
90
|
-
let itemSchema = schema.items;
|
|
91
|
-
if ((0, import_utils.isFixedItems)(schema) && (0, import_utils.allowAdditionalItems)(schema)) {
|
|
92
|
-
itemSchema = schema.additionalItems;
|
|
93
|
-
}
|
|
94
|
-
return schemaUtils.getDefaultFormState(itemSchema);
|
|
95
|
-
};
|
|
96
|
-
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
97
|
-
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
98
|
-
* keyed data
|
|
99
|
-
*
|
|
100
|
-
* @param event - The event for the click
|
|
101
|
-
*/
|
|
102
|
-
this.onAddClick = (event) => {
|
|
103
|
-
this._handleAddClick(event);
|
|
104
|
-
};
|
|
105
|
-
/** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
|
|
106
|
-
* keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
|
|
107
|
-
* form data converted from the keyed data
|
|
108
|
-
*
|
|
109
|
-
* @param index - The index at which the add button is clicked
|
|
110
|
-
*/
|
|
111
|
-
this.onAddIndexClick = (index) => {
|
|
112
|
-
return (event) => {
|
|
113
|
-
this._handleAddClick(event, index);
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
/** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
|
|
117
|
-
* keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
|
|
118
|
-
* form data converted from the keyed data
|
|
119
|
-
*
|
|
120
|
-
* @param index - The index at which the copy button is clicked
|
|
121
|
-
*/
|
|
122
|
-
this.onCopyIndexClick = (index) => {
|
|
123
|
-
return (event) => {
|
|
124
|
-
if (event) {
|
|
125
|
-
event.preventDefault();
|
|
126
|
-
}
|
|
127
|
-
const { onChange, errorSchema } = this.props;
|
|
128
|
-
const { keyedFormData } = this.state;
|
|
129
|
-
let newErrorSchema;
|
|
130
|
-
if (errorSchema) {
|
|
131
|
-
newErrorSchema = {};
|
|
132
|
-
for (const idx in errorSchema) {
|
|
133
|
-
const i = parseInt(idx);
|
|
134
|
-
if (i <= index) {
|
|
135
|
-
(0, import_set.default)(newErrorSchema, [i], errorSchema[idx]);
|
|
136
|
-
} else if (i > index) {
|
|
137
|
-
(0, import_set.default)(newErrorSchema, [i + 1], errorSchema[idx]);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
const newKeyedFormDataRow = {
|
|
142
|
-
key: generateRowId(),
|
|
143
|
-
item: (0, import_cloneDeep.default)(keyedFormData[index].item)
|
|
144
|
-
};
|
|
145
|
-
const newKeyedFormData = [...keyedFormData];
|
|
146
|
-
if (index !== void 0) {
|
|
147
|
-
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
148
|
-
} else {
|
|
149
|
-
newKeyedFormData.push(newKeyedFormDataRow);
|
|
150
|
-
}
|
|
151
|
-
this.setState(
|
|
152
|
-
{
|
|
153
|
-
keyedFormData: newKeyedFormData,
|
|
154
|
-
updatedKeyedFormData: true
|
|
155
|
-
},
|
|
156
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
157
|
-
);
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
/** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
|
|
161
|
-
* keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
|
|
162
|
-
* from the keyed data
|
|
163
|
-
*
|
|
164
|
-
* @param index - The index at which the remove button is clicked
|
|
165
|
-
*/
|
|
166
|
-
this.onDropIndexClick = (index) => {
|
|
167
|
-
return (event) => {
|
|
168
|
-
if (event) {
|
|
169
|
-
event.preventDefault();
|
|
170
|
-
}
|
|
171
|
-
const { onChange, errorSchema } = this.props;
|
|
172
|
-
const { keyedFormData } = this.state;
|
|
173
|
-
let newErrorSchema;
|
|
174
|
-
if (errorSchema) {
|
|
175
|
-
newErrorSchema = {};
|
|
176
|
-
for (const idx in errorSchema) {
|
|
177
|
-
const i = parseInt(idx);
|
|
178
|
-
if (i < index) {
|
|
179
|
-
(0, import_set.default)(newErrorSchema, [i], errorSchema[idx]);
|
|
180
|
-
} else if (i > index) {
|
|
181
|
-
(0, import_set.default)(newErrorSchema, [i - 1], errorSchema[idx]);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
|
|
186
|
-
this.setState(
|
|
187
|
-
{
|
|
188
|
-
keyedFormData: newKeyedFormData,
|
|
189
|
-
updatedKeyedFormData: true
|
|
190
|
-
},
|
|
191
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
192
|
-
);
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
/** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
|
|
196
|
-
* row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
|
|
197
|
-
* plain form data converted from the keyed data
|
|
198
|
-
*
|
|
199
|
-
* @param index - The index of the item to move
|
|
200
|
-
* @param newIndex - The index to where the item is to be moved
|
|
201
|
-
*/
|
|
202
|
-
this.onReorderClick = (index, newIndex) => {
|
|
203
|
-
return (event) => {
|
|
204
|
-
if (event) {
|
|
205
|
-
event.preventDefault();
|
|
206
|
-
event.currentTarget.blur();
|
|
207
|
-
}
|
|
208
|
-
const { onChange, errorSchema } = this.props;
|
|
209
|
-
let newErrorSchema;
|
|
210
|
-
if (errorSchema) {
|
|
211
|
-
newErrorSchema = {};
|
|
212
|
-
for (const idx in errorSchema) {
|
|
213
|
-
const i = parseInt(idx);
|
|
214
|
-
if (i == index) {
|
|
215
|
-
(0, import_set.default)(newErrorSchema, [newIndex], errorSchema[index]);
|
|
216
|
-
} else if (i == newIndex) {
|
|
217
|
-
(0, import_set.default)(newErrorSchema, [index], errorSchema[newIndex]);
|
|
218
|
-
} else {
|
|
219
|
-
(0, import_set.default)(newErrorSchema, [idx], errorSchema[i]);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
const { keyedFormData } = this.state;
|
|
224
|
-
function reOrderArray() {
|
|
225
|
-
const _newKeyedFormData = keyedFormData.slice();
|
|
226
|
-
_newKeyedFormData.splice(index, 1);
|
|
227
|
-
_newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
|
|
228
|
-
return _newKeyedFormData;
|
|
229
|
-
}
|
|
230
|
-
const newKeyedFormData = reOrderArray();
|
|
231
|
-
this.setState(
|
|
232
|
-
{
|
|
233
|
-
keyedFormData: newKeyedFormData
|
|
234
|
-
},
|
|
235
|
-
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
236
|
-
);
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
/** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
|
|
240
|
-
* `onChange` callback with the updated form data
|
|
241
|
-
*
|
|
242
|
-
* @param index - The index of the item being changed
|
|
243
|
-
*/
|
|
244
|
-
this.onChangeForIndex = (index) => {
|
|
245
|
-
return (value, newErrorSchema, id) => {
|
|
246
|
-
const { formData, onChange, errorSchema } = this.props;
|
|
247
|
-
const arrayData = Array.isArray(formData) ? formData : [];
|
|
248
|
-
const newFormData = arrayData.map((item, i) => {
|
|
249
|
-
const jsonValue = typeof value === "undefined" ? null : value;
|
|
250
|
-
return index === i ? jsonValue : item;
|
|
251
|
-
});
|
|
252
|
-
onChange(
|
|
253
|
-
newFormData,
|
|
254
|
-
errorSchema && errorSchema && {
|
|
255
|
-
...errorSchema,
|
|
256
|
-
[index]: newErrorSchema
|
|
257
|
-
},
|
|
258
|
-
id
|
|
259
|
-
);
|
|
260
|
-
};
|
|
261
|
-
};
|
|
262
|
-
/** Callback handler used to change the value for a checkbox */
|
|
263
|
-
this.onSelectChange = (value) => {
|
|
264
|
-
const { onChange, idSchema } = this.props;
|
|
265
|
-
onChange(value, void 0, idSchema && idSchema.$id);
|
|
266
|
-
};
|
|
267
86
|
const { formData = [] } = props;
|
|
268
87
|
const keyedFormData = generateKeyedFormData(formData);
|
|
269
88
|
this.state = {
|
|
@@ -338,6 +157,18 @@ var ArrayField = class extends import_react.Component {
|
|
|
338
157
|
}
|
|
339
158
|
return addable;
|
|
340
159
|
}
|
|
160
|
+
/** Returns the default form information for an item based on the schema for that item. Deals with the possibility
|
|
161
|
+
* that the schema is fixed and allows additional items.
|
|
162
|
+
*/
|
|
163
|
+
_getNewFormDataRow = () => {
|
|
164
|
+
const { schema, registry } = this.props;
|
|
165
|
+
const { schemaUtils } = registry;
|
|
166
|
+
let itemSchema = schema.items;
|
|
167
|
+
if ((0, import_utils.isFixedItems)(schema) && (0, import_utils.allowAdditionalItems)(schema)) {
|
|
168
|
+
itemSchema = schema.additionalItems;
|
|
169
|
+
}
|
|
170
|
+
return schemaUtils.getDefaultFormState(itemSchema);
|
|
171
|
+
};
|
|
341
172
|
/** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
|
|
342
173
|
* either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
|
|
343
174
|
* the state, and then returning `onChange()` with the plain form data converted from the keyed data
|
|
@@ -381,6 +212,177 @@ var ArrayField = class extends import_react.Component {
|
|
|
381
212
|
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
382
213
|
);
|
|
383
214
|
}
|
|
215
|
+
/** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
|
|
216
|
+
* the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
|
|
217
|
+
* keyed data
|
|
218
|
+
*
|
|
219
|
+
* @param event - The event for the click
|
|
220
|
+
*/
|
|
221
|
+
onAddClick = (event) => {
|
|
222
|
+
this._handleAddClick(event);
|
|
223
|
+
};
|
|
224
|
+
/** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
|
|
225
|
+
* keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
|
|
226
|
+
* form data converted from the keyed data
|
|
227
|
+
*
|
|
228
|
+
* @param index - The index at which the add button is clicked
|
|
229
|
+
*/
|
|
230
|
+
onAddIndexClick = (index) => {
|
|
231
|
+
return (event) => {
|
|
232
|
+
this._handleAddClick(event, index);
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
/** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
|
|
236
|
+
* keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
|
|
237
|
+
* form data converted from the keyed data
|
|
238
|
+
*
|
|
239
|
+
* @param index - The index at which the copy button is clicked
|
|
240
|
+
*/
|
|
241
|
+
onCopyIndexClick = (index) => {
|
|
242
|
+
return (event) => {
|
|
243
|
+
if (event) {
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
}
|
|
246
|
+
const { onChange, errorSchema } = this.props;
|
|
247
|
+
const { keyedFormData } = this.state;
|
|
248
|
+
let newErrorSchema;
|
|
249
|
+
if (errorSchema) {
|
|
250
|
+
newErrorSchema = {};
|
|
251
|
+
for (const idx in errorSchema) {
|
|
252
|
+
const i = parseInt(idx);
|
|
253
|
+
if (i <= index) {
|
|
254
|
+
(0, import_set.default)(newErrorSchema, [i], errorSchema[idx]);
|
|
255
|
+
} else if (i > index) {
|
|
256
|
+
(0, import_set.default)(newErrorSchema, [i + 1], errorSchema[idx]);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const newKeyedFormDataRow = {
|
|
261
|
+
key: generateRowId(),
|
|
262
|
+
item: (0, import_cloneDeep.default)(keyedFormData[index].item)
|
|
263
|
+
};
|
|
264
|
+
const newKeyedFormData = [...keyedFormData];
|
|
265
|
+
if (index !== void 0) {
|
|
266
|
+
newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
|
|
267
|
+
} else {
|
|
268
|
+
newKeyedFormData.push(newKeyedFormDataRow);
|
|
269
|
+
}
|
|
270
|
+
this.setState(
|
|
271
|
+
{
|
|
272
|
+
keyedFormData: newKeyedFormData,
|
|
273
|
+
updatedKeyedFormData: true
|
|
274
|
+
},
|
|
275
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
/** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
|
|
280
|
+
* keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
|
|
281
|
+
* from the keyed data
|
|
282
|
+
*
|
|
283
|
+
* @param index - The index at which the remove button is clicked
|
|
284
|
+
*/
|
|
285
|
+
onDropIndexClick = (index) => {
|
|
286
|
+
return (event) => {
|
|
287
|
+
if (event) {
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
}
|
|
290
|
+
const { onChange, errorSchema } = this.props;
|
|
291
|
+
const { keyedFormData } = this.state;
|
|
292
|
+
let newErrorSchema;
|
|
293
|
+
if (errorSchema) {
|
|
294
|
+
newErrorSchema = {};
|
|
295
|
+
for (const idx in errorSchema) {
|
|
296
|
+
const i = parseInt(idx);
|
|
297
|
+
if (i < index) {
|
|
298
|
+
(0, import_set.default)(newErrorSchema, [i], errorSchema[idx]);
|
|
299
|
+
} else if (i > index) {
|
|
300
|
+
(0, import_set.default)(newErrorSchema, [i - 1], errorSchema[idx]);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
|
|
305
|
+
this.setState(
|
|
306
|
+
{
|
|
307
|
+
keyedFormData: newKeyedFormData,
|
|
308
|
+
updatedKeyedFormData: true
|
|
309
|
+
},
|
|
310
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
311
|
+
);
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
/** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
|
|
315
|
+
* row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
|
|
316
|
+
* plain form data converted from the keyed data
|
|
317
|
+
*
|
|
318
|
+
* @param index - The index of the item to move
|
|
319
|
+
* @param newIndex - The index to where the item is to be moved
|
|
320
|
+
*/
|
|
321
|
+
onReorderClick = (index, newIndex) => {
|
|
322
|
+
return (event) => {
|
|
323
|
+
if (event) {
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
event.currentTarget.blur();
|
|
326
|
+
}
|
|
327
|
+
const { onChange, errorSchema } = this.props;
|
|
328
|
+
let newErrorSchema;
|
|
329
|
+
if (errorSchema) {
|
|
330
|
+
newErrorSchema = {};
|
|
331
|
+
for (const idx in errorSchema) {
|
|
332
|
+
const i = parseInt(idx);
|
|
333
|
+
if (i == index) {
|
|
334
|
+
(0, import_set.default)(newErrorSchema, [newIndex], errorSchema[index]);
|
|
335
|
+
} else if (i == newIndex) {
|
|
336
|
+
(0, import_set.default)(newErrorSchema, [index], errorSchema[newIndex]);
|
|
337
|
+
} else {
|
|
338
|
+
(0, import_set.default)(newErrorSchema, [idx], errorSchema[i]);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const { keyedFormData } = this.state;
|
|
343
|
+
function reOrderArray() {
|
|
344
|
+
const _newKeyedFormData = keyedFormData.slice();
|
|
345
|
+
_newKeyedFormData.splice(index, 1);
|
|
346
|
+
_newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
|
|
347
|
+
return _newKeyedFormData;
|
|
348
|
+
}
|
|
349
|
+
const newKeyedFormData = reOrderArray();
|
|
350
|
+
this.setState(
|
|
351
|
+
{
|
|
352
|
+
keyedFormData: newKeyedFormData
|
|
353
|
+
},
|
|
354
|
+
() => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
|
|
355
|
+
);
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
/** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
|
|
359
|
+
* `onChange` callback with the updated form data
|
|
360
|
+
*
|
|
361
|
+
* @param index - The index of the item being changed
|
|
362
|
+
*/
|
|
363
|
+
onChangeForIndex = (index) => {
|
|
364
|
+
return (value, newErrorSchema, id) => {
|
|
365
|
+
const { formData, onChange, errorSchema } = this.props;
|
|
366
|
+
const arrayData = Array.isArray(formData) ? formData : [];
|
|
367
|
+
const newFormData = arrayData.map((item, i) => {
|
|
368
|
+
const jsonValue = typeof value === "undefined" ? null : value;
|
|
369
|
+
return index === i ? jsonValue : item;
|
|
370
|
+
});
|
|
371
|
+
onChange(
|
|
372
|
+
newFormData,
|
|
373
|
+
errorSchema && errorSchema && {
|
|
374
|
+
...errorSchema,
|
|
375
|
+
[index]: newErrorSchema
|
|
376
|
+
},
|
|
377
|
+
id
|
|
378
|
+
);
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
/** Callback handler used to change the value for a checkbox */
|
|
382
|
+
onSelectChange = (value) => {
|
|
383
|
+
const { onChange, idSchema } = this.props;
|
|
384
|
+
onChange(value, void 0, idSchema && idSchema.$id);
|
|
385
|
+
};
|
|
384
386
|
/** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
|
|
385
387
|
*/
|
|
386
388
|
render() {
|
|
@@ -475,7 +477,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
475
477
|
totalItems: keyedFormData.length
|
|
476
478
|
});
|
|
477
479
|
}),
|
|
478
|
-
className: `field field-array field-array-of-${itemsSchema.type}`,
|
|
480
|
+
className: `rjsf-field rjsf-field-array rjsf-field-array-of-${itemsSchema.type}`,
|
|
479
481
|
disabled,
|
|
480
482
|
idSchema,
|
|
481
483
|
uiSchema,
|
|
@@ -683,7 +685,7 @@ var ArrayField = class extends import_react.Component {
|
|
|
683
685
|
const canAdd = this.canAddItem(items) && !!additionalSchema;
|
|
684
686
|
const arrayProps = {
|
|
685
687
|
canAdd,
|
|
686
|
-
className: "field field-array field-array-fixed-items",
|
|
688
|
+
className: "rjsf-field rjsf-field-array rjsf-field-array-fixed-items",
|
|
687
689
|
disabled,
|
|
688
690
|
idSchema,
|
|
689
691
|
formData,
|
|
@@ -764,14 +766,14 @@ var ArrayField = class extends import_react.Component {
|
|
|
764
766
|
} = registry;
|
|
765
767
|
const ItemSchemaField = ArraySchemaField || SchemaField2;
|
|
766
768
|
const { orderable = true, removable = true, copyable = false } = (0, import_utils.getUiOptions)(uiSchema, globalUiOptions);
|
|
767
|
-
const
|
|
769
|
+
const has4 = {
|
|
768
770
|
moveUp: orderable && canMoveUp,
|
|
769
771
|
moveDown: orderable && canMoveDown,
|
|
770
772
|
copy: copyable && canAdd,
|
|
771
773
|
remove: removable && canRemove,
|
|
772
774
|
toolbar: false
|
|
773
775
|
};
|
|
774
|
-
|
|
776
|
+
has4.toolbar = Object.keys(has4).some((key2) => has4[key2]);
|
|
775
777
|
return {
|
|
776
778
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
777
779
|
ItemSchemaField,
|
|
@@ -799,21 +801,31 @@ var ArrayField = class extends import_react.Component {
|
|
|
799
801
|
rawErrors
|
|
800
802
|
}
|
|
801
803
|
),
|
|
802
|
-
|
|
804
|
+
buttonsProps: {
|
|
805
|
+
idSchema: itemIdSchema,
|
|
806
|
+
disabled,
|
|
807
|
+
readonly,
|
|
808
|
+
canAdd,
|
|
809
|
+
hasCopy: has4.copy,
|
|
810
|
+
hasMoveUp: has4.moveUp,
|
|
811
|
+
hasMoveDown: has4.moveDown,
|
|
812
|
+
hasRemove: has4.remove,
|
|
813
|
+
index,
|
|
814
|
+
totalItems,
|
|
815
|
+
onAddIndexClick: this.onAddIndexClick,
|
|
816
|
+
onCopyIndexClick: this.onCopyIndexClick,
|
|
817
|
+
onDropIndexClick: this.onDropIndexClick,
|
|
818
|
+
onReorderClick: this.onReorderClick,
|
|
819
|
+
registry,
|
|
820
|
+
schema: itemSchema,
|
|
821
|
+
uiSchema: itemUiSchema
|
|
822
|
+
},
|
|
823
|
+
className: "rjsf-array-item",
|
|
803
824
|
disabled,
|
|
804
|
-
|
|
805
|
-
hasCopy: has2.copy,
|
|
806
|
-
hasToolbar: has2.toolbar,
|
|
807
|
-
hasMoveUp: has2.moveUp,
|
|
808
|
-
hasMoveDown: has2.moveDown,
|
|
809
|
-
hasRemove: has2.remove,
|
|
825
|
+
hasToolbar: has4.toolbar,
|
|
810
826
|
index,
|
|
811
827
|
totalItems,
|
|
812
828
|
key,
|
|
813
|
-
onAddIndexClick: this.onAddIndexClick,
|
|
814
|
-
onCopyIndexClick: this.onCopyIndexClick,
|
|
815
|
-
onDropIndexClick: this.onDropIndexClick,
|
|
816
|
-
onReorderClick: this.onReorderClick,
|
|
817
829
|
readonly,
|
|
818
830
|
registry,
|
|
819
831
|
schema: itemSchema,
|
|
@@ -825,7 +837,7 @@ var ArrayField_default = ArrayField;
|
|
|
825
837
|
|
|
826
838
|
// src/components/fields/BooleanField.tsx
|
|
827
839
|
var import_utils2 = require("@rjsf/utils");
|
|
828
|
-
var import_isObject2 = __toESM(require("lodash/isObject"));
|
|
840
|
+
var import_isObject2 = __toESM(require("lodash/isObject"), 1);
|
|
829
841
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
830
842
|
function BooleanField(props) {
|
|
831
843
|
const {
|
|
@@ -853,6 +865,7 @@ function BooleanField(props) {
|
|
|
853
865
|
title: uiTitle,
|
|
854
866
|
// Unlike the other fields, don't use `getDisplayLabel()` since it always returns false for the boolean type
|
|
855
867
|
label: displayLabel = true,
|
|
868
|
+
enumNames,
|
|
856
869
|
...options
|
|
857
870
|
} = (0, import_utils2.getUiOptions)(uiSchema, globalUiOptions);
|
|
858
871
|
const Widget = (0, import_utils2.getWidget)(schema, widget, widgets2);
|
|
@@ -877,9 +890,8 @@ function BooleanField(props) {
|
|
|
877
890
|
uiSchema
|
|
878
891
|
);
|
|
879
892
|
} else {
|
|
880
|
-
const schemaWithEnumNames = schema;
|
|
881
893
|
const enums = schema.enum ?? [true, false];
|
|
882
|
-
if (!
|
|
894
|
+
if (!enumNames && enums.length === 2 && enums.every((v) => typeof v === "boolean")) {
|
|
883
895
|
enumOptions = [
|
|
884
896
|
{
|
|
885
897
|
value: enums[0],
|
|
@@ -891,14 +903,7 @@ function BooleanField(props) {
|
|
|
891
903
|
}
|
|
892
904
|
];
|
|
893
905
|
} else {
|
|
894
|
-
enumOptions = (0, import_utils2.optionsList)(
|
|
895
|
-
{
|
|
896
|
-
enum: enums,
|
|
897
|
-
// NOTE: enumNames is deprecated, but still supported for now.
|
|
898
|
-
enumNames: schemaWithEnumNames.enumNames
|
|
899
|
-
},
|
|
900
|
-
uiSchema
|
|
901
|
-
);
|
|
906
|
+
enumOptions = (0, import_utils2.optionsList)({ enum: enums }, uiSchema);
|
|
902
907
|
}
|
|
903
908
|
}
|
|
904
909
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -928,213 +933,935 @@ function BooleanField(props) {
|
|
|
928
933
|
}
|
|
929
934
|
var BooleanField_default = BooleanField;
|
|
930
935
|
|
|
931
|
-
// src/components/fields/
|
|
936
|
+
// src/components/fields/LayoutGridField.tsx
|
|
932
937
|
var import_react2 = require("react");
|
|
933
|
-
var import_get2 = __toESM(require("lodash/get"));
|
|
934
|
-
var import_isEmpty = __toESM(require("lodash/isEmpty"));
|
|
935
|
-
var import_omit = __toESM(require("lodash/omit"));
|
|
936
938
|
var import_utils3 = require("@rjsf/utils");
|
|
939
|
+
var import_cloneDeep2 = __toESM(require("lodash/cloneDeep"), 1);
|
|
940
|
+
var import_each = __toESM(require("lodash/each"), 1);
|
|
941
|
+
var import_flatten = __toESM(require("lodash/flatten"), 1);
|
|
942
|
+
var import_get2 = __toESM(require("lodash/get"), 1);
|
|
943
|
+
var import_has = __toESM(require("lodash/has"), 1);
|
|
944
|
+
var import_includes = __toESM(require("lodash/includes"), 1);
|
|
945
|
+
var import_intersection = __toESM(require("lodash/intersection"), 1);
|
|
946
|
+
var import_isEmpty = __toESM(require("lodash/isEmpty"), 1);
|
|
947
|
+
var import_isFunction = __toESM(require("lodash/isFunction"), 1);
|
|
948
|
+
var import_isEqual = __toESM(require("lodash/isEqual"), 1);
|
|
949
|
+
var import_isObject3 = __toESM(require("lodash/isObject"), 1);
|
|
950
|
+
var import_isPlainObject = __toESM(require("lodash/isPlainObject"), 1);
|
|
951
|
+
var import_isString = __toESM(require("lodash/isString"), 1);
|
|
952
|
+
var import_isUndefined = __toESM(require("lodash/isUndefined"), 1);
|
|
953
|
+
var import_set2 = __toESM(require("lodash/set"), 1);
|
|
937
954
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
938
|
-
var
|
|
939
|
-
|
|
955
|
+
var import_react3 = require("react");
|
|
956
|
+
var LOOKUP_REGEX = /^\$lookup=(.+)/;
|
|
957
|
+
var LAYOUT_GRID_UI_OPTION = "layoutGrid";
|
|
958
|
+
var LAYOUT_GRID_OPTION = `ui:${LAYOUT_GRID_UI_OPTION}`;
|
|
959
|
+
var UI_GLOBAL_OPTIONS = "ui:global_options";
|
|
960
|
+
function getNonNullishValue(value, fallback) {
|
|
961
|
+
return value ?? fallback;
|
|
962
|
+
}
|
|
963
|
+
var LayoutGridField = class _LayoutGridField extends import_react2.PureComponent {
|
|
964
|
+
static defaultProps = {
|
|
965
|
+
layoutGridSchema: void 0
|
|
966
|
+
};
|
|
967
|
+
static TEST_IDS = (0, import_utils3.getTestIds)();
|
|
968
|
+
/** Computes the uiSchema for the field with `name` from the `uiProps` and `uiSchema` provided. The field UI Schema
|
|
969
|
+
* will always contain a copy of the global options from the `uiSchema` (so they can be passed down) as well as
|
|
970
|
+
* copying them into the local ui options. When the `forceReadonly` flag is true, then the field UI Schema is
|
|
971
|
+
* updated to make "readonly" be true. When the `schemaReadonly` flag is true AND the field UI Schema does NOT have
|
|
972
|
+
* the flag already provided, then we also make "readonly" true. We always make sure to return the final value of the
|
|
973
|
+
* field UI Schema's "readonly" flag as `uiReadonly` along with the `fieldUiSchema` in the return value.
|
|
940
974
|
*
|
|
941
|
-
* @param
|
|
975
|
+
* @param field - The name of the field to pull the existing UI Schema for
|
|
976
|
+
* @param uiProps - Any props that should be put into the field's uiSchema
|
|
977
|
+
* @param [uiSchema] - The optional UI Schema from which to get the UI schema for the field
|
|
978
|
+
* @param [schemaReadonly] - Optional flag indicating whether the schema indicates the field is readonly
|
|
979
|
+
* @param [forceReadonly] - Optional flag indicating whether the Form itself is in readonly mode
|
|
942
980
|
*/
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
962
|
-
if (newFormData && newOption) {
|
|
963
|
-
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
981
|
+
static computeFieldUiSchema(field, uiProps, uiSchema, schemaReadonly, forceReadonly) {
|
|
982
|
+
const globalUiOptions = (0, import_get2.default)(uiSchema, [UI_GLOBAL_OPTIONS], {});
|
|
983
|
+
const localUiSchema = (0, import_get2.default)(uiSchema, field);
|
|
984
|
+
const localUiOptions = { ...(0, import_get2.default)(localUiSchema, [import_utils3.UI_OPTIONS_KEY], {}), ...uiProps, ...globalUiOptions };
|
|
985
|
+
const fieldUiSchema = { ...localUiSchema };
|
|
986
|
+
if (!(0, import_isEmpty.default)(localUiOptions)) {
|
|
987
|
+
(0, import_set2.default)(fieldUiSchema, [import_utils3.UI_OPTIONS_KEY], localUiOptions);
|
|
988
|
+
}
|
|
989
|
+
if (!(0, import_isEmpty.default)(globalUiOptions)) {
|
|
990
|
+
(0, import_set2.default)(fieldUiSchema, [UI_GLOBAL_OPTIONS], globalUiOptions);
|
|
991
|
+
}
|
|
992
|
+
let { readonly: uiReadonly } = (0, import_utils3.getUiOptions)(fieldUiSchema);
|
|
993
|
+
if (forceReadonly === true || (0, import_isUndefined.default)(uiReadonly) && schemaReadonly === true) {
|
|
994
|
+
uiReadonly = true;
|
|
995
|
+
if ((0, import_has.default)(localUiOptions, import_utils3.READONLY_KEY)) {
|
|
996
|
+
(0, import_set2.default)(fieldUiSchema, [import_utils3.UI_OPTIONS_KEY, import_utils3.READONLY_KEY], true);
|
|
997
|
+
} else {
|
|
998
|
+
(0, import_set2.default)(fieldUiSchema, `ui:${import_utils3.READONLY_KEY}`, true);
|
|
964
999
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
};
|
|
968
|
-
const {
|
|
969
|
-
formData,
|
|
970
|
-
options,
|
|
971
|
-
registry: { schemaUtils }
|
|
972
|
-
} = this.props;
|
|
973
|
-
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
974
|
-
this.state = {
|
|
975
|
-
retrievedOptions,
|
|
976
|
-
selectedOption: this.getMatchingOption(0, formData, retrievedOptions)
|
|
977
|
-
};
|
|
1000
|
+
}
|
|
1001
|
+
return { fieldUiSchema, uiReadonly };
|
|
978
1002
|
}
|
|
979
|
-
/**
|
|
980
|
-
*
|
|
1003
|
+
/** Given an `operator`, `datum` and `value` determines whether this condition is considered matching. Matching
|
|
1004
|
+
* depends on the `operator`. The `datum` and `value` are converted into arrays if they aren't already and then the
|
|
1005
|
+
* contents of the two arrays are compared using the `operator`. When `operator` is All, then the two arrays must be
|
|
1006
|
+
* equal to match. When `operator` is SOME then the intersection of the two arrays must have at least one value in
|
|
1007
|
+
* common to match. When `operator` is NONE then the intersection of the two arrays must not have any values in common
|
|
1008
|
+
* to match.
|
|
981
1009
|
*
|
|
982
|
-
* @param
|
|
983
|
-
* @param
|
|
1010
|
+
* @param [operator] - The optional operator for the condition
|
|
1011
|
+
* @param [datum] - The optional datum for the condition, this can be an item or a list of items of type unknown
|
|
1012
|
+
* @param [value='$0m3tH1nG Un3xP3cT3d'] The optional value for the condition, defaulting to a highly unlikely value
|
|
1013
|
+
* to avoid comparing two undefined elements when `value` was forgotten in the condition definition.
|
|
1014
|
+
* This can be an item or a list of items of type unknown
|
|
1015
|
+
* @returns - True if the condition matches, false otherwise
|
|
984
1016
|
*/
|
|
985
|
-
|
|
986
|
-
const
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1017
|
+
static conditionMatches(operator, datum, value = "$0m3tH1nG Un3xP3cT3d") {
|
|
1018
|
+
const data = (0, import_flatten.default)([datum]).sort();
|
|
1019
|
+
const values = (0, import_flatten.default)([value]).sort();
|
|
1020
|
+
switch (operator) {
|
|
1021
|
+
case "all" /* ALL */:
|
|
1022
|
+
return (0, import_isEqual.default)(data, values);
|
|
1023
|
+
case "some" /* SOME */:
|
|
1024
|
+
return (0, import_intersection.default)(data, values).length > 0;
|
|
1025
|
+
case "none" /* NONE */:
|
|
1026
|
+
return (0, import_intersection.default)(data, values).length === 0;
|
|
1027
|
+
default:
|
|
1028
|
+
return false;
|
|
995
1029
|
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1030
|
+
}
|
|
1031
|
+
/** From within the `layoutGridSchema` finds the `children` and any extra `gridProps` from the object keyed by
|
|
1032
|
+
* `schemaKey`. If the `children` contains extra `gridProps` and those props contain a `className` string, try to
|
|
1033
|
+
* lookup whether that `className` has a replacement value in the `registry` using the `FORM_CONTEXT_LOOKUP_BASE`.
|
|
1034
|
+
* When the `className` value contains multiple classNames separated by a space, the lookup will look for a
|
|
1035
|
+
* replacement value for each `className` and combine them into one.
|
|
1036
|
+
*
|
|
1037
|
+
* @param layoutGridSchema - The GridSchemaType instance from which to obtain the `schemaKey` children and extra props
|
|
1038
|
+
* @param schemaKey - A `GridType` value, used to get the children and extra props from within the `layoutGridSchema`
|
|
1039
|
+
* @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
|
|
1040
|
+
* @returns - An object containing the list of `LayoutGridSchemaType` `children` and any extra `gridProps`
|
|
1041
|
+
* @throws - A `TypeError` when the `children` is not an array
|
|
1042
|
+
*/
|
|
1043
|
+
static findChildrenAndProps(layoutGridSchema, schemaKey, registry) {
|
|
1044
|
+
let gridProps = {};
|
|
1045
|
+
let children = layoutGridSchema[schemaKey];
|
|
1046
|
+
if ((0, import_isPlainObject.default)(children)) {
|
|
1047
|
+
const { children: elements, className: toMapClassNames, ...otherProps } = children;
|
|
1048
|
+
children = elements;
|
|
1049
|
+
if (toMapClassNames) {
|
|
1050
|
+
const classes = toMapClassNames.split(" ");
|
|
1051
|
+
const className = classes.map((ele) => (0, import_utils3.lookupFromFormContext)(registry, ele, ele)).join(" ");
|
|
1052
|
+
gridProps = { ...otherProps, className };
|
|
1053
|
+
} else {
|
|
1054
|
+
gridProps = otherProps;
|
|
1001
1055
|
}
|
|
1002
1056
|
}
|
|
1003
|
-
if (
|
|
1004
|
-
|
|
1057
|
+
if (!Array.isArray(children)) {
|
|
1058
|
+
throw new TypeError(`Expected array for "${schemaKey}" in ${JSON.stringify(layoutGridSchema)}`);
|
|
1005
1059
|
}
|
|
1060
|
+
return { children, gridProps };
|
|
1006
1061
|
}
|
|
1007
|
-
/**
|
|
1062
|
+
/** Generates an idSchema for the `schema` using `@rjsf`'s `toIdSchema` util, passing the `baseIdSchema`'s `$id` value
|
|
1063
|
+
* as the id prefix.
|
|
1008
1064
|
*
|
|
1009
|
-
* @param
|
|
1010
|
-
* @param
|
|
1011
|
-
* @
|
|
1065
|
+
* @param schemaUtils - The `SchemaUtilsType` used to call `toIdSchema`
|
|
1066
|
+
* @param schema - The schema to generate the idSchema for
|
|
1067
|
+
* @param baseIdSchema - The IdSchema for the base
|
|
1068
|
+
* @param formData - The formData to pass the `toIdSchema`
|
|
1069
|
+
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
1070
|
+
* @returns - The generated `idSchema` for the `schema`
|
|
1012
1071
|
*/
|
|
1013
|
-
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
registry: { schemaUtils }
|
|
1017
|
-
} = this.props;
|
|
1018
|
-
const discriminator = (0, import_utils3.getDiscriminatorFieldFromSchema)(schema);
|
|
1019
|
-
const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
|
|
1020
|
-
return option;
|
|
1072
|
+
static getIdSchema(schemaUtils, baseIdSchema, formData, schema = {}, idSeparator) {
|
|
1073
|
+
const baseId = (0, import_get2.default)(baseIdSchema, import_utils3.ID_KEY);
|
|
1074
|
+
return schemaUtils.toIdSchema(schema, baseId, formData, baseId, idSeparator);
|
|
1021
1075
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1076
|
+
/** Given a `dottedPath` to a field in the `initialSchema`, iterate through each individual path in the schema until
|
|
1077
|
+
* the leaf path is found and returned (along with whether that leaf path `isRequired`) OR no schema exists for an
|
|
1078
|
+
* element in the path. If the leaf schema element happens to be a oneOf/anyOf then also return the oneOf/anyOf as
|
|
1079
|
+
* `options`.
|
|
1080
|
+
*
|
|
1081
|
+
* @param schemaUtils - The `SchemaUtilsType` used to call `retrieveSchema`
|
|
1082
|
+
* @param dottedPath - The dotted-path to the field for which to get the schema
|
|
1083
|
+
* @param initialSchema - The initial schema to start the search from
|
|
1084
|
+
* @param formData - The formData, useful for resolving a oneOf/anyOf selection in the path hierarchy
|
|
1085
|
+
* @param initialIdSchema - The initial idSchema to start the search from
|
|
1086
|
+
* @param [idSeparator] - The param to pass into the `toIdSchema` util which will use it to join the `idSchema` paths
|
|
1087
|
+
* @returns - An object containing the destination schema, isRequired and isReadonly flags for the field and options
|
|
1088
|
+
* info if a oneOf/anyOf
|
|
1027
1089
|
*/
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
schema,
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
const rawErrors = (0, import_get2.default)(errorSchema, import_utils3.ERRORS_KEY, []);
|
|
1053
|
-
const fieldErrorSchema = (0, import_omit.default)(errorSchema, [import_utils3.ERRORS_KEY]);
|
|
1054
|
-
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1055
|
-
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1056
|
-
let optionSchema;
|
|
1057
|
-
if (option) {
|
|
1058
|
-
const { required } = schema;
|
|
1059
|
-
optionSchema = required ? (0, import_utils3.mergeSchemas)({ required }, option) : option;
|
|
1060
|
-
}
|
|
1061
|
-
let optionsUiSchema = [];
|
|
1062
|
-
if (import_utils3.ONE_OF_KEY in schema && uiSchema && import_utils3.ONE_OF_KEY in uiSchema) {
|
|
1063
|
-
if (Array.isArray(uiSchema[import_utils3.ONE_OF_KEY])) {
|
|
1064
|
-
optionsUiSchema = uiSchema[import_utils3.ONE_OF_KEY];
|
|
1090
|
+
static getSchemaDetailsForField(schemaUtils, dottedPath, initialSchema, formData, initialIdSchema, idSeparator) {
|
|
1091
|
+
let rawSchema = initialSchema;
|
|
1092
|
+
let idSchema = initialIdSchema;
|
|
1093
|
+
const parts = dottedPath.split(".");
|
|
1094
|
+
const leafPath = parts.pop();
|
|
1095
|
+
let schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1096
|
+
let innerData = formData;
|
|
1097
|
+
let isReadonly = schema.readOnly;
|
|
1098
|
+
parts.forEach((part) => {
|
|
1099
|
+
if ((0, import_has.default)(schema, import_utils3.PROPERTIES_KEY)) {
|
|
1100
|
+
rawSchema = (0, import_get2.default)(schema, [import_utils3.PROPERTIES_KEY, part], {});
|
|
1101
|
+
idSchema = (0, import_get2.default)(idSchema, part, {});
|
|
1102
|
+
} else if (schema && ((0, import_has.default)(schema, import_utils3.ONE_OF_KEY) || (0, import_has.default)(schema, import_utils3.ANY_OF_KEY))) {
|
|
1103
|
+
const xxx = (0, import_has.default)(schema, import_utils3.ONE_OF_KEY) ? import_utils3.ONE_OF_KEY : import_utils3.ANY_OF_KEY;
|
|
1104
|
+
const selectedSchema = schemaUtils.findSelectedOptionInXxxOf(schema, part, xxx, innerData);
|
|
1105
|
+
const selectedIdSchema = _LayoutGridField.getIdSchema(
|
|
1106
|
+
schemaUtils,
|
|
1107
|
+
idSchema,
|
|
1108
|
+
formData,
|
|
1109
|
+
selectedSchema,
|
|
1110
|
+
idSeparator
|
|
1111
|
+
);
|
|
1112
|
+
rawSchema = (0, import_get2.default)(selectedSchema, [import_utils3.PROPERTIES_KEY, part], {});
|
|
1113
|
+
idSchema = (0, import_get2.default)(selectedIdSchema, part, {});
|
|
1065
1114
|
} else {
|
|
1066
|
-
|
|
1115
|
+
rawSchema = {};
|
|
1067
1116
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1117
|
+
innerData = (0, import_get2.default)(innerData, part, {});
|
|
1118
|
+
schema = schemaUtils.retrieveSchema(rawSchema, innerData);
|
|
1119
|
+
isReadonly = getNonNullishValue(schema.readOnly, isReadonly);
|
|
1120
|
+
});
|
|
1121
|
+
let optionsInfo;
|
|
1122
|
+
let isRequired = false;
|
|
1123
|
+
if ((0, import_isEmpty.default)(schema)) {
|
|
1124
|
+
schema = void 0;
|
|
1125
|
+
}
|
|
1126
|
+
if (schema && leafPath) {
|
|
1127
|
+
if (schema && ((0, import_has.default)(schema, import_utils3.ONE_OF_KEY) || (0, import_has.default)(schema, import_utils3.ANY_OF_KEY))) {
|
|
1128
|
+
const xxx = (0, import_has.default)(schema, import_utils3.ONE_OF_KEY) ? import_utils3.ONE_OF_KEY : import_utils3.ANY_OF_KEY;
|
|
1129
|
+
schema = schemaUtils.findSelectedOptionInXxxOf(schema, leafPath, xxx, innerData);
|
|
1130
|
+
const rawIdSchema = _LayoutGridField.getIdSchema(schemaUtils, idSchema, formData, schema, idSeparator);
|
|
1131
|
+
idSchema = (0, import_utils3.mergeObjects)(rawIdSchema, idSchema);
|
|
1132
|
+
}
|
|
1133
|
+
isRequired = schema !== void 0 && Array.isArray(schema.required) && (0, import_includes.default)(schema.required, leafPath);
|
|
1134
|
+
schema = (0, import_get2.default)(schema, [import_utils3.PROPERTIES_KEY, leafPath]);
|
|
1135
|
+
schema = schema ? schemaUtils.retrieveSchema(schema) : schema;
|
|
1136
|
+
idSchema = (0, import_get2.default)(idSchema, leafPath, {});
|
|
1137
|
+
isReadonly = getNonNullishValue(schema?.readOnly, isReadonly);
|
|
1138
|
+
if (schema && ((0, import_has.default)(schema, import_utils3.ONE_OF_KEY) || (0, import_has.default)(schema, import_utils3.ANY_OF_KEY))) {
|
|
1139
|
+
const xxx = (0, import_has.default)(schema, import_utils3.ONE_OF_KEY) ? import_utils3.ONE_OF_KEY : import_utils3.ANY_OF_KEY;
|
|
1140
|
+
const discriminator = (0, import_utils3.getDiscriminatorFieldFromSchema)(schema);
|
|
1141
|
+
optionsInfo = { options: schema[xxx], hasDiscriminator: !!discriminator };
|
|
1073
1142
|
}
|
|
1074
1143
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1144
|
+
return { schema, isRequired, isReadonly, optionsInfo, idSchema };
|
|
1145
|
+
}
|
|
1146
|
+
/** Gets the custom render component from the `render`, by either determining that it is either already a function or
|
|
1147
|
+
* it is a non-function value that can be used to look up the function in the registry. If no function can be found,
|
|
1148
|
+
* null is returned.
|
|
1149
|
+
*
|
|
1150
|
+
* @param render - The potential render function or lookup name to one
|
|
1151
|
+
* @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
|
|
1152
|
+
* @returns - Either a render function if available, or null if not
|
|
1153
|
+
*/
|
|
1154
|
+
static getCustomRenderComponent(render, registry) {
|
|
1155
|
+
let customRenderer = render;
|
|
1156
|
+
if ((0, import_isString.default)(customRenderer)) {
|
|
1157
|
+
customRenderer = (0, import_utils3.lookupFromFormContext)(registry, customRenderer);
|
|
1078
1158
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1159
|
+
if ((0, import_isFunction.default)(customRenderer)) {
|
|
1160
|
+
return customRenderer;
|
|
1161
|
+
}
|
|
1162
|
+
return null;
|
|
1163
|
+
}
|
|
1164
|
+
/** Extract the `name`, and optional `render` and all other props from the `gridSchema`. We look up the `render` to
|
|
1165
|
+
* see if can be resolved to a UIComponent. If `name` does not exist and there is an optional `render` UIComponent, we
|
|
1166
|
+
* set the `rendered` component with only specified props for that component in the object.
|
|
1167
|
+
*
|
|
1168
|
+
* @param registry - The `@rjsf` Registry from which to look up `classNames` if they are present in the extra props
|
|
1169
|
+
* @param gridSchema - The string or object that represents the configuration for the grid field
|
|
1170
|
+
* @returns - The UIComponentPropsType computed from the gridSchema
|
|
1171
|
+
*/
|
|
1172
|
+
static computeUIComponentPropsFromGridSchema(registry, gridSchema) {
|
|
1173
|
+
let name;
|
|
1174
|
+
let UIComponent = null;
|
|
1175
|
+
let uiProps = {};
|
|
1176
|
+
let rendered;
|
|
1177
|
+
if ((0, import_isString.default)(gridSchema) || (0, import_isUndefined.default)(gridSchema)) {
|
|
1178
|
+
name = gridSchema ?? "";
|
|
1179
|
+
} else {
|
|
1180
|
+
const { name: innerName, render, ...innerProps } = gridSchema;
|
|
1181
|
+
name = innerName;
|
|
1182
|
+
uiProps = innerProps;
|
|
1183
|
+
if (!(0, import_isEmpty.default)(uiProps)) {
|
|
1184
|
+
(0, import_each.default)(uiProps, (prop, key) => {
|
|
1185
|
+
if ((0, import_isString.default)(prop)) {
|
|
1186
|
+
const match = LOOKUP_REGEX.exec(prop);
|
|
1187
|
+
if (Array.isArray(match) && match.length > 1) {
|
|
1188
|
+
const name2 = match[1];
|
|
1189
|
+
uiProps[key] = (0, import_utils3.lookupFromFormContext)(registry, name2, name2);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
UIComponent = _LayoutGridField.getCustomRenderComponent(render, registry);
|
|
1195
|
+
if (!innerName && UIComponent) {
|
|
1196
|
+
rendered = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UIComponent, { ...innerProps, "data-testid": _LayoutGridField.TEST_IDS.uiComponent });
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return { name, UIComponent, uiProps, rendered };
|
|
1200
|
+
}
|
|
1201
|
+
/** Constructs an `LayoutGridField` with the given `props`
|
|
1202
|
+
*
|
|
1203
|
+
* @param props - The `LayoutGridField` for this template
|
|
1204
|
+
*/
|
|
1205
|
+
constructor(props) {
|
|
1206
|
+
super(props);
|
|
1207
|
+
}
|
|
1208
|
+
/** Generates an `onChange` handler for the field associated with the `dottedPath`. This handler will clone and update
|
|
1209
|
+
* the `formData` with the new `value` and the `errorSchema` if an `errSchema` is provided. After updating those two
|
|
1210
|
+
* elements, they will then be passed on to the `onChange` handler of the `LayoutFieldGrid`.
|
|
1211
|
+
*
|
|
1212
|
+
* @param dottedPath - The dotted-path to the field for which to generate the onChange handler
|
|
1213
|
+
* @returns - The `onChange` handling function for the `dottedPath` field
|
|
1214
|
+
*/
|
|
1215
|
+
onFieldChange = (dottedPath) => {
|
|
1216
|
+
return (value, errSchema, id) => {
|
|
1217
|
+
const { onChange, errorSchema, formData } = this.props;
|
|
1218
|
+
const newFormData = (0, import_cloneDeep2.default)(formData || {});
|
|
1219
|
+
let newErrorSchema = errorSchema;
|
|
1220
|
+
if (errSchema && errorSchema) {
|
|
1221
|
+
newErrorSchema = (0, import_cloneDeep2.default)(errorSchema);
|
|
1222
|
+
(0, import_set2.default)(newErrorSchema, dottedPath, errSchema);
|
|
1223
|
+
}
|
|
1224
|
+
(0, import_set2.default)(newFormData, dottedPath, value);
|
|
1225
|
+
onChange(newFormData, newErrorSchema, id);
|
|
1226
|
+
};
|
|
1227
|
+
};
|
|
1228
|
+
/** Renders the `children` of the `GridType.CONDITION` if it passes. The `layoutGridSchema` for the
|
|
1229
|
+
* `GridType.CONDITION` is separated into the `children` and other `gridProps`. The `gridProps` are used to extract
|
|
1230
|
+
* the `operator`, `field` and `value` of the condition. If the condition matches, then all of the `children` are
|
|
1231
|
+
* rendered, otherwise null is returned.
|
|
1232
|
+
*
|
|
1233
|
+
* @param layoutGridSchema - The string or object that represents the configuration for the grid field
|
|
1234
|
+
* @returns - The rendered the children for the `GridType.CONDITION` or null
|
|
1235
|
+
*/
|
|
1236
|
+
renderCondition(layoutGridSchema) {
|
|
1237
|
+
const { formData, registry } = this.props;
|
|
1238
|
+
const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
|
|
1239
|
+
layoutGridSchema,
|
|
1240
|
+
"ui:condition" /* CONDITION */,
|
|
1241
|
+
registry
|
|
1242
|
+
);
|
|
1243
|
+
const { operator, field = "", value } = gridProps;
|
|
1244
|
+
const fieldData = (0, import_get2.default)(formData, field, null);
|
|
1245
|
+
if (_LayoutGridField.conditionMatches(operator, fieldData, value)) {
|
|
1246
|
+
return this.renderChildren(children);
|
|
1247
|
+
}
|
|
1248
|
+
return null;
|
|
1249
|
+
}
|
|
1250
|
+
/** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMN` is separated
|
|
1251
|
+
* into the `children` and other `gridProps`. The `gridProps` will be spread onto the outer `GridTemplate`. Inside
|
|
1252
|
+
* the `GridTemplate` all the `children` are rendered.
|
|
1253
|
+
*
|
|
1254
|
+
* @param layoutGridSchema - The string or object that represents the configuration for the grid field
|
|
1255
|
+
* @returns - The rendered `GridTemplate` containing the children for the `GridType.COLUMN`
|
|
1256
|
+
*/
|
|
1257
|
+
renderCol(layoutGridSchema) {
|
|
1258
|
+
const { registry, uiSchema } = this.props;
|
|
1259
|
+
const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
|
|
1260
|
+
layoutGridSchema,
|
|
1261
|
+
"ui:col" /* COLUMN */,
|
|
1262
|
+
registry
|
|
1263
|
+
);
|
|
1264
|
+
const uiOptions = (0, import_utils3.getUiOptions)(uiSchema);
|
|
1265
|
+
const GridTemplate2 = (0, import_utils3.getTemplate)("GridTemplate", registry, uiOptions);
|
|
1266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GridTemplate2, { column: true, "data-testid": _LayoutGridField.TEST_IDS.col, ...gridProps, children: this.renderChildren(children) });
|
|
1267
|
+
}
|
|
1268
|
+
/** Renders a material-ui `GridTemplate` as an item. The `layoutGridSchema` for the `GridType.COLUMNS` is separated
|
|
1269
|
+
* into the `children` and other `gridProps`. The `children` is iterated on and `gridProps` will be spread onto the
|
|
1270
|
+
* outer `GridTemplate`. Each child will have their own rendered `GridTemplate`.
|
|
1271
|
+
*
|
|
1272
|
+
* @param layoutGridSchema - The string or object that represents the configuration for the grid field
|
|
1273
|
+
* @returns - The rendered `GridTemplate` containing the children for the `GridType.COLUMNS`
|
|
1274
|
+
*/
|
|
1275
|
+
renderColumns(layoutGridSchema) {
|
|
1276
|
+
const { registry, uiSchema } = this.props;
|
|
1277
|
+
const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
|
|
1278
|
+
layoutGridSchema,
|
|
1279
|
+
"ui:columns" /* COLUMNS */,
|
|
1280
|
+
registry
|
|
1281
|
+
);
|
|
1282
|
+
const uiOptions = (0, import_utils3.getUiOptions)(uiSchema);
|
|
1283
|
+
const GridTemplate2 = (0, import_utils3.getTemplate)("GridTemplate", registry, uiOptions);
|
|
1284
|
+
return children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1285
|
+
GridTemplate2,
|
|
1286
|
+
{
|
|
1287
|
+
column: true,
|
|
1288
|
+
"data-testid": _LayoutGridField.TEST_IDS.col,
|
|
1289
|
+
...gridProps,
|
|
1290
|
+
children: this.renderChildren([child])
|
|
1291
|
+
},
|
|
1292
|
+
`column-${(0, import_utils3.hashObject)(child)}`
|
|
1293
|
+
));
|
|
1294
|
+
}
|
|
1295
|
+
/** Renders a material-ui `GridTemplate` as a container. The
|
|
1296
|
+
* `layoutGridSchema` for the `GridType.ROW` is separated into the `children` and other `gridProps`. The `gridProps`
|
|
1297
|
+
* will be spread onto the outer `GridTemplate`. Inside of the `GridTemplate` all of the `children` are rendered.
|
|
1298
|
+
*
|
|
1299
|
+
* @param layoutGridSchema - The string or object that represents the configuration for the grid field
|
|
1300
|
+
* @returns - The rendered `GridTemplate` containing the children for the `GridType.ROW`
|
|
1301
|
+
*/
|
|
1302
|
+
renderRow(layoutGridSchema) {
|
|
1303
|
+
const { registry, uiSchema } = this.props;
|
|
1304
|
+
const { children, gridProps } = _LayoutGridField.findChildrenAndProps(
|
|
1305
|
+
layoutGridSchema,
|
|
1306
|
+
"ui:row" /* ROW */,
|
|
1307
|
+
registry
|
|
1308
|
+
);
|
|
1309
|
+
const uiOptions = (0, import_utils3.getUiOptions)(uiSchema);
|
|
1310
|
+
const GridTemplate2 = (0, import_utils3.getTemplate)("GridTemplate", registry, uiOptions);
|
|
1311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GridTemplate2, { ...gridProps, "data-testid": _LayoutGridField.TEST_IDS.row, children: this.renderChildren(children) });
|
|
1312
|
+
}
|
|
1313
|
+
/** Iterates through all the `childrenLayoutGridSchema`, rendering a nested `LayoutGridField` for each item in the
|
|
1314
|
+
* list, passing all the props for the current `LayoutGridField` along, updating the `schema` by calling
|
|
1315
|
+
* `retrieveSchema()` on it to resolve any `$ref`s. In addition to the updated `schema`, each item in
|
|
1316
|
+
* `childrenLayoutGridSchema` is passed as `layoutGridSchema`.
|
|
1317
|
+
*
|
|
1318
|
+
* @param childrenLayoutGridSchema - The list of strings or objects that represents the configurations for the
|
|
1319
|
+
* children fields
|
|
1320
|
+
* @returns - The nested `LayoutGridField`s
|
|
1321
|
+
*/
|
|
1322
|
+
renderChildren(childrenLayoutGridSchema) {
|
|
1323
|
+
const { registry, schema: rawSchema, formData } = this.props;
|
|
1324
|
+
const { schemaUtils } = registry;
|
|
1325
|
+
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1326
|
+
return childrenLayoutGridSchema.map((layoutGridSchema) => /* @__PURE__ */ (0, import_react3.createElement)(
|
|
1327
|
+
_LayoutGridField,
|
|
1328
|
+
{
|
|
1329
|
+
...this.props,
|
|
1330
|
+
key: `layoutGrid-${(0, import_utils3.hashObject)(layoutGridSchema)}`,
|
|
1331
|
+
schema,
|
|
1332
|
+
layoutGridSchema
|
|
1333
|
+
}
|
|
1334
|
+
));
|
|
1335
|
+
}
|
|
1336
|
+
/** Renders the field described by `gridSchema`. If `gridSchema` is not an object, then is will be assumed
|
|
1337
|
+
* to be the dotted-path to the field in the schema. Otherwise, we extract the `name`, and optional `render` and all
|
|
1338
|
+
* other props. If `name` does not exist and there is an optional `render`, we return the `render` component with only
|
|
1339
|
+
* specified props for that component. If `name` exists, we take the name, the initial & root schemas and the formData
|
|
1340
|
+
* and get the destination schema, is required state and optional oneOf/anyOf options for it. If the destination
|
|
1341
|
+
* schema was located along with oneOf/anyOf options then a `LayoutMultiSchemaField` will be rendered with the
|
|
1342
|
+
* `uiSchema`, `errorSchema`, `idSchema` and `formData` drilled down to the dotted-path field, spreading any other
|
|
1343
|
+
* props from `gridSchema` into the `ui:options`. If the destination schema located without any oneOf/anyOf options,
|
|
1344
|
+
* then a `SchemaField` will be rendered with the same props as mentioned in the previous sentence. If no destination
|
|
1345
|
+
* schema was located, but a custom render component was found, then it will be rendered with many of the non-event
|
|
1346
|
+
* handling props. If none of the previous render paths are valid, then a null is returned.
|
|
1347
|
+
*
|
|
1348
|
+
* @param gridSchema - The string or object that represents the configuration for the grid field
|
|
1349
|
+
* @returns - One of `LayoutMultiSchemaField`, `SchemaField`, a custom render component or null, depending
|
|
1350
|
+
*/
|
|
1351
|
+
renderField(gridSchema) {
|
|
1352
|
+
const {
|
|
1353
|
+
schema: initialSchema,
|
|
1354
|
+
uiSchema,
|
|
1355
|
+
errorSchema,
|
|
1356
|
+
idSchema,
|
|
1357
|
+
onBlur,
|
|
1358
|
+
onFocus,
|
|
1359
|
+
formData,
|
|
1360
|
+
readonly,
|
|
1361
|
+
registry,
|
|
1362
|
+
idSeparator,
|
|
1363
|
+
layoutGridSchema,
|
|
1364
|
+
// Used to pull this out of otherProps since we don't want to pass it through
|
|
1365
|
+
...otherProps
|
|
1366
|
+
} = this.props;
|
|
1367
|
+
const { fields: fields2, schemaUtils } = registry;
|
|
1368
|
+
const { SchemaField: SchemaField2, LayoutMultiSchemaField: LayoutMultiSchemaField2 } = fields2;
|
|
1369
|
+
const uiComponentProps = _LayoutGridField.computeUIComponentPropsFromGridSchema(registry, gridSchema);
|
|
1370
|
+
if (uiComponentProps.rendered) {
|
|
1371
|
+
return uiComponentProps.rendered;
|
|
1372
|
+
}
|
|
1373
|
+
const { name, UIComponent, uiProps } = uiComponentProps;
|
|
1374
|
+
const {
|
|
1375
|
+
schema,
|
|
1376
|
+
isRequired,
|
|
1377
|
+
isReadonly,
|
|
1378
|
+
optionsInfo,
|
|
1379
|
+
idSchema: fieldIdSchema
|
|
1380
|
+
} = _LayoutGridField.getSchemaDetailsForField(
|
|
1381
|
+
schemaUtils,
|
|
1382
|
+
name,
|
|
1383
|
+
initialSchema,
|
|
1384
|
+
formData,
|
|
1385
|
+
idSchema,
|
|
1386
|
+
idSeparator
|
|
1387
|
+
);
|
|
1388
|
+
if (schema) {
|
|
1389
|
+
const Field = optionsInfo?.hasDiscriminator ? LayoutMultiSchemaField2 : SchemaField2;
|
|
1390
|
+
const { fieldUiSchema, uiReadonly } = _LayoutGridField.computeFieldUiSchema(
|
|
1391
|
+
name,
|
|
1392
|
+
uiProps,
|
|
1393
|
+
uiSchema,
|
|
1394
|
+
isReadonly,
|
|
1395
|
+
readonly
|
|
1396
|
+
);
|
|
1397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1398
|
+
Field,
|
|
1399
|
+
{
|
|
1400
|
+
"data-testid": optionsInfo?.hasDiscriminator ? _LayoutGridField.TEST_IDS.layoutMultiSchemaField : _LayoutGridField.TEST_IDS.field,
|
|
1401
|
+
...otherProps,
|
|
1402
|
+
name,
|
|
1403
|
+
required: isRequired,
|
|
1404
|
+
readonly: uiReadonly,
|
|
1405
|
+
schema,
|
|
1406
|
+
uiSchema: fieldUiSchema,
|
|
1407
|
+
errorSchema: (0, import_get2.default)(errorSchema, name),
|
|
1408
|
+
idSchema: fieldIdSchema,
|
|
1409
|
+
idSeparator,
|
|
1410
|
+
formData: (0, import_get2.default)(formData, name),
|
|
1411
|
+
onChange: this.onFieldChange(name),
|
|
1412
|
+
onBlur,
|
|
1413
|
+
onFocus,
|
|
1414
|
+
options: optionsInfo?.options,
|
|
1415
|
+
registry
|
|
1416
|
+
}
|
|
1417
|
+
);
|
|
1418
|
+
}
|
|
1419
|
+
if (UIComponent) {
|
|
1420
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1421
|
+
UIComponent,
|
|
1422
|
+
{
|
|
1423
|
+
"data-testid": _LayoutGridField.TEST_IDS.uiComponent,
|
|
1424
|
+
...otherProps,
|
|
1425
|
+
name,
|
|
1426
|
+
required: isRequired,
|
|
1427
|
+
formData,
|
|
1428
|
+
readOnly: !!isReadonly || readonly,
|
|
1429
|
+
errorSchema,
|
|
1430
|
+
uiSchema,
|
|
1431
|
+
schema: initialSchema,
|
|
1432
|
+
idSchema,
|
|
1433
|
+
idSeparator,
|
|
1434
|
+
onBlur,
|
|
1435
|
+
onFocus,
|
|
1436
|
+
registry,
|
|
1437
|
+
...uiProps
|
|
1438
|
+
}
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
return null;
|
|
1442
|
+
}
|
|
1443
|
+
/** Renders the `LayoutGridField`. If there isn't a `layoutGridSchema` prop defined, then try pulling it out of the
|
|
1444
|
+
* `uiSchema` via `ui:LayoutGridField`. If `layoutGridSchema` is an object, then check to see if any of the properties
|
|
1445
|
+
* match one of the `GridType`s. If so, call the appropriate render function for the type. Otherwise, just call the
|
|
1446
|
+
* generic `renderField()` function with the `layoutGridSchema`.
|
|
1447
|
+
*
|
|
1448
|
+
* @returns - the rendered `LayoutGridField`
|
|
1449
|
+
*/
|
|
1450
|
+
render() {
|
|
1451
|
+
const { uiSchema } = this.props;
|
|
1452
|
+
let { layoutGridSchema } = this.props;
|
|
1453
|
+
const uiOptions = (0, import_utils3.getUiOptions)(uiSchema);
|
|
1454
|
+
if (!layoutGridSchema && LAYOUT_GRID_UI_OPTION in uiOptions && (0, import_isObject3.default)(uiOptions[LAYOUT_GRID_UI_OPTION])) {
|
|
1455
|
+
layoutGridSchema = uiOptions[LAYOUT_GRID_UI_OPTION];
|
|
1456
|
+
}
|
|
1457
|
+
if ((0, import_isObject3.default)(layoutGridSchema)) {
|
|
1458
|
+
if ("ui:row" /* ROW */ in layoutGridSchema) {
|
|
1459
|
+
return this.renderRow(layoutGridSchema);
|
|
1460
|
+
}
|
|
1461
|
+
if ("ui:col" /* COLUMN */ in layoutGridSchema) {
|
|
1462
|
+
return this.renderCol(layoutGridSchema);
|
|
1463
|
+
}
|
|
1464
|
+
if ("ui:columns" /* COLUMNS */ in layoutGridSchema) {
|
|
1465
|
+
return this.renderColumns(layoutGridSchema);
|
|
1466
|
+
}
|
|
1467
|
+
if ("ui:condition" /* CONDITION */ in layoutGridSchema) {
|
|
1468
|
+
return this.renderCondition(layoutGridSchema);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
return this.renderField(layoutGridSchema);
|
|
1115
1472
|
}
|
|
1116
1473
|
};
|
|
1117
|
-
var MultiSchemaField_default = AnyOfField;
|
|
1118
1474
|
|
|
1119
|
-
// src/components/fields/
|
|
1120
|
-
var import_react3 = require("react");
|
|
1475
|
+
// src/components/fields/LayoutHeaderField.tsx
|
|
1121
1476
|
var import_utils4 = require("@rjsf/utils");
|
|
1122
1477
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1478
|
+
function LayoutHeaderField(props) {
|
|
1479
|
+
const { idSchema, title, schema, uiSchema, required, registry, name } = props;
|
|
1480
|
+
const options = (0, import_utils4.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
1481
|
+
const { title: uiTitle } = options;
|
|
1482
|
+
const { title: schemaTitle } = schema;
|
|
1483
|
+
const fieldTitle = uiTitle || title || schemaTitle || name;
|
|
1484
|
+
if (!fieldTitle) {
|
|
1485
|
+
return null;
|
|
1486
|
+
}
|
|
1487
|
+
const TitleFieldTemplate = (0, import_utils4.getTemplate)(
|
|
1488
|
+
"TitleFieldTemplate",
|
|
1489
|
+
registry,
|
|
1490
|
+
options
|
|
1491
|
+
);
|
|
1492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1493
|
+
TitleFieldTemplate,
|
|
1494
|
+
{
|
|
1495
|
+
id: (0, import_utils4.titleId)(idSchema),
|
|
1496
|
+
title: fieldTitle,
|
|
1497
|
+
required,
|
|
1498
|
+
schema,
|
|
1499
|
+
uiSchema,
|
|
1500
|
+
registry
|
|
1501
|
+
}
|
|
1502
|
+
);
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
// src/components/fields/LayoutMultiSchemaField.tsx
|
|
1506
|
+
var import_react4 = require("react");
|
|
1507
|
+
var import_utils5 = require("@rjsf/utils");
|
|
1508
|
+
var import_get3 = __toESM(require("lodash/get"), 1);
|
|
1509
|
+
var import_has2 = __toESM(require("lodash/has"), 1);
|
|
1510
|
+
var import_isEmpty2 = __toESM(require("lodash/isEmpty"), 1);
|
|
1511
|
+
var import_noop = __toESM(require("lodash/noop"), 1);
|
|
1512
|
+
var import_omit = __toESM(require("lodash/omit"), 1);
|
|
1513
|
+
var import_set3 = __toESM(require("lodash/set"), 1);
|
|
1514
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1515
|
+
function getSelectedOption(options, selectorField, value) {
|
|
1516
|
+
const defaultValue = "!@#!@$@#$!@$#";
|
|
1517
|
+
const schemaOptions = options.map(({ schema }) => schema);
|
|
1518
|
+
return schemaOptions.find((option) => {
|
|
1519
|
+
const selector = (0, import_get3.default)(option, [import_utils5.PROPERTIES_KEY, selectorField]);
|
|
1520
|
+
const result = (0, import_get3.default)(selector, import_utils5.DEFAULT_KEY, (0, import_get3.default)(selector, import_utils5.CONST_KEY, defaultValue));
|
|
1521
|
+
return result === value;
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
function computeEnumOptions(schema, options, schemaUtils, uiSchema, formData) {
|
|
1525
|
+
const realOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
1526
|
+
let tempSchema = schema;
|
|
1527
|
+
if ((0, import_has2.default)(schema, import_utils5.ONE_OF_KEY)) {
|
|
1528
|
+
tempSchema = { ...schema, [import_utils5.ONE_OF_KEY]: realOptions };
|
|
1529
|
+
} else if ((0, import_has2.default)(schema, import_utils5.ANY_OF_KEY)) {
|
|
1530
|
+
tempSchema = { ...schema, [import_utils5.ANY_OF_KEY]: realOptions };
|
|
1531
|
+
}
|
|
1532
|
+
const enumOptions = (0, import_utils5.optionsList)(tempSchema, uiSchema);
|
|
1533
|
+
if (!enumOptions) {
|
|
1534
|
+
throw new Error(`No enumOptions were computed from the schema ${JSON.stringify(tempSchema)}`);
|
|
1535
|
+
}
|
|
1536
|
+
return enumOptions;
|
|
1537
|
+
}
|
|
1538
|
+
function LayoutMultiSchemaField(props) {
|
|
1539
|
+
const {
|
|
1540
|
+
name,
|
|
1541
|
+
baseType,
|
|
1542
|
+
disabled = false,
|
|
1543
|
+
formData,
|
|
1544
|
+
idSchema,
|
|
1545
|
+
onBlur,
|
|
1546
|
+
onChange,
|
|
1547
|
+
options,
|
|
1548
|
+
onFocus,
|
|
1549
|
+
registry,
|
|
1550
|
+
uiSchema,
|
|
1551
|
+
schema,
|
|
1552
|
+
formContext,
|
|
1553
|
+
autofocus,
|
|
1554
|
+
readonly,
|
|
1555
|
+
required,
|
|
1556
|
+
errorSchema,
|
|
1557
|
+
hideError = false
|
|
1558
|
+
} = props;
|
|
1559
|
+
const { widgets: widgets2, schemaUtils, globalUiOptions } = registry;
|
|
1560
|
+
const [enumOptions, setEnumOptions] = (0, import_react4.useState)(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1561
|
+
const id = (0, import_get3.default)(idSchema, import_utils5.ID_KEY);
|
|
1562
|
+
const discriminator = (0, import_utils5.getDiscriminatorFieldFromSchema)(schema);
|
|
1563
|
+
const FieldErrorTemplate2 = (0, import_utils5.getTemplate)("FieldErrorTemplate", registry, options);
|
|
1564
|
+
const FieldTemplate2 = (0, import_utils5.getTemplate)("FieldTemplate", registry, options);
|
|
1565
|
+
const schemaHash = (0, import_utils5.hashObject)(schema);
|
|
1566
|
+
const optionsHash = (0, import_utils5.hashObject)(options);
|
|
1567
|
+
const uiSchemaHash = uiSchema ? (0, import_utils5.hashObject)(uiSchema) : "";
|
|
1568
|
+
const formDataHash = formData ? (0, import_utils5.hashObject)(formData) : "";
|
|
1569
|
+
(0, import_react4.useEffect)(() => {
|
|
1570
|
+
setEnumOptions(computeEnumOptions(schema, options, schemaUtils, uiSchema, formData));
|
|
1571
|
+
}, [schemaHash, optionsHash, schemaUtils, uiSchemaHash, formDataHash]);
|
|
1572
|
+
const {
|
|
1573
|
+
widget = discriminator ? "radio" : "select",
|
|
1574
|
+
title = "",
|
|
1575
|
+
placeholder = "",
|
|
1576
|
+
optionsSchemaSelector: selectorField = discriminator,
|
|
1577
|
+
hideError: uiSchemaHideError,
|
|
1578
|
+
...uiOptions
|
|
1579
|
+
} = (0, import_utils5.getUiOptions)(uiSchema);
|
|
1580
|
+
if (!selectorField) {
|
|
1581
|
+
throw new Error("No selector field provided for the LayoutMultiSchemaField");
|
|
1582
|
+
}
|
|
1583
|
+
const selectedOption = (0, import_get3.default)(formData, selectorField);
|
|
1584
|
+
let optionSchema = (0, import_get3.default)(enumOptions[0]?.schema, [import_utils5.PROPERTIES_KEY, selectorField], {});
|
|
1585
|
+
const option = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
1586
|
+
optionSchema = optionSchema?.type ? optionSchema : { ...optionSchema, type: option?.type || baseType };
|
|
1587
|
+
const Widget = (0, import_utils5.getWidget)(optionSchema, widget, widgets2);
|
|
1588
|
+
const hideFieldError = uiSchemaHideError === void 0 ? hideError : Boolean(uiSchemaHideError);
|
|
1589
|
+
const rawErrors = (0, import_get3.default)(errorSchema, [import_utils5.ERRORS_KEY], []);
|
|
1590
|
+
const fieldErrorSchema = (0, import_omit.default)(errorSchema, [import_utils5.ERRORS_KEY]);
|
|
1591
|
+
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1592
|
+
const onOptionChange = (opt) => {
|
|
1593
|
+
const newOption = getSelectedOption(enumOptions, selectorField, opt);
|
|
1594
|
+
const oldOption = getSelectedOption(enumOptions, selectorField, selectedOption);
|
|
1595
|
+
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
1596
|
+
if (newFormData && newOption) {
|
|
1597
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1598
|
+
}
|
|
1599
|
+
if (newFormData) {
|
|
1600
|
+
(0, import_set3.default)(newFormData, selectorField, opt);
|
|
1601
|
+
}
|
|
1602
|
+
onChange(newFormData, void 0, id);
|
|
1603
|
+
};
|
|
1604
|
+
const widgetOptions = { enumOptions, ...uiOptions };
|
|
1605
|
+
const errors = !hideFieldError && rawErrors.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FieldErrorTemplate2, { idSchema, schema, errors: rawErrors, registry }) : void 0;
|
|
1606
|
+
const ignored = (value) => import_noop.default;
|
|
1607
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1608
|
+
FieldTemplate2,
|
|
1609
|
+
{
|
|
1610
|
+
id,
|
|
1611
|
+
schema,
|
|
1612
|
+
label: (title || schema.title) ?? "",
|
|
1613
|
+
disabled: disabled || Array.isArray(enumOptions) && (0, import_isEmpty2.default)(enumOptions),
|
|
1614
|
+
uiSchema,
|
|
1615
|
+
formContext,
|
|
1616
|
+
required,
|
|
1617
|
+
readonly: !!readonly,
|
|
1618
|
+
registry,
|
|
1619
|
+
displayLabel,
|
|
1620
|
+
errors,
|
|
1621
|
+
onChange,
|
|
1622
|
+
onDropPropertyClick: ignored,
|
|
1623
|
+
onKeyChange: ignored,
|
|
1624
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1625
|
+
Widget,
|
|
1626
|
+
{
|
|
1627
|
+
id,
|
|
1628
|
+
name,
|
|
1629
|
+
schema,
|
|
1630
|
+
label: (title || schema.title) ?? "",
|
|
1631
|
+
disabled: disabled || Array.isArray(enumOptions) && (0, import_isEmpty2.default)(enumOptions),
|
|
1632
|
+
uiSchema,
|
|
1633
|
+
formContext,
|
|
1634
|
+
autofocus,
|
|
1635
|
+
readonly,
|
|
1636
|
+
required,
|
|
1637
|
+
registry,
|
|
1638
|
+
multiple: false,
|
|
1639
|
+
rawErrors,
|
|
1640
|
+
hideError: hideFieldError,
|
|
1641
|
+
hideLabel: !displayLabel,
|
|
1642
|
+
errorSchema: fieldErrorSchema,
|
|
1643
|
+
placeholder,
|
|
1644
|
+
onChange: onOptionChange,
|
|
1645
|
+
onBlur,
|
|
1646
|
+
onFocus,
|
|
1647
|
+
value: selectedOption,
|
|
1648
|
+
options: widgetOptions
|
|
1649
|
+
}
|
|
1650
|
+
)
|
|
1651
|
+
}
|
|
1652
|
+
);
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
// src/components/fields/MultiSchemaField.tsx
|
|
1656
|
+
var import_react5 = require("react");
|
|
1657
|
+
var import_get4 = __toESM(require("lodash/get"), 1);
|
|
1658
|
+
var import_isEmpty3 = __toESM(require("lodash/isEmpty"), 1);
|
|
1659
|
+
var import_omit2 = __toESM(require("lodash/omit"), 1);
|
|
1660
|
+
var import_utils6 = require("@rjsf/utils");
|
|
1661
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1662
|
+
var AnyOfField = class extends import_react5.Component {
|
|
1663
|
+
/** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
|
|
1664
|
+
*
|
|
1665
|
+
* @param props - The `FieldProps` for this template
|
|
1666
|
+
*/
|
|
1667
|
+
constructor(props) {
|
|
1668
|
+
super(props);
|
|
1669
|
+
const {
|
|
1670
|
+
formData,
|
|
1671
|
+
options,
|
|
1672
|
+
registry: { schemaUtils }
|
|
1673
|
+
} = this.props;
|
|
1674
|
+
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
1675
|
+
this.state = {
|
|
1676
|
+
retrievedOptions,
|
|
1677
|
+
selectedOption: this.getMatchingOption(0, formData, retrievedOptions)
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
/** React lifecycle method that is called when the props and/or state for this component is updated. It recomputes the
|
|
1681
|
+
* currently selected option based on the overall `formData`
|
|
1682
|
+
*
|
|
1683
|
+
* @param prevProps - The previous `FieldProps` for this template
|
|
1684
|
+
* @param prevState - The previous `AnyOfFieldState` for this template
|
|
1685
|
+
*/
|
|
1686
|
+
componentDidUpdate(prevProps, prevState) {
|
|
1687
|
+
const { formData, options, idSchema } = this.props;
|
|
1688
|
+
const { selectedOption } = this.state;
|
|
1689
|
+
let newState = this.state;
|
|
1690
|
+
if (!(0, import_utils6.deepEquals)(prevProps.options, options)) {
|
|
1691
|
+
const {
|
|
1692
|
+
registry: { schemaUtils }
|
|
1693
|
+
} = this.props;
|
|
1694
|
+
const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
|
|
1695
|
+
newState = { selectedOption, retrievedOptions };
|
|
1696
|
+
}
|
|
1697
|
+
if (!(0, import_utils6.deepEquals)(formData, prevProps.formData) && idSchema.$id === prevProps.idSchema.$id) {
|
|
1698
|
+
const { retrievedOptions } = newState;
|
|
1699
|
+
const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
|
|
1700
|
+
if (prevState && matchingOption !== selectedOption) {
|
|
1701
|
+
newState = { selectedOption: matchingOption, retrievedOptions };
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
if (newState !== this.state) {
|
|
1705
|
+
this.setState(newState);
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
/** Determines the best matching option for the given `formData` and `options`.
|
|
1709
|
+
*
|
|
1710
|
+
* @param formData - The new formData
|
|
1711
|
+
* @param options - The list of options to choose from
|
|
1712
|
+
* @return - The index of the `option` that best matches the `formData`
|
|
1713
|
+
*/
|
|
1714
|
+
getMatchingOption(selectedOption, formData, options) {
|
|
1715
|
+
const {
|
|
1716
|
+
schema,
|
|
1717
|
+
registry: { schemaUtils }
|
|
1718
|
+
} = this.props;
|
|
1719
|
+
const discriminator = (0, import_utils6.getDiscriminatorFieldFromSchema)(schema);
|
|
1720
|
+
const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
|
|
1721
|
+
return option;
|
|
1722
|
+
}
|
|
1723
|
+
/** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
|
|
1724
|
+
* to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
|
|
1725
|
+
* the `onChange` handler.
|
|
1726
|
+
*
|
|
1727
|
+
* @param option - The new option value being selected
|
|
1728
|
+
*/
|
|
1729
|
+
onOptionChange = (option) => {
|
|
1730
|
+
const { selectedOption, retrievedOptions } = this.state;
|
|
1731
|
+
const { formData, onChange, registry } = this.props;
|
|
1732
|
+
const { schemaUtils } = registry;
|
|
1733
|
+
const intOption = option !== void 0 ? parseInt(option, 10) : -1;
|
|
1734
|
+
if (intOption === selectedOption) {
|
|
1735
|
+
return;
|
|
1736
|
+
}
|
|
1737
|
+
const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
|
|
1738
|
+
const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
|
|
1739
|
+
let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
|
|
1740
|
+
if (newOption) {
|
|
1741
|
+
newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
|
|
1742
|
+
}
|
|
1743
|
+
this.setState({ selectedOption: intOption }, () => {
|
|
1744
|
+
onChange(newFormData, void 0, this.getFieldId());
|
|
1745
|
+
});
|
|
1746
|
+
};
|
|
1747
|
+
getFieldId() {
|
|
1748
|
+
const { idSchema, schema } = this.props;
|
|
1749
|
+
return `${idSchema.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
|
|
1750
|
+
}
|
|
1751
|
+
/** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
|
|
1752
|
+
*/
|
|
1753
|
+
render() {
|
|
1754
|
+
const {
|
|
1755
|
+
name,
|
|
1756
|
+
disabled = false,
|
|
1757
|
+
errorSchema = {},
|
|
1758
|
+
formContext,
|
|
1759
|
+
onBlur,
|
|
1760
|
+
onFocus,
|
|
1761
|
+
readonly,
|
|
1762
|
+
registry,
|
|
1763
|
+
schema,
|
|
1764
|
+
uiSchema
|
|
1765
|
+
} = this.props;
|
|
1766
|
+
const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
|
|
1767
|
+
const { SchemaField: _SchemaField } = fields2;
|
|
1768
|
+
const { selectedOption, retrievedOptions } = this.state;
|
|
1769
|
+
const {
|
|
1770
|
+
widget = "select",
|
|
1771
|
+
placeholder,
|
|
1772
|
+
autofocus,
|
|
1773
|
+
autocomplete,
|
|
1774
|
+
title = schema.title,
|
|
1775
|
+
...uiOptions
|
|
1776
|
+
} = (0, import_utils6.getUiOptions)(uiSchema, globalUiOptions);
|
|
1777
|
+
const Widget = (0, import_utils6.getWidget)({ type: "number" }, widget, widgets2);
|
|
1778
|
+
const rawErrors = (0, import_get4.default)(errorSchema, import_utils6.ERRORS_KEY, []);
|
|
1779
|
+
const fieldErrorSchema = (0, import_omit2.default)(errorSchema, [import_utils6.ERRORS_KEY]);
|
|
1780
|
+
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1781
|
+
const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
|
|
1782
|
+
let optionSchema;
|
|
1783
|
+
if (option) {
|
|
1784
|
+
const { required } = schema;
|
|
1785
|
+
optionSchema = required ? (0, import_utils6.mergeSchemas)({ required }, option) : option;
|
|
1786
|
+
}
|
|
1787
|
+
let optionsUiSchema = [];
|
|
1788
|
+
if (import_utils6.ONE_OF_KEY in schema && uiSchema && import_utils6.ONE_OF_KEY in uiSchema) {
|
|
1789
|
+
if (Array.isArray(uiSchema[import_utils6.ONE_OF_KEY])) {
|
|
1790
|
+
optionsUiSchema = uiSchema[import_utils6.ONE_OF_KEY];
|
|
1791
|
+
} else {
|
|
1792
|
+
console.warn(`uiSchema.oneOf is not an array for "${title || name}"`);
|
|
1793
|
+
}
|
|
1794
|
+
} else if (import_utils6.ANY_OF_KEY in schema && uiSchema && import_utils6.ANY_OF_KEY in uiSchema) {
|
|
1795
|
+
if (Array.isArray(uiSchema[import_utils6.ANY_OF_KEY])) {
|
|
1796
|
+
optionsUiSchema = uiSchema[import_utils6.ANY_OF_KEY];
|
|
1797
|
+
} else {
|
|
1798
|
+
console.warn(`uiSchema.anyOf is not an array for "${title || name}"`);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
let optionUiSchema = uiSchema;
|
|
1802
|
+
if (selectedOption >= 0 && optionsUiSchema.length > selectedOption) {
|
|
1803
|
+
optionUiSchema = optionsUiSchema[selectedOption];
|
|
1804
|
+
}
|
|
1805
|
+
const translateEnum = title ? import_utils6.TranslatableString.TitleOptionPrefix : import_utils6.TranslatableString.OptionPrefix;
|
|
1806
|
+
const translateParams = title ? [title] : [];
|
|
1807
|
+
const enumOptions = retrievedOptions.map((opt, index) => {
|
|
1808
|
+
const { title: uiTitle = opt.title } = (0, import_utils6.getUiOptions)(optionsUiSchema[index]);
|
|
1809
|
+
return {
|
|
1810
|
+
label: uiTitle || translateString(translateEnum, translateParams.concat(String(index + 1))),
|
|
1811
|
+
value: index
|
|
1812
|
+
};
|
|
1813
|
+
});
|
|
1814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "panel panel-default panel-body", children: [
|
|
1815
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "form-group", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1816
|
+
Widget,
|
|
1817
|
+
{
|
|
1818
|
+
id: this.getFieldId(),
|
|
1819
|
+
name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
|
|
1820
|
+
schema: { type: "number", default: 0 },
|
|
1821
|
+
onChange: this.onOptionChange,
|
|
1822
|
+
onBlur,
|
|
1823
|
+
onFocus,
|
|
1824
|
+
disabled: disabled || (0, import_isEmpty3.default)(enumOptions),
|
|
1825
|
+
multiple: false,
|
|
1826
|
+
rawErrors,
|
|
1827
|
+
errorSchema: fieldErrorSchema,
|
|
1828
|
+
value: selectedOption >= 0 ? selectedOption : void 0,
|
|
1829
|
+
options: { enumOptions, ...uiOptions },
|
|
1830
|
+
registry,
|
|
1831
|
+
formContext,
|
|
1832
|
+
placeholder,
|
|
1833
|
+
autocomplete,
|
|
1834
|
+
autofocus,
|
|
1835
|
+
label: title ?? name,
|
|
1836
|
+
hideLabel: !displayLabel,
|
|
1837
|
+
readonly
|
|
1838
|
+
}
|
|
1839
|
+
) }),
|
|
1840
|
+
optionSchema && optionSchema.type !== "null" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(_SchemaField, { ...this.props, schema: optionSchema, uiSchema: optionUiSchema })
|
|
1841
|
+
] });
|
|
1842
|
+
}
|
|
1843
|
+
};
|
|
1844
|
+
var MultiSchemaField_default = AnyOfField;
|
|
1845
|
+
|
|
1846
|
+
// src/components/fields/NumberField.tsx
|
|
1847
|
+
var import_react6 = require("react");
|
|
1848
|
+
var import_utils7 = require("@rjsf/utils");
|
|
1849
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1123
1850
|
var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
|
|
1124
1851
|
var trailingCharMatcher = /[0.]0*$/;
|
|
1125
1852
|
function NumberField(props) {
|
|
1126
1853
|
const { registry, onChange, formData, value: initialValue } = props;
|
|
1127
|
-
const [lastValue, setLastValue] = (0,
|
|
1854
|
+
const [lastValue, setLastValue] = (0, import_react6.useState)(initialValue);
|
|
1128
1855
|
const { StringField: StringField2 } = registry.fields;
|
|
1129
1856
|
let value = formData;
|
|
1130
|
-
const handleChange = (0,
|
|
1131
|
-
(value2) => {
|
|
1857
|
+
const handleChange = (0, import_react6.useCallback)(
|
|
1858
|
+
(value2, errorSchema, id) => {
|
|
1132
1859
|
setLastValue(value2);
|
|
1133
1860
|
if (`${value2}`.charAt(0) === ".") {
|
|
1134
1861
|
value2 = `0${value2}`;
|
|
1135
1862
|
}
|
|
1136
|
-
const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? (0,
|
|
1137
|
-
onChange(processed);
|
|
1863
|
+
const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? (0, import_utils7.asNumber)(value2.replace(trailingCharMatcher, "")) : (0, import_utils7.asNumber)(value2);
|
|
1864
|
+
onChange(processed, errorSchema, id);
|
|
1138
1865
|
},
|
|
1139
1866
|
[onChange]
|
|
1140
1867
|
);
|
|
@@ -1144,149 +1871,26 @@ function NumberField(props) {
|
|
|
1144
1871
|
value = lastValue;
|
|
1145
1872
|
}
|
|
1146
1873
|
}
|
|
1147
|
-
return /* @__PURE__ */ (0,
|
|
1874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StringField2, { ...props, formData: value, onChange: handleChange });
|
|
1148
1875
|
}
|
|
1149
1876
|
var NumberField_default = NumberField;
|
|
1150
1877
|
|
|
1151
1878
|
// src/components/fields/ObjectField.tsx
|
|
1152
|
-
var
|
|
1153
|
-
var
|
|
1154
|
-
var import_markdown_to_jsx = __toESM(require("markdown-to-jsx"));
|
|
1155
|
-
var
|
|
1156
|
-
var
|
|
1157
|
-
var
|
|
1158
|
-
var
|
|
1159
|
-
var import_unset = __toESM(require("lodash/unset"));
|
|
1160
|
-
var
|
|
1161
|
-
var ObjectField = class extends
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
additionalProperties: {}
|
|
1168
|
-
};
|
|
1169
|
-
/** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
|
|
1170
|
-
* to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
|
|
1171
|
-
* formData.
|
|
1172
|
-
*
|
|
1173
|
-
* @param name - The name of the property
|
|
1174
|
-
* @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
|
|
1175
|
-
* @returns - The onPropertyChange callback for the `name` property
|
|
1176
|
-
*/
|
|
1177
|
-
this.onPropertyChange = (name, addedByAdditionalProperties = false) => {
|
|
1178
|
-
return (value, newErrorSchema, id) => {
|
|
1179
|
-
const { formData, onChange, errorSchema } = this.props;
|
|
1180
|
-
if (value === void 0 && addedByAdditionalProperties) {
|
|
1181
|
-
value = "";
|
|
1182
|
-
}
|
|
1183
|
-
const newFormData = { ...formData, [name]: value };
|
|
1184
|
-
onChange(
|
|
1185
|
-
newFormData,
|
|
1186
|
-
errorSchema && errorSchema && {
|
|
1187
|
-
...errorSchema,
|
|
1188
|
-
[name]: newErrorSchema
|
|
1189
|
-
},
|
|
1190
|
-
id
|
|
1191
|
-
);
|
|
1192
|
-
};
|
|
1193
|
-
};
|
|
1194
|
-
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
1195
|
-
* and calls the `onChange` callback with it
|
|
1196
|
-
*
|
|
1197
|
-
* @param key - The key for which the drop callback is desired
|
|
1198
|
-
* @returns - The drop property click callback
|
|
1199
|
-
*/
|
|
1200
|
-
this.onDropPropertyClick = (key) => {
|
|
1201
|
-
return (event) => {
|
|
1202
|
-
event.preventDefault();
|
|
1203
|
-
const { onChange, formData } = this.props;
|
|
1204
|
-
const copiedFormData = { ...formData };
|
|
1205
|
-
(0, import_unset.default)(copiedFormData, key);
|
|
1206
|
-
onChange(copiedFormData);
|
|
1207
|
-
};
|
|
1208
|
-
};
|
|
1209
|
-
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
1210
|
-
* that is already not assigned is found.
|
|
1211
|
-
*
|
|
1212
|
-
* @param preferredKey - The preferred name of a new key
|
|
1213
|
-
* @param [formData] - The form data in which to check if the desired key already exists
|
|
1214
|
-
* @returns - The name of the next available key from `preferredKey`
|
|
1215
|
-
*/
|
|
1216
|
-
this.getAvailableKey = (preferredKey, formData) => {
|
|
1217
|
-
const { uiSchema, registry } = this.props;
|
|
1218
|
-
const { duplicateKeySuffixSeparator = "-" } = (0, import_utils5.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
1219
|
-
let index = 0;
|
|
1220
|
-
let newKey = preferredKey;
|
|
1221
|
-
while ((0, import_has.default)(formData, newKey)) {
|
|
1222
|
-
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
|
|
1223
|
-
}
|
|
1224
|
-
return newKey;
|
|
1225
|
-
};
|
|
1226
|
-
/** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
|
|
1227
|
-
* callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
|
|
1228
|
-
*
|
|
1229
|
-
* @param oldValue - The old value of a field
|
|
1230
|
-
* @returns - The key change callback function
|
|
1231
|
-
*/
|
|
1232
|
-
this.onKeyChange = (oldValue) => {
|
|
1233
|
-
return (value, newErrorSchema) => {
|
|
1234
|
-
if (oldValue === value) {
|
|
1235
|
-
return;
|
|
1236
|
-
}
|
|
1237
|
-
const { formData, onChange, errorSchema } = this.props;
|
|
1238
|
-
value = this.getAvailableKey(value, formData);
|
|
1239
|
-
const newFormData = {
|
|
1240
|
-
...formData
|
|
1241
|
-
};
|
|
1242
|
-
const newKeys = { [oldValue]: value };
|
|
1243
|
-
const keyValues = Object.keys(newFormData).map((key) => {
|
|
1244
|
-
const newKey = newKeys[key] || key;
|
|
1245
|
-
return { [newKey]: newFormData[key] };
|
|
1246
|
-
});
|
|
1247
|
-
const renamedObj = Object.assign({}, ...keyValues);
|
|
1248
|
-
this.setState({ wasPropertyKeyModified: true });
|
|
1249
|
-
onChange(
|
|
1250
|
-
renamedObj,
|
|
1251
|
-
errorSchema && errorSchema && {
|
|
1252
|
-
...errorSchema,
|
|
1253
|
-
[value]: newErrorSchema
|
|
1254
|
-
}
|
|
1255
|
-
);
|
|
1256
|
-
};
|
|
1257
|
-
};
|
|
1258
|
-
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
1259
|
-
* default data for that field has been added to the formData.
|
|
1260
|
-
*
|
|
1261
|
-
* @param schema - The schema element to which the new property is being added
|
|
1262
|
-
*/
|
|
1263
|
-
this.handleAddClick = (schema) => () => {
|
|
1264
|
-
if (!schema.additionalProperties) {
|
|
1265
|
-
return;
|
|
1266
|
-
}
|
|
1267
|
-
const { formData, onChange, registry } = this.props;
|
|
1268
|
-
const newFormData = { ...formData };
|
|
1269
|
-
let type = void 0;
|
|
1270
|
-
let defaultValue = void 0;
|
|
1271
|
-
if ((0, import_isObject3.default)(schema.additionalProperties)) {
|
|
1272
|
-
type = schema.additionalProperties.type;
|
|
1273
|
-
defaultValue = schema.additionalProperties.default;
|
|
1274
|
-
let apSchema = schema.additionalProperties;
|
|
1275
|
-
if (import_utils5.REF_KEY in apSchema) {
|
|
1276
|
-
const { schemaUtils } = registry;
|
|
1277
|
-
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[import_utils5.REF_KEY] }, formData);
|
|
1278
|
-
type = apSchema.type;
|
|
1279
|
-
defaultValue = apSchema.default;
|
|
1280
|
-
}
|
|
1281
|
-
if (!type && (import_utils5.ANY_OF_KEY in apSchema || import_utils5.ONE_OF_KEY in apSchema)) {
|
|
1282
|
-
type = "object";
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
1286
|
-
(0, import_set2.default)(newFormData, newKey, defaultValue ?? this.getDefaultValue(type));
|
|
1287
|
-
onChange(newFormData);
|
|
1288
|
-
};
|
|
1289
|
-
}
|
|
1879
|
+
var import_react7 = require("react");
|
|
1880
|
+
var import_utils8 = require("@rjsf/utils");
|
|
1881
|
+
var import_markdown_to_jsx = __toESM(require("markdown-to-jsx"), 1);
|
|
1882
|
+
var import_get5 = __toESM(require("lodash/get"), 1);
|
|
1883
|
+
var import_has3 = __toESM(require("lodash/has"), 1);
|
|
1884
|
+
var import_isObject4 = __toESM(require("lodash/isObject"), 1);
|
|
1885
|
+
var import_set4 = __toESM(require("lodash/set"), 1);
|
|
1886
|
+
var import_unset = __toESM(require("lodash/unset"), 1);
|
|
1887
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1888
|
+
var ObjectField = class extends import_react7.Component {
|
|
1889
|
+
/** Set up the initial state */
|
|
1890
|
+
state = {
|
|
1891
|
+
wasPropertyKeyModified: false,
|
|
1892
|
+
additionalProperties: {}
|
|
1893
|
+
};
|
|
1290
1894
|
/** Returns a flag indicating whether the `name` field is required in the object schema
|
|
1291
1895
|
*
|
|
1292
1896
|
* @param name - The name of the field to check for required-ness
|
|
@@ -1296,6 +1900,95 @@ var ObjectField = class extends import_react4.Component {
|
|
|
1296
1900
|
const { schema } = this.props;
|
|
1297
1901
|
return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
|
|
1298
1902
|
}
|
|
1903
|
+
/** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
|
|
1904
|
+
* to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
|
|
1905
|
+
* formData.
|
|
1906
|
+
*
|
|
1907
|
+
* @param name - The name of the property
|
|
1908
|
+
* @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
|
|
1909
|
+
* @returns - The onPropertyChange callback for the `name` property
|
|
1910
|
+
*/
|
|
1911
|
+
onPropertyChange = (name, addedByAdditionalProperties = false) => {
|
|
1912
|
+
return (value, newErrorSchema, id) => {
|
|
1913
|
+
const { formData, onChange, errorSchema } = this.props;
|
|
1914
|
+
if (value === void 0 && addedByAdditionalProperties) {
|
|
1915
|
+
value = "";
|
|
1916
|
+
}
|
|
1917
|
+
const newFormData = { ...formData, [name]: value };
|
|
1918
|
+
onChange(
|
|
1919
|
+
newFormData,
|
|
1920
|
+
errorSchema && errorSchema && {
|
|
1921
|
+
...errorSchema,
|
|
1922
|
+
[name]: newErrorSchema
|
|
1923
|
+
},
|
|
1924
|
+
id
|
|
1925
|
+
);
|
|
1926
|
+
};
|
|
1927
|
+
};
|
|
1928
|
+
/** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
|
|
1929
|
+
* and calls the `onChange` callback with it
|
|
1930
|
+
*
|
|
1931
|
+
* @param key - The key for which the drop callback is desired
|
|
1932
|
+
* @returns - The drop property click callback
|
|
1933
|
+
*/
|
|
1934
|
+
onDropPropertyClick = (key) => {
|
|
1935
|
+
return (event) => {
|
|
1936
|
+
event.preventDefault();
|
|
1937
|
+
const { onChange, formData } = this.props;
|
|
1938
|
+
const copiedFormData = { ...formData };
|
|
1939
|
+
(0, import_unset.default)(copiedFormData, key);
|
|
1940
|
+
onChange(copiedFormData);
|
|
1941
|
+
};
|
|
1942
|
+
};
|
|
1943
|
+
/** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
|
|
1944
|
+
* that is already not assigned is found.
|
|
1945
|
+
*
|
|
1946
|
+
* @param preferredKey - The preferred name of a new key
|
|
1947
|
+
* @param [formData] - The form data in which to check if the desired key already exists
|
|
1948
|
+
* @returns - The name of the next available key from `preferredKey`
|
|
1949
|
+
*/
|
|
1950
|
+
getAvailableKey = (preferredKey, formData) => {
|
|
1951
|
+
const { uiSchema, registry } = this.props;
|
|
1952
|
+
const { duplicateKeySuffixSeparator = "-" } = (0, import_utils8.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
1953
|
+
let index = 0;
|
|
1954
|
+
let newKey = preferredKey;
|
|
1955
|
+
while ((0, import_has3.default)(formData, newKey)) {
|
|
1956
|
+
newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
|
|
1957
|
+
}
|
|
1958
|
+
return newKey;
|
|
1959
|
+
};
|
|
1960
|
+
/** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
|
|
1961
|
+
* callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
|
|
1962
|
+
*
|
|
1963
|
+
* @param oldValue - The old value of a field
|
|
1964
|
+
* @returns - The key change callback function
|
|
1965
|
+
*/
|
|
1966
|
+
onKeyChange = (oldValue) => {
|
|
1967
|
+
return (value, newErrorSchema) => {
|
|
1968
|
+
if (oldValue === value) {
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
const { formData, onChange, errorSchema } = this.props;
|
|
1972
|
+
value = this.getAvailableKey(value, formData);
|
|
1973
|
+
const newFormData = {
|
|
1974
|
+
...formData
|
|
1975
|
+
};
|
|
1976
|
+
const newKeys = { [oldValue]: value };
|
|
1977
|
+
const keyValues = Object.keys(newFormData).map((key) => {
|
|
1978
|
+
const newKey = newKeys[key] || key;
|
|
1979
|
+
return { [newKey]: newFormData[key] };
|
|
1980
|
+
});
|
|
1981
|
+
const renamedObj = Object.assign({}, ...keyValues);
|
|
1982
|
+
this.setState({ wasPropertyKeyModified: true });
|
|
1983
|
+
onChange(
|
|
1984
|
+
renamedObj,
|
|
1985
|
+
errorSchema && errorSchema && {
|
|
1986
|
+
...errorSchema,
|
|
1987
|
+
[value]: newErrorSchema
|
|
1988
|
+
}
|
|
1989
|
+
);
|
|
1990
|
+
};
|
|
1991
|
+
};
|
|
1299
1992
|
/** Returns a default value to be used for a new additional schema property of the given `type`
|
|
1300
1993
|
*
|
|
1301
1994
|
* @param type - The type of the new additional schema property
|
|
@@ -1317,9 +2010,48 @@ var ObjectField = class extends import_react4.Component {
|
|
|
1317
2010
|
return {};
|
|
1318
2011
|
case "string":
|
|
1319
2012
|
default:
|
|
1320
|
-
return translateString(
|
|
2013
|
+
return translateString(import_utils8.TranslatableString.NewStringDefault);
|
|
1321
2014
|
}
|
|
1322
2015
|
}
|
|
2016
|
+
/** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
|
|
2017
|
+
* default data for that field has been added to the formData.
|
|
2018
|
+
*
|
|
2019
|
+
* @param schema - The schema element to which the new property is being added
|
|
2020
|
+
*/
|
|
2021
|
+
handleAddClick = (schema) => () => {
|
|
2022
|
+
if (!(schema.additionalProperties || schema.patternProperties)) {
|
|
2023
|
+
return;
|
|
2024
|
+
}
|
|
2025
|
+
const { formData, onChange, registry } = this.props;
|
|
2026
|
+
const newFormData = { ...formData };
|
|
2027
|
+
const newKey = this.getAvailableKey("newKey", newFormData);
|
|
2028
|
+
if (schema.patternProperties) {
|
|
2029
|
+
(0, import_set4.default)(newFormData, newKey, null);
|
|
2030
|
+
} else {
|
|
2031
|
+
let type = void 0;
|
|
2032
|
+
let constValue = void 0;
|
|
2033
|
+
let defaultValue = void 0;
|
|
2034
|
+
if ((0, import_isObject4.default)(schema.additionalProperties)) {
|
|
2035
|
+
type = schema.additionalProperties.type;
|
|
2036
|
+
constValue = schema.additionalProperties.const;
|
|
2037
|
+
defaultValue = schema.additionalProperties.default;
|
|
2038
|
+
let apSchema = schema.additionalProperties;
|
|
2039
|
+
if (import_utils8.REF_KEY in apSchema) {
|
|
2040
|
+
const { schemaUtils } = registry;
|
|
2041
|
+
apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[import_utils8.REF_KEY] }, formData);
|
|
2042
|
+
type = apSchema.type;
|
|
2043
|
+
constValue = apSchema.const;
|
|
2044
|
+
defaultValue = apSchema.default;
|
|
2045
|
+
}
|
|
2046
|
+
if (!type && (import_utils8.ANY_OF_KEY in apSchema || import_utils8.ONE_OF_KEY in apSchema)) {
|
|
2047
|
+
type = "object";
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
const newValue = constValue ?? defaultValue ?? this.getDefaultValue(type);
|
|
2051
|
+
(0, import_set4.default)(newFormData, newKey, newValue);
|
|
2052
|
+
}
|
|
2053
|
+
onChange(newFormData);
|
|
2054
|
+
};
|
|
1323
2055
|
/** Renders the `ObjectField` from the given props
|
|
1324
2056
|
*/
|
|
1325
2057
|
render() {
|
|
@@ -1344,43 +2076,43 @@ var ObjectField = class extends import_react4.Component {
|
|
|
1344
2076
|
const { fields: fields2, formContext, schemaUtils, translateString, globalUiOptions } = registry;
|
|
1345
2077
|
const { SchemaField: SchemaField2 } = fields2;
|
|
1346
2078
|
const schema = schemaUtils.retrieveSchema(rawSchema, formData);
|
|
1347
|
-
const uiOptions = (0,
|
|
2079
|
+
const uiOptions = (0, import_utils8.getUiOptions)(uiSchema, globalUiOptions);
|
|
1348
2080
|
const { properties: schemaProperties = {} } = schema;
|
|
1349
2081
|
const templateTitle = uiOptions.title ?? schema.title ?? title ?? name;
|
|
1350
2082
|
const description = uiOptions.description ?? schema.description;
|
|
1351
2083
|
let orderedProperties;
|
|
1352
2084
|
try {
|
|
1353
2085
|
const properties = Object.keys(schemaProperties);
|
|
1354
|
-
orderedProperties = (0,
|
|
2086
|
+
orderedProperties = (0, import_utils8.orderProperties)(properties, uiOptions.order);
|
|
1355
2087
|
} catch (err) {
|
|
1356
|
-
return /* @__PURE__ */ (0,
|
|
1357
|
-
/* @__PURE__ */ (0,
|
|
1358
|
-
/* @__PURE__ */ (0,
|
|
2088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
2089
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "rjsf-config-error", style: { color: "red" }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_markdown_to_jsx.default, { options: { disableParsingRawHTML: true }, children: translateString(import_utils8.TranslatableString.InvalidObjectField, [name || "root", err.message]) }) }),
|
|
2090
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("pre", { children: JSON.stringify(schema) })
|
|
1359
2091
|
] });
|
|
1360
2092
|
}
|
|
1361
|
-
const Template = (0,
|
|
2093
|
+
const Template = (0, import_utils8.getTemplate)("ObjectFieldTemplate", registry, uiOptions);
|
|
1362
2094
|
const templateProps = {
|
|
1363
2095
|
// getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
|
|
1364
2096
|
title: uiOptions.label === false ? "" : templateTitle,
|
|
1365
2097
|
description: uiOptions.label === false ? void 0 : description,
|
|
1366
2098
|
properties: orderedProperties.map((name2) => {
|
|
1367
|
-
const addedByAdditionalProperties = (0,
|
|
2099
|
+
const addedByAdditionalProperties = (0, import_has3.default)(schema, [import_utils8.PROPERTIES_KEY, name2, import_utils8.ADDITIONAL_PROPERTY_FLAG]);
|
|
1368
2100
|
const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
|
|
1369
|
-
const hidden = (0,
|
|
1370
|
-
const fieldIdSchema = (0,
|
|
2101
|
+
const hidden = (0, import_utils8.getUiOptions)(fieldUiSchema).widget === "hidden";
|
|
2102
|
+
const fieldIdSchema = (0, import_get5.default)(idSchema, [name2], {});
|
|
1371
2103
|
return {
|
|
1372
|
-
content: /* @__PURE__ */ (0,
|
|
2104
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1373
2105
|
SchemaField2,
|
|
1374
2106
|
{
|
|
1375
2107
|
name: name2,
|
|
1376
2108
|
required: this.isRequired(name2),
|
|
1377
|
-
schema: (0,
|
|
2109
|
+
schema: (0, import_get5.default)(schema, [import_utils8.PROPERTIES_KEY, name2], {}),
|
|
1378
2110
|
uiSchema: fieldUiSchema,
|
|
1379
|
-
errorSchema: (0,
|
|
2111
|
+
errorSchema: (0, import_get5.default)(errorSchema, name2),
|
|
1380
2112
|
idSchema: fieldIdSchema,
|
|
1381
2113
|
idPrefix,
|
|
1382
2114
|
idSeparator,
|
|
1383
|
-
formData: (0,
|
|
2115
|
+
formData: (0, import_get5.default)(formData, name2),
|
|
1384
2116
|
formContext,
|
|
1385
2117
|
wasPropertyKeyModified: this.state.wasPropertyKeyModified,
|
|
1386
2118
|
onKeyChange: this.onKeyChange(name2),
|
|
@@ -1413,18 +2145,17 @@ var ObjectField = class extends import_react4.Component {
|
|
|
1413
2145
|
formContext,
|
|
1414
2146
|
registry
|
|
1415
2147
|
};
|
|
1416
|
-
return /* @__PURE__ */ (0,
|
|
2148
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Template, { ...templateProps, onAddClick: this.handleAddClick });
|
|
1417
2149
|
}
|
|
1418
2150
|
};
|
|
1419
2151
|
var ObjectField_default = ObjectField;
|
|
1420
2152
|
|
|
1421
2153
|
// src/components/fields/SchemaField.tsx
|
|
1422
|
-
var
|
|
1423
|
-
var
|
|
1424
|
-
var
|
|
1425
|
-
var
|
|
1426
|
-
var
|
|
1427
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2154
|
+
var import_react8 = require("react");
|
|
2155
|
+
var import_utils9 = require("@rjsf/utils");
|
|
2156
|
+
var import_isObject5 = __toESM(require("lodash/isObject"), 1);
|
|
2157
|
+
var import_omit3 = __toESM(require("lodash/omit"), 1);
|
|
2158
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1428
2159
|
var COMPONENT_TYPES = {
|
|
1429
2160
|
array: "ArrayField",
|
|
1430
2161
|
boolean: "BooleanField",
|
|
@@ -1443,7 +2174,7 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1443
2174
|
if (typeof field === "string" && field in fields2) {
|
|
1444
2175
|
return fields2[field];
|
|
1445
2176
|
}
|
|
1446
|
-
const schemaType = (0,
|
|
2177
|
+
const schemaType = (0, import_utils9.getSchemaType)(schema);
|
|
1447
2178
|
const type = Array.isArray(schemaType) ? schemaType[0] : schemaType || "";
|
|
1448
2179
|
const schemaId = schema.$id;
|
|
1449
2180
|
let componentName = COMPONENT_TYPES[type];
|
|
@@ -1454,17 +2185,17 @@ function getFieldComponent(schema, uiOptions, idSchema, registry) {
|
|
|
1454
2185
|
return () => null;
|
|
1455
2186
|
}
|
|
1456
2187
|
return componentName in fields2 ? fields2[componentName] : () => {
|
|
1457
|
-
const UnsupportedFieldTemplate = (0,
|
|
2188
|
+
const UnsupportedFieldTemplate = (0, import_utils9.getTemplate)(
|
|
1458
2189
|
"UnsupportedFieldTemplate",
|
|
1459
2190
|
registry,
|
|
1460
2191
|
uiOptions
|
|
1461
2192
|
);
|
|
1462
|
-
return /* @__PURE__ */ (0,
|
|
2193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1463
2194
|
UnsupportedFieldTemplate,
|
|
1464
2195
|
{
|
|
1465
2196
|
schema,
|
|
1466
2197
|
idSchema,
|
|
1467
|
-
reason: translateString(
|
|
2198
|
+
reason: translateString(import_utils9.TranslatableString.UnknownFieldType, [String(schema.type)]),
|
|
1468
2199
|
registry
|
|
1469
2200
|
}
|
|
1470
2201
|
);
|
|
@@ -1488,22 +2219,22 @@ function SchemaFieldRender(props) {
|
|
|
1488
2219
|
wasPropertyKeyModified = false
|
|
1489
2220
|
} = props;
|
|
1490
2221
|
const { formContext, schemaUtils, globalUiOptions } = registry;
|
|
1491
|
-
const uiOptions = (0,
|
|
1492
|
-
const FieldTemplate2 = (0,
|
|
1493
|
-
const DescriptionFieldTemplate = (0,
|
|
2222
|
+
const uiOptions = (0, import_utils9.getUiOptions)(uiSchema, globalUiOptions);
|
|
2223
|
+
const FieldTemplate2 = (0, import_utils9.getTemplate)("FieldTemplate", registry, uiOptions);
|
|
2224
|
+
const DescriptionFieldTemplate = (0, import_utils9.getTemplate)(
|
|
1494
2225
|
"DescriptionFieldTemplate",
|
|
1495
2226
|
registry,
|
|
1496
2227
|
uiOptions
|
|
1497
2228
|
);
|
|
1498
|
-
const FieldHelpTemplate2 = (0,
|
|
1499
|
-
const FieldErrorTemplate2 = (0,
|
|
2229
|
+
const FieldHelpTemplate2 = (0, import_utils9.getTemplate)("FieldHelpTemplate", registry, uiOptions);
|
|
2230
|
+
const FieldErrorTemplate2 = (0, import_utils9.getTemplate)("FieldErrorTemplate", registry, uiOptions);
|
|
1500
2231
|
const schema = schemaUtils.retrieveSchema(_schema, formData);
|
|
1501
|
-
const fieldId = _idSchema[
|
|
1502
|
-
const idSchema = (0,
|
|
2232
|
+
const fieldId = _idSchema[import_utils9.ID_KEY];
|
|
2233
|
+
const idSchema = (0, import_utils9.mergeObjects)(
|
|
1503
2234
|
schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator),
|
|
1504
2235
|
_idSchema
|
|
1505
2236
|
);
|
|
1506
|
-
const handleFieldComponentChange = (0,
|
|
2237
|
+
const handleFieldComponentChange = (0, import_react8.useCallback)(
|
|
1507
2238
|
(formData2, newErrorSchema, id2) => {
|
|
1508
2239
|
const theId = id2 || fieldId;
|
|
1509
2240
|
return onChange(formData2, newErrorSchema, theId);
|
|
@@ -1521,11 +2252,11 @@ function SchemaFieldRender(props) {
|
|
|
1521
2252
|
}
|
|
1522
2253
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1523
2254
|
const { __errors, ...fieldErrorSchema } = errorSchema || {};
|
|
1524
|
-
const fieldUiSchema = (0,
|
|
1525
|
-
if (
|
|
1526
|
-
fieldUiSchema[
|
|
2255
|
+
const fieldUiSchema = (0, import_omit3.default)(uiSchema, ["ui:classNames", "classNames", "ui:style"]);
|
|
2256
|
+
if (import_utils9.UI_OPTIONS_KEY in fieldUiSchema) {
|
|
2257
|
+
fieldUiSchema[import_utils9.UI_OPTIONS_KEY] = (0, import_omit3.default)(fieldUiSchema[import_utils9.UI_OPTIONS_KEY], ["classNames", "style"]);
|
|
1527
2258
|
}
|
|
1528
|
-
const field = /* @__PURE__ */ (0,
|
|
2259
|
+
const field = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1529
2260
|
FieldComponent,
|
|
1530
2261
|
{
|
|
1531
2262
|
...props,
|
|
@@ -1542,33 +2273,24 @@ function SchemaFieldRender(props) {
|
|
|
1542
2273
|
rawErrors: __errors
|
|
1543
2274
|
}
|
|
1544
2275
|
);
|
|
1545
|
-
const id = idSchema[
|
|
2276
|
+
const id = idSchema[import_utils9.ID_KEY];
|
|
1546
2277
|
let label;
|
|
1547
2278
|
if (wasPropertyKeyModified) {
|
|
1548
2279
|
label = name;
|
|
1549
2280
|
} else {
|
|
1550
|
-
label =
|
|
2281
|
+
label = import_utils9.ADDITIONAL_PROPERTY_FLAG in schema ? name : uiOptions.title || props.schema.title || schema.title || props.title || name;
|
|
1551
2282
|
}
|
|
1552
2283
|
const description = uiOptions.description || props.schema.description || schema.description || "";
|
|
1553
|
-
const richDescription = uiOptions.enableMarkdownInDescription ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_markdown_to_jsx2.default, { options: { disableParsingRawHTML: true }, children: description }) : description;
|
|
1554
2284
|
const help = uiOptions.help;
|
|
1555
2285
|
const hidden = uiOptions.widget === "hidden";
|
|
1556
|
-
const classNames = ["
|
|
2286
|
+
const classNames = ["rjsf-field", `rjsf-field-${(0, import_utils9.getSchemaType)(schema)}`];
|
|
1557
2287
|
if (!hideError && __errors && __errors.length > 0) {
|
|
1558
|
-
classNames.push("field-error
|
|
1559
|
-
}
|
|
1560
|
-
if (uiSchema?.classNames) {
|
|
1561
|
-
if (true) {
|
|
1562
|
-
console.warn(
|
|
1563
|
-
"'uiSchema.classNames' is deprecated and may be removed in a major release; Use 'ui:classNames' instead."
|
|
1564
|
-
);
|
|
1565
|
-
}
|
|
1566
|
-
classNames.push(uiSchema.classNames);
|
|
2288
|
+
classNames.push("rjsf-field-error");
|
|
1567
2289
|
}
|
|
1568
2290
|
if (uiOptions.classNames) {
|
|
1569
2291
|
classNames.push(uiOptions.classNames);
|
|
1570
2292
|
}
|
|
1571
|
-
const helpComponent = /* @__PURE__ */ (0,
|
|
2293
|
+
const helpComponent = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1572
2294
|
FieldHelpTemplate2,
|
|
1573
2295
|
{
|
|
1574
2296
|
help,
|
|
@@ -1579,7 +2301,7 @@ function SchemaFieldRender(props) {
|
|
|
1579
2301
|
registry
|
|
1580
2302
|
}
|
|
1581
2303
|
);
|
|
1582
|
-
const errorsComponent = hideError || (schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ (0,
|
|
2304
|
+
const errorsComponent = hideError || (schema.anyOf || schema.oneOf) && !schemaUtils.isSelect(schema) ? void 0 : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1583
2305
|
FieldErrorTemplate2,
|
|
1584
2306
|
{
|
|
1585
2307
|
errors: __errors,
|
|
@@ -1591,11 +2313,11 @@ function SchemaFieldRender(props) {
|
|
|
1591
2313
|
}
|
|
1592
2314
|
);
|
|
1593
2315
|
const fieldProps = {
|
|
1594
|
-
description: /* @__PURE__ */ (0,
|
|
2316
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1595
2317
|
DescriptionFieldTemplate,
|
|
1596
2318
|
{
|
|
1597
|
-
id: (0,
|
|
1598
|
-
description
|
|
2319
|
+
id: (0, import_utils9.descriptionId)(id),
|
|
2320
|
+
description,
|
|
1599
2321
|
schema,
|
|
1600
2322
|
uiSchema,
|
|
1601
2323
|
registry
|
|
@@ -1628,9 +2350,9 @@ function SchemaFieldRender(props) {
|
|
|
1628
2350
|
const _AnyOfField = registry.fields.AnyOfField;
|
|
1629
2351
|
const _OneOfField = registry.fields.OneOfField;
|
|
1630
2352
|
const isReplacingAnyOrOneOf = uiSchema?.["ui:field"] && uiSchema?.["ui:fieldReplacesAnyOrOneOf"] === true;
|
|
1631
|
-
return /* @__PURE__ */ (0,
|
|
2353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
1632
2354
|
field,
|
|
1633
|
-
schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ (0,
|
|
2355
|
+
schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1634
2356
|
_AnyOfField,
|
|
1635
2357
|
{
|
|
1636
2358
|
name,
|
|
@@ -1647,14 +2369,15 @@ function SchemaFieldRender(props) {
|
|
|
1647
2369
|
onChange: props.onChange,
|
|
1648
2370
|
onFocus: props.onFocus,
|
|
1649
2371
|
options: schema.anyOf.map(
|
|
1650
|
-
(_schema2) => schemaUtils.retrieveSchema((0,
|
|
2372
|
+
(_schema2) => schemaUtils.retrieveSchema((0, import_isObject5.default)(_schema2) ? _schema2 : {}, formData)
|
|
1651
2373
|
),
|
|
1652
2374
|
registry,
|
|
2375
|
+
required,
|
|
1653
2376
|
schema,
|
|
1654
2377
|
uiSchema
|
|
1655
2378
|
}
|
|
1656
2379
|
),
|
|
1657
|
-
schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ (0,
|
|
2380
|
+
schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1658
2381
|
_OneOfField,
|
|
1659
2382
|
{
|
|
1660
2383
|
name,
|
|
@@ -1671,28 +2394,29 @@ function SchemaFieldRender(props) {
|
|
|
1671
2394
|
onChange: props.onChange,
|
|
1672
2395
|
onFocus: props.onFocus,
|
|
1673
2396
|
options: schema.oneOf.map(
|
|
1674
|
-
(_schema2) => schemaUtils.retrieveSchema((0,
|
|
2397
|
+
(_schema2) => schemaUtils.retrieveSchema((0, import_isObject5.default)(_schema2) ? _schema2 : {}, formData)
|
|
1675
2398
|
),
|
|
1676
2399
|
registry,
|
|
2400
|
+
required,
|
|
1677
2401
|
schema,
|
|
1678
2402
|
uiSchema
|
|
1679
2403
|
}
|
|
1680
2404
|
)
|
|
1681
2405
|
] }) });
|
|
1682
2406
|
}
|
|
1683
|
-
var SchemaField = class extends
|
|
2407
|
+
var SchemaField = class extends import_react8.Component {
|
|
1684
2408
|
shouldComponentUpdate(nextProps) {
|
|
1685
|
-
return !(0,
|
|
2409
|
+
return !(0, import_utils9.deepEquals)(this.props, nextProps);
|
|
1686
2410
|
}
|
|
1687
2411
|
render() {
|
|
1688
|
-
return /* @__PURE__ */ (0,
|
|
2412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SchemaFieldRender, { ...this.props });
|
|
1689
2413
|
}
|
|
1690
2414
|
};
|
|
1691
2415
|
var SchemaField_default = SchemaField;
|
|
1692
2416
|
|
|
1693
2417
|
// src/components/fields/StringField.tsx
|
|
1694
|
-
var
|
|
1695
|
-
var
|
|
2418
|
+
var import_utils10 = require("@rjsf/utils");
|
|
2419
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1696
2420
|
function StringField(props) {
|
|
1697
2421
|
const {
|
|
1698
2422
|
schema,
|
|
@@ -1713,16 +2437,16 @@ function StringField(props) {
|
|
|
1713
2437
|
} = props;
|
|
1714
2438
|
const { title, format } = schema;
|
|
1715
2439
|
const { widgets: widgets2, formContext, schemaUtils, globalUiOptions } = registry;
|
|
1716
|
-
const enumOptions = schemaUtils.isSelect(schema) ? (0,
|
|
2440
|
+
const enumOptions = schemaUtils.isSelect(schema) ? (0, import_utils10.optionsList)(schema, uiSchema) : void 0;
|
|
1717
2441
|
let defaultWidget = enumOptions ? "select" : "text";
|
|
1718
|
-
if (format && (0,
|
|
2442
|
+
if (format && (0, import_utils10.hasWidget)(schema, format, widgets2)) {
|
|
1719
2443
|
defaultWidget = format;
|
|
1720
2444
|
}
|
|
1721
|
-
const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = (0,
|
|
2445
|
+
const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = (0, import_utils10.getUiOptions)(uiSchema);
|
|
1722
2446
|
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
|
|
1723
2447
|
const label = uiTitle ?? title ?? name;
|
|
1724
|
-
const Widget = (0,
|
|
1725
|
-
return /* @__PURE__ */ (0,
|
|
2448
|
+
const Widget = (0, import_utils10.getWidget)(schema, widget, widgets2);
|
|
2449
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1726
2450
|
Widget,
|
|
1727
2451
|
{
|
|
1728
2452
|
options: { ...options, enumOptions },
|
|
@@ -1751,10 +2475,10 @@ function StringField(props) {
|
|
|
1751
2475
|
var StringField_default = StringField;
|
|
1752
2476
|
|
|
1753
2477
|
// src/components/fields/NullField.tsx
|
|
1754
|
-
var
|
|
2478
|
+
var import_react9 = require("react");
|
|
1755
2479
|
function NullField(props) {
|
|
1756
2480
|
const { formData, onChange } = props;
|
|
1757
|
-
(0,
|
|
2481
|
+
(0, import_react9.useEffect)(() => {
|
|
1758
2482
|
if (formData === void 0) {
|
|
1759
2483
|
onChange(null);
|
|
1760
2484
|
}
|
|
@@ -1770,6 +2494,9 @@ function fields() {
|
|
|
1770
2494
|
ArrayField: ArrayField_default,
|
|
1771
2495
|
// ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
|
|
1772
2496
|
BooleanField: BooleanField_default,
|
|
2497
|
+
LayoutGridField,
|
|
2498
|
+
LayoutHeaderField,
|
|
2499
|
+
LayoutMultiSchemaField,
|
|
1773
2500
|
NumberField: NumberField_default,
|
|
1774
2501
|
ObjectField: ObjectField_default,
|
|
1775
2502
|
OneOfField: MultiSchemaField_default,
|
|
@@ -1781,24 +2508,24 @@ function fields() {
|
|
|
1781
2508
|
var fields_default = fields;
|
|
1782
2509
|
|
|
1783
2510
|
// src/components/templates/ArrayFieldDescriptionTemplate.tsx
|
|
1784
|
-
var
|
|
1785
|
-
var
|
|
2511
|
+
var import_utils11 = require("@rjsf/utils");
|
|
2512
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1786
2513
|
function ArrayFieldDescriptionTemplate(props) {
|
|
1787
2514
|
const { idSchema, description, registry, schema, uiSchema } = props;
|
|
1788
|
-
const options = (0,
|
|
2515
|
+
const options = (0, import_utils11.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
1789
2516
|
const { label: displayLabel = true } = options;
|
|
1790
2517
|
if (!description || !displayLabel) {
|
|
1791
2518
|
return null;
|
|
1792
2519
|
}
|
|
1793
|
-
const DescriptionFieldTemplate = (0,
|
|
2520
|
+
const DescriptionFieldTemplate = (0, import_utils11.getTemplate)(
|
|
1794
2521
|
"DescriptionFieldTemplate",
|
|
1795
2522
|
registry,
|
|
1796
2523
|
options
|
|
1797
2524
|
);
|
|
1798
|
-
return /* @__PURE__ */ (0,
|
|
2525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1799
2526
|
DescriptionFieldTemplate,
|
|
1800
2527
|
{
|
|
1801
|
-
id: (0,
|
|
2528
|
+
id: (0, import_utils11.descriptionId)(idSchema),
|
|
1802
2529
|
description,
|
|
1803
2530
|
schema,
|
|
1804
2531
|
uiSchema,
|
|
@@ -1808,35 +2535,25 @@ function ArrayFieldDescriptionTemplate(props) {
|
|
|
1808
2535
|
}
|
|
1809
2536
|
|
|
1810
2537
|
// src/components/templates/ArrayFieldItemTemplate.tsx
|
|
1811
|
-
var
|
|
2538
|
+
var import_utils12 = require("@rjsf/utils");
|
|
2539
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1812
2540
|
function ArrayFieldItemTemplate(props) {
|
|
1813
|
-
const {
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
hasToolbar,
|
|
1818
|
-
hasMoveDown,
|
|
1819
|
-
hasMoveUp,
|
|
1820
|
-
hasRemove,
|
|
1821
|
-
hasCopy,
|
|
1822
|
-
index,
|
|
1823
|
-
onCopyIndexClick,
|
|
1824
|
-
onDropIndexClick,
|
|
1825
|
-
onReorderClick,
|
|
1826
|
-
readonly,
|
|
2541
|
+
const { children, className, buttonsProps, hasToolbar, registry, uiSchema } = props;
|
|
2542
|
+
const uiOptions = (0, import_utils12.getUiOptions)(uiSchema);
|
|
2543
|
+
const ArrayFieldItemButtonsTemplate2 = (0, import_utils12.getTemplate)(
|
|
2544
|
+
"ArrayFieldItemButtonsTemplate",
|
|
1827
2545
|
registry,
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
|
|
2546
|
+
uiOptions
|
|
2547
|
+
);
|
|
1831
2548
|
const btnStyle = {
|
|
1832
2549
|
flex: 1,
|
|
1833
2550
|
paddingLeft: 6,
|
|
1834
2551
|
paddingRight: 6,
|
|
1835
2552
|
fontWeight: "bold"
|
|
1836
2553
|
};
|
|
1837
|
-
return /* @__PURE__ */ (0,
|
|
1838
|
-
/* @__PURE__ */ (0,
|
|
1839
|
-
hasToolbar && /* @__PURE__ */ (0,
|
|
2554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className, children: [
|
|
2555
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: hasToolbar ? "col-xs-9" : "col-xs-12", children }),
|
|
2556
|
+
hasToolbar && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "col-xs-3 array-item-toolbox", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1840
2557
|
"div",
|
|
1841
2558
|
{
|
|
1842
2559
|
className: "btn-group",
|
|
@@ -1844,56 +2561,88 @@ function ArrayFieldItemTemplate(props) {
|
|
|
1844
2561
|
display: "flex",
|
|
1845
2562
|
justifyContent: "space-around"
|
|
1846
2563
|
},
|
|
1847
|
-
children:
|
|
1848
|
-
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1849
|
-
MoveUpButton2,
|
|
1850
|
-
{
|
|
1851
|
-
style: btnStyle,
|
|
1852
|
-
disabled: disabled || readonly || !hasMoveUp,
|
|
1853
|
-
onClick: onReorderClick(index, index - 1),
|
|
1854
|
-
uiSchema,
|
|
1855
|
-
registry
|
|
1856
|
-
}
|
|
1857
|
-
),
|
|
1858
|
-
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1859
|
-
MoveDownButton2,
|
|
1860
|
-
{
|
|
1861
|
-
style: btnStyle,
|
|
1862
|
-
disabled: disabled || readonly || !hasMoveDown,
|
|
1863
|
-
onClick: onReorderClick(index, index + 1),
|
|
1864
|
-
uiSchema,
|
|
1865
|
-
registry
|
|
1866
|
-
}
|
|
1867
|
-
),
|
|
1868
|
-
hasCopy && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1869
|
-
CopyButton2,
|
|
1870
|
-
{
|
|
1871
|
-
style: btnStyle,
|
|
1872
|
-
disabled: disabled || readonly,
|
|
1873
|
-
onClick: onCopyIndexClick(index),
|
|
1874
|
-
uiSchema,
|
|
1875
|
-
registry
|
|
1876
|
-
}
|
|
1877
|
-
),
|
|
1878
|
-
hasRemove && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1879
|
-
RemoveButton2,
|
|
1880
|
-
{
|
|
1881
|
-
style: btnStyle,
|
|
1882
|
-
disabled: disabled || readonly,
|
|
1883
|
-
onClick: onDropIndexClick(index),
|
|
1884
|
-
uiSchema,
|
|
1885
|
-
registry
|
|
1886
|
-
}
|
|
1887
|
-
)
|
|
1888
|
-
]
|
|
2564
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ArrayFieldItemButtonsTemplate2, { ...buttonsProps, style: btnStyle })
|
|
1889
2565
|
}
|
|
1890
2566
|
) })
|
|
1891
2567
|
] });
|
|
1892
2568
|
}
|
|
1893
2569
|
|
|
2570
|
+
// src/components/templates/ArrayFieldItemButtonsTemplate.tsx
|
|
2571
|
+
var import_react10 = require("react");
|
|
2572
|
+
var import_utils13 = require("@rjsf/utils");
|
|
2573
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2574
|
+
function ArrayFieldItemButtonsTemplate(props) {
|
|
2575
|
+
const {
|
|
2576
|
+
disabled,
|
|
2577
|
+
hasCopy,
|
|
2578
|
+
hasMoveDown,
|
|
2579
|
+
hasMoveUp,
|
|
2580
|
+
hasRemove,
|
|
2581
|
+
idSchema,
|
|
2582
|
+
index,
|
|
2583
|
+
onCopyIndexClick,
|
|
2584
|
+
onDropIndexClick,
|
|
2585
|
+
onReorderClick,
|
|
2586
|
+
readonly,
|
|
2587
|
+
registry,
|
|
2588
|
+
uiSchema
|
|
2589
|
+
} = props;
|
|
2590
|
+
const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
|
|
2591
|
+
const onCopyClick = (0, import_react10.useMemo)(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
|
|
2592
|
+
const onRemoveClick = (0, import_react10.useMemo)(() => onDropIndexClick(index), [index, onDropIndexClick]);
|
|
2593
|
+
const onArrowUpClick = (0, import_react10.useMemo)(() => onReorderClick(index, index - 1), [index, onReorderClick]);
|
|
2594
|
+
const onArrowDownClick = (0, import_react10.useMemo)(() => onReorderClick(index, index + 1), [index, onReorderClick]);
|
|
2595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
2596
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2597
|
+
MoveUpButton2,
|
|
2598
|
+
{
|
|
2599
|
+
id: (0, import_utils13.buttonId)(idSchema, "moveUp"),
|
|
2600
|
+
className: "rjsf-array-item-move-up",
|
|
2601
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
2602
|
+
onClick: onArrowUpClick,
|
|
2603
|
+
uiSchema,
|
|
2604
|
+
registry
|
|
2605
|
+
}
|
|
2606
|
+
),
|
|
2607
|
+
(hasMoveUp || hasMoveDown) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2608
|
+
MoveDownButton2,
|
|
2609
|
+
{
|
|
2610
|
+
id: (0, import_utils13.buttonId)(idSchema, "moveDown"),
|
|
2611
|
+
className: "rjsf-array-item-move-down",
|
|
2612
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
2613
|
+
onClick: onArrowDownClick,
|
|
2614
|
+
uiSchema,
|
|
2615
|
+
registry
|
|
2616
|
+
}
|
|
2617
|
+
),
|
|
2618
|
+
hasCopy && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2619
|
+
CopyButton2,
|
|
2620
|
+
{
|
|
2621
|
+
id: (0, import_utils13.buttonId)(idSchema, "copy"),
|
|
2622
|
+
className: "rjsf-array-item-copy",
|
|
2623
|
+
disabled: disabled || readonly,
|
|
2624
|
+
onClick: onCopyClick,
|
|
2625
|
+
uiSchema,
|
|
2626
|
+
registry
|
|
2627
|
+
}
|
|
2628
|
+
),
|
|
2629
|
+
hasRemove && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2630
|
+
RemoveButton2,
|
|
2631
|
+
{
|
|
2632
|
+
id: (0, import_utils13.buttonId)(idSchema, "remove"),
|
|
2633
|
+
className: "rjsf-array-item-remove",
|
|
2634
|
+
disabled: disabled || readonly,
|
|
2635
|
+
onClick: onRemoveClick,
|
|
2636
|
+
uiSchema,
|
|
2637
|
+
registry
|
|
2638
|
+
}
|
|
2639
|
+
)
|
|
2640
|
+
] });
|
|
2641
|
+
}
|
|
2642
|
+
|
|
1894
2643
|
// src/components/templates/ArrayFieldTemplate.tsx
|
|
1895
|
-
var
|
|
1896
|
-
var
|
|
2644
|
+
var import_utils14 = require("@rjsf/utils");
|
|
2645
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1897
2646
|
function ArrayFieldTemplate(props) {
|
|
1898
2647
|
const {
|
|
1899
2648
|
canAdd,
|
|
@@ -1909,18 +2658,18 @@ function ArrayFieldTemplate(props) {
|
|
|
1909
2658
|
schema,
|
|
1910
2659
|
title
|
|
1911
2660
|
} = props;
|
|
1912
|
-
const uiOptions = (0,
|
|
1913
|
-
const ArrayFieldDescriptionTemplate2 = (0,
|
|
2661
|
+
const uiOptions = (0, import_utils14.getUiOptions)(uiSchema);
|
|
2662
|
+
const ArrayFieldDescriptionTemplate2 = (0, import_utils14.getTemplate)(
|
|
1914
2663
|
"ArrayFieldDescriptionTemplate",
|
|
1915
2664
|
registry,
|
|
1916
2665
|
uiOptions
|
|
1917
2666
|
);
|
|
1918
|
-
const ArrayFieldItemTemplate2 = (0,
|
|
2667
|
+
const ArrayFieldItemTemplate2 = (0, import_utils14.getTemplate)(
|
|
1919
2668
|
"ArrayFieldItemTemplate",
|
|
1920
2669
|
registry,
|
|
1921
2670
|
uiOptions
|
|
1922
2671
|
);
|
|
1923
|
-
const ArrayFieldTitleTemplate2 = (0,
|
|
2672
|
+
const ArrayFieldTitleTemplate2 = (0, import_utils14.getTemplate)(
|
|
1924
2673
|
"ArrayFieldTitleTemplate",
|
|
1925
2674
|
registry,
|
|
1926
2675
|
uiOptions
|
|
@@ -1928,8 +2677,8 @@ function ArrayFieldTemplate(props) {
|
|
|
1928
2677
|
const {
|
|
1929
2678
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
1930
2679
|
} = registry.templates;
|
|
1931
|
-
return /* @__PURE__ */ (0,
|
|
1932
|
-
/* @__PURE__ */ (0,
|
|
2680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("fieldset", { className, id: idSchema.$id, children: [
|
|
2681
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1933
2682
|
ArrayFieldTitleTemplate2,
|
|
1934
2683
|
{
|
|
1935
2684
|
idSchema,
|
|
@@ -1940,7 +2689,7 @@ function ArrayFieldTemplate(props) {
|
|
|
1940
2689
|
registry
|
|
1941
2690
|
}
|
|
1942
2691
|
),
|
|
1943
|
-
/* @__PURE__ */ (0,
|
|
2692
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1944
2693
|
ArrayFieldDescriptionTemplate2,
|
|
1945
2694
|
{
|
|
1946
2695
|
idSchema,
|
|
@@ -1950,11 +2699,12 @@ function ArrayFieldTemplate(props) {
|
|
|
1950
2699
|
registry
|
|
1951
2700
|
}
|
|
1952
2701
|
),
|
|
1953
|
-
/* @__PURE__ */ (0,
|
|
1954
|
-
canAdd && /* @__PURE__ */ (0,
|
|
2702
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "row array-item-list", children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
|
|
2703
|
+
canAdd && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1955
2704
|
AddButton2,
|
|
1956
2705
|
{
|
|
1957
|
-
|
|
2706
|
+
id: (0, import_utils14.buttonId)(idSchema, "add"),
|
|
2707
|
+
className: "rjsf-array-item-add",
|
|
1958
2708
|
onClick: onAddClick,
|
|
1959
2709
|
disabled: disabled || readonly,
|
|
1960
2710
|
uiSchema,
|
|
@@ -1965,24 +2715,24 @@ function ArrayFieldTemplate(props) {
|
|
|
1965
2715
|
}
|
|
1966
2716
|
|
|
1967
2717
|
// src/components/templates/ArrayFieldTitleTemplate.tsx
|
|
1968
|
-
var
|
|
1969
|
-
var
|
|
2718
|
+
var import_utils15 = require("@rjsf/utils");
|
|
2719
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1970
2720
|
function ArrayFieldTitleTemplate(props) {
|
|
1971
2721
|
const { idSchema, title, schema, uiSchema, required, registry } = props;
|
|
1972
|
-
const options = (0,
|
|
2722
|
+
const options = (0, import_utils15.getUiOptions)(uiSchema, registry.globalUiOptions);
|
|
1973
2723
|
const { label: displayLabel = true } = options;
|
|
1974
2724
|
if (!title || !displayLabel) {
|
|
1975
2725
|
return null;
|
|
1976
2726
|
}
|
|
1977
|
-
const TitleFieldTemplate = (0,
|
|
2727
|
+
const TitleFieldTemplate = (0, import_utils15.getTemplate)(
|
|
1978
2728
|
"TitleFieldTemplate",
|
|
1979
2729
|
registry,
|
|
1980
2730
|
options
|
|
1981
2731
|
);
|
|
1982
|
-
return /* @__PURE__ */ (0,
|
|
2732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1983
2733
|
TitleFieldTemplate,
|
|
1984
2734
|
{
|
|
1985
|
-
id: (0,
|
|
2735
|
+
id: (0, import_utils15.titleId)(idSchema),
|
|
1986
2736
|
title,
|
|
1987
2737
|
required,
|
|
1988
2738
|
schema,
|
|
@@ -1993,9 +2743,9 @@ function ArrayFieldTitleTemplate(props) {
|
|
|
1993
2743
|
}
|
|
1994
2744
|
|
|
1995
2745
|
// src/components/templates/BaseInputTemplate.tsx
|
|
1996
|
-
var
|
|
1997
|
-
var
|
|
1998
|
-
var
|
|
2746
|
+
var import_react11 = require("react");
|
|
2747
|
+
var import_utils16 = require("@rjsf/utils");
|
|
2748
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1999
2749
|
function BaseInputTemplate(props) {
|
|
2000
2750
|
const {
|
|
2001
2751
|
id,
|
|
@@ -2028,7 +2778,7 @@ function BaseInputTemplate(props) {
|
|
|
2028
2778
|
}
|
|
2029
2779
|
const inputProps = {
|
|
2030
2780
|
...rest,
|
|
2031
|
-
...(0,
|
|
2781
|
+
...(0, import_utils16.getInputProps)(schema, type, options)
|
|
2032
2782
|
};
|
|
2033
2783
|
let inputValue;
|
|
2034
2784
|
if (inputProps.type === "number" || inputProps.type === "integer") {
|
|
@@ -2036,20 +2786,20 @@ function BaseInputTemplate(props) {
|
|
|
2036
2786
|
} else {
|
|
2037
2787
|
inputValue = value == null ? "" : value;
|
|
2038
2788
|
}
|
|
2039
|
-
const _onChange = (0,
|
|
2789
|
+
const _onChange = (0, import_react11.useCallback)(
|
|
2040
2790
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
2041
2791
|
[onChange, options]
|
|
2042
2792
|
);
|
|
2043
|
-
const _onBlur = (0,
|
|
2793
|
+
const _onBlur = (0, import_react11.useCallback)(
|
|
2044
2794
|
({ target }) => onBlur(id, target && target.value),
|
|
2045
2795
|
[onBlur, id]
|
|
2046
2796
|
);
|
|
2047
|
-
const _onFocus = (0,
|
|
2797
|
+
const _onFocus = (0, import_react11.useCallback)(
|
|
2048
2798
|
({ target }) => onFocus(id, target && target.value),
|
|
2049
2799
|
[onFocus, id]
|
|
2050
2800
|
);
|
|
2051
|
-
return /* @__PURE__ */ (0,
|
|
2052
|
-
/* @__PURE__ */ (0,
|
|
2801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
2802
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2053
2803
|
"input",
|
|
2054
2804
|
{
|
|
2055
2805
|
id,
|
|
@@ -2060,100 +2810,67 @@ function BaseInputTemplate(props) {
|
|
|
2060
2810
|
autoFocus: autofocus,
|
|
2061
2811
|
value: inputValue,
|
|
2062
2812
|
...inputProps,
|
|
2063
|
-
list: schema.examples ? (0,
|
|
2813
|
+
list: schema.examples ? (0, import_utils16.examplesId)(id) : void 0,
|
|
2064
2814
|
onChange: onChangeOverride || _onChange,
|
|
2065
2815
|
onBlur: _onBlur,
|
|
2066
2816
|
onFocus: _onFocus,
|
|
2067
|
-
"aria-describedby": (0,
|
|
2817
|
+
"aria-describedby": (0, import_utils16.ariaDescribedByIds)(id, !!schema.examples)
|
|
2068
2818
|
}
|
|
2069
2819
|
),
|
|
2070
|
-
Array.isArray(schema.examples) && /* @__PURE__ */ (0,
|
|
2071
|
-
return /* @__PURE__ */ (0,
|
|
2820
|
+
Array.isArray(schema.examples) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("datalist", { id: (0, import_utils16.examplesId)(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
|
|
2821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: example }, example);
|
|
2072
2822
|
}) }, `datalist_${id}`)
|
|
2073
2823
|
] });
|
|
2074
2824
|
}
|
|
2075
2825
|
|
|
2076
2826
|
// src/components/templates/ButtonTemplates/SubmitButton.tsx
|
|
2077
|
-
var
|
|
2078
|
-
var
|
|
2827
|
+
var import_utils17 = require("@rjsf/utils");
|
|
2828
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2079
2829
|
function SubmitButton({ uiSchema }) {
|
|
2080
|
-
const { submitText, norender, props: submitButtonProps = {} } = (0,
|
|
2830
|
+
const { submitText, norender, props: submitButtonProps = {} } = (0, import_utils17.getSubmitButtonOptions)(uiSchema);
|
|
2081
2831
|
if (norender) {
|
|
2082
2832
|
return null;
|
|
2083
2833
|
}
|
|
2084
|
-
return /* @__PURE__ */ (0,
|
|
2834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "submit", ...submitButtonProps, className: `btn btn-info ${submitButtonProps.className || ""}`, children: submitText }) });
|
|
2085
2835
|
}
|
|
2086
2836
|
|
|
2087
2837
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
2088
|
-
var
|
|
2838
|
+
var import_utils19 = require("@rjsf/utils");
|
|
2089
2839
|
|
|
2090
2840
|
// src/components/templates/ButtonTemplates/IconButton.tsx
|
|
2091
|
-
var
|
|
2092
|
-
var
|
|
2841
|
+
var import_utils18 = require("@rjsf/utils");
|
|
2842
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2093
2843
|
function IconButton(props) {
|
|
2094
2844
|
const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
|
|
2095
|
-
return /* @__PURE__ */ (0,
|
|
2845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("i", { className: `glyphicon glyphicon-${icon}` }) });
|
|
2096
2846
|
}
|
|
2097
2847
|
function CopyButton(props) {
|
|
2098
2848
|
const {
|
|
2099
2849
|
registry: { translateString }
|
|
2100
2850
|
} = props;
|
|
2101
|
-
return /* @__PURE__ */ (0,
|
|
2102
|
-
IconButton,
|
|
2103
|
-
{
|
|
2104
|
-
title: translateString(import_utils13.TranslatableString.CopyButton),
|
|
2105
|
-
className: "array-item-copy",
|
|
2106
|
-
...props,
|
|
2107
|
-
icon: "copy"
|
|
2108
|
-
}
|
|
2109
|
-
);
|
|
2851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(IconButton, { title: translateString(import_utils18.TranslatableString.CopyButton), ...props, icon: "copy" });
|
|
2110
2852
|
}
|
|
2111
2853
|
function MoveDownButton(props) {
|
|
2112
2854
|
const {
|
|
2113
2855
|
registry: { translateString }
|
|
2114
2856
|
} = props;
|
|
2115
|
-
return /* @__PURE__ */ (0,
|
|
2116
|
-
IconButton,
|
|
2117
|
-
{
|
|
2118
|
-
title: translateString(import_utils13.TranslatableString.MoveDownButton),
|
|
2119
|
-
className: "array-item-move-down",
|
|
2120
|
-
...props,
|
|
2121
|
-
icon: "arrow-down"
|
|
2122
|
-
}
|
|
2123
|
-
);
|
|
2857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(IconButton, { title: translateString(import_utils18.TranslatableString.MoveDownButton), ...props, icon: "arrow-down" });
|
|
2124
2858
|
}
|
|
2125
2859
|
function MoveUpButton(props) {
|
|
2126
2860
|
const {
|
|
2127
2861
|
registry: { translateString }
|
|
2128
2862
|
} = props;
|
|
2129
|
-
return /* @__PURE__ */ (0,
|
|
2130
|
-
IconButton,
|
|
2131
|
-
{
|
|
2132
|
-
title: translateString(import_utils13.TranslatableString.MoveUpButton),
|
|
2133
|
-
className: "array-item-move-up",
|
|
2134
|
-
...props,
|
|
2135
|
-
icon: "arrow-up"
|
|
2136
|
-
}
|
|
2137
|
-
);
|
|
2863
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(IconButton, { title: translateString(import_utils18.TranslatableString.MoveUpButton), ...props, icon: "arrow-up" });
|
|
2138
2864
|
}
|
|
2139
2865
|
function RemoveButton(props) {
|
|
2140
2866
|
const {
|
|
2141
2867
|
registry: { translateString }
|
|
2142
2868
|
} = props;
|
|
2143
|
-
return /* @__PURE__ */ (0,
|
|
2144
|
-
IconButton,
|
|
2145
|
-
{
|
|
2146
|
-
title: translateString(import_utils13.TranslatableString.RemoveButton),
|
|
2147
|
-
className: "array-item-remove",
|
|
2148
|
-
...props,
|
|
2149
|
-
iconType: "danger",
|
|
2150
|
-
icon: "remove"
|
|
2151
|
-
}
|
|
2152
|
-
);
|
|
2869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(IconButton, { title: translateString(import_utils18.TranslatableString.RemoveButton), ...props, iconType: "danger", icon: "remove" });
|
|
2153
2870
|
}
|
|
2154
2871
|
|
|
2155
2872
|
// src/components/templates/ButtonTemplates/AddButton.tsx
|
|
2156
|
-
var
|
|
2873
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2157
2874
|
function AddButton({
|
|
2158
2875
|
className,
|
|
2159
2876
|
onClick,
|
|
@@ -2161,13 +2878,13 @@ function AddButton({
|
|
|
2161
2878
|
registry
|
|
2162
2879
|
}) {
|
|
2163
2880
|
const { translateString } = registry;
|
|
2164
|
-
return /* @__PURE__ */ (0,
|
|
2881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "row", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2165
2882
|
IconButton,
|
|
2166
2883
|
{
|
|
2167
2884
|
iconType: "info",
|
|
2168
2885
|
icon: "plus",
|
|
2169
2886
|
className: "btn-add col-xs-12",
|
|
2170
|
-
title: translateString(
|
|
2887
|
+
title: translateString(import_utils19.TranslatableString.AddButton),
|
|
2171
2888
|
onClick,
|
|
2172
2889
|
disabled,
|
|
2173
2890
|
registry
|
|
@@ -2188,68 +2905,79 @@ function buttonTemplates() {
|
|
|
2188
2905
|
}
|
|
2189
2906
|
var ButtonTemplates_default = buttonTemplates;
|
|
2190
2907
|
|
|
2908
|
+
// src/components/RichDescription.tsx
|
|
2909
|
+
var import_utils20 = require("@rjsf/utils");
|
|
2910
|
+
var import_markdown_to_jsx2 = __toESM(require("markdown-to-jsx"), 1);
|
|
2911
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2912
|
+
var TEST_IDS = (0, import_utils20.getTestIds)();
|
|
2913
|
+
function RichDescription({ description, registry, uiSchema = {} }) {
|
|
2914
|
+
const { globalUiOptions } = registry;
|
|
2915
|
+
const uiOptions = (0, import_utils20.getUiOptions)(uiSchema, globalUiOptions);
|
|
2916
|
+
if (uiOptions.enableMarkdownInDescription && typeof description === "string") {
|
|
2917
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_markdown_to_jsx2.default, { options: { disableParsingRawHTML: true }, "data-testid": TEST_IDS.markdown, children: description });
|
|
2918
|
+
}
|
|
2919
|
+
return description;
|
|
2920
|
+
}
|
|
2921
|
+
RichDescription.TEST_IDS = TEST_IDS;
|
|
2922
|
+
|
|
2191
2923
|
// src/components/templates/DescriptionField.tsx
|
|
2192
|
-
var
|
|
2924
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2193
2925
|
function DescriptionField(props) {
|
|
2194
|
-
const { id, description } = props;
|
|
2926
|
+
const { id, description, registry, uiSchema } = props;
|
|
2195
2927
|
if (!description) {
|
|
2196
2928
|
return null;
|
|
2197
2929
|
}
|
|
2198
|
-
|
|
2199
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { id, className: "field-description", children: description });
|
|
2200
|
-
} else {
|
|
2201
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { id, className: "field-description", children: description });
|
|
2202
|
-
}
|
|
2930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { id, className: "field-description", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(RichDescription, { description, registry, uiSchema }) });
|
|
2203
2931
|
}
|
|
2204
2932
|
|
|
2205
2933
|
// src/components/templates/ErrorList.tsx
|
|
2206
|
-
var
|
|
2207
|
-
var
|
|
2934
|
+
var import_utils21 = require("@rjsf/utils");
|
|
2935
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2208
2936
|
function ErrorList({
|
|
2209
2937
|
errors,
|
|
2210
2938
|
registry
|
|
2211
2939
|
}) {
|
|
2212
2940
|
const { translateString } = registry;
|
|
2213
|
-
return /* @__PURE__ */ (0,
|
|
2214
|
-
/* @__PURE__ */ (0,
|
|
2215
|
-
/* @__PURE__ */ (0,
|
|
2216
|
-
return /* @__PURE__ */ (0,
|
|
2941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "panel panel-danger errors", children: [
|
|
2942
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "panel-heading", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h3", { className: "panel-title", children: translateString(import_utils21.TranslatableString.ErrorsLabel) }) }),
|
|
2943
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("ul", { className: "list-group", children: errors.map((error, i) => {
|
|
2944
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("li", { className: "list-group-item text-danger", children: error.stack }, i);
|
|
2217
2945
|
}) })
|
|
2218
2946
|
] });
|
|
2219
2947
|
}
|
|
2220
2948
|
|
|
2221
2949
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
2222
|
-
var
|
|
2950
|
+
var import_utils22 = require("@rjsf/utils");
|
|
2223
2951
|
|
|
2224
2952
|
// src/components/templates/FieldTemplate/Label.tsx
|
|
2225
|
-
var
|
|
2953
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2226
2954
|
var REQUIRED_FIELD_SYMBOL = "*";
|
|
2227
2955
|
function Label(props) {
|
|
2228
2956
|
const { label, required, id } = props;
|
|
2229
2957
|
if (!label) {
|
|
2230
2958
|
return null;
|
|
2231
2959
|
}
|
|
2232
|
-
return /* @__PURE__ */ (0,
|
|
2960
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "control-label", htmlFor: id, children: [
|
|
2233
2961
|
label,
|
|
2234
|
-
required && /* @__PURE__ */ (0,
|
|
2962
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "required", children: REQUIRED_FIELD_SYMBOL })
|
|
2235
2963
|
] });
|
|
2236
2964
|
}
|
|
2237
2965
|
|
|
2238
2966
|
// src/components/templates/FieldTemplate/FieldTemplate.tsx
|
|
2239
|
-
var
|
|
2967
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2240
2968
|
function FieldTemplate(props) {
|
|
2241
2969
|
const { id, label, children, errors, help, description, hidden, required, displayLabel, registry, uiSchema } = props;
|
|
2242
|
-
const uiOptions = (0,
|
|
2243
|
-
const WrapIfAdditionalTemplate2 = (0,
|
|
2970
|
+
const uiOptions = (0, import_utils22.getUiOptions)(uiSchema);
|
|
2971
|
+
const WrapIfAdditionalTemplate2 = (0, import_utils22.getTemplate)(
|
|
2244
2972
|
"WrapIfAdditionalTemplate",
|
|
2245
2973
|
registry,
|
|
2246
2974
|
uiOptions
|
|
2247
2975
|
);
|
|
2248
2976
|
if (hidden) {
|
|
2249
|
-
return /* @__PURE__ */ (0,
|
|
2977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "hidden", children });
|
|
2250
2978
|
}
|
|
2251
|
-
return /* @__PURE__ */ (0,
|
|
2252
|
-
displayLabel && /* @__PURE__ */ (0,
|
|
2979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrapIfAdditionalTemplate2, { ...props, children: [
|
|
2980
|
+
displayLabel && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Label, { label, required, id }),
|
|
2253
2981
|
displayLabel && description ? description : null,
|
|
2254
2982
|
children,
|
|
2255
2983
|
errors,
|
|
@@ -2261,37 +2989,44 @@ function FieldTemplate(props) {
|
|
|
2261
2989
|
var FieldTemplate_default = FieldTemplate;
|
|
2262
2990
|
|
|
2263
2991
|
// src/components/templates/FieldErrorTemplate.tsx
|
|
2264
|
-
var
|
|
2265
|
-
var
|
|
2992
|
+
var import_utils23 = require("@rjsf/utils");
|
|
2993
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2266
2994
|
function FieldErrorTemplate(props) {
|
|
2267
2995
|
const { errors = [], idSchema } = props;
|
|
2268
2996
|
if (errors.length === 0) {
|
|
2269
2997
|
return null;
|
|
2270
2998
|
}
|
|
2271
|
-
const id = (0,
|
|
2272
|
-
return /* @__PURE__ */ (0,
|
|
2273
|
-
return /* @__PURE__ */ (0,
|
|
2999
|
+
const id = (0, import_utils23.errorId)(idSchema);
|
|
3000
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
|
|
3001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("li", { className: "text-danger", children: error }, index);
|
|
2274
3002
|
}) }) });
|
|
2275
3003
|
}
|
|
2276
3004
|
|
|
2277
3005
|
// src/components/templates/FieldHelpTemplate.tsx
|
|
2278
|
-
var
|
|
2279
|
-
var
|
|
3006
|
+
var import_utils24 = require("@rjsf/utils");
|
|
3007
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2280
3008
|
function FieldHelpTemplate(props) {
|
|
2281
3009
|
const { idSchema, help } = props;
|
|
2282
3010
|
if (!help) {
|
|
2283
3011
|
return null;
|
|
2284
3012
|
}
|
|
2285
|
-
const id = (0,
|
|
3013
|
+
const id = (0, import_utils24.helpId)(idSchema);
|
|
2286
3014
|
if (typeof help === "string") {
|
|
2287
|
-
return /* @__PURE__ */ (0,
|
|
3015
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { id, className: "help-block", children: help });
|
|
2288
3016
|
}
|
|
2289
|
-
return /* @__PURE__ */ (0,
|
|
3017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { id, className: "help-block", children: help });
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
// src/components/templates/GridTemplate.tsx
|
|
3021
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3022
|
+
function GridTemplate(props) {
|
|
3023
|
+
const { children, column, className, ...rest } = props;
|
|
3024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className, ...rest, children });
|
|
2290
3025
|
}
|
|
2291
3026
|
|
|
2292
3027
|
// src/components/templates/ObjectFieldTemplate.tsx
|
|
2293
|
-
var
|
|
2294
|
-
var
|
|
3028
|
+
var import_utils25 = require("@rjsf/utils");
|
|
3029
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2295
3030
|
function ObjectFieldTemplate(props) {
|
|
2296
3031
|
const {
|
|
2297
3032
|
description,
|
|
@@ -2307,9 +3042,9 @@ function ObjectFieldTemplate(props) {
|
|
|
2307
3042
|
title,
|
|
2308
3043
|
uiSchema
|
|
2309
3044
|
} = props;
|
|
2310
|
-
const options = (0,
|
|
2311
|
-
const TitleFieldTemplate = (0,
|
|
2312
|
-
const DescriptionFieldTemplate = (0,
|
|
3045
|
+
const options = (0, import_utils25.getUiOptions)(uiSchema);
|
|
3046
|
+
const TitleFieldTemplate = (0, import_utils25.getTemplate)("TitleFieldTemplate", registry, options);
|
|
3047
|
+
const DescriptionFieldTemplate = (0, import_utils25.getTemplate)(
|
|
2313
3048
|
"DescriptionFieldTemplate",
|
|
2314
3049
|
registry,
|
|
2315
3050
|
options
|
|
@@ -2317,11 +3052,11 @@ function ObjectFieldTemplate(props) {
|
|
|
2317
3052
|
const {
|
|
2318
3053
|
ButtonTemplates: { AddButton: AddButton2 }
|
|
2319
3054
|
} = registry.templates;
|
|
2320
|
-
return /* @__PURE__ */ (0,
|
|
2321
|
-
title && /* @__PURE__ */ (0,
|
|
3055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("fieldset", { id: idSchema.$id, children: [
|
|
3056
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2322
3057
|
TitleFieldTemplate,
|
|
2323
3058
|
{
|
|
2324
|
-
id: (0,
|
|
3059
|
+
id: (0, import_utils25.titleId)(idSchema),
|
|
2325
3060
|
title,
|
|
2326
3061
|
required,
|
|
2327
3062
|
schema,
|
|
@@ -2329,10 +3064,10 @@ function ObjectFieldTemplate(props) {
|
|
|
2329
3064
|
registry
|
|
2330
3065
|
}
|
|
2331
3066
|
),
|
|
2332
|
-
description && /* @__PURE__ */ (0,
|
|
3067
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2333
3068
|
DescriptionFieldTemplate,
|
|
2334
3069
|
{
|
|
2335
|
-
id: (0,
|
|
3070
|
+
id: (0, import_utils25.descriptionId)(idSchema),
|
|
2336
3071
|
description,
|
|
2337
3072
|
schema,
|
|
2338
3073
|
uiSchema,
|
|
@@ -2340,10 +3075,11 @@ function ObjectFieldTemplate(props) {
|
|
|
2340
3075
|
}
|
|
2341
3076
|
),
|
|
2342
3077
|
properties.map((prop) => prop.content),
|
|
2343
|
-
(0,
|
|
3078
|
+
(0, import_utils25.canExpand)(schema, uiSchema, formData) && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2344
3079
|
AddButton2,
|
|
2345
3080
|
{
|
|
2346
|
-
|
|
3081
|
+
id: (0, import_utils25.buttonId)(idSchema, "add"),
|
|
3082
|
+
className: "rjsf-object-property-expand",
|
|
2347
3083
|
onClick: onAddClick(schema),
|
|
2348
3084
|
disabled: disabled || readonly,
|
|
2349
3085
|
uiSchema,
|
|
@@ -2354,43 +3090,43 @@ function ObjectFieldTemplate(props) {
|
|
|
2354
3090
|
}
|
|
2355
3091
|
|
|
2356
3092
|
// src/components/templates/TitleField.tsx
|
|
2357
|
-
var
|
|
3093
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2358
3094
|
var REQUIRED_FIELD_SYMBOL2 = "*";
|
|
2359
3095
|
function TitleField(props) {
|
|
2360
3096
|
const { id, title, required } = props;
|
|
2361
|
-
return /* @__PURE__ */ (0,
|
|
3097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("legend", { id, children: [
|
|
2362
3098
|
title,
|
|
2363
|
-
required && /* @__PURE__ */ (0,
|
|
3099
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "required", children: REQUIRED_FIELD_SYMBOL2 })
|
|
2364
3100
|
] });
|
|
2365
3101
|
}
|
|
2366
3102
|
|
|
2367
3103
|
// src/components/templates/UnsupportedField.tsx
|
|
2368
|
-
var
|
|
2369
|
-
var import_markdown_to_jsx3 = __toESM(require("markdown-to-jsx"));
|
|
2370
|
-
var
|
|
3104
|
+
var import_utils26 = require("@rjsf/utils");
|
|
3105
|
+
var import_markdown_to_jsx3 = __toESM(require("markdown-to-jsx"), 1);
|
|
3106
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
2371
3107
|
function UnsupportedField(props) {
|
|
2372
3108
|
const { schema, idSchema, reason, registry } = props;
|
|
2373
3109
|
const { translateString } = registry;
|
|
2374
|
-
let translateEnum =
|
|
3110
|
+
let translateEnum = import_utils26.TranslatableString.UnsupportedField;
|
|
2375
3111
|
const translateParams = [];
|
|
2376
3112
|
if (idSchema && idSchema.$id) {
|
|
2377
|
-
translateEnum =
|
|
3113
|
+
translateEnum = import_utils26.TranslatableString.UnsupportedFieldWithId;
|
|
2378
3114
|
translateParams.push(idSchema.$id);
|
|
2379
3115
|
}
|
|
2380
3116
|
if (reason) {
|
|
2381
|
-
translateEnum = translateEnum ===
|
|
3117
|
+
translateEnum = translateEnum === import_utils26.TranslatableString.UnsupportedField ? import_utils26.TranslatableString.UnsupportedFieldWithReason : import_utils26.TranslatableString.UnsupportedFieldWithIdAndReason;
|
|
2382
3118
|
translateParams.push(reason);
|
|
2383
3119
|
}
|
|
2384
|
-
return /* @__PURE__ */ (0,
|
|
2385
|
-
/* @__PURE__ */ (0,
|
|
2386
|
-
schema && /* @__PURE__ */ (0,
|
|
3120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "unsupported-field", children: [
|
|
3121
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_markdown_to_jsx3.default, { options: { disableParsingRawHTML: true }, children: translateString(translateEnum, translateParams) }) }),
|
|
3122
|
+
schema && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("pre", { children: JSON.stringify(schema, null, 2) })
|
|
2387
3123
|
] });
|
|
2388
3124
|
}
|
|
2389
3125
|
var UnsupportedField_default = UnsupportedField;
|
|
2390
3126
|
|
|
2391
3127
|
// src/components/templates/WrapIfAdditionalTemplate.tsx
|
|
2392
|
-
var
|
|
2393
|
-
var
|
|
3128
|
+
var import_utils27 = require("@rjsf/utils");
|
|
3129
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
2394
3130
|
function WrapIfAdditionalTemplate(props) {
|
|
2395
3131
|
const {
|
|
2396
3132
|
id,
|
|
@@ -2403,21 +3139,28 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2403
3139
|
readonly,
|
|
2404
3140
|
required,
|
|
2405
3141
|
schema,
|
|
3142
|
+
hideError,
|
|
3143
|
+
rawErrors,
|
|
2406
3144
|
children,
|
|
2407
3145
|
uiSchema,
|
|
2408
3146
|
registry
|
|
2409
3147
|
} = props;
|
|
2410
3148
|
const { templates: templates2, translateString } = registry;
|
|
2411
3149
|
const { RemoveButton: RemoveButton2 } = templates2.ButtonTemplates;
|
|
2412
|
-
const keyLabel = translateString(
|
|
2413
|
-
const additional =
|
|
3150
|
+
const keyLabel = translateString(import_utils27.TranslatableString.KeyLabel, [label]);
|
|
3151
|
+
const additional = import_utils27.ADDITIONAL_PROPERTY_FLAG in schema;
|
|
3152
|
+
const classNamesList = ["form-group", classNames];
|
|
3153
|
+
if (!hideError && rawErrors && rawErrors.length > 0) {
|
|
3154
|
+
classNamesList.push("has-error has-danger");
|
|
3155
|
+
}
|
|
3156
|
+
const uiClassNames = classNamesList.join(" ").trim();
|
|
2414
3157
|
if (!additional) {
|
|
2415
|
-
return /* @__PURE__ */ (0,
|
|
3158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: uiClassNames, style, children });
|
|
2416
3159
|
}
|
|
2417
|
-
return /* @__PURE__ */ (0,
|
|
2418
|
-
/* @__PURE__ */ (0,
|
|
2419
|
-
/* @__PURE__ */ (0,
|
|
2420
|
-
/* @__PURE__ */ (0,
|
|
3160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: uiClassNames, style, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "row", children: [
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "form-group", children: [
|
|
3162
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Label, { label: keyLabel, required, id: `${id}-key` }),
|
|
3163
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2421
3164
|
"input",
|
|
2422
3165
|
{
|
|
2423
3166
|
className: "form-control",
|
|
@@ -2428,11 +3171,12 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
2428
3171
|
}
|
|
2429
3172
|
)
|
|
2430
3173
|
] }) }),
|
|
2431
|
-
/* @__PURE__ */ (0,
|
|
2432
|
-
/* @__PURE__ */ (0,
|
|
3174
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "form-additional form-group col-xs-5", children }),
|
|
3175
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "col-xs-2", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
2433
3176
|
RemoveButton2,
|
|
2434
3177
|
{
|
|
2435
|
-
|
|
3178
|
+
id: (0, import_utils27.buttonId)(id, "remove"),
|
|
3179
|
+
className: "rjsf-object-property-remove btn-block",
|
|
2436
3180
|
style: { border: "0" },
|
|
2437
3181
|
disabled: disabled || readonly,
|
|
2438
3182
|
onClick: onDropPropertyClick(label),
|
|
@@ -2448,6 +3192,7 @@ function templates() {
|
|
|
2448
3192
|
return {
|
|
2449
3193
|
ArrayFieldDescriptionTemplate,
|
|
2450
3194
|
ArrayFieldItemTemplate,
|
|
3195
|
+
ArrayFieldItemButtonsTemplate,
|
|
2451
3196
|
ArrayFieldTemplate,
|
|
2452
3197
|
ArrayFieldTitleTemplate,
|
|
2453
3198
|
ButtonTemplates: ButtonTemplates_default(),
|
|
@@ -2457,6 +3202,7 @@ function templates() {
|
|
|
2457
3202
|
FieldTemplate: FieldTemplate_default,
|
|
2458
3203
|
FieldErrorTemplate,
|
|
2459
3204
|
FieldHelpTemplate,
|
|
3205
|
+
GridTemplate,
|
|
2460
3206
|
ObjectFieldTemplate,
|
|
2461
3207
|
TitleFieldTemplate: TitleField,
|
|
2462
3208
|
UnsupportedFieldTemplate: UnsupportedField_default,
|
|
@@ -2466,9 +3212,9 @@ function templates() {
|
|
|
2466
3212
|
var templates_default = templates;
|
|
2467
3213
|
|
|
2468
3214
|
// src/components/widgets/AltDateWidget.tsx
|
|
2469
|
-
var
|
|
2470
|
-
var
|
|
2471
|
-
var
|
|
3215
|
+
var import_react12 = require("react");
|
|
3216
|
+
var import_utils28 = require("@rjsf/utils");
|
|
3217
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
2472
3218
|
function readyForChange(state) {
|
|
2473
3219
|
return Object.values(state).every((value) => value !== -1);
|
|
2474
3220
|
}
|
|
@@ -2488,14 +3234,14 @@ function DateElement({
|
|
|
2488
3234
|
}) {
|
|
2489
3235
|
const id = rootId + "_" + type;
|
|
2490
3236
|
const { SelectWidget: SelectWidget2 } = registry.widgets;
|
|
2491
|
-
return /* @__PURE__ */ (0,
|
|
3237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2492
3238
|
SelectWidget2,
|
|
2493
3239
|
{
|
|
2494
3240
|
schema: { type: "integer" },
|
|
2495
3241
|
id,
|
|
2496
3242
|
name,
|
|
2497
3243
|
className: "form-control",
|
|
2498
|
-
options: { enumOptions: (0,
|
|
3244
|
+
options: { enumOptions: (0, import_utils28.dateRangeOptions)(range[0], range[1]) },
|
|
2499
3245
|
placeholder: type,
|
|
2500
3246
|
value,
|
|
2501
3247
|
disabled,
|
|
@@ -2506,7 +3252,7 @@ function DateElement({
|
|
|
2506
3252
|
onFocus,
|
|
2507
3253
|
registry,
|
|
2508
3254
|
label: "",
|
|
2509
|
-
"aria-describedby": (0,
|
|
3255
|
+
"aria-describedby": (0, import_utils28.ariaDescribedByIds)(rootId)
|
|
2510
3256
|
}
|
|
2511
3257
|
);
|
|
2512
3258
|
}
|
|
@@ -2525,34 +3271,37 @@ function AltDateWidget({
|
|
|
2525
3271
|
value
|
|
2526
3272
|
}) {
|
|
2527
3273
|
const { translateString } = registry;
|
|
2528
|
-
const [lastValue, setLastValue] = (0,
|
|
2529
|
-
const [state, setState] = (0,
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
3274
|
+
const [lastValue, setLastValue] = (0, import_react12.useState)(value);
|
|
3275
|
+
const [state, setState] = (0, import_react12.useReducer)(
|
|
3276
|
+
(state2, action) => {
|
|
3277
|
+
return { ...state2, ...action };
|
|
3278
|
+
},
|
|
3279
|
+
(0, import_utils28.parseDateString)(value, time)
|
|
3280
|
+
);
|
|
3281
|
+
(0, import_react12.useEffect)(() => {
|
|
3282
|
+
const stateValue = (0, import_utils28.toDateString)(state, time);
|
|
2534
3283
|
if (readyForChange(state) && stateValue !== value) {
|
|
2535
3284
|
onChange(stateValue);
|
|
2536
3285
|
} else if (lastValue !== value) {
|
|
2537
3286
|
setLastValue(value);
|
|
2538
|
-
setState((0,
|
|
3287
|
+
setState((0, import_utils28.parseDateString)(value, time));
|
|
2539
3288
|
}
|
|
2540
3289
|
}, [time, value, onChange, state, lastValue]);
|
|
2541
|
-
const handleChange = (0,
|
|
3290
|
+
const handleChange = (0, import_react12.useCallback)((property, value2) => {
|
|
2542
3291
|
setState({ [property]: value2 });
|
|
2543
3292
|
}, []);
|
|
2544
|
-
const handleSetNow = (0,
|
|
3293
|
+
const handleSetNow = (0, import_react12.useCallback)(
|
|
2545
3294
|
(event) => {
|
|
2546
3295
|
event.preventDefault();
|
|
2547
3296
|
if (disabled || readonly) {
|
|
2548
3297
|
return;
|
|
2549
3298
|
}
|
|
2550
|
-
const nextState = (0,
|
|
2551
|
-
onChange((0,
|
|
3299
|
+
const nextState = (0, import_utils28.parseDateString)((/* @__PURE__ */ new Date()).toJSON(), time);
|
|
3300
|
+
onChange((0, import_utils28.toDateString)(nextState, time));
|
|
2552
3301
|
},
|
|
2553
3302
|
[disabled, readonly, time]
|
|
2554
3303
|
);
|
|
2555
|
-
const handleClear = (0,
|
|
3304
|
+
const handleClear = (0, import_react12.useCallback)(
|
|
2556
3305
|
(event) => {
|
|
2557
3306
|
event.preventDefault();
|
|
2558
3307
|
if (disabled || readonly) {
|
|
@@ -2562,13 +3311,13 @@ function AltDateWidget({
|
|
|
2562
3311
|
},
|
|
2563
3312
|
[disabled, readonly, onChange]
|
|
2564
3313
|
);
|
|
2565
|
-
return /* @__PURE__ */ (0,
|
|
2566
|
-
(0,
|
|
3314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("ul", { className: "list-inline", children: [
|
|
3315
|
+
(0, import_utils28.getDateElementProps)(
|
|
2567
3316
|
state,
|
|
2568
3317
|
time,
|
|
2569
3318
|
options.yearsRange,
|
|
2570
3319
|
options.format
|
|
2571
|
-
).map((elemProps, i) => /* @__PURE__ */ (0,
|
|
3320
|
+
).map((elemProps, i) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2572
3321
|
DateElement,
|
|
2573
3322
|
{
|
|
2574
3323
|
rootId: id,
|
|
@@ -2583,27 +3332,27 @@ function AltDateWidget({
|
|
|
2583
3332
|
autofocus: autofocus && i === 0
|
|
2584
3333
|
}
|
|
2585
3334
|
) }, i)),
|
|
2586
|
-
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ (0,
|
|
2587
|
-
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ (0,
|
|
3335
|
+
(options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(import_utils28.TranslatableString.NowLabel) }) }),
|
|
3336
|
+
(options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("li", { className: "list-inline-item", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(import_utils28.TranslatableString.ClearLabel) }) })
|
|
2588
3337
|
] });
|
|
2589
3338
|
}
|
|
2590
3339
|
var AltDateWidget_default = AltDateWidget;
|
|
2591
3340
|
|
|
2592
3341
|
// src/components/widgets/AltDateTimeWidget.tsx
|
|
2593
|
-
var
|
|
3342
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
2594
3343
|
function AltDateTimeWidget({
|
|
2595
3344
|
time = true,
|
|
2596
3345
|
...props
|
|
2597
3346
|
}) {
|
|
2598
3347
|
const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
|
|
2599
|
-
return /* @__PURE__ */ (0,
|
|
3348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(AltDateWidget2, { time, ...props });
|
|
2600
3349
|
}
|
|
2601
3350
|
var AltDateTimeWidget_default = AltDateTimeWidget;
|
|
2602
3351
|
|
|
2603
3352
|
// src/components/widgets/CheckboxWidget.tsx
|
|
2604
|
-
var
|
|
2605
|
-
var
|
|
2606
|
-
var
|
|
3353
|
+
var import_react13 = require("react");
|
|
3354
|
+
var import_utils29 = require("@rjsf/utils");
|
|
3355
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
2607
3356
|
function CheckboxWidget({
|
|
2608
3357
|
schema,
|
|
2609
3358
|
uiSchema,
|
|
@@ -2620,38 +3369,38 @@ function CheckboxWidget({
|
|
|
2620
3369
|
onChange,
|
|
2621
3370
|
registry
|
|
2622
3371
|
}) {
|
|
2623
|
-
const DescriptionFieldTemplate = (0,
|
|
3372
|
+
const DescriptionFieldTemplate = (0, import_utils29.getTemplate)(
|
|
2624
3373
|
"DescriptionFieldTemplate",
|
|
2625
3374
|
registry,
|
|
2626
3375
|
options
|
|
2627
3376
|
);
|
|
2628
|
-
const required = (0,
|
|
2629
|
-
const handleChange = (0,
|
|
3377
|
+
const required = (0, import_utils29.schemaRequiresTrueValue)(schema);
|
|
3378
|
+
const handleChange = (0, import_react13.useCallback)(
|
|
2630
3379
|
(event) => onChange(event.target.checked),
|
|
2631
3380
|
[onChange]
|
|
2632
3381
|
);
|
|
2633
|
-
const handleBlur = (0,
|
|
3382
|
+
const handleBlur = (0, import_react13.useCallback)(
|
|
2634
3383
|
(event) => onBlur(id, event.target.checked),
|
|
2635
3384
|
[onBlur, id]
|
|
2636
3385
|
);
|
|
2637
|
-
const handleFocus = (0,
|
|
3386
|
+
const handleFocus = (0, import_react13.useCallback)(
|
|
2638
3387
|
(event) => onFocus(id, event.target.checked),
|
|
2639
3388
|
[onFocus, id]
|
|
2640
3389
|
);
|
|
2641
3390
|
const description = options.description ?? schema.description;
|
|
2642
|
-
return /* @__PURE__ */ (0,
|
|
2643
|
-
!hideLabel &&
|
|
3391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
|
|
3392
|
+
!hideLabel && description && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
2644
3393
|
DescriptionFieldTemplate,
|
|
2645
3394
|
{
|
|
2646
|
-
id: (0,
|
|
3395
|
+
id: (0, import_utils29.descriptionId)(id),
|
|
2647
3396
|
description,
|
|
2648
3397
|
schema,
|
|
2649
3398
|
uiSchema,
|
|
2650
3399
|
registry
|
|
2651
3400
|
}
|
|
2652
3401
|
),
|
|
2653
|
-
/* @__PURE__ */ (0,
|
|
2654
|
-
/* @__PURE__ */ (0,
|
|
3402
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("label", { children: [
|
|
3403
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
2655
3404
|
"input",
|
|
2656
3405
|
{
|
|
2657
3406
|
type: "checkbox",
|
|
@@ -2664,19 +3413,19 @@ function CheckboxWidget({
|
|
|
2664
3413
|
onChange: handleChange,
|
|
2665
3414
|
onBlur: handleBlur,
|
|
2666
3415
|
onFocus: handleFocus,
|
|
2667
|
-
"aria-describedby": (0,
|
|
3416
|
+
"aria-describedby": (0, import_utils29.ariaDescribedByIds)(id)
|
|
2668
3417
|
}
|
|
2669
3418
|
),
|
|
2670
|
-
(0,
|
|
3419
|
+
(0, import_utils29.labelValue)(/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { children: label }), hideLabel)
|
|
2671
3420
|
] })
|
|
2672
3421
|
] });
|
|
2673
3422
|
}
|
|
2674
3423
|
var CheckboxWidget_default = CheckboxWidget;
|
|
2675
3424
|
|
|
2676
3425
|
// src/components/widgets/CheckboxesWidget.tsx
|
|
2677
|
-
var
|
|
2678
|
-
var
|
|
2679
|
-
var
|
|
3426
|
+
var import_react14 = require("react");
|
|
3427
|
+
var import_utils30 = require("@rjsf/utils");
|
|
3428
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
2680
3429
|
function CheckboxesWidget({
|
|
2681
3430
|
id,
|
|
2682
3431
|
disabled,
|
|
@@ -2689,31 +3438,31 @@ function CheckboxesWidget({
|
|
|
2689
3438
|
onFocus
|
|
2690
3439
|
}) {
|
|
2691
3440
|
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
2692
|
-
const handleBlur = (0,
|
|
2693
|
-
({ target }) => onBlur(id, (0,
|
|
3441
|
+
const handleBlur = (0, import_react14.useCallback)(
|
|
3442
|
+
({ target }) => onBlur(id, (0, import_utils30.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
2694
3443
|
[onBlur, id]
|
|
2695
3444
|
);
|
|
2696
|
-
const handleFocus = (0,
|
|
2697
|
-
({ target }) => onFocus(id, (0,
|
|
3445
|
+
const handleFocus = (0, import_react14.useCallback)(
|
|
3446
|
+
({ target }) => onFocus(id, (0, import_utils30.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
2698
3447
|
[onFocus, id]
|
|
2699
3448
|
);
|
|
2700
|
-
return /* @__PURE__ */ (0,
|
|
2701
|
-
const checked = (0,
|
|
3449
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
3450
|
+
const checked = (0, import_utils30.enumOptionsIsSelected)(option.value, checkboxesValues);
|
|
2702
3451
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
2703
3452
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
2704
3453
|
const handleChange = (event) => {
|
|
2705
3454
|
if (event.target.checked) {
|
|
2706
|
-
onChange((0,
|
|
3455
|
+
onChange((0, import_utils30.enumOptionsSelectValue)(index, checkboxesValues, enumOptions));
|
|
2707
3456
|
} else {
|
|
2708
|
-
onChange((0,
|
|
3457
|
+
onChange((0, import_utils30.enumOptionsDeselectValue)(index, checkboxesValues, enumOptions));
|
|
2709
3458
|
}
|
|
2710
3459
|
};
|
|
2711
|
-
const checkbox = /* @__PURE__ */ (0,
|
|
2712
|
-
/* @__PURE__ */ (0,
|
|
3460
|
+
const checkbox = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("span", { children: [
|
|
3461
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
2713
3462
|
"input",
|
|
2714
3463
|
{
|
|
2715
3464
|
type: "checkbox",
|
|
2716
|
-
id: (0,
|
|
3465
|
+
id: (0, import_utils30.optionId)(id, index),
|
|
2717
3466
|
name: id,
|
|
2718
3467
|
checked,
|
|
2719
3468
|
value: String(index),
|
|
@@ -2722,67 +3471,67 @@ function CheckboxesWidget({
|
|
|
2722
3471
|
onChange: handleChange,
|
|
2723
3472
|
onBlur: handleBlur,
|
|
2724
3473
|
onFocus: handleFocus,
|
|
2725
|
-
"aria-describedby": (0,
|
|
3474
|
+
"aria-describedby": (0, import_utils30.ariaDescribedByIds)(id)
|
|
2726
3475
|
}
|
|
2727
3476
|
),
|
|
2728
|
-
/* @__PURE__ */ (0,
|
|
3477
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { children: option.label })
|
|
2729
3478
|
] });
|
|
2730
|
-
return inline ? /* @__PURE__ */ (0,
|
|
3479
|
+
return inline ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("label", { children: checkbox }) }, index);
|
|
2731
3480
|
}) });
|
|
2732
3481
|
}
|
|
2733
3482
|
var CheckboxesWidget_default = CheckboxesWidget;
|
|
2734
3483
|
|
|
2735
3484
|
// src/components/widgets/ColorWidget.tsx
|
|
2736
|
-
var
|
|
2737
|
-
var
|
|
3485
|
+
var import_utils31 = require("@rjsf/utils");
|
|
3486
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
2738
3487
|
function ColorWidget(props) {
|
|
2739
3488
|
const { disabled, readonly, options, registry } = props;
|
|
2740
|
-
const BaseInputTemplate2 = (0,
|
|
2741
|
-
return /* @__PURE__ */ (0,
|
|
3489
|
+
const BaseInputTemplate2 = (0, import_utils31.getTemplate)("BaseInputTemplate", registry, options);
|
|
3490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
|
|
2742
3491
|
}
|
|
2743
3492
|
|
|
2744
3493
|
// src/components/widgets/DateWidget.tsx
|
|
2745
|
-
var
|
|
2746
|
-
var
|
|
2747
|
-
var
|
|
3494
|
+
var import_react15 = require("react");
|
|
3495
|
+
var import_utils32 = require("@rjsf/utils");
|
|
3496
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
2748
3497
|
function DateWidget(props) {
|
|
2749
3498
|
const { onChange, options, registry } = props;
|
|
2750
|
-
const BaseInputTemplate2 = (0,
|
|
2751
|
-
const handleChange = (0,
|
|
2752
|
-
return /* @__PURE__ */ (0,
|
|
3499
|
+
const BaseInputTemplate2 = (0, import_utils32.getTemplate)("BaseInputTemplate", registry, options);
|
|
3500
|
+
const handleChange = (0, import_react15.useCallback)((value) => onChange(value || void 0), [onChange]);
|
|
3501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
|
|
2753
3502
|
}
|
|
2754
3503
|
|
|
2755
3504
|
// src/components/widgets/DateTimeWidget.tsx
|
|
2756
|
-
var
|
|
2757
|
-
var
|
|
3505
|
+
var import_utils33 = require("@rjsf/utils");
|
|
3506
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
2758
3507
|
function DateTimeWidget(props) {
|
|
2759
3508
|
const { onChange, value, options, registry } = props;
|
|
2760
|
-
const BaseInputTemplate2 = (0,
|
|
2761
|
-
return /* @__PURE__ */ (0,
|
|
3509
|
+
const BaseInputTemplate2 = (0, import_utils33.getTemplate)("BaseInputTemplate", registry, options);
|
|
3510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2762
3511
|
BaseInputTemplate2,
|
|
2763
3512
|
{
|
|
2764
3513
|
type: "datetime-local",
|
|
2765
3514
|
...props,
|
|
2766
|
-
value: (0,
|
|
2767
|
-
onChange: (value2) => onChange((0,
|
|
3515
|
+
value: (0, import_utils33.utcToLocal)(value),
|
|
3516
|
+
onChange: (value2) => onChange((0, import_utils33.localToUTC)(value2))
|
|
2768
3517
|
}
|
|
2769
3518
|
);
|
|
2770
3519
|
}
|
|
2771
3520
|
|
|
2772
3521
|
// src/components/widgets/EmailWidget.tsx
|
|
2773
|
-
var
|
|
2774
|
-
var
|
|
3522
|
+
var import_utils34 = require("@rjsf/utils");
|
|
3523
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
2775
3524
|
function EmailWidget(props) {
|
|
2776
3525
|
const { options, registry } = props;
|
|
2777
|
-
const BaseInputTemplate2 = (0,
|
|
2778
|
-
return /* @__PURE__ */ (0,
|
|
3526
|
+
const BaseInputTemplate2 = (0, import_utils34.getTemplate)("BaseInputTemplate", registry, options);
|
|
3527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BaseInputTemplate2, { type: "email", ...props });
|
|
2779
3528
|
}
|
|
2780
3529
|
|
|
2781
3530
|
// src/components/widgets/FileWidget.tsx
|
|
2782
|
-
var
|
|
2783
|
-
var
|
|
2784
|
-
var import_markdown_to_jsx4 = __toESM(require("markdown-to-jsx"));
|
|
2785
|
-
var
|
|
3531
|
+
var import_react16 = require("react");
|
|
3532
|
+
var import_utils35 = require("@rjsf/utils");
|
|
3533
|
+
var import_markdown_to_jsx4 = __toESM(require("markdown-to-jsx"), 1);
|
|
3534
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
2786
3535
|
function addNameToDataURL(dataURL, name) {
|
|
2787
3536
|
if (dataURL === null) {
|
|
2788
3537
|
return null;
|
|
@@ -2827,11 +3576,11 @@ function FileInfoPreview({
|
|
|
2827
3576
|
return null;
|
|
2828
3577
|
}
|
|
2829
3578
|
if (["image/jpeg", "image/png"].includes(type)) {
|
|
2830
|
-
return /* @__PURE__ */ (0,
|
|
3579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
|
|
2831
3580
|
}
|
|
2832
|
-
return /* @__PURE__ */ (0,
|
|
3581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
|
|
2833
3582
|
" ",
|
|
2834
|
-
/* @__PURE__ */ (0,
|
|
3583
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(import_utils35.TranslatableString.PreviewLabel) })
|
|
2835
3584
|
] });
|
|
2836
3585
|
}
|
|
2837
3586
|
function FilesInfo({
|
|
@@ -2845,14 +3594,14 @@ function FilesInfo({
|
|
|
2845
3594
|
return null;
|
|
2846
3595
|
}
|
|
2847
3596
|
const { translateString } = registry;
|
|
2848
|
-
const { RemoveButton: RemoveButton2 } = (0,
|
|
2849
|
-
return /* @__PURE__ */ (0,
|
|
3597
|
+
const { RemoveButton: RemoveButton2 } = (0, import_utils35.getTemplate)("ButtonTemplates", registry, options);
|
|
3598
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
|
|
2850
3599
|
const { name, size, type } = fileInfo;
|
|
2851
3600
|
const handleRemove = () => onRemove(key);
|
|
2852
|
-
return /* @__PURE__ */ (0,
|
|
2853
|
-
/* @__PURE__ */ (0,
|
|
2854
|
-
preview && /* @__PURE__ */ (0,
|
|
2855
|
-
/* @__PURE__ */ (0,
|
|
3601
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("li", { children: [
|
|
3602
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_markdown_to_jsx4.default, { children: translateString(import_utils35.TranslatableString.FilesInfo, [name, type, String(size)]) }),
|
|
3603
|
+
preview && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(FileInfoPreview, { fileInfo, registry }),
|
|
3604
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(RemoveButton2, { onClick: handleRemove, registry })
|
|
2856
3605
|
] }, key);
|
|
2857
3606
|
}) });
|
|
2858
3607
|
}
|
|
@@ -2862,7 +3611,7 @@ function extractFileInfo(dataURLs) {
|
|
|
2862
3611
|
return acc;
|
|
2863
3612
|
}
|
|
2864
3613
|
try {
|
|
2865
|
-
const { blob, name } = (0,
|
|
3614
|
+
const { blob, name } = (0, import_utils35.dataURItoBlob)(dataURL);
|
|
2866
3615
|
return [
|
|
2867
3616
|
...acc,
|
|
2868
3617
|
{
|
|
@@ -2872,15 +3621,15 @@ function extractFileInfo(dataURLs) {
|
|
|
2872
3621
|
type: blob.type
|
|
2873
3622
|
}
|
|
2874
3623
|
];
|
|
2875
|
-
} catch
|
|
3624
|
+
} catch {
|
|
2876
3625
|
return acc;
|
|
2877
3626
|
}
|
|
2878
3627
|
}, []);
|
|
2879
3628
|
}
|
|
2880
3629
|
function FileWidget(props) {
|
|
2881
3630
|
const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
|
|
2882
|
-
const BaseInputTemplate2 = (0,
|
|
2883
|
-
const handleChange = (0,
|
|
3631
|
+
const BaseInputTemplate2 = (0, import_utils35.getTemplate)("BaseInputTemplate", registry, options);
|
|
3632
|
+
const handleChange = (0, import_react16.useCallback)(
|
|
2884
3633
|
(event) => {
|
|
2885
3634
|
if (!event.target.files) {
|
|
2886
3635
|
return;
|
|
@@ -2888,7 +3637,7 @@ function FileWidget(props) {
|
|
|
2888
3637
|
processFiles(event.target.files).then((filesInfoEvent) => {
|
|
2889
3638
|
const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL);
|
|
2890
3639
|
if (multiple) {
|
|
2891
|
-
onChange(value.concat(newValue
|
|
3640
|
+
onChange(value.concat(newValue));
|
|
2892
3641
|
} else {
|
|
2893
3642
|
onChange(newValue[0]);
|
|
2894
3643
|
}
|
|
@@ -2896,8 +3645,8 @@ function FileWidget(props) {
|
|
|
2896
3645
|
},
|
|
2897
3646
|
[multiple, value, onChange]
|
|
2898
3647
|
);
|
|
2899
|
-
const filesInfo = (0,
|
|
2900
|
-
const rmFile = (0,
|
|
3648
|
+
const filesInfo = (0, import_react16.useMemo)(() => extractFileInfo(Array.isArray(value) ? value : [value]), [value]);
|
|
3649
|
+
const rmFile = (0, import_react16.useCallback)(
|
|
2901
3650
|
(index) => {
|
|
2902
3651
|
if (multiple) {
|
|
2903
3652
|
const newValue = value.filter((_, i) => i !== index);
|
|
@@ -2908,8 +3657,8 @@ function FileWidget(props) {
|
|
|
2908
3657
|
},
|
|
2909
3658
|
[multiple, value, onChange]
|
|
2910
3659
|
);
|
|
2911
|
-
return /* @__PURE__ */ (0,
|
|
2912
|
-
/* @__PURE__ */ (0,
|
|
3660
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { children: [
|
|
3661
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2913
3662
|
BaseInputTemplate2,
|
|
2914
3663
|
{
|
|
2915
3664
|
...props,
|
|
@@ -2921,7 +3670,7 @@ function FileWidget(props) {
|
|
|
2921
3670
|
accept: options.accept ? String(options.accept) : void 0
|
|
2922
3671
|
}
|
|
2923
3672
|
),
|
|
2924
|
-
/* @__PURE__ */ (0,
|
|
3673
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
2925
3674
|
FilesInfo,
|
|
2926
3675
|
{
|
|
2927
3676
|
filesInfo,
|
|
@@ -2936,28 +3685,28 @@ function FileWidget(props) {
|
|
|
2936
3685
|
var FileWidget_default = FileWidget;
|
|
2937
3686
|
|
|
2938
3687
|
// src/components/widgets/HiddenWidget.tsx
|
|
2939
|
-
var
|
|
3688
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
2940
3689
|
function HiddenWidget({
|
|
2941
3690
|
id,
|
|
2942
3691
|
value
|
|
2943
3692
|
}) {
|
|
2944
|
-
return /* @__PURE__ */ (0,
|
|
3693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("input", { type: "hidden", id, name: id, value: typeof value === "undefined" ? "" : value });
|
|
2945
3694
|
}
|
|
2946
3695
|
var HiddenWidget_default = HiddenWidget;
|
|
2947
3696
|
|
|
2948
3697
|
// src/components/widgets/PasswordWidget.tsx
|
|
2949
|
-
var
|
|
2950
|
-
var
|
|
3698
|
+
var import_utils36 = require("@rjsf/utils");
|
|
3699
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
2951
3700
|
function PasswordWidget(props) {
|
|
2952
3701
|
const { options, registry } = props;
|
|
2953
|
-
const BaseInputTemplate2 = (0,
|
|
2954
|
-
return /* @__PURE__ */ (0,
|
|
3702
|
+
const BaseInputTemplate2 = (0, import_utils36.getTemplate)("BaseInputTemplate", registry, options);
|
|
3703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(BaseInputTemplate2, { type: "password", ...props });
|
|
2955
3704
|
}
|
|
2956
3705
|
|
|
2957
3706
|
// src/components/widgets/RadioWidget.tsx
|
|
2958
|
-
var
|
|
2959
|
-
var
|
|
2960
|
-
var
|
|
3707
|
+
var import_react17 = require("react");
|
|
3708
|
+
var import_utils37 = require("@rjsf/utils");
|
|
3709
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
2961
3710
|
function RadioWidget({
|
|
2962
3711
|
options,
|
|
2963
3712
|
value,
|
|
@@ -2971,25 +3720,25 @@ function RadioWidget({
|
|
|
2971
3720
|
id
|
|
2972
3721
|
}) {
|
|
2973
3722
|
const { enumOptions, enumDisabled, inline, emptyValue } = options;
|
|
2974
|
-
const handleBlur = (0,
|
|
2975
|
-
({ target }) => onBlur(id, (0,
|
|
2976
|
-
[onBlur, id]
|
|
3723
|
+
const handleBlur = (0, import_react17.useCallback)(
|
|
3724
|
+
({ target }) => onBlur(id, (0, import_utils37.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
3725
|
+
[onBlur, enumOptions, emptyValue, id]
|
|
2977
3726
|
);
|
|
2978
|
-
const handleFocus = (0,
|
|
2979
|
-
({ target }) => onFocus(id, (0,
|
|
2980
|
-
[onFocus, id]
|
|
3727
|
+
const handleFocus = (0, import_react17.useCallback)(
|
|
3728
|
+
({ target }) => onFocus(id, (0, import_utils37.enumOptionsValueForIndex)(target && target.value, enumOptions, emptyValue)),
|
|
3729
|
+
[onFocus, enumOptions, emptyValue, id]
|
|
2981
3730
|
);
|
|
2982
|
-
return /* @__PURE__ */ (0,
|
|
2983
|
-
const checked = (0,
|
|
3731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "field-radio-group", id, role: "radiogroup", children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
|
|
3732
|
+
const checked = (0, import_utils37.enumOptionsIsSelected)(option.value, value);
|
|
2984
3733
|
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
2985
3734
|
const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
|
|
2986
3735
|
const handleChange = () => onChange(option.value);
|
|
2987
|
-
const radio = /* @__PURE__ */ (0,
|
|
2988
|
-
/* @__PURE__ */ (0,
|
|
3736
|
+
const radio = /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { children: [
|
|
3737
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
2989
3738
|
"input",
|
|
2990
3739
|
{
|
|
2991
3740
|
type: "radio",
|
|
2992
|
-
id: (0,
|
|
3741
|
+
id: (0, import_utils37.optionId)(id, i),
|
|
2993
3742
|
checked,
|
|
2994
3743
|
name: id,
|
|
2995
3744
|
required,
|
|
@@ -2999,18 +3748,18 @@ function RadioWidget({
|
|
|
2999
3748
|
onChange: handleChange,
|
|
3000
3749
|
onBlur: handleBlur,
|
|
3001
3750
|
onFocus: handleFocus,
|
|
3002
|
-
"aria-describedby": (0,
|
|
3751
|
+
"aria-describedby": (0, import_utils37.ariaDescribedByIds)(id)
|
|
3003
3752
|
}
|
|
3004
3753
|
),
|
|
3005
|
-
/* @__PURE__ */ (0,
|
|
3754
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { children: option.label })
|
|
3006
3755
|
] });
|
|
3007
|
-
return inline ? /* @__PURE__ */ (0,
|
|
3756
|
+
return inline ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("label", { className: `radio-inline ${disabledCls}`, children: radio }, i) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("label", { children: radio }) }, i);
|
|
3008
3757
|
}) });
|
|
3009
3758
|
}
|
|
3010
3759
|
var RadioWidget_default = RadioWidget;
|
|
3011
3760
|
|
|
3012
3761
|
// src/components/widgets/RangeWidget.tsx
|
|
3013
|
-
var
|
|
3762
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
3014
3763
|
function RangeWidget(props) {
|
|
3015
3764
|
const {
|
|
3016
3765
|
value,
|
|
@@ -3018,16 +3767,119 @@ function RangeWidget(props) {
|
|
|
3018
3767
|
templates: { BaseInputTemplate: BaseInputTemplate2 }
|
|
3019
3768
|
}
|
|
3020
3769
|
} = props;
|
|
3021
|
-
return /* @__PURE__ */ (0,
|
|
3022
|
-
/* @__PURE__ */ (0,
|
|
3023
|
-
/* @__PURE__ */ (0,
|
|
3770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "field-range-wrapper", children: [
|
|
3771
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(BaseInputTemplate2, { type: "range", ...props }),
|
|
3772
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "range-view", children: value })
|
|
3024
3773
|
] });
|
|
3025
3774
|
}
|
|
3026
3775
|
|
|
3776
|
+
// src/components/widgets/RatingWidget.tsx
|
|
3777
|
+
var import_react18 = require("react");
|
|
3778
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
3779
|
+
function RatingWidget({
|
|
3780
|
+
id,
|
|
3781
|
+
value,
|
|
3782
|
+
required,
|
|
3783
|
+
disabled,
|
|
3784
|
+
readonly,
|
|
3785
|
+
autofocus,
|
|
3786
|
+
onChange,
|
|
3787
|
+
onFocus,
|
|
3788
|
+
onBlur,
|
|
3789
|
+
schema,
|
|
3790
|
+
options
|
|
3791
|
+
}) {
|
|
3792
|
+
const { stars = 5, shape = "star" } = options;
|
|
3793
|
+
const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
|
|
3794
|
+
const min = schema.minimum || 0;
|
|
3795
|
+
const handleStarClick = (0, import_react18.useCallback)(
|
|
3796
|
+
(starValue) => {
|
|
3797
|
+
if (!disabled && !readonly) {
|
|
3798
|
+
onChange(starValue);
|
|
3799
|
+
}
|
|
3800
|
+
},
|
|
3801
|
+
[onChange, disabled, readonly]
|
|
3802
|
+
);
|
|
3803
|
+
const handleFocus = (0, import_react18.useCallback)(
|
|
3804
|
+
(event) => {
|
|
3805
|
+
if (onFocus) {
|
|
3806
|
+
const starValue = Number(event.target.dataset.value);
|
|
3807
|
+
onFocus(id, starValue);
|
|
3808
|
+
}
|
|
3809
|
+
},
|
|
3810
|
+
[onFocus, id]
|
|
3811
|
+
);
|
|
3812
|
+
const handleBlur = (0, import_react18.useCallback)(
|
|
3813
|
+
(event) => {
|
|
3814
|
+
if (onBlur) {
|
|
3815
|
+
const starValue = Number(event.target.dataset.value);
|
|
3816
|
+
onBlur(id, starValue);
|
|
3817
|
+
}
|
|
3818
|
+
},
|
|
3819
|
+
[onBlur, id]
|
|
3820
|
+
);
|
|
3821
|
+
const getSymbol = (isFilled) => {
|
|
3822
|
+
if (shape === "heart") {
|
|
3823
|
+
return isFilled ? "\u2665" : "\u2661";
|
|
3824
|
+
}
|
|
3825
|
+
return isFilled ? "\u2605" : "\u2606";
|
|
3826
|
+
};
|
|
3827
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_jsx_runtime45.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
3828
|
+
"div",
|
|
3829
|
+
{
|
|
3830
|
+
className: "rating-widget",
|
|
3831
|
+
style: {
|
|
3832
|
+
display: "inline-flex",
|
|
3833
|
+
fontSize: "1.5rem",
|
|
3834
|
+
cursor: disabled || readonly ? "default" : "pointer"
|
|
3835
|
+
},
|
|
3836
|
+
children: [
|
|
3837
|
+
[...Array(numStars)].map((_, index) => {
|
|
3838
|
+
const starValue = min + index;
|
|
3839
|
+
const isFilled = starValue <= value;
|
|
3840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
3841
|
+
"span",
|
|
3842
|
+
{
|
|
3843
|
+
onClick: () => handleStarClick(starValue),
|
|
3844
|
+
onFocus: handleFocus,
|
|
3845
|
+
onBlur: handleBlur,
|
|
3846
|
+
"data-value": starValue,
|
|
3847
|
+
tabIndex: disabled || readonly ? -1 : 0,
|
|
3848
|
+
role: "radio",
|
|
3849
|
+
"aria-checked": starValue === value,
|
|
3850
|
+
"aria-label": `${starValue} ${shape === "heart" ? "heart" : "star"}${starValue === 1 ? "" : "s"}`,
|
|
3851
|
+
style: {
|
|
3852
|
+
color: isFilled ? "#FFD700" : "#ccc",
|
|
3853
|
+
padding: "0 0.2rem",
|
|
3854
|
+
transition: "color 0.2s",
|
|
3855
|
+
userSelect: "none"
|
|
3856
|
+
},
|
|
3857
|
+
children: getSymbol(isFilled)
|
|
3858
|
+
},
|
|
3859
|
+
index
|
|
3860
|
+
);
|
|
3861
|
+
}),
|
|
3862
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
3863
|
+
"input",
|
|
3864
|
+
{
|
|
3865
|
+
type: "hidden",
|
|
3866
|
+
id,
|
|
3867
|
+
name: id,
|
|
3868
|
+
value: value || "",
|
|
3869
|
+
required,
|
|
3870
|
+
disabled: disabled || readonly,
|
|
3871
|
+
"aria-hidden": "true"
|
|
3872
|
+
}
|
|
3873
|
+
)
|
|
3874
|
+
]
|
|
3875
|
+
}
|
|
3876
|
+
) });
|
|
3877
|
+
}
|
|
3878
|
+
|
|
3027
3879
|
// src/components/widgets/SelectWidget.tsx
|
|
3028
|
-
var
|
|
3029
|
-
var
|
|
3030
|
-
var
|
|
3880
|
+
var import_react19 = require("react");
|
|
3881
|
+
var import_utils38 = require("@rjsf/utils");
|
|
3882
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
3031
3883
|
function getValue(event, multiple) {
|
|
3032
3884
|
if (multiple) {
|
|
3033
3885
|
return Array.from(event.target.options).slice().filter((o) => o.selected).map((o) => o.value);
|
|
@@ -3051,35 +3903,36 @@ function SelectWidget({
|
|
|
3051
3903
|
}) {
|
|
3052
3904
|
const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
|
|
3053
3905
|
const emptyValue = multiple ? [] : "";
|
|
3054
|
-
const handleFocus = (0,
|
|
3906
|
+
const handleFocus = (0, import_react19.useCallback)(
|
|
3055
3907
|
(event) => {
|
|
3056
3908
|
const newValue = getValue(event, multiple);
|
|
3057
|
-
return onFocus(id, (0,
|
|
3909
|
+
return onFocus(id, (0, import_utils38.enumOptionsValueForIndex)(newValue, enumOptions, optEmptyVal));
|
|
3058
3910
|
},
|
|
3059
|
-
[onFocus, id,
|
|
3911
|
+
[onFocus, id, multiple, enumOptions, optEmptyVal]
|
|
3060
3912
|
);
|
|
3061
|
-
const handleBlur = (0,
|
|
3913
|
+
const handleBlur = (0, import_react19.useCallback)(
|
|
3062
3914
|
(event) => {
|
|
3063
3915
|
const newValue = getValue(event, multiple);
|
|
3064
|
-
return onBlur(id, (0,
|
|
3916
|
+
return onBlur(id, (0, import_utils38.enumOptionsValueForIndex)(newValue, enumOptions, optEmptyVal));
|
|
3065
3917
|
},
|
|
3066
|
-
[onBlur, id,
|
|
3918
|
+
[onBlur, id, multiple, enumOptions, optEmptyVal]
|
|
3067
3919
|
);
|
|
3068
|
-
const handleChange = (0,
|
|
3920
|
+
const handleChange = (0, import_react19.useCallback)(
|
|
3069
3921
|
(event) => {
|
|
3070
3922
|
const newValue = getValue(event, multiple);
|
|
3071
|
-
return onChange((0,
|
|
3923
|
+
return onChange((0, import_utils38.enumOptionsValueForIndex)(newValue, enumOptions, optEmptyVal));
|
|
3072
3924
|
},
|
|
3073
|
-
[onChange,
|
|
3925
|
+
[onChange, multiple, enumOptions, optEmptyVal]
|
|
3074
3926
|
);
|
|
3075
|
-
const selectedIndexes = (0,
|
|
3927
|
+
const selectedIndexes = (0, import_utils38.enumOptionsIndexForValue)(value, enumOptions, multiple);
|
|
3076
3928
|
const showPlaceholderOption = !multiple && schema.default === void 0;
|
|
3077
|
-
return /* @__PURE__ */ (0,
|
|
3929
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
3078
3930
|
"select",
|
|
3079
3931
|
{
|
|
3080
3932
|
id,
|
|
3081
3933
|
name: id,
|
|
3082
3934
|
multiple,
|
|
3935
|
+
role: "combobox",
|
|
3083
3936
|
className: "form-control",
|
|
3084
3937
|
value: typeof selectedIndexes === "undefined" ? emptyValue : selectedIndexes,
|
|
3085
3938
|
required,
|
|
@@ -3088,12 +3941,12 @@ function SelectWidget({
|
|
|
3088
3941
|
onBlur: handleBlur,
|
|
3089
3942
|
onFocus: handleFocus,
|
|
3090
3943
|
onChange: handleChange,
|
|
3091
|
-
"aria-describedby": (0,
|
|
3944
|
+
"aria-describedby": (0, import_utils38.ariaDescribedByIds)(id),
|
|
3092
3945
|
children: [
|
|
3093
|
-
showPlaceholderOption && /* @__PURE__ */ (0,
|
|
3946
|
+
showPlaceholderOption && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("option", { value: "", children: placeholder }),
|
|
3094
3947
|
Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label }, i) => {
|
|
3095
3948
|
const disabled2 = enumDisabled && enumDisabled.indexOf(value2) !== -1;
|
|
3096
|
-
return /* @__PURE__ */ (0,
|
|
3949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("option", { value: String(i), disabled: disabled2, children: label }, i);
|
|
3097
3950
|
})
|
|
3098
3951
|
]
|
|
3099
3952
|
}
|
|
@@ -3102,9 +3955,9 @@ function SelectWidget({
|
|
|
3102
3955
|
var SelectWidget_default = SelectWidget;
|
|
3103
3956
|
|
|
3104
3957
|
// src/components/widgets/TextareaWidget.tsx
|
|
3105
|
-
var
|
|
3106
|
-
var
|
|
3107
|
-
var
|
|
3958
|
+
var import_react20 = require("react");
|
|
3959
|
+
var import_utils39 = require("@rjsf/utils");
|
|
3960
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
3108
3961
|
function TextareaWidget({
|
|
3109
3962
|
id,
|
|
3110
3963
|
options = {},
|
|
@@ -3118,19 +3971,19 @@ function TextareaWidget({
|
|
|
3118
3971
|
onBlur,
|
|
3119
3972
|
onFocus
|
|
3120
3973
|
}) {
|
|
3121
|
-
const handleChange = (0,
|
|
3974
|
+
const handleChange = (0, import_react20.useCallback)(
|
|
3122
3975
|
({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
|
|
3123
3976
|
[onChange, options.emptyValue]
|
|
3124
3977
|
);
|
|
3125
|
-
const handleBlur = (0,
|
|
3978
|
+
const handleBlur = (0, import_react20.useCallback)(
|
|
3126
3979
|
({ target }) => onBlur(id, target && target.value),
|
|
3127
3980
|
[onBlur, id]
|
|
3128
3981
|
);
|
|
3129
|
-
const handleFocus = (0,
|
|
3982
|
+
const handleFocus = (0, import_react20.useCallback)(
|
|
3130
3983
|
({ target }) => onFocus(id, target && target.value),
|
|
3131
3984
|
[id, onFocus]
|
|
3132
3985
|
);
|
|
3133
|
-
return /* @__PURE__ */ (0,
|
|
3986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
3134
3987
|
"textarea",
|
|
3135
3988
|
{
|
|
3136
3989
|
id,
|
|
@@ -3146,7 +3999,7 @@ function TextareaWidget({
|
|
|
3146
3999
|
onBlur: handleBlur,
|
|
3147
4000
|
onFocus: handleFocus,
|
|
3148
4001
|
onChange: handleChange,
|
|
3149
|
-
"aria-describedby": (0,
|
|
4002
|
+
"aria-describedby": (0, import_utils39.ariaDescribedByIds)(id)
|
|
3150
4003
|
}
|
|
3151
4004
|
);
|
|
3152
4005
|
}
|
|
@@ -3157,41 +4010,41 @@ TextareaWidget.defaultProps = {
|
|
|
3157
4010
|
var TextareaWidget_default = TextareaWidget;
|
|
3158
4011
|
|
|
3159
4012
|
// src/components/widgets/TextWidget.tsx
|
|
3160
|
-
var
|
|
3161
|
-
var
|
|
4013
|
+
var import_utils40 = require("@rjsf/utils");
|
|
4014
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
3162
4015
|
function TextWidget(props) {
|
|
3163
4016
|
const { options, registry } = props;
|
|
3164
|
-
const BaseInputTemplate2 = (0,
|
|
3165
|
-
return /* @__PURE__ */ (0,
|
|
4017
|
+
const BaseInputTemplate2 = (0, import_utils40.getTemplate)("BaseInputTemplate", registry, options);
|
|
4018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(BaseInputTemplate2, { ...props });
|
|
3166
4019
|
}
|
|
3167
4020
|
|
|
3168
4021
|
// src/components/widgets/TimeWidget.tsx
|
|
3169
|
-
var
|
|
3170
|
-
var
|
|
3171
|
-
var
|
|
4022
|
+
var import_react21 = require("react");
|
|
4023
|
+
var import_utils41 = require("@rjsf/utils");
|
|
4024
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
3172
4025
|
function TimeWidget(props) {
|
|
3173
4026
|
const { onChange, options, registry } = props;
|
|
3174
|
-
const BaseInputTemplate2 = (0,
|
|
3175
|
-
const handleChange = (0,
|
|
3176
|
-
return /* @__PURE__ */ (0,
|
|
4027
|
+
const BaseInputTemplate2 = (0, import_utils41.getTemplate)("BaseInputTemplate", registry, options);
|
|
4028
|
+
const handleChange = (0, import_react21.useCallback)((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
|
|
4029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
|
|
3177
4030
|
}
|
|
3178
4031
|
|
|
3179
4032
|
// src/components/widgets/URLWidget.tsx
|
|
3180
|
-
var
|
|
3181
|
-
var
|
|
4033
|
+
var import_utils42 = require("@rjsf/utils");
|
|
4034
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
3182
4035
|
function URLWidget(props) {
|
|
3183
4036
|
const { options, registry } = props;
|
|
3184
|
-
const BaseInputTemplate2 = (0,
|
|
3185
|
-
return /* @__PURE__ */ (0,
|
|
4037
|
+
const BaseInputTemplate2 = (0, import_utils42.getTemplate)("BaseInputTemplate", registry, options);
|
|
4038
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(BaseInputTemplate2, { type: "url", ...props });
|
|
3186
4039
|
}
|
|
3187
4040
|
|
|
3188
4041
|
// src/components/widgets/UpDownWidget.tsx
|
|
3189
|
-
var
|
|
3190
|
-
var
|
|
4042
|
+
var import_utils43 = require("@rjsf/utils");
|
|
4043
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
3191
4044
|
function UpDownWidget(props) {
|
|
3192
4045
|
const { options, registry } = props;
|
|
3193
|
-
const BaseInputTemplate2 = (0,
|
|
3194
|
-
return /* @__PURE__ */ (0,
|
|
4046
|
+
const BaseInputTemplate2 = (0, import_utils43.getTemplate)("BaseInputTemplate", registry, options);
|
|
4047
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(BaseInputTemplate2, { type: "number", ...props });
|
|
3195
4048
|
}
|
|
3196
4049
|
|
|
3197
4050
|
// src/components/widgets/index.ts
|
|
@@ -3210,6 +4063,7 @@ function widgets() {
|
|
|
3210
4063
|
PasswordWidget,
|
|
3211
4064
|
RadioWidget: RadioWidget_default,
|
|
3212
4065
|
RangeWidget,
|
|
4066
|
+
RatingWidget,
|
|
3213
4067
|
SelectWidget: SelectWidget_default,
|
|
3214
4068
|
TextWidget,
|
|
3215
4069
|
TextareaWidget: TextareaWidget_default,
|
|
@@ -3228,13 +4082,17 @@ function getDefaultRegistry() {
|
|
|
3228
4082
|
widgets: widgets_default(),
|
|
3229
4083
|
rootSchema: {},
|
|
3230
4084
|
formContext: {},
|
|
3231
|
-
translateString:
|
|
4085
|
+
translateString: import_utils44.englishStringTranslator
|
|
3232
4086
|
};
|
|
3233
4087
|
}
|
|
3234
4088
|
|
|
3235
4089
|
// src/components/Form.tsx
|
|
3236
|
-
var
|
|
3237
|
-
var Form = class extends
|
|
4090
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
4091
|
+
var Form = class extends import_react22.Component {
|
|
4092
|
+
/** The ref used to hold the `form` element, this needs to be `any` because `tagName` or `_internalFormWrapper` can
|
|
4093
|
+
* provide any possible type here
|
|
4094
|
+
*/
|
|
4095
|
+
formElement;
|
|
3238
4096
|
/** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
|
|
3239
4097
|
* `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
|
|
3240
4098
|
* state construction.
|
|
@@ -3243,278 +4101,14 @@ var Form = class extends import_react17.Component {
|
|
|
3243
4101
|
*/
|
|
3244
4102
|
constructor(props) {
|
|
3245
4103
|
super(props);
|
|
3246
|
-
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
3247
|
-
*
|
|
3248
|
-
* @param formData - The data for the `Form`
|
|
3249
|
-
* @param fields - The fields to keep while filtering
|
|
3250
|
-
*/
|
|
3251
|
-
this.getUsedFormData = (formData, fields2) => {
|
|
3252
|
-
if (fields2.length === 0 && typeof formData !== "object") {
|
|
3253
|
-
return formData;
|
|
3254
|
-
}
|
|
3255
|
-
const data = (0, import_pick.default)(formData, fields2);
|
|
3256
|
-
if (Array.isArray(formData)) {
|
|
3257
|
-
return Object.keys(data).map((key) => data[key]);
|
|
3258
|
-
}
|
|
3259
|
-
return data;
|
|
3260
|
-
};
|
|
3261
|
-
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
3262
|
-
*
|
|
3263
|
-
* @param pathSchema - The `PathSchema` object for the form
|
|
3264
|
-
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
3265
|
-
*/
|
|
3266
|
-
this.getFieldNames = (pathSchema, formData) => {
|
|
3267
|
-
const getAllPaths = (_obj, acc = [], paths = [[]]) => {
|
|
3268
|
-
Object.keys(_obj).forEach((key) => {
|
|
3269
|
-
if (typeof _obj[key] === "object") {
|
|
3270
|
-
const newPaths = paths.map((path) => [...path, key]);
|
|
3271
|
-
if (_obj[key][import_utils39.RJSF_ADDITIONAL_PROPERTIES_FLAG] && _obj[key][import_utils39.NAME_KEY] !== "") {
|
|
3272
|
-
acc.push(_obj[key][import_utils39.NAME_KEY]);
|
|
3273
|
-
} else {
|
|
3274
|
-
getAllPaths(_obj[key], acc, newPaths);
|
|
3275
|
-
}
|
|
3276
|
-
} else if (key === import_utils39.NAME_KEY && _obj[key] !== "") {
|
|
3277
|
-
paths.forEach((path) => {
|
|
3278
|
-
const formValue = (0, import_get4.default)(formData, path);
|
|
3279
|
-
if (typeof formValue !== "object" || (0, import_isEmpty2.default)(formValue) || Array.isArray(formValue) && formValue.every((val) => typeof val !== "object")) {
|
|
3280
|
-
acc.push(path);
|
|
3281
|
-
}
|
|
3282
|
-
});
|
|
3283
|
-
}
|
|
3284
|
-
});
|
|
3285
|
-
return acc;
|
|
3286
|
-
};
|
|
3287
|
-
return getAllPaths(pathSchema);
|
|
3288
|
-
};
|
|
3289
|
-
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
3290
|
-
*
|
|
3291
|
-
* @param formData - The data for the `Form`
|
|
3292
|
-
* @returns The `formData` after omitting extra data
|
|
3293
|
-
*/
|
|
3294
|
-
this.omitExtraData = (formData) => {
|
|
3295
|
-
const { schema, schemaUtils } = this.state;
|
|
3296
|
-
const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
3297
|
-
const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
|
|
3298
|
-
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
3299
|
-
const newFormData = this.getUsedFormData(formData, fieldNames);
|
|
3300
|
-
return newFormData;
|
|
3301
|
-
};
|
|
3302
|
-
/** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
|
|
3303
|
-
* `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
|
|
3304
|
-
* then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
|
|
3305
|
-
* in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
|
|
3306
|
-
* updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
|
|
3307
|
-
* callback will be called if specified with the updated state.
|
|
3308
|
-
*
|
|
3309
|
-
* @param formData - The new form data from a change to a field
|
|
3310
|
-
* @param newErrorSchema - The new `ErrorSchema` based on the field change
|
|
3311
|
-
* @param id - The id of the field that caused the change
|
|
3312
|
-
*/
|
|
3313
|
-
this.onChange = (formData, newErrorSchema, id) => {
|
|
3314
|
-
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
3315
|
-
const { schemaUtils, schema, retrievedSchema } = this.state;
|
|
3316
|
-
if ((0, import_utils39.isObject)(formData) || Array.isArray(formData)) {
|
|
3317
|
-
const newState = this.getStateFromProps(this.props, formData, retrievedSchema);
|
|
3318
|
-
formData = newState.formData;
|
|
3319
|
-
}
|
|
3320
|
-
const mustValidate = !noValidate && liveValidate;
|
|
3321
|
-
let state = { formData, schema };
|
|
3322
|
-
let newFormData = formData;
|
|
3323
|
-
let _retrievedSchema;
|
|
3324
|
-
if (omitExtraData === true && liveOmit === true) {
|
|
3325
|
-
newFormData = this.omitExtraData(formData);
|
|
3326
|
-
state = {
|
|
3327
|
-
formData: newFormData
|
|
3328
|
-
};
|
|
3329
|
-
}
|
|
3330
|
-
if (mustValidate) {
|
|
3331
|
-
const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
|
|
3332
|
-
let errors = schemaValidation.errors;
|
|
3333
|
-
let errorSchema = schemaValidation.errorSchema;
|
|
3334
|
-
const schemaValidationErrors = errors;
|
|
3335
|
-
const schemaValidationErrorSchema = errorSchema;
|
|
3336
|
-
if (extraErrors) {
|
|
3337
|
-
const merged = (0, import_utils39.validationDataMerge)(schemaValidation, extraErrors);
|
|
3338
|
-
errorSchema = merged.errorSchema;
|
|
3339
|
-
errors = merged.errors;
|
|
3340
|
-
}
|
|
3341
|
-
if (newErrorSchema) {
|
|
3342
|
-
const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
|
|
3343
|
-
errorSchema = (0, import_utils39.mergeObjects)(errorSchema, filteredErrors, "preventDuplicates");
|
|
3344
|
-
}
|
|
3345
|
-
state = {
|
|
3346
|
-
formData: newFormData,
|
|
3347
|
-
errors,
|
|
3348
|
-
errorSchema,
|
|
3349
|
-
schemaValidationErrors,
|
|
3350
|
-
schemaValidationErrorSchema
|
|
3351
|
-
};
|
|
3352
|
-
} else if (!noValidate && newErrorSchema) {
|
|
3353
|
-
const errorSchema = extraErrors ? (0, import_utils39.mergeObjects)(newErrorSchema, extraErrors, "preventDuplicates") : newErrorSchema;
|
|
3354
|
-
state = {
|
|
3355
|
-
formData: newFormData,
|
|
3356
|
-
errorSchema,
|
|
3357
|
-
errors: (0, import_utils39.toErrorList)(errorSchema)
|
|
3358
|
-
};
|
|
3359
|
-
}
|
|
3360
|
-
if (_retrievedSchema) {
|
|
3361
|
-
state.retrievedSchema = _retrievedSchema;
|
|
3362
|
-
}
|
|
3363
|
-
this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
|
|
3364
|
-
};
|
|
3365
|
-
/**
|
|
3366
|
-
* Callback function to handle reset form data.
|
|
3367
|
-
* - Reset all fields with default values.
|
|
3368
|
-
* - Reset validations and errors
|
|
3369
|
-
*
|
|
3370
|
-
*/
|
|
3371
|
-
this.reset = () => {
|
|
3372
|
-
const { onChange } = this.props;
|
|
3373
|
-
const newState = this.getStateFromProps(this.props, void 0);
|
|
3374
|
-
const newFormData = newState.formData;
|
|
3375
|
-
const state = {
|
|
3376
|
-
formData: newFormData,
|
|
3377
|
-
errorSchema: {},
|
|
3378
|
-
errors: [],
|
|
3379
|
-
schemaValidationErrors: [],
|
|
3380
|
-
schemaValidationErrorSchema: {}
|
|
3381
|
-
};
|
|
3382
|
-
this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
|
|
3383
|
-
};
|
|
3384
|
-
/** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
|
|
3385
|
-
* was provided.
|
|
3386
|
-
*
|
|
3387
|
-
* @param id - The unique `id` of the field that was blurred
|
|
3388
|
-
* @param data - The data associated with the field that was blurred
|
|
3389
|
-
*/
|
|
3390
|
-
this.onBlur = (id, data) => {
|
|
3391
|
-
const { onBlur } = this.props;
|
|
3392
|
-
if (onBlur) {
|
|
3393
|
-
onBlur(id, data);
|
|
3394
|
-
}
|
|
3395
|
-
};
|
|
3396
|
-
/** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
|
|
3397
|
-
* was provided.
|
|
3398
|
-
*
|
|
3399
|
-
* @param id - The unique `id` of the field that was focused
|
|
3400
|
-
* @param data - The data associated with the field that was focused
|
|
3401
|
-
*/
|
|
3402
|
-
this.onFocus = (id, data) => {
|
|
3403
|
-
const { onFocus } = this.props;
|
|
3404
|
-
if (onFocus) {
|
|
3405
|
-
onFocus(id, data);
|
|
3406
|
-
}
|
|
3407
|
-
};
|
|
3408
|
-
/** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
|
|
3409
|
-
* happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
|
|
3410
|
-
* `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
|
|
3411
|
-
* via the `onError()` callback unless validation is disabled. Finally, it will add in any `extraErrors` and then call
|
|
3412
|
-
* back the `onSubmit` callback if it was provided.
|
|
3413
|
-
*
|
|
3414
|
-
* @param event - The submit HTML form event
|
|
3415
|
-
*/
|
|
3416
|
-
this.onSubmit = (event) => {
|
|
3417
|
-
event.preventDefault();
|
|
3418
|
-
if (event.target !== event.currentTarget) {
|
|
3419
|
-
return;
|
|
3420
|
-
}
|
|
3421
|
-
event.persist();
|
|
3422
|
-
const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
|
|
3423
|
-
let { formData: newFormData } = this.state;
|
|
3424
|
-
if (omitExtraData === true) {
|
|
3425
|
-
newFormData = this.omitExtraData(newFormData);
|
|
3426
|
-
}
|
|
3427
|
-
if (noValidate || this.validateFormWithFormData(newFormData)) {
|
|
3428
|
-
const errorSchema = extraErrors || {};
|
|
3429
|
-
const errors = extraErrors ? (0, import_utils39.toErrorList)(extraErrors) : [];
|
|
3430
|
-
this.setState(
|
|
3431
|
-
{
|
|
3432
|
-
formData: newFormData,
|
|
3433
|
-
errors,
|
|
3434
|
-
errorSchema,
|
|
3435
|
-
schemaValidationErrors: [],
|
|
3436
|
-
schemaValidationErrorSchema: {}
|
|
3437
|
-
},
|
|
3438
|
-
() => {
|
|
3439
|
-
if (onSubmit) {
|
|
3440
|
-
onSubmit({ ...this.state, formData: newFormData, status: "submitted" }, event);
|
|
3441
|
-
}
|
|
3442
|
-
}
|
|
3443
|
-
);
|
|
3444
|
-
}
|
|
3445
|
-
};
|
|
3446
|
-
/** Provides a function that can be used to programmatically submit the `Form` */
|
|
3447
|
-
this.submit = () => {
|
|
3448
|
-
if (this.formElement.current) {
|
|
3449
|
-
const submitCustomEvent = new CustomEvent("submit", {
|
|
3450
|
-
cancelable: true
|
|
3451
|
-
});
|
|
3452
|
-
submitCustomEvent.preventDefault();
|
|
3453
|
-
this.formElement.current.dispatchEvent(submitCustomEvent);
|
|
3454
|
-
this.formElement.current.requestSubmit();
|
|
3455
|
-
}
|
|
3456
|
-
};
|
|
3457
|
-
/** Validates the form using the given `formData`. For use on form submission or on programmatic validation.
|
|
3458
|
-
* If `onError` is provided, then it will be called with the list of errors.
|
|
3459
|
-
*
|
|
3460
|
-
* @param formData - The form data to validate
|
|
3461
|
-
* @returns - True if the form is valid, false otherwise.
|
|
3462
|
-
*/
|
|
3463
|
-
this.validateFormWithFormData = (formData) => {
|
|
3464
|
-
const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
|
|
3465
|
-
const { errors: prevErrors } = this.state;
|
|
3466
|
-
const schemaValidation = this.validate(formData);
|
|
3467
|
-
let errors = schemaValidation.errors;
|
|
3468
|
-
let errorSchema = schemaValidation.errorSchema;
|
|
3469
|
-
const schemaValidationErrors = errors;
|
|
3470
|
-
const schemaValidationErrorSchema = errorSchema;
|
|
3471
|
-
const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
3472
|
-
if (hasError) {
|
|
3473
|
-
if (extraErrors) {
|
|
3474
|
-
const merged = (0, import_utils39.validationDataMerge)(schemaValidation, extraErrors);
|
|
3475
|
-
errorSchema = merged.errorSchema;
|
|
3476
|
-
errors = merged.errors;
|
|
3477
|
-
}
|
|
3478
|
-
if (focusOnFirstError) {
|
|
3479
|
-
if (typeof focusOnFirstError === "function") {
|
|
3480
|
-
focusOnFirstError(errors[0]);
|
|
3481
|
-
} else {
|
|
3482
|
-
this.focusOnError(errors[0]);
|
|
3483
|
-
}
|
|
3484
|
-
}
|
|
3485
|
-
this.setState(
|
|
3486
|
-
{
|
|
3487
|
-
errors,
|
|
3488
|
-
errorSchema,
|
|
3489
|
-
schemaValidationErrors,
|
|
3490
|
-
schemaValidationErrorSchema
|
|
3491
|
-
},
|
|
3492
|
-
() => {
|
|
3493
|
-
if (onError) {
|
|
3494
|
-
onError(errors);
|
|
3495
|
-
} else {
|
|
3496
|
-
console.error("Form validation failed", errors);
|
|
3497
|
-
}
|
|
3498
|
-
}
|
|
3499
|
-
);
|
|
3500
|
-
} else if (prevErrors.length > 0) {
|
|
3501
|
-
this.setState({
|
|
3502
|
-
errors: [],
|
|
3503
|
-
errorSchema: {},
|
|
3504
|
-
schemaValidationErrors: [],
|
|
3505
|
-
schemaValidationErrorSchema: {}
|
|
3506
|
-
});
|
|
3507
|
-
}
|
|
3508
|
-
return !hasError;
|
|
3509
|
-
};
|
|
3510
4104
|
if (!props.validator) {
|
|
3511
4105
|
throw new Error("A validator is required for Form functionality to work");
|
|
3512
4106
|
}
|
|
3513
4107
|
this.state = this.getStateFromProps(props, props.formData);
|
|
3514
|
-
if (this.props.onChange && !(0,
|
|
4108
|
+
if (this.props.onChange && !(0, import_utils45.deepEquals)(this.state.formData, this.props.formData)) {
|
|
3515
4109
|
this.props.onChange(this.state);
|
|
3516
4110
|
}
|
|
3517
|
-
this.formElement = (0,
|
|
4111
|
+
this.formElement = (0, import_react22.createRef)();
|
|
3518
4112
|
}
|
|
3519
4113
|
/**
|
|
3520
4114
|
* `getSnapshotBeforeUpdate` is a React lifecycle method that is invoked right before the most recently rendered
|
|
@@ -3535,9 +4129,10 @@ var Form = class extends import_react17.Component {
|
|
|
3535
4129
|
* with a flag indicating that an update is not necessary.
|
|
3536
4130
|
*/
|
|
3537
4131
|
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
3538
|
-
if (!(0,
|
|
3539
|
-
const
|
|
3540
|
-
const
|
|
4132
|
+
if (!(0, import_utils45.deepEquals)(this.props, prevProps)) {
|
|
4133
|
+
const formDataChangedFields = (0, import_utils45.getChangedFields)(this.props.formData, prevProps.formData);
|
|
4134
|
+
const isSchemaChanged = !(0, import_utils45.deepEquals)(prevProps.schema, this.props.schema);
|
|
4135
|
+
const isFormDataChanged = formDataChangedFields.length > 0 || !(0, import_utils45.deepEquals)(prevProps.formData, this.props.formData);
|
|
3541
4136
|
const nextState = this.getStateFromProps(
|
|
3542
4137
|
this.props,
|
|
3543
4138
|
this.props.formData,
|
|
@@ -3545,9 +4140,10 @@ var Form = class extends import_react17.Component {
|
|
|
3545
4140
|
// Or if the `formData` changes, for example in the case of a schema with dependencies that need to
|
|
3546
4141
|
// match one of the subSchemas, the retrieved schema must be updated.
|
|
3547
4142
|
isSchemaChanged || isFormDataChanged ? void 0 : this.state.retrievedSchema,
|
|
3548
|
-
isSchemaChanged
|
|
4143
|
+
isSchemaChanged,
|
|
4144
|
+
formDataChangedFields
|
|
3549
4145
|
);
|
|
3550
|
-
const shouldUpdate = !(0,
|
|
4146
|
+
const shouldUpdate = !(0, import_utils45.deepEquals)(nextState, prevState);
|
|
3551
4147
|
return { nextState, shouldUpdate };
|
|
3552
4148
|
}
|
|
3553
4149
|
return { shouldUpdate: false };
|
|
@@ -3560,9 +4156,6 @@ var Form = class extends import_react17.Component {
|
|
|
3560
4156
|
* If an update is required, it applies the next state and, if needed, triggers the `onChange` handler to inform about
|
|
3561
4157
|
* changes.
|
|
3562
4158
|
*
|
|
3563
|
-
* This method effectively replaces the deprecated `UNSAFE_componentWillReceiveProps`, providing a safer alternative
|
|
3564
|
-
* to handle prop changes and state updates.
|
|
3565
|
-
*
|
|
3566
4159
|
* @param _ - The previous set of props.
|
|
3567
4160
|
* @param prevState - The previous state of the component before the update.
|
|
3568
4161
|
* @param snapshot - The value returned from `getSnapshotBeforeUpdate`.
|
|
@@ -3570,7 +4163,7 @@ var Form = class extends import_react17.Component {
|
|
|
3570
4163
|
componentDidUpdate(_, prevState, snapshot) {
|
|
3571
4164
|
if (snapshot.shouldUpdate) {
|
|
3572
4165
|
const { nextState } = snapshot;
|
|
3573
|
-
if (!(0,
|
|
4166
|
+
if (!(0, import_utils45.deepEquals)(nextState.formData, this.props.formData) && !(0, import_utils45.deepEquals)(nextState.formData, prevState.formData) && this.props.onChange) {
|
|
3574
4167
|
this.props.onChange(nextState);
|
|
3575
4168
|
}
|
|
3576
4169
|
this.setState(nextState);
|
|
@@ -3584,9 +4177,10 @@ var Form = class extends import_react17.Component {
|
|
|
3584
4177
|
* @param inputFormData - The new or current data for the `Form`
|
|
3585
4178
|
* @param retrievedSchema - An expanded schema, if not provided, it will be retrieved from the `schema` and `formData`.
|
|
3586
4179
|
* @param isSchemaChanged - A flag indicating whether the schema has changed.
|
|
4180
|
+
* @param formDataChangedFields - The changed fields of `formData`
|
|
3587
4181
|
* @returns - The new state for the `Form`
|
|
3588
4182
|
*/
|
|
3589
|
-
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false) {
|
|
4183
|
+
getStateFromProps(props, inputFormData, retrievedSchema, isSchemaChanged = false, formDataChangedFields = []) {
|
|
3590
4184
|
const state = this.state || {};
|
|
3591
4185
|
const schema = "schema" in props ? props.schema : this.props.schema;
|
|
3592
4186
|
const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
|
|
@@ -3595,12 +4189,25 @@ var Form = class extends import_react17.Component {
|
|
|
3595
4189
|
const mustValidate = edit && !props.noValidate && liveValidate;
|
|
3596
4190
|
const rootSchema = schema;
|
|
3597
4191
|
const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
|
|
4192
|
+
const experimental_customMergeAllOf = "experimental_customMergeAllOf" in props ? props.experimental_customMergeAllOf : this.props.experimental_customMergeAllOf;
|
|
3598
4193
|
let schemaUtils = state.schemaUtils;
|
|
3599
|
-
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
3600
|
-
|
|
4194
|
+
if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(
|
|
4195
|
+
props.validator,
|
|
4196
|
+
rootSchema,
|
|
4197
|
+
experimental_defaultFormStateBehavior,
|
|
4198
|
+
experimental_customMergeAllOf
|
|
4199
|
+
)) {
|
|
4200
|
+
schemaUtils = (0, import_utils45.createSchemaUtils)(
|
|
4201
|
+
props.validator,
|
|
4202
|
+
rootSchema,
|
|
4203
|
+
experimental_defaultFormStateBehavior,
|
|
4204
|
+
experimental_customMergeAllOf
|
|
4205
|
+
);
|
|
3601
4206
|
}
|
|
3602
4207
|
const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
|
|
3603
|
-
const _retrievedSchema =
|
|
4208
|
+
const _retrievedSchema = this.updateRetrievedSchema(
|
|
4209
|
+
retrievedSchema ?? schemaUtils.retrieveSchema(schema, formData)
|
|
4210
|
+
);
|
|
3604
4211
|
const getCurrentErrors = () => {
|
|
3605
4212
|
if (props.noValidate || isSchemaChanged) {
|
|
3606
4213
|
return { errors: [], errorSchema: {} };
|
|
@@ -3622,10 +4229,10 @@ var Form = class extends import_react17.Component {
|
|
|
3622
4229
|
if (mustValidate) {
|
|
3623
4230
|
const schemaValidation = this.validate(formData, schema, schemaUtils, _retrievedSchema);
|
|
3624
4231
|
errors = schemaValidation.errors;
|
|
3625
|
-
if (
|
|
4232
|
+
if (retrievedSchema === void 0) {
|
|
3626
4233
|
errorSchema = schemaValidation.errorSchema;
|
|
3627
4234
|
} else {
|
|
3628
|
-
errorSchema = (0,
|
|
4235
|
+
errorSchema = (0, import_utils45.mergeObjects)(
|
|
3629
4236
|
this.state?.errorSchema,
|
|
3630
4237
|
schemaValidation.errorSchema,
|
|
3631
4238
|
"preventDuplicates"
|
|
@@ -3637,9 +4244,23 @@ var Form = class extends import_react17.Component {
|
|
|
3637
4244
|
const currentErrors = getCurrentErrors();
|
|
3638
4245
|
errors = currentErrors.errors;
|
|
3639
4246
|
errorSchema = currentErrors.errorSchema;
|
|
4247
|
+
if (formDataChangedFields.length > 0) {
|
|
4248
|
+
const newErrorSchema = formDataChangedFields.reduce(
|
|
4249
|
+
(acc, key) => {
|
|
4250
|
+
acc[key] = void 0;
|
|
4251
|
+
return acc;
|
|
4252
|
+
},
|
|
4253
|
+
{}
|
|
4254
|
+
);
|
|
4255
|
+
errorSchema = schemaValidationErrorSchema = (0, import_utils45.mergeObjects)(
|
|
4256
|
+
currentErrors.errorSchema,
|
|
4257
|
+
newErrorSchema,
|
|
4258
|
+
"preventDuplicates"
|
|
4259
|
+
);
|
|
4260
|
+
}
|
|
3640
4261
|
}
|
|
3641
4262
|
if (props.extraErrors) {
|
|
3642
|
-
const merged = (0,
|
|
4263
|
+
const merged = (0, import_utils45.validationDataMerge)({ errorSchema, errors }, props.extraErrors);
|
|
3643
4264
|
errorSchema = merged.errorSchema;
|
|
3644
4265
|
errors = merged.errors;
|
|
3645
4266
|
}
|
|
@@ -3672,7 +4293,22 @@ var Form = class extends import_react17.Component {
|
|
|
3672
4293
|
* @returns - True if the component should be updated, false otherwise
|
|
3673
4294
|
*/
|
|
3674
4295
|
shouldComponentUpdate(nextProps, nextState) {
|
|
3675
|
-
return (0,
|
|
4296
|
+
return (0, import_utils45.shouldRender)(this, nextProps, nextState);
|
|
4297
|
+
}
|
|
4298
|
+
/** Gets the previously raised customValidate errors.
|
|
4299
|
+
*
|
|
4300
|
+
* @returns the previous customValidate errors
|
|
4301
|
+
*/
|
|
4302
|
+
getPreviousCustomValidateErrors() {
|
|
4303
|
+
const { customValidate, uiSchema } = this.props;
|
|
4304
|
+
const prevFormData = this.state.formData;
|
|
4305
|
+
let customValidateErrors = {};
|
|
4306
|
+
if (typeof customValidate === "function") {
|
|
4307
|
+
const errorHandler = customValidate(prevFormData, (0, import_utils45.createErrorHandler)(prevFormData), uiSchema);
|
|
4308
|
+
const userErrorSchema = (0, import_utils45.unwrapErrorHandler)(errorHandler);
|
|
4309
|
+
customValidateErrors = userErrorSchema;
|
|
4310
|
+
}
|
|
4311
|
+
return customValidateErrors;
|
|
3676
4312
|
}
|
|
3677
4313
|
/** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
|
|
3678
4314
|
* `schemaUtils` in the state), returning the results.
|
|
@@ -3691,10 +4327,10 @@ var Form = class extends import_react17.Component {
|
|
|
3691
4327
|
renderErrors(registry) {
|
|
3692
4328
|
const { errors, errorSchema, schema, uiSchema } = this.state;
|
|
3693
4329
|
const { formContext } = this.props;
|
|
3694
|
-
const options = (0,
|
|
3695
|
-
const ErrorListTemplate = (0,
|
|
4330
|
+
const options = (0, import_utils45.getUiOptions)(uiSchema);
|
|
4331
|
+
const ErrorListTemplate = (0, import_utils45.getTemplate)("ErrorListTemplate", registry, options);
|
|
3696
4332
|
if (errors && errors.length) {
|
|
3697
|
-
return /* @__PURE__ */ (0,
|
|
4333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
3698
4334
|
ErrorListTemplate,
|
|
3699
4335
|
{
|
|
3700
4336
|
errors,
|
|
@@ -3708,6 +4344,62 @@ var Form = class extends import_react17.Component {
|
|
|
3708
4344
|
}
|
|
3709
4345
|
return null;
|
|
3710
4346
|
}
|
|
4347
|
+
/** Returns the `formData` with only the elements specified in the `fields` list
|
|
4348
|
+
*
|
|
4349
|
+
* @param formData - The data for the `Form`
|
|
4350
|
+
* @param fields - The fields to keep while filtering
|
|
4351
|
+
*/
|
|
4352
|
+
getUsedFormData = (formData, fields2) => {
|
|
4353
|
+
if (fields2.length === 0 && typeof formData !== "object") {
|
|
4354
|
+
return formData;
|
|
4355
|
+
}
|
|
4356
|
+
const data = (0, import_pick.default)(formData, fields2);
|
|
4357
|
+
if (Array.isArray(formData)) {
|
|
4358
|
+
return Object.keys(data).map((key) => data[key]);
|
|
4359
|
+
}
|
|
4360
|
+
return data;
|
|
4361
|
+
};
|
|
4362
|
+
/** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
|
|
4363
|
+
*
|
|
4364
|
+
* @param pathSchema - The `PathSchema` object for the form
|
|
4365
|
+
* @param [formData] - The form data to use while checking for empty objects/arrays
|
|
4366
|
+
*/
|
|
4367
|
+
getFieldNames = (pathSchema, formData) => {
|
|
4368
|
+
const getAllPaths = (_obj, acc = [], paths = [[]]) => {
|
|
4369
|
+
Object.keys(_obj).forEach((key) => {
|
|
4370
|
+
if (typeof _obj[key] === "object") {
|
|
4371
|
+
const newPaths = paths.map((path) => [...path, key]);
|
|
4372
|
+
if (_obj[key][import_utils45.RJSF_ADDITIONAL_PROPERTIES_FLAG] && _obj[key][import_utils45.NAME_KEY] !== "") {
|
|
4373
|
+
acc.push(_obj[key][import_utils45.NAME_KEY]);
|
|
4374
|
+
} else {
|
|
4375
|
+
getAllPaths(_obj[key], acc, newPaths);
|
|
4376
|
+
}
|
|
4377
|
+
} else if (key === import_utils45.NAME_KEY && _obj[key] !== "") {
|
|
4378
|
+
paths.forEach((path) => {
|
|
4379
|
+
const formValue = (0, import_get6.default)(formData, path);
|
|
4380
|
+
if (typeof formValue !== "object" || (0, import_isEmpty4.default)(formValue) || Array.isArray(formValue) && formValue.every((val) => typeof val !== "object")) {
|
|
4381
|
+
acc.push(path);
|
|
4382
|
+
}
|
|
4383
|
+
});
|
|
4384
|
+
}
|
|
4385
|
+
});
|
|
4386
|
+
return acc;
|
|
4387
|
+
};
|
|
4388
|
+
return getAllPaths(pathSchema);
|
|
4389
|
+
};
|
|
4390
|
+
/** Returns the `formData` after filtering to remove any extra data not in a form field
|
|
4391
|
+
*
|
|
4392
|
+
* @param formData - The data for the `Form`
|
|
4393
|
+
* @returns The `formData` after omitting extra data
|
|
4394
|
+
*/
|
|
4395
|
+
omitExtraData = (formData) => {
|
|
4396
|
+
const { schema, schemaUtils } = this.state;
|
|
4397
|
+
const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
|
|
4398
|
+
const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
|
|
4399
|
+
const fieldNames = this.getFieldNames(pathSchema, formData);
|
|
4400
|
+
const newFormData = this.getUsedFormData(formData, fieldNames);
|
|
4401
|
+
return newFormData;
|
|
4402
|
+
};
|
|
3711
4403
|
// Filtering errors based on your retrieved schema to only show errors for properties in the selected branch.
|
|
3712
4404
|
filterErrorsBasedOnSchema(schemaErrors, resolvedSchema, formData) {
|
|
3713
4405
|
const { retrievedSchema, schemaUtils } = this.state;
|
|
@@ -3718,18 +4410,185 @@ var Form = class extends import_react17.Component {
|
|
|
3718
4410
|
if (resolvedSchema?.type !== "object" && resolvedSchema?.type !== "array") {
|
|
3719
4411
|
filteredErrors.__errors = schemaErrors.__errors;
|
|
3720
4412
|
}
|
|
3721
|
-
const
|
|
4413
|
+
const prevCustomValidateErrors = this.getPreviousCustomValidateErrors();
|
|
4414
|
+
const filterPreviousCustomErrors = (errors = [], prevCustomErrors) => {
|
|
4415
|
+
if (errors.length === 0) {
|
|
4416
|
+
return errors;
|
|
4417
|
+
}
|
|
4418
|
+
return errors.filter((error) => {
|
|
4419
|
+
return !prevCustomErrors.includes(error);
|
|
4420
|
+
});
|
|
4421
|
+
};
|
|
4422
|
+
const filterNilOrEmptyErrors = (errors, previousCustomValidateErrors = {}) => {
|
|
3722
4423
|
(0, import_forEach.default)(errors, (errorAtKey, errorKey) => {
|
|
3723
|
-
|
|
4424
|
+
const prevCustomValidateErrorAtKey = previousCustomValidateErrors[errorKey];
|
|
4425
|
+
if ((0, import_isNil.default)(errorAtKey) || Array.isArray(errorAtKey) && errorAtKey.length === 0) {
|
|
3724
4426
|
delete errors[errorKey];
|
|
4427
|
+
} else if ((0, import_utils45.isObject)(errorAtKey) && (0, import_utils45.isObject)(prevCustomValidateErrorAtKey) && Array.isArray(prevCustomValidateErrorAtKey?.__errors)) {
|
|
4428
|
+
errors[errorKey] = filterPreviousCustomErrors(errorAtKey.__errors, prevCustomValidateErrorAtKey.__errors);
|
|
3725
4429
|
} else if (typeof errorAtKey === "object" && !Array.isArray(errorAtKey.__errors)) {
|
|
3726
|
-
|
|
4430
|
+
filterNilOrEmptyErrors(errorAtKey, previousCustomValidateErrors[errorKey]);
|
|
3727
4431
|
}
|
|
3728
4432
|
});
|
|
3729
4433
|
return errors;
|
|
3730
4434
|
};
|
|
3731
|
-
return
|
|
4435
|
+
return filterNilOrEmptyErrors(filteredErrors, prevCustomValidateErrors);
|
|
4436
|
+
}
|
|
4437
|
+
/** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
|
|
4438
|
+
* `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
|
|
4439
|
+
* then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filtered to remove any extra data not
|
|
4440
|
+
* in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
|
|
4441
|
+
* updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
|
|
4442
|
+
* callback will be called if specified with the updated state.
|
|
4443
|
+
*
|
|
4444
|
+
* @param formData - The new form data from a change to a field
|
|
4445
|
+
* @param newErrorSchema - The new `ErrorSchema` based on the field change
|
|
4446
|
+
* @param id - The id of the field that caused the change
|
|
4447
|
+
*/
|
|
4448
|
+
onChange = (formData, newErrorSchema, id) => {
|
|
4449
|
+
const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
|
|
4450
|
+
const { schemaUtils, schema } = this.state;
|
|
4451
|
+
let retrievedSchema = this.state.retrievedSchema;
|
|
4452
|
+
if ((0, import_utils45.isObject)(formData) || Array.isArray(formData)) {
|
|
4453
|
+
const newState = this.getStateFromProps(this.props, formData);
|
|
4454
|
+
formData = newState.formData;
|
|
4455
|
+
retrievedSchema = newState.retrievedSchema;
|
|
4456
|
+
}
|
|
4457
|
+
const mustValidate = !noValidate && liveValidate;
|
|
4458
|
+
let state = { formData, schema };
|
|
4459
|
+
let newFormData = formData;
|
|
4460
|
+
if (omitExtraData === true && liveOmit === true) {
|
|
4461
|
+
newFormData = this.omitExtraData(formData);
|
|
4462
|
+
state = {
|
|
4463
|
+
formData: newFormData
|
|
4464
|
+
};
|
|
4465
|
+
}
|
|
4466
|
+
if (mustValidate) {
|
|
4467
|
+
const schemaValidation = this.validate(newFormData, schema, schemaUtils, retrievedSchema);
|
|
4468
|
+
let errors = schemaValidation.errors;
|
|
4469
|
+
let errorSchema = schemaValidation.errorSchema;
|
|
4470
|
+
const schemaValidationErrors = errors;
|
|
4471
|
+
const schemaValidationErrorSchema = errorSchema;
|
|
4472
|
+
if (extraErrors) {
|
|
4473
|
+
const merged = (0, import_utils45.validationDataMerge)(schemaValidation, extraErrors);
|
|
4474
|
+
errorSchema = merged.errorSchema;
|
|
4475
|
+
errors = merged.errors;
|
|
4476
|
+
}
|
|
4477
|
+
if (newErrorSchema) {
|
|
4478
|
+
const filteredErrors = this.filterErrorsBasedOnSchema(newErrorSchema, retrievedSchema, newFormData);
|
|
4479
|
+
errorSchema = (0, import_utils45.mergeObjects)(errorSchema, filteredErrors, "preventDuplicates");
|
|
4480
|
+
}
|
|
4481
|
+
state = {
|
|
4482
|
+
formData: newFormData,
|
|
4483
|
+
errors,
|
|
4484
|
+
errorSchema,
|
|
4485
|
+
schemaValidationErrors,
|
|
4486
|
+
schemaValidationErrorSchema
|
|
4487
|
+
};
|
|
4488
|
+
} else if (!noValidate && newErrorSchema) {
|
|
4489
|
+
const errorSchema = extraErrors ? (0, import_utils45.mergeObjects)(newErrorSchema, extraErrors, "preventDuplicates") : newErrorSchema;
|
|
4490
|
+
state = {
|
|
4491
|
+
formData: newFormData,
|
|
4492
|
+
errorSchema,
|
|
4493
|
+
errors: (0, import_utils45.toErrorList)(errorSchema)
|
|
4494
|
+
};
|
|
4495
|
+
}
|
|
4496
|
+
this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
|
|
4497
|
+
};
|
|
4498
|
+
/**
|
|
4499
|
+
* If the retrievedSchema has changed the new retrievedSchema is returned.
|
|
4500
|
+
* Otherwise, the old retrievedSchema is returned to persist reference.
|
|
4501
|
+
* - This ensures that AJV retrieves the schema from the cache when it has not changed,
|
|
4502
|
+
* avoiding the performance cost of recompiling the schema.
|
|
4503
|
+
*
|
|
4504
|
+
* @param retrievedSchema The new retrieved schema.
|
|
4505
|
+
* @returns The new retrieved schema if it has changed, else the old retrieved schema.
|
|
4506
|
+
*/
|
|
4507
|
+
updateRetrievedSchema(retrievedSchema) {
|
|
4508
|
+
const isTheSame = (0, import_utils45.deepEquals)(retrievedSchema, this.state?.retrievedSchema);
|
|
4509
|
+
return isTheSame ? this.state.retrievedSchema : retrievedSchema;
|
|
3732
4510
|
}
|
|
4511
|
+
/**
|
|
4512
|
+
* Callback function to handle reset form data.
|
|
4513
|
+
* - Reset all fields with default values.
|
|
4514
|
+
* - Reset validations and errors
|
|
4515
|
+
*
|
|
4516
|
+
*/
|
|
4517
|
+
reset = () => {
|
|
4518
|
+
const { onChange } = this.props;
|
|
4519
|
+
const newState = this.getStateFromProps(this.props, void 0);
|
|
4520
|
+
const newFormData = newState.formData;
|
|
4521
|
+
const state = {
|
|
4522
|
+
formData: newFormData,
|
|
4523
|
+
errorSchema: {},
|
|
4524
|
+
errors: [],
|
|
4525
|
+
schemaValidationErrors: [],
|
|
4526
|
+
schemaValidationErrorSchema: {}
|
|
4527
|
+
};
|
|
4528
|
+
this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
|
|
4529
|
+
};
|
|
4530
|
+
/** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
|
|
4531
|
+
* was provided.
|
|
4532
|
+
*
|
|
4533
|
+
* @param id - The unique `id` of the field that was blurred
|
|
4534
|
+
* @param data - The data associated with the field that was blurred
|
|
4535
|
+
*/
|
|
4536
|
+
onBlur = (id, data) => {
|
|
4537
|
+
const { onBlur } = this.props;
|
|
4538
|
+
if (onBlur) {
|
|
4539
|
+
onBlur(id, data);
|
|
4540
|
+
}
|
|
4541
|
+
};
|
|
4542
|
+
/** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
|
|
4543
|
+
* was provided.
|
|
4544
|
+
*
|
|
4545
|
+
* @param id - The unique `id` of the field that was focused
|
|
4546
|
+
* @param data - The data associated with the field that was focused
|
|
4547
|
+
*/
|
|
4548
|
+
onFocus = (id, data) => {
|
|
4549
|
+
const { onFocus } = this.props;
|
|
4550
|
+
if (onFocus) {
|
|
4551
|
+
onFocus(id, data);
|
|
4552
|
+
}
|
|
4553
|
+
};
|
|
4554
|
+
/** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
|
|
4555
|
+
* happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
|
|
4556
|
+
* `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
|
|
4557
|
+
* via the `onError()` callback unless validation is disabled. Finally, it will add in any `extraErrors` and then call
|
|
4558
|
+
* back the `onSubmit` callback if it was provided.
|
|
4559
|
+
*
|
|
4560
|
+
* @param event - The submit HTML form event
|
|
4561
|
+
*/
|
|
4562
|
+
onSubmit = (event) => {
|
|
4563
|
+
event.preventDefault();
|
|
4564
|
+
if (event.target !== event.currentTarget) {
|
|
4565
|
+
return;
|
|
4566
|
+
}
|
|
4567
|
+
event.persist();
|
|
4568
|
+
const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
|
|
4569
|
+
let { formData: newFormData } = this.state;
|
|
4570
|
+
if (omitExtraData === true) {
|
|
4571
|
+
newFormData = this.omitExtraData(newFormData);
|
|
4572
|
+
}
|
|
4573
|
+
if (noValidate || this.validateFormWithFormData(newFormData)) {
|
|
4574
|
+
const errorSchema = extraErrors || {};
|
|
4575
|
+
const errors = extraErrors ? (0, import_utils45.toErrorList)(extraErrors) : [];
|
|
4576
|
+
this.setState(
|
|
4577
|
+
{
|
|
4578
|
+
formData: newFormData,
|
|
4579
|
+
errors,
|
|
4580
|
+
errorSchema,
|
|
4581
|
+
schemaValidationErrors: [],
|
|
4582
|
+
schemaValidationErrorSchema: {}
|
|
4583
|
+
},
|
|
4584
|
+
() => {
|
|
4585
|
+
if (onSubmit) {
|
|
4586
|
+
onSubmit({ ...this.state, formData: newFormData, status: "submitted" }, event);
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
);
|
|
4590
|
+
}
|
|
4591
|
+
};
|
|
3733
4592
|
/** Returns the registry for the form */
|
|
3734
4593
|
getRegistry() {
|
|
3735
4594
|
const { translateString: customTranslateString, uiSchema = {} } = this.props;
|
|
@@ -3750,9 +4609,20 @@ var Form = class extends import_react17.Component {
|
|
|
3750
4609
|
formContext: this.props.formContext || formContext,
|
|
3751
4610
|
schemaUtils,
|
|
3752
4611
|
translateString: customTranslateString || translateString,
|
|
3753
|
-
globalUiOptions: uiSchema[
|
|
4612
|
+
globalUiOptions: uiSchema[import_utils45.UI_GLOBAL_OPTIONS_KEY]
|
|
3754
4613
|
};
|
|
3755
4614
|
}
|
|
4615
|
+
/** Provides a function that can be used to programmatically submit the `Form` */
|
|
4616
|
+
submit = () => {
|
|
4617
|
+
if (this.formElement.current) {
|
|
4618
|
+
const submitCustomEvent = new CustomEvent("submit", {
|
|
4619
|
+
cancelable: true
|
|
4620
|
+
});
|
|
4621
|
+
submitCustomEvent.preventDefault();
|
|
4622
|
+
this.formElement.current.dispatchEvent(submitCustomEvent);
|
|
4623
|
+
this.formElement.current.requestSubmit();
|
|
4624
|
+
}
|
|
4625
|
+
};
|
|
3756
4626
|
/** Attempts to focus on the field associated with the `error`. Uses the `property` field to compute path of the error
|
|
3757
4627
|
* field, then, using the `idPrefix` and `idSeparator` converts that path into an id. Then the input element with that
|
|
3758
4628
|
* id is attempted to be found using the `formElement` ref. If it is located, then it is focused.
|
|
@@ -3771,7 +4641,7 @@ var Form = class extends import_react17.Component {
|
|
|
3771
4641
|
const elementId = path.join(idSeparator);
|
|
3772
4642
|
let field = this.formElement.current.elements[elementId];
|
|
3773
4643
|
if (!field) {
|
|
3774
|
-
field = this.formElement.current.querySelector(`input[id
|
|
4644
|
+
field = this.formElement.current.querySelector(`input[id^="${elementId}"`);
|
|
3775
4645
|
}
|
|
3776
4646
|
if (field && field.length) {
|
|
3777
4647
|
field = field[0];
|
|
@@ -3780,6 +4650,59 @@ var Form = class extends import_react17.Component {
|
|
|
3780
4650
|
field.focus();
|
|
3781
4651
|
}
|
|
3782
4652
|
}
|
|
4653
|
+
/** Validates the form using the given `formData`. For use on form submission or on programmatic validation.
|
|
4654
|
+
* If `onError` is provided, then it will be called with the list of errors.
|
|
4655
|
+
*
|
|
4656
|
+
* @param formData - The form data to validate
|
|
4657
|
+
* @returns - True if the form is valid, false otherwise.
|
|
4658
|
+
*/
|
|
4659
|
+
validateFormWithFormData = (formData) => {
|
|
4660
|
+
const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
|
|
4661
|
+
const { errors: prevErrors } = this.state;
|
|
4662
|
+
const schemaValidation = this.validate(formData);
|
|
4663
|
+
let errors = schemaValidation.errors;
|
|
4664
|
+
let errorSchema = schemaValidation.errorSchema;
|
|
4665
|
+
const schemaValidationErrors = errors;
|
|
4666
|
+
const schemaValidationErrorSchema = errorSchema;
|
|
4667
|
+
const hasError = errors.length > 0 || extraErrors && extraErrorsBlockSubmit;
|
|
4668
|
+
if (hasError) {
|
|
4669
|
+
if (extraErrors) {
|
|
4670
|
+
const merged = (0, import_utils45.validationDataMerge)(schemaValidation, extraErrors);
|
|
4671
|
+
errorSchema = merged.errorSchema;
|
|
4672
|
+
errors = merged.errors;
|
|
4673
|
+
}
|
|
4674
|
+
if (focusOnFirstError) {
|
|
4675
|
+
if (typeof focusOnFirstError === "function") {
|
|
4676
|
+
focusOnFirstError(errors[0]);
|
|
4677
|
+
} else {
|
|
4678
|
+
this.focusOnError(errors[0]);
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4681
|
+
this.setState(
|
|
4682
|
+
{
|
|
4683
|
+
errors,
|
|
4684
|
+
errorSchema,
|
|
4685
|
+
schemaValidationErrors,
|
|
4686
|
+
schemaValidationErrorSchema
|
|
4687
|
+
},
|
|
4688
|
+
() => {
|
|
4689
|
+
if (onError) {
|
|
4690
|
+
onError(errors);
|
|
4691
|
+
} else {
|
|
4692
|
+
console.error("Form validation failed", errors);
|
|
4693
|
+
}
|
|
4694
|
+
}
|
|
4695
|
+
);
|
|
4696
|
+
} else if (prevErrors.length > 0) {
|
|
4697
|
+
this.setState({
|
|
4698
|
+
errors: [],
|
|
4699
|
+
errorSchema: {},
|
|
4700
|
+
schemaValidationErrors: [],
|
|
4701
|
+
schemaValidationErrorSchema: {}
|
|
4702
|
+
});
|
|
4703
|
+
}
|
|
4704
|
+
return !hasError;
|
|
4705
|
+
};
|
|
3783
4706
|
/** Programmatically validate the form. If `omitExtraData` is true, the `formData` will first be filtered to remove
|
|
3784
4707
|
* any extra data not in a form field. If `onError` is provided, then it will be called with the list of errors the
|
|
3785
4708
|
* same way as would happen on form submission.
|
|
@@ -3811,7 +4734,6 @@ var Form = class extends import_react17.Component {
|
|
|
3811
4734
|
action,
|
|
3812
4735
|
autoComplete,
|
|
3813
4736
|
enctype,
|
|
3814
|
-
acceptcharset,
|
|
3815
4737
|
acceptCharset,
|
|
3816
4738
|
noHtml5Validate = false,
|
|
3817
4739
|
disabled,
|
|
@@ -3826,12 +4748,12 @@ var Form = class extends import_react17.Component {
|
|
|
3826
4748
|
const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
|
|
3827
4749
|
const as = _internalFormWrapper ? tagName : void 0;
|
|
3828
4750
|
const FormTag = _internalFormWrapper || tagName || "form";
|
|
3829
|
-
let { [
|
|
4751
|
+
let { [import_utils45.SUBMIT_BTN_OPTIONS_KEY]: submitOptions = {} } = (0, import_utils45.getUiOptions)(uiSchema);
|
|
3830
4752
|
if (disabled) {
|
|
3831
4753
|
submitOptions = { ...submitOptions, props: { ...submitOptions.props, disabled: true } };
|
|
3832
4754
|
}
|
|
3833
|
-
const submitUiSchema = { [
|
|
3834
|
-
return /* @__PURE__ */ (0,
|
|
4755
|
+
const submitUiSchema = { [import_utils45.UI_OPTIONS_KEY]: { [import_utils45.SUBMIT_BTN_OPTIONS_KEY]: submitOptions } };
|
|
4756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
|
|
3835
4757
|
FormTag,
|
|
3836
4758
|
{
|
|
3837
4759
|
className: className ? className : "rjsf",
|
|
@@ -3842,14 +4764,14 @@ var Form = class extends import_react17.Component {
|
|
|
3842
4764
|
action,
|
|
3843
4765
|
autoComplete,
|
|
3844
4766
|
encType: enctype,
|
|
3845
|
-
acceptCharset
|
|
4767
|
+
acceptCharset,
|
|
3846
4768
|
noValidate: noHtml5Validate,
|
|
3847
4769
|
onSubmit: this.onSubmit,
|
|
3848
4770
|
as,
|
|
3849
4771
|
ref: this.formElement,
|
|
3850
4772
|
children: [
|
|
3851
4773
|
showErrorList === "top" && this.renderErrors(registry),
|
|
3852
|
-
/* @__PURE__ */ (0,
|
|
4774
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
3853
4775
|
_SchemaField,
|
|
3854
4776
|
{
|
|
3855
4777
|
name: "",
|
|
@@ -3869,7 +4791,7 @@ var Form = class extends import_react17.Component {
|
|
|
3869
4791
|
readonly
|
|
3870
4792
|
}
|
|
3871
4793
|
),
|
|
3872
|
-
children ? children : /* @__PURE__ */ (0,
|
|
4794
|
+
children ? children : /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(SubmitButton2, { uiSchema: submitUiSchema, registry }),
|
|
3873
4795
|
showErrorList === "bottom" && this.renderErrors(registry)
|
|
3874
4796
|
]
|
|
3875
4797
|
}
|
|
@@ -3878,10 +4800,10 @@ var Form = class extends import_react17.Component {
|
|
|
3878
4800
|
};
|
|
3879
4801
|
|
|
3880
4802
|
// src/withTheme.tsx
|
|
3881
|
-
var
|
|
3882
|
-
var
|
|
4803
|
+
var import_react23 = require("react");
|
|
4804
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
3883
4805
|
function withTheme(themeProps) {
|
|
3884
|
-
return (0,
|
|
4806
|
+
return (0, import_react23.forwardRef)(
|
|
3885
4807
|
({ fields: fields2, widgets: widgets2, templates: templates2, ...directProps }, ref) => {
|
|
3886
4808
|
fields2 = { ...themeProps?.fields, ...fields2 };
|
|
3887
4809
|
widgets2 = { ...themeProps?.widgets, ...widgets2 };
|
|
@@ -3893,7 +4815,7 @@ function withTheme(themeProps) {
|
|
|
3893
4815
|
...templates2?.ButtonTemplates
|
|
3894
4816
|
}
|
|
3895
4817
|
};
|
|
3896
|
-
return /* @__PURE__ */ (0,
|
|
4818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
3897
4819
|
Form,
|
|
3898
4820
|
{
|
|
3899
4821
|
...themeProps,
|
|
@@ -3909,5 +4831,5 @@ function withTheme(themeProps) {
|
|
|
3909
4831
|
}
|
|
3910
4832
|
|
|
3911
4833
|
// src/index.ts
|
|
3912
|
-
var
|
|
4834
|
+
var index_default = Form;
|
|
3913
4835
|
//# sourceMappingURL=index.js.map
|