@datalayer/jupyter-lexical 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/lib/components/InsertEquationDialog.d.ts +6 -0
  4. package/lib/components/InsertEquationDialog.js +17 -0
  5. package/lib/components/InsertEquationDialog.js.map +1 -0
  6. package/lib/components/InsertImageDialog.d.ts +13 -0
  7. package/lib/components/InsertImageDialog.js +48 -0
  8. package/lib/components/InsertImageDialog.js.map +1 -0
  9. package/lib/components/JupyterCellComponent.d.ts +2 -0
  10. package/lib/components/JupyterCellComponent.js +12 -0
  11. package/lib/components/JupyterCellComponent.js.map +1 -0
  12. package/lib/components/JupyterOutputComponent.d.ts +13 -0
  13. package/lib/components/JupyterOutputComponent.js +8 -0
  14. package/lib/components/JupyterOutputComponent.js.map +1 -0
  15. package/lib/convert/LexicalToNbFormat.d.ts +4 -0
  16. package/lib/convert/LexicalToNbFormat.js +100 -0
  17. package/lib/convert/LexicalToNbFormat.js.map +1 -0
  18. package/lib/convert/NbFormatToLexical.d.ts +4 -0
  19. package/lib/convert/NbFormatToLexical.js +31 -0
  20. package/lib/convert/NbFormatToLexical.js.map +1 -0
  21. package/lib/convert/markdown/MarkdownExport.d.ts +11 -0
  22. package/lib/convert/markdown/MarkdownExport.js +129 -0
  23. package/lib/convert/markdown/MarkdownExport.js.map +1 -0
  24. package/lib/convert/markdown/MarkdownImport.d.ts +2 -0
  25. package/lib/convert/markdown/MarkdownImport.js +246 -0
  26. package/lib/convert/markdown/MarkdownImport.js.map +1 -0
  27. package/lib/convert/markdown/MarkdownShortcuts.d.ts +10 -0
  28. package/lib/convert/markdown/MarkdownShortcuts.js +254 -0
  29. package/lib/convert/markdown/MarkdownShortcuts.js.map +1 -0
  30. package/lib/convert/markdown/MarkdownTransformers.d.ts +39 -0
  31. package/lib/convert/markdown/MarkdownTransformers.js +242 -0
  32. package/lib/convert/markdown/MarkdownTransformers.js.map +1 -0
  33. package/lib/convert/markdown/convertToMarkdown.d.ts +1 -0
  34. package/lib/convert/markdown/convertToMarkdown.js +126 -0
  35. package/lib/convert/markdown/convertToMarkdown.js.map +1 -0
  36. package/lib/convert/markdown/index.d.ts +17 -0
  37. package/lib/convert/markdown/index.js +46 -0
  38. package/lib/convert/markdown/index.js.map +1 -0
  39. package/lib/convert/markdown/utils.d.ts +24 -0
  40. package/lib/convert/markdown/utils.js +303 -0
  41. package/lib/convert/markdown/utils.js.map +1 -0
  42. package/lib/convert/transformers/MarkdownTransformers.d.ts +13 -0
  43. package/lib/convert/transformers/MarkdownTransformers.js +178 -0
  44. package/lib/convert/transformers/MarkdownTransformers.js.map +1 -0
  45. package/lib/examples/App.d.ts +1 -0
  46. package/lib/examples/App.js +22 -0
  47. package/lib/examples/App.js.map +1 -0
  48. package/lib/examples/Editor.d.ts +9 -0
  49. package/lib/examples/Editor.js +81 -0
  50. package/lib/examples/Editor.js.map +1 -0
  51. package/lib/examples/Example.d.ts +1 -0
  52. package/lib/examples/Example.js +11 -0
  53. package/lib/examples/Example.js.map +1 -0
  54. package/lib/examples/content/Example.ipynb.json +98 -0
  55. package/lib/examples/content/Example.lexical.json +259 -0
  56. package/lib/examples/context/LexicalContext.d.ts +13 -0
  57. package/lib/examples/context/LexicalContext.js +22 -0
  58. package/lib/examples/context/LexicalContext.js.map +1 -0
  59. package/lib/examples/plugins/ToolbarPlugin.d.ts +2 -0
  60. package/lib/examples/plugins/ToolbarPlugin.js +448 -0
  61. package/lib/examples/plugins/ToolbarPlugin.js.map +1 -0
  62. package/lib/examples/plugins/TreeViewPlugin.d.ts +2 -0
  63. package/lib/examples/plugins/TreeViewPlugin.js +13 -0
  64. package/lib/examples/plugins/TreeViewPlugin.js.map +1 -0
  65. package/lib/examples/themes/Theme.d.ts +10 -0
  66. package/lib/examples/themes/Theme.js +94 -0
  67. package/lib/examples/themes/Theme.js.map +1 -0
  68. package/lib/hooks/useModal.d.ts +2 -0
  69. package/lib/hooks/useModal.js +39 -0
  70. package/lib/hooks/useModal.js.map +1 -0
  71. package/lib/images/yellow-flower-small.jpg +0 -0
  72. package/lib/index.d.ts +40 -0
  73. package/lib/index.js +55 -0
  74. package/lib/index.js.map +1 -0
  75. package/lib/jupyter/index.d.ts +0 -0
  76. package/lib/jupyter/index.js +6 -0
  77. package/lib/jupyter/index.js.map +1 -0
  78. package/lib/jupyter/lab/Example.d.ts +1 -0
  79. package/lib/jupyter/lab/Example.js +11 -0
  80. package/lib/jupyter/lab/Example.js.map +1 -0
  81. package/lib/jupyter/lab/__tests__/datalayer.spec.d.ts +0 -0
  82. package/lib/jupyter/lab/__tests__/datalayer.spec.js +11 -0
  83. package/lib/jupyter/lab/__tests__/datalayer.spec.js.map +1 -0
  84. package/lib/jupyter/lab/component/MockComponent.d.ts +2 -0
  85. package/lib/jupyter/lab/component/MockComponent.js +17 -0
  86. package/lib/jupyter/lab/component/MockComponent.js.map +1 -0
  87. package/lib/jupyter/lab/component/MockTab1.d.ts +2 -0
  88. package/lib/jupyter/lab/component/MockTab1.js +14 -0
  89. package/lib/jupyter/lab/component/MockTab1.js.map +1 -0
  90. package/lib/jupyter/lab/handler.d.ts +8 -0
  91. package/lib/jupyter/lab/handler.js +41 -0
  92. package/lib/jupyter/lab/handler.js.map +1 -0
  93. package/lib/jupyter/lab/index.d.ts +7 -0
  94. package/lib/jupyter/lab/index.js +73 -0
  95. package/lib/jupyter/lab/index.js.map +1 -0
  96. package/lib/jupyter/lab/widget.d.ts +6 -0
  97. package/lib/jupyter/lab/widget.js +18 -0
  98. package/lib/jupyter/lab/widget.js.map +1 -0
  99. package/lib/nodes/EquationNode.d.ts +31 -0
  100. package/lib/nodes/EquationNode.js +118 -0
  101. package/lib/nodes/EquationNode.js.map +1 -0
  102. package/lib/nodes/ImageNode.css +50 -0
  103. package/lib/nodes/ImageNode.d.ts +58 -0
  104. package/lib/nodes/ImageNode.js +275 -0
  105. package/lib/nodes/ImageNode.js.map +1 -0
  106. package/lib/nodes/JupyterCodeHighlightNode.d.ts +49 -0
  107. package/lib/nodes/JupyterCodeHighlightNode.js +165 -0
  108. package/lib/nodes/JupyterCodeHighlightNode.js.map +1 -0
  109. package/lib/nodes/JupyterCodeHighlighter.d.ts +28 -0
  110. package/lib/nodes/JupyterCodeHighlighter.js +522 -0
  111. package/lib/nodes/JupyterCodeHighlighter.js.map +1 -0
  112. package/lib/nodes/JupyterCodeNode.d.ts +50 -0
  113. package/lib/nodes/JupyterCodeNode.js +277 -0
  114. package/lib/nodes/JupyterCodeNode.js.map +1 -0
  115. package/lib/nodes/JupyterOutputNode.d.ts +58 -0
  116. package/lib/nodes/JupyterOutputNode.js +144 -0
  117. package/lib/nodes/JupyterOutputNode.js.map +1 -0
  118. package/lib/nodes/YouTubeNode.d.ts +28 -0
  119. package/lib/nodes/YouTubeNode.js +56 -0
  120. package/lib/nodes/YouTubeNode.js.map +1 -0
  121. package/lib/plugins/AutoEmbedPlugin.d.ts +17 -0
  122. package/lib/plugins/AutoEmbedPlugin.js +110 -0
  123. package/lib/plugins/AutoEmbedPlugin.js.map +1 -0
  124. package/lib/plugins/AutoLinkPlugin.d.ts +2 -0
  125. package/lib/plugins/AutoLinkPlugin.js +34 -0
  126. package/lib/plugins/AutoLinkPlugin.js.map +1 -0
  127. package/lib/plugins/CodeActionMenuPlugin.css +52 -0
  128. package/lib/plugins/CodeActionMenuPlugin.d.ts +12 -0
  129. package/lib/plugins/CodeActionMenuPlugin.js +108 -0
  130. package/lib/plugins/CodeActionMenuPlugin.js.map +1 -0
  131. package/lib/plugins/ComponentPickerMenuPlugin.d.ts +2 -0
  132. package/lib/plugins/ComponentPickerMenuPlugin.js +244 -0
  133. package/lib/plugins/ComponentPickerMenuPlugin.js.map +1 -0
  134. package/lib/plugins/EquationsPlugin.d.ts +21 -0
  135. package/lib/plugins/EquationsPlugin.js +48 -0
  136. package/lib/plugins/EquationsPlugin.js.map +1 -0
  137. package/lib/plugins/HorizontalRulePlugin.d.ts +2 -0
  138. package/lib/plugins/HorizontalRulePlugin.js +40 -0
  139. package/lib/plugins/HorizontalRulePlugin.js.map +1 -0
  140. package/lib/plugins/ImagesPlugin.d.ts +25 -0
  141. package/lib/plugins/ImagesPlugin.js +212 -0
  142. package/lib/plugins/ImagesPlugin.js.map +1 -0
  143. package/lib/plugins/JupyterPlugin.css +13 -0
  144. package/lib/plugins/JupyterPlugin.d.ts +16 -0
  145. package/lib/plugins/JupyterPlugin.js +169 -0
  146. package/lib/plugins/JupyterPlugin.js.map +1 -0
  147. package/lib/plugins/ListMaxIndentLevelPlugin.d.ts +4 -0
  148. package/lib/plugins/ListMaxIndentLevelPlugin.js +49 -0
  149. package/lib/plugins/ListMaxIndentLevelPlugin.js.map +1 -0
  150. package/lib/plugins/MardownPlugin.d.ts +2 -0
  151. package/lib/plugins/MardownPlugin.js +20 -0
  152. package/lib/plugins/MardownPlugin.js.map +1 -0
  153. package/lib/plugins/NbformatContentPlugin.d.ts +6 -0
  154. package/lib/plugins/NbformatContentPlugin.js +20 -0
  155. package/lib/plugins/NbformatContentPlugin.js.map +1 -0
  156. package/lib/plugins/TableOfContentsPlugin.css +87 -0
  157. package/lib/plugins/TableOfContentsPlugin.d.ts +3 -0
  158. package/lib/plugins/TableOfContentsPlugin.js +115 -0
  159. package/lib/plugins/TableOfContentsPlugin.js.map +1 -0
  160. package/lib/plugins/YouTubePlugin.d.ts +4 -0
  161. package/lib/plugins/YouTubePlugin.js +34 -0
  162. package/lib/plugins/YouTubePlugin.js.map +1 -0
  163. package/lib/ui/Button.css +40 -0
  164. package/lib/ui/Button.d.ts +18 -0
  165. package/lib/ui/Button.js +8 -0
  166. package/lib/ui/Button.js.map +1 -0
  167. package/lib/ui/ContentEditable.css +24 -0
  168. package/lib/ui/ContentEditable.d.ts +5 -0
  169. package/lib/ui/ContentEditable.js +20 -0
  170. package/lib/ui/ContentEditable.js.map +1 -0
  171. package/lib/ui/CopyButton.d.ts +7 -0
  172. package/lib/ui/CopyButton.js +47 -0
  173. package/lib/ui/CopyButton.js.map +1 -0
  174. package/lib/ui/Dialog.css +23 -0
  175. package/lib/ui/Dialog.d.ts +16 -0
  176. package/lib/ui/Dialog.js +21 -0
  177. package/lib/ui/Dialog.js.map +1 -0
  178. package/lib/ui/DropDown.d.ts +23 -0
  179. package/lib/ui/DropDown.js +119 -0
  180. package/lib/ui/DropDown.js.map +1 -0
  181. package/lib/ui/EquationEditor.css +42 -0
  182. package/lib/ui/EquationEditor.d.ts +18 -0
  183. package/lib/ui/EquationEditor.js +31 -0
  184. package/lib/ui/EquationEditor.js.map +1 -0
  185. package/lib/ui/FileInput.d.ts +15 -0
  186. package/lib/ui/FileInput.js +18 -0
  187. package/lib/ui/FileInput.js.map +1 -0
  188. package/lib/ui/ImageResizer.d.ts +16 -0
  189. package/lib/ui/ImageResizer.js +166 -0
  190. package/lib/ui/ImageResizer.js.map +1 -0
  191. package/lib/ui/Input.css +37 -0
  192. package/lib/ui/KatexEquationAlterer.css +45 -0
  193. package/lib/ui/KatexEquationAlterer.d.ts +7 -0
  194. package/lib/ui/KatexEquationAlterer.js +33 -0
  195. package/lib/ui/KatexEquationAlterer.js.map +1 -0
  196. package/lib/ui/KatexRenderer.d.ts +6 -0
  197. package/lib/ui/KatexRenderer.js +36 -0
  198. package/lib/ui/KatexRenderer.js.map +1 -0
  199. package/lib/ui/Modal.css +67 -0
  200. package/lib/ui/Modal.d.ts +15 -0
  201. package/lib/ui/Modal.js +58 -0
  202. package/lib/ui/Modal.js.map +1 -0
  203. package/lib/ui/Placeholder.css +29 -0
  204. package/lib/ui/Placeholder.d.ts +14 -0
  205. package/lib/ui/Placeholder.js +7 -0
  206. package/lib/ui/Placeholder.js.map +1 -0
  207. package/lib/ui/PrettierButton.css +20 -0
  208. package/lib/ui/PrettierButton.tsx_tmp +133 -0
  209. package/lib/ui/TextInput.d.ts +16 -0
  210. package/lib/ui/TextInput.js +20 -0
  211. package/lib/ui/TextInput.js.map +1 -0
  212. package/lib/utils/canUseDOM.d.ts +8 -0
  213. package/lib/utils/canUseDOM.js +16 -0
  214. package/lib/utils/canUseDOM.js.map +1 -0
  215. package/lib/utils/debouncer.d.ts +1 -0
  216. package/lib/utils/debouncer.js +24 -0
  217. package/lib/utils/debouncer.js.map +1 -0
  218. package/lib/utils/invariant.d.ts +8 -0
  219. package/lib/utils/invariant.js +23 -0
  220. package/lib/utils/invariant.js.map +1 -0
  221. package/lib/utils/join.d.ts +8 -0
  222. package/lib/utils/join.js +16 -0
  223. package/lib/utils/join.js.map +1 -0
  224. package/lib/utils/selection.d.ts +8 -0
  225. package/lib/utils/selection.js +14 -0
  226. package/lib/utils/selection.js.map +1 -0
  227. package/lib/utils/useLayoutEffect.d.ts +10 -0
  228. package/lib/utils/useLayoutEffect.js +19 -0
  229. package/lib/utils/useLayoutEffect.js.map +1 -0
  230. package/package.json +166 -0
  231. package/style/base.css +16 -0
  232. package/style/index.css +7 -0
  233. package/style/index.js +7 -0
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2023 Datalayer, Inc.
4
+ *
5
+ * MIT License
6
+ */
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ */
14
+ import { MarkdownShortcutPlugin } from '@lexical/react/LexicalMarkdownShortcutPlugin';
15
+ import { PLAYGROUND_TRANSFORMERS } from '../convert/transformers/MarkdownTransformers';
16
+ export const MarkdownPlugin = () => {
17
+ return _jsx(MarkdownShortcutPlugin, { transformers: PLAYGROUND_TRANSFORMERS });
18
+ };
19
+ export default MarkdownPlugin;
20
+ //# sourceMappingURL=MardownPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MardownPlugin.js","sourceRoot":"","sources":["../../src/plugins/MardownPlugin.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAC,sBAAsB,EAAC,MAAM,8CAA8C,CAAC;AAEpF,OAAO,EAAC,uBAAuB,EAAC,MAAM,8CAA8C,CAAC;AAErF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAgB,EAAE;IAC9C,OAAO,KAAC,sBAAsB,IAAC,YAAY,EAAE,uBAAuB,GAAI,CAAC;AAC3E,CAAC,CAAA;AAED,eAAe,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { INotebookContent } from "@jupyterlab/nbformat";
2
+ type Props = {
3
+ notebook?: INotebookContent;
4
+ };
5
+ export declare const NbformatContentPlugin: (props: Props) => null;
6
+ export default NbformatContentPlugin;
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { useEffect } from "react";
7
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
8
+ import { nbformatToLexical } from "../convert/NbFormatToLexical";
9
+ export const NbformatContentPlugin = (props) => {
10
+ const { notebook } = props;
11
+ const [editor] = useLexicalComposerContext();
12
+ useEffect(() => {
13
+ if (notebook) {
14
+ nbformatToLexical(notebook, editor);
15
+ }
16
+ }, [editor, notebook]);
17
+ return null;
18
+ };
19
+ export default NbformatContentPlugin;
20
+ //# sourceMappingURL=NbformatContentPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NbformatContentPlugin.js","sourceRoot":"","sources":["../../src/plugins/NbformatContentPlugin.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAY,EAAE,EAAE;IACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAC3B,MAAM,CAAC,MAAM,CAAC,GAAG,yBAAyB,EAAE,CAAC;IAC7C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,EAAE;YACZ,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;SACrC;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;IACtB,OAAO,IAAI,CAAC;AACd,CAAC,CAAA;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,87 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+
7
+ .table-of-contents .heading2 {
8
+ margin-left: 10px;
9
+ }
10
+
11
+ .table-of-contents .heading3 {
12
+ margin-left: 20px;
13
+ }
14
+
15
+ .selected-heading {
16
+ color: #3578e5;
17
+ position: relative;
18
+ }
19
+
20
+ .selected-heading-wrapper::before {
21
+ content: ' ';
22
+ position: absolute;
23
+ display: inline-block;
24
+ left: -30px;
25
+ top: 4px;
26
+ z-index: 10;
27
+ height: 4px;
28
+ width: 4px;
29
+ background-color: #3578e5;
30
+ border: solid 4px white;
31
+ border-radius: 50%;
32
+ }
33
+
34
+ .normal-heading {
35
+ cursor: pointer;
36
+ line-height: 20px;
37
+ font-size: 16px;
38
+ }
39
+
40
+ .table-of-contents {
41
+ color: #65676b;
42
+ position: fixed;
43
+ top: 100px;
44
+ /* right: 100px; */
45
+ right: 0px;
46
+ padding: 10px;
47
+ width: 250px;
48
+ display: flex;
49
+ flex-direction: row;
50
+ justify-content: flex-start;
51
+ z-index: 1;
52
+ height: 300px;
53
+ }
54
+
55
+ .first-heading {
56
+ color: black;
57
+ font-weight: bold;
58
+ cursor: pointer;
59
+ }
60
+
61
+ .headings {
62
+ list-style: none;
63
+ margin-top: 0;
64
+ margin-left: 10px;
65
+ padding: 0;
66
+ overflow: scroll;
67
+ width: 100%;
68
+ height: 220px;
69
+ overflow-x: hidden;
70
+ overflow-y: auto;
71
+ }
72
+
73
+ .headings::before {
74
+ content: ' ';
75
+ position: absolute;
76
+ height: 220px;
77
+ width: 4px;
78
+ right: 240px;
79
+ margin-top: 5px;
80
+ background-color: #ccd0d5;
81
+ border-radius: 2px;
82
+ }
83
+
84
+ .normal-heading-wrapper {
85
+ margin-left: 32px;
86
+ position: relative;
87
+ }
@@ -0,0 +1,3 @@
1
+ import './TableOfContentsPlugin.css';
2
+ export declare const TableOfContentsPlugin: () => import("react/jsx-runtime").JSX.Element;
3
+ export default TableOfContentsPlugin;
@@ -0,0 +1,115 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import './TableOfContentsPlugin.css';
3
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
4
+ import LexicalTableOfContents from '@lexical/react/LexicalTableOfContents';
5
+ import { useEffect, useRef, useState } from 'react';
6
+ function indent(tagName) {
7
+ if (tagName === 'h2') {
8
+ return 'heading2';
9
+ }
10
+ else if (tagName === 'h3') {
11
+ return 'heading3';
12
+ }
13
+ }
14
+ function TableOfContentsList({ tableOfContents, }) {
15
+ const [selectedKey, setSelectedKey] = useState('');
16
+ const selectedIndex = useRef(0);
17
+ const [editor] = useLexicalComposerContext();
18
+ function scrollToNode(key, currIndex) {
19
+ editor.getEditorState().read(() => {
20
+ const domElement = editor.getElementByKey(key);
21
+ if (domElement !== null) {
22
+ domElement.scrollIntoView();
23
+ setSelectedKey(key);
24
+ selectedIndex.current = currIndex;
25
+ }
26
+ });
27
+ }
28
+ function isHeadingAtTheTopOfThePage(element) {
29
+ const elementYPosition = element?.getClientRects()[0].y;
30
+ return elementYPosition >= 0.26 && elementYPosition <= 9;
31
+ }
32
+ function isHeadingAboveViewport(element) {
33
+ const elementYPosition = element?.getClientRects()[0].y;
34
+ return elementYPosition <= 0;
35
+ }
36
+ function isHeadingBelowTheTopOfThePage(element) {
37
+ const elementYPosition = element?.getClientRects()[0].y;
38
+ return elementYPosition > 9;
39
+ }
40
+ useEffect(() => {
41
+ function scrollCallback() {
42
+ if (tableOfContents.length !== 0 &&
43
+ selectedIndex.current < tableOfContents.length - 1) {
44
+ let currentHeading = editor.getElementByKey(tableOfContents[selectedIndex.current][0]);
45
+ if (currentHeading !== null) {
46
+ if (isHeadingBelowTheTopOfThePage(currentHeading)) {
47
+ //On natural scroll, user is scrolling up
48
+ while (currentHeading !== null &&
49
+ isHeadingBelowTheTopOfThePage(currentHeading) &&
50
+ selectedIndex.current > 0) {
51
+ const prevHeading = editor.getElementByKey(tableOfContents[selectedIndex.current - 1][0]);
52
+ if (prevHeading !== null &&
53
+ (isHeadingAboveViewport(prevHeading) ||
54
+ isHeadingBelowTheTopOfThePage(prevHeading))) {
55
+ selectedIndex.current--;
56
+ }
57
+ currentHeading = prevHeading;
58
+ }
59
+ const prevHeadingKey = tableOfContents[selectedIndex.current][0];
60
+ setSelectedKey(prevHeadingKey);
61
+ }
62
+ else if (isHeadingAboveViewport(currentHeading)) {
63
+ //On natural scroll, user is scrolling down
64
+ while (currentHeading !== null &&
65
+ isHeadingAboveViewport(currentHeading) &&
66
+ selectedIndex.current < tableOfContents.length - 1) {
67
+ const nextHeading = editor.getElementByKey(tableOfContents[selectedIndex.current + 1][0]);
68
+ if (nextHeading !== null &&
69
+ (isHeadingAtTheTopOfThePage(nextHeading) ||
70
+ isHeadingAboveViewport(nextHeading))) {
71
+ selectedIndex.current++;
72
+ }
73
+ currentHeading = nextHeading;
74
+ }
75
+ const nextHeadingKey = tableOfContents[selectedIndex.current][0];
76
+ setSelectedKey(nextHeadingKey);
77
+ }
78
+ }
79
+ }
80
+ else {
81
+ selectedIndex.current = 0;
82
+ }
83
+ }
84
+ let timerId;
85
+ function debounceFunction(func, delay) {
86
+ clearTimeout(timerId);
87
+ timerId = setTimeout(func, delay);
88
+ }
89
+ function onScroll() {
90
+ debounceFunction(scrollCallback, 10);
91
+ }
92
+ document.addEventListener('scroll', onScroll);
93
+ return () => document.removeEventListener('scroll', onScroll);
94
+ }, [tableOfContents, editor]);
95
+ return (_jsx("div", { className: "table-of-contents", children: _jsx("ul", { className: "headings", children: tableOfContents.map(([key, text, tag], index) => {
96
+ if (index === 0) {
97
+ return (_jsxs("div", { className: "normal-heading-wrapper", children: [_jsx("div", { className: "first-heading", onClick: () => scrollToNode(key, index), role: "button", tabIndex: 0, children: ('' + text).length > 20
98
+ ? text.substring(0, 20) + '...'
99
+ : text }, key), _jsx("br", {})] }));
100
+ }
101
+ else {
102
+ return (_jsx("div", { className: `normal-heading-wrapper ${selectedKey === key ? 'selected-heading-wrapper' : ''}`, children: _jsx("div", { onClick: () => scrollToNode(key, index), role: "button", className: indent(tag), tabIndex: 0, children: _jsx("li", { className: `normal-heading ${selectedKey === key ? 'selected-heading' : ''}
103
+ `, children: ('' + text).length > 27
104
+ ? text.substring(0, 27) + '...'
105
+ : text }) }, key) }));
106
+ }
107
+ }) }) }));
108
+ }
109
+ export const TableOfContentsPlugin = () => {
110
+ return (_jsx(LexicalTableOfContents, { children: (tableOfContents) => {
111
+ return _jsx(TableOfContentsList, { tableOfContents: tableOfContents });
112
+ } }));
113
+ };
114
+ export default TableOfContentsPlugin;
115
+ //# sourceMappingURL=TableOfContentsPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableOfContentsPlugin.js","sourceRoot":"","sources":["../../src/plugins/TableOfContentsPlugin.tsx"],"names":[],"mappings":";AAgBA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAC,yBAAyB,EAAC,MAAM,uCAAuC,CAAC;AAChF,OAAO,sBAAsB,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAElD,SAAS,MAAM,CAAC,OAAuB;IACrC,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,UAAU,CAAC;KACnB;SAAM,IAAI,OAAO,KAAK,IAAI,EAAE;QAC3B,OAAO,UAAU,CAAC;KACnB;AACH,CA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EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE;oCACtB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK;oCAC/B,CAAC,CAAC,IAAI,IANH,GAAG,CAOJ,EACN,cAAM,IACF,CACP,CAAC;iBACH;qBAAM;oBACL,OAAO,CACL,cACE,SAAS,EAAE,0BACT,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,EACrD,EAAE,YACF,cAEE,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,EACvC,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,CAAC,YACX,aACE,SAAS,EAAE,kBACT,WAAW,KAAK,GAAG,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAC7C;qBACC,YACA,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE;oCACtB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK;oCAC/B,CAAC,CAAC,IAAI,GACL,IAbA,GAAG,CAcJ,GACF,CACP,CAAC;iBACH;YACH,CAAC,CAAC,GACC,GACD,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACxC,OAAO,CACL,KAAC,sBAAsB,cACpB,CAAC,eAAe,EAAE,EAAE;YACnB,OAAO,KAAC,mBAAmB,IAAC,eAAe,EAAE,eAAe,GAAI,CAAC;QACnE,CAAC,GACsB,CAC1B,CAAC;AACJ,CAAC,CAAA;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { LexicalCommand } from 'lexical';
2
+ export declare const INSERT_YOUTUBE_COMMAND: LexicalCommand<string>;
3
+ export declare const YouTubePlugin: () => JSX.Element | null;
4
+ export default YouTubePlugin;
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ *
12
+ */
13
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
14
+ import { $insertNodeToNearestRoot } from '@lexical/utils';
15
+ import { COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
16
+ import { useEffect } from 'react';
17
+ import { $createYouTubeNode, YouTubeNode } from '../nodes/YouTubeNode';
18
+ export const INSERT_YOUTUBE_COMMAND = createCommand();
19
+ export const YouTubePlugin = () => {
20
+ const [editor] = useLexicalComposerContext();
21
+ useEffect(() => {
22
+ if (!editor.hasNodes([YouTubeNode])) {
23
+ throw new Error('YouTubePlugin: YouTubeNode not registered on editor');
24
+ }
25
+ return editor.registerCommand(INSERT_YOUTUBE_COMMAND, (payload) => {
26
+ const youTubeNode = $createYouTubeNode(payload);
27
+ $insertNodeToNearestRoot(youTubeNode);
28
+ return true;
29
+ }, COMMAND_PRIORITY_EDITOR);
30
+ }, [editor]);
31
+ return null;
32
+ };
33
+ export default YouTubePlugin;
34
+ //# sourceMappingURL=YouTubePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YouTubePlugin.js","sourceRoot":"","sources":["../../src/plugins/YouTubePlugin.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEF,OAAO,EAAC,yBAAyB,EAAC,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAC,wBAAwB,EAAC,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAC,uBAAuB,EAAE,aAAa,EAAiB,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAErE,MAAM,CAAC,MAAM,sBAAsB,GAA2B,aAAa,EAAE,CAAC;AAE/E,MAAM,CAAC,MAAM,aAAa,GAAG,GAAuB,EAAE;IACnD,MAAM,CAAC,MAAM,CAAC,GAAG,yBAAyB,EAAE,CAAC;IAC7C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QACD,OAAO,MAAM,CAAC,eAAe,CAC3B,sBAAsB,EACtB,CAAC,OAAO,EAAE,EAAE;YACV,MAAM,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;YAChD,wBAAwB,CAAC,WAAW,CAAC,CAAC;YACtC,OAAO,IAAI,CAAC;QACd,CAAC,EACD,uBAAuB,CACxB,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC,CAAA;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+
14
+ .Button__root {
15
+ padding-top: 10px;
16
+ padding-bottom: 10px;
17
+ padding-left: 15px;
18
+ padding-right: 15px;
19
+ border: 0px;
20
+ background-color: #eee;
21
+ border-radius: 5px;
22
+ cursor: pointer;
23
+ font-size: 14px;
24
+ }
25
+ .Button__root:hover {
26
+ background-color: #ddd;
27
+ }
28
+ .Button__small {
29
+ padding-top: 5px;
30
+ padding-bottom: 5px;
31
+ padding-left: 10px;
32
+ padding-right: 10px;
33
+ font-size: 13px;
34
+ }
35
+ .Button__disabled {
36
+ cursor: not-allowed;
37
+ }
38
+ .Button__disabled:hover {
39
+ background-color: #eee;
40
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { ReactNode } from 'react';
8
+ import './Button.css';
9
+ export declare const Button: ({ "data-test-id": dataTestId, children, className, onClick, disabled, small, title, }: {
10
+ 'data-test-id'?: string | undefined;
11
+ children: ReactNode;
12
+ className?: string | undefined;
13
+ disabled?: boolean | undefined;
14
+ onClick: () => void;
15
+ small?: boolean | undefined;
16
+ title?: string | undefined;
17
+ }) => JSX.Element;
18
+ export default Button;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import joinClasses from '../utils/join';
3
+ import './Button.css';
4
+ export const Button = ({ 'data-test-id': dataTestId, children, className, onClick, disabled, small, title, }) => {
5
+ return (_jsx("button", { disabled: disabled, className: joinClasses('Button__root', disabled && 'Button__disabled', small && 'Button__small', className), onClick: onClick, title: title, "aria-label": title, ...(dataTestId && { 'data-test-id': dataTestId }), children: children }));
6
+ };
7
+ export default Button;
8
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/ui/Button.tsx"],"names":[],"mappings":";AAcA,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,cAAc,EAAE,UAAU,EAC1B,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,KAAK,EACL,KAAK,GASN,EAAe,EAAE;IAChB,OAAO,CACL,iBACE,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,WAAW,CACpB,cAAc,EACd,QAAQ,IAAI,kBAAkB,EAC9B,KAAK,IAAI,eAAe,EACxB,SAAS,CACV,EACD,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,gBACA,KAAK,KACb,CAAC,UAAU,IAAI,EAAC,cAAc,EAAE,UAAU,EAAC,CAAC,YAC/C,QAAQ,GACF,CACV,CAAC;AACJ,CAAC,CAAA;AAED,eAAe,MAAM,CAAC"}
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ *
14
+ */
15
+ .ContentEditable__root {
16
+ border: 0;
17
+ font-size: 15px;
18
+ display: block;
19
+ position: relative;
20
+ tab-size: 1;
21
+ outline: 0;
22
+ padding: 10px;
23
+ height: calc(100% - 20px);
24
+ }
@@ -0,0 +1,5 @@
1
+ import './ContentEditable.css';
2
+ export declare const LexicalContentEditable: ({ className, }: {
3
+ className?: string | undefined;
4
+ }) => JSX.Element;
5
+ export default LexicalContentEditable;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2023 Datalayer, Inc.
4
+ *
5
+ * MIT License
6
+ */
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ */
14
+ import { ContentEditable } from '@lexical/react/LexicalContentEditable';
15
+ import './ContentEditable.css';
16
+ export const LexicalContentEditable = ({ className, }) => {
17
+ return _jsx(ContentEditable, { className: className || 'ContentEditable__root' });
18
+ };
19
+ export default LexicalContentEditable;
20
+ //# sourceMappingURL=ContentEditable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentEditable.js","sourceRoot":"","sources":["../../src/ui/ContentEditable.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAC,eAAe,EAAC,MAAM,uCAAuC,CAAC;AAEtE,OAAO,uBAAuB,CAAC;AAE/B,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACrC,SAAS,GAGV,EAAe,EAAE;IAChB,OAAO,KAAC,eAAe,IAAC,SAAS,EAAE,SAAS,IAAI,uBAAuB,GAAI,CAAC;AAC9E,CAAC,CAAA;AAED,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { LexicalEditor } from 'lexical';
2
+ interface Props {
3
+ editor: LexicalEditor;
4
+ getCodeDOMNode: () => HTMLElement | null;
5
+ }
6
+ export declare function CopyButton({ editor, getCodeDOMNode }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2023 Datalayer, Inc.
4
+ *
5
+ * MIT License
6
+ */
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ import { useState } from 'react';
14
+ import { $getNearestNodeFromDOMNode, $getSelection, $setSelection, } from 'lexical';
15
+ import { $isJupyterCodeNode } from '../nodes/JupyterCodeNode';
16
+ import { useDebounce } from '../utils/debouncer';
17
+ export function CopyButton({ editor, getCodeDOMNode }) {
18
+ const [isCopyCompleted, setCopyCompleted] = useState(false);
19
+ const removeSuccessIcon = useDebounce(() => {
20
+ setCopyCompleted(false);
21
+ }, 1000);
22
+ async function handleClick() {
23
+ const codeDOMNode = getCodeDOMNode();
24
+ if (!codeDOMNode) {
25
+ return;
26
+ }
27
+ let content = '';
28
+ editor.update(() => {
29
+ const codeNode = $getNearestNodeFromDOMNode(codeDOMNode);
30
+ if ($isJupyterCodeNode(codeNode)) {
31
+ content = codeNode.getTextContent();
32
+ }
33
+ const selection = $getSelection();
34
+ $setSelection(selection);
35
+ });
36
+ try {
37
+ await navigator.clipboard.writeText(content);
38
+ setCopyCompleted(true);
39
+ removeSuccessIcon();
40
+ }
41
+ catch (err) {
42
+ console.error('Failed to copy: ', err);
43
+ }
44
+ }
45
+ return (_jsx("button", { className: "menu-item", onClick: handleClick, "aria-label": "copy", children: isCopyCompleted ? (_jsx("i", { className: "format success" })) : (_jsx("i", { className: "format copy" })) }));
46
+ }
47
+ //# sourceMappingURL=CopyButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopyButton.js","sourceRoot":"","sources":["../../src/ui/CopyButton.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,aAAa,GAEd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAO/C,MAAM,UAAU,UAAU,CAAC,EAAC,MAAM,EAAE,cAAc,EAAQ;IACxD,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACrE,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE;QACzC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,EAAE,IAAI,CAAC,CAAC;IACT,KAAK,UAAU,WAAW;QACxB,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;QACrC,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO;SACR;QACD,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;YACjB,MAAM,QAAQ,GAAG,0BAA0B,CAAC,WAAW,CAAC,CAAC;YACzD,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE;gBAChC,OAAO,GAAG,QAAQ,CAAC,cAAc,EAAE,CAAC;aACrC;YACD,MAAM,SAAS,GAAG,aAAa,EAAE,CAAC;YAClC,aAAa,CAAC,SAAS,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,IAAI;YACF,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YAC7C,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACvB,iBAAiB,EAAE,CAAC;SACrB;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;SACxC;IACH,CAAC;IACD,OAAO,CACL,iBAAQ,SAAS,EAAC,WAAW,EAAC,OAAO,EAAE,WAAW,gBAAa,MAAM,YAClE,eAAe,CAAC,CAAC,CAAC,CACjB,YAAG,SAAS,EAAC,gBAAgB,GAAG,CACjC,CAAC,CAAC,CAAC,CACF,YAAG,SAAS,EAAC,aAAa,GAAG,CAC9B,GACM,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+
7
+ .DialogActions {
8
+ display: flex;
9
+ flex-direction: row;
10
+ justify-content: right;
11
+ margin-top: 20px;
12
+ }
13
+
14
+ .DialogButtonsList {
15
+ display: flex;
16
+ flex-direction: column;
17
+ justify-content: right;
18
+ margin-top: 20px;
19
+ }
20
+
21
+ .DialogButtonsList button {
22
+ margin-bottom: 20px;
23
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import './Dialog.css';
9
+ import { ReactNode } from 'react';
10
+ type Props = Readonly<{
11
+ 'data-test-id'?: string;
12
+ children: ReactNode;
13
+ }>;
14
+ export declare function DialogButtonsList({ children }: Props): JSX.Element;
15
+ export declare function DialogActions({ 'data-test-id': dataTestId, children, }: Props): JSX.Element;
16
+ export {};
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2023 Datalayer, Inc.
4
+ *
5
+ * MIT License
6
+ */
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ */
14
+ import './Dialog.css';
15
+ export function DialogButtonsList({ children }) {
16
+ return _jsx("div", { className: "DialogButtonsList", children: children });
17
+ }
18
+ export function DialogActions({ 'data-test-id': dataTestId, children, }) {
19
+ return (_jsx("div", { className: "DialogActions", "data-test-id": dataTestId, children: children }));
20
+ }
21
+ //# sourceMappingURL=Dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../src/ui/Dialog.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,OAAO,cAAc,CAAC;AAStB,MAAM,UAAU,iBAAiB,CAAC,EAAC,QAAQ,EAAQ;IACjD,OAAO,cAAK,SAAS,EAAC,mBAAmB,YAAE,QAAQ,GAAO,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAC5B,cAAc,EAAE,UAAU,EAC1B,QAAQ,GACF;IACN,OAAO,CACL,cAAK,SAAS,EAAC,eAAe,kBAAe,UAAU,YACpD,QAAQ,GACL,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { ReactNode } from 'react';
8
+ import * as React from 'react';
9
+ export declare function DropDownItem({ children, className, onClick, title, }: {
10
+ children: React.ReactNode;
11
+ className: string;
12
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
13
+ title?: string;
14
+ }): import("react/jsx-runtime").JSX.Element;
15
+ export declare const DropDown: ({ buttonLabel, buttonAriaLabel, buttonClassName, buttonIconClassName, children, stopCloseOnClickSelf, }: {
16
+ buttonAriaLabel?: string | undefined;
17
+ buttonClassName: string;
18
+ buttonIconClassName?: string | undefined;
19
+ buttonLabel?: string | undefined;
20
+ children: ReactNode;
21
+ stopCloseOnClickSelf?: boolean | undefined;
22
+ }) => JSX.Element;
23
+ export default DropDown;