@pareto-engineering/design-system 4.0.0-alpha.78 → 4.0.0-alpha.81

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 (98) hide show
  1. package/dist/cjs/a/Label/styles.scss +1 -1
  2. package/dist/cjs/a/Quote/styles.scss +1 -1
  3. package/dist/cjs/a/Tooltip/Tooltip.js +21 -5
  4. package/dist/cjs/a/Tooltip/styles.scss +44 -36
  5. package/dist/cjs/a/index.js +0 -7
  6. package/dist/cjs/b/Page/common/PageHelmet/PageHelmet.js +4 -1
  7. package/dist/cjs/b/index.js +1 -8
  8. package/dist/cjs/f/fields/EditorInput/EditorInput.js +18 -4
  9. package/dist/cjs/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +8 -4
  10. package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +0 -6
  11. package/dist/cjs/f/fields/EditorInput/styles.scss +9 -2
  12. package/dist/cjs/f/fields/SelectInput/SelectInput.js +9 -2
  13. package/dist/cjs/f/fields/SelectInput/common/Single/Single.js +13 -2
  14. package/dist/cjs/f/fields/SelectInput/styles.scss +1 -1
  15. package/dist/cjs/{b → g}/ExpandableLexicalPreview/ExpandableLexicalPreview.js +59 -47
  16. package/dist/cjs/g/ExpandableLexicalPreview/common/NewWindowPortal/NewWindowPortal.js +79 -0
  17. package/dist/cjs/g/ExpandableLexicalPreview/common/NewWindowPortal/index.js +13 -0
  18. package/dist/cjs/g/ExpandableLexicalPreview/common/NewWindowPortal/styles.scss +9 -0
  19. package/dist/cjs/g/ExpandableLexicalPreview/common/index.js +12 -0
  20. package/dist/cjs/g/ExpandableLexicalPreview/styles.scss +34 -0
  21. package/dist/cjs/g/index.js +12 -0
  22. package/dist/cjs/index.js +11 -0
  23. package/dist/es/a/Label/styles.scss +1 -1
  24. package/dist/es/a/Quote/styles.scss +1 -1
  25. package/dist/es/a/Tooltip/Tooltip.js +21 -5
  26. package/dist/es/a/Tooltip/styles.scss +44 -36
  27. package/dist/es/a/index.js +0 -1
  28. package/dist/es/b/Page/common/PageHelmet/PageHelmet.js +4 -1
  29. package/dist/es/b/index.js +1 -2
  30. package/dist/es/f/fields/EditorInput/EditorInput.js +16 -3
  31. package/dist/es/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +8 -4
  32. package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +0 -6
  33. package/dist/es/f/fields/EditorInput/styles.scss +9 -2
  34. package/dist/es/f/fields/SelectInput/SelectInput.js +9 -2
  35. package/dist/es/f/fields/SelectInput/common/Single/Single.js +12 -1
  36. package/dist/es/f/fields/SelectInput/styles.scss +1 -1
  37. package/dist/es/g/ExpandableLexicalPreview/ExpandableLexicalPreview.js +126 -0
  38. package/dist/es/g/ExpandableLexicalPreview/common/NewWindowPortal/NewWindowPortal.js +70 -0
  39. package/dist/es/g/ExpandableLexicalPreview/common/NewWindowPortal/index.js +2 -0
  40. package/dist/es/g/ExpandableLexicalPreview/common/NewWindowPortal/styles.scss +9 -0
  41. package/dist/es/g/ExpandableLexicalPreview/common/index.js +1 -0
  42. package/dist/es/g/ExpandableLexicalPreview/styles.scss +34 -0
  43. package/dist/es/g/index.js +1 -0
  44. package/dist/es/index.js +1 -0
  45. package/package.json +4 -4
  46. package/src/stories/a/Tooltip.stories.jsx +7 -12
  47. package/src/stories/f/SelectInput.stories.jsx +18 -2
  48. package/src/stories/{b → g}/ExpandableLexicalPreview.stories.jsx +13 -5
  49. package/src/ui/a/Label/styles.scss +1 -1
  50. package/src/ui/a/Quote/styles.scss +1 -1
  51. package/src/ui/a/Tooltip/Tooltip.jsx +27 -4
  52. package/src/ui/a/Tooltip/styles.scss +44 -36
  53. package/src/ui/a/index.js +0 -1
  54. package/src/ui/b/Page/common/PageHelmet/PageHelmet.jsx +6 -0
  55. package/src/ui/b/index.js +0 -1
  56. package/src/ui/f/fields/EditorInput/EditorInput.jsx +14 -1
  57. package/src/ui/f/fields/EditorInput/common/ColorPicker/ColorPicker.jsx +8 -3
  58. package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.jsx +0 -14
  59. package/src/ui/f/fields/EditorInput/styles.scss +9 -2
  60. package/src/ui/f/fields/SelectInput/SelectInput.jsx +10 -2
  61. package/src/ui/f/fields/SelectInput/common/Single/Single.jsx +13 -1
  62. package/src/ui/f/fields/SelectInput/styles.scss +1 -1
  63. package/src/ui/g/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +180 -0
  64. package/src/ui/g/ExpandableLexicalPreview/common/NewWindowPortal/NewWindowPortal.jsx +80 -0
  65. package/src/ui/g/ExpandableLexicalPreview/common/NewWindowPortal/index.js +2 -0
  66. package/src/ui/g/ExpandableLexicalPreview/common/NewWindowPortal/styles.scss +9 -0
  67. package/src/ui/g/ExpandableLexicalPreview/common/index.js +1 -0
  68. package/src/ui/g/ExpandableLexicalPreview/styles.scss +34 -0
  69. package/src/ui/g/index.js +1 -0
  70. package/src/ui/index.js +1 -0
  71. package/tests/__snapshots__/Storyshots.test.js.snap +221 -99
  72. package/dist/cjs/a/LexicalPreview/LexicalPreview.js +0 -90
  73. package/dist/cjs/a/LexicalPreview/index.js +0 -13
  74. package/dist/cjs/a/LexicalPreview/styles.scss +0 -46
  75. package/dist/cjs/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +0 -112
  76. package/dist/cjs/b/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -13
  77. package/dist/cjs/b/ExpandableLexicalPreview/common/index.js +0 -12
  78. package/dist/cjs/b/ExpandableLexicalPreview/styles.scss +0 -84
  79. package/dist/es/a/LexicalPreview/LexicalPreview.js +0 -80
  80. package/dist/es/a/LexicalPreview/index.js +0 -2
  81. package/dist/es/a/LexicalPreview/styles.scss +0 -46
  82. package/dist/es/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +0 -115
  83. package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +0 -102
  84. package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -1
  85. package/dist/es/b/ExpandableLexicalPreview/common/index.js +0 -1
  86. package/dist/es/b/ExpandableLexicalPreview/styles.scss +0 -84
  87. package/src/stories/a/LexicalPreview.stories.jsx +0 -28
  88. package/src/ui/a/LexicalPreview/LexicalPreview.jsx +0 -109
  89. package/src/ui/a/LexicalPreview/index.js +0 -2
  90. package/src/ui/a/LexicalPreview/styles.scss +0 -46
  91. package/src/ui/b/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +0 -157
  92. package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.jsx +0 -123
  93. package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -1
  94. package/src/ui/b/ExpandableLexicalPreview/common/index.js +0 -1
  95. package/src/ui/b/ExpandableLexicalPreview/styles.scss +0 -84
  96. /package/dist/cjs/{b → g}/ExpandableLexicalPreview/index.js +0 -0
  97. /package/dist/es/{b → g}/ExpandableLexicalPreview/index.js +0 -0
  98. /package/src/ui/{b → g}/ExpandableLexicalPreview/index.js +0 -0
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactDom = require("react-dom");
8
+ var _react = require("react");
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
11
+ var _a = require("../../../../a");
12
+ require("./styles.scss");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ /* @pareto-engineering/generator-front 1.0.12 */
15
+
16
+ // Local Definitions
17
+
18
+ const baseClassName = _exports.default.base;
19
+ const copyStyles = (sourceDocument, targetDocument) => {
20
+ Array.from(sourceDocument.querySelectorAll('link[rel="stylesheet"], style')).forEach(link => {
21
+ targetDocument.head.appendChild(link.cloneNode(true));
22
+ });
23
+ };
24
+ /**
25
+ * This is the component description.
26
+ */
27
+ const NewWindowPortal = _ref => {
28
+ let {
29
+ children,
30
+ pageTitle,
31
+ onBlock,
32
+ onOpen
33
+ } = _ref;
34
+ const [newWindow, setNewWindow] = (0, _react.useState)(null);
35
+ const container = (0, _react.useMemo)(() => document.createElement('div'), []);
36
+ const {
37
+ userTheme = 'light'
38
+ } = (0, _a.useTheme)();
39
+ (0, _react.useEffect)(() => {
40
+ if (!container) return;
41
+ container.classList.add(baseClassName, 'new-window-portal', `ui-${userTheme}`);
42
+ const newExternalWindow = window.open('', pageTitle, 'width="100%",height="100%"');
43
+ if (newExternalWindow) {
44
+ newExternalWindow.document.title = pageTitle;
45
+ newExternalWindow.document.body.appendChild(container);
46
+ setNewWindow(newExternalWindow);
47
+ onOpen();
48
+ } else {
49
+ console.warn('A new window / tab could not be opened. Check your settings and/or extensions, maybe it was blocked.');
50
+ onBlock();
51
+ }
52
+
53
+ // eslint-disable-next-line consistent-return
54
+ return () => {
55
+ container.classList.remove(...container.classList);
56
+ newExternalWindow?.close();
57
+ };
58
+ }, [container, pageTitle, userTheme]);
59
+ (0, _react.useEffect)(() => {
60
+ if (newWindow) {
61
+ copyStyles(document, newWindow.document);
62
+ }
63
+ }, [newWindow]);
64
+ return /*#__PURE__*/(0, _reactDom.createPortal)(children, container);
65
+ };
66
+ NewWindowPortal.propTypes = {
67
+ /**
68
+ * The children JSX
69
+ */
70
+ children: _propTypes.default.node,
71
+ /**
72
+ * The new window page title
73
+ */
74
+ pageTitle: _propTypes.default.string.isRequired
75
+ };
76
+ NewWindowPortal.defaultProps = {
77
+ // someProp:false
78
+ };
79
+ var _default = exports.default = NewWindowPortal;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "NewWindowPortal", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _NewWindowPortal.default;
10
+ }
11
+ });
12
+ var _NewWindowPortal = _interopRequireDefault(require("./NewWindowPortal"));
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,9 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ .#{bem.$base}.new-window-portal {
6
+ background-color: var(--background-far);
7
+ height: 100%;
8
+ width: 100%;
9
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "NewWindowPortal", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _NewWindowPortal.NewWindowPortal;
10
+ }
11
+ });
12
+ var _NewWindowPortal = require("./NewWindowPortal");
@@ -0,0 +1,34 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ .#{bem.$base}.expandable-lexical-preview {
6
+ display: flex;
7
+ flex-direction: column;
8
+ flex-wrap: wrap;
9
+ gap: var(--gap);
10
+ position: relative;
11
+ width: 100%;
12
+
13
+
14
+ &.collapsed {
15
+ flex-direction: row;
16
+ }
17
+
18
+ > .title {
19
+ margin: 0;
20
+ }
21
+
22
+ > .#{bem.$base}.button {
23
+ align-items: center;
24
+ border: 1px solid var(--outline-inputs);
25
+ display: flex;
26
+ }
27
+
28
+ > .#{bem.$base}.expand-button {
29
+ border: 1px solid var(--outline-inputs);
30
+ position: absolute;
31
+ right: 1em;
32
+ top: 5.5rem;
33
+ }
34
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ExpandableLexicalPreview", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _ExpandableLexicalPreview.ExpandableLexicalPreview;
10
+ }
11
+ });
12
+ var _ExpandableLexicalPreview = require("./ExpandableLexicalPreview");
package/dist/cjs/index.js CHANGED
@@ -58,6 +58,17 @@ Object.keys(_f).forEach(function (key) {
58
58
  }
59
59
  });
