@pareto-engineering/design-system 4.0.0-alpha.77 → 4.0.0-alpha.79

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 (210) hide show
  1. package/dist/cjs/a/AnimatedBlobs/AnimatedBlobs.js +1 -1
  2. package/dist/cjs/a/AnimatedGradient/AnimatedGradient.js +1 -1
  3. package/dist/cjs/a/AppContext/Context.js +1 -1
  4. package/dist/cjs/a/AppContext/ContextProvider.js +1 -1
  5. package/dist/cjs/a/BlurOverlay/BlurOverlay.js +1 -1
  6. package/dist/cjs/a/ContentTree/ContentTree.js +1 -1
  7. package/dist/cjs/a/ContentTree/common/Tree/Tree.js +1 -1
  8. package/dist/cjs/a/Conversation/Context.js +1 -1
  9. package/dist/cjs/a/Conversation/Conversation.js +1 -1
  10. package/dist/cjs/a/Conversation/common/Message/Message.js +1 -1
  11. package/dist/cjs/a/DatePicker/DatePicker.js +1 -1
  12. package/dist/cjs/a/DotInfo/DotInfo.js +1 -1
  13. package/dist/cjs/a/Figure/Figure.js +1 -1
  14. package/dist/cjs/a/HamburgerButton/HamburgerButton.js +1 -1
  15. package/dist/cjs/a/IconList/IconList.js +1 -1
  16. package/dist/cjs/a/IconList/common/Item/Item.js +1 -1
  17. package/dist/cjs/a/Label/Label.js +1 -1
  18. package/dist/cjs/a/LoadingCircle/LoadingCircle.js +1 -1
  19. package/dist/cjs/a/MetaCard/MetaCard.js +1 -1
  20. package/dist/cjs/a/People/People.js +1 -1
  21. package/dist/cjs/a/People/common/Person/Person.js +1 -1
  22. package/dist/cjs/a/People/styles.scss +1 -1
  23. package/dist/cjs/a/Popover/Popover.js +1 -1
  24. package/dist/cjs/a/ProgressBar/ProgressBar.js +1 -1
  25. package/dist/cjs/a/Quote/Quote.js +16 -6
  26. package/dist/cjs/a/Quote/styles.scss +16 -37
  27. package/dist/cjs/a/Removable/Removable.js +1 -1
  28. package/dist/cjs/a/SVG/SVG.js +1 -1
  29. package/dist/cjs/a/SVG/common/UseSVG/UseSVG.js +1 -1
  30. package/dist/cjs/a/SnapScroller/SnapScroller.js +1 -1
  31. package/dist/cjs/a/Spinner/Spinner.js +1 -1
  32. package/dist/cjs/a/TextSteps/TextSteps.js +1 -1
  33. package/dist/cjs/a/Timestamp/Timestamp.js +1 -1
  34. package/dist/cjs/a/Tip/Tip.js +1 -1
  35. package/dist/cjs/a/ToggleSwitch/ToggleSwitch.js +1 -1
  36. package/dist/cjs/a/Tooltip/Tooltip.js +71 -0
  37. package/dist/cjs/a/{LexicalPreview → Tooltip}/index.js +3 -3
  38. package/dist/cjs/a/Tooltip/styles.scss +56 -0
  39. package/dist/cjs/a/XMLEditor/XMLEditor.js +1 -1
  40. package/dist/cjs/a/index.js +8 -8
  41. package/dist/cjs/b/Button/Button.js +1 -1
  42. package/dist/cjs/b/Button/common/Group/Group.js +1 -1
  43. package/dist/cjs/b/Card/Card.js +1 -1
  44. package/dist/cjs/b/Card/common/Group/Group.js +1 -1
  45. package/dist/cjs/b/Card/common/Section/Section.js +1 -1
  46. package/dist/cjs/b/Logo/Logo.js +1 -1
  47. package/dist/cjs/b/Page/Context.js +1 -1
  48. package/dist/cjs/b/Page/Page.js +1 -1
  49. package/dist/cjs/b/Page/common/PageHelmet/PageHelmet.js +5 -2
  50. package/dist/cjs/b/Page/common/Section/Section.js +1 -1
  51. package/dist/cjs/b/SocialMediaButton/SocialMediaButton.js +1 -1
  52. package/dist/cjs/b/ThemeSelector/ThemeSelector.js +1 -1
  53. package/dist/cjs/b/Title/Title.js +1 -1
  54. package/dist/cjs/b/index.js +1 -8
  55. package/dist/cjs/c/Modal/Modal.js +1 -1
  56. package/dist/cjs/c/Modal/common/ModalHeader/ModalHeader.js +1 -1
  57. package/dist/cjs/c/Shortener/Shortener.js +1 -1
  58. package/dist/cjs/c/SocialMediaShareButton/SocialMediaShareButton.js +1 -1
  59. package/dist/cjs/f/FormInput/FormInput.js +1 -1
  60. package/dist/cjs/f/common/Debugger/Debugger.js +1 -1
  61. package/dist/cjs/f/common/Description/Description.js +1 -1
  62. package/dist/cjs/f/common/Label/Label.js +1 -1
  63. package/dist/cjs/f/fields/Checkbox/Checkbox.js +1 -1
  64. package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +1 -1
  65. package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +1 -1
  66. package/dist/cjs/f/fields/EditorInput/EditorInput.js +37 -12
  67. package/dist/cjs/f/fields/EditorInput/common/BlockFormatDropDown/BlockFormatDropDown.js +256 -0
  68. package/dist/cjs/f/fields/EditorInput/common/BlockFormatDropDown/index.js +13 -0
  69. package/dist/cjs/f/fields/EditorInput/common/BlockFormatDropDown/styles.scss +55 -0
  70. package/dist/cjs/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +94 -0
  71. package/dist/cjs/f/fields/EditorInput/common/ColorPicker/index.js +13 -0
  72. package/dist/cjs/f/fields/EditorInput/common/ColorPicker/styles.scss +36 -0
  73. package/dist/cjs/f/fields/EditorInput/common/FontSizeDropDown/FontSizeDropDown.js +94 -0
  74. package/dist/cjs/f/fields/EditorInput/common/FontSizeDropDown/index.js +13 -0
  75. package/dist/cjs/f/fields/EditorInput/common/FontSizeDropDown/styles.scss +55 -0
  76. package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +295 -0
  77. package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/index.js +13 -0
  78. package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/styles.scss +56 -0
  79. package/dist/cjs/f/fields/EditorInput/common/index.js +24 -3
  80. package/dist/cjs/f/fields/EditorInput/styles.scss +116 -25
  81. package/dist/cjs/f/fields/LinkInput/LinkInput.js +1 -1
  82. package/dist/cjs/f/fields/QueryChoices/QueryChoices.js +1 -1
  83. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +1 -1
  84. package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +1 -1
  85. package/dist/cjs/f/fields/QueryCombobox/common/Menu/Menu.js +1 -1
  86. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +1 -1
  87. package/dist/cjs/f/fields/QuerySelect/QuerySelect.js +1 -1
  88. package/dist/cjs/f/fields/RatingsInput/RatingsInput.js +1 -1
  89. package/dist/cjs/f/fields/RatingsInput/common/Rating/Rating.js +1 -1
  90. package/dist/cjs/f/fields/SelectInput/SelectInput.js +10 -3
  91. package/dist/cjs/f/fields/SelectInput/common/Menu/Menu.js +1 -1
  92. package/dist/cjs/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
  93. package/dist/cjs/f/fields/SelectInput/common/Single/Single.js +14 -3
  94. package/dist/cjs/f/fields/SelectInput/styles.scss +1 -1
  95. package/dist/cjs/f/fields/TextInput/TextInput.js +1 -1
  96. package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +1 -1
  97. package/dist/cjs/{b → g}/ExpandableLexicalPreview/ExpandableLexicalPreview.js +28 -43
  98. package/dist/cjs/{b → g}/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +7 -8
  99. package/dist/cjs/g/ExpandableLexicalPreview/styles.scss +34 -0
  100. package/dist/cjs/g/index.js +12 -0
  101. package/dist/cjs/index.js +11 -0
  102. package/dist/cjs/test/QueryLoader/QueryLoader.js +1 -1
  103. package/dist/cjs/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +1 -1
  104. package/dist/cjs/utils/hooks/index.js +7 -0
  105. package/dist/cjs/utils/hooks/useOutsideClick.js +25 -0
  106. package/dist/cjs/utils/index.js +6 -0
  107. package/dist/es/a/People/styles.scss +1 -1
  108. package/dist/es/a/Quote/Quote.js +15 -5
  109. package/dist/es/a/Quote/styles.scss +16 -37
  110. package/dist/es/a/Tooltip/Tooltip.js +59 -0
  111. package/dist/es/a/Tooltip/index.js +2 -0
  112. package/dist/es/a/Tooltip/styles.scss +56 -0
  113. package/dist/es/a/index.js +2 -2
  114. package/dist/es/b/Page/common/PageHelmet/PageHelmet.js +4 -1
  115. package/dist/es/b/index.js +1 -2
  116. package/dist/es/f/fields/EditorInput/EditorInput.js +35 -11
  117. package/dist/es/f/fields/EditorInput/common/BlockFormatDropDown/BlockFormatDropDown.js +246 -0
  118. package/dist/es/f/fields/EditorInput/common/BlockFormatDropDown/index.js +2 -0
  119. package/dist/es/f/fields/EditorInput/common/BlockFormatDropDown/styles.scss +55 -0
  120. package/dist/es/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +83 -0
  121. package/dist/es/f/fields/EditorInput/common/ColorPicker/index.js +2 -0
  122. package/dist/es/f/fields/EditorInput/common/ColorPicker/styles.scss +36 -0
  123. package/dist/es/f/fields/EditorInput/common/FontSizeDropDown/FontSizeDropDown.js +81 -0
  124. package/dist/es/f/fields/EditorInput/common/FontSizeDropDown/index.js +2 -0
  125. package/dist/es/f/fields/EditorInput/common/FontSizeDropDown/styles.scss +55 -0
  126. package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +283 -0
  127. package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/index.js +2 -0
  128. package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/styles.scss +56 -0
  129. package/dist/es/f/fields/EditorInput/common/index.js +5 -2
  130. package/dist/es/f/fields/EditorInput/styles.scss +116 -25
  131. package/dist/es/f/fields/SelectInput/SelectInput.js +9 -2
  132. package/dist/es/f/fields/SelectInput/common/Single/Single.js +12 -1
  133. package/dist/es/f/fields/SelectInput/styles.scss +1 -1
  134. package/dist/es/{b → g}/ExpandableLexicalPreview/ExpandableLexicalPreview.js +29 -45
  135. package/dist/es/{b → g}/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +18 -21
  136. package/dist/es/g/ExpandableLexicalPreview/styles.scss +34 -0
  137. package/dist/es/g/index.js +1 -0
  138. package/dist/es/index.js +1 -0
  139. package/dist/es/utils/hooks/index.js +2 -1
  140. package/dist/es/utils/hooks/useOutsideClick.js +19 -0
  141. package/dist/es/utils/index.js +1 -1
  142. package/package.json +14 -6
  143. package/src/stories/a/Quote.stories.jsx +30 -10
  144. package/src/stories/a/Tooltip.stories.jsx +80 -0
  145. package/src/stories/a/XMLEditor.stories.jsx +6 -1
  146. package/src/stories/f/SelectInput.stories.jsx +18 -2
  147. package/src/stories/{b → g}/ExpandableLexicalPreview.stories.jsx +2 -1
  148. package/src/ui/a/People/styles.scss +1 -1
  149. package/src/ui/a/Quote/Quote.jsx +16 -9
  150. package/src/ui/a/Quote/styles.scss +16 -37
  151. package/src/ui/a/Tooltip/Tooltip.jsx +83 -0
  152. package/src/ui/a/Tooltip/index.js +2 -0
  153. package/src/ui/a/Tooltip/styles.scss +56 -0
  154. package/src/ui/a/index.js +1 -1
  155. package/src/ui/b/Page/common/PageHelmet/PageHelmet.jsx +6 -0
  156. package/src/ui/b/index.js +0 -1
  157. package/src/ui/f/fields/EditorInput/EditorInput.jsx +35 -5
  158. package/src/ui/f/fields/EditorInput/common/BlockFormatDropDown/BlockFormatDropDown.jsx +292 -0
  159. package/src/ui/f/fields/EditorInput/common/BlockFormatDropDown/index.js +2 -0
  160. package/src/ui/f/fields/EditorInput/common/BlockFormatDropDown/styles.scss +55 -0
  161. package/src/ui/f/fields/EditorInput/common/ColorPicker/ColorPicker.jsx +110 -0
  162. package/src/ui/f/fields/EditorInput/common/ColorPicker/index.js +2 -0
  163. package/src/ui/f/fields/EditorInput/common/ColorPicker/styles.scss +36 -0
  164. package/src/ui/f/fields/EditorInput/common/FontSizeDropDown/FontSizeDropDown.jsx +134 -0
  165. package/src/ui/f/fields/EditorInput/common/FontSizeDropDown/index.js +2 -0
  166. package/src/ui/f/fields/EditorInput/common/FontSizeDropDown/styles.scss +55 -0
  167. package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.jsx +431 -0
  168. package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/index.js +2 -0
  169. package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/styles.scss +56 -0
  170. package/src/ui/f/fields/EditorInput/common/index.js +6 -0
  171. package/src/ui/f/fields/EditorInput/styles.scss +116 -25
  172. package/src/ui/f/fields/SelectInput/SelectInput.jsx +10 -2
  173. package/src/ui/f/fields/SelectInput/common/Single/Single.jsx +13 -1
  174. package/src/ui/f/fields/SelectInput/styles.scss +1 -1
  175. package/src/ui/{b → g}/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +43 -56
  176. package/src/ui/{b → g}/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.jsx +32 -36
  177. package/src/ui/g/ExpandableLexicalPreview/styles.scss +34 -0
  178. package/src/ui/g/index.js +1 -0
  179. package/src/ui/index.js +1 -0
  180. package/src/ui/utils/hooks/index.js +1 -0
  181. package/src/ui/utils/hooks/useOutsideClick.js +23 -0
  182. package/src/ui/utils/index.js +1 -1
  183. package/tests/__snapshots__/Storyshots.test.js.snap +914 -433
  184. package/tests/mockResizeObserver.js +9 -0
  185. package/tests/test-setup.js +3 -0
  186. package/dist/cjs/a/LexicalPreview/LexicalPreview.js +0 -90
  187. package/dist/cjs/a/LexicalPreview/styles.scss +0 -46
  188. package/dist/cjs/b/ExpandableLexicalPreview/styles.scss +0 -84
  189. package/dist/cjs/f/fields/EditorInput/common/Toolbar.js +0 -257
  190. package/dist/es/a/LexicalPreview/LexicalPreview.js +0 -80
  191. package/dist/es/a/LexicalPreview/index.js +0 -2
  192. package/dist/es/a/LexicalPreview/styles.scss +0 -46
  193. package/dist/es/b/ExpandableLexicalPreview/styles.scss +0 -84
  194. package/dist/es/f/fields/EditorInput/common/Toolbar.js +0 -246
  195. package/src/stories/a/LexicalPreview.stories.jsx +0 -28
  196. package/src/ui/a/LexicalPreview/LexicalPreview.jsx +0 -109
  197. package/src/ui/a/LexicalPreview/index.js +0 -2
  198. package/src/ui/a/LexicalPreview/styles.scss +0 -46
  199. package/src/ui/b/ExpandableLexicalPreview/styles.scss +0 -84
  200. package/src/ui/f/fields/EditorInput/common/Toolbar.jsx +0 -356
  201. package/src/ui/f/fields/EditorInput/common/index.jsx +0 -3
  202. /package/dist/cjs/{b → g}/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -0
  203. /package/dist/cjs/{b → g}/ExpandableLexicalPreview/common/index.js +0 -0
  204. /package/dist/cjs/{b → g}/ExpandableLexicalPreview/index.js +0 -0
  205. /package/dist/es/{b → g}/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -0
  206. /package/dist/es/{b → g}/ExpandableLexicalPreview/common/index.js +0 -0
  207. /package/dist/es/{b → g}/ExpandableLexicalPreview/index.js +0 -0
  208. /package/src/ui/{b → g}/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -0
  209. /package/src/ui/{b → g}/ExpandableLexicalPreview/common/index.js +0 -0
  210. /package/src/ui/{b → g}/ExpandableLexicalPreview/index.js +0 -0
