@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.
Files changed (63) hide show
  1. package/dist/cjs/a/XMLEditor/XMLEditor.js +3 -15
  2. package/dist/cjs/f/fields/EditorInput/EditorInput.js +6 -21
  3. package/dist/cjs/f/fields/EditorInput/common/StopPropagationPlugin.js +2 -7
  4. package/dist/cjs/f/fields/SelectInput/common/Menu/Menu.js +1 -1
  5. package/dist/cjs/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
  6. package/dist/cjs/f/fields/SelectInput/styles.scss +1 -1
  7. package/dist/cjs/g/FormBuilder/FormBuilder.js +38 -5
  8. package/dist/cjs/g/FormBuilder/common/Builder/Builder.js +62 -25
  9. package/dist/cjs/g/FormBuilder/common/Builder/common/ActionsContainer/ActionsContainer.js +80 -0
  10. package/dist/cjs/g/FormBuilder/common/Builder/common/ActionsContainer/index.js +13 -0
  11. package/dist/cjs/g/FormBuilder/common/Builder/common/ActionsContainer/styles.scss +59 -0
  12. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +19 -45
  13. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +0 -49
  14. package/dist/cjs/g/FormBuilder/common/Builder/common/Section/Section.js +14 -3
  15. package/dist/cjs/g/FormBuilder/common/Builder/common/Section/styles.scss +61 -0
  16. package/dist/cjs/g/FormBuilder/common/Builder/common/index.js +8 -1
  17. package/dist/cjs/g/FormBuilder/common/Builder/styles.scss +5 -48
  18. package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +76 -33
  19. package/dist/cjs/g/FormBuilder/common/Renderer/common/Section/Section.js +8 -3
  20. package/dist/cjs/g/FormBuilder/common/Renderer/styles.scss +12 -1
  21. package/dist/es/a/XMLEditor/XMLEditor.js +3 -15
  22. package/dist/es/f/fields/EditorInput/EditorInput.js +7 -22
  23. package/dist/es/f/fields/EditorInput/common/StopPropagationPlugin.js +2 -6
  24. package/dist/es/f/fields/SelectInput/common/Menu/Menu.js +1 -1
  25. package/dist/es/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
  26. package/dist/es/f/fields/SelectInput/styles.scss +1 -1
  27. package/dist/es/g/FormBuilder/FormBuilder.js +38 -5
  28. package/dist/es/g/FormBuilder/common/Builder/Builder.js +56 -20
  29. package/dist/es/g/FormBuilder/common/Builder/common/ActionsContainer/ActionsContainer.js +70 -0
  30. package/dist/es/g/FormBuilder/common/Builder/common/ActionsContainer/index.js +2 -0
  31. package/dist/es/g/FormBuilder/common/Builder/common/ActionsContainer/styles.scss +59 -0
  32. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +21 -47
  33. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +0 -49
  34. package/dist/es/g/FormBuilder/common/Builder/common/Section/Section.js +14 -3
  35. package/dist/es/g/FormBuilder/common/Builder/common/Section/styles.scss +61 -0
  36. package/dist/es/g/FormBuilder/common/Builder/common/index.js +2 -1
  37. package/dist/es/g/FormBuilder/common/Builder/styles.scss +5 -48
  38. package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +76 -34
  39. package/dist/es/g/FormBuilder/common/Renderer/common/Section/Section.js +8 -3
  40. package/dist/es/g/FormBuilder/common/Renderer/styles.scss +12 -1
  41. package/package.json +4 -4
  42. package/src/stories/g/FormBuilder.stories.jsx +116 -21
  43. package/src/ui/a/XMLEditor/XMLEditor.jsx +1 -15
  44. package/src/ui/f/fields/EditorInput/EditorInput.jsx +7 -23
  45. package/src/ui/f/fields/EditorInput/common/StopPropagationPlugin.jsx +2 -6
  46. package/src/ui/f/fields/SelectInput/common/Menu/Menu.jsx +1 -0
  47. package/src/ui/f/fields/SelectInput/common/Multiple/Multiple.jsx +1 -1
  48. package/src/ui/f/fields/SelectInput/styles.scss +1 -1
  49. package/src/ui/g/FormBuilder/FormBuilder.jsx +50 -3
  50. package/src/ui/g/FormBuilder/common/Builder/Builder.jsx +56 -18
  51. package/src/ui/g/FormBuilder/common/Builder/common/ActionsContainer/ActionsContainer.jsx +97 -0
  52. package/src/ui/g/FormBuilder/common/Builder/common/ActionsContainer/index.js +2 -0
  53. package/src/ui/g/FormBuilder/common/Builder/common/ActionsContainer/styles.scss +59 -0
  54. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +40 -60
  55. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +0 -49
  56. package/src/ui/g/FormBuilder/common/Builder/common/Section/Section.jsx +26 -4
  57. package/src/ui/g/FormBuilder/common/Builder/common/Section/styles.scss +61 -0
  58. package/src/ui/g/FormBuilder/common/Builder/common/index.js +1 -0
  59. package/src/ui/g/FormBuilder/common/Builder/styles.scss +5 -48
  60. package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +84 -33
  61. package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +3 -2
  62. package/src/ui/g/FormBuilder/common/Renderer/styles.scss +12 -1
  63. package/tests/__snapshots__/Storyshots.test.js.snap +395 -133