60
60
  });
61
+ var _g = require("./g");
62
+ Object.keys(_g).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _g[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _g[key];
69
+ }
70
+ });
71
+ });
61
72
  var _utils = require("./utils");
62
73
  Object.keys(_utils).forEach(function (key) {
63
74
  if (key === "default" || key === "__esModule") return;
@@ -20,9 +20,9 @@ $default-font-size: calc(1em * var(--s-1));
20
20
  color: var(--on-x, var(--on-#{$default-color}));
21
21
  display: inline-flex;
22
22
  font-size: $default-font-size;
23
+ gap: calc(var(--gap) / 2);
23
24
  padding: $default-padding;
24
25
  white-space: nowrap;
25
-
26
26
  &.#{bem.$modifier-compact} {
27
27
  padding: $compact-padding;
28
28
  }
@@ -4,7 +4,7 @@
4
4
  @use "@pareto-engineering/styles/src/mixins";
5
5
  @use "@pareto-engineering/styles/src/globals" as *;
6
6
 
7
- $default-gap: 1.5rem;
7
+ $default-gap: 3rem;
8
8
 
9
9
  .#{bem.$base}.quote {
10
10
  border-left: 3px solid var(--x);
@@ -18,14 +18,22 @@ const Tooltip = ({
18
18
  style,
19
19
  position,
20
20
  color,
21
+ description,
22
+ content,
21
23
  children
22
24
  // ...otherProps
23
25
  }) => /*#__PURE__*/React.createElement("div", {
24
26
  id: id,
25
- className: [baseClassName, componentClassName, userClassName, position, `x-${color}`].filter(e => e).join(' '),
26
- style: style,
27
- role: "tooltip"
28
- }, children);
27
+ className: [baseClassName, componentClassName, userClassName, `x-${color}`].filter(e => e).join(' '),
28
+ style: style
29
+ }, /*#__PURE__*/React.createElement("div", {
30
+ className: "tooltip-trigger-wrapper",
31
+ "aria-describedby": description
32
+ }, children), /*#__PURE__*/React.createElement("div", {
33
+ className: `tooltip-content ${position}`,
34
+ role: "tooltip",
35
+ id: description
36
+ }, content));
29
37
  Tooltip.propTypes = {
30
38
  /**
31
39
  * The HTML id for this element
@@ -40,9 +48,17 @@ Tooltip.propTypes = {
40
48
  */
41
49
  style: PropTypes.objectOf(PropTypes.string),
42
50
  /**
43
- * The children JSX
51
+ * The children JSX where the tooltip will be applied
44
52
  */
45
53
  children: PropTypes.node.isRequired,
54
+ /**
55
+ * The content JSX that renders the tooltip content
56
+ */
57
+ content: PropTypes.node.isRequired,
58
+ /**
59
+ * The text description to identify the element that describes the tooltip
60
+ */
61
+ description: PropTypes.string.isRequired,
46
62
  /**
47
63
  * The position of the tooltip with respect to the trigger element
48
64
  */
@@ -7,47 +7,55 @@ $default-inline-padding: var(--theme-default-padding);
7
7
  $default-width: var(--tooltip-width, 20rem);
8
8
 
9
9
  .#{bem.$base}.tooltip {
10
- background: var(--x);
11
- border: var(--theme-default-border-style) var(--ui-lines);
12
- border-radius: calc(var(--theme-default-border-radius) / 2);
13
- opacity: 0;
14
- padding: $default-block-padding $default-inline-padding;
15
- position: absolute;
16
- transform: translateX(var(--horizontal, 0)) translateY(var(--vertical, 0));
17
- transition: opacity .2s ease, transform .2s ease;
18
- width: $default-width;
19
- z-index: 10;
20
-
21
- :has(> &) {
22
- position: relative;
23
-
24
- &:is(:hover, :focus-visible, :active) > .#{bem.$base}.tooltip {
25
- opacity: 1;
26
- transition-delay: 200ms;
10
+ display: inline-block;
11
+ position: relative;
12
+
13
+ > .tooltip-content {
14
+ background: var(--x);
15
+ border: var(--theme-default-border-style) var(--ui-lines);
16
+ border-radius: calc(var(--theme-default-border-radius) / 2);
17
+ opacity: 0;
18
+ overflow: hidden;
19
+ padding: $default-block-padding $default-inline-padding;
20
+ position: absolute;
21
+ transform: translateX(var(--horizontal, 0)) translateY(var(--vertical, 0));
22
+ transition: opacity .2s ease, transform .2s ease;
23
+ visibility: hidden;
24
+ width: $default-width;
25
+ z-index: 10;
26
+
27
+ &.top {
28
+ --horizontal: -50%;
29
+ bottom: calc(100% + $default-block-padding);
30
+ left: 50%;
27
31
  }
28
- }
29
32
 
30
- &.top {
31
- --horizontal: -50%;
32
- bottom: calc(100% + $default-block-padding);
33
- left: 50%;
34
- }
33
+ &.right {
34
+ --vertical: 50%;
35
+ bottom: 50%;
36
+ left: calc(100% + $default-inline-padding);
37
+ }
35
38
 
36
- &.right {
37
- --vertical: 50%;
38
- bottom: 50%;
39
- left: calc(100% + $default-inline-padding);
40
- }
39
+ &.bottom {
40
+ --horizontal: -50%;
41
+ left: 50%;
42
+ top: calc(100% + $default-block-padding);
43
+ }
41
44
 
42
- &.bottom {
43
- --horizontal: -50%;
44
- left: 50%;
45
- top: calc(100% + $default-block-padding);
45
+ &.left {
46
+ --vertical: 50%;
47
+ bottom: 50%;
48
+ right: calc(100% + $default-inline-padding);
49
+ }
46
50
  }
47
51
 
48
- &.left {
49
- --vertical: 50%;
50
- bottom: 50%;
51
- right: calc(100% + $default-inline-padding);
52
+ > .tooltip-trigger-wrapper {
53
+ cursor: pointer;
54
+
55
+ &:is(:hover, :focus-visible, :active) + .tooltip-content {
56
+ opacity: 1;
57
+ transition-delay: 200ms;
58
+ visibility: visible;
59
+ }
52
60
  }
53
61
  }
@@ -24,6 +24,5 @@ export { TextSteps } from "./TextSteps";
24
24
  export { Removable } from "./Removable";
25
25
  export { ToggleSwitch } from "./ToggleSwitch";
26
26
  export { XMLEditor } from "./XMLEditor";
27
- export { LexicalPreview } from "./LexicalPreview";
28
27
  export { DatePicker } from "./DatePicker";
29
28
  export { Tooltip } from "./Tooltip";
@@ -110,6 +110,7 @@ const helmetMap = [{
110
110
  })
111
111
  }];
112
112
  const PageHelmet = ({
113
+ jsonld,
113
114
  ...props
114
115
  }) => {
115
116
  // const intl = useIntl()
@@ -150,7 +151,9 @@ const PageHelmet = ({
150
151
  }, []), [props, context]);
151
152
  return /*#__PURE__*/React.createElement(Helmet, {
152
153
  key: props.title
153
- }, HelmetContent);
154
+ }, HelmetContent, jsonld && /*#__PURE__*/React.createElement("script", {
155
+ type: "application/ld+json"
156
+ }, `${JSON.stringify(jsonld)}`));
154
157
  };
