@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
|
@@ -38,9 +38,7 @@ const XMLEditor = _ref => {
|
|
|
38
38
|
gutterWidth,
|
|
39
39
|
config,
|
|
40
40
|
onChange,
|
|
41
|
-
onBlur
|
|
42
|
-
stopAllPropagation,
|
|
43
|
-
stopPropagationKeys
|
|
41
|
+
onBlur
|
|
44
42
|
} = _ref;
|
|
45
43
|
const editorRef = (0, _react.useRef)();
|
|
46
44
|
(0, _react.useEffect)(() => {
|
|
@@ -55,9 +53,7 @@ const XMLEditor = _ref => {
|
|
|
55
53
|
}
|
|
56
54
|
}), _view.EditorView.domEventHandlers({
|
|
57
55
|
keydown(e) {
|
|
58
|
-
|
|
59
|
-
e.stopPropagation();
|
|
60
|
-
}
|
|
56
|
+
e.stopPropagation();
|
|
61
57
|
}
|
|
62
58
|
})]
|
|
63
59
|
});
|
|
@@ -113,18 +109,10 @@ XMLEditor.propTypes = {
|
|
|
113
109
|
* The width of the gutter.
|
|
114
110
|
*/
|
|
115
111
|
gutterWidth: _propTypes.default.string,
|
|
116
|
-
/**
|
|
117
|
-
* The keys to stop propagation on.
|
|
118
|
-
*/
|
|
119
|
-
stopPropagationKeys: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
120
112
|
/**
|
|
121
113
|
* The callback for when the editor loses focus.
|
|
122
114
|
*/
|
|
123
|
-
onBlur: _propTypes.default.func
|
|
124
|
-
/**
|
|
125
|
-
* Whether to stop all propagation of keys to keep focus on the editor.
|
|
126
|
-
*/
|
|
127
|
-
stopAllPropagation: _propTypes.default.bool
|
|
115
|
+
onBlur: _propTypes.default.func
|
|
128
116
|
};
|
|
129
117
|
XMLEditor.defaultProps = {
|
|
130
118
|
config: `<View>
|
|
@@ -59,7 +59,6 @@ const EditorInput = _ref2 => {
|
|
|
59
59
|
style,
|
|
60
60
|
name,
|
|
61
61
|
label,
|
|
62
|
-
// validate,
|
|
63
62
|
resize,
|
|
64
63
|
color,
|
|
65
64
|
rows,
|
|
@@ -68,20 +67,17 @@ const EditorInput = _ref2 => {
|
|
|
68
67
|
description,
|
|
69
68
|
disabled,
|
|
70
69
|
showDebugger,
|
|
71
|
-
stopPropagationKeys,
|
|
72
70
|
setEditorState
|
|
73
|
-
// handleOnChange,
|
|
74
71
|
// ...otherProps
|
|
75
72
|
} = _ref2;
|
|
73
|
+
const [field,,] = (0, _formik.useField)(name);
|
|
76
74
|
const {
|
|
77
|
-
values,
|
|
78
75
|
setFieldValue
|
|
79
76
|
} = (0, _formik.useFormikContext)();
|
|
80
77
|
const setInitialValue = () => {
|
|
81
|
-
const value = values[name];
|
|
82
78
|
try {
|
|
83
|
-
JSON.parse(value);
|
|
84
|
-
return value;
|
|
79
|
+
JSON.parse(field.value);
|
|
80
|
+
return field.value;
|
|
85
81
|
} catch {
|
|
86
82
|
const defaultValue = {
|
|
87
83
|
root: {
|
|
@@ -108,7 +104,7 @@ const EditorInput = _ref2 => {
|
|
|
108
104
|
version: 1
|
|
109
105
|
}
|
|
110
106
|
};
|
|
111
|
-
defaultValue.root.children[0].children[0].text = value;
|
|
107
|
+
defaultValue.root.children[0].children[0].text = field.value;
|
|
112
108
|
return JSON.stringify(defaultValue);
|
|
113
109
|
}
|
|
114
110
|
};
|
|
@@ -158,9 +154,7 @@ const EditorInput = _ref2 => {
|
|
|
158
154
|
onChange: onChange
|
|
159
155
|
}), /*#__PURE__*/React.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/React.createElement(_LexicalClickableLinkPlugin.default, null), /*#__PURE__*/React.createElement(_LexicalTabIndentationPlugin.TabIndentationPlugin, null), setEditorState && /*#__PURE__*/React.createElement(ExposeEditorStatePlugin, {
|
|
160
156
|
setEditorState: setEditorState
|
|
161
|
-
}), /*#__PURE__*/React.createElement(_LexicalHistoryPlugin.HistoryPlugin, null),
|
|
162
|
-
stopPropagationKeys: stopPropagationKeys
|
|
163
|
-
}), /*#__PURE__*/React.createElement(_common.FormDescription, {
|
|
157
|
+
}), /*#__PURE__*/React.createElement(_LexicalHistoryPlugin.HistoryPlugin, null), /*#__PURE__*/React.createElement(_common2.StopPropagationPlugin, null), /*#__PURE__*/React.createElement(_common.FormDescription, {
|
|
164
158
|
className: "s-1",
|
|
165
159
|
description: description,
|
|
166
160
|
name: name
|
|
@@ -187,11 +181,6 @@ EditorInput.propTypes = {
|
|
|
187
181
|
* The input label
|
|
188
182
|
*/
|
|
189
183
|
label: _propTypes.default.string.isRequired,
|
|
190
|
-
/**
|
|
191
|
-
* The input value validator function
|
|
192
|
-
*/
|
|
193
|
-
// validate:PropTypes.func,
|
|
194
|
-
|
|
195
184
|
/**
|
|
196
185
|
* The number of rows int the text area
|
|
197
186
|
*/
|
|
@@ -223,11 +212,7 @@ EditorInput.propTypes = {
|
|
|
223
212
|
/**
|
|
224
213
|
* Whether to show the debugger or not
|
|
225
214
|
*/
|
|
226
|
-
showDebugger: _propTypes.default.bool
|
|
227
|
-
/**
|
|
228
|
-
* Map to stop propagation of the given keys
|
|
229
|
-
*/
|
|
230
|
-
stopPropagationKeys: _propTypes.default.arrayOf(_propTypes.default.string)
|
|
215
|
+
showDebugger: _propTypes.default.bool
|
|
231
216
|
};
|
|
232
217
|
EditorInput.defaultProps = {
|
|
233
218
|
rows: 10,
|
|
@@ -6,16 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
|
|
9
|
-
const StopPropagationPlugin =
|
|
10
|
-
let {
|
|
11
|
-
stopPropagationKeys
|
|
12
|
-
} = _ref;
|
|
9
|
+
const StopPropagationPlugin = () => {
|
|
13
10
|
const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
|
|
14
11
|
(0, _react.useInsertionEffect)(() => {
|
|
15
12
|
const onKeyDown = e => {
|
|
16
|
-
|
|
17
|
-
e.stopPropagation();
|
|
18
|
-
}
|
|
13
|
+
e.stopPropagation();
|
|
19
14
|
};
|
|
20
15
|
return editor.registerRootListener((rootElement, prevRootElement) => {
|
|
21
16
|
if (prevRootElement !== null) {
|
|
@@ -41,7 +41,7 @@ const Menu = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
41
41
|
item,
|
|
42
42
|
index
|
|
43
43
|
}), {
|
|
44
|
-
className: ['item', highlightedIndex === index && _exports.default.modifierActive].filter(Boolean).join(' ')
|
|
44
|
+
className: ['item', item.disabled && _exports.default.modifierDisabled, highlightedIndex === index && _exports.default.modifierActive].filter(Boolean).join(' ')
|
|
45
45
|
}), /*#__PURE__*/React.createElement("p", null, item.label))));
|
|
46
46
|
});
|
|
47
47
|
Menu.propTypes = {
|
|
@@ -136,7 +136,7 @@ const Multiple = _ref => {
|
|
|
136
136
|
case _downshift.useCombobox.stateChangeTypes.InputKeyDownEnter:
|
|
137
137
|
case _downshift.useCombobox.stateChangeTypes.ItemClick:
|
|
138
138
|
case _downshift.useCombobox.stateChangeTypes.InputBlur:
|
|
139
|
-
if (selectedItem) {
|
|
139
|
+
if (selectedItem && !selectedItem?.disabled) {
|
|
140
140
|
setSearchInputValue('');
|
|
141
141
|
addSelectedItem(selectedItem);
|
|
142
142
|
}
|
|
@@ -29,9 +29,15 @@ const FormBuilder = _ref => {
|
|
|
29
29
|
style,
|
|
30
30
|
mode,
|
|
31
31
|
formData,
|
|
32
|
+
readOnly,
|
|
33
|
+
shouldSubmit,
|
|
32
34
|
formBuilderId,
|
|
33
35
|
onBuilderFormSave,
|
|
34
|
-
|
|
36
|
+
onBuilderError,
|
|
37
|
+
onRendererError,
|
|
38
|
+
onRendererFormSave,
|
|
39
|
+
onBuilderValidate,
|
|
40
|
+
initialBuilderValues
|
|
35
41
|
// ...otherProps
|
|
36
42
|
} = _ref;
|
|
37
43
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -40,11 +46,17 @@ const FormBuilder = _ref => {
|
|
|
40
46
|
style: style
|
|
41
47
|
// {...otherProps}
|
|
42
48
|
}, mode === 'build' && /*#__PURE__*/React.createElement(_common.Builder, {
|
|
49
|
+
initialValues: initialBuilderValues,
|
|
43
50
|
formBuilderId: formBuilderId,
|
|
44
|
-
onSave: onBuilderFormSave
|
|
51
|
+
onSave: onBuilderFormSave,
|
|
52
|
+
onError: onBuilderError,
|
|
53
|
+
validate: onBuilderValidate
|
|
45
54
|
}), mode === 'render' && /*#__PURE__*/React.createElement(_common.Renderer, {
|
|
46
55
|
formData: formData,
|
|
47
|
-
onSave: onRendererFormSave
|
|
56
|
+
onSave: onRendererFormSave,
|
|
57
|
+
readOnly: readOnly,
|
|
58
|
+
shouldSubmit: shouldSubmit,
|
|
59
|
+
onError: onRendererError
|
|
48
60
|
}));
|
|
49
61
|
};
|
|
50
62
|
FormBuilder.propTypes = {
|
|
@@ -67,10 +79,31 @@ FormBuilder.propTypes = {
|
|
|
67
79
|
/**
|
|
68
80
|
* This is the ID of the form element in the <Builder /> component
|
|
69
81
|
*/
|
|
70
|
-
formBuilderId: _propTypes.default.string.isRequired
|
|
82
|
+
formBuilderId: _propTypes.default.string.isRequired,
|
|
83
|
+
/**
|
|
84
|
+
* The form data to be used to construct the form builder in renderer mode
|
|
85
|
+
*/
|
|
86
|
+
formData: _propTypes.default.shape({
|
|
87
|
+
sections: _propTypes.default.arrayOf(_propTypes.default.objectOf(_propTypes.default.any))
|
|
88
|
+
}),
|
|
89
|
+
/**
|
|
90
|
+
* The initial values to instatiate form builder in builder mode
|
|
91
|
+
*/
|
|
92
|
+
initialBuilderValues: _propTypes.default.shape({
|
|
93
|
+
sections: _propTypes.default.arrayOf(_propTypes.default.objectOf(_propTypes.default.any))
|
|
94
|
+
}),
|
|
95
|
+
/**
|
|
96
|
+
* Whether the whole Form in renderer mode should be readOnly
|
|
97
|
+
*/
|
|
98
|
+
readOnly: _propTypes.default.bool,
|
|
99
|
+
/**
|
|
100
|
+
* Whether the form builder in renderer mode should submit the form values itself
|
|
101
|
+
*/
|
|
102
|
+
shouldSubmit: _propTypes.default.bool
|
|
71
103
|
};
|
|
72
104
|
FormBuilder.defaultProps = {
|
|
73
|
-
mode: 'build'
|
|
105
|
+
mode: 'build',
|
|
106
|
+
readOnly: false
|
|
74
107
|
};
|
|
75
108
|
FormBuilder.Builder = _common.Builder;
|
|
76
109
|
FormBuilder.Renderer = _common.Renderer;
|
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var React = _react;
|
|
8
9
|
var _formik = require("formik");
|
|
9
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
11
|
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
@@ -38,12 +39,42 @@ const Builder = _ref => {
|
|
|
38
39
|
className: userClassName,
|
|
39
40
|
style,
|
|
40
41
|
onSave,
|
|
41
|
-
|
|
42
|
+
onError,
|
|
43
|
+
validate,
|
|
44
|
+
formBuilderId,
|
|
45
|
+
initialValues = {}
|
|
42
46
|
// ...otherProps
|
|
43
47
|
} = _ref;
|
|
44
48
|
const handleSubmit = values => {
|
|
45
49
|
const reOrderedValues = reorderInputs(values);
|
|
46
|
-
onSave(reOrderedValues);
|
|
50
|
+
onSave?.(reOrderedValues);
|
|
51
|
+
};
|
|
52
|
+
const initialFormState = initialValues?.sections ? initialValues : {
|
|
53
|
+
sections: [{
|
|
54
|
+
title: '',
|
|
55
|
+
description: '',
|
|
56
|
+
key: 'section-0',
|
|
57
|
+
inputs: [],
|
|
58
|
+
orderedInputDragIds: [],
|
|
59
|
+
navigation: {
|
|
60
|
+
nextSection: 'next'
|
|
61
|
+
}
|
|
62
|
+
}]
|
|
63
|
+
};
|
|
64
|
+
const handleDeleteSection = _ref2 => {
|
|
65
|
+
let {
|
|
66
|
+
index,
|
|
67
|
+
remove,
|
|
68
|
+
values
|
|
69
|
+
} = _ref2;
|
|
70
|
+
remove(index);
|
|
71
|
+
values.sections.splice(index, 1);
|
|
72
|
+
values.sections.forEach((section, sectionIndex) => {
|
|
73
|
+
section.inputs.forEach((input, inputIndex) => {
|
|
74
|
+
// eslint-disable-next-line no-param-reassign
|
|
75
|
+
input.name = `section_${sectionIndex}_input_${inputIndex}`;
|
|
76
|
+
});
|
|
77
|
+
});
|
|
47
78
|
};
|
|
48
79
|
return /*#__PURE__*/React.createElement("div", {
|
|
49
80
|
id: id,
|
|
@@ -52,24 +83,23 @@ const Builder = _ref => {
|
|
|
52
83
|
}, /*#__PURE__*/React.createElement("p", {
|
|
53
84
|
className: "h3"
|
|
54
85
|
}, "Form Builder"), /*#__PURE__*/React.createElement(_formik.Formik, {
|
|
55
|
-
initialValues:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
key: 'section-0',
|
|
60
|
-
inputs: [],
|
|
61
|
-
orderedInputDragIds: [],
|
|
62
|
-
navigation: {
|
|
63
|
-
nextSection: 'next'
|
|
64
|
-
}
|
|
65
|
-
}]
|
|
66
|
-
},
|
|
67
|
-
onSubmit: handleSubmit
|
|
68
|
-
}, _ref2 => {
|
|
86
|
+
initialValues: initialFormState,
|
|
87
|
+
onSubmit: handleSubmit,
|
|
88
|
+
validate: validate
|
|
89
|
+
}, _ref3 => {
|
|
69
90
|
let {
|
|
70
|
-
values
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
values,
|
|
92
|
+
errors,
|
|
93
|
+
setFieldValue
|
|
94
|
+
} = _ref3;
|
|
95
|
+
(0, _react.useEffect)(() => {
|
|
96
|
+
const reOrderedValues = reorderInputs(values);
|
|
97
|
+
onSave?.(reOrderedValues);
|
|
98
|
+
}, [values]);
|
|
99
|
+
(0, _react.useEffect)(() => {
|
|
100
|
+
onError?.(errors);
|
|
101
|
+
}, [errors, values]);
|
|
102
|
+
const availableSections = values?.sections?.map((section, idx) => ({
|
|
73
103
|
value: idx,
|
|
74
104
|
label: `Go to ${section.title || `Untitled Section ${idx + 1}`}`
|
|
75
105
|
}));
|
|
@@ -77,13 +107,20 @@ const Builder = _ref => {
|
|
|
77
107
|
id: formBuilderId
|
|
78
108
|
}, /*#__PURE__*/React.createElement(_formik.FieldArray, {
|
|
79
109
|
name: "sections"
|
|
80
|
-
},
|
|
110
|
+
}, _ref4 => {
|
|
81
111
|
let {
|
|
82
|
-
push
|
|
83
|
-
|
|
84
|
-
|
|
112
|
+
push,
|
|
113
|
+
remove
|
|
114
|
+
} = _ref4;
|
|
115
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, values?.sections?.map((section, index) => /*#__PURE__*/React.createElement(_common.Section, {
|
|
85
116
|
key: section.key,
|
|
86
|
-
index: index
|
|
117
|
+
index: index,
|
|
118
|
+
handleDeleteSection: () => handleDeleteSection({
|
|
119
|
+
index,
|
|
120
|
+
remove,
|
|
121
|
+
values,
|
|
122
|
+
setFieldValue
|
|
123
|
+
})
|
|
87
124
|
})), /*#__PURE__*/React.createElement("div", {
|
|
88
125
|
className: "section-footer"
|
|
89
126
|
}, /*#__PURE__*/React.createElement("button", {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var React = _react;
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
11
|
+
require("./styles.scss");
|
|
12
|
+
var _utils = require("../../../../../../utils");
|
|
13
|
+
var _a = require("../../../../../../a");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.2 */
|
|
18
|
+
|
|
19
|
+
// Local Definitions
|
|
20
|
+
|
|
21
|
+
const baseClassName = _exports.default.base;
|
|
22
|
+
const componentClassName = 'actions-container';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This is the component description.
|
|
26
|
+
*/
|
|
27
|
+
const ActionsContainer = _ref => {
|
|
28
|
+
let {
|
|
29
|
+
id,
|
|
30
|
+
className: userClassName,
|
|
31
|
+
style,
|
|
32
|
+
preferredPopoverOrder,
|
|
33
|
+
children
|
|
34
|
+
// ...otherProps
|
|
35
|
+
} = _ref;
|
|
36
|
+
const parentRef = (0, _react.useRef)(null);
|
|
37
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
38
|
+
(0, _utils.useOutsideClick)(parentRef, () => setIsOpen(false));
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
id: id,
|
|
41
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
42
|
+
style: style,
|
|
43
|
+
ref: parentRef
|
|
44
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
45
|
+
type: "button",
|
|
46
|
+
onClick: () => setIsOpen(!isOpen)
|
|
47
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
48
|
+
className: "icon x-ui-icons c-x"
|
|
49
|
+
}, "!")), /*#__PURE__*/React.createElement(_a.Popover, {
|
|
50
|
+
isOpen: isOpen,
|
|
51
|
+
parentRef: parentRef,
|
|
52
|
+
preferredPrimaryOrder: preferredPopoverOrder
|
|
53
|
+
}, children));
|
|
54
|
+
};
|
|
55
|
+
ActionsContainer.propTypes = {
|
|
56
|
+
/**
|
|
57
|
+
* The HTML id for this element
|
|
58
|
+
*/
|
|
59
|
+
id: _propTypes.default.string,
|
|
60
|
+
/**
|
|
61
|
+
* The HTML class names for this element
|
|
62
|
+
*/
|
|
63
|
+
className: _propTypes.default.string,
|
|
64
|
+
/**
|
|
65
|
+
* The React-written, css properties for this element.
|
|
66
|
+
*/
|
|
67
|
+
style: _propTypes.default.objectOf(_propTypes.default.string),
|
|
68
|
+
/**
|
|
69
|
+
* The preferred order for the popover
|
|
70
|
+
*/
|
|
71
|
+
preferredPopoverOrder: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
72
|
+
/**
|
|
73
|
+
* The children of the actions container
|
|
74
|
+
*/
|
|
75
|
+
children: _propTypes.default.node
|
|
76
|
+
};
|
|
77
|
+
ActionsContainer.defaultProps = {
|
|
78
|
+
preferredPopoverOrder: ['right', 'bottom', 'left', 'top']
|
|
79
|
+
};
|
|
80
|
+
var _default = exports.default = ActionsContainer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ActionsContainer", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ActionsContainer.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _ActionsContainer = _interopRequireDefault(require("./ActionsContainer"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.1.1-alpha.2 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-padding: 1rem;
|
|
6
|
+
$default-margin: 1rem;
|
|
7
|
+
$default-list-width: var(--action-button-width, 18rem);
|
|
8
|
+
|
|
9
|
+
.#{bem.$base}.actions-container {
|
|
10
|
+
position: relative;
|
|
11
|
+
|
|
12
|
+
> button {
|
|
13
|
+
background-color: transparent;
|
|
14
|
+
border: 0;
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
> .#{bem.$base}.popover {
|
|
19
|
+
background-color: var(--background-cards);
|
|
20
|
+
border: var(--theme-default-border-style) var(--main2);
|
|
21
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
22
|
+
cursor: default;
|
|
23
|
+
padding: $default-padding;
|
|
24
|
+
width: $default-list-width;
|
|
25
|
+
|
|
26
|
+
> p {
|
|
27
|
+
margin: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
> ul {
|
|
31
|
+
list-style: none;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 0;
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
|
|
36
|
+
> .option {
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
padding-block: calc($default-padding / 4);
|
|
39
|
+
|
|
40
|
+
&:not(.with-check-mark) {
|
|
41
|
+
padding-inline: $default-padding;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* stylelint-disable-next-line selector-max-compound-selectors -- required */
|
|
45
|
+
> button {
|
|
46
|
+
background: transparent;
|
|
47
|
+
border: 0;
|
|
48
|
+
color: var(--paragraph);
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
font-size: calc(var(--s0) * .875rem);
|
|
51
|
+
text-align: left;
|
|
52
|
+
width: 100%;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
@@ -11,8 +11,8 @@ var _formik = require("formik");
|
|
|
11
11
|
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
12
12
|
var _f = require("../../../../../../f");
|
|
13
13
|
var _a = require("../../../../../../a");
|
|
14
|
-
var _utils = require("../../../../../../utils");
|
|
15
14
|
require("./styles.scss");
|
|
15
|
+
var _ActionsContainer = require("../ActionsContainer");
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
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); }
|
|
18
18
|
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; }
|
|
@@ -33,32 +33,32 @@ const InputBuilder = _ref => {
|
|
|
33
33
|
style,
|
|
34
34
|
sectionIndex,
|
|
35
35
|
inputIndex,
|
|
36
|
-
onDelete
|
|
36
|
+
onDelete
|
|
37
37
|
// onCopy,
|
|
38
|
-
preferredPopoverOrder
|
|
39
38
|
// ...otherProps
|
|
40
39
|
} = _ref;
|
|
41
40
|
const {
|
|
42
41
|
values,
|
|
43
42
|
setFieldValue
|
|
44
43
|
} = (0, _formik.useFormikContext)();
|
|
45
|
-
const input = values.sections[sectionIndex]
|
|
44
|
+
const input = values.sections[sectionIndex]?.inputs[inputIndex];
|
|
46
45
|
const handleToggleRequired = () => {
|
|
47
|
-
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.required`, !input
|
|
46
|
+
setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.required`, !input?.required);
|
|
48
47
|
};
|
|
49
48
|
const toggleSwitchStyles = {
|
|
50
49
|
...(!input?.required ? {
|
|
51
50
|
'--slider-background-color': 'var(--disabled)'
|
|
52
51
|
} : {})
|
|
53
52
|
};
|
|
54
|
-
const parentRef = (0, _react.useRef)(null);
|
|
55
|
-
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
56
|
-
(0, _utils.useOutsideClick)(parentRef, () => setIsOpen(false));
|
|
57
53
|
const [hasDescription, setHasDescription] = (0, _react.useState)(false);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
|
|
55
|
+
// TODO: handle nav logic
|
|
56
|
+
// const handleToggleConditionalNavigation = () => {
|
|
57
|
+
// setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.conditionalNavigation`,
|
|
58
|
+
// !input?.conditionalNavigation)
|
|
59
|
+
// }
|
|
60
|
+
|
|
61
|
+
const availableSections = values?.sections?.map((section, idx) => ({
|
|
62
62
|
value: idx,
|
|
63
63
|
label: `Go to ${section.title || `Untitled Section ${idx + 1}`}`
|
|
64
64
|
}));
|
|
@@ -96,9 +96,6 @@ const InputBuilder = _ref => {
|
|
|
96
96
|
}, {
|
|
97
97
|
value: 'select',
|
|
98
98
|
label: 'Dropdown select'
|
|
99
|
-
}, {
|
|
100
|
-
value: 'editor',
|
|
101
|
-
label: 'Editor input'
|
|
102
99
|
}, {
|
|
103
100
|
value: 'multiple',
|
|
104
101
|
label: 'Checkboxes'
|
|
@@ -122,33 +119,14 @@ const InputBuilder = _ref => {
|
|
|
122
119
|
checked: input?.required,
|
|
123
120
|
style: toggleSwitchStyles,
|
|
124
121
|
inputId: `sections_${sectionIndex}_inputs.${inputIndex}_toggle`
|
|
125
|
-
})), /*#__PURE__*/React.createElement("
|
|
126
|
-
className: "actions",
|
|
127
|
-
ref: parentRef
|
|
128
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
129
|
-
type: "button",
|
|
130
|
-
onClick: () => setIsOpen(!isOpen)
|
|
131
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
132
|
-
className: "icon x-ui-icons c-x"
|
|
133
|
-
}, "!")), /*#__PURE__*/React.createElement(_a.Popover, {
|
|
134
|
-
isOpen: isOpen,
|
|
135
|
-
parentRef: parentRef,
|
|
136
|
-
preferredPrimaryOrder: preferredPopoverOrder
|
|
137
|
-
}, /*#__PURE__*/React.createElement("p", null, "Show"), /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
|
|
122
|
+
})), /*#__PURE__*/React.createElement(_ActionsContainer.ActionsContainer, null, /*#__PURE__*/React.createElement("p", null, "Show"), /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
|
|
138
123
|
className: `option ${hasDescription ? 'with-check-mark' : ''}`
|
|
139
124
|
}, hasDescription && /*#__PURE__*/React.createElement("span", {
|
|
140
125
|
className: "x-ui-icons c-x icon"
|
|
141
126
|
}, "I"), /*#__PURE__*/React.createElement("button", {
|
|
142
127
|
onClick: () => setHasDescription(!hasDescription),
|
|
143
128
|
type: "button"
|
|
144
|
-
}, "Description")), /*#__PURE__*/React.createElement("
|
|
145
|
-
className: `option ${input?.conditionalNavigation ? 'with-check-mark' : ''}`
|
|
146
|
-
}, input?.conditionalNavigation && /*#__PURE__*/React.createElement("span", {
|
|
147
|
-
className: "x-ui-icons c-x icon"
|
|
148
|
-
}, "I"), /*#__PURE__*/React.createElement("button", {
|
|
149
|
-
onClick: handleToggleConditionalNavigation,
|
|
150
|
-
type: "button"
|
|
151
|
-
}, "Go to section based on answer"))))))), /*#__PURE__*/React.createElement("div", {
|
|
129
|
+
}, "Description")))))), /*#__PURE__*/React.createElement("div", {
|
|
152
130
|
className: "input-name-description"
|
|
153
131
|
}, /*#__PURE__*/React.createElement(_f.TextInput, {
|
|
154
132
|
label: "Input name",
|
|
@@ -170,8 +148,8 @@ const InputBuilder = _ref => {
|
|
|
170
148
|
}, /*#__PURE__*/React.createElement("p", null, "Options"), input?.options.map((option, optionIndex) => /*#__PURE__*/React.createElement("div", {
|
|
171
149
|
key: option.key,
|
|
172
150
|
className: "option-container"
|
|
173
|
-
}, input
|
|
174
|
-
className: `input-icon-sample ${input
|
|
151
|
+
}, input?.type !== 'select' && /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
className: `input-icon-sample ${input?.type}`
|
|
175
153
|
}), /*#__PURE__*/React.createElement(_f.TextInput, {
|
|
176
154
|
name: `sections.${sectionIndex}.inputs.${inputIndex}.options.${optionIndex}.value`,
|
|
177
155
|
placeholder: `Option ${optionIndex + 1}`,
|
|
@@ -191,7 +169,7 @@ const InputBuilder = _ref => {
|
|
|
191
169
|
className: "add-option-cta",
|
|
192
170
|
type: "button",
|
|
193
171
|
onClick: () => push({
|
|
194
|
-
key: `sections-${sectionIndex}-inputs-${inputIndex}-options-${input
|
|
172
|
+
key: `sections-${sectionIndex}-inputs-${inputIndex}-options-${input?.options.length - 1}`,
|
|
195
173
|
value: '',
|
|
196
174
|
label: '',
|
|
197
175
|
nextSection: ''
|
|
@@ -217,13 +195,9 @@ InputBuilder.propTypes = {
|
|
|
217
195
|
/**
|
|
218
196
|
* The React-written, css properties for this element.
|
|
219
197
|
*/
|
|
220
|
-
style: _propTypes.default.objectOf(_propTypes.default.string)
|
|
221
|
-
/**
|
|
222
|
-
* The preferred primary order of the popover
|
|
223
|
-
*/
|
|
224
|
-
preferredPopoverOrder: _propTypes.default.arrayOf(_propTypes.default.string)
|
|
198
|
+
style: _propTypes.default.objectOf(_propTypes.default.string)
|
|
225
199
|
};
|
|
226
200
|
InputBuilder.defaultProps = {
|
|
227
|
-
|
|
201
|
+
// some properties
|
|
228
202
|
};
|
|
229
203
|
var _default = exports.default = InputBuilder;
|