@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,2 @@
1
+ import { UseEuiTheme } from '@elastic/eui';
2
+ export declare const getResetStyles: (theme: UseEuiTheme) => import("@emotion/react").SerializedStyles;
@@ -0,0 +1,79 @@
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 { euiFocusRing } from '@elastic/eui';
9
+ import { css } from '@emotion/react';
10
+ export const getResetStyles = (theme) => {
11
+ const { euiTheme } = theme;
12
+ return css `
13
+ button {
14
+ background: none;
15
+ border: none;
16
+ padding: 0;
17
+ margin: 0;
18
+ color: inherit;
19
+ border-radius: 0;
20
+ font-size: inherit;
21
+ font-family: inherit;
22
+ }
23
+
24
+ input,
25
+ textarea,
26
+ select {
27
+ font-size: 1rem; // Inherit from html root
28
+ font-family: inherit;
29
+ }
30
+
31
+ dd {
32
+ margin: 0;
33
+ }
34
+
35
+ figure {
36
+ margin: 0;
37
+ }
38
+
39
+ img {
40
+ max-inline-size: 100%;
41
+ height: auto;
42
+ }
43
+
44
+ ul, ol {
45
+ list-style: none;
46
+ }
47
+
48
+ * {
49
+ ${euiFocusRing(theme, 'outset', { color: euiTheme.colors.primary })};
50
+ }
51
+
52
+ /**
53
+ * Resets globals in theme/Layout
54
+ * https://github.com/facebook/docusaurus/blob/e64e0e7c96f695f9d63b22c0d0ee2e4001852ac6/packages/docusaurus-theme-classic/src/theme/Layout/styles.module.css#L8-L11
55
+ */
56
+ body {
57
+ height: initial;
58
+ }
59
+
60
+ html, body, div, span, applet, object, iframe,
61
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
62
+ a, abbr, acronym, address, big, cite, code,
63
+ del, dfn, em, img, ins, kbd, q, s, samp,
64
+ small, strike, strong, sub, sup, tt, var,
65
+ b, u, i, center,
66
+ dl, dt, dd, ol, ul, li,
67
+ fieldset, form, label, legend,
68
+ table, caption, tbody, tfoot, thead, tr, th, td,
69
+ article, aside, canvas, details, embed,
70
+ figure, figcaption, footer, header, hgroup,
71
+ menu, nav, output, ruby, section, summary,
72
+ time, mark, audio, video {
73
+ margin: 0;
74
+ padding: 0;
75
+ border: none;
76
+ vertical-align: baseline;
77
+ }
78
+ `;
79
+ };
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@elastic/eui-docusaurus-theme",
3
+ "version": "2.0.0",
4
+ "description": "EUI theme for Docusaurus",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "tsc --build",
9
+ "start": "tsc --watch"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/elastic/eui.git",
14
+ "directory": "packages/docusaurus-theme"
15
+ },
16
+ "devDependencies": {
17
+ "@docusaurus/types": "^3.7.0",
18
+ "@types/react": "^18.3.3",
19
+ "@types/react-dom": "^18.3.0",
20
+ "@types/react-is": "^18",
21
+ "typedoc": "^0.28.4",
22
+ "typescript": "~5.5.4"
23
+ },
24
+ "main": "lib/index.js",
25
+ "exports": {
26
+ "./lib/*": "./lib/*",
27
+ "./components/*": "./lib/components/*",
28
+ "./components": "./lib/components/index.js",
29
+ ".": "./lib/index.js"
30
+ },
31
+ "files": [
32
+ "lib",
33
+ "src",
34
+ "!**/.tsbuildinfo"
35
+ ],
36
+ "dependencies": {
37
+ "@docusaurus/core": "^3.7.0",
38
+ "@docusaurus/module-type-aliases": "^3.7.0",
39
+ "@docusaurus/plugin-content-docs": "^3.7.0",
40
+ "@docusaurus/theme-common": "^3.7.0",
41
+ "@docusaurus/utils-validation": "^3.7.0",
42
+ "@elastic/datemath": "^5.0.3",
43
+ "@elastic/eui": "^109.1.0",
44
+ "@elastic/eui-theme-borealis": "^5.0.0",
45
+ "@emotion/css": "^11.11.2",
46
+ "@emotion/react": "^11.11.4",
47
+ "@types/react-window": "^1.8.8",
48
+ "clsx": "^2.1.1",
49
+ "codesandbox": "^2.2.3",
50
+ "dedent": "^1.5.3",
51
+ "moment": "^2.30.1",
52
+ "prism-react-renderer": "^2.3.1",
53
+ "react-is": "^18.3.1",
54
+ "react-live": "patch:react-live@npm%3A4.1.7#~/.yarn/patches/react-live-npm-4.1.7-7b41625faa.patch",
55
+ "react-window": "^1.8.10"
56
+ },
57
+ "peerDependencies": {
58
+ "react": "^18.0.0",
59
+ "react-dom": "^18.0.0"
60
+ }
61
+ }
@@ -0,0 +1,11 @@
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
+
9
+ import { EuiBadge } from '@elastic/eui';
10
+
11
+ export const Badge = EuiBadge;
@@ -0,0 +1,24 @@
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
+
9
+ import { HTMLAttributes } from 'react';
10
+
11
+ type Props = HTMLAttributes<SVGElement>;
12
+
13
+ export const CodeSandboxIcon = (props: Props) => (
14
+ <svg
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ width="16"
17
+ height="16"
18
+ preserveAspectRatio="xMidYMid"
19
+ viewBox="-20 0 296 296"
20
+ {...props}
21
+ >
22
+ <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" />
23
+ </svg>
24
+ );
@@ -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
+
9
+ export { CodeSandboxIcon } from './codesandbox_icon';
@@ -0,0 +1,95 @@
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
+
9
+ import {
10
+ EuiButton,
11
+ EuiButtonIcon,
12
+ EuiFlexGroup,
13
+ EuiToolTip,
14
+ useEuiMemoizedStyles,
15
+ UseEuiTheme,
16
+ darken,
17
+ } from '@elastic/eui';
18
+ import { css } from '@emotion/react';
19
+ import { extraActions } from '@theme/Demo/actions';
20
+ import { DemoSourceMeta } from '../demo';
21
+
22
+ export interface DemoActionsBarProps {
23
+ activeSource: DemoSourceMeta | null;
24
+ sources: DemoSourceMeta[];
25
+ isSourceOpen: boolean;
26
+ setSourceOpen(isOpen: boolean): void;
27
+ onClickReloadExample(): void;
28
+ onClickCopyToClipboard(): void;
29
+ }
30
+
31
+ const getDemoActionsBarStyles = (euiTheme: UseEuiTheme) => {
32
+ return {
33
+ actionsBar: css`
34
+ padding: var(--eui-size-s);
35
+ background: ${darken(euiTheme.euiTheme.colors.body, 0.05)};
36
+ border-top: 1px solid var(--docs-demo-border-color);
37
+
38
+ &:last-child {
39
+ // border radius should be 1px smaller to work nicely
40
+ // with the wrapper border width of 1px
41
+ border-radius: 0 0 calc(var(--docs-demo-border-radius) - 1px)
42
+ calc(var(--docs-demo-border-radius) - 1px);
43
+ }
44
+ `,
45
+ button: css`
46
+ margin-right: auto;
47
+ `,
48
+ };
49
+ };
50
+
51
+ export const DemoActionsBar = ({
52
+ isSourceOpen,
53
+ setSourceOpen,
54
+ activeSource,
55
+ sources,
56
+ onClickReloadExample,
57
+ onClickCopyToClipboard,
58
+ }: DemoActionsBarProps) => {
59
+ const styles = useEuiMemoizedStyles(getDemoActionsBarStyles);
60
+
61
+ return (
62
+ <EuiFlexGroup alignItems="center" css={styles.actionsBar} gutterSize="s">
63
+ <EuiButton
64
+ css={styles.button}
65
+ onClick={() => setSourceOpen(!isSourceOpen)}
66
+ size="s"
67
+ color="text"
68
+ minWidth={false}
69
+ >
70
+ {isSourceOpen ? 'Hide source' : 'Show source'}
71
+ </EuiButton>
72
+ {extraActions.map((ActionComponent) => (
73
+ <ActionComponent sources={sources} activeSource={activeSource} />
74
+ ))}
75
+ <EuiToolTip content="Copy to clipboard">
76
+ <EuiButtonIcon
77
+ size="s"
78
+ iconType="copyClipboard"
79
+ color="text"
80
+ onClick={onClickCopyToClipboard}
81
+ aria-label="Copy code to clipboard"
82
+ />
83
+ </EuiToolTip>
84
+ <EuiToolTip content="Reload example">
85
+ <EuiButtonIcon
86
+ size="s"
87
+ iconType="refresh"
88
+ color="text"
89
+ onClick={onClickReloadExample}
90
+ aria-label="Reload example"
91
+ />
92
+ </EuiToolTip>
93
+ </EuiFlexGroup>
94
+ );
95
+ };
@@ -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
+
9
+ export { DemoActionsBar, type DemoActionsBarProps } from './actions_bar';
@@ -0,0 +1,44 @@
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
+
9
+ const IMPORT_REGEX = /^import [^'"]* from ['"]([^.'"\n ][^'"\n ]*)['"];?/gm;
10
+ const DEFAULT_EXPORT_REGEX = /export default /;
11
+ const COMPONENT_ONLY_REGEX = /^\(?</;
12
+
13
+ /**
14
+ * Transforms input JS/TS source code to a react-live compatible syntax.
15
+ * react-live uses the surcase library to transform input source code into
16
+ * browser-readable JavaScript.
17
+ *
18
+ * While surcase does support CommonJS and ESM import/export statements,
19
+ * it's not trivial to expose our internal React and EUI exports through it
20
+ * and because we already control the execution scope of the interactive demos
21
+ * it isn't really necessary to implement a smart `require()` replacement.
22
+ *
23
+ * Returning an IIFE is necessary when the source code is more than just
24
+ * a JSX component definition (e.g. it contains a variable definition
25
+ * or `export default` statement).
26
+ *
27
+ * @see https://github.com/alangpierce/sucrase
28
+ * @see https://github.com/FormidableLabs/react-live/blob/master/packages/react-live/src/utils/transpile/index.ts
29
+ */
30
+ export const demoCodeTransformer = (code: string) => {
31
+ // Remove ESM imports
32
+ code = code.replace(IMPORT_REGEX, '');
33
+
34
+ // Handle ESM default exports
35
+ code = code.replace(DEFAULT_EXPORT_REGEX, 'return ');
36
+
37
+ // If the demo is JSX only return as-is
38
+ if (COMPONENT_ONLY_REGEX.test(code)) {
39
+ return code;
40
+ }
41
+
42
+ // If the demo is more than just JSX wrap in an immediately invoked function expression
43
+ return `(() => { ${code} })()`;
44
+ }
@@ -0,0 +1,34 @@
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
+
9
+ const importRegex =
10
+ /import([ \n\t]*(?:[^ \n\t\{\}]+[ \n\t]*,?)?(?:[ \n\t]*\{(?:[ \n\t]*[^ \n\t"'\{\}]+[ \n\t]*,?)+\})?[ \n\t]*)from[ \n\t]*(['"])(?<dependency>[^'"\n]+)(?:['"])/g;
11
+
12
+ /**
13
+ * Find dependencies in import statements and return
14
+ * a package.json-like dependencies object.
15
+ */
16
+ export const findExternalDependencies = (source: string) => {
17
+ return [...source.matchAll(importRegex)].reduce((acc, item) => {
18
+ const dependency = item.groups?.dependency;
19
+ if (!dependency) {
20
+ return acc;
21
+ }
22
+
23
+ const splitDependency = dependency.split('/');
24
+ if (dependency[0] === '@') {
25
+ // org-scoped dependencies have a single slash; ignore subsequent ones
26
+ acc[splitDependency.slice(0, 2).join('/')] = 'latest';
27
+ } else if (splitDependency[0] && /^[a-z]/i.test(splitDependency[0])) {
28
+ // non org-scoped dependencies should have no slashes
29
+ acc[splitDependency[0]] = 'latest';
30
+ }
31
+
32
+ return acc;
33
+ }, {} as Record<string, string>);
34
+ };
@@ -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
+
9
+ export { createOpenInCodeSandboxAction } from './open_action';
@@ -0,0 +1,132 @@
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
+
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 type { ActionComponent } from '../../../theme/Demo/actions';
14
+ import { CodeSandboxIcon } from '../../codesandbox_icon';
15
+ import { findExternalDependencies } from './find_external_dependencies';
16
+
17
+ const indexTsxSource = dedent`
18
+ import React from 'react';
19
+ import { createRoot } from 'react-dom/client';
20
+ import createCache from '@emotion/cache';
21
+ import { EuiProvider, euiStylisPrefixer } from '@elastic/eui';
22
+
23
+ import Demo from './demo';
24
+
25
+ const cache = createCache({
26
+ key: 'codesandbox',
27
+ stylisPlugins: [euiStylisPrefixer],
28
+ container: document.querySelector('meta[name="emotion-styles"]')!,
29
+ });
30
+ cache.compat = true;
31
+
32
+ const root = createRoot(document.getElementById('root')!);
33
+ root.render(
34
+ <EuiProvider cache={cache}>
35
+ <Demo />
36
+ </EuiProvider>
37
+ );`;
38
+
39
+ const publicIndexHtmlSource = dedent`
40
+ <head>
41
+ <title>@elastic/eui component demo</title>
42
+ <meta charset="utf-8">
43
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
44
+ <meta name="viewport" content="width=device-width,initial-scale=1">
45
+ <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" />
46
+ <meta name="emotion-styles">
47
+ </head>
48
+ <body>
49
+ <div id="root" />
50
+ </body>
51
+ `;
52
+
53
+ export const defaultCodeSandboxParameters = {
54
+ files: {
55
+ 'index.tsx': {
56
+ content: indexTsxSource,
57
+ },
58
+ 'public/index.html': {
59
+ content: publicIndexHtmlSource,
60
+ },
61
+ },
62
+ };
63
+
64
+ export type Options = {
65
+ files?: Record<string, string>;
66
+ dependencies: Record<string, string>;
67
+ };
68
+
69
+ const processTsxSource = (source: string) => {
70
+ // jsxImportSource pragma is needed in CodeSandbox as it doesn't seem
71
+ // to support that setting via tsconfig.json
72
+ return `/** @jsxImportSource @emotion/react */\n${source}`;
73
+ };
74
+
75
+ export const createOpenInCodeSandboxAction =
76
+ ({ files = {}, dependencies }: Options): ActionComponent =>
77
+ ({ activeSource }) => {
78
+ const parameters: string = useMemo(() => {
79
+ const source = activeSource?.code || '';
80
+
81
+ // Compute list of extra files that may be passed
82
+ const extraFiles = Object.entries(files).reduce(
83
+ (acc, [file, content]) => {
84
+ acc[file] = { content };
85
+ return acc;
86
+ },
87
+ {} as Record<string, { content: string }>
88
+ );
89
+
90
+ return getParameters({
91
+ files: {
92
+ ...defaultCodeSandboxParameters.files,
93
+ 'demo.tsx': {
94
+ content: processTsxSource(source),
95
+ },
96
+ 'package.json': {
97
+ content: {
98
+ dependencies: {
99
+ ...findExternalDependencies(source),
100
+ ...dependencies,
101
+ },
102
+ },
103
+ },
104
+ ...extraFiles,
105
+ },
106
+ } as any);
107
+ }, [activeSource]);
108
+
109
+ return (
110
+ <form
111
+ action="https://codesandbox.io/api/v1/sandboxes/define"
112
+ method="POST"
113
+ target="_blank"
114
+ >
115
+ <input type="hidden" name="parameters" value={parameters} />
116
+ <input
117
+ type="hidden"
118
+ name="query"
119
+ value={`module=/demo.tsx&view=split`}
120
+ />
121
+ <EuiToolTip content="Open in CodeSandbox">
122
+ <EuiButtonIcon
123
+ type="submit"
124
+ size="s"
125
+ iconType={CodeSandboxIcon}
126
+ color="text"
127
+ aria-label="Open in CodeSandbox"
128
+ />
129
+ </EuiToolTip>
130
+ </form>
131
+ );
132
+ };
@@ -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
+
9
+ import { createContext, useContext } from 'react';
10
+ import { DemoSourceMeta } from './demo';
11
+
12
+ export interface DemoContextObject {
13
+ /**
14
+ * Array of all available sources for this demo instance
15
+ */
16
+ sources: DemoSourceMeta[];
17
+
18
+ /**
19
+ * Add source to the list of available sources
20
+ * This should only be used internally when initializing the component!
21
+ */
22
+ addSource(source: DemoSourceMeta): void;
23
+ }
24
+
25
+ export const DemoContext = createContext<DemoContextObject>({
26
+ sources: [],
27
+ addSource: () => {},
28
+ });
29
+
30
+ export const useDemoContext = () => useContext(DemoContext);
@@ -0,0 +1,17 @@
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
+
9
+ import { Demo, DemoProps } from './demo';
10
+
11
+ /**
12
+ * Creates a custom <Demo /> component with predefined props.
13
+ */
14
+ export const createDemo =
15
+ (defaultProps: Partial<DemoProps>): typeof Demo =>
16
+ (props: DemoProps) =>
17
+ <Demo {...defaultProps} {...props} />;