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