@@ -0,0 +1,83 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react';
3
+ import { useRef, useEffect, useState } from 'react';
4
+ import { ColorPicker as ReactColorPicker, useColor } from 'react-color-palette';
5
+ import PropTypes from 'prop-types';
6
+ import styleNames from '@pareto-engineering/bem/exports';
7
+ import "./styles.scss";
8
+ import { Popover } from "../../../../../a";
9
+ import { useOutsideClick } from "../../../../../utils";
10
+ // Local Definitions
11
+
12
+ const baseClassName = styleNames.base;
13
+ const componentClassName = 'color-picker';
14
+
15
+ /**
16
+ * This is the component description.
17
+ */
18
+ const ColorPicker = ({
19
+ id,
20
+ className: userClassName,
21
+ style,
22
+ icon,
23
+ color,
24
+ onChange
25
+ // ...otherProps
26
+ }) => {
27
+ const [colorValue, setColor] = useColor(color);
28
+ const parentRef = useRef(null);
29
+ const [isOpen, setIsOpen] = useState(false);
30
+ useOutsideClick(parentRef, () => setIsOpen(false));
31
+ useEffect(() => {
32
+ const {
33
+ hex
34
+ } = colorValue;
35
+ if (hex) {
36
+ onChange(hex);
37
+ }
38
+ }, [colorValue]);
39
+ return (
40
+ /*#__PURE__*/
41
+ // eslint-disable-next-line jsx-a11y/control-has-associated-label
42
+ React.createElement("div", {
43
+ id: id,
44
+ className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
45
+ style: style,
46
+ ref: parentRef
47
+ // {...otherProps}
48
+ }, /*#__PURE__*/React.createElement("button", {
49
+ type: "button",
50
+ onClick: () => setIsOpen(!isOpen)
51
+ }, /*#__PURE__*/React.createElement("span", {
52
+ className: "icon"
53
+ }, icon), /*#__PURE__*/React.createElement("span", {
54
+ className: "icon"
55
+ }, "V")), /*#__PURE__*/React.createElement(Popover, {
56
+ parentRef: parentRef,
57
+ isOpen: isOpen,
58
+ color: "background-far"
59
+ }, /*#__PURE__*/React.createElement(ReactColorPicker, {
60
+ color: colorValue,
61
+ onChange: setColor,
62
+ hideInput: true
63
+ })))
64
+ );
65
+ };
66
+ ColorPicker.propTypes = {
67
+ /**
68
+ * The HTML id for this element
69
+ */
70
+ id: PropTypes.string,
71
+ /**
72
+ * The HTML class names for this element
73
+ */
74
+ className: PropTypes.string,
75
+ /**
76
+ * The React-written, css properties for this element.
77
+ */
78
+ style: PropTypes.objectOf(PropTypes.string)
79
+ };
80
+ ColorPicker.defaultProps = {
81
+ // someProp:false
82
+ };
83
+ export default ColorPicker;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as ColorPicker } from "./ColorPicker";
@@ -0,0 +1,36 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+ @use "react-color-palette/css";
5
+
6
+ $default-width: 20rem;
7
+
8
+ .#{bem.$base}.color-picker {
9
+ cursor: pointer;
10
+ position: relative;
11
+
12
+ > button {
13
+ align-items: center;
14
+ background-color: var(--x);
15
+ border: 0;
16
+ color: var(--on-background-inputs);
17
+ display: flex;
18
+ gap: calc(var(--gap) / 2);
19
+ padding: calc(var(--theme-default-padding) / 2);
20
+
21
+ &:hover {
22
+ background: var(--hard-x);
23
+ border-radius: calc(var(--theme-default-border-radius) / 2);
24
+ }
25
+ }
26
+
27
+
28
+ > .#{bem.$base}.popover {
29
+ background-color: var(--background-far);
30
+ border: 1px solid var(--hard-background-cards);
31
+ border-radius: calc(var(--theme-default-border-radius) / 2);
32
+ color: var(--heading);
33
+ padding: calc(var(--theme-default-padding) / 2);
34
+ width: $default-width;
35
+ }
36
+ }
@@ -0,0 +1,81 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react';
3
+ import { useState, useRef, useCallback } from 'react';
4
+ import { $getSelection, $isRangeSelection } from 'lexical';
5
+ import { $patchStyleText } from '@lexical/selection';
6
+ import PropTypes from 'prop-types';
7
+ import styleNames from '@pareto-engineering/bem/exports';
8
+ import "./styles.scss";
9
+ import { Popover } from "../../../../../a";
10
+ import { useOutsideClick } from "../../../../../utils";
11
+
12
+ // Local Definitions
13
+
14
+ const baseClassName = styleNames.base;
15
+ const componentClassName = 'font-size-drop-down';
16
+ const FONT_SIZE_OPTIONS = [['10px', '10px'], ['11px', '11px'], ['12px', '12px'], ['13px', '13px'], ['14px', '14px'], ['15px', '15px'], ['16px', '16px'], ['17px', '17px'], ['18px', '18px'], ['19px', '19px'], ['20px', '20px']];
17
+
18
+ /**
19
+ * This is the component description.
20
+ */
21
+ const FontSizeDropDown = ({
22
+ id,
23
+ className: userClassName,
24
+ style,
25
+ editor,
26
+ value
27
+ // ...otherProps
28
+ }) => {
29
+ const parentRef = useRef(null);
30
+ const [isOpen, setIsOpen] = useState(false);
31
+ useOutsideClick(parentRef, () => setIsOpen(false));
32
+ const handleClick = useCallback(option => {
33
+ editor.update(() => {
34
+ const selection = $getSelection();
35
+ if ($isRangeSelection(selection)) {
36
+ $patchStyleText(selection, {
37
+ 'font-size': option
38
+ });
39
+ }
40
+ });
41
+ }, [editor]);
42
+ return /*#__PURE__*/React.createElement("button", {
43
+ id: id,
44
+ className: [baseClassName, componentClassName, userClassName, 'group'].filter(e => e).join(' '),
45
+ style: style,
46
+ ref: parentRef,
47
+ type: "button",
48
+ onClick: () => setIsOpen(!isOpen)
49
+ // {...otherProps}
50
+ }, /*#__PURE__*/React.createElement("span", null, value), /*#__PURE__*/React.createElement("span", {
51
+ className: "icon"
52
+ }, "V"), isOpen && /*#__PURE__*/React.createElement(Popover, {
53
+ parentRef: parentRef,
54
+ isOpen: isOpen,
55
+ color: "background-far"
56
+ }, FONT_SIZE_OPTIONS.map(([option, text]) => /*#__PURE__*/React.createElement("button", {
57
+ className: `item ${value === option ? 'active' : ''}`,
58
+ onClick: () => handleClick(option),
59
+ type: "button"
60
+ }, /*#__PURE__*/React.createElement("span", {
61
+ className: "text"
62
+ }, text)))));
63
+ };
64
+ FontSizeDropDown.propTypes = {
65
+ /**
66
+ * The HTML id for this element
67
+ */
68
+ id: PropTypes.string,
69
+ /**
70
+ * The HTML class names for this element
71
+ */
72
+ className: PropTypes.string,
73
+ /**
74
+ * The React-written, css properties for this element.
75
+ */
76
+ style: PropTypes.objectOf(PropTypes.string)
77
+ };
78
+ FontSizeDropDown.defaultProps = {
79
+ // someProp:false
80
+ };
81
+ export default FontSizeDropDown;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as FontSizeDropDown } from "./FontSizeDropDown";
@@ -0,0 +1,55 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ $default-width: 4.5rem;
6
+
7
+ .#{bem.$base}.font-size-drop-down {
8
+ align-items: center;
9
+ background-color: var(--x);
10
+ border: 0;
11
+ color: var(--on-background-inputs);
12
+ cursor: pointer;
13
+ display: flex;
14
+ gap: calc(var(--gap) / 2);
15
+ margin-inline: calc(var(--theme-default-padding) / 4);
16
+ padding: calc(var(--theme-default-padding) / 2);
17
+ position: relative;
18
+
19
+ &:hover {
20
+ background: var(--hard-x);
21
+ border-radius: calc(var(--theme-default-border-radius) / 2);
22
+ }
23
+
24
+ > .#{bem.$base}.popover {
25
+ background-color: var(--background-far);
26
+ border: 1px solid var(--hard-background-cards);
27
+ border-radius: calc(var(--theme-default-border-radius) / 2);
28
+ color: var(--heading);
29
+ display: flex;
30
+ flex-direction: column;
31
+ padding: calc(var(--theme-default-padding) / 2);
32
+ width: $default-width;
33
+
34
+ > .item {
35
+ align-items: center;
36
+ background-color: var(--x);
37
+ border: 0;
38
+ border-radius: calc(var(--theme-default-border-radius) / 2);
39
+ color: var(--paragraph);
40
+ cursor: pointer;
41
+ display: flex;
42
+ gap: calc(var(--gap) / 2);
43
+ padding: calc(var(--theme-default-padding) / 2);
44
+ transition: all .2s;
45
+
46
+ &:hover {
47
+ background-color: var(--hard-x);
48
+ }
49
+
50
+ &.active {
51
+ background-color: var(--hard-ui-main);
52
+ }
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,283 @@
1
+ /* eslint-disable import/no-extraneous-dependencies -- required here */
2
+ import * as React from 'react';
3
+ import { useEffect, useState, useCallback } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { mergeRegister, $getNearestNodeOfType, $findMatchingParent } from '@lexical/utils';
6
+ import { $isHeadingNode } from '@lexical/rich-text';
7
+ import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, UNDO_COMMAND, REDO_COMMAND, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, DEPRECATED_$isGridSelection } from 'lexical';
8
+ import { $isListNode, ListNode } from '@lexical/list';
9
+ import { $getSelectionStyleValueForProperty, $isAtNodeEnd, $patchStyleText } from '@lexical/selection';
10
+ import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
11
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
12
+ import { $isTableNode } from '@lexical/table';
13
+ import styleNames from '@pareto-engineering/bem/exports';
14
+ import { BlockFormatDropDown } from "../BlockFormatDropDown";
15
+ import { ColorPicker } from "../ColorPicker";
16
+ import { FontSizeDropDown } from "../FontSizeDropDown";
17
+
18
+ // Local Definitions
19
+ import "./styles.scss";
20
+ const getSelectedNode = selection => {
21
+ const {
22
+ anchor,
23
+ focus
24
+ } = selection;
25
+ const anchorNode = selection.anchor.getNode();
26
+ const focusNode = selection.focus.getNode();
27
+ if (anchorNode === focusNode) {
28
+ return anchorNode;
29
+ }
30
+ const isBackward = selection.isBackward();
31
+ if (isBackward) {
32
+ return $isAtNodeEnd(focus) ? anchorNode : focusNode;
33
+ }
34
+ return $isAtNodeEnd(anchor) ? focusNode : anchorNode;
35
+ };
36
+ export const blockTypeToBlockName = {
37
+ bullet: 'Bulleted List',
38
+ check: 'Check List',
39
+ code: 'Code Block',
40
+ h1: 'Heading 1',
41
+ h2: 'Heading 2',
42
+ h3: 'Heading 3',
43
+ number: 'Numbered List',
44
+ paragraph: 'Normal',
45
+ quote: 'Quote'
46
+ };
47
+ const baseClassName = styleNames.base;
48
+ const componentClassName = 'toolbar-plugin';
49
+
50
+ /**
51
+ * This is the component description
52
+ */
53
+ const ToolbarPlugin = ({
54
+ id,
55
+ className: userClassName,
56
+ style: inlineStyles,
57
+ baseBgColor
58
+ // ...otherProps
59
+ }) => {
60
+ const [editor] = useLexicalComposerContext();
61
+ const [activeEditor, setActiveEditor] = useState(editor);
62
+ const [blockType, setBlockType] = useState('paragraph');
63
+ const [rootType, setRootType] = useState('root');
64
+ const [fontColor, setFontColor] = useState('#000000');
65
+ const [bgColor, setBgColor] = useState('#ffffff');
66
+ const [fontSize, setFontSize] = useState('15px');
67
+ const [isEditable, setIsEditable] = useState(() => editor.isEditable());
68
+ const [isBold, setIsBold] = useState(false);
69
+ const [isItalic, setIsItalic] = useState(false);
70
+ const [isStrikethrough, setIsStrikethrough] = useState(false);
71
+ const [isLink, setIsLink] = useState(false);
72
+ const [isUnderline, setIsUnderline] = useState(false);
73
+ const [canRedo, setCanRedo] = useState(false);
74
+ const [canUndo, setCanUndo] = useState(false);
75
+ const formatLink = useCallback(() => {
76
+ if (!isLink) {
77
+ // eslint-disable-next-line no-alert
78
+ const path = prompt('Enter the full URL. Ex: https://www.example.com');
79
+ editor.dispatchCommand(TOGGLE_LINK_COMMAND, path);
80
+ } else {
81
+ editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
82
+ }
83
+ }, [editor, isLink]);
84
+ const $updateToolbar = useCallback(() => {
85
+ const selection = $getSelection();
86
+ if ($isRangeSelection(selection)) {
87
+ const anchorNode = selection.anchor.getNode();
88
+ let element = anchorNode.getKey() === 'root' ? anchorNode : $findMatchingParent(anchorNode, e => {
89
+ const parent = e.getParent();
90
+ return parent !== null && $isRootOrShadowRoot(parent);
91
+ });
92
+ if (element === null) {
93
+ element = anchorNode.getTopLevelElementOrThrow();
94
+ }
95
+ const elementKey = element.getKey();
96
+ const elementDOM = activeEditor.getElementByKey(elementKey);
97
+
98
+ // Update text format
99
+ setIsBold(selection.hasFormat('bold'));
100
+ setIsItalic(selection.hasFormat('italic'));
101
+ setIsUnderline(selection.hasFormat('underline'));
102
+ setIsStrikethrough(selection.hasFormat('strikethrough'));
103
+
104
+ // Update links
105
+ const node = getSelectedNode(selection);
106
+ const parent = node.getParent();
107
+ if ($isLinkNode(parent) || $isLinkNode(node)) {
108
+ setIsLink(true);
109
+ } else {
110
+ setIsLink(false);
111
+ }
112
+ const tableNode = $findMatchingParent(node, $isTableNode);
113
+ if ($isTableNode(tableNode)) {
114
+ setRootType('table');
115
+ } else {
116
+ setRootType('root');
117
+ }
118
+ if (elementDOM !== null) {
119
+ if ($isListNode(element)) {
120
+ const parentList = $getNearestNodeOfType(anchorNode, ListNode);
121
+ const type = parentList ? parentList.getListType() : element.getListType();
122
+ setBlockType(type);
123
+ } else {
124
+ const type = $isHeadingNode(element) ? element.getTag() : element.getType();
125
+ if (type in blockTypeToBlockName) {
126
+ setBlockType(type);
127
+ }
128
+ }
129
+ }
130
+ setFontSize($getSelectionStyleValueForProperty(selection, 'font-size', '15px'));
131
+ setFontColor($getSelectionStyleValueForProperty(selection, 'color', '#000'));
132
+ setBgColor($getSelectionStyleValueForProperty(selection, 'background-color', '#fff'));
133
+ }
134
+ }, [activeEditor]);
135
+ useEffect(() => editor.registerCommand(SELECTION_CHANGE_COMMAND, (_payload, newEditor) => {
136
+ $updateToolbar();
137
+ setActiveEditor(newEditor);
138
+ return false;
139
+ }, COMMAND_PRIORITY_CRITICAL), [editor, $updateToolbar]);
140
+ useEffect(() => mergeRegister(editor.registerEditableListener(editable => {
141
+ setIsEditable(editable);
142
+ }), activeEditor.registerUpdateListener(({
143
+ editorState
144
+ }) => {
145
+ editorState.read(() => {
146
+ $updateToolbar();
147
+ });
148
+ }), activeEditor.registerCommand(CAN_UNDO_COMMAND, payload => {
149
+ setCanUndo(payload);
150
+ return false;
151
+ }, COMMAND_PRIORITY_CRITICAL), activeEditor.registerCommand(CAN_REDO_COMMAND, payload => {
152
+ setCanRedo(payload);
153
+ return false;
154
+ }, COMMAND_PRIORITY_CRITICAL)), [$updateToolbar, activeEditor, editor]);
155
+ const applyStyleText = useCallback(styles => {
156
+ activeEditor.update(() => {
157
+ const selection = $getSelection();
158
+ if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {
159
+ $patchStyleText(selection, styles);
160
+ }
161
+ });
162
+ }, [activeEditor]);
163
+ const onFontColorSelect = useCallback(value => {
164
+ applyStyleText({
165
+ color: value
166
+ });
167
+ }, [applyStyleText]);
168
+ const onBgColorSelect = useCallback(value => {
169
+ applyStyleText({
170
+ 'background-color': value
171
+ });
172
+ }, [applyStyleText]);
173
+ return /*#__PURE__*/React.createElement("div", {
174
+ id: id,
175
+ className: [baseClassName, componentClassName, userClassName, `x-${baseBgColor}`].filter(e => e).join(' '),
176
+ style: inlineStyles
177
+ }, /*#__PURE__*/React.createElement("div", {
178
+ className: "group"
179
+ }, /*#__PURE__*/React.createElement("button", {
180
+ type: "button",
181
+ onClick: () => editor.dispatchCommand(UNDO_COMMAND),
182
+ className: "ai-icon",
183
+ disabled: !canUndo || !isEditable
184
+ }, "A"), /*#__PURE__*/React.createElement("button", {
185
+ type: "button",
186
+ className: "ai-icon",
187
+ onClick: () => editor.dispatchCommand(REDO_COMMAND),
188
+ disabled: !canRedo || !isEditable
189
+ }, "B")), /*#__PURE__*/React.createElement(BlockFormatDropDown, {
190
+ blockType: blockType,
191
+ editor: editor,
192
+ rootType: rootType
193
+ }), /*#__PURE__*/React.createElement("div", {
194
+ className: "group"
195
+ }, /*#__PURE__*/React.createElement("button", {
196
+ type: "button",
197
+ className: isBold ? 'active' : undefined,
198
+ onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')
199
+ }, /*#__PURE__*/React.createElement("span", {
200
+ className: "icon"
201
+ }, "|")), /*#__PURE__*/React.createElement("button", {
202
+ type: "button",
203
+ className: isItalic ? 'active' : undefined,
204
+ onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')
205
+ }, /*#__PURE__*/React.createElement("span", {
206
+ className: "icon"
207
+ }, "}")), /*#__PURE__*/React.createElement("button", {
208
+ type: "button",
209
+ className: isUnderline ? 'active' : undefined,
210
+ onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline')
211
+ }, /*#__PURE__*/React.createElement("span", {
212
+ className: "icon"
213
+ }, "~")), /*#__PURE__*/React.createElement("button", {
214
+ type: "button",
215
+ className: isStrikethrough ? 'active' : undefined,
216
+ onClick: () => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough')
217
+ }, /*#__PURE__*/React.createElement("span", {
218
+ className: "icon"
219
+ }, "?")), /*#__PURE__*/React.createElement("button", {
220
+ type: "button",
221
+ className: isLink ? 'active' : undefined,
222
+ onClick: formatLink
223
+ }, /*#__PURE__*/React.createElement("span", {
224
+ className: "icon"
225
+ }, "]"))), /*#__PURE__*/React.createElement(FontSizeDropDown, {
226
+ editor: editor,
227
+ value: fontSize
228
+ }), /*#__PURE__*/React.createElement("div", {
229
+ className: "group"
230
+ }, /*#__PURE__*/React.createElement(ColorPicker, {
231
+ icon: "'",
232
+ color: fontColor,
233
+ onChange: onFontColorSelect
234
+ }), /*#__PURE__*/React.createElement(ColorPicker, {
235
+ icon: "#",
236
+ color: bgColor,
237
+ onChange: onBgColorSelect
238
+ })), /*#__PURE__*/React.createElement("div", {
239
+ className: "group"
240
+ }, /*#__PURE__*/React.createElement("button", {
241
+ type: "button",
242
+ onClick: () => editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'left')
243
+ }, /*#__PURE__*/React.createElement("span", {
244
+ className: "icon"
245
+ }, "^")), /*#__PURE__*/React.createElement("button", {
246
+ type: "button",
247
+ onClick: () => editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'center')
248
+ }, /*#__PURE__*/React.createElement("span", {
249
+ className: "icon"
250
+ }, "_")), /*#__PURE__*/React.createElement("button", {
251
+ type: "button",
252
+ onClick: () => editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'right')
253
+ }, /*#__PURE__*/React.createElement("span", {
254
+ className: "icon"
255
+ }, "`")), /*#__PURE__*/React.createElement("button", {
256
+ type: "button",
257
+ onClick: () => editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'justify')
258
+ }, /*#__PURE__*/React.createElement("span", {
259
+ className: "icon"
260
+ }, "{"))));
261
+ };
262
+ ToolbarPlugin.propTypes = {
263
+ /**
264
+ * The HTML id for this element
265
+ */
266
+ id: PropTypes.string,
267
+ /**
268
+ * The HTML class names for this element
269
+ */
270
+ className: PropTypes.string,
271
+ /**
272
+ * The React-written, css properties for this element.
273
+ */
274
+ style: PropTypes.objectOf(PropTypes.string),
275
+ /**
276
+ * Base background color
277
+ */
278
+ baseBgColor: PropTypes.string
279
+ };
280
+ ToolbarPlugin.defaultProps = {
281
+ baseBgColor: 'background-far'
282
+ };
283
+ export default ToolbarPlugin;
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as ToolbarPlugin } from "./ToolbarPlugin";
@@ -0,0 +1,56 @@
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
+
8
+ $default-gap: calc(var(--gap) / 2);
9
+ $default-padding: .55em .75em;
10
+ $default-input-border-radius: var(--theme-default-input-border-radius);
11
+ $default-border: var(--theme-default-input-border);
12
+ $default-icon-color: var(--soft-ui-icons);
13
+
14
+ .#{bem.$base}.toolbar-plugin {
15
+ align-items: center;
16
+ border-inline: $default-border;
17
+ border-top: $default-border;
18
+ border-top-left-radius: $default-input-border-radius;
19
+ border-top-right-radius: $default-input-border-radius;
20
+ display: flex;
21
+ flex-wrap: wrap;
22
+ padding-block: calc(var(--theme-default-padding) / 4);
23
+
24
+ > .ds + .group {
25
+ border-left: 1px solid var(--soft-background-inputs);
26
+ }
27
+
28
+ > .group {
29
+ display: flex;
30
+ gap: calc(var(--gap) / 2);
31
+
32
+ > button {
33
+ background: var(--x);
34
+ border: 0;
35
+ border-radius: calc(var(--theme-default-border-radius) / 2);
36
+ color: $default-icon-color;
37
+ cursor: pointer;
38
+ margin: 0;
39
+ padding: $default-padding;
40
+
41
+ &:hover,
42
+ &.active {
43
+ background: var(--hard-x);
44
+ }
45
+ }
46
+
47
+ &:not(.#{bem.$base}) {
48
+ padding-inline: calc(var(--theme-default-padding) / 4);
49
+ }
50
+
51
+
52
+ &:not(:last-child, .#{bem.$base}) {
53
+ border-right: 1px solid var(--soft-background-inputs);
54
+ }
55
+ }
56
+ }
@@ -1,3 +1,6 @@
1
- export { default as Toolbar } from "./Toolbar";
1
+ export { BlockFormatDropDown } from "./BlockFormatDropDown";
2
2
  export { default as TreeViewPlugin } from "./TreeViewPlugin";
3
- export { default as StopPropagationPlugin } from "./StopPropagationPlugin";
3
+ export { default as StopPropagationPlugin } from "./StopPropagationPlugin";
4
+ export { ToolbarPlugin } from "./ToolbarPlugin";
5
+ export { ColorPicker } from "./ColorPicker";
6
+ export { FontSizeDropDown } from "./FontSizeDropDown";