@pareto-engineering/design-system 4.0.0-alpha.70 → 4.0.0-alpha.73

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 (125) hide show
  1. package/dist/cjs/{c/ContentSlides/common/Slide/Slide.js → a/LexicalPreview/LexicalPreview.js} +43 -28
  2. package/dist/cjs/{c/ContentSlides/common/Sidebar → a/LexicalPreview}/index.js +3 -3
  3. package/dist/cjs/a/LexicalPreview/styles.scss +46 -0
  4. package/dist/cjs/a/People/common/Person/Person.js +7 -2
  5. package/dist/cjs/a/ProgressBar/ProgressBar.js +3 -2
  6. package/dist/cjs/a/ProgressBar/styles.scss +11 -1
  7. package/dist/cjs/a/XMLEditor/XMLEditor.js +14 -6
  8. package/dist/cjs/a/index.js +8 -1
  9. package/dist/cjs/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +125 -0
  10. package/dist/cjs/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +112 -0
  11. package/dist/cjs/{c/ContentSlides/common/Navigator → b/ExpandableLexicalPreview/common/ExpandButton}/index.js +3 -3
  12. package/dist/cjs/b/ExpandableLexicalPreview/common/index.js +12 -0
  13. package/dist/cjs/b/ExpandableLexicalPreview/index.js +13 -0
  14. package/dist/cjs/b/ExpandableLexicalPreview/styles.scss +84 -0
  15. package/dist/cjs/b/index.js +8 -1
  16. package/dist/cjs/c/index.js +0 -13
  17. package/dist/cjs/f/fields/EditorInput/EditorInput.js +14 -3
  18. package/dist/cjs/f/fields/EditorInput/common/StopPropagationPlugin.js +30 -0
  19. package/dist/cjs/f/fields/EditorInput/common/index.js +7 -0
  20. package/dist/cjs/index.js +0 -11
  21. package/dist/es/a/LexicalPreview/LexicalPreview.js +80 -0
  22. package/dist/es/a/LexicalPreview/index.js +2 -0
  23. package/dist/es/a/LexicalPreview/styles.scss +46 -0
  24. package/dist/es/a/People/common/Person/Person.js +22 -15
  25. package/dist/es/a/ProgressBar/ProgressBar.js +3 -2
  26. package/dist/es/a/ProgressBar/styles.scss +11 -1
  27. package/dist/es/a/XMLEditor/XMLEditor.js +16 -10
  28. package/dist/es/a/index.js +2 -1
  29. package/dist/es/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +115 -0
  30. package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +102 -0
  31. package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/index.js +1 -0
  32. package/dist/es/b/ExpandableLexicalPreview/common/index.js +1 -0
  33. package/dist/es/b/ExpandableLexicalPreview/index.js +2 -0
  34. package/dist/es/b/ExpandableLexicalPreview/styles.scss +84 -0
  35. package/dist/es/b/index.js +2 -1
  36. package/dist/es/c/index.js +0 -1
  37. package/dist/es/f/fields/EditorInput/EditorInput.js +15 -4
  38. package/dist/es/f/fields/EditorInput/common/StopPropagationPlugin.js +23 -0
  39. package/dist/es/f/fields/EditorInput/common/index.js +2 -1
  40. package/dist/es/index.js +0 -1
  41. package/package.json +5 -5
  42. package/src/stories/a/LexicalPreview.stories.jsx +28 -0
  43. package/src/stories/a/ProgressBar.stories.jsx +1 -1
  44. package/src/stories/b/ExpandableLexicalPreview.stories.jsx +29 -0
  45. package/src/stories/colors.js +4 -0
  46. package/src/ui/a/LexicalPreview/LexicalPreview.jsx +109 -0
  47. package/src/ui/a/LexicalPreview/index.js +2 -0
  48. package/src/ui/a/LexicalPreview/styles.scss +46 -0
  49. package/src/ui/a/People/common/Person/Person.jsx +31 -19
  50. package/src/ui/a/ProgressBar/ProgressBar.jsx +2 -0
  51. package/src/ui/a/ProgressBar/styles.scss +11 -1
  52. package/src/ui/a/XMLEditor/XMLEditor.jsx +16 -5
  53. package/src/ui/a/index.js +1 -0
  54. package/src/ui/b/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +157 -0
  55. package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.jsx +123 -0
  56. package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/index.js +1 -0
  57. package/src/ui/b/ExpandableLexicalPreview/common/index.js +1 -0
  58. package/src/ui/b/ExpandableLexicalPreview/index.js +2 -0
  59. package/src/ui/b/ExpandableLexicalPreview/styles.scss +84 -0
  60. package/src/ui/b/index.js +1 -0
  61. package/src/ui/c/index.js +0 -1
  62. package/src/ui/f/fields/EditorInput/EditorInput.jsx +16 -2
  63. package/src/ui/f/fields/EditorInput/common/StopPropagationPlugin.jsx +29 -0
  64. package/src/ui/f/fields/EditorInput/common/index.jsx +1 -0
  65. package/src/ui/index.js +0 -1
  66. package/tests/__snapshots__/Storyshots.test.js.snap +1249 -641
  67. package/dist/cjs/c/ContentSlides/ContentSlides.js +0 -172
  68. package/dist/cjs/c/ContentSlides/Context.js +0 -10
  69. package/dist/cjs/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.js +0 -126
  70. package/dist/cjs/c/ContentSlides/common/HorizontalMenu/index.js +0 -13
  71. package/dist/cjs/c/ContentSlides/common/Navigator/Navigator.js +0 -128
  72. package/dist/cjs/c/ContentSlides/common/Sidebar/Sidebar.js +0 -94
  73. package/dist/cjs/c/ContentSlides/common/Slide/index.js +0 -13
  74. package/dist/cjs/c/ContentSlides/common/index.js +0 -33
  75. package/dist/cjs/c/ContentSlides/index.js +0 -27
  76. package/dist/cjs/c/ContentSlides/styles.scss +0 -312
  77. package/dist/cjs/c/ContentSlides/useContentSlides.js +0 -11
  78. package/dist/cjs/r/SwitchRouteMap/SwitchRouteMap.js +0 -58
  79. package/dist/cjs/r/SwitchRouteMap/index.js +0 -13
  80. package/dist/cjs/r/common/PrivateRoute/PrivateRoute.js +0 -74
  81. package/dist/cjs/r/common/PrivateRoute/index.js +0 -13
  82. package/dist/cjs/r/common/index.js +0 -12
  83. package/dist/cjs/r/index.js +0 -27
  84. package/dist/es/c/ContentSlides/ContentSlides.js +0 -160
  85. package/dist/es/c/ContentSlides/Context.js +0 -2
  86. package/dist/es/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.js +0 -116
  87. package/dist/es/c/ContentSlides/common/HorizontalMenu/index.js +0 -2
  88. package/dist/es/c/ContentSlides/common/Navigator/Navigator.js +0 -118
  89. package/dist/es/c/ContentSlides/common/Navigator/index.js +0 -2
  90. package/dist/es/c/ContentSlides/common/Sidebar/Sidebar.js +0 -84
  91. package/dist/es/c/ContentSlides/common/Sidebar/index.js +0 -2
  92. package/dist/es/c/ContentSlides/common/Slide/Slide.js +0 -65
  93. package/dist/es/c/ContentSlides/common/Slide/index.js +0 -2
  94. package/dist/es/c/ContentSlides/common/index.js +0 -4
  95. package/dist/es/c/ContentSlides/index.js +0 -4
  96. package/dist/es/c/ContentSlides/styles.scss +0 -312
  97. package/dist/es/c/ContentSlides/useContentSlides.js +0 -3
  98. package/dist/es/r/SwitchRouteMap/SwitchRouteMap.js +0 -45
  99. package/dist/es/r/SwitchRouteMap/index.js +0 -2
  100. package/dist/es/r/common/PrivateRoute/PrivateRoute.js +0 -66
  101. package/dist/es/r/common/PrivateRoute/index.js +0 -2
  102. package/dist/es/r/common/index.js +0 -1
  103. package/dist/es/r/index.js +0 -2
  104. package/src/stories/c/ContentSlides.stories.jsx +0 -214
  105. package/src/ui/c/ContentSlides/ContentSlides.jsx +0 -214
  106. package/src/ui/c/ContentSlides/Context.js +0 -3
  107. package/src/ui/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.jsx +0 -145
  108. package/src/ui/c/ContentSlides/common/HorizontalMenu/index.js +0 -2
  109. package/src/ui/c/ContentSlides/common/Navigator/Navigator.jsx +0 -150
  110. package/src/ui/c/ContentSlides/common/Navigator/index.js +0 -2
  111. package/src/ui/c/ContentSlides/common/Sidebar/Sidebar.jsx +0 -135
  112. package/src/ui/c/ContentSlides/common/Sidebar/index.js +0 -2
  113. package/src/ui/c/ContentSlides/common/Slide/Slide.jsx +0 -87
  114. package/src/ui/c/ContentSlides/common/Slide/index.js +0 -2
  115. package/src/ui/c/ContentSlides/common/index.js +0 -4
  116. package/src/ui/c/ContentSlides/index.js +0 -4
  117. package/src/ui/c/ContentSlides/styles.scss +0 -312
  118. package/src/ui/c/ContentSlides/useContentSlides.js +0 -4
  119. package/src/ui/r/SwitchRouteMap/SwitchRouteMap.jsx +0 -64
  120. package/src/ui/r/SwitchRouteMap/index.js +0 -2
  121. package/src/ui/r/common/PrivateRoute/PrivateRoute.jsx +0 -73
  122. package/src/ui/r/common/PrivateRoute/index.js +0 -2
  123. package/src/ui/r/common/index.js +0 -1
  124. package/src/ui/r/index.js +0 -2
  125. /package/src/stories/a/{CodeEditor.stories.jsx → XMLEditor.stories.jsx} +0 -0
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "Card", {
15
15
  return _Card.Card;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "ExpandableLexicalPreview", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _ExpandableLexicalPreview.ExpandableLexicalPreview;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "Logo", {
19
25
  enumerable: true,
20
26
  get: function () {
@@ -51,4 +57,5 @@ var _Page = require("./Page");
51
57
  var _SocialMediaButton = require("./SocialMediaButton");
52
58
  var _ThemeSelector = require("./ThemeSelector");
53
59
  var _Title = require("./Title");
54
- var _Card = require("./Card");
60
+ var _Card = require("./Card");
61
+ var _ExpandableLexicalPreview = require("./ExpandableLexicalPreview");
@@ -3,12 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "ContentSlides", {
7
- enumerable: true,
8
- get: function () {
9
- return _ContentSlides.ContentSlides;
10
- }
11
- });
12
6
  Object.defineProperty(exports, "Modal", {
13
7
  enumerable: true,
14
8
  get: function () {
@@ -27,13 +21,6 @@ Object.defineProperty(exports, "SocialMediaShareButton", {
27
21
  return _SocialMediaShareButton.SocialMediaShareButton;
28
22
  }
29
23
  });
30
- Object.defineProperty(exports, "useContentSlides", {
31
- enumerable: true,
32
- get: function () {
33
- return _ContentSlides.useContentSlides;
34
- }
35
- });
36
- var _ContentSlides = require("./ContentSlides");
37
24
  var _Shortener = require("./Shortener");
38
25
  var _SocialMediaShareButton = require("./SocialMediaShareButton");
39
26
  var _Modal = require("./Modal");
@@ -51,7 +51,8 @@ const EditorInput = _ref => {
51
51
  labelColor,
52
52
  description,
53
53
  disabled,
54
- showDebugger
54
+ showDebugger,
55
+ stopPropagationKeys
55
56
  // ...otherProps
56
57
  } = _ref;
57
58
  const formik = (0, _formik.useFormikContext)();
@@ -130,7 +131,9 @@ const EditorInput = _ref => {
130
131
  })
131
132
  }), /*#__PURE__*/React.createElement(_LexicalOnChangePlugin.OnChangePlugin, {
132
133
  onChange: onChange
133
- }), /*#__PURE__*/React.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/React.createElement(_LexicalListPlugin.ListPlugin, null), /*#__PURE__*/React.createElement(_LexicalTabIndentationPlugin.TabIndentationPlugin, null), /*#__PURE__*/React.createElement(_LexicalHistoryPlugin.HistoryPlugin, null), /*#__PURE__*/React.createElement(_common.FormDescription, {
134
+ }), /*#__PURE__*/React.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/React.createElement(_LexicalListPlugin.ListPlugin, null), /*#__PURE__*/React.createElement(_LexicalTabIndentationPlugin.TabIndentationPlugin, null), /*#__PURE__*/React.createElement(_LexicalHistoryPlugin.HistoryPlugin, null), stopPropagationKeys && /*#__PURE__*/React.createElement(_common2.StopPropagationPlugin, {
135
+ stopPropagationKeys: stopPropagationKeys
136
+ }), /*#__PURE__*/React.createElement(_common.FormDescription, {
134
137
  className: "s-1",
135
138
  description: description,
136
139
  name: name
@@ -189,7 +192,15 @@ EditorInput.propTypes = {
189
192
  /**
190
193
  * The resize property of the text area
191
194
  */
192
- resize: _propTypes.default.oneOf(['none', 'both', 'horizontal', 'vertical'])
195
+ resize: _propTypes.default.oneOf(['none', 'both', 'horizontal', 'vertical']),
196
+ /**
197
+ * Whether to show the debugger or not
198
+ */
199
+ showDebugger: _propTypes.default.bool,
200
+ /**
201
+ * Map to stop propagation of the given keys
202
+ */
203
+ stopPropagationKeys: _propTypes.default.arrayOf(_propTypes.default.string)
193
204
  };
194
205
  EditorInput.defaultProps = {
195
206
  rows: 10,
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
9
+ const StopPropagationPlugin = _ref => {
10
+ let {
11
+ stopPropagationKeys
12
+ } = _ref;
13
+ const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
14
+ (0, _react.useInsertionEffect)(() => {
15
+ const onKeyDown = e => {
16
+ if (stopPropagationKeys?.includes(e.key)) {
17
+ e.stopPropagation();
18
+ }
19
+ };
20
+ return editor.registerRootListener((rootElement, prevRootElement) => {
21
+ if (prevRootElement !== null) {
22
+ prevRootElement.removeEventListener('keydown', onKeyDown);
23
+ }
24
+ if (rootElement !== null) {
25
+ rootElement.addEventListener('keydown', onKeyDown);
26
+ }
27
+ });
28
+ }, [editor]);
29
+ };
30
+ var _default = exports.default = StopPropagationPlugin;
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "StopPropagationPlugin", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _StopPropagationPlugin.default;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "Toolbar", {
7
13
  enumerable: true,
8
14
  get: function () {
@@ -17,4 +23,5 @@ Object.defineProperty(exports, "TreeViewPlugin", {
17
23
  });
18
24
  var _Toolbar = _interopRequireDefault(require("./Toolbar"));
19
25
  var _TreeViewPlugin = _interopRequireDefault(require("./TreeViewPlugin"));
26
+ var _StopPropagationPlugin = _interopRequireDefault(require("./StopPropagationPlugin"));
20
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
package/dist/cjs/index.js CHANGED
@@ -3,17 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _r = require("./r");
7
- Object.keys(_r).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _r[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _r[key];
14
- }
15
- });
16
- });
17
6
  var _a = require("./a");
18
7
  Object.keys(_a).forEach(function (key) {
19
8
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,80 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ /* eslint-disable import/no-extraneous-dependencies -- required here */
3
+ import * as React from 'react';
4
+ import { LexicalComposer } from '@lexical/react/LexicalComposer';
5
+ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
6
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable';
7
+ import { AutoLinkNode, LinkNode } from '@lexical/link';
8
+ import { ListItemNode, ListNode } from '@lexical/list';
9
+ import PropTypes from 'prop-types';
10
+ import styleNames from '@pareto-engineering/bem/exports';
11
+ import "./styles.scss";
12
+
13
+ // Local Definitions
14
+
15
+ const baseClassName = styleNames.base;
16
+ const componentClassName = 'lexical-preview';
17
+
18
+ /**
19
+ * This is the component description.
20
+ */
21
+ const LexicalPreview = ({
22
+ id,
23
+ className: userClassName,
24
+ style,
25
+ nodes,
26
+ color
27
+ // ...otherProps
28
+ }) => {
29
+ const initialConfig = {
30
+ nameSpace: id,
31
+ editable: false,
32
+ editorState: nodes,
33
+ theme: {
34
+ text: {
35
+ italic: 'italic',
36
+ strikethrough: 'strikethrough',
37
+ underline: 'underlined'
38
+ }
39
+ },
40
+ nodes: [AutoLinkNode, LinkNode, ListNode, ListItemNode]
41
+ };
42
+ return /*#__PURE__*/React.createElement(LexicalComposer, {
43
+ initialConfig: initialConfig
44
+ }, /*#__PURE__*/React.createElement("div", {
45
+ id: id,
46
+ className: [baseClassName, componentClassName, userClassName, `y-${color}`].filter(e => e).join(' '),
47
+ style: style
48
+ }, /*#__PURE__*/React.createElement(RichTextPlugin, {
49
+ contentEditable: /*#__PURE__*/React.createElement(ContentEditable, {
50
+ id: id,
51
+ className: "content-editable"
52
+ })
53
+ })));
54
+ };
55
+ LexicalPreview.propTypes = {
56
+ /**
57
+ * The HTML id for this element
58
+ */
59
+ id: PropTypes.string,
60
+ /**
61
+ * The HTML class names for this element
62
+ */
63
+ className: PropTypes.string,
64
+ /**
65
+ * The React-written, css properties for this element.
66
+ */
67
+ style: PropTypes.objectOf(PropTypes.string),
68
+ /**
69
+ * Color of the text
70
+ */
71
+ color: PropTypes.string,
72
+ /**
73
+ * The nodes to render in the form of a json string
74
+ */
75
+ nodes: PropTypes.string
76
+ };
77
+ LexicalPreview.defaultProps = {
78
+ color: 'paragraph'
79
+ };
80
+ export default LexicalPreview;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as LexicalPreview } from "./LexicalPreview";
@@ -0,0 +1,46 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+ @use "@pareto-engineering/styles/src/mixins";
5
+ @use "@pareto-engineering/styles/src/globals" as *;
6
+
7
+ .#{bem.$base}.lexical-preview {
8
+ > .content-editable {
9
+ color: var(--y);
10
+ overflow: auto;
11
+
12
+ li:has(ol, ul) {
13
+ list-style-type: none;
14
+ }
15
+
16
+ p,
17
+ span,
18
+ strong,
19
+ em,
20
+ li {
21
+ &.underlined {
22
+ text-decoration: underline;
23
+
24
+ &.strikethrough {
25
+ text-decoration: underline line-through;
26
+ }
27
+ }
28
+
29
+ &.strikethrough {
30
+ text-decoration: line-through;
31
+ }
32
+
33
+ &.italic {
34
+ font-style: italic;
35
+ }
36
+ }
37
+
38
+ :first-child {
39
+ margin-top: 0;
40
+ }
41
+
42
+ &::placeholder {
43
+ color: var(--metadata);
44
+ }
45
+ }
46
+ }
@@ -20,21 +20,28 @@ const Person = ({
20
20
  role,
21
21
  color
22
22
  // ...otherProps
23
- }) => /*#__PURE__*/React.createElement("div", {
24
- id: id,
25
- className: [baseClassName, componentClassName, userClassName, `y-${color}`].filter(e => e).join(' '),
26
- style: style
27
- }, /*#__PURE__*/React.createElement("img", {
28
- className: "image v50 mr-v",
29
- src: image,
30
- alt: `${name}, ${role}`
31
- }), /*#__PURE__*/React.createElement("div", {
32
- className: "details"
33
- }, name && /*#__PURE__*/React.createElement("p", {
34
- className: "name"
35
- }, name), role && /*#__PURE__*/React.createElement("p", {
36
- className: "role"
37
- }, role)));
23
+ }) => {
24
+ const handleImageSrcError = e => {
25
+ e.target.onerror = null;
26
+ e.target.src = '/default-avatar.svg';
27
+ };
28
+ return /*#__PURE__*/React.createElement("div", {
29
+ id: id,
30
+ className: [baseClassName, componentClassName, userClassName, `y-${color}`].filter(e => e).join(' '),
31
+ style: style
32
+ }, /*#__PURE__*/React.createElement("img", {
33
+ className: "image v50 mr-v",
34
+ src: image || '/default-avatar.svg',
35
+ alt: `${name}, ${role}`,
36
+ onError: handleImageSrcError
37
+ }), /*#__PURE__*/React.createElement("div", {
38
+ className: "details"
39
+ }, name && /*#__PURE__*/React.createElement("p", {
40
+ className: "name"
41
+ }, name), role && /*#__PURE__*/React.createElement("p", {
42
+ className: "role"
43
+ }, role)));
44
+ };
38
45
  Person.propTypes = {
39
46
  /**
40
47
  * The HTML id for this element
@@ -19,11 +19,12 @@ const ProgressBar = ({
19
19
  attached,
20
20
  color,
21
21
  progress,
22
- height
22
+ height,
23
+ rounded
23
24
  // ...otherProps
24
25
  }) => /*#__PURE__*/React.createElement("div", {
25
26
  id: id,
26
- className: [baseClassName, componentClassName, attached && styleNames.modifierAttached, color && `x-${color}`, userClassName].filter(e => e).join(' '),
27
+ className: [baseClassName, componentClassName, attached && styleNames.modifierAttached, color && `x-${color}`, userClassName, rounded && 'rounded'].filter(e => e).join(' '),
27
28
  style: {
28
29
  '--progress': progress,
29
30
  '--height': height,
@@ -5,9 +5,11 @@
5
5
  $default-height:var(--height, 1em);
6
6
  $default-border:none;//2px solid var(--grid);
7
7
  $default-transition-duration:.5s;
8
- $default-color:var(--x, var(--main1));
8
+ $default-color:var(--x, var(--main));
9
+ $default-border-radius:var(--theme-border-radius, 1.875rem);
9
10
 
10
11
  .#{bem.$base}.progress-bar {
12
+ background-color: var(--progress-bar-background-color);
11
13
  border: $default-border;
12
14
  height: $default-height;
13
15
  position: relative;
@@ -28,6 +30,14 @@ $default-color:var(--x, var(--main1));
28
30
  z-index: 1;
29
31
  }
30
32
 
33
+ &.rounded {
34
+ border-radius: $default-border-radius;
35
+
36
+ &::after {
37
+ border-radius: $default-border-radius;
38
+ }
39
+ }
40
+
31
41
  &.#{bem.$modifier-attached} {
32
42
  border: unset;
33
43
  border-bottom: $default-border;
@@ -4,10 +4,8 @@ import { useEffect, useRef } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { EditorState } from '@codemirror/state';
6
6
  import { EditorView, keymap, lineNumbers, drawSelection, dropCursor, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, crosshairCursor, rectangularSelection } from '@codemirror/view';
7
- import { defaultKeymap, indentWithTab } from '@codemirror/commands';
8
- import {
9
- // indentOnInput,
10
- bracketMatching, foldGutter } from '@codemirror/language';
7
+ import { defaultKeymap } from '@codemirror/commands';
8
+ import { indentOnInput, bracketMatching, foldGutter } from '@codemirror/language';
11
9
  import { xml } from '@codemirror/lang-xml';
12
10
  import styleNames from '@pareto-engineering/bem/exports';
13
11
  import { theme } from "./common";
@@ -28,18 +26,22 @@ const XMLEditor = ({
28
26
  height,
29
27
  gutterWidth,
30
28
  config,
31
- onChange
29
+ onChange,
30
+ stopPropagationKeys
32
31
  }) => {
33
32
  const editorRef = useRef();
34
33
  useEffect(() => {
35
34
  const startState = EditorState.create({
36
35
  doc: config,
37
- extensions: [keymap.of([defaultKeymap, indentWithTab]),
38
- // TOFIX: Indent with tab prevents indentOnInout from working.
39
- // indentOnInput(),
40
- lineNumbers(), bracketMatching(), foldGutter(), drawSelection(), highlightActiveLine(), highlightActiveLineGutter(), highlightSpecialChars(), dropCursor(), rectangularSelection(), crosshairCursor(), xml(), theme, EditorState.readOnly.of(readOnly), EditorView.updateListener.of(view => {
36
+ extensions: [keymap.of(defaultKeymap), indentOnInput(), lineNumbers(), bracketMatching(), foldGutter(), drawSelection(), highlightActiveLine(), highlightActiveLineGutter(), highlightSpecialChars(), dropCursor(), rectangularSelection(), crosshairCursor(), xml(), theme, EditorState.readOnly.of(readOnly), EditorView.updateListener.of(view => {
41
37
  onChange(view);
42
38
  // view.state.doc.toString() to receive the current content in the editor.
39
+ }), EditorView.domEventHandlers({
40
+ keydown(e) {
41
+ if (stopPropagationKeys?.includes(e.key)) {
42
+ e.stopPropagation();
43
+ }
44
+ }
43
45
  })]
44
46
  });
45
47
  const view = new EditorView({
@@ -93,7 +95,11 @@ XMLEditor.propTypes = {
93
95
  /**
94
96
  * The width of the gutter.
95
97
  */
96
- gutterWidth: PropTypes.string
98
+ gutterWidth: PropTypes.string,
99
+ /**
100
+ * The keys to stop propagation on.
101
+ */
102
+ stopPropagationKeys: PropTypes.arrayOf(PropTypes.string)
97
103
  };
98
104
  XMLEditor.defaultProps = {
99
105
  config: `<View>
@@ -23,4 +23,5 @@ export { AnimatedGradient } from "./AnimatedGradient";
23
23
  export { TextSteps } from "./TextSteps";
24
24
  export { Removable } from "./Removable";
25
25
  export { ToggleSwitch } from "./ToggleSwitch";
26
- export { XMLEditor } from "./XMLEditor";
26
+ export { XMLEditor } from "./XMLEditor";
27
+ export { LexicalPreview } from "./LexicalPreview";
@@ -0,0 +1,115 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ /* eslint-disable import/no-extraneous-dependencies -- required here */
3
+ import * as React from 'react';
4
+ import { useState, useMemo } from 'react';
5
+ import { LexicalComposer } from '@lexical/react/LexicalComposer';
6
+ import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
7
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable';
8
+ import { AutoLinkNode, LinkNode } from '@lexical/link';
9
+ import { ListItemNode, ListNode } from '@lexical/list';
10
+ import PropTypes from 'prop-types';
11
+ import styleNames from '@pareto-engineering/bem/exports';
12
+ import { Button } from '@pareto-engineering/design-system';
13
+ import "./styles.scss";
14
+ import { ExpandButton } from "./common";
15
+
16
+ // Local Definitions
17
+
18
+ const baseClassName = styleNames.base;
19
+ const componentClassName = 'expandable-lexical-preview';
20
+
21
+ /**
22
+ * This is the component description.
23
+ */
24
+ const ExpandableLexicalPreview = ({
25
+ id,
26
+ className: userClassName,
27
+ style,
28
+ nodes,
29
+ color,
30
+ resize,
31
+ title
32
+ // ...otherProps
33
+ }) => {
34
+ const initialConfig = {
35
+ nameSpace: id,
36
+ editable: false,
37
+ editorState: nodes,
38
+ theme: {
39
+ text: {
40
+ italic: 'italic',
41
+ strikethrough: 'strikethrough',
42
+ underline: 'underlined'
43
+ }
44
+ },
45
+ nodes: [AutoLinkNode, LinkNode, ListNode, ListItemNode]
46
+ };
47
+ const [isExpanded, setIsExpanded] = useState(false);
48
+ const handleButtonClick = () => {
49
+ setIsExpanded(!isExpanded);
50
+ };
51
+ const Content = useMemo(() => /*#__PURE__*/React.createElement("div", {
52
+ className: "lexical-content"
53
+ }, /*#__PURE__*/React.createElement(RichTextPlugin, {
54
+ contentEditable: /*#__PURE__*/React.createElement(ContentEditable, {
55
+ id: id,
56
+ className: "content-editable"
57
+ })
58
+ }), /*#__PURE__*/React.createElement(ExpandButton, {
59
+ title: title,
60
+ onResolve: handleButtonClick
61
+ })), [id]);
62
+ return /*#__PURE__*/React.createElement(LexicalComposer, {
63
+ initialConfig: initialConfig
64
+ }, /*#__PURE__*/React.createElement("div", {
65
+ id: id,
66
+ className: [baseClassName, componentClassName, userClassName, `y-${color}`, isExpanded && 'collapsed'].filter(e => e).join(' '),
67
+ style: {
68
+ '--resize': resize,
69
+ ...style
70
+ }
71
+ }, typeof title === 'string' ? /*#__PURE__*/React.createElement("p", {
72
+ className: "title h2"
73
+ }, title) : title, isExpanded && /*#__PURE__*/React.createElement(Button, {
74
+ onClick: handleButtonClick,
75
+ color: "background-far",
76
+ isCompact: true
77
+ }, /*#__PURE__*/React.createElement("span", {
78
+ className: "ai-icon c-x x-paragraph"
79
+ }, "C")), !isExpanded && Content));
80
+ };
81
+ ExpandableLexicalPreview.propTypes = {
82
+ /**
83
+ * The HTML id for this element
84
+ */
85
+ id: PropTypes.string,
86
+ /**
87
+ * The HTML class names for this element
88
+ */
89
+ className: PropTypes.string,
90
+ /**
91
+ * The React-written, css properties for this element.
92
+ */
93
+ style: PropTypes.objectOf(PropTypes.string),
94
+ /**
95
+ * Color of the text
96
+ */
97
+ color: PropTypes.string,
98
+ /**
99
+ * The nodes to render in the form of a json string
100
+ */
101
+ nodes: PropTypes.string,
102
+ /**
103
+ * The resize property of the textarea
104
+ */
105
+ resize: PropTypes.string,
106
+ /**
107
+ * The title for the preview.
108
+ */
109
+ title: PropTypes.string
110
+ };
111
+ ExpandableLexicalPreview.defaultProps = {
112
+ color: 'paragraph',
113
+ resize: 'vertical'
114
+ };
115
+ export default ExpandableLexicalPreview;
@@ -0,0 +1,102 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ /* eslint-disable import/no-extraneous-dependencies -- required here */
3
+ import * as React from 'react';
4
+ import { $generateHtmlFromNodes } from '@lexical/html';
5
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
6
+ import PropTypes from 'prop-types';
7
+ import styleNames from '@pareto-engineering/bem/exports';
8
+ import { Button } from '@pareto-engineering/design-system';
9
+
10
+ // Local Definitions
11
+
12
+ const baseClassName = styleNames.base;
13
+ const componentClassName = 'expand-button';
14
+
15
+ /**
16
+ * This is the component description.
17
+ */
18
+ const ExpandButton = ({
19
+ id,
20
+ className: userClassName,
21
+ style,
22
+ onResolve,
23
+ title
24
+ // ...otherProps
25
+ }) => {
26
+ const [editor] = useLexicalComposerContext();
27
+ return /*#__PURE__*/React.createElement(Button, {
28
+ id: id,
29
+ className: [baseClassName, componentClassName, userClassName, 'ai-icon'].filter(e => e).join(' '),
30
+ style: style,
31
+ color: "background-far",
32
+ isCompact: true,
33
+ onClick: () => {
34
+ editor.getEditorState().read(() => {
35
+ const rawHtml = $generateHtmlFromNodes(editor);
36
+ const preview = window.open('', '_blank', 'width=600,height=600');
37
+ preview.document.write(`<html>
38
+ <title>${title || 'Preview'}</title>
39
+ <style>
40
+ li:has(ol, ul) {
41
+ list-style-type: none;
42
+ }
43
+
44
+ p,
45
+ span,
46
+ strong,
47
+ em,
48
+ li {
49
+ &.underlined {
50
+ text-decoration: underline;
51
+
52
+ &.strikethrough {
53
+ text-decoration: underline line-through;
54
+ }
55
+ }
56
+
57
+ &.strikethrough {
58
+ text-decoration: line-through;
59
+ }
60
+
61
+ &.italic {
62
+ font-style: italic;
63
+ }
64
+ }
65
+
66
+ :first-child {
67
+ margin-top: 0;
68
+ }
69
+
70
+ &::placeholder {
71
+ color: #abadb3;
72
+ }
73
+ </style>
74
+ <body>
75
+ <style></style>
76
+ ${rawHtml}
77
+ <button onclick="window.close()">Close Preview</button>
78
+ </body></html>`);
79
+ });
80
+ onResolve();
81
+ }
82
+ }, "D");
83
+ };
84
+ ExpandButton.propTypes = {
85
+ /**
86
+ * The HTML id for this element
87
+ */
88
+ id: PropTypes.string,
89
+ /**
90
+ * The HTML class names for this element
91
+ */
92
+ className: PropTypes.string,
93
+ /**
94
+ * The React-written, css properties for this element.
95
+ */
96
+ style: PropTypes.objectOf(PropTypes.string)
97
+ };
98
+ ExpandButton.defaultProps = {
99
+ // color: 'paragraph',
100
+ // resize: 'vertical',
101
+ };
102
+ export default ExpandButton;
@@ -0,0 +1 @@
1
+ export { default as ExpandButton } from "./ExpandButton";
@@ -0,0 +1 @@
1
+ export { ExpandButton } from "./ExpandButton";
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as ExpandableLexicalPreview } from "./ExpandableLexicalPreview";