@@ -19,9 +19,15 @@ const FormBuilder = ({
19
19
  style,
20
20
  mode,
21
21
  formData,
22
+ readOnly,
23
+ shouldSubmit,
22
24
  formBuilderId,
23
25
  onBuilderFormSave,
24
- onRendererFormSave
26
+ onBuilderError,
27
+ onRendererError,
28
+ onRendererFormSave,
29
+ onBuilderValidate,
30
+ initialBuilderValues
25
31
  // ...otherProps
26
32
  }) => /*#__PURE__*/React.createElement("div", {
27
33
  id: id,
@@ -29,11 +35,17 @@ const FormBuilder = ({
29
35
  style: style
30
36
  // {...otherProps}
31
37
  }, mode === 'build' && /*#__PURE__*/React.createElement(Builder, {
38
+ initialValues: initialBuilderValues,
32
39
  formBuilderId: formBuilderId,
33
- onSave: onBuilderFormSave
40
+ onSave: onBuilderFormSave,
41
+ onError: onBuilderError,
42
+ validate: onBuilderValidate
34
43
  }), mode === 'render' && /*#__PURE__*/React.createElement(Renderer, {
35
44
  formData: formData,
36
- onSave: onRendererFormSave
45
+ onSave: onRendererFormSave,
46
+ readOnly: readOnly,
47
+ shouldSubmit: shouldSubmit,
48
+ onError: onRendererError
37
49
  }));
38
50
  FormBuilder.propTypes = {
39
51
  /**
@@ -55,10 +67,31 @@ FormBuilder.propTypes = {
55
67
  /**
56
68
  * This is the ID of the form element in the <Builder /> component
57
69
  */
58
- formBuilderId: PropTypes.string.isRequired
70
+ formBuilderId: PropTypes.string.isRequired,
71
+ /**
72
+ * The form data to be used to construct the form builder in renderer mode
73
+ */
74
+ formData: PropTypes.shape({
75
+ sections: PropTypes.arrayOf(PropTypes.objectOf(PropTypes.any))
76
+ }),
77
+ /**
78
+ * The initial values to instatiate form builder in builder mode
79
+ */
80
+ initialBuilderValues: PropTypes.shape({
81
+ sections: PropTypes.arrayOf(PropTypes.objectOf(PropTypes.any))
82
+ }),
83
+ /**
84
+ * Whether the whole Form in renderer mode should be readOnly
85
+ */
86
+ readOnly: PropTypes.bool,
87
+ /**
88
+ * Whether the form builder in renderer mode should submit the form values itself
89
+ */
90
+ shouldSubmit: PropTypes.bool
59
91
  };
60
92
  FormBuilder.defaultProps = {
61
- mode: 'build'
93
+ mode: 'build',
94
+ readOnly: false
62
95
  };
63
96
  FormBuilder.Builder = Builder;
64
97
  FormBuilder.Renderer = Renderer;
@@ -1,5 +1,6 @@
1
1
  /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
2
  import * as React from 'react';
3
+ import { useEffect } from 'react';
3
4
  import { Formik, Form, FieldArray } from 'formik';
4
5
  import PropTypes from 'prop-types';
5
6
  import styleNames from '@pareto-engineering/bem/exports';
@@ -28,12 +29,41 @@ const Builder = ({
28
29
  className: userClassName,
29
30
  style,
30
31
  onSave,
31
- formBuilderId
32
+ onError,
33
+ validate,
34
+ formBuilderId,
35
+ initialValues = {}
32
36
  // ...otherProps
33
37
  }) => {
34
38
  const handleSubmit = values => {
35
39
  const reOrderedValues = reorderInputs(values);
36
- onSave(reOrderedValues);
40
+ onSave?.(reOrderedValues);
41
+ };
42
+ const initialFormState = initialValues?.sections ? initialValues : {
43
+ sections: [{
44
+ title: '',
45
+ description: '',
46
+ key: 'section-0',
47
+ inputs: [],
48
+ orderedInputDragIds: [],
49
+ navigation: {
50
+ nextSection: 'next'
51
+ }
52
+ }]
53
+ };
54
+ const handleDeleteSection = ({
55
+ index,
56
+ remove,
57
+ values
58
+ }) => {
59
+ remove(index);
60
+ values.sections.splice(index, 1);
61
+ values.sections.forEach((section, sectionIndex) => {
62
+ section.inputs.forEach((input, inputIndex) => {
63
+ // eslint-disable-next-line no-param-reassign
64
+ input.name = `section_${sectionIndex}_input_${inputIndex}`;
65
+ });
66
+ });
37
67
  };
38
68
  return /*#__PURE__*/React.createElement("div", {
39
69
  id: id,
@@ -42,23 +72,22 @@ const Builder = ({
42
72
  }, /*#__PURE__*/React.createElement("p", {
43
73
  className: "h3"
44
74
  }, "Form Builder"), /*#__PURE__*/React.createElement(Formik, {
45
- initialValues: {
46
- sections: [{
47
- title: '',
48
- description: '',
49
- key: 'section-0',
50
- inputs: [],
51
- orderedInputDragIds: [],
52
- navigation: {
53
- nextSection: 'next'
54
- }
55
- }]
56
- },
57
- onSubmit: handleSubmit
75
+ initialValues: initialFormState,
76
+ onSubmit: handleSubmit,
77
+ validate: validate
58
78
  }, ({
59
- values
79
+ values,
80
+ errors,
81
+ setFieldValue
60
82
  }) => {
61
- const availableSections = values.sections.map((section, idx) => ({
83
+ useEffect(() => {
84
+ const reOrderedValues = reorderInputs(values);
85
+ onSave?.(reOrderedValues);
86
+ }, [values]);
87
+ useEffect(() => {
88
+ onError?.(errors);
89
+ }, [errors, values]);
90
+ const availableSections = values?.sections?.map((section, idx) => ({
62
91
  value: idx,
63
92
  label: `Go to ${section.title || `Untitled Section ${idx + 1}`}`
64
93
  }));
@@ -67,10 +96,17 @@ const Builder = ({
67
96
  }, /*#__PURE__*/React.createElement(FieldArray, {
68
97
  name: "sections"
69
98
  }, ({
70
- push
71
- }) => /*#__PURE__*/React.createElement(React.Fragment, null, values.sections.map((section, index) => /*#__PURE__*/React.createElement(Section, {
99
+ push,
100
+ remove
101
+ }) => /*#__PURE__*/React.createElement(React.Fragment, null, values?.sections?.map((section, index) => /*#__PURE__*/React.createElement(Section, {
72
102
  key: section.key,
73
- index: index
103
+ index: index,
104
+ handleDeleteSection: () => handleDeleteSection({
105
+ index,
106
+ remove,
107
+ values,
108
+ setFieldValue
109
+ })
74
110
  })), /*#__PURE__*/React.createElement("div", {
75
111
  className: "section-footer"
76
112
  }, /*#__PURE__*/React.createElement("button", {
@@ -0,0 +1,70 @@
1
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
+ import * as React from 'react';
3
+ import { useState, useRef } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import styleNames from '@pareto-engineering/bem/exports';
6
+ import "./styles.scss";
7
+
8
+ // Local Definitions
9
+
10
+ import { useOutsideClick } from "../../../../../../utils";
11
+ import { Popover } from "../../../../../../a";
12
+ const baseClassName = styleNames.base;
13
+ const componentClassName = 'actions-container';
14
+
15
+ /**
16
+ * This is the component description.
17
+ */
18
+ const ActionsContainer = ({
19
+ id,
20
+ className: userClassName,
21
+ style,
22
+ preferredPopoverOrder,
23
+ children
24
+ // ...otherProps
25
+ }) => {
26
+ const parentRef = useRef(null);
27
+ const [isOpen, setIsOpen] = useState(false);
28
+ useOutsideClick(parentRef, () => setIsOpen(false));
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ id: id,
31
+ className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
32
+ style: style,
33
+ ref: parentRef
34
+ }, /*#__PURE__*/React.createElement("button", {
35
+ type: "button",
36
+ onClick: () => setIsOpen(!isOpen)
37
+ }, /*#__PURE__*/React.createElement("span", {
38
+ className: "icon x-ui-icons c-x"
39
+ }, "!")), /*#__PURE__*/React.createElement(Popover, {
40
+ isOpen: isOpen,
41
+ parentRef: parentRef,
42
+ preferredPrimaryOrder: preferredPopoverOrder
43
+ }, children));
44
+ };
45
+ ActionsContainer.propTypes = {
46
+ /**
47
+ * The HTML id for this element
48
+ */
49
+ id: PropTypes.string,
50
+ /**
51
+ * The HTML class names for this element
52
+ */
53
+ className: PropTypes.string,
54
+ /**
55
+ * The React-written, css properties for this element.
56
+ */
57
+ style: PropTypes.objectOf(PropTypes.string),
58
+ /**
59
+ * The preferred order for the popover
60
+ */
61
+ preferredPopoverOrder: PropTypes.arrayOf(PropTypes.string),
62
+ /**
63
+ * The children of the actions container
64
+ */
65
+ children: PropTypes.node
66
+ };
67
+ ActionsContainer.defaultProps = {
68
+ preferredPopoverOrder: ['right', 'bottom', 'left', 'top']
69
+ };
70
+ export default ActionsContainer;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
+ export { default as ActionsContainer } from "./ActionsContainer";
@@ -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
+
@@ -1,16 +1,16 @@
1
1
  /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
2
  import * as React from 'react';
3
- import { useState, useRef } from 'react';
3
+ import { useState } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { FieldArray, useFormikContext } from 'formik';
6
6
  import styleNames from '@pareto-engineering/bem/exports';
7
7
  import { SelectInput, TextInput } from "../../../../../../f";
8
- import { ToggleSwitch, Popover } from "../../../../../../a";
9
- import { useOutsideClick } from "../../../../../../utils";
8
+ import { ToggleSwitch } from "../../../../../../a";
10
9
  import "./styles.scss";
11
10
 
12
11
  // Local Definitions
13
12
 
13
+ import { ActionsContainer } from "../ActionsContainer";
14
14
  const baseClassName = styleNames.base;
15
15
  const componentClassName = 'input-builder';
16
16
 
@@ -23,32 +23,32 @@ const InputBuilder = ({
23
23
  style,
24
24
  sectionIndex,
25
25
  inputIndex,
26
- onDelete,
26
+ onDelete
27
27
  // onCopy,
28
- preferredPopoverOrder
29
28
  // ...otherProps
30
29
  }) => {
31
30
  const {
32
31
  values,
33
32
  setFieldValue
34
33
  } = useFormikContext();
35
- const input = values.sections[sectionIndex].inputs[inputIndex];
34
+ const input = values.sections[sectionIndex]?.inputs[inputIndex];
36
35
  const handleToggleRequired = () => {
37
- setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.required`, !input.required);
36
+ setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.required`, !input?.required);
38
37
  };
39
38
  const toggleSwitchStyles = {
40
39
  ...(!input?.required ? {
41
40
  '--slider-background-color': 'var(--disabled)'
42
41
  } : {})
43
42
  };
44
- const parentRef = useRef(null);
45
- const [isOpen, setIsOpen] = useState(false);
46
- useOutsideClick(parentRef, () => setIsOpen(false));
47
43
  const [hasDescription, setHasDescription] = useState(false);
48
- const handleToggleConditionalNavigation = () => {
49
- setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.conditionalNavigation`, !input.conditionalNavigation);
50
- };
51
- const availableSections = values.sections.map((section, idx) => ({
44
+
45
+ // TODO: handle nav logic
46
+ // const handleToggleConditionalNavigation = () => {
47
+ // setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.conditionalNavigation`,
48
+ // !input?.conditionalNavigation)
49
+ // }
50
+
51
+ const availableSections = values?.sections?.map((section, idx) => ({
52
52
  value: idx,
53
53
  label: `Go to ${section.title || `Untitled Section ${idx + 1}`}`
54
54
  }));
@@ -86,9 +86,6 @@ const InputBuilder = ({
86
86
  }, {
87
87
  value: 'select',
88
88
  label: 'Dropdown select'
89
- }, {
90
- value: 'editor',
91
- label: 'Editor input'
92
89
  }, {
93
90
  value: 'multiple',
94
91
  label: 'Checkboxes'
@@ -112,33 +109,14 @@ const InputBuilder = ({
112
109
  checked: input?.required,
113
110
  style: toggleSwitchStyles,
114
111
  inputId: `sections_${sectionIndex}_inputs.${inputIndex}_toggle`
115
- })), /*#__PURE__*/React.createElement("div", {
116
- className: "actions",
117
- ref: parentRef
118
- }, /*#__PURE__*/React.createElement("button", {
119
- type: "button",
120
- onClick: () => setIsOpen(!isOpen)
121
- }, /*#__PURE__*/React.createElement("span", {
122
- className: "icon x-ui-icons c-x"
123
- }, "!")), /*#__PURE__*/React.createElement(Popover, {
124
- isOpen: isOpen,
125
- parentRef: parentRef,
126
- preferredPrimaryOrder: preferredPopoverOrder
127
- }, /*#__PURE__*/React.createElement("p", null, "Show"), /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
112
+ })), /*#__PURE__*/React.createElement(ActionsContainer, null, /*#__PURE__*/React.createElement("p", null, "Show"), /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
128
113
  className: `option ${hasDescription ? 'with-check-mark' : ''}`
129
114
  }, hasDescription && /*#__PURE__*/React.createElement("span", {
130
115
  className: "x-ui-icons c-x icon"
131
116
  }, "I"), /*#__PURE__*/React.createElement("button", {
132
117
  onClick: () => setHasDescription(!hasDescription),
133
118
  type: "button"
134
- }, "Description")), /*#__PURE__*/React.createElement("li", {
135
- className: `option ${input?.conditionalNavigation ? 'with-check-mark' : ''}`
136
- }, input?.conditionalNavigation && /*#__PURE__*/React.createElement("span", {
137
- className: "x-ui-icons c-x icon"
138
- }, "I"), /*#__PURE__*/React.createElement("button", {
139
- onClick: handleToggleConditionalNavigation,
140
- type: "button"
141
- }, "Go to section based on answer"))))))), /*#__PURE__*/React.createElement("div", {
119
+ }, "Description")))))), /*#__PURE__*/React.createElement("div", {
142
120
  className: "input-name-description"
143
121
  }, /*#__PURE__*/React.createElement(TextInput, {
144
122
  label: "Input name",
@@ -158,8 +136,8 @@ const InputBuilder = ({
158
136
  }, /*#__PURE__*/React.createElement("p", null, "Options"), input?.options.map((option, optionIndex) => /*#__PURE__*/React.createElement("div", {
159
137
  key: option.key,
160
138
  className: "option-container"
161
- }, input.type !== 'select' && /*#__PURE__*/React.createElement("div", {
162
- className: `input-icon-sample ${input.type}`
139
+ }, input?.type !== 'select' && /*#__PURE__*/React.createElement("div", {
140
+ className: `input-icon-sample ${input?.type}`
163
141
  }), /*#__PURE__*/React.createElement(TextInput, {
164
142
  name: `sections.${sectionIndex}.inputs.${inputIndex}.options.${optionIndex}.value`,
165
143
  placeholder: `Option ${optionIndex + 1}`,
@@ -179,7 +157,7 @@ const InputBuilder = ({
179
157
  className: "add-option-cta",
180
158
  type: "button",
181
159
  onClick: () => push({
182
- key: `sections-${sectionIndex}-inputs-${inputIndex}-options-${input.options.length - 1}`,
160
+ key: `sections-${sectionIndex}-inputs-${inputIndex}-options-${input?.options.length - 1}`,
183
161
  value: '',
184
162
  label: '',
185
163
  nextSection: ''
@@ -204,13 +182,9 @@ InputBuilder.propTypes = {
204
182
  /**
205
183
  * The React-written, css properties for this element.
206
184
  */
207
- style: PropTypes.objectOf(PropTypes.string),
208
- /**
209
- * The preferred primary order of the popover
210
- */
211
- preferredPopoverOrder: PropTypes.arrayOf(PropTypes.string)
185
+ style: PropTypes.objectOf(PropTypes.string)
212
186
  };
213
187
  InputBuilder.defaultProps = {
214
- preferredPopoverOrder: ['right', 'bottom', 'left', 'top']
188
+ // some properties
215
189
  };
216
190
  export default InputBuilder;
@@ -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
 
@@ -10,8 +10,10 @@ import styleNames from '@pareto-engineering/bem/exports';
10
10
  import { TextInput, EditorInput } from "../../../../../../f";
11
11
  import { DragAndDrop } from "../../../../..";
12
12
  import { InputBuilder } from "../InputBuilder";
13
+ import { ActionsContainer } from "../ActionsContainer";
14
+ import "./styles.scss";
13
15
  const baseClassName = styleNames.base;
14
- const componentClassName = 'section';
16
+ const componentClassName = 'builder-section';
15
17
 
16
18
  /**
17
19
  * This is the component description.
@@ -20,7 +22,8 @@ const Section = ({
20
22
  id,
21
23
  className: userClassName,
22
24
  style,
23
- index
25
+ index,
26
+ handleDeleteSection
24
27
  // ...otherProps
25
28
  }) => {
26
29
  const {
@@ -62,9 +65,17 @@ const Section = ({
62
65
  id: id,
63
66
  className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
64
67
  style: style
68
+ }, /*#__PURE__*/React.createElement("div", {
69
+ className: "section-header"
65
70
  }, /*#__PURE__*/React.createElement("p", {
66
71
  className: "h4"
67
- }, index === 0 ? 'Form title' : `Section ${index + 1}`), /*#__PURE__*/React.createElement(TextInput, {
72
+ }, index === 0 ? 'Form title' : `Section ${index + 1}`), index !== 0 && /*#__PURE__*/React.createElement(ActionsContainer, null, /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
73
+ className: "option"
74
+ }, /*#__PURE__*/React.createElement("button", {
75
+ type: "button",
76
+ className: "remove-section-cta",
77
+ onClick: handleDeleteSection
78
+ }, "Delete Section"))))), /*#__PURE__*/React.createElement(TextInput, {
68
79
  name: `sections.${index}.title`,
69
80
  placeholder: `Title of the ${index === 0 ? 'form' : 'section'}`
70
81
  }), /*#__PURE__*/React.createElement(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
+
@@ -1,2 +1,3 @@
1
1
  export { Section } from "./Section";
2
- export { InputBuilder } from "./InputBuilder";
2
+ export { InputBuilder } from "./InputBuilder";
3
+ export { ActionsContainer } from "./ActionsContainer";
@@ -49,56 +49,13 @@ $default-margin: 1rem;
49
49
  flex: .4;
50
50
  gap: var(--gap);
51
51
 
52
- > .#{bem.$base}.select-input {
53
- flex: auto;
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
- > form {
65
- /* stylelint-disable selector-max-compound-selectors -- required */
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
  }