@elastic/eui-docusaurus-theme 2.0.0

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 (297) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +292 -0
  3. package/lib/.tsbuildinfo-client +1 -0
  4. package/lib/components/badge/index.d.ts +1 -0
  5. package/lib/components/badge/index.js +9 -0
  6. package/lib/components/codesandbox_icon/codesandbox_icon.d.ts +4 -0
  7. package/lib/components/codesandbox_icon/codesandbox_icon.js +2 -0
  8. package/lib/components/codesandbox_icon/index.d.ts +1 -0
  9. package/lib/components/codesandbox_icon/index.js +8 -0
  10. package/lib/components/demo/actions_bar/actions_bar.d.ts +10 -0
  11. package/lib/components/demo/actions_bar/actions_bar.js +34 -0
  12. package/lib/components/demo/actions_bar/index.d.ts +1 -0
  13. package/lib/components/demo/actions_bar/index.js +8 -0
  14. package/lib/components/demo/code_transformer.d.ts +18 -0
  15. package/lib/components/demo/code_transformer.js +39 -0
  16. package/lib/components/demo/codesandbox/find_external_dependencies.d.ts +5 -0
  17. package/lib/components/demo/codesandbox/find_external_dependencies.js +30 -0
  18. package/lib/components/demo/codesandbox/index.d.ts +1 -0
  19. package/lib/components/demo/codesandbox/index.js +8 -0
  20. package/lib/components/demo/codesandbox/open_action.d.ts +16 -0
  21. package/lib/components/demo/codesandbox/open_action.js +91 -0
  22. package/lib/components/demo/context.d.ts +14 -0
  23. package/lib/components/demo/context.js +13 -0
  24. package/lib/components/demo/create_demo.d.ts +5 -0
  25. package/lib/components/demo/create_demo.js +13 -0
  26. package/lib/components/demo/demo.d.ts +23 -0
  27. package/lib/components/demo/demo.js +61 -0
  28. package/lib/components/demo/editor/editor.d.ts +1 -0
  29. package/lib/components/demo/editor/editor.js +39 -0
  30. package/lib/components/demo/editor/index.d.ts +1 -0
  31. package/lib/components/demo/editor/index.js +8 -0
  32. package/lib/components/demo/index.d.ts +3 -0
  33. package/lib/components/demo/index.js +10 -0
  34. package/lib/components/demo/preview/index.d.ts +1 -0
  35. package/lib/components/demo/preview/index.js +8 -0
  36. package/lib/components/demo/preview/preview.d.ts +7 -0
  37. package/lib/components/demo/preview/preview.js +36 -0
  38. package/lib/components/demo/scope.d.ts +1 -0
  39. package/lib/components/demo/scope.js +12 -0
  40. package/lib/components/demo/source/get_source_from_children.d.ts +11 -0
  41. package/lib/components/demo/source/get_source_from_children.js +42 -0
  42. package/lib/components/demo/source/index.d.ts +1 -0
  43. package/lib/components/demo/source/index.js +8 -0
  44. package/lib/components/demo/source/source.d.ts +6 -0
  45. package/lib/components/demo/source/source.js +25 -0
  46. package/lib/components/figma_embed/index.d.ts +5 -0
  47. package/lib/components/figma_embed/index.js +36 -0
  48. package/lib/components/guideline/guideline.d.ts +10 -0
  49. package/lib/components/guideline/guideline.js +68 -0
  50. package/lib/components/guideline/guideline_text.d.ts +6 -0
  51. package/lib/components/guideline/guideline_text.js +28 -0
  52. package/lib/components/guideline/index.d.ts +2 -0
  53. package/lib/components/guideline/index.js +9 -0
  54. package/lib/components/guideline/types.d.ts +1 -0
  55. package/lib/components/guideline/types.js +8 -0
  56. package/lib/components/high_contrast_mode_toggle/index.d.ts +1 -0
  57. package/lib/components/high_contrast_mode_toggle/index.js +15 -0
  58. package/lib/components/icon/index.d.ts +1 -0
  59. package/lib/components/icon/index.js +9 -0
  60. package/lib/components/index.d.ts +7 -0
  61. package/lib/components/index.js +14 -0
  62. package/lib/components/navbar_item/index.d.ts +19 -0
  63. package/lib/components/navbar_item/index.js +84 -0
  64. package/lib/components/prop_table/definition_types.d.ts +43 -0
  65. package/lib/components/prop_table/definition_types.js +8 -0
  66. package/lib/components/prop_table/extended_types.d.ts +5 -0
  67. package/lib/components/prop_table/extended_types.js +27 -0
  68. package/lib/components/prop_table/extended_types_info.d.ts +26 -0
  69. package/lib/components/prop_table/extended_types_info.js +34 -0
  70. package/lib/components/prop_table/index.d.ts +1 -0
  71. package/lib/components/prop_table/index.js +8 -0
  72. package/lib/components/prop_table/prop_table.d.ts +8 -0
  73. package/lib/components/prop_table/prop_table.js +115 -0
  74. package/lib/components/theme_context/index.d.ts +16 -0
  75. package/lib/components/theme_context/index.js +103 -0
  76. package/lib/components/theme_context/theme_overrides.d.ts +2 -0
  77. package/lib/components/theme_context/theme_overrides.js +12 -0
  78. package/lib/components/version_switcher/index.d.ts +23 -0
  79. package/lib/components/version_switcher/index.js +51 -0
  80. package/lib/index.d.ts +2 -0
  81. package/lib/index.js +19 -0
  82. package/lib/index.js.map +1 -0
  83. package/lib/theme/Admonition/Types.d.ts +3 -0
  84. package/lib/theme/Admonition/Types.js +51 -0
  85. package/lib/theme/CodeBlock/index.d.ts +3 -0
  86. package/lib/theme/CodeBlock/index.js +35 -0
  87. package/lib/theme/ColorModeToggle/index.d.ts +10 -0
  88. package/lib/theme/ColorModeToggle/index.js +51 -0
  89. package/lib/theme/Demo/actions.d.ts +8 -0
  90. package/lib/theme/Demo/actions.js +8 -0
  91. package/lib/theme/Demo/default_scope.d.ts +3 -0
  92. package/lib/theme/Demo/default_scope.js +17 -0
  93. package/lib/theme/DocBreadcrumbs/Items/Home/index.d.ts +2 -0
  94. package/lib/theme/DocBreadcrumbs/Items/Home/index.js +15 -0
  95. package/lib/theme/DocBreadcrumbs/Items/item.styles.d.ts +5 -0
  96. package/lib/theme/DocBreadcrumbs/Items/item.styles.js +40 -0
  97. package/lib/theme/DocBreadcrumbs/index.d.ts +2 -0
  98. package/lib/theme/DocBreadcrumbs/index.js +63 -0
  99. package/lib/theme/DocItem/Content/index.d.ts +3 -0
  100. package/lib/theme/DocItem/Content/index.js +44 -0
  101. package/lib/theme/DocItem/Footer/index.d.ts +2 -0
  102. package/lib/theme/DocItem/Footer/index.js +17 -0
  103. package/lib/theme/DocItem/Layout/index.d.ts +3 -0
  104. package/lib/theme/DocItem/Layout/index.js +71 -0
  105. package/lib/theme/DocItem/Metadata/index.d.ts +2 -0
  106. package/lib/theme/DocItem/Metadata/index.js +7 -0
  107. package/lib/theme/DocItem/Paginator/index.d.ts +6 -0
  108. package/lib/theme/DocItem/Paginator/index.js +11 -0
  109. package/lib/theme/DocItem/TOC/Desktop/index.d.ts +2 -0
  110. package/lib/theme/DocItem/TOC/Desktop/index.js +8 -0
  111. package/lib/theme/DocItem/TOC/Mobile/index.d.ts +2 -0
  112. package/lib/theme/DocItem/TOC/Mobile/index.js +17 -0
  113. package/lib/theme/DocItem/index.d.ts +3 -0
  114. package/lib/theme/DocItem/index.js +10 -0
  115. package/lib/theme/DocPaginator/index.d.ts +3 -0
  116. package/lib/theme/DocPaginator/index.js +19 -0
  117. package/lib/theme/DocRoot/Layout/Main/index.d.ts +3 -0
  118. package/lib/theme/DocRoot/Layout/Main/index.js +35 -0
  119. package/lib/theme/DocRoot/Layout/Sidebar/index.d.ts +3 -0
  120. package/lib/theme/DocRoot/Layout/Sidebar/index.js +81 -0
  121. package/lib/theme/DocRoot/Layout/index.d.ts +3 -0
  122. package/lib/theme/DocRoot/Layout/index.js +47 -0
  123. package/lib/theme/DocSidebarItem/Category/index.d.ts +3 -0
  124. package/lib/theme/DocSidebarItem/Category/index.js +146 -0
  125. package/lib/theme/DocSidebarItem/Link/index.d.ts +3 -0
  126. package/lib/theme/DocSidebarItem/Link/index.js +39 -0
  127. package/lib/theme/DocSidebarItem/index.d.ts +3 -0
  128. package/lib/theme/DocSidebarItem/index.js +15 -0
  129. package/lib/theme/DocSidebarItems/index.d.ts +5 -0
  130. package/lib/theme/DocSidebarItems/index.js +17 -0
  131. package/lib/theme/EditThisPage/index.d.ts +3 -0
  132. package/lib/theme/EditThisPage/index.js +17 -0
  133. package/lib/theme/Footer/index.d.ts +2 -0
  134. package/lib/theme/Footer/index.js +43 -0
  135. package/lib/theme/Heading/index.d.ts +3 -0
  136. package/lib/theme/Heading/index.js +49 -0
  137. package/lib/theme/Logo/index.d.ts +3 -0
  138. package/lib/theme/Logo/index.js +80 -0
  139. package/lib/theme/MDXComponents/A.d.ts +6 -0
  140. package/lib/theme/MDXComponents/A.js +17 -0
  141. package/lib/theme/MDXComponents/Blockquote.d.ts +2 -0
  142. package/lib/theme/MDXComponents/Blockquote.js +18 -0
  143. package/lib/theme/MDXComponents/Code.d.ts +6 -0
  144. package/lib/theme/MDXComponents/Code.js +35 -0
  145. package/lib/theme/MDXComponents/Heading.d.ts +4 -0
  146. package/lib/theme/MDXComponents/Heading.js +4 -0
  147. package/lib/theme/MDXComponents/ListItem.d.ts +2 -0
  148. package/lib/theme/MDXComponents/ListItem.js +5 -0
  149. package/lib/theme/MDXComponents/OrderedList.d.ts +2 -0
  150. package/lib/theme/MDXComponents/OrderedList.js +11 -0
  151. package/lib/theme/MDXComponents/Paragraph.d.ts +2 -0
  152. package/lib/theme/MDXComponents/Paragraph.js +18 -0
  153. package/lib/theme/MDXComponents/Table.d.ts +2 -0
  154. package/lib/theme/MDXComponents/Table.js +3 -0
  155. package/lib/theme/MDXComponents/TableBody.d.ts +2 -0
  156. package/lib/theme/MDXComponents/TableBody.js +3 -0
  157. package/lib/theme/MDXComponents/TableDataCell.d.ts +2 -0
  158. package/lib/theme/MDXComponents/TableDataCell.js +3 -0
  159. package/lib/theme/MDXComponents/TableHeader.d.ts +2 -0
  160. package/lib/theme/MDXComponents/TableHeader.js +3 -0
  161. package/lib/theme/MDXComponents/TableHeaderCell.d.ts +2 -0
  162. package/lib/theme/MDXComponents/TableHeaderCell.js +3 -0
  163. package/lib/theme/MDXComponents/TableRow.d.ts +2 -0
  164. package/lib/theme/MDXComponents/TableRow.js +3 -0
  165. package/lib/theme/MDXComponents/UnorderedList.d.ts +2 -0
  166. package/lib/theme/MDXComponents/UnorderedList.js +11 -0
  167. package/lib/theme/MDXComponents/index.d.ts +2 -0
  168. package/lib/theme/MDXComponents/index.js +46 -0
  169. package/lib/theme/MDXContent/index.d.ts +6 -0
  170. package/lib/theme/MDXContent/index.js +4 -0
  171. package/lib/theme/Navbar/Content/index.d.ts +7 -0
  172. package/lib/theme/Navbar/Content/index.js +149 -0
  173. package/lib/theme/Navbar/Layout/index.d.ts +6 -0
  174. package/lib/theme/Navbar/Layout/index.js +59 -0
  175. package/lib/theme/Navbar/MobileSidebar/Header/index.d.ts +7 -0
  176. package/lib/theme/Navbar/MobileSidebar/Header/index.js +46 -0
  177. package/lib/theme/Navbar/MobileSidebar/Layout/index.d.ts +6 -0
  178. package/lib/theme/Navbar/MobileSidebar/Layout/index.js +26 -0
  179. package/lib/theme/Navbar/MobileSidebar/index.d.ts +7 -0
  180. package/lib/theme/Navbar/MobileSidebar/index.js +14 -0
  181. package/lib/theme/NavbarItem/DropdownNavbarItem/index.d.ts +3 -0
  182. package/lib/theme/NavbarItem/DropdownNavbarItem/index.js +94 -0
  183. package/lib/theme/NavbarItem/NavbarNavLink.d.ts +7 -0
  184. package/lib/theme/NavbarItem/NavbarNavLink.js +48 -0
  185. package/lib/theme/PaginatorNavLink/index.d.ts +3 -0
  186. package/lib/theme/PaginatorNavLink/index.js +43 -0
  187. package/lib/theme/Root.d.ts +3 -0
  188. package/lib/theme/Root.js +66 -0
  189. package/lib/theme/Root.styles.d.ts +2 -0
  190. package/lib/theme/Root.styles.js +111 -0
  191. package/lib/theme/TOCCollapsible/CollapseButton/index.d.ts +3 -0
  192. package/lib/theme/TOCCollapsible/CollapseButton/index.js +23 -0
  193. package/lib/theme/TOCItems/Tree.d.ts +5 -0
  194. package/lib/theme/TOCItems/Tree.js +80 -0
  195. package/lib/theme/infima.styles.d.ts +1 -0
  196. package/lib/theme/infima.styles.js +1456 -0
  197. package/lib/theme/reset.styles.d.ts +2 -0
  198. package/lib/theme/reset.styles.js +79 -0
  199. package/package.json +61 -0
  200. package/src/components/badge/index.ts +11 -0
  201. package/src/components/codesandbox_icon/codesandbox_icon.tsx +24 -0
  202. package/src/components/codesandbox_icon/index.ts +9 -0
  203. package/src/components/demo/actions_bar/actions_bar.tsx +95 -0
  204. package/src/components/demo/actions_bar/index.ts +9 -0
  205. package/src/components/demo/code_transformer.ts +44 -0
  206. package/src/components/demo/codesandbox/find_external_dependencies.ts +34 -0
  207. package/src/components/demo/codesandbox/index.ts +9 -0
  208. package/src/components/demo/codesandbox/open_action.tsx +132 -0
  209. package/src/components/demo/context.ts +30 -0
  210. package/src/components/demo/create_demo.tsx +17 -0
  211. package/src/components/demo/demo.tsx +143 -0
  212. package/src/components/demo/editor/editor.tsx +51 -0
  213. package/src/components/demo/editor/index.ts +9 -0
  214. package/src/components/demo/index.ts +11 -0
  215. package/src/components/demo/preview/index.ts +9 -0
  216. package/src/components/demo/preview/preview.tsx +77 -0
  217. package/src/components/demo/scope.ts +14 -0
  218. package/src/components/demo/source/get_source_from_children.ts +59 -0
  219. package/src/components/demo/source/index.ts +9 -0
  220. package/src/components/demo/source/source.tsx +36 -0
  221. package/src/components/figma_embed/index.tsx +57 -0
  222. package/src/components/guideline/guideline.tsx +121 -0
  223. package/src/components/guideline/guideline_text.tsx +51 -0
  224. package/src/components/guideline/index.ts +10 -0
  225. package/src/components/guideline/types.ts +9 -0
  226. package/src/components/high_contrast_mode_toggle/index.tsx +28 -0
  227. package/src/components/icon/index.ts +11 -0
  228. package/src/components/index.ts +15 -0
  229. package/src/components/navbar_item/index.tsx +164 -0
  230. package/src/components/prop_table/definition_types.ts +53 -0
  231. package/src/components/prop_table/extended_types.tsx +66 -0
  232. package/src/components/prop_table/extended_types_info.ts +35 -0
  233. package/src/components/prop_table/index.ts +9 -0
  234. package/src/components/prop_table/prop_table.tsx +235 -0
  235. package/src/components/theme_context/index.tsx +156 -0
  236. package/src/components/theme_context/theme_overrides.ts +15 -0
  237. package/src/components/version_switcher/index.tsx +144 -0
  238. package/src/index.ts +21 -0
  239. package/src/theme/Admonition/Types.tsx +85 -0
  240. package/src/theme/CodeBlock/index.tsx +57 -0
  241. package/src/theme/ColorModeToggle/index.tsx +93 -0
  242. package/src/theme/Demo/actions.tsx +20 -0
  243. package/src/theme/Demo/default_scope.ts +19 -0
  244. package/src/theme/DocBreadcrumbs/Items/Home/index.tsx +38 -0
  245. package/src/theme/DocBreadcrumbs/Items/item.styles.ts +43 -0
  246. package/src/theme/DocBreadcrumbs/index.tsx +144 -0
  247. package/src/theme/DocItem/Content/index.tsx +75 -0
  248. package/src/theme/DocItem/Footer/index.tsx +59 -0
  249. package/src/theme/DocItem/Layout/index.tsx +112 -0
  250. package/src/theme/DocItem/Metadata/index.tsx +23 -0
  251. package/src/theme/DocItem/Paginator/index.tsx +20 -0
  252. package/src/theme/DocItem/TOC/Desktop/index.tsx +24 -0
  253. package/src/theme/DocItem/TOC/Mobile/index.tsx +35 -0
  254. package/src/theme/DocItem/index.tsx +30 -0
  255. package/src/theme/DocPaginator/index.tsx +64 -0
  256. package/src/theme/DocRoot/Layout/Main/index.tsx +61 -0
  257. package/src/theme/DocRoot/Layout/Sidebar/index.tsx +124 -0
  258. package/src/theme/DocRoot/Layout/index.tsx +72 -0
  259. package/src/theme/DocSidebarItem/Category/index.tsx +266 -0
  260. package/src/theme/DocSidebarItem/Link/index.tsx +86 -0
  261. package/src/theme/DocSidebarItem/index.tsx +29 -0
  262. package/src/theme/DocSidebarItems/index.tsx +30 -0
  263. package/src/theme/EditThisPage/index.tsx +50 -0
  264. package/src/theme/Footer/index.tsx +67 -0
  265. package/src/theme/Heading/index.tsx +94 -0
  266. package/src/theme/Logo/index.tsx +146 -0
  267. package/src/theme/MDXComponents/A.tsx +33 -0
  268. package/src/theme/MDXComponents/Blockquote.tsx +35 -0
  269. package/src/theme/MDXComponents/Code.tsx +60 -0
  270. package/src/theme/MDXComponents/Heading.tsx +16 -0
  271. package/src/theme/MDXComponents/ListItem.tsx +20 -0
  272. package/src/theme/MDXComponents/OrderedList.tsx +26 -0
  273. package/src/theme/MDXComponents/Paragraph.tsx +33 -0
  274. package/src/theme/MDXComponents/Table.tsx +16 -0
  275. package/src/theme/MDXComponents/TableBody.tsx +16 -0
  276. package/src/theme/MDXComponents/TableDataCell.tsx +20 -0
  277. package/src/theme/MDXComponents/TableHeader.tsx +16 -0
  278. package/src/theme/MDXComponents/TableHeaderCell.tsx +20 -0
  279. package/src/theme/MDXComponents/TableRow.tsx +16 -0
  280. package/src/theme/MDXComponents/UnorderedList.tsx +26 -0
  281. package/src/theme/MDXComponents/index.ts +61 -0
  282. package/src/theme/MDXContent/index.tsx +22 -0
  283. package/src/theme/Navbar/Content/index.tsx +262 -0
  284. package/src/theme/Navbar/Layout/index.tsx +100 -0
  285. package/src/theme/Navbar/MobileSidebar/Header/index.tsx +89 -0
  286. package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +44 -0
  287. package/src/theme/Navbar/MobileSidebar/index.tsx +46 -0
  288. package/src/theme/NavbarItem/DropdownNavbarItem/index.tsx +200 -0
  289. package/src/theme/NavbarItem/NavbarNavLink.tsx +141 -0
  290. package/src/theme/PaginatorNavLink/index.tsx +72 -0
  291. package/src/theme/Root.styles.ts +122 -0
  292. package/src/theme/Root.tsx +106 -0
  293. package/src/theme/TOCCollapsible/CollapseButton/index.tsx +53 -0
  294. package/src/theme/TOCItems/Tree.tsx +114 -0
  295. package/src/theme/infima.styles.ts +1458 -0
  296. package/src/theme/reset.styles.ts +82 -0
  297. package/src/theme/theme.d.ts +598 -0
