@limetech/lime-elements 39.13.3 → 39.14.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/CHANGELOG.md +14 -0
- package/dist/cjs/{_assignValue-D2D1zedG.js → _assignValue-DpsLUlF4.js} +25 -2
- package/dist/cjs/{_baseForOwn-QM0kHQT5.js → _baseEach-C570gT5Y.js} +43 -1
- package/dist/cjs/{_baseIsEqual-D6hrjmx4.js → _baseIsEqual-aOPReRWl.js} +1 -0
- package/dist/cjs/{_baseIteratee-iGEZ9pZY.js → _baseIteratee-DggA4e7a.js} +3 -1
- package/dist/cjs/_commonjsHelpers-CFO10eej.js +7 -0
- package/dist/cjs/_getAllKeysIn-BQIV8aw7.js +118 -0
- package/dist/cjs/_isIterateeCall-CPWXFS_s.js +72 -0
- package/dist/cjs/cloneDeep-CxFNKF1Y.js +619 -0
- package/dist/cjs/{isArrayLikeObject-CTP6Ak01.js → difference-Bfsq4sXB.js} +93 -5
- package/dist/cjs/{focus-trigger-element-NnpJ5nTp.js → focus-trigger-element-Brw8VubX.js} +1 -1
- package/dist/cjs/{format-D04vDIBj.js → format-D4jZb7Ls.js} +1 -1
- package/dist/cjs/{index-mbfaT7TB.js → index-BgFEL6FF.js} +1 -1
- package/dist/cjs/{isEmpty-DCC_l2Xp.js → isEmpty-EBCFxX1S.js} +1 -1
- package/dist/cjs/{isEqual-BsHLqE-x.js → isEqual-bXyw7kXo.js} +1 -1
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-badge.cjs.entry.js +2 -2
- package/dist/cjs/limel-breadcrumbs_7.cjs.entry.js +2 -3
- package/dist/cjs/limel-chip_2.cjs.entry.js +3 -3
- package/dist/cjs/limel-circular-progress.cjs.entry.js +2 -2
- package/dist/cjs/limel-code-editor.cjs.entry.js +1 -1
- package/dist/cjs/limel-date-picker.cjs.entry.js +3 -3
- package/dist/cjs/limel-dialog.cjs.entry.js +2 -2
- package/dist/cjs/limel-file-dropzone_2.cjs.entry.js +5 -44
- package/dist/cjs/limel-file-viewer.cjs.entry.js +2 -2
- package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +12 -74
- package/dist/cjs/limel-form.cjs.entry.js +38541 -50295
- package/dist/cjs/limel-markdown.cjs.entry.js +3 -3
- package/dist/cjs/limel-popover_2.cjs.entry.js +2 -3
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +23 -481
- package/dist/cjs/limel-tab-bar.cjs.entry.js +4 -83
- package/dist/cjs/limel-table.cjs.entry.js +14 -269
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{markdown-parser-DCnW9yak.js → markdown-parser-BIa99LAc.js} +2 -2
- package/dist/cjs/{moment-DCqC7BZP.js → moment-CqRdiK10.js} +1 -1
- package/dist/cjs/pickBy-kLjYLoam.js +201 -0
- package/dist/cjs/{sv-jO-ewmqh.js → sv-BSR4W58y.js} +1 -1
- package/dist/collection/components/form/adapters/widget-adapter.js +23 -30
- package/dist/collection/components/form/fields/array-field.js +39 -6
- package/dist/collection/components/form/fields/field-helpers.js +4 -4
- package/dist/collection/components/form/fields/object-field.js +4 -2
- package/dist/collection/components/form/fields/schema-field.js +33 -70
- package/dist/collection/components/form/form.css +19 -19
- package/dist/collection/components/form/form.js +40 -72
- package/dist/collection/components/form/form.test-schemas.js +308 -0
- package/dist/collection/components/form/row/row-context.js +2 -0
- package/dist/collection/components/form/row/row.js +2 -2
- package/dist/collection/components/form/templates/array-context.js +2 -0
- package/dist/collection/components/form/templates/array-field-collapsible-item.js +4 -4
- package/dist/collection/components/form/templates/array-field-item.js +47 -0
- package/dist/collection/components/form/templates/array-field-simple-item.js +6 -7
- package/dist/collection/components/form/templates/array-field.js +38 -94
- package/dist/collection/components/form/templates/index.js +1 -0
- package/dist/collection/components/form/templates/object-field.js +15 -11
- package/dist/collection/components/form/validation-display.js +75 -0
- package/dist/collection/components/form/validator.js +10 -0
- package/dist/collection/components/form/widgets/code-editor.js +1 -1
- package/dist/collection/components/form/widgets/select.js +2 -1
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/trigger/create-html-inserter.js +2 -2
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/trigger/factory-helpers/append-transaction-handler.js +7 -0
- package/dist/collection/components/text-editor/prosemirror-adapter/plugins/trigger/inserter.js +1 -1
- package/dist/esm/{_assignValue-DkGAX8ec.js → _assignValue-DOEO9byf.js} +24 -2
- package/dist/esm/{_baseForOwn-CfpQNnvA.js → _baseEach-CL_-rBMy.js} +42 -2
- package/dist/esm/{_baseIsEqual-BvHnKRmD.js → _baseIsEqual-BfXMsuGh.js} +2 -2
- package/dist/esm/{_baseIteratee-DFBCJcMA.js → _baseIteratee-kS1-0_xD.js} +3 -3
- package/dist/esm/_commonjsHelpers-B85MJLTf.js +5 -0
- package/dist/esm/_getAllKeysIn-BKpeslPJ.js +113 -0
- package/dist/esm/_isIterateeCall-CTcCv8Mb.js +69 -0
- package/dist/esm/cloneDeep-BXAw5H-1.js +609 -0
- package/dist/esm/{isArrayLikeObject-D7yRwRv4.js → difference-DMAjHh-t.js} +91 -7
- package/dist/esm/{focus-trigger-element-6aEStEKM.js → focus-trigger-element-DubROLkE.js} +1 -1
- package/dist/esm/{format-BMPGHLQ8.js → format-hTrthuPP.js} +1 -1
- package/dist/esm/{index-DJJymEnS.js → index-t4DgGbWS.js} +1 -1
- package/dist/esm/{isArrayLike-bWHU4ebg.js → isArrayLike-D1QkaJU2.js} +1 -1
- package/dist/esm/{isEmpty-tfwtR2ai.js → isEmpty-DrFXbHWO.js} +2 -2
- package/dist/esm/{isEqual-BkQ4Z_9r.js → isEqual-CpaoJ_AF.js} +1 -1
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-badge.entry.js +2 -2
- package/dist/esm/limel-breadcrumbs_7.entry.js +2 -3
- package/dist/esm/limel-chip_2.entry.js +4 -4
- package/dist/esm/limel-circular-progress.entry.js +2 -2
- package/dist/esm/limel-code-editor.entry.js +1 -1
- package/dist/esm/limel-date-picker.entry.js +3 -3
- package/dist/esm/limel-dialog.entry.js +3 -3
- package/dist/esm/limel-file-dropzone_2.entry.js +4 -43
- package/dist/esm/limel-file-viewer.entry.js +2 -2
- package/dist/esm/limel-flatpickr-adapter.entry.js +8 -70
- package/dist/esm/limel-form.entry.js +38553 -50307
- package/dist/esm/limel-markdown.entry.js +3 -3
- package/dist/esm/limel-popover_2.entry.js +2 -3
- package/dist/esm/limel-prosemirror-adapter.entry.js +22 -480
- package/dist/esm/limel-tab-bar.entry.js +4 -83
- package/dist/esm/limel-table.entry.js +11 -266
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{markdown-parser-CXYHPPe2.js → markdown-parser-D7vLKElE.js} +2 -2
- package/dist/esm/{moment-DhvPC9Jt.js → moment-DQRNe8qq.js} +1 -1
- package/dist/esm/pickBy-BEA90LIZ.js +195 -0
- package/dist/esm/{sv-84mf7Xsv.js → sv-CY-6-yEp.js} +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/p-1cb2d781.entry.js +13 -0
- package/dist/lime-elements/{p-00d6ccd6.entry.js → p-25ae3a55.entry.js} +5 -5
- package/dist/lime-elements/{p-be0cbddb.entry.js → p-374ec191.entry.js} +1 -1
- package/dist/lime-elements/p-3a662d7e.entry.js +1 -0
- package/dist/lime-elements/{p-f0f5eda1.entry.js → p-41be4893.entry.js} +1 -1
- package/dist/lime-elements/{p-c84911e6.entry.js → p-4ad193a2.entry.js} +1 -1
- package/dist/lime-elements/{p-dd7a2361.entry.js → p-4ce682cf.entry.js} +3 -3
- package/dist/lime-elements/{p-eeae0ef6.entry.js → p-5ee484a7.entry.js} +4 -4
- package/dist/lime-elements/{p-b1d6553c.entry.js → p-77abb595.entry.js} +1 -1
- package/dist/lime-elements/p-8065425a.entry.js +1 -0
- package/dist/lime-elements/{p-77ba0f66.entry.js → p-8299af78.entry.js} +1 -1
- package/dist/lime-elements/{p-87c5e951.entry.js → p-8c7a7003.entry.js} +1 -1
- package/dist/lime-elements/{p-ce20d720.entry.js → p-97c401f1.entry.js} +1 -1
- package/dist/lime-elements/p-9a378cf0.entry.js +1 -0
- package/dist/lime-elements/p-B3zCFNAw.js +1 -0
- package/dist/lime-elements/p-B6bNnxRu.js +1 -0
- package/dist/lime-elements/p-B85MJLTf.js +1 -0
- package/dist/lime-elements/p-BCMRfUKp.js +1 -0
- package/dist/lime-elements/p-BbU4FGNT.js +1 -0
- package/dist/lime-elements/p-Bp0tNo1s.js +1 -0
- package/dist/lime-elements/{p-DpyWBa_Z.js → p-Bt64o80S.js} +1 -1
- package/dist/lime-elements/{p-BqiDn_Sf.js → p-BvDmWgCs.js} +1 -1
- package/dist/lime-elements/p-CMjGNANG.js +1 -0
- package/dist/lime-elements/p-DFWcgJ_i.js +1 -0
- package/dist/lime-elements/{p-B4YDb6f3.js → p-DJvGLFul.js} +1 -1
- package/dist/lime-elements/p-DTXIk0fN.js +1 -0
- package/dist/lime-elements/{p-BgPHaiMH.js → p-D_uMnX5g.js} +1 -1
- package/dist/lime-elements/{p-g3InYy9F.js → p-DdYOzHlg.js} +1 -1
- package/dist/lime-elements/{p-ndpPJpml.js → p-DsDkl4Sy.js} +1 -1
- package/dist/lime-elements/p-UGKt6Ywx.js +1 -0
- package/dist/lime-elements/p-afcf580c.entry.js +16 -0
- package/dist/lime-elements/p-f6c3f49b.entry.js +1 -0
- package/dist/lime-elements/p-v6b303K5.js +1 -0
- package/dist/lime-elements/p-xQsJdKrq.js +1 -0
- package/dist/lime-elements/{p-BYx8mudw.js → p-zo6O9LC9.js} +2 -2
- package/dist/types/components/form/adapters/widget-adapter.d.ts +3 -2
- package/dist/types/components/form/fields/array-field.d.ts +11 -19
- package/dist/types/components/form/fields/object-field.d.ts +2 -2
- package/dist/types/components/form/fields/schema-field.d.ts +5 -18
- package/dist/types/components/form/form.d.ts +4 -8
- package/dist/types/components/form/form.test-schemas.d.ts +30 -0
- package/dist/types/components/form/row/row-context.d.ts +2 -0
- package/dist/types/components/form/templates/array-context.d.ts +7 -0
- package/dist/types/components/form/templates/array-field-collapsible-item.d.ts +7 -11
- package/dist/types/components/form/templates/array-field-item.d.ts +6 -0
- package/dist/types/components/form/templates/array-field-simple-item.d.ts +7 -9
- package/dist/types/components/form/templates/array-field.d.ts +7 -8
- package/dist/types/components/form/templates/index.d.ts +1 -0
- package/dist/types/components/form/templates/object-field.d.ts +6 -1
- package/dist/types/components/form/templates/types.d.ts +2 -4
- package/dist/types/components/form/validation-display.d.ts +60 -0
- package/dist/types/components/form/validator.d.ts +6 -0
- package/dist/types/components/form/widgets/code-editor.d.ts +1 -1
- package/dist/types/components/form/widgets/types.d.ts +1 -1
- package/dist/types/components/text-editor/prosemirror-adapter/plugins/trigger/create-html-inserter.d.ts +2 -1
- package/package.json +4 -2
- package/dist/cjs/_baseAssignValue-BJgt6T7z.js +0 -27
- package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +0 -10
- package/dist/cjs/_getPrototype-BK9cL-57.js +0 -8
- package/dist/cjs/negate-Bg3SqQh6.js +0 -42
- package/dist/collection/components/form/fields/types.js +0 -1
- package/dist/collection/components/form/schema-cache.js +0 -66
- package/dist/esm/_baseAssignValue-C8Uwn8zr.js +0 -25
- package/dist/esm/_commonjsHelpers-BFTU3MAI.js +0 -7
- package/dist/esm/_getPrototype-jV9gkkJy.js +0 -6
- package/dist/esm/negate-ooVD-6_a.js +0 -40
- package/dist/lime-elements/p-45dfcaf3.entry.js +0 -1
- package/dist/lime-elements/p-5db2d069.entry.js +0 -1
- package/dist/lime-elements/p-9728aa4a.entry.js +0 -1
- package/dist/lime-elements/p-BFTU3MAI.js +0 -1
- package/dist/lime-elements/p-BlJd1RC5.js +0 -1
- package/dist/lime-elements/p-C6SEjICu.js +0 -1
- package/dist/lime-elements/p-CqEHNkif.js +0 -1
- package/dist/lime-elements/p-Cs5T63LB.js +0 -1
- package/dist/lime-elements/p-Cw1B5fXE.js +0 -1
- package/dist/lime-elements/p-DKxusNKT.js +0 -1
- package/dist/lime-elements/p-DrjUjEz3.js +0 -1
- package/dist/lime-elements/p-DzlmgobW.js +0 -1
- package/dist/lime-elements/p-ZcW3uvZL.js +0 -1
- package/dist/lime-elements/p-a4a09ce9.entry.js +0 -7
- package/dist/lime-elements/p-c4e2885d.entry.js +0 -16
- package/dist/lime-elements/p-ee80a6f2.entry.js +0 -1
- package/dist/lime-elements/p-ooVD-6_a.js +0 -1
- package/dist/types/components/form/fields/types.d.ts +0 -41
- package/dist/types/components/form/schema-cache.d.ts +0 -17
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { hasValue, isFieldInvalid, isFieldRequired, getErrorText, } from "../validation-display";
|
|
3
3
|
import { getHelpComponent } from "../help";
|
|
4
|
+
import { RowLayoutContext } from "../row/row-context";
|
|
4
5
|
/**
|
|
5
6
|
* A widget is a concept in react-jsonschema-form (rjsf).
|
|
6
7
|
* It represents a HTML tag for the user to enter data, eg. input, select, etc.
|
|
@@ -23,47 +24,35 @@ export class LimeElementsWidgetAdapter extends React.Component {
|
|
|
23
24
|
};
|
|
24
25
|
this.handleBlur = this.handleBlur.bind(this);
|
|
25
26
|
}
|
|
26
|
-
hasValue() {
|
|
27
|
-
const value = this.getValue();
|
|
28
|
-
if (!value) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
if (Array.isArray(value)) {
|
|
32
|
-
return value.length > 0;
|
|
33
|
-
}
|
|
34
|
-
if (value instanceof Date) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
if (typeof value === 'object') {
|
|
38
|
-
return Object.entries(value).length > 0;
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
27
|
handleBlur() {
|
|
43
28
|
this.setState({ modified: true });
|
|
44
29
|
}
|
|
45
30
|
getLabel() {
|
|
46
|
-
|
|
31
|
+
if (this.context) {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
const { schema, label, hideLabel } = this.props.widgetProps;
|
|
35
|
+
if (hideLabel) {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
47
38
|
return label || schema.title;
|
|
48
39
|
}
|
|
49
40
|
isInvalid() {
|
|
50
41
|
const { modified } = this.state;
|
|
51
|
-
const { rawErrors } = this.props.widgetProps;
|
|
52
|
-
return (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
const { rawErrors, required, schema } = this.props.widgetProps;
|
|
43
|
+
return isFieldInvalid({
|
|
44
|
+
hasErrors: !!rawErrors,
|
|
45
|
+
modified: modified,
|
|
46
|
+
hasValue: hasValue(this.getValue()),
|
|
47
|
+
required: isFieldRequired({ required, minItems: schema.minItems }),
|
|
48
|
+
});
|
|
57
49
|
}
|
|
58
50
|
getHelperText() {
|
|
59
51
|
const { rawErrors, schema } = this.props.widgetProps;
|
|
60
52
|
if (!this.isInvalid()) {
|
|
61
|
-
return schema.description;
|
|
62
|
-
}
|
|
63
|
-
if (rawErrors) {
|
|
64
|
-
return capitalize(rawErrors[0]);
|
|
53
|
+
return this.context ? '' : schema.description;
|
|
65
54
|
}
|
|
66
|
-
return schema.description;
|
|
55
|
+
return getErrorText(rawErrors || [], schema.description);
|
|
67
56
|
}
|
|
68
57
|
getValue() {
|
|
69
58
|
const { value } = this.props;
|
|
@@ -76,7 +65,10 @@ export class LimeElementsWidgetAdapter extends React.Component {
|
|
|
76
65
|
const disabled = this.isDisabled();
|
|
77
66
|
const value = this.getValue();
|
|
78
67
|
const readonly = this.isReadOnly();
|
|
79
|
-
return React.createElement(React.Fragment, {}, React.createElement(name, Object.assign(Object.assign({ value: value, label: this.getLabel(), disabled: disabled, readonly: readonly, required:
|
|
68
|
+
return React.createElement(React.Fragment, {}, React.createElement(name, Object.assign(Object.assign({ value: value, label: this.getLabel(), disabled: disabled, readonly: readonly, required: isFieldRequired({
|
|
69
|
+
required: this.props.widgetProps.required,
|
|
70
|
+
minItems: this.props.widgetProps.schema.minItems,
|
|
71
|
+
}), invalid: this.isInvalid(), 'helper-text': this.getHelperText() }, extraProps), { onChange: this.handleChange, onBlur: this.handleBlur })), getHelpComponent(this.props.widgetProps.schema));
|
|
80
72
|
}
|
|
81
73
|
isDisabled() {
|
|
82
74
|
var _a, _b;
|
|
@@ -91,3 +83,4 @@ export class LimeElementsWidgetAdapter extends React.Component {
|
|
|
91
83
|
return widgetProps.readonly;
|
|
92
84
|
}
|
|
93
85
|
}
|
|
86
|
+
LimeElementsWidgetAdapter.contextType = RowLayoutContext;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import JSONArrayField from "@rjsf/core/lib/components/fields/ArrayField";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import { getDefaultRegistry } from "@rjsf/core";
|
|
3
3
|
import { resetDependentFields } from "./field-helpers";
|
|
4
|
+
import { ARRAY_REORDER_EVENT } from "../templates/array-field";
|
|
5
|
+
const { fields: defaultFields } = getDefaultRegistry();
|
|
6
|
+
const BaseArrayField = defaultFields.ArrayField;
|
|
4
7
|
/**
|
|
5
8
|
* This override field exists to supplement the need to reset dependent fields
|
|
6
9
|
* in SchemaField. The `resetDependentFields` function requires that the schema that
|
|
@@ -14,6 +17,10 @@ import { resetDependentFields } from "./field-helpers";
|
|
|
14
17
|
* `resetDependentFields` on the changed list items. This is possible because the ArrayField is also given
|
|
15
18
|
* the raw schema so it can properly call `resetDependentFields`
|
|
16
19
|
*
|
|
20
|
+
* This field also handles drag-and-drop reordering. The ArrayFieldTemplate
|
|
21
|
+
* dispatches an `arrayReorder` DOM event when Sortable.js completes a drag.
|
|
22
|
+
* This field listens for that event and reorders the form data via onChange.
|
|
23
|
+
*
|
|
17
24
|
* This form has to handle several events that can affect the list:
|
|
18
25
|
*
|
|
19
26
|
* 1. An on change where no list item changes
|
|
@@ -32,20 +39,46 @@ export class ArrayField extends React.Component {
|
|
|
32
39
|
constructor(props) {
|
|
33
40
|
super(props);
|
|
34
41
|
this.handleChange = this.handleChange.bind(this);
|
|
42
|
+
this.handleReorder = this.handleReorder.bind(this);
|
|
43
|
+
this.setWrapper = this.setWrapper.bind(this);
|
|
44
|
+
}
|
|
45
|
+
componentWillUnmount() {
|
|
46
|
+
this.setWrapper(null);
|
|
47
|
+
}
|
|
48
|
+
setWrapper(element) {
|
|
49
|
+
if (this.wrapper) {
|
|
50
|
+
this.wrapper.removeEventListener(ARRAY_REORDER_EVENT, this.handleReorder);
|
|
51
|
+
}
|
|
52
|
+
this.wrapper = element !== null && element !== void 0 ? element : undefined;
|
|
53
|
+
if (this.wrapper) {
|
|
54
|
+
this.wrapper.addEventListener(ARRAY_REORDER_EVENT, this.handleReorder);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
handleReorder(event) {
|
|
58
|
+
event.stopPropagation();
|
|
59
|
+
const { fromIndex, toIndex } = event.detail;
|
|
60
|
+
const { formData, fieldPathId } = this.props;
|
|
61
|
+
if (!Array.isArray(formData) || !fieldPathId) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const reordered = [...formData];
|
|
65
|
+
const [item] = reordered.splice(fromIndex, 1);
|
|
66
|
+
reordered.splice(toIndex, 0, item);
|
|
67
|
+
this.props.onChange(reordered, fieldPathId.path);
|
|
35
68
|
}
|
|
36
|
-
handleChange(newData,
|
|
69
|
+
handleChange(newData, path) {
|
|
37
70
|
const { formData: oldData, schema } = this.props;
|
|
38
71
|
const { rootSchema } = this.props.registry;
|
|
39
72
|
// This case handles when the first list item is added. When there are no
|
|
40
73
|
// items we get undefined instead of []
|
|
41
74
|
if (!oldData) {
|
|
42
|
-
this.props.onChange(newData,
|
|
75
|
+
this.props.onChange(newData, path);
|
|
43
76
|
return;
|
|
44
77
|
}
|
|
45
78
|
// This case happens when we add or remove an item from the list
|
|
46
79
|
// No need to check for resetting fields unless we change data
|
|
47
80
|
if (oldData.length !== newData.length) {
|
|
48
|
-
this.props.onChange(newData,
|
|
81
|
+
this.props.onChange(newData, path);
|
|
49
82
|
return;
|
|
50
83
|
}
|
|
51
84
|
const nonMatchingIndices = [];
|
|
@@ -63,10 +96,10 @@ export class ArrayField extends React.Component {
|
|
|
63
96
|
const i = nonMatchingIndices[0];
|
|
64
97
|
newData[i] = resetDependentFields(oldData[i], newData[i], schema.items, rootSchema);
|
|
65
98
|
}
|
|
66
|
-
this.props.onChange(newData,
|
|
99
|
+
this.props.onChange(newData, path);
|
|
67
100
|
}
|
|
68
101
|
render() {
|
|
69
102
|
const arrayProps = Object.assign(Object.assign({}, this.props), { onChange: this.handleChange });
|
|
70
|
-
return React.createElement(
|
|
103
|
+
return React.createElement('div', { ref: this.setWrapper }, React.createElement(BaseArrayField, arrayProps));
|
|
71
104
|
}
|
|
72
105
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { union, isEqual, isPlainObject, negate } from "lodash-es";
|
|
2
|
-
import { retrieveSchema, ADDITIONAL_PROPERTY_FLAG } from "@rjsf/
|
|
2
|
+
import { retrieveSchema, ADDITIONAL_PROPERTY_FLAG } from "@rjsf/utils";
|
|
3
|
+
import { rjsfValidator } from "../validator";
|
|
3
4
|
/**
|
|
4
5
|
* Given two objects, get a list of keys for each value that is different between
|
|
5
6
|
* the two objects. Compares using deep comparison
|
|
@@ -35,9 +36,8 @@ export const resetDependentFields = (oldData, newData, schema, rootSchema) => {
|
|
|
35
36
|
return newData;
|
|
36
37
|
}
|
|
37
38
|
// Get the schema generated by the current data
|
|
38
|
-
const currentSchema = retrieveSchema(schema, rootSchema, oldData);
|
|
39
|
-
|
|
40
|
-
const newSchema = retrieveSchema(schema, rootSchema, newData);
|
|
39
|
+
const currentSchema = retrieveSchema(rjsfValidator, schema, rootSchema, oldData);
|
|
40
|
+
const newSchema = retrieveSchema(rjsfValidator, schema, rootSchema, newData);
|
|
41
41
|
// Get property keys whose schema changed due to the new data.
|
|
42
42
|
// These properties that have changed are the properties that are dependent on
|
|
43
43
|
// data that has changed in the current onChange event
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import JSONObjectField from "@rjsf/core/lib/components/fields/ObjectField";
|
|
2
1
|
import React from "react";
|
|
2
|
+
import { getDefaultRegistry } from "@rjsf/core";
|
|
3
3
|
import { CodeEditor } from "../widgets/code-editor";
|
|
4
4
|
import { renderDescription, renderTitle } from "../templates/common";
|
|
5
5
|
import { isCustomObjectSchema } from "./field-helpers";
|
|
6
|
+
const { fields: defaultFields } = getDefaultRegistry();
|
|
7
|
+
const BaseObjectField = defaultFields.ObjectField;
|
|
6
8
|
export class ObjectField extends React.Component {
|
|
7
9
|
render() {
|
|
8
10
|
if (!isCustomObjectSchema(this.props.schema)) {
|
|
9
|
-
return React.createElement(
|
|
11
|
+
return React.createElement(BaseObjectField, this.props);
|
|
10
12
|
}
|
|
11
13
|
return React.createElement(React.Fragment, {}, renderTitle(this.props.schema.title), renderDescription(this.props.schema.description), React.createElement(CodeEditor, this.props));
|
|
12
14
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import JSONSchemaField from "@rjsf/core/lib/components/fields/SchemaField";
|
|
2
1
|
import React from "react";
|
|
3
|
-
import {
|
|
2
|
+
import { getDefaultRegistry } from "@rjsf/core";
|
|
3
|
+
import { isEmpty } from "lodash-es";
|
|
4
|
+
import { hasValue, isFieldInvalid, isFieldRequired, getErrorText, } from "../validation-display";
|
|
4
5
|
import { resetDependentFields } from "./field-helpers";
|
|
5
6
|
import { FieldTemplate } from "../templates";
|
|
6
7
|
import { getHelpComponent } from "../help";
|
|
7
8
|
import { TimePicker } from "../widgets/time-picker";
|
|
9
|
+
import { RowLayoutContext } from "../row/row-context";
|
|
10
|
+
const { fields: defaultFields } = getDefaultRegistry();
|
|
11
|
+
const BaseSchemaField = defaultFields.SchemaField;
|
|
8
12
|
/**
|
|
9
13
|
* If given a value and schema, check if the value should be translated
|
|
10
14
|
* from null to undefined to avoid issues with validation
|
|
@@ -48,10 +52,6 @@ const hasCustomComponent = (schema) => {
|
|
|
48
52
|
return true;
|
|
49
53
|
};
|
|
50
54
|
const verifyCustomComponentIsDefined = (elementName) => {
|
|
51
|
-
const supportsCustomElements = 'customElements' in window;
|
|
52
|
-
if (!supportsCustomElements) {
|
|
53
|
-
throw new Error('Custom form elements are not supported by this browser!');
|
|
54
|
-
}
|
|
55
55
|
if (!customElements.get(elementName)) {
|
|
56
56
|
throw new Error(`Custom form element '${elementName}' is not defined!`);
|
|
57
57
|
}
|
|
@@ -90,51 +90,23 @@ export class SchemaField extends React.Component {
|
|
|
90
90
|
this.handleCustomComponentChange =
|
|
91
91
|
this.handleCustomComponentChange.bind(this);
|
|
92
92
|
}
|
|
93
|
-
hasValue() {
|
|
94
|
-
const value = this.getValue();
|
|
95
|
-
if (!value) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
if (Array.isArray(value)) {
|
|
99
|
-
return value.length > 0;
|
|
100
|
-
}
|
|
101
|
-
if (value instanceof Date) {
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
if (typeof value === 'object') {
|
|
105
|
-
return !isEmpty(value);
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
getLabel() {
|
|
110
|
-
const { schema } = this.props;
|
|
111
|
-
return schema.title;
|
|
112
|
-
}
|
|
113
93
|
isInvalid() {
|
|
114
94
|
const { modified } = this.state;
|
|
115
|
-
const { errorSchema } = this.props;
|
|
116
|
-
return (
|
|
117
|
-
!isEmpty(errorSchema)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
95
|
+
const { errorSchema, required, schema } = this.props;
|
|
96
|
+
return isFieldInvalid({
|
|
97
|
+
hasErrors: !isEmpty(errorSchema),
|
|
98
|
+
modified: modified,
|
|
99
|
+
hasValue: hasValue(this.props.formData),
|
|
100
|
+
required: isFieldRequired({ required, minItems: schema.minItems }),
|
|
101
|
+
});
|
|
122
102
|
}
|
|
123
103
|
getHelperText() {
|
|
124
104
|
var _a, _b, _c;
|
|
125
105
|
const { errorSchema, schema } = this.props;
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (!isEmpty(errorSchema) && '__errors' in errorSchema) {
|
|
131
|
-
return capitalize(errorSchema.__errors[0]);
|
|
132
|
-
}
|
|
133
|
-
return schema.description;
|
|
134
|
-
}
|
|
135
|
-
getValue() {
|
|
136
|
-
const { formData } = this.props;
|
|
137
|
-
return formData;
|
|
106
|
+
const hasErrors = !isEmpty(errorSchema) && '__errors' in errorSchema;
|
|
107
|
+
const errors = this.isInvalid() && hasErrors ? errorSchema.__errors : [];
|
|
108
|
+
const fallbackText = (_c = (_b = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.component) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.helperText;
|
|
109
|
+
return getErrorText(errors, schema.description, fallbackText);
|
|
138
110
|
}
|
|
139
111
|
handleCustomComponentChange(event) {
|
|
140
112
|
const { schema } = this.props;
|
|
@@ -143,35 +115,41 @@ export class SchemaField extends React.Component {
|
|
|
143
115
|
if (shouldChangeToUndefined(value, schema)) {
|
|
144
116
|
value = undefined;
|
|
145
117
|
}
|
|
146
|
-
this.handleChange(value);
|
|
118
|
+
this.handleChange(value, this.props.fieldPathId.path);
|
|
147
119
|
}
|
|
148
|
-
handleChange(data) {
|
|
120
|
+
handleChange(data, path) {
|
|
149
121
|
const { formData, schema } = this.props;
|
|
150
122
|
const { rootSchema } = this.props.registry;
|
|
151
123
|
this.setState({ modified: true });
|
|
152
124
|
const newData = resetDependentFields(formData, data, schema, rootSchema);
|
|
153
|
-
this.props.onChange(newData);
|
|
125
|
+
this.props.onChange(newData, path);
|
|
154
126
|
}
|
|
155
127
|
buildCustomComponentProps() {
|
|
156
|
-
const { disabled, readonly, name, registry, schema, errorSchema,
|
|
128
|
+
const { disabled, readonly, name, registry, schema: rawSchema, errorSchema, fieldPathId, } = this.props;
|
|
129
|
+
const schema = rawSchema;
|
|
157
130
|
const factoryProps = getFactoryProps(registry.formContext, schema);
|
|
158
|
-
return Object.assign(Object.assign({}, factoryProps), { value: this.
|
|
131
|
+
return Object.assign(Object.assign({}, factoryProps), { value: this.props.formData, required: isFieldRequired({
|
|
132
|
+
required: this.props.required,
|
|
133
|
+
minItems: schema.minItems,
|
|
134
|
+
}), readonly: readonly || schema.readOnly, disabled: disabled, invalid: this.isInvalid(), label: this.context ? '' : schema.title, helperText: this.context && !this.isInvalid() ? '' : this.getHelperText(), ref: (element) => {
|
|
135
|
+
var _a;
|
|
159
136
|
element.formInfo = {
|
|
160
137
|
schema: schema,
|
|
161
138
|
rootSchema: registry.formContext.schema,
|
|
162
139
|
errorSchema: errorSchema,
|
|
163
140
|
rootValue: registry.formContext.rootValue,
|
|
164
141
|
name: name,
|
|
165
|
-
schemaPath:
|
|
142
|
+
schemaPath: (_a = fieldPathId === null || fieldPathId === void 0 ? void 0 : fieldPathId.path) === null || _a === void 0 ? void 0 : _a.map(String),
|
|
166
143
|
};
|
|
167
144
|
return () => { };
|
|
168
145
|
} });
|
|
169
146
|
}
|
|
170
147
|
renderCustomComponent(props) {
|
|
171
|
-
const
|
|
148
|
+
const schema = props.schema;
|
|
149
|
+
const { name, props: userDefinedComponentProps } = getCustomComponent(schema);
|
|
172
150
|
verifyCustomComponentIsDefined(name);
|
|
173
151
|
const component = React.createElement(name, Object.assign(Object.assign(Object.assign({}, userDefinedComponentProps), this.buildCustomComponentProps()), { onChange: this.handleCustomComponentChange }));
|
|
174
|
-
return React.createElement(FieldTemplate, Object.assign(Object.assign({}, this.props), { classNames: '
|
|
152
|
+
return React.createElement(FieldTemplate, Object.assign(Object.assign({}, this.props), { classNames: 'rjsf-field rjsf-field-custom' }), component, getHelpComponent(schema));
|
|
175
153
|
}
|
|
176
154
|
render() {
|
|
177
155
|
var _a;
|
|
@@ -185,22 +163,7 @@ export class SchemaField extends React.Component {
|
|
|
185
163
|
if (this.props.schema.format === 'time') {
|
|
186
164
|
fieldProps.uiSchema = Object.assign({ 'ui:widget': TimePicker }, fieldProps.uiSchema);
|
|
187
165
|
}
|
|
188
|
-
return React.createElement(
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Gets the path to the current property within the schema
|
|
192
|
-
*
|
|
193
|
-
* @param schemaId - the id of the schema
|
|
194
|
-
* @returns an array with the schema path for the current property
|
|
195
|
-
* @example
|
|
196
|
-
* const schemaId = 'root_sections_0_controls_0_name';
|
|
197
|
-
* const schemaPath = getSchemaPath(schemaId);
|
|
198
|
-
* // ➡ ['sections', '0', 'controls', '0', 'name']
|
|
199
|
-
*/
|
|
200
|
-
getSchemaPath(schemaId) {
|
|
201
|
-
if (schemaId === undefined) {
|
|
202
|
-
return undefined;
|
|
203
|
-
}
|
|
204
|
-
return schemaId.replace('root_', '').split('_');
|
|
166
|
+
return React.createElement(BaseSchemaField, fieldProps);
|
|
205
167
|
}
|
|
206
168
|
}
|
|
169
|
+
SchemaField.contextType = RowLayoutContext;
|
|
@@ -124,10 +124,10 @@
|
|
|
124
124
|
.limel-form-row--layout .main-information {
|
|
125
125
|
position: relative;
|
|
126
126
|
}
|
|
127
|
-
.limel-form-row--layout .main-information > .
|
|
127
|
+
.limel-form-row--layout .main-information > .rjsf-field {
|
|
128
128
|
position: unset;
|
|
129
129
|
}
|
|
130
|
-
.limel-form-row--layout .main-information > .
|
|
130
|
+
.limel-form-row--layout .main-information > .rjsf-field limel-help {
|
|
131
131
|
top: 0;
|
|
132
132
|
}
|
|
133
133
|
.limel-form-row--layout limel-icon {
|
|
@@ -155,12 +155,12 @@
|
|
|
155
155
|
.limel-form-row--layout .has-icon .description {
|
|
156
156
|
padding-left: calc(var(--limel-form-row-icon-size) + var(--limel-form-row-main-information-gap));
|
|
157
157
|
}
|
|
158
|
-
.limel-form-row--layout .
|
|
158
|
+
.limel-form-row--layout .rjsf-field {
|
|
159
159
|
flex-shrink: 0;
|
|
160
160
|
display: flex;
|
|
161
161
|
align-content: center;
|
|
162
162
|
}
|
|
163
|
-
.limel-form-row--layout .
|
|
163
|
+
.limel-form-row--layout .rjsf-field limel-slider {
|
|
164
164
|
min-width: 8rem;
|
|
165
165
|
display: block;
|
|
166
166
|
}
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
box-sizing: border-box;
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
.
|
|
188
|
+
.rjsf-field {
|
|
189
189
|
min-width: 0;
|
|
190
190
|
}
|
|
191
191
|
|
|
@@ -368,26 +368,26 @@ limel-markdown {
|
|
|
368
368
|
margin-bottom: 0.5rem;
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
-
.
|
|
371
|
+
.rjsf-field {
|
|
372
372
|
position: relative;
|
|
373
373
|
}
|
|
374
|
-
.
|
|
374
|
+
.rjsf-field limel-help {
|
|
375
375
|
position: absolute;
|
|
376
376
|
top: calc(var(--form-row-gap, 1rem) * -0.5);
|
|
377
377
|
left: calc(var(--form-column-gap, 1rem) * -0.5);
|
|
378
378
|
}
|
|
379
|
-
.
|
|
379
|
+
.rjsf-field h1 {
|
|
380
380
|
color: rgb(var(--contrast-1400), 0.8);
|
|
381
381
|
}
|
|
382
|
-
.
|
|
382
|
+
.rjsf-field h1 {
|
|
383
383
|
--limel-form-h1-font-size: 1.476rem;
|
|
384
384
|
font-weight: 800;
|
|
385
385
|
}
|
|
386
|
-
.
|
|
386
|
+
.rjsf-field .rjsf-field h1 {
|
|
387
387
|
--limel-form-h1-font-size: 1.383rem;
|
|
388
388
|
font-weight: 700;
|
|
389
389
|
}
|
|
390
|
-
.
|
|
390
|
+
.rjsf-field .rjsf-field h1:before {
|
|
391
391
|
content: "";
|
|
392
392
|
display: block;
|
|
393
393
|
position: absolute;
|
|
@@ -401,28 +401,28 @@ limel-markdown {
|
|
|
401
401
|
border-radius: 0.125rem;
|
|
402
402
|
opacity: 0.6;
|
|
403
403
|
}
|
|
404
|
-
.
|
|
404
|
+
.rjsf-field .rjsf-field .rjsf-field h1 {
|
|
405
405
|
--limel-form-h1-font-size: 1.296rem;
|
|
406
406
|
font-weight: 600;
|
|
407
407
|
}
|
|
408
|
-
.
|
|
408
|
+
.rjsf-field .rjsf-field .rjsf-field h1:before {
|
|
409
409
|
display: none;
|
|
410
410
|
}
|
|
411
|
-
.
|
|
411
|
+
.rjsf-field .rjsf-field .rjsf-field .rjsf-field h1 {
|
|
412
412
|
--limel-form-h1-font-size: 1.215rem;
|
|
413
413
|
}
|
|
414
|
-
.
|
|
414
|
+
.rjsf-field .rjsf-field .rjsf-field .rjsf-field h1:before {
|
|
415
415
|
display: none;
|
|
416
416
|
}
|
|
417
|
-
.
|
|
417
|
+
.rjsf-field .rjsf-field .rjsf-field .rjsf-field .rjsf-field h1 {
|
|
418
418
|
--limel-form-h1-font-size: 1.138rem;
|
|
419
419
|
}
|
|
420
|
-
.
|
|
420
|
+
.rjsf-field .rjsf-field .rjsf-field .rjsf-field .rjsf-field h1:before {
|
|
421
421
|
display: none;
|
|
422
422
|
}
|
|
423
|
-
.
|
|
423
|
+
.rjsf-field .rjsf-field .rjsf-field .rjsf-field .rjsf-field .rjsf-field h1 {
|
|
424
424
|
--limel-form-h1-font-size: 1.067rem;
|
|
425
425
|
}
|
|
426
|
-
.
|
|
426
|
+
.rjsf-field .rjsf-field .rjsf-field .rjsf-field .rjsf-field .rjsf-field h1:before {
|
|
427
427
|
display: none;
|
|
428
428
|
}
|