@pareto-engineering/design-system 4.2.0 → 4.2.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/cjs/a/XMLEditor/XMLEditor.js +3 -15
- package/dist/cjs/f/fields/EditorInput/EditorInput.js +6 -21
- package/dist/cjs/f/fields/EditorInput/common/StopPropagationPlugin.js +2 -7
- package/dist/cjs/f/fields/SelectInput/common/Menu/Menu.js +1 -1
- package/dist/cjs/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
- package/dist/cjs/f/fields/SelectInput/styles.scss +1 -1
- package/dist/cjs/g/FormBuilder/FormBuilder.js +38 -5
- package/dist/cjs/g/FormBuilder/common/Builder/Builder.js +62 -25
- package/dist/cjs/g/FormBuilder/common/Builder/common/ActionsContainer/ActionsContainer.js +80 -0
- package/dist/cjs/g/FormBuilder/common/Builder/common/ActionsContainer/index.js +13 -0
- package/dist/cjs/g/FormBuilder/common/Builder/common/ActionsContainer/styles.scss +59 -0
- package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +19 -45
- package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +0 -49
- package/dist/cjs/g/FormBuilder/common/Builder/common/Section/Section.js +14 -3
- package/dist/cjs/g/FormBuilder/common/Builder/common/Section/styles.scss +61 -0
- package/dist/cjs/g/FormBuilder/common/Builder/common/index.js +8 -1
- package/dist/cjs/g/FormBuilder/common/Builder/styles.scss +5 -48
- package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +76 -33
- package/dist/cjs/g/FormBuilder/common/Renderer/common/Section/Section.js +8 -3
- package/dist/cjs/g/FormBuilder/common/Renderer/styles.scss +12 -1
- package/dist/es/a/XMLEditor/XMLEditor.js +3 -15
- package/dist/es/f/fields/EditorInput/EditorInput.js +7 -22
- package/dist/es/f/fields/EditorInput/common/StopPropagationPlugin.js +2 -6
- package/dist/es/f/fields/SelectInput/common/Menu/Menu.js +1 -1
- package/dist/es/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
- package/dist/es/f/fields/SelectInput/styles.scss +1 -1
- package/dist/es/g/FormBuilder/FormBuilder.js +38 -5
- package/dist/es/g/FormBuilder/common/Builder/Builder.js +56 -20
- package/dist/es/g/FormBuilder/common/Builder/common/ActionsContainer/ActionsContainer.js +70 -0
- package/dist/es/g/FormBuilder/common/Builder/common/ActionsContainer/index.js +2 -0
- package/dist/es/g/FormBuilder/common/Builder/common/ActionsContainer/styles.scss +59 -0
- package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +21 -47
- package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +0 -49
- package/dist/es/g/FormBuilder/common/Builder/common/Section/Section.js +14 -3
- package/dist/es/g/FormBuilder/common/Builder/common/Section/styles.scss +61 -0
- package/dist/es/g/FormBuilder/common/Builder/common/index.js +2 -1
- package/dist/es/g/FormBuilder/common/Builder/styles.scss +5 -48
- package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +76 -34
- package/dist/es/g/FormBuilder/common/Renderer/common/Section/Section.js +8 -3
- package/dist/es/g/FormBuilder/common/Renderer/styles.scss +12 -1
- package/package.json +4 -4
- package/src/stories/g/FormBuilder.stories.jsx +116 -21
- package/src/ui/a/XMLEditor/XMLEditor.jsx +1 -15
- package/src/ui/f/fields/EditorInput/EditorInput.jsx +7 -23
- package/src/ui/f/fields/EditorInput/common/StopPropagationPlugin.jsx +2 -6
- package/src/ui/f/fields/SelectInput/common/Menu/Menu.jsx +1 -0
- package/src/ui/f/fields/SelectInput/common/Multiple/Multiple.jsx +1 -1
- package/src/ui/f/fields/SelectInput/styles.scss +1 -1
- package/src/ui/g/FormBuilder/FormBuilder.jsx +50 -3
- package/src/ui/g/FormBuilder/common/Builder/Builder.jsx +56 -18
- package/src/ui/g/FormBuilder/common/Builder/common/ActionsContainer/ActionsContainer.jsx +97 -0
- package/src/ui/g/FormBuilder/common/Builder/common/ActionsContainer/index.js +2 -0
- package/src/ui/g/FormBuilder/common/Builder/common/ActionsContainer/styles.scss +59 -0
- package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +40 -60
- package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +0 -49
- package/src/ui/g/FormBuilder/common/Builder/common/Section/Section.jsx +26 -4
- package/src/ui/g/FormBuilder/common/Builder/common/Section/styles.scss +61 -0
- package/src/ui/g/FormBuilder/common/Builder/common/index.js +1 -0
- package/src/ui/g/FormBuilder/common/Builder/styles.scss +5 -48
- package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +84 -33
- package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +3 -2
- package/src/ui/g/FormBuilder/common/Renderer/styles.scss +12 -1
- package/tests/__snapshots__/Storyshots.test.js.snap +395 -133
|
@@ -54,55 +54,6 @@ $default-list-width: var(--action-button-width, 18rem);
|
|
|
54
54
|
font-size: calc(var(--s1) * 1rem);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
> .actions {
|
|
59
|
-
position: relative;
|
|
60
|
-
|
|
61
|
-
> button {
|
|
62
|
-
background-color: transparent;
|
|
63
|
-
border: 0;
|
|
64
|
-
cursor: pointer;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
> .#{bem.$base}.popover {
|
|
68
|
-
background-color: var(--background-cards);
|
|
69
|
-
border: var(--theme-default-border-style) var(--main2);
|
|
70
|
-
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
71
|
-
cursor: default;
|
|
72
|
-
padding: $default-padding;
|
|
73
|
-
width: $default-list-width;
|
|
74
|
-
|
|
75
|
-
> p {
|
|
76
|
-
margin: 0;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
> ul {
|
|
80
|
-
list-style: none;
|
|
81
|
-
margin: 0;
|
|
82
|
-
padding: 0;
|
|
83
|
-
white-space: nowrap;
|
|
84
|
-
|
|
85
|
-
> .option {
|
|
86
|
-
cursor: pointer;
|
|
87
|
-
padding-block: calc($default-padding / 4);
|
|
88
|
-
|
|
89
|
-
&:not(.with-check-mark) {
|
|
90
|
-
padding-inline: $default-padding;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
> button {
|
|
94
|
-
background: transparent;
|
|
95
|
-
border: 0;
|
|
96
|
-
color: var(--paragraph);
|
|
97
|
-
cursor: pointer;
|
|
98
|
-
font-size: calc(var(--s0) * .875rem);
|
|
99
|
-
text-align: left;
|
|
100
|
-
width: 100%;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
57
|
}
|
|
107
58
|
}
|
|
108
59
|
|
|
@@ -12,6 +12,8 @@ var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports")
|
|
|
12
12
|
var _f = require("../../../../../../f");
|
|
13
13
|
var _ = require("../../../../..");
|
|
14
14
|
var _InputBuilder = require("../InputBuilder");
|
|
15
|
+
var _ActionsContainer = require("../ActionsContainer");
|
|
16
|
+
require("./styles.scss");
|
|
15
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -20,7 +22,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
20
22
|
// Local Definitions
|
|
21
23
|
|
|
22
24
|
const baseClassName = _exports.default.base;
|
|
23
|
-
const componentClassName = 'section';
|
|
25
|
+
const componentClassName = 'builder-section';
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
28
|
* This is the component description.
|
|
@@ -30,7 +32,8 @@ const Section = _ref => {
|
|
|
30
32
|
id,
|
|
31
33
|
className: userClassName,
|
|
32
34
|
style,
|
|
33
|
-
index
|
|
35
|
+
index,
|
|
36
|
+
handleDeleteSection
|
|
34
37
|
// ...otherProps
|
|
35
38
|
} = _ref;
|
|
36
39
|
const {
|
|
@@ -72,9 +75,17 @@ const Section = _ref => {
|
|
|
72
75
|
id: id,
|
|
73
76
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
74
77
|
style: style
|
|
78
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: "section-header"
|
|
75
80
|
}, /*#__PURE__*/React.createElement("p", {
|
|
76
81
|
className: "h4"
|
|
77
|
-
}, index === 0 ? 'Form title' : `Section ${index + 1}`), /*#__PURE__*/React.createElement(
|
|
82
|
+
}, index === 0 ? 'Form title' : `Section ${index + 1}`), index !== 0 && /*#__PURE__*/React.createElement(_ActionsContainer.ActionsContainer, null, /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
|
|
83
|
+
className: "option"
|
|
84
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
85
|
+
type: "button",
|
|
86
|
+
className: "remove-section-cta",
|
|
87
|
+
onClick: handleDeleteSection
|
|
88
|
+
}, "Delete Section"))))), /*#__PURE__*/React.createElement(_f.TextInput, {
|
|
78
89
|
name: `sections.${index}.title`,
|
|
79
90
|
placeholder: `Title of the ${index === 0 ? 'form' : 'section'}`
|
|
80
91
|
}), /*#__PURE__*/React.createElement(_f.EditorInput, {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.2 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-margin: 1rem;
|
|
6
|
+
|
|
7
|
+
.#{bem.$base}.builder-section {
|
|
8
|
+
border-bottom: var(--theme-default-border-style) var(--on-background-inputs);
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
> .section-header {
|
|
12
|
+
align-items: center;
|
|
13
|
+
display: flex;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
> .#{bem.$base}.editor-input {
|
|
18
|
+
margin-top: $default-margin;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
> form {
|
|
22
|
+
/* stylelint-disable selector-max-compound-selectors -- required */
|
|
23
|
+
> .add-question-cta {
|
|
24
|
+
align-items: center;
|
|
25
|
+
background-color: transparent;
|
|
26
|
+
border: 0;
|
|
27
|
+
color: var(--hard-interactive);
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
display: flex;
|
|
30
|
+
gap: var(--gap);
|
|
31
|
+
margin-block: calc($default-margin * 1.5);
|
|
32
|
+
margin-left: auto;
|
|
33
|
+
padding: 0;
|
|
34
|
+
transition: all .2s;
|
|
35
|
+
|
|
36
|
+
&:hover {
|
|
37
|
+
color: var(--interactive);
|
|
38
|
+
|
|
39
|
+
> .icon-container {
|
|
40
|
+
background-color: var(--interactive);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
> .icon-container {
|
|
45
|
+
align-items: center;
|
|
46
|
+
background-color: var(--hard-interactive);
|
|
47
|
+
border-radius: 50%;
|
|
48
|
+
display: flex;
|
|
49
|
+
height: 1.6rem;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
width: 1.6rem;
|
|
52
|
+
|
|
53
|
+
> .icon {
|
|
54
|
+
color: var(--on-interactive);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "ActionsContainer", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ActionsContainer.ActionsContainer;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "InputBuilder", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
@@ -16,4 +22,5 @@ Object.defineProperty(exports, "Section", {
|
|
|
16
22
|
}
|
|
17
23
|
});
|
|
18
24
|
var _Section = require("./Section");
|
|
19
|
-
var _InputBuilder = require("./InputBuilder");
|
|
25
|
+
var _InputBuilder = require("./InputBuilder");
|
|
26
|
+
var _ActionsContainer = require("./ActionsContainer");
|
|
@@ -49,56 +49,13 @@ $default-margin: 1rem;
|
|
|
49
49
|
flex: .4;
|
|
50
50
|
gap: var(--gap);
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
/* stylelint-disable-next-line selector-max-compound-selectors -- required */
|
|
53
|
+
> span {
|
|
54
|
+
white-space: nowrap;
|
|
54
55
|
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
> .#{bem.$base}.section {
|
|
58
|
-
border-bottom: var(--theme-default-border-style) var(--on-background-inputs);
|
|
59
|
-
|
|
60
|
-
> .#{bem.$base}.editor-input {
|
|
61
|
-
margin-top: $default-margin;
|
|
62
|
-
}
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
> .add-question-cta {
|
|
67
|
-
align-items: center;
|
|
68
|
-
background-color: transparent;
|
|
69
|
-
border: 0;
|
|
70
|
-
color: var(--hard-interactive);
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
display: flex;
|
|
73
|
-
gap: var(--gap);
|
|
74
|
-
margin-block: calc($default-margin * 1.5);
|
|
75
|
-
margin-left: auto;
|
|
76
|
-
padding: 0;
|
|
77
|
-
transition: all .2s;
|
|
78
|
-
|
|
79
|
-
/* stylelint-disable-next-line max-nesting-depth -- required */
|
|
80
|
-
&:hover {
|
|
81
|
-
color: var(--interactive);
|
|
82
|
-
|
|
83
|
-
/* stylelint-disable max-nesting-depth -- required */
|
|
84
|
-
> .icon-container {
|
|
85
|
-
background-color: var(--interactive);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
> .icon-container {
|
|
90
|
-
align-items: center;
|
|
91
|
-
background-color: var(--hard-interactive);
|
|
92
|
-
border-radius: 50%;
|
|
93
|
-
display: flex;
|
|
94
|
-
height: 1.6rem;
|
|
95
|
-
justify-content: center;
|
|
96
|
-
width: 1.6rem;
|
|
97
|
-
|
|
98
|
-
> .icon {
|
|
99
|
-
color: var(--on-interactive);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
57
|
+
> .#{bem.$base}.select-input {
|
|
58
|
+
flex: auto;
|
|
102
59
|
}
|
|
103
60
|
}
|
|
104
61
|
}
|
|
@@ -18,6 +18,27 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
18
18
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /* @pareto-engineering/generator-front 1.1.1-alpha.2 */ // Local Definitions
|
|
19
19
|
const baseClassName = _exports.default.base;
|
|
20
20
|
const componentClassName = 'renderer';
|
|
21
|
+
const reconstructFormDataWithValues = (formData, values) => {
|
|
22
|
+
const newData = {
|
|
23
|
+
...formData
|
|
24
|
+
};
|
|
25
|
+
Object.keys(values).forEach(key => {
|
|
26
|
+
const [sectionIdx, inputIdx] = key.match(/\d+/g).map(Number);
|
|
27
|
+
newData.sections[sectionIdx].inputs[inputIdx].value = values[key];
|
|
28
|
+
});
|
|
29
|
+
return newData;
|
|
30
|
+
};
|
|
31
|
+
const validate = values => {
|
|
32
|
+
const errors = {};
|
|
33
|
+
const hasAtLeastOneValue = Object.keys(values).some(valueKey => {
|
|
34
|
+
const inputValue = values[valueKey];
|
|
35
|
+
return inputValue && inputValue !== '';
|
|
36
|
+
});
|
|
37
|
+
if (!hasAtLeastOneValue) {
|
|
38
|
+
errors.message = 'At least one input must have a value';
|
|
39
|
+
}
|
|
40
|
+
return errors;
|
|
41
|
+
};
|
|
21
42
|
|
|
22
43
|
/**
|
|
23
44
|
* This is the component description.
|
|
@@ -28,28 +49,36 @@ const Renderer = _ref => {
|
|
|
28
49
|
className: userClassName,
|
|
29
50
|
style,
|
|
30
51
|
formData,
|
|
31
|
-
|
|
52
|
+
readOnly,
|
|
53
|
+
onSave,
|
|
54
|
+
onError,
|
|
55
|
+
shouldSubmit
|
|
32
56
|
// ...otherProps
|
|
33
57
|
} = _ref;
|
|
34
58
|
const [currentSectionIndex, setCurrentSectionIndex] = (0, _react.useState)(0);
|
|
35
59
|
const [sectionHistory, setSectionHistory] = (0, _react.useState)([]);
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
60
|
+
const [updatedFormData, setUpdatedFormData] = (0, _react.useState)(formData);
|
|
61
|
+
(0, _react.useEffect)(() => {
|
|
62
|
+
setUpdatedFormData(formData);
|
|
63
|
+
}, [formData]);
|
|
64
|
+
const initialValues = formData.sections.reduce((acc, section, sectionIndex) => {
|
|
65
|
+
section.inputs.forEach((input, inputIndex) => {
|
|
66
|
+
const inputName = `section_${sectionIndex}_input_${inputIndex}`;
|
|
67
|
+
acc[inputName] = input.value || '';
|
|
39
68
|
});
|
|
40
69
|
return acc;
|
|
41
70
|
}, {});
|
|
42
71
|
const handleSubmit = values => {
|
|
43
|
-
const currentSection =
|
|
72
|
+
const currentSection = updatedFormData.sections[currentSectionIndex];
|
|
44
73
|
// by default, 'next' section is the immediate section after the current one
|
|
45
74
|
let nextSectionIndex = currentSectionIndex + 1;
|
|
46
75
|
|
|
47
76
|
// Any other value is either submit or an index to a section
|
|
48
77
|
if (currentSection.navigation.nextSection !== 'next') {
|
|
49
|
-
nextSectionIndex = currentSection.navigation.nextSection === 'submit' ?
|
|
78
|
+
nextSectionIndex = currentSection.navigation.nextSection === 'submit' ? updatedFormData.sections.length // submit
|
|
50
79
|
: parseInt(currentSection.navigation.nextSection, 10); // go to specific section
|
|
51
80
|
}
|
|
52
|
-
if (nextSectionIndex >=
|
|
81
|
+
if (nextSectionIndex >= updatedFormData.sections.length) {
|
|
53
82
|
// submit
|
|
54
83
|
onSave(values);
|
|
55
84
|
} else {
|
|
@@ -68,28 +97,50 @@ const Renderer = _ref => {
|
|
|
68
97
|
setSectionHistory([...sectionHistory]);
|
|
69
98
|
}
|
|
70
99
|
};
|
|
100
|
+
const isSubmit = currentSectionIndex === updatedFormData.sections.length - 1 || updatedFormData.sections[currentSectionIndex].navigation.nextSection === 'submit';
|
|
71
101
|
return /*#__PURE__*/React.createElement("div", {
|
|
72
102
|
id: id,
|
|
73
103
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
74
104
|
style: style
|
|
75
105
|
}, /*#__PURE__*/React.createElement(_formik.Formik, {
|
|
76
106
|
initialValues: initialValues,
|
|
77
|
-
onSubmit: handleSubmit
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
107
|
+
onSubmit: handleSubmit,
|
|
108
|
+
validate: validate
|
|
109
|
+
}, _ref2 => {
|
|
110
|
+
let {
|
|
111
|
+
values,
|
|
112
|
+
errors
|
|
113
|
+
} = _ref2;
|
|
114
|
+
(0, _react.useEffect)(() => {
|
|
115
|
+
const formDataWithValues = reconstructFormDataWithValues(updatedFormData, values);
|
|
116
|
+
setUpdatedFormData(formDataWithValues);
|
|
117
|
+
onSave?.(formDataWithValues);
|
|
118
|
+
}, [values]);
|
|
119
|
+
(0, _react.useEffect)(() => {
|
|
120
|
+
onError?.({
|
|
121
|
+
errors,
|
|
122
|
+
values
|
|
123
|
+
});
|
|
124
|
+
}, [errors, values]);
|
|
125
|
+
return /*#__PURE__*/React.createElement(_formik.Form, null, updatedFormData.sections.map((section, sectionIndex) => sectionIndex === currentSectionIndex && /*#__PURE__*/React.createElement(_common.Section, _extends({
|
|
126
|
+
key: `${section.title}`
|
|
127
|
+
}, section, {
|
|
128
|
+
readOnly: readOnly
|
|
129
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
130
|
+
className: "navigator-container"
|
|
131
|
+
}, /*#__PURE__*/React.createElement(_b.Button, {
|
|
132
|
+
color: "interactive",
|
|
133
|
+
isGradient: true,
|
|
134
|
+
isCompact: true,
|
|
135
|
+
isGhost: true,
|
|
136
|
+
onClick: handlePrevious,
|
|
137
|
+
disabled: sectionHistory.length === 0
|
|
138
|
+
}, "Previous"), (!isSubmit || shouldSubmit) && /*#__PURE__*/React.createElement(_b.Button, {
|
|
139
|
+
color: "interactive",
|
|
140
|
+
isGradient: true,
|
|
141
|
+
type: "submit"
|
|
142
|
+
}, isSubmit ? 'Submit' : 'Next')));
|
|
143
|
+
}));
|
|
93
144
|
};
|
|
94
145
|
Renderer.propTypes = {
|
|
95
146
|
/**
|
|
@@ -103,17 +154,9 @@ Renderer.propTypes = {
|
|
|
103
154
|
/**
|
|
104
155
|
* The React-written, css properties for this element.
|
|
105
156
|
*/
|
|
106
|
-
style: _propTypes.default.objectOf(_propTypes.default.string)
|
|
107
|
-
/**
|
|
108
|
-
* The children JSX
|
|
109
|
-
*/
|
|
110
|
-
formData: _propTypes.default.shape({
|
|
111
|
-
formTitle: _propTypes.default.string.isRequired,
|
|
112
|
-
formDescription: _propTypes.default.string.isRequired,
|
|
113
|
-
sections: _propTypes.default.arrayOf(_propTypes.default.objectOf(_propTypes.default.any))
|
|
114
|
-
})
|
|
157
|
+
style: _propTypes.default.objectOf(_propTypes.default.string)
|
|
115
158
|
};
|
|
116
159
|
Renderer.defaultProps = {
|
|
117
|
-
// someProp:false
|
|
160
|
+
// someProp: false,
|
|
118
161
|
};
|
|
119
162
|
var _default = exports.default = Renderer;
|
|
@@ -26,19 +26,24 @@ const Section = _ref => {
|
|
|
26
26
|
style,
|
|
27
27
|
title,
|
|
28
28
|
description,
|
|
29
|
-
inputs
|
|
29
|
+
inputs,
|
|
30
|
+
readOnly
|
|
30
31
|
// ...otherProps
|
|
31
32
|
} = _ref;
|
|
32
33
|
return /*#__PURE__*/React.createElement("div", {
|
|
33
34
|
id: id,
|
|
34
35
|
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
35
36
|
style: style
|
|
36
|
-
}, /*#__PURE__*/React.createElement("
|
|
37
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
38
|
+
className: "h3"
|
|
39
|
+
}, title), /*#__PURE__*/React.createElement(_.ExpandableLexicalPreview, {
|
|
37
40
|
nodes: description,
|
|
38
41
|
name: "instructions"
|
|
39
42
|
}), inputs.map(input => /*#__PURE__*/React.createElement(_f.FormInput, _extends({
|
|
40
43
|
key: input.name
|
|
41
|
-
}, input
|
|
44
|
+
}, input, {
|
|
45
|
+
disabled: readOnly
|
|
46
|
+
}))));
|
|
42
47
|
};
|
|
43
48
|
Section.propTypes = {
|
|
44
49
|
/**
|
|
@@ -6,10 +6,21 @@ $default-margin: 1rem;
|
|
|
6
6
|
|
|
7
7
|
.#{bem.$base}.renderer {
|
|
8
8
|
> form {
|
|
9
|
+
> .#{bem.$base}.section {
|
|
10
|
+
margin-bottom: calc($default-margin * 2);
|
|
11
|
+
|
|
12
|
+
> p {
|
|
13
|
+
margin: 0;
|
|
14
|
+
}
|
|
15
|
+
> .#{bem.$base}.expandable-lexical-preview {
|
|
16
|
+
margin-bottom: $default-margin;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
> .navigator-container {
|
|
10
21
|
display: flex;
|
|
11
22
|
gap: var(--gap);
|
|
12
|
-
|
|
23
|
+
justify-content: space-between;
|
|
13
24
|
}
|
|
14
25
|
}
|
|
15
26
|
}
|
|
@@ -27,9 +27,7 @@ const XMLEditor = ({
|
|
|
27
27
|
gutterWidth,
|
|
28
28
|
config,
|
|
29
29
|
onChange,
|
|
30
|
-
onBlur
|
|
31
|
-
stopAllPropagation,
|
|
32
|
-
stopPropagationKeys
|
|
30
|
+
onBlur
|
|
33
31
|
}) => {
|
|
34
32
|
const editorRef = useRef();
|
|
35
33
|
useEffect(() => {
|
|
@@ -44,9 +42,7 @@ const XMLEditor = ({
|
|
|
44
42
|
}
|
|
45
43
|
}), EditorView.domEventHandlers({
|
|
46
44
|
keydown(e) {
|
|
47
|
-
|
|
48
|
-
e.stopPropagation();
|
|
49
|
-
}
|
|
45
|
+
e.stopPropagation();
|
|
50
46
|
}
|
|
51
47
|
})]
|
|
52
48
|
});
|
|
@@ -102,18 +98,10 @@ XMLEditor.propTypes = {
|
|
|
102
98
|
* The width of the gutter.
|
|
103
99
|
*/
|
|
104
100
|
gutterWidth: PropTypes.string,
|
|
105
|
-
/**
|
|
106
|
-
* The keys to stop propagation on.
|
|
107
|
-
*/
|
|
108
|
-
stopPropagationKeys: PropTypes.arrayOf(PropTypes.string),
|
|
109
101
|
/**
|
|
110
102
|
* The callback for when the editor loses focus.
|
|
111
103
|
*/
|
|
112
|
-
onBlur: PropTypes.func
|
|
113
|
-
/**
|
|
114
|
-
* Whether to stop all propagation of keys to keep focus on the editor.
|
|
115
|
-
*/
|
|
116
|
-
stopAllPropagation: PropTypes.bool
|
|
104
|
+
onBlur: PropTypes.func
|
|
117
105
|
};
|
|
118
106
|
XMLEditor.defaultProps = {
|
|
119
107
|
config: `<View>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable import/no-extraneous-dependencies -- required here */
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { memo, useEffect } from 'react';
|
|
5
|
-
import { useFormikContext } from 'formik';
|
|
5
|
+
import { useField, useFormikContext } from 'formik';
|
|
6
6
|
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
7
7
|
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
8
8
|
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
@@ -48,7 +48,6 @@ const EditorInput = ({
|
|
|
48
48
|
style,
|
|
49
49
|
name,
|
|
50
50
|
label,
|
|
51
|
-
// validate,
|
|
52
51
|
resize,
|
|
53
52
|
color,
|
|
54
53
|
rows,
|
|
@@ -57,20 +56,17 @@ const EditorInput = ({
|
|
|
57
56
|
description,
|
|
58
57
|
disabled,
|
|
59
58
|
showDebugger,
|
|
60
|
-
stopPropagationKeys,
|
|
61
59
|
setEditorState
|
|
62
|
-
// handleOnChange,
|
|
63
60
|
// ...otherProps
|
|
64
61
|
}) => {
|
|
62
|
+
const [field,,] = useField(name);
|
|
65
63
|
const {
|
|
66
|
-
values,
|
|
67
64
|
setFieldValue
|
|
68
65
|
} = useFormikContext();
|
|
69
66
|
const setInitialValue = () => {
|
|
70
|
-
const value = values[name];
|
|
71
67
|
try {
|
|
72
|
-
JSON.parse(value);
|
|
73
|
-
return value;
|
|
68
|
+
JSON.parse(field.value);
|
|
69
|
+
return field.value;
|
|
74
70
|
} catch {
|
|
75
71
|
const defaultValue = {
|
|
76
72
|
root: {
|
|
@@ -97,7 +93,7 @@ const EditorInput = ({
|
|
|
97
93
|
version: 1
|
|
98
94
|
}
|
|
99
95
|
};
|
|
100
|
-
defaultValue.root.children[0].children[0].text = value;
|
|
96
|
+
defaultValue.root.children[0].children[0].text = field.value;
|
|
101
97
|
return JSON.stringify(defaultValue);
|
|
102
98
|
}
|
|
103
99
|
};
|
|
@@ -147,9 +143,7 @@ const EditorInput = ({
|
|
|
147
143
|
onChange: onChange
|
|
148
144
|
}), /*#__PURE__*/React.createElement(LinkPlugin, null), /*#__PURE__*/React.createElement(LexicalClickableLinkPlugin, null), /*#__PURE__*/React.createElement(TabIndentationPlugin, null), setEditorState && /*#__PURE__*/React.createElement(ExposeEditorStatePlugin, {
|
|
149
145
|
setEditorState: setEditorState
|
|
150
|
-
}), /*#__PURE__*/React.createElement(HistoryPlugin, null),
|
|
151
|
-
stopPropagationKeys: stopPropagationKeys
|
|
152
|
-
}), /*#__PURE__*/React.createElement(FormDescription, {
|
|
146
|
+
}), /*#__PURE__*/React.createElement(HistoryPlugin, null), /*#__PURE__*/React.createElement(StopPropagationPlugin, null), /*#__PURE__*/React.createElement(FormDescription, {
|
|
153
147
|
className: "s-1",
|
|
154
148
|
description: description,
|
|
155
149
|
name: name
|
|
@@ -176,11 +170,6 @@ EditorInput.propTypes = {
|
|
|
176
170
|
* The input label
|
|
177
171
|
*/
|
|
178
172
|
label: PropTypes.string.isRequired,
|
|
179
|
-
/**
|
|
180
|
-
* The input value validator function
|
|
181
|
-
*/
|
|
182
|
-
// validate:PropTypes.func,
|
|
183
|
-
|
|
184
173
|
/**
|
|
185
174
|
* The number of rows int the text area
|
|
186
175
|
*/
|
|
@@ -212,11 +201,7 @@ EditorInput.propTypes = {
|
|
|
212
201
|
/**
|
|
213
202
|
* Whether to show the debugger or not
|
|
214
203
|
*/
|
|
215
|
-
showDebugger: PropTypes.bool
|
|
216
|
-
/**
|
|
217
|
-
* Map to stop propagation of the given keys
|
|
218
|
-
*/
|
|
219
|
-
stopPropagationKeys: PropTypes.arrayOf(PropTypes.string)
|
|
204
|
+
showDebugger: PropTypes.bool
|
|
220
205
|
};
|
|
221
206
|
EditorInput.defaultProps = {
|
|
222
207
|
rows: 10,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { useInsertionEffect } from 'react';
|
|
2
2
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
-
const StopPropagationPlugin = ({
|
|
4
|
-
stopPropagationKeys
|
|
5
|
-
}) => {
|
|
3
|
+
const StopPropagationPlugin = () => {
|
|
6
4
|
const [editor] = useLexicalComposerContext();
|
|
7
5
|
useInsertionEffect(() => {
|
|
8
6
|
const onKeyDown = e => {
|
|
9
|
-
|
|
10
|
-
e.stopPropagation();
|
|
11
|
-
}
|
|
7
|
+
e.stopPropagation();
|
|
12
8
|
};
|
|
13
9
|
return editor.registerRootListener((rootElement, prevRootElement) => {
|
|
14
10
|
if (prevRootElement !== null) {
|
|
@@ -32,7 +32,7 @@ const Menu = /*#__PURE__*/React.forwardRef(({
|
|
|
32
32
|
item,
|
|
33
33
|
index
|
|
34
34
|
}), {
|
|
35
|
-
className: ['item', highlightedIndex === index && styleNames.modifierActive].filter(Boolean).join(' ')
|
|
35
|
+
className: ['item', item.disabled && styleNames.modifierDisabled, highlightedIndex === index && styleNames.modifierActive].filter(Boolean).join(' ')
|
|
36
36
|
}), /*#__PURE__*/React.createElement("p", null, item.label)))));
|
|
37
37
|
Menu.propTypes = {
|
|
38
38
|
/**
|
|
@@ -127,7 +127,7 @@ const Multiple = ({
|
|
|
127
127
|
case useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
128
128
|
case useCombobox.stateChangeTypes.ItemClick:
|
|
129
129
|
case useCombobox.stateChangeTypes.InputBlur:
|
|
130
|
-
if (selectedItem) {
|
|
130
|
+
if (selectedItem && !selectedItem?.disabled) {
|
|
131
131
|
setSearchInputValue('');
|
|
132
132
|
addSelectedItem(selectedItem);
|
|
133
133
|
}
|