@@ -0,0 +1 @@
1
+ export declare const Badge: import("react").FunctionComponent<import("@elastic/eui").EuiBadgeProps>;
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ import { EuiBadge } from '@elastic/eui';
9
+ export const Badge = EuiBadge;
@@ -0,0 +1,4 @@
1
+ import { HTMLAttributes } from 'react';
2
+ type Props = HTMLAttributes<SVGElement>;
3
+ export declare const CodeSandboxIcon: (props: Props) => import("@emotion/react/jsx-runtime").JSX.Element;
4
+ export {};
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ export const CodeSandboxIcon = (props) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", preserveAspectRatio: "xMidYMid", viewBox: "-20 0 296 296", ...props, children: _jsx("path", { d: "M115.498 261.088v-106.61L23.814 101.73v60.773l41.996 24.347v45.7l49.688 28.54Zm23.814.627 50.605-29.151V185.78l42.269-24.495v-60.011l-92.874 53.621v106.82Zm80.66-180.887-48.817-28.289-42.863 24.872-43.188-24.897-49.252 28.667 91.914 52.882 92.206-53.235ZM0 222.212V74.495L127.987 0 256 74.182v147.797l-128.016 73.744L0 222.212Z" }) }));
@@ -0,0 +1 @@
1
+ export { CodeSandboxIcon } from './codesandbox_icon';
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ export { CodeSandboxIcon } from './codesandbox_icon';
@@ -0,0 +1,10 @@
1
+ import { DemoSourceMeta } from '../demo';
2
+ export interface DemoActionsBarProps {
3
+ activeSource: DemoSourceMeta | null;
4
+ sources: DemoSourceMeta[];
5
+ isSourceOpen: boolean;
6
+ setSourceOpen(isOpen: boolean): void;
7
+ onClickReloadExample(): void;
8
+ onClickCopyToClipboard(): void;
9
+ }
10
+ export declare const DemoActionsBar: ({ isSourceOpen, setSourceOpen, activeSource, sources, onClickReloadExample, onClickCopyToClipboard, }: DemoActionsBarProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+ import { EuiButton, EuiButtonIcon, EuiFlexGroup, EuiToolTip, useEuiMemoizedStyles, darken, } from '@elastic/eui';
10
+ import { css } from '@emotion/react';
11
+ import { extraActions } from '@theme/Demo/actions';
12
+ const getDemoActionsBarStyles = (euiTheme) => {
13
+ return {
14
+ actionsBar: css `
15
+ padding: var(--eui-size-s);
16
+ background: ${darken(euiTheme.euiTheme.colors.body, 0.05)};
17
+ border-top: 1px solid var(--docs-demo-border-color);
18
+
19
+ &:last-child {
20
+ // border radius should be 1px smaller to work nicely
21
+ // with the wrapper border width of 1px
22
+ border-radius: 0 0 calc(var(--docs-demo-border-radius) - 1px)
23
+ calc(var(--docs-demo-border-radius) - 1px);
24
+ }
25
+ `,
26
+ button: css `
27
+ margin-right: auto;
28
+ `,
29
+ };
30
+ };
31
+ export const DemoActionsBar = ({ isSourceOpen, setSourceOpen, activeSource, sources, onClickReloadExample, onClickCopyToClipboard, }) => {
32
+ const styles = useEuiMemoizedStyles(getDemoActionsBarStyles);
33
+ return (_jsxs(EuiFlexGroup, { alignItems: "center", css: styles.actionsBar, gutterSize: "s", children: [_jsx(EuiButton, { css: styles.button, onClick: () => setSourceOpen(!isSourceOpen), size: "s", color: "text", minWidth: false, children: isSourceOpen ? 'Hide source' : 'Show source' }), extraActions.map((ActionComponent) => (_jsx(ActionComponent, { sources: sources, activeSource: activeSource }))), _jsx(EuiToolTip, { content: "Copy to clipboard", children: _jsx(EuiButtonIcon, { size: "s", iconType: "copyClipboard", color: "text", onClick: onClickCopyToClipboard, "aria-label": "Copy code to clipboard" }) }), _jsx(EuiToolTip, { content: "Reload example", children: _jsx(EuiButtonIcon, { size: "s", iconType: "refresh", color: "text", onClick: onClickReloadExample, "aria-label": "Reload example" }) })] }));
34
+ };
@@ -0,0 +1 @@
1
+ export { DemoActionsBar, type DemoActionsBarProps } from './actions_bar';
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ export { DemoActionsBar } from './actions_bar';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Transforms input JS/TS source code to a react-live compatible syntax.
3
+ * react-live uses the surcase library to transform input source code into
4
+ * browser-readable JavaScript.
5
+ *
6
+ * While surcase does support CommonJS and ESM import/export statements,
7
+ * it's not trivial to expose our internal React and EUI exports through it
8
+ * and because we already control the execution scope of the interactive demos
9
+ * it isn't really necessary to implement a smart `require()` replacement.
10
+ *
11
+ * Returning an IIFE is necessary when the source code is more than just
12
+ * a JSX component definition (e.g. it contains a variable definition
13
+ * or `export default` statement).
14
+ *
15
+ * @see https://github.com/alangpierce/sucrase
16
+ * @see https://github.com/FormidableLabs/react-live/blob/master/packages/react-live/src/utils/transpile/index.ts
17
+ */
18
+ export declare const demoCodeTransformer: (code: string) => string;
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ const IMPORT_REGEX = /^import [^'"]* from ['"]([^.'"\n ][^'"\n ]*)['"];?/gm;
9
+ const DEFAULT_EXPORT_REGEX = /export default /;
10
+ const COMPONENT_ONLY_REGEX = /^\(?</;
11
+ /**
12
+ * Transforms input JS/TS source code to a react-live compatible syntax.
13
+ * react-live uses the surcase library to transform input source code into
14
+ * browser-readable JavaScript.
15
+ *
16
+ * While surcase does support CommonJS and ESM import/export statements,
17
+ * it's not trivial to expose our internal React and EUI exports through it
18
+ * and because we already control the execution scope of the interactive demos
19
+ * it isn't really necessary to implement a smart `require()` replacement.
20
+ *
21
+ * Returning an IIFE is necessary when the source code is more than just
22
+ * a JSX component definition (e.g. it contains a variable definition
23
+ * or `export default` statement).
24
+ *
25
+ * @see https://github.com/alangpierce/sucrase
26
+ * @see https://github.com/FormidableLabs/react-live/blob/master/packages/react-live/src/utils/transpile/index.ts
27
+ */
28
+ export const demoCodeTransformer = (code) => {
29
+ // Remove ESM imports
30
+ code = code.replace(IMPORT_REGEX, '');
31
+ // Handle ESM default exports
32
+ code = code.replace(DEFAULT_EXPORT_REGEX, 'return ');
33
+ // If the demo is JSX only return as-is
34
+ if (COMPONENT_ONLY_REGEX.test(code)) {
35
+ return code;
36
+ }
37
+ // If the demo is more than just JSX wrap in an immediately invoked function expression
38
+ return `(() => { ${code} })()`;
39
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Find dependencies in import statements and return
3
+ * a package.json-like dependencies object.
4
+ */
5
+ export declare const findExternalDependencies: (source: string) => Record<string, string>;
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ const importRegex = /import([ \n\t]*(?:[^ \n\t\{\}]+[ \n\t]*,?)?(?:[ \n\t]*\{(?:[ \n\t]*[^ \n\t"'\{\}]+[ \n\t]*,?)+\})?[ \n\t]*)from[ \n\t]*(['"])(?<dependency>[^'"\n]+)(?:['"])/g;
9
+ /**
10
+ * Find dependencies in import statements and return
11
+ * a package.json-like dependencies object.
12
+ */
13
+ export const findExternalDependencies = (source) => {
14
+ return [...source.matchAll(importRegex)].reduce((acc, item) => {
15
+ const dependency = item.groups?.dependency;
16
+ if (!dependency) {
17
+ return acc;
18
+ }
19
+ const splitDependency = dependency.split('/');
20
+ if (dependency[0] === '@') {
21
+ // org-scoped dependencies have a single slash; ignore subsequent ones
22
+ acc[splitDependency.slice(0, 2).join('/')] = 'latest';
23
+ }
24
+ else if (splitDependency[0] && /^[a-z]/i.test(splitDependency[0])) {
25
+ // non org-scoped dependencies should have no slashes
26
+ acc[splitDependency[0]] = 'latest';
27
+ }
28
+ return acc;
29
+ }, {});
30
+ };
@@ -0,0 +1 @@
1
+ export { createOpenInCodeSandboxAction } from './open_action';
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ export { createOpenInCodeSandboxAction } from './open_action';
@@ -0,0 +1,16 @@
1
+ import type { ActionComponent } from '../../../theme/Demo/actions';
2
+ export declare const defaultCodeSandboxParameters: {
3
+ files: {
4
+ 'index.tsx': {
5
+ content: string;
6
+ };
7
+ 'public/index.html': {
8
+ content: string;
9
+ };
10
+ };
11
+ };
12
+ export type Options = {
13
+ files?: Record<string, string>;
14
+ dependencies: Record<string, string>;
15
+ };
16
+ export declare const createOpenInCodeSandboxAction: ({ files, dependencies }: Options) => ActionComponent;
@@ -0,0 +1,91 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+ import { useMemo } from 'react';
10
+ import { getParameters } from 'codesandbox/lib/api/define';
11
+ import dedent from 'dedent';
12
+ import { EuiButtonIcon, EuiToolTip } from '@elastic/eui';
13
+ import { CodeSandboxIcon } from '../../codesandbox_icon';
14
+ import { findExternalDependencies } from './find_external_dependencies';
15
+ const indexTsxSource = dedent `
16
+ import React from 'react';
17
+ import { createRoot } from 'react-dom/client';
18
+ import createCache from '@emotion/cache';
19
+ import { EuiProvider, euiStylisPrefixer } from '@elastic/eui';
20
+
21
+ import Demo from './demo';
22
+
23
+ const cache = createCache({
24
+ key: 'codesandbox',
25
+ stylisPlugins: [euiStylisPrefixer],
26
+ container: document.querySelector('meta[name="emotion-styles"]')!,
27
+ });
28
+ cache.compat = true;
29
+
30
+ const root = createRoot(document.getElementById('root')!);
31
+ root.render(
32
+ <EuiProvider cache={cache}>
33
+ <Demo />
34
+ </EuiProvider>
35
+ );`;
36
+ const publicIndexHtmlSource = dedent `
37
+ <head>
38
+ <title>@elastic/eui component demo</title>
39
+ <meta charset="utf-8">
40
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
41
+ <meta name="viewport" content="width=device-width,initial-scale=1">
42
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300..700&family=Roboto+Mono:ital,wght@0,400..700;1,400..700&display=swap" rel="stylesheet" />
43
+ <meta name="emotion-styles">
44
+ </head>
45
+ <body>
46
+ <div id="root" />
47
+ </body>
48
+ `;
49
+ export const defaultCodeSandboxParameters = {
50
+ files: {
51
+ 'index.tsx': {
52
+ content: indexTsxSource,
53
+ },
54
+ 'public/index.html': {
55
+ content: publicIndexHtmlSource,
56
+ },
57
+ },
58
+ };
59
+ const processTsxSource = (source) => {
60
+ // jsxImportSource pragma is needed in CodeSandbox as it doesn't seem
61
+ // to support that setting via tsconfig.json
62
+ return `/** @jsxImportSource @emotion/react */\n${source}`;
63
+ };
64
+ export const createOpenInCodeSandboxAction = ({ files = {}, dependencies }) => ({ activeSource }) => {
65
+ const parameters = useMemo(() => {
66
+ const source = activeSource?.code || '';
67
+ // Compute list of extra files that may be passed
68
+ const extraFiles = Object.entries(files).reduce((acc, [file, content]) => {
69
+ acc[file] = { content };
70
+ return acc;
71
+ }, {});
72
+ return getParameters({
73
+ files: {
74
+ ...defaultCodeSandboxParameters.files,
75
+ 'demo.tsx': {
76
+ content: processTsxSource(source),
77
+ },
78
+ 'package.json': {
79
+ content: {
80
+ dependencies: {
81
+ ...findExternalDependencies(source),
82
+ ...dependencies,
83
+ },
84
+ },
85
+ },
86
+ ...extraFiles,
87
+ },
88
+ });
89
+ }, [activeSource]);
90
+ return (_jsxs("form", { action: "https://codesandbox.io/api/v1/sandboxes/define", method: "POST", target: "_blank", children: [_jsx("input", { type: "hidden", name: "parameters", value: parameters }), _jsx("input", { type: "hidden", name: "query", value: `module=/demo.tsx&view=split` }), _jsx(EuiToolTip, { content: "Open in CodeSandbox", children: _jsx(EuiButtonIcon, { type: "submit", size: "s", iconType: CodeSandboxIcon, color: "text", "aria-label": "Open in CodeSandbox" }) })] }));
91
+ };
@@ -0,0 +1,14 @@
1
+ import { DemoSourceMeta } from './demo';
2
+ export interface DemoContextObject {
3
+ /**
4
+ * Array of all available sources for this demo instance
5
+ */
6
+ sources: DemoSourceMeta[];
7
+ /**
8
+ * Add source to the list of available sources
9
+ * This should only be used internally when initializing the component!
10
+ */
11
+ addSource(source: DemoSourceMeta): void;
12
+ }
13
+ export declare const DemoContext: import("react").Context<DemoContextObject>;
14
+ export declare const useDemoContext: () => DemoContextObject;
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ import { createContext, useContext } from 'react';
9
+ export const DemoContext = createContext({
10
+ sources: [],
11
+ addSource: () => { },
12
+ });
13
+ export const useDemoContext = () => useContext(DemoContext);
@@ -0,0 +1,5 @@
1
+ import { Demo, DemoProps } from './demo';
2
+ /**
3
+ * Creates a custom <Demo /> component with predefined props.
4
+ */
5
+ export declare const createDemo: (defaultProps: Partial<DemoProps>) => typeof Demo;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+ import { Demo } from './demo';
10
+ /**
11
+ * Creates a custom <Demo /> component with predefined props.
12
+ */
13
+ export const createDemo = (defaultProps) => (props) => _jsx(Demo, { ...defaultProps, ...props });
@@ -0,0 +1,23 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { DemoPreviewProps } from './preview/preview';
3
+ export interface DemoSourceMeta {
4
+ code: string;
5
+ isActive: boolean;
6
+ filename?: string;
7
+ }
8
+ export interface DemoProps extends PropsWithChildren {
9
+ /**
10
+ * Whether the source code editor is open by default
11
+ */
12
+ isSourceOpen?: boolean;
13
+ /**
14
+ * Allows to extend the default scope of the rendered demo and pass additional
15
+ * properties available within the demo.
16
+ *
17
+ * The default scope exposes all React and EUI exports.
18
+ */
19
+ scope?: Record<string, unknown>;
20
+ previewPadding?: DemoPreviewProps['padding'];
21
+ previewWrapper?: DemoPreviewProps['wrapperComponent'];
22
+ }
23
+ export declare const Demo: ({ children, scope, isSourceOpen: _isSourceOpen, previewPadding, previewWrapper, }: DemoProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+ import { Children, useCallback, useMemo, useState, } from 'react';
10
+ import { isElement } from 'react-is';
11
+ import { LiveProvider } from 'react-live';
12
+ import { themes as prismThemes } from 'prism-react-renderer';
13
+ import { useEuiMemoizedStyles, copyToClipboard, } from '@elastic/eui';
14
+ import { css } from '@emotion/react';
15
+ import { demoDefaultScope } from '@theme/Demo/default_scope';
16
+ import { DemoContext } from './context';
17
+ import { DemoEditor } from './editor';
18
+ import { DemoPreview } from './preview';
19
+ import { DemoSource } from './source';
20
+ import { originalScope } from './scope';
21
+ import { DemoActionsBar } from './actions_bar';
22
+ import { demoCodeTransformer } from './code_transformer';
23
+ const getDemoStyles = (euiTheme) => ({
24
+ demo: css `
25
+ --docs-demo-border-color: ${euiTheme.euiTheme.border.color};
26
+ --docs-demo-border-radius: ${euiTheme.euiTheme.size.s};
27
+
28
+ border: 1px solid var(--docs-demo-border-color);
29
+ border-radius: var(--docs-demo-border-radius);
30
+ margin-block: ${euiTheme.euiTheme.size.xl};
31
+ word-break: break-word;
32
+ `,
33
+ });
34
+ export const Demo = ({ children, scope, isSourceOpen: _isSourceOpen = false, previewPadding, previewWrapper, }) => {
35
+ const styles = useEuiMemoizedStyles(getDemoStyles);
36
+ const [sources, setSources] = useState([]);
37
+ const [isSourceOpen, setIsSourceOpen] = useState(_isSourceOpen);
38
+ const activeSource = sources[0] || null;
39
+ // liveProviderKey restarts the demo to its initial state
40
+ const [liveProviderKey, setLiveProviderKey] = useState(0);
41
+ const finalScope = useMemo(() => ({
42
+ ...originalScope,
43
+ ...demoDefaultScope,
44
+ ...scope,
45
+ }), [scope]);
46
+ const addSource = useCallback((source) => {
47
+ setSources((sources) => [...sources, source]);
48
+ }, []);
49
+ const onClickCopyToClipboard = useCallback(() => {
50
+ copyToClipboard(activeSource?.code || '');
51
+ }, [activeSource]);
52
+ const onClickReloadExample = useCallback(() => {
53
+ setLiveProviderKey((liveProviderKey) => liveProviderKey + 1);
54
+ }, []);
55
+ return (_jsx("div", { css: styles.demo, children: _jsxs(DemoContext.Provider, { value: { sources, addSource }, children: [_jsxs(LiveProvider, { code: activeSource?.code || '', transformCode: demoCodeTransformer, theme: prismThemes.dracula, scope: finalScope, children: [_jsx(DemoPreview, { padding: previewPadding, wrapperComponent: previewWrapper }), _jsx(DemoActionsBar, { isSourceOpen: isSourceOpen, setSourceOpen: setIsSourceOpen, activeSource: activeSource, sources: sources, onClickCopyToClipboard: onClickCopyToClipboard, onClickReloadExample: onClickReloadExample }), isSourceOpen && _jsx(DemoEditor, {})] }, liveProviderKey), Children.map(children, (child, index) => {
56
+ if (isElement(child) && child.type === DemoSource) {
57
+ return child;
58
+ }
59
+ return _jsx(DemoSource, { isActive: index === 0, children: child });
60
+ })] }) }));
61
+ };
@@ -0,0 +1 @@
1
+ export declare const DemoEditor: () => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+ import { LiveEditor, LiveError } from 'react-live';
10
+ import { css } from '@emotion/react';
11
+ import { useEuiMemoizedStyles } from '@elastic/eui';
12
+ const getEditorStyles = () => ({
13
+ editor: css `
14
+ font-family: var(--ifm-font-family-monospace);
15
+ border-radius: 0 0 var(--docs-demo-border-radius) var(--docs-demo-border-radius);
16
+
17
+ & .prism-code {
18
+ border-radius: 0 0 calc(var(--docs-demo-border-radius) - 1px) calc(var(--docs-demo-border-radius) - 1px);
19
+ max-height: 450px;
20
+ overflow: auto;
21
+ }
22
+ `,
23
+ error: css `
24
+ // docusaurus overrides the default pre styles
25
+ // forcing us to use higher specificity here
26
+ && > pre {
27
+ font-size: var(--eui-font-size-s);
28
+ background: var(--eui-background-color-danger);
29
+ color: var(--eui-color-danger-text);
30
+ padding: var(--eui-size-xs) var(--eui-size-s);
31
+ margin: 0;
32
+ border-radius: 0;
33
+ }
34
+ `,
35
+ });
36
+ export const DemoEditor = () => {
37
+ const styles = useEuiMemoizedStyles(getEditorStyles);
38
+ return (_jsxs("div", { css: styles.editor, children: [_jsx("div", { css: styles.error, children: _jsx(LiveError, {}) }), _jsx("div", { children: _jsx(LiveEditor, { tabMode: "focus" }) })] }));
39
+ };
@@ -0,0 +1 @@
1
+ export { DemoEditor } from './editor';
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ export { DemoEditor } from './editor';
@@ -0,0 +1,3 @@
1
+ export { Demo, type DemoProps } from './demo';
2
+ export { DemoSource } from './source';
3
+ export { createDemo } from './create_demo';
@@ -0,0 +1,10 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ export { Demo } from './demo';
9
+ export { DemoSource } from './source';
10
+ export { createDemo } from './create_demo';
@@ -0,0 +1 @@
1
+ export { DemoPreview } from './preview';
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ export { DemoPreview } from './preview';
@@ -0,0 +1,7 @@
1
+ import { ComponentType, PropsWithChildren } from 'react';
2
+ import { EuiPaddingSize } from '@elastic/eui';
3
+ export interface DemoPreviewProps {
4
+ padding?: EuiPaddingSize;
5
+ wrapperComponent?: ComponentType<PropsWithChildren>;
6
+ }
7
+ export declare const DemoPreview: ({ padding, wrapperComponent: WrapperComponent, }: DemoPreviewProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
+ /*
3
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
+ * or more contributor license agreements. Licensed under the Elastic License
5
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
6
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
7
+ * Side Public License, v 1.
8
+ */
9
+ import { css } from '@emotion/react';
10
+ import { LivePreview } from 'react-live';
11
+ import { Fragment, } from 'react';
12
+ import BrowserOnly from '@docusaurus/BrowserOnly';
13
+ import ErrorBoundary from '@docusaurus/ErrorBoundary';
14
+ import { ErrorBoundaryErrorMessageFallback } from '@docusaurus/theme-common';
15
+ import { useEuiTheme, euiPaddingSize, } from '@elastic/eui';
16
+ const getPreviewStyles = (euiTheme) => ({
17
+ previewWrapper: css `
18
+ padding: var(--docs-demo-preview-padding);
19
+ border-radius: var(--docs-demo-border-radius);
20
+ `,
21
+ });
22
+ /**
23
+ * PreviewLoader provides a fallback content for the server-side render
24
+ * of the live component preview component.
25
+ * Due to the limitations of react-live the demo is only rendered client-side.
26
+ */
27
+ const PreviewLoader = () => _jsx("div", { children: "Loading..." });
28
+ export const DemoPreview = ({ padding = 'l', wrapperComponent: WrapperComponent = Fragment, }) => {
29
+ const euiTheme = useEuiTheme();
30
+ const styles = getPreviewStyles(euiTheme);
31
+ const paddingSize = euiPaddingSize(euiTheme, padding);
32
+ const style = {
33
+ '--docs-demo-preview-padding': paddingSize,
34
+ };
35
+ return (_jsx(BrowserOnly, { fallback: _jsx(PreviewLoader, {}), children: () => (_jsx(_Fragment, { children: _jsx(ErrorBoundary, { fallback: (params) => (_jsx(ErrorBoundaryErrorMessageFallback, { ...params })), children: _jsx("div", { css: styles.previewWrapper, style: style, children: _jsx(WrapperComponent, { children: _jsx(LivePreview, {}) }) }) }) })) }));
36
+ };
@@ -0,0 +1 @@
1
+ export declare const originalScope: Record<string, unknown>;
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ import React from 'react';
9
+ export const originalScope = {
10
+ React,
11
+ ...React,
12
+ };
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SourceMeta {
3
+ /**
4
+ * The source code
5
+ */
6
+ code: string;
7
+ }
8
+ /**
9
+ * Get source string from given children.
10
+ */
11
+ export declare const getSourceFromChildren: (children: ReactNode) => string | null;