155
158
  PageHelmet.propTypes = {
156
159
  robots: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
@@ -4,5 +4,4 @@ export { Page } from "./Page";
4
4
  export { SocialMediaButton } from "./SocialMediaButton";
5
5
  export { ThemeSelector } from "./ThemeSelector";
6
6
  export { Title } from "./Title";
7
- export { Card } from "./Card";
8
- export { ExpandableLexicalPreview } from "./ExpandableLexicalPreview";
7
+ export { Card } from "./Card";
@@ -1,7 +1,7 @@
1
1
  /* @pareto-engineering/generator-front 1.0.12 */
2
2
  /* eslint-disable import/no-extraneous-dependencies -- required here */
3
3
  import * as React from 'react';
4
- import { memo } from 'react';
4
+ import { memo, useEffect } from 'react';
5
5
  import { useFormikContext } from 'formik';
6
6
  import { LexicalComposer } from '@lexical/react/LexicalComposer';
7
7
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
@@ -18,6 +18,7 @@ import { ListItemNode, ListNode } from '@lexical/list';
18
18
  import { CheckListPlugin } from '@lexical/react/LexicalCheckListPlugin';
19
19
  import { HeadingNode, QuoteNode } from '@lexical/rich-text';
20
20
  import { CodeHighlightNode, CodeNode } from '@lexical/code';
21
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
21
22
  import PropTypes from 'prop-types';
22
23
  import styleNames from '@pareto-engineering/bem/exports';
23
24
 
@@ -28,6 +29,15 @@ import { ToolbarPlugin, TreeViewPlugin, StopPropagationPlugin } from "./common";
28
29
  import "./styles.scss";
29
30
  const baseClassName = styleNames.base;
30
31
  const componentClassName = 'editor-input';
32
+ const ExposeEditorStatePlugin = ({
33
+ setEditorState
34
+ }) => {
35
+ const [editor] = useLexicalComposerContext();
36
+ useEffect(() => {
37
+ setEditorState(editor);
38
+ }, [editor]);
39
+ return null;
40
+ };
31
41
 
32
42
  /**
33
43
  * This is the component description.
@@ -47,7 +57,8 @@ const EditorInput = ({
47
57
  description,
48
58
  disabled,
49
59
  showDebugger,
50
- stopPropagationKeys
60
+ stopPropagationKeys,
61
+ setEditorState
51
62
  // ...otherProps
52
63
  }) => {
53
64
  const formik = useFormikContext();
@@ -132,7 +143,9 @@ const EditorInput = ({
132
143
  ErrorBoundary: LexicalErrorBoundary
133
144
  }), /*#__PURE__*/React.createElement(ListPlugin, null), /*#__PURE__*/React.createElement(CheckListPlugin, null), /*#__PURE__*/React.createElement(OnChangePlugin, {
134
145
  onChange: onChange
135
- }), /*#__PURE__*/React.createElement(LinkPlugin, null), /*#__PURE__*/React.createElement(LexicalClickableLinkPlugin, null), /*#__PURE__*/React.createElement(TabIndentationPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, null), stopPropagationKeys && /*#__PURE__*/React.createElement(StopPropagationPlugin, {
146
+ }), /*#__PURE__*/React.createElement(LinkPlugin, null), /*#__PURE__*/React.createElement(LexicalClickableLinkPlugin, null), /*#__PURE__*/React.createElement(TabIndentationPlugin, null), setEditorState && /*#__PURE__*/React.createElement(ExposeEditorStatePlugin, {
147
+ setEditorState: setEditorState
148
+ }), /*#__PURE__*/React.createElement(HistoryPlugin, null), stopPropagationKeys && /*#__PURE__*/React.createElement(StopPropagationPlugin, {
136
149
  stopPropagationKeys: stopPropagationKeys
137
150
  }), /*#__PURE__*/React.createElement(FormDescription, {
138
151
  className: "s-1",
@@ -20,11 +20,11 @@ const ColorPicker = ({
20
20
  className: userClassName,
21
21
  style,
22
22
  icon,
23
- color,
23
+ defaultColorHex,
24
24
  onChange
25
25
  // ...otherProps
26
26
  }) => {
27
- const [colorValue, setColor] = useColor(color);
27
+ const [colorValue, setColor] = useColor(defaultColorHex);
28
28
  const parentRef = useRef(null);
29
29
  const [isOpen, setIsOpen] = useState(false);
30
30
  useOutsideClick(parentRef, () => setIsOpen(false));
@@ -75,9 +75,13 @@ ColorPicker.propTypes = {
75
75
  /**
76
76
  * The React-written, css properties for this element.
77
77
  */
78
- style: PropTypes.objectOf(PropTypes.string)
78
+ style: PropTypes.objectOf(PropTypes.string),
79
+ /**
80
+ * The required default hex value for the color picker
81
+ */
82
+ defaultColorHex: PropTypes.string
79
83
  };
80
84
  ColorPicker.defaultProps = {
81
- // someProp:false
85
+ defaultColorHex: '#ffffff'
82
86
  };
83
87
  export default ColorPicker;
@@ -61,8 +61,6 @@ const ToolbarPlugin = ({
61
61
  const [activeEditor, setActiveEditor] = useState(editor);
62
62
  const [blockType, setBlockType] = useState('paragraph');
63
63
  const [rootType, setRootType] = useState('root');
64
- const [fontColor, setFontColor] = useState('#000000');
65
- const [bgColor, setBgColor] = useState('#ffffff');
66
64
  const [fontSize, setFontSize] = useState('15px');
67
65
  const [isEditable, setIsEditable] = useState(() => editor.isEditable());
68
66
  const [isBold, setIsBold] = useState(false);
@@ -128,8 +126,6 @@ const ToolbarPlugin = ({
128
126
  }
129
127
  }
130
128
  setFontSize($getSelectionStyleValueForProperty(selection, 'font-size', '15px'));
131
- setFontColor($getSelectionStyleValueForProperty(selection, 'color', '#000'));
132
- setBgColor($getSelectionStyleValueForProperty(selection, 'background-color', '#fff'));
133
129
  }
134
130
  }, [activeEditor]);
135
131
  useEffect(() => editor.registerCommand(SELECTION_CHANGE_COMMAND, (_payload, newEditor) => {
@@ -229,11 +225,9 @@ const ToolbarPlugin = ({
229
225
  className: "group"
230
226
  }, /*#__PURE__*/React.createElement(ColorPicker, {
231
227
  icon: "'",
232
- color: fontColor,
233
228
  onChange: onFontColorSelect
234
229
  }), /*#__PURE__*/React.createElement(ColorPicker, {
235
230
  icon: "#",
236
- color: bgColor,
237
231
  onChange: onBgColorSelect
238
232
  })), /*#__PURE__*/React.createElement("div", {
239
233
  className: "group"
@@ -32,6 +32,11 @@ $default-check-mark-dimensions: 1rem;
32
32
  border: $focus-border;
33
33
  }
34
34
  }
35
+
36
+ > .content-editable {
37
+ border-bottom-left-radius: $default-input-border-radius;
38
+ border-bottom-right-radius: $default-input-border-radius;
39
+ }
35
40
  }
36
41
 
37
42
  &.disabled {
@@ -40,6 +45,10 @@ $default-check-mark-dimensions: 1rem;
40
45
  color: var(--metadata);
41
46
  cursor: not-allowed;
42
47
  }
48
+
49
+ > .content-editable {
50
+ border-radius: $default-input-border-radius;
51
+ }
43
52
  }
44
53
 
45
54
  .color-menu-button {
@@ -70,8 +79,6 @@ $default-check-mark-dimensions: 1rem;
70
79
  > .content-editable {
71
80
  background: $default-background;
72
81
  border: $default-border;
73
- border-bottom-left-radius: $default-input-border-radius;
74
- border-bottom-right-radius: $default-input-border-radius;
75
82
  color: var(--y);
76
83
  height: var(--rows);
77
84
  outline: none;
@@ -23,6 +23,7 @@ const SelectInput = ({
23
23
  labelColor,
24
24
  color,
25
25
  options,
26
+ hasDefault,
26
27
  validate,
27
28
  optional,
28
29
  description,
@@ -40,6 +41,7 @@ const SelectInput = ({
40
41
  labelColor,
41
42
  color,
42
43
  options,
44
+ hasDefault,
43
45
  validate,
44
46
  optional,
45
47
  description,
@@ -124,10 +126,15 @@ SelectInput.propTypes = {
124
126
  /**
125
127
  * The placeholder of the select input
126
128
  */
127
- placeholder: PropTypes.string
129
+ placeholder: PropTypes.string,
130
+ /**
131
+ * Whether this select input has a default value(s)
132
+ */
133
+ hasDefault: PropTypes.bool
128
134
  };
129
135
  SelectInput.defaultProps = {
130
136
  disabled: false,
131
- multiple: false
137
+ multiple: false,
138
+ hasDefault: false
132
139
  };
133
140
  export default /*#__PURE__*/memo(SelectInput);
@@ -1,6 +1,7 @@
1
1
  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); }
2
2
  /* @pareto-engineering/generator-front 1.0.12 */
3
3
  import * as React from 'react';
4
+ import { useEffect } from 'react';
4
5
  import { useField } from 'formik';
5
6
  import PropTypes from 'prop-types';
6
7
  import styleNames from '@pareto-engineering/bem/exports';
@@ -24,6 +25,7 @@ const Single = ({
24
25
  labelColor,
25
26
  color,
26
27
  options,
28
+ hasDefault,
27
29
  validate,
28
30
  optional,
29
31
  description,
@@ -32,10 +34,19 @@ const Single = ({
32
34
  autoComplete
33
35
  // ...otherProps
34
36
  }) => {
35
- const [field] = useField({
37
+ const [field,, helpers] = useField({
36
38
  name,
37
39
  validate
38
40
  });
41
+ const {
42
+ setValue
43
+ } = helpers;
44
+ useEffect(() => {
45
+ if (hasDefault && !field.value) {
46
+ const defaultOption = options.find(option => option.isDefault);
47
+ setValue(defaultOption?.value);
48
+ }
49
+ }, [hasDefault]);
39
50
  return /*#__PURE__*/React.createElement("div", {
40
51
  id: id,
41
52
  className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
@@ -83,7 +83,7 @@ $default-gap: var(--gap);
83
83
 
84
84
  /* stylelint-disable-next-line max-nesting-depth -- required */
85
85
  &:disabled {
86
- opacity: 0%;
86
+ background: transparent;
87
87
  }
88
88
  }
89
89
  }