@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,292 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { useState, useRef } from 'react'
5
+
6
+ import {
7
+ $createParagraphNode,
8
+ $getSelection,
9
+ $isRangeSelection,
10
+ DEPRECATED_$isGridSelection,
11
+ } from 'lexical'
12
+
13
+ import {
14
+ $createHeadingNode,
15
+ $createQuoteNode,
16
+ } from '@lexical/rich-text'
17
+
18
+ import {
19
+ $setBlocksType,
20
+ } from '@lexical/selection'
21
+
22
+ import {
23
+ INSERT_CHECK_LIST_COMMAND,
24
+ INSERT_ORDERED_LIST_COMMAND,
25
+ INSERT_UNORDERED_LIST_COMMAND,
26
+ REMOVE_LIST_COMMAND,
27
+ } from '@lexical/list'
28
+
29
+ import { $createCodeNode } from '@lexical/code'
30
+
31
+ import PropTypes from 'prop-types'
32
+
33
+ import styleNames from '@pareto-engineering/bem/exports'
34
+
35
+ import './styles.scss'
36
+
37
+ import { Popover } from 'ui/a'
38
+
39
+ import { useOutsideClick } from 'ui/utils'
40
+
41
+ import { blockTypeToBlockName } from '../ToolbarPlugin/ToolbarPlugin'
42
+
43
+ // Local Definitions
44
+
45
+ const baseClassName = styleNames.base
46
+
47
+ const componentClassName = 'block-format-drop-down'
48
+
49
+ const iconsMap = {
50
+ bullet :{ icon: '.', className: 'icon' },
51
+ check :{ icon: '4', className: 'ai-icon' },
52
+ code :{ icon: '6', className: 'ai-icon' },
53
+ h1 :{ icon: '1', className: 'ai-icon' },
54
+ h2 :{ icon: '2', className: 'ai-icon' },
55
+ h3 :{ icon: '3', className: 'ai-icon' },
56
+ number :{ icon: '-', className: 'icon' },
57
+ paragraph:{ icon: 'N', className: 'ai-icon' },
58
+ quote :{ icon: '5', className: 'ai-icon' },
59
+
60
+ }
61
+ /**
62
+ * This is the component description.
63
+ */
64
+ const BlockFormatDropDown = ({
65
+ id,
66
+ className:userClassName,
67
+ style,
68
+ editor,
69
+ blockType,
70
+ // ...otherProps
71
+ }) => {
72
+ const formatParagraph = () => {
73
+ editor.update(() => {
74
+ const selection = $getSelection()
75
+ if (
76
+ $isRangeSelection(selection)
77
+ || DEPRECATED_$isGridSelection(selection)
78
+ ) {
79
+ $setBlocksType(selection, () => $createParagraphNode())
80
+ }
81
+ })
82
+ }
83
+
84
+ const formatHeading = (headingSize) => {
85
+ if (blockType !== headingSize) {
86
+ editor.update(() => {
87
+ const selection = $getSelection()
88
+ if (
89
+ $isRangeSelection(selection)
90
+ || DEPRECATED_$isGridSelection(selection)
91
+ ) {
92
+ $setBlocksType(selection, () => $createHeadingNode(headingSize))
93
+ }
94
+ })
95
+ }
96
+ }
97
+
98
+ const formatBulletList = () => {
99
+ if (blockType !== 'bullet') {
100
+ editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined)
101
+ } else {
102
+ editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
103
+ }
104
+ }
105
+
106
+ const formatCheckList = () => {
107
+ if (blockType !== 'check') {
108
+ editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined)
109
+ } else {
110
+ editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
111
+ }
112
+ }
113
+
114
+ const formatNumberedList = () => {
115
+ if (blockType !== 'number') {
116
+ editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined)
117
+ } else {
118
+ editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
119
+ }
120
+ }
121
+
122
+ const formatQuote = () => {
123
+ if (blockType !== 'quote') {
124
+ editor.update(() => {
125
+ const selection = $getSelection()
126
+ if (
127
+ $isRangeSelection(selection)
128
+ || DEPRECATED_$isGridSelection(selection)
129
+ ) {
130
+ $setBlocksType(selection, () => $createQuoteNode())
131
+ }
132
+ })
133
+ }
134
+ }
135
+
136
+ const formatCode = () => {
137
+ if (blockType !== 'code') {
138
+ editor.update(() => {
139
+ let selection = $getSelection()
140
+
141
+ if (
142
+ $isRangeSelection(selection)
143
+ || DEPRECATED_$isGridSelection(selection)
144
+ ) {
145
+ if (selection.isCollapsed()) {
146
+ $setBlocksType(selection, () => $createCodeNode())
147
+ } else {
148
+ const textContent = selection.getTextContent()
149
+ const codeNode = $createCodeNode()
150
+ selection.insertNodes([codeNode])
151
+ selection = $getSelection()
152
+ if ($isRangeSelection(selection)) selection.insertRawText(textContent)
153
+ }
154
+ }
155
+ })
156
+ }
157
+ }
158
+
159
+ const parentRef = useRef(null)
160
+
161
+ const [isOpen, setIsOpen] = useState(false)
162
+
163
+ useOutsideClick(parentRef, () => setIsOpen(false))
164
+
165
+ return (
166
+ <button
167
+ id={id}
168
+ className={[
169
+ baseClassName,
170
+ componentClassName,
171
+ userClassName,
172
+ 'group',
173
+ ]
174
+ .filter((e) => e)
175
+ .join(' ')}
176
+ style={style}
177
+ ref={parentRef}
178
+ type="button"
179
+ onClick={() => setIsOpen(!isOpen)}
180
+ // {...otherProps}
181
+ >
182
+ <span className={iconsMap[blockType].className}>
183
+ {iconsMap[blockType].icon}
184
+ </span>
185
+ <span>{blockTypeToBlockName[blockType]}</span>
186
+ <span className="icon">V</span>
187
+ {isOpen && (
188
+ <Popover
189
+ parentRef={parentRef}
190
+ isOpen={isOpen}
191
+ color="background-far"
192
+ >
193
+ <button
194
+ className={`item ${blockType === 'paragraph' ? 'active' : ''}`}
195
+ onClick={formatParagraph}
196
+ type="button"
197
+ >
198
+ <span className="ai-icon">N</span>
199
+ <span className="text">Normal</span>
200
+ </button>
201
+ <button
202
+ className={`item ${blockType === 'h1' ? 'active' : ''}`}
203
+ onClick={() => formatHeading('h1')}
204
+ type="button"
205
+ >
206
+ <span className="ai-icon">1</span>
207
+ <span className="text">Heading 1</span>
208
+ </button>
209
+ <button
210
+ className={`item ${blockType === 'h2' ? 'active' : ''}`}
211
+ onClick={() => formatHeading('h2')}
212
+ type="button"
213
+ >
214
+ <span className="ai-icon">2</span>
215
+ <span className="text">Heading 2</span>
216
+ </button>
217
+ <button
218
+ className={`item ${blockType === 'h3' ? 'active' : ''}`}
219
+ onClick={() => formatHeading('h3')}
220
+ type="button"
221
+ >
222
+ <span className="ai-icon">3</span>
223
+ <span className="text">Heading 3</span>
224
+ </button>
225
+ <button
226
+ className={`item ${blockType === 'bullet' ? 'active' : ''}`}
227
+ onClick={formatBulletList}
228
+ type="button"
229
+ >
230
+ <span className="icon">.</span>
231
+ <span className="text">Bullet List</span>
232
+ </button>
233
+ <button
234
+ className={`item ${blockType === 'number' ? 'active' : ''}`}
235
+ onClick={formatNumberedList}
236
+ type="button"
237
+ >
238
+ <span className="icon">-</span>
239
+ <span className="text">Numbered List</span>
240
+ </button>
241
+ <button
242
+ className={`item ${blockType === 'check' ? 'active' : ''}`}
243
+ onClick={formatCheckList}
244
+ type="button"
245
+ >
246
+ <span className="ai-icon">4</span>
247
+ <span className="text">Check List</span>
248
+ </button>
249
+ <button
250
+ className={`item ${blockType === 'quote' ? 'active' : ''}`}
251
+ onClick={formatQuote}
252
+ type="button"
253
+ >
254
+ <span className="ai-icon">5</span>
255
+ <span className="text">Quote</span>
256
+ </button>
257
+ <button
258
+ className={`item ${blockType === 'code' ? 'active' : ''}`}
259
+ onClick={formatCode}
260
+ type="button"
261
+ >
262
+ <span className="ai-icon">6</span>
263
+ <span className="text">Code Block</span>
264
+ </button>
265
+ </Popover>
266
+ )}
267
+ </button>
268
+ )
269
+ }
270
+
271
+ BlockFormatDropDown.propTypes = {
272
+ /**
273
+ * The HTML id for this element
274
+ */
275
+ id:PropTypes.string,
276
+
277
+ /**
278
+ * The HTML class names for this element
279
+ */
280
+ className:PropTypes.string,
281
+
282
+ /**
283
+ * The React-written, css properties for this element.
284
+ */
285
+ style:PropTypes.objectOf(PropTypes.string),
286
+ }
287
+
288
+ BlockFormatDropDown.defaultProps = {
289
+ // someProp:false
290
+ }
291
+
292
+ export default BlockFormatDropDown
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ export { default as BlockFormatDropDown } from './BlockFormatDropDown'
@@ -0,0 +1,55 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ $default-width: 15em;
6
+
7
+ .#{bem.$base}.block-format-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,110 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { useRef, useEffect, useState } from 'react'
5
+
6
+ import { ColorPicker as ReactColorPicker, useColor } from 'react-color-palette'
7
+
8
+ import PropTypes from 'prop-types'
9
+
10
+ import styleNames from '@pareto-engineering/bem/exports'
11
+
12
+ import './styles.scss'
13
+
14
+ import { Popover } from 'ui/a'
15
+
16
+ import { useOutsideClick } from 'ui/utils'
17
+ // Local Definitions
18
+
19
+ const baseClassName = styleNames.base
20
+
21
+ const componentClassName = 'color-picker'
22
+
23
+ /**
24
+ * This is the component description.
25
+ */
26
+ const ColorPicker = ({
27
+ id,
28
+ className:userClassName,
29
+ style,
30
+ icon,
31
+ color,
32
+ onChange,
33
+ // ...otherProps
34
+ }) => {
35
+ const [colorValue, setColor] = useColor(color)
36
+
37
+ const parentRef = useRef(null)
38
+
39
+ const [isOpen, setIsOpen] = useState(false)
40
+
41
+ useOutsideClick(parentRef, () => setIsOpen(false))
42
+
43
+ useEffect(() => {
44
+ const { hex } = colorValue
45
+ if (hex) {
46
+ onChange(hex)
47
+ }
48
+ }, [colorValue])
49
+
50
+ return (
51
+ // eslint-disable-next-line jsx-a11y/control-has-associated-label
52
+ <div
53
+ id={id}
54
+ className={[
55
+
56
+ baseClassName,
57
+
58
+ componentClassName,
59
+ userClassName,
60
+ ]
61
+ .filter((e) => e)
62
+ .join(' ')}
63
+ style={style}
64
+ ref={parentRef}
65
+ // {...otherProps}
66
+ >
67
+ <button
68
+ type="button"
69
+ onClick={() => setIsOpen(!isOpen)}
70
+ >
71
+ <span className="icon">{icon}</span>
72
+ <span className="icon">V</span>
73
+ </button>
74
+ <Popover
75
+ parentRef={parentRef}
76
+ isOpen={isOpen}
77
+ color="background-far"
78
+ >
79
+ <ReactColorPicker
80
+ color={colorValue}
81
+ onChange={setColor}
82
+ hideInput
83
+ />
84
+ </Popover>
85
+ </div>
86
+ )
87
+ }
88
+
89
+ ColorPicker.propTypes = {
90
+ /**
91
+ * The HTML id for this element
92
+ */
93
+ id:PropTypes.string,
94
+
95
+ /**
96
+ * The HTML class names for this element
97
+ */
98
+ className:PropTypes.string,
99
+
100
+ /**
101
+ * The React-written, css properties for this element.
102
+ */
103
+ style:PropTypes.objectOf(PropTypes.string),
104
+ }
105
+
106
+ ColorPicker.defaultProps = {
107
+ // someProp:false
108
+ }
109
+
110
+ 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,134 @@
1
+ /* @pareto-engineering/generator-front 1.0.12 */
2
+ import * as React from 'react'
3
+
4
+ import { useState, useRef, useCallback } from 'react'
5
+
6
+ import { $getSelection, $isRangeSelection } from 'lexical'
7
+
8
+ import { $patchStyleText } from '@lexical/selection'
9
+
10
+ import PropTypes from 'prop-types'
11
+
12
+ import styleNames from '@pareto-engineering/bem/exports'
13
+
14
+ import './styles.scss'
15
+
16
+ import { Popover } from 'ui/a'
17
+
18
+ import { useOutsideClick } from 'ui/utils'
19
+
20
+ // Local Definitions
21
+
22
+ const baseClassName = styleNames.base
23
+
24
+ const componentClassName = 'font-size-drop-down'
25
+
26
+ const FONT_SIZE_OPTIONS = [
27
+ ['10px', '10px'],
28
+ ['11px', '11px'],
29
+ ['12px', '12px'],
30
+ ['13px', '13px'],
31
+ ['14px', '14px'],
32
+ ['15px', '15px'],
33
+ ['16px', '16px'],
34
+ ['17px', '17px'],
35
+ ['18px', '18px'],
36
+ ['19px', '19px'],
37
+ ['20px', '20px'],
38
+ ]
39
+
40
+ /**
41
+ * This is the component description.
42
+ */
43
+ const FontSizeDropDown = ({
44
+ id,
45
+ className:userClassName,
46
+ style,
47
+ editor,
48
+ value,
49
+ // ...otherProps
50
+ }) => {
51
+ const parentRef = useRef(null)
52
+
53
+ const [isOpen, setIsOpen] = useState(false)
54
+
55
+ useOutsideClick(parentRef, () => setIsOpen(false))
56
+
57
+ const handleClick = useCallback(
58
+ (option) => {
59
+ editor.update(() => {
60
+ const selection = $getSelection()
61
+ if ($isRangeSelection(selection)) {
62
+ $patchStyleText(selection, {
63
+ 'font-size':option,
64
+ })
65
+ }
66
+ })
67
+ },
68
+ [editor],
69
+ )
70
+
71
+ return (
72
+ <button
73
+ id={id}
74
+ className={[
75
+ baseClassName,
76
+ componentClassName,
77
+ userClassName,
78
+ 'group',
79
+ ]
80
+ .filter((e) => e)
81
+ .join(' ')}
82
+ style={style}
83
+ ref={parentRef}
84
+ type="button"
85
+ onClick={() => setIsOpen(!isOpen)}
86
+ // {...otherProps}
87
+ >
88
+ <span>{value}</span>
89
+ <span className="icon">
90
+ V
91
+ </span>
92
+ {isOpen && (
93
+ <Popover
94
+ parentRef={parentRef}
95
+ isOpen={isOpen}
96
+ color="background-far"
97
+ >
98
+ {FONT_SIZE_OPTIONS.map(([option, text]) => (
99
+ <button
100
+ className={`item ${value === option ? 'active' : ''}`}
101
+ onClick={() => handleClick(option)}
102
+ type="button"
103
+ >
104
+ <span className="text">{text}</span>
105
+ </button>
106
+ ))}
107
+ </Popover>
108
+ )}
109
+ </button>
110
+ )
111
+ }
112
+
113
+ FontSizeDropDown.propTypes = {
114
+ /**
115
+ * The HTML id for this element
116
+ */
117
+ id:PropTypes.string,
118
+
119
+ /**
120
+ * The HTML class names for this element
121
+ */
122
+ className:PropTypes.string,
123
+
124
+ /**
125
+ * The React-written, css properties for this element.
126
+ */
127
+ style:PropTypes.objectOf(PropTypes.string),
128
+ }
129
+
130
+ FontSizeDropDown.defaultProps = {
131
+ // someProp:false
132
+ }
133
+
134
+ 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
+ }