@antv/dumi-theme-antv 0.2.2 → 0.3.0-beta.10

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 (265) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -33
  3. package/dist/builtins/Playground/index.d.ts +21 -0
  4. package/dist/builtins/Playground/index.js +69 -0
  5. package/dist/builtins/Playground/index.module.less +15 -0
  6. package/dist/context.d.ts +6 -0
  7. package/dist/context.js +2 -0
  8. package/dist/layouts/DocLayout.d.ts +7 -0
  9. package/dist/layouts/DocLayout.js +48 -0
  10. package/dist/layouts/entry/API.d.ts +10 -0
  11. package/dist/layouts/entry/API.js +12 -0
  12. package/dist/layouts/entry/Index.d.ts +7 -0
  13. package/dist/layouts/entry/Index.js +79 -0
  14. package/dist/layouts/entry/Manual.d.ts +8 -0
  15. package/dist/layouts/entry/Manual.js +13 -0
  16. package/dist/locales/en.json +98 -0
  17. package/dist/locales/zh.json +98 -0
  18. package/dist/pages/404.d.ts +6 -0
  19. package/dist/pages/404.js +18 -0
  20. package/dist/pages/Example/index.d.ts +6 -0
  21. package/dist/pages/Example/index.js +115 -0
  22. package/dist/pages/Example/index.module.less +82 -0
  23. package/dist/pages/Example/utils.d.ts +1 -0
  24. package/dist/pages/Example/utils.js +9 -0
  25. package/dist/pages/Examples/components/Accouncement/index.d.ts +6 -0
  26. package/dist/pages/Examples/components/Accouncement/index.js +60 -0
  27. package/dist/pages/Examples/components/Accouncement/index.module.less +9 -0
  28. package/dist/pages/Examples/components/Article/index.d.ts +2 -0
  29. package/dist/pages/Examples/components/Article/index.js +8 -0
  30. package/dist/pages/Examples/components/Article/index.module.less +2 -0
  31. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.d.ts +10 -0
  32. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +74 -0
  33. package/dist/pages/Examples/components/ExampleTopicMenu/index.d.ts +9 -0
  34. package/{es/builtins/Example.js → dist/pages/Examples/components/ExampleTopicMenu/index.js} +47 -33
  35. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.d.ts +10 -0
  36. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +33 -0
  37. package/dist/pages/Examples/components/GalleryPageContent/index.d.ts +10 -0
  38. package/dist/pages/Examples/components/GalleryPageContent/index.js +81 -0
  39. package/dist/pages/Examples/index.d.ts +8 -0
  40. package/dist/pages/Examples/index.js +95 -0
  41. package/dist/pages/Examples/index.module.less +607 -0
  42. package/dist/pages/Examples/types.d.ts +34 -0
  43. package/dist/pages/Examples/types.js +1 -0
  44. package/dist/plugin/examples.d.ts +21 -0
  45. package/dist/plugin/examples.js +105 -0
  46. package/dist/plugin/index.d.ts +3 -0
  47. package/dist/plugin/index.js +113 -0
  48. package/dist/plugin/utils.d.ts +5 -0
  49. package/dist/plugin/utils.js +46 -0
  50. package/dist/slots/404.d.ts +2 -0
  51. package/{es/antv/404/index.js → dist/slots/404.js} +4 -9
  52. package/{es/antv/Cases/Cases.d.ts → dist/slots/Cases/index.d.ts} +5 -4
  53. package/{es/antv/Cases/Cases.js → dist/slots/Cases/index.js} +25 -25
  54. package/{src/antv/Cases/Cases.module.less → dist/slots/Cases/index.module.less} +36 -5
  55. package/dist/slots/CodeEditor/Toolbar.d.ts +67 -0
  56. package/dist/slots/CodeEditor/Toolbar.js +140 -0
  57. package/dist/slots/CodeEditor/Toolbar.module.less +81 -0
  58. package/dist/slots/CodeEditor/index.d.ts +58 -0
  59. package/dist/slots/CodeEditor/index.js +226 -0
  60. package/dist/slots/CodeEditor/index.module.less +11 -0
  61. package/dist/slots/CodeEditor/utils.d.ts +42 -0
  62. package/dist/slots/CodeEditor/utils.js +157 -0
  63. package/dist/slots/CodePreview/CodeHeader.d.ts +19 -0
  64. package/dist/slots/CodePreview/CodeHeader.js +32 -0
  65. package/dist/slots/CodePreview/CodeHeader.module.less +0 -0
  66. package/dist/slots/CodePreview/index.d.ts +17 -0
  67. package/dist/slots/CodePreview/index.js +29 -0
  68. package/dist/slots/CodePreview/index.module.less +43 -0
  69. package/dist/slots/CodeRunner/index.d.ts +15 -0
  70. package/dist/slots/CodeRunner/index.js +79 -0
  71. package/dist/slots/CodeRunner/index.module.less +0 -0
  72. package/dist/slots/CodeRunner/utils.d.ts +11 -0
  73. package/dist/slots/CodeRunner/utils.js +36 -0
  74. package/dist/slots/Companies/index.d.ts +13 -0
  75. package/dist/slots/Companies/index.js +49 -0
  76. package/dist/slots/Companies/index.module.less +82 -0
  77. package/dist/slots/Detail/News.d.ts +10 -0
  78. package/{es/antv/Banner/Notification.js → dist/slots/Detail/News.js} +8 -11
  79. package/{src/antv/Banner/Notification.module.less → dist/slots/Detail/News.module.less} +15 -3
  80. package/dist/slots/Detail/index.d.ts +27 -0
  81. package/dist/slots/Detail/index.js +124 -0
  82. package/{src/antv/Banner/Banner.module.less → dist/slots/Detail/index.module.less} +42 -74
  83. package/dist/slots/ExampleSider/index.d.ts +21 -0
  84. package/dist/slots/ExampleSider/index.js +196 -0
  85. package/dist/slots/ExampleSider/index.module.less +141 -0
  86. package/{es/antv → dist/slots}/Features/FeatureCard.d.ts +2 -1
  87. package/{es/antv → dist/slots}/Features/FeatureCard.js +6 -6
  88. package/{src/antv → dist/slots}/Features/FeatureCard.module.less +8 -1
  89. package/{es/antv → dist/slots}/Features/index.d.ts +2 -2
  90. package/{es/antv → dist/slots}/Features/index.js +19 -26
  91. package/{src/antv/Features/Features.module.less → dist/slots/Features/index.module.less} +34 -3
  92. package/dist/slots/Footer/index.d.ts +18 -0
  93. package/dist/slots/Footer/index.js +188 -0
  94. package/dist/slots/Footer/index.module.less +86 -0
  95. package/dist/slots/Header/Logo.d.ts +7 -0
  96. package/{es/antv → dist/slots}/Header/Logo.js +6 -2
  97. package/dist/slots/Header/LogoWhite.d.ts +7 -0
  98. package/dist/slots/Header/LogoWhite.js +19 -0
  99. package/dist/slots/Header/Navs.d.ts +26 -0
  100. package/dist/slots/Header/Navs.js +63 -0
  101. package/dist/slots/Header/Products/NavigatorBanner.d.ts +10 -0
  102. package/dist/slots/Header/Products/NavigatorBanner.js +34 -0
  103. package/dist/slots/Header/Products/NavigatorBanner.module.less +39 -0
  104. package/{es/antv → dist/slots/Header}/Products/Product.d.ts +3 -3
  105. package/{es/antv → dist/slots/Header}/Products/Product.js +11 -16
  106. package/{src/antv → dist/slots/Header}/Products/Product.module.less +10 -8
  107. package/{es/antv → dist/slots/Header}/Products/getProducts.d.ts +2 -7
  108. package/dist/slots/Header/Products/getProducts.js +67 -0
  109. package/dist/slots/Header/Products/index.d.ts +9 -0
  110. package/{es/antv → dist/slots/Header}/Products/index.js +15 -22
  111. package/dist/slots/Header/Search.d.ts +12 -0
  112. package/dist/slots/Header/Search.js +90 -0
  113. package/dist/slots/Header/Search.module.less +39 -0
  114. package/dist/slots/Header/index.d.ts +66 -0
  115. package/dist/slots/Header/index.js +380 -0
  116. package/dist/slots/Header/index.module.less +382 -0
  117. package/dist/slots/Header/utils.d.ts +1 -0
  118. package/dist/slots/Header/utils.js +26 -0
  119. package/dist/slots/Loading/index.d.ts +7 -0
  120. package/dist/slots/Loading/index.js +79 -0
  121. package/dist/slots/Loading/index.module.less +279 -0
  122. package/dist/slots/ManualContent/NavigatorBanner.d.ts +9 -0
  123. package/dist/slots/ManualContent/NavigatorBanner.js +36 -0
  124. package/dist/slots/ManualContent/NavigatorBanner.module.less +39 -0
  125. package/dist/slots/ManualContent/ReadingTime.d.ts +3 -0
  126. package/dist/slots/ManualContent/ReadingTime.js +10 -0
  127. package/dist/slots/ManualContent/index.d.ts +9 -0
  128. package/dist/slots/ManualContent/index.js +344 -0
  129. package/dist/slots/ManualContent/index.module.less +668 -0
  130. package/dist/slots/ManualContent/utils.d.ts +3 -0
  131. package/dist/slots/ManualContent/utils.js +35 -0
  132. package/dist/slots/SEO.d.ts +10 -0
  133. package/dist/slots/SEO.js +59 -0
  134. package/dist/slots/TOC.d.ts +5 -0
  135. package/dist/slots/TOC.js +6 -0
  136. package/dist/slots/_.less +83 -0
  137. package/dist/slots/global.d.ts +1 -0
  138. package/dist/slots/global.js +7 -0
  139. package/dist/slots/hooks.d.ts +16 -0
  140. package/{es/antv → dist/slots}/hooks.js +60 -37
  141. package/dist/slots/utils.d.ts +5 -0
  142. package/dist/slots/utils.js +112 -0
  143. package/dist/types.d.ts +86 -0
  144. package/dist/types.js +1 -0
  145. package/dist/typings.d.ts +24 -0
  146. package/package.json +110 -47
  147. package/es/antv/404/index.d.ts +0 -2
  148. package/es/antv/Banner/Banner.module.less +0 -412
  149. package/es/antv/Banner/Notification.d.ts +0 -10
  150. package/es/antv/Banner/Notification.module.less +0 -108
  151. package/es/antv/Banner/index.d.ts +0 -25
  152. package/es/antv/Banner/index.js +0 -104
  153. package/es/antv/Cases/Cases.module.less +0 -203
  154. package/es/antv/Features/FeatureCard.module.less +0 -51
  155. package/es/antv/Features/Features.module.less +0 -169
  156. package/es/antv/Footer/Footer.module.less +0 -36
  157. package/es/antv/Footer/index.d.ts +0 -12
  158. package/es/antv/Footer/index.js +0 -237
  159. package/es/antv/Header/Logo.d.ts +0 -4
  160. package/es/antv/Products/Product.module.less +0 -146
  161. package/es/antv/Products/getNewProducts.d.ts +0 -24
  162. package/es/antv/Products/getNewProducts.js +0 -35
  163. package/es/antv/Products/getProducts.js +0 -460
  164. package/es/antv/Products/index.d.ts +0 -9
  165. package/es/antv/hooks.d.ts +0 -14
  166. package/es/antv/mixins.less +0 -21
  167. package/es/antv/utils.d.ts +0 -5
  168. package/es/antv/utils.js +0 -49
  169. package/es/builtins/API.d.ts +0 -3
  170. package/es/builtins/API.js +0 -37
  171. package/es/builtins/Alert.d.ts +0 -3
  172. package/es/builtins/Alert.js +0 -7
  173. package/es/builtins/Alert.less +0 -62
  174. package/es/builtins/Badge.d.ts +0 -3
  175. package/es/builtins/Badge.js +0 -7
  176. package/es/builtins/Badge.less +0 -31
  177. package/es/builtins/Example.d.ts +0 -5
  178. package/es/builtins/Example.less +0 -47
  179. package/es/builtins/Previewer.d.ts +0 -39
  180. package/es/builtins/Previewer.js +0 -225
  181. package/es/builtins/Previewer.less +0 -406
  182. package/es/builtins/SourceCode.d.ts +0 -10
  183. package/es/builtins/SourceCode.js +0 -70
  184. package/es/builtins/SourceCode.less +0 -103
  185. package/es/builtins/Table.d.ts +0 -4
  186. package/es/builtins/Table.js +0 -56
  187. package/es/builtins/Table.less +0 -43
  188. package/es/builtins/Tree.d.ts +0 -4
  189. package/es/builtins/Tree.js +0 -213
  190. package/es/builtins/Tree.less +0 -159
  191. package/es/components/Dark.d.ts +0 -9
  192. package/es/components/Dark.js +0 -125
  193. package/es/components/Dark.less +0 -121
  194. package/es/components/LocaleSelect.d.ts +0 -6
  195. package/es/components/LocaleSelect.js +0 -53
  196. package/es/components/LocaleSelect.less +0 -59
  197. package/es/components/Navbar.d.ts +0 -10
  198. package/es/components/Navbar.js +0 -155
  199. package/es/components/Navbar.less +0 -180
  200. package/es/components/SearchBar.d.ts +0 -4
  201. package/es/components/SearchBar.js +0 -81
  202. package/es/components/SearchBar.less +0 -165
  203. package/es/components/SideMenu.d.ts +0 -10
  204. package/es/components/SideMenu.js +0 -99
  205. package/es/components/SideMenu.less +0 -379
  206. package/es/components/SlugList.d.ts +0 -7
  207. package/es/components/SlugList.js +0 -38
  208. package/es/components/SlugList.less +0 -18
  209. package/es/declaration.d.ts +0 -1
  210. package/es/layout.d.ts +0 -5
  211. package/es/layout.js +0 -276
  212. package/es/style/layout.less +0 -402
  213. package/es/style/markdown.less +0 -240
  214. package/es/style/variables.less +0 -37
  215. package/src/antv/404/index.tsx +0 -25
  216. package/src/antv/Banner/Notification.tsx +0 -45
  217. package/src/antv/Banner/index.tsx +0 -139
  218. package/src/antv/Cases/Cases.tsx +0 -116
  219. package/src/antv/Features/FeatureCard.tsx +0 -24
  220. package/src/antv/Features/index.tsx +0 -86
  221. package/src/antv/Footer/Footer.module.less +0 -36
  222. package/src/antv/Footer/index.tsx +0 -272
  223. package/src/antv/Header/Logo.tsx +0 -85
  224. package/src/antv/Products/Product.tsx +0 -80
  225. package/src/antv/Products/getNewProducts.tsx +0 -53
  226. package/src/antv/Products/getProducts.tsx +0 -626
  227. package/src/antv/Products/index.tsx +0 -70
  228. package/src/antv/hooks.ts +0 -87
  229. package/src/antv/mixins.less +0 -21
  230. package/src/antv/utils.ts +0 -44
  231. package/src/builtins/API.tsx +0 -57
  232. package/src/builtins/Alert.less +0 -62
  233. package/src/builtins/Alert.tsx +0 -4
  234. package/src/builtins/Badge.less +0 -31
  235. package/src/builtins/Badge.tsx +0 -4
  236. package/src/builtins/Example.less +0 -47
  237. package/src/builtins/Example.tsx +0 -34
  238. package/src/builtins/Previewer.less +0 -406
  239. package/src/builtins/Previewer.tsx +0 -264
  240. package/src/builtins/SourceCode.less +0 -103
  241. package/src/builtins/SourceCode.tsx +0 -55
  242. package/src/builtins/Table.less +0 -43
  243. package/src/builtins/Table.tsx +0 -42
  244. package/src/builtins/Tree.less +0 -159
  245. package/src/builtins/Tree.tsx +0 -130
  246. package/src/components/Dark.less +0 -121
  247. package/src/components/Dark.tsx +0 -78
  248. package/src/components/LocaleSelect.less +0 -59
  249. package/src/components/LocaleSelect.tsx +0 -53
  250. package/src/components/Navbar.less +0 -180
  251. package/src/components/Navbar.tsx +0 -152
  252. package/src/components/SearchBar.less +0 -165
  253. package/src/components/SearchBar.tsx +0 -68
  254. package/src/components/SideMenu.less +0 -379
  255. package/src/components/SideMenu.tsx +0 -148
  256. package/src/components/SlugList.less +0 -18
  257. package/src/components/SlugList.tsx +0 -20
  258. package/src/declaration.d.ts +0 -1
  259. package/src/layout.tsx +0 -225
  260. package/src/style/layout.less +0 -402
  261. package/src/style/markdown.less +0 -240
  262. package/src/style/variables.less +0 -37
  263. package/src/test/SearchBar.test.ts +0 -32
  264. package/src/test/Table.test.tsx +0 -41
  265. package/src/test/index.test.tsx +0 -377
@@ -1,3 +0,0 @@
1
- import './Badge.less';
2
- declare const _default: (props: any) => JSX.Element;
3
- export default _default;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import './Badge.less';
3
- export default (function (props) {
4
- return /*#__PURE__*/React.createElement("span", Object.assign({
5
- className: "__dumi-default-badge"
6
- }, props));
7
- });
@@ -1,31 +0,0 @@
1
- @import (reference) '../style/variables.less';
2
-
3
- .@{prefix}-badge {
4
- display: inline-block;
5
- margin-left: 6px;
6
- padding: 1px 7px;
7
- color: #fff;
8
- font-size: 13px;
9
- line-height: 20px;
10
- text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1);
11
- box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.06);
12
- border-radius: 1px;
13
- vertical-align: top;
14
-
15
- &:not([type]),
16
- &[type='info'] {
17
- background: #4569d4;
18
- }
19
-
20
- &[type='warning'] {
21
- background: #ffc121;
22
- }
23
-
24
- &[type='success'] {
25
- background: #8cd225;
26
- }
27
-
28
- &[type='error'] {
29
- background: #ff4646;
30
- }
31
- }
@@ -1,5 +0,0 @@
1
- import './Example.less';
2
- declare const _default: (props: {
3
- route: any;
4
- }) => JSX.Element;
5
- export default _default;
@@ -1,47 +0,0 @@
1
- @import (reference) '../style/variables.less';
2
-
3
- .@{prefix}-example-wrapper {
4
- padding-top: 16px;
5
- height: calc(100vh - @s-nav-height - 2px);
6
-
7
- @media @mobile {
8
- padding-top: 16px;
9
- }
10
-
11
- &-toolbar {
12
- display: flex;
13
- color: @c-heading;
14
- font-size: 16px;
15
- font-weight: 500;
16
- justify-content: space-between;
17
- margin-bottom: 16px;
18
- border-bottom: 1px solid @c-border;
19
-
20
- button,
21
- a {
22
- display: inline-block;
23
- margin: 6px 0 6px 12px;
24
- width: 16px;
25
- height: 16px;
26
- font-weight: 400;
27
- border: 0;
28
- outline: none;
29
- vertical-align: middle;
30
- cursor: pointer;
31
-
32
- &:first-child {
33
- background-position-x: -144px;
34
- }
35
-
36
- &:nth-child(2) {
37
- background-position-x: -126px;
38
- }
39
- }
40
- }
41
-
42
- iframe {
43
- width: 100%;
44
- min-height: 100%;
45
- border: 0;
46
- }
47
- }
@@ -1,39 +0,0 @@
1
- import React from 'react';
2
- import type { IPreviewerComponentProps } from 'dumi/theme';
3
- import './Previewer.less';
4
- export interface IPreviewerProps extends IPreviewerComponentProps {
5
- /**
6
- * enable transform to change CSS containing block for demo
7
- */
8
- transform?: boolean;
9
- /**
10
- * modify background for demo area
11
- */
12
- background?: string;
13
- /**
14
- * collapse padding of demo area
15
- */
16
- compact?: boolean;
17
- /**
18
- * configurations for action button
19
- */
20
- hideActions?: ('CSB' | 'EXTERNAL' | 'RIDDLE')[];
21
- /**
22
- * show source code by default
23
- */
24
- defaultShowCode?: boolean;
25
- /**
26
- * use iframe mode for this demo
27
- */
28
- iframe?: true | number;
29
- /**
30
- * replace builtin demo url
31
- */
32
- demoUrl?: string;
33
- /**
34
- * control action bar render
35
- */
36
- actionBarRender?: (actionBarNode: React.ReactNode) => React.ReactNode;
37
- }
38
- declare const Previewer: React.FC<IPreviewerProps>;
39
- export default Previewer;
@@ -1,225 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
-
9
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
-
11
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
- import React, { useState, useContext, useRef, useEffect } from 'react';
14
- import Tabs, { TabPane } from 'rc-tabs'; // @ts-ignore
15
-
16
- import { history } from 'dumi';
17
- import { context, useCodeSandbox, useRiddle, useMotions, useCopy, useLocaleProps, useDemoUrl, useTSPlaygroundUrl, Link, AnchorLink, usePrefersColor } from 'dumi/theme';
18
- import SourceCode from './SourceCode';
19
- import './Previewer.less';
20
- /**
21
- * get source code type for file
22
- * @param file file path
23
- * @param source file source object
24
- */
25
-
26
- function getSourceType(file, source) {
27
- var _a; // use file extension as source type first
28
-
29
-
30
- var type = (_a = file.match(/\.(\w+)$/)) === null || _a === void 0 ? void 0 : _a[1];
31
-
32
- if (!type) {
33
- type = source.tsx ? 'tsx' : 'jsx';
34
- }
35
-
36
- return type;
37
- }
38
-
39
- var Previewer = function Previewer(oProps) {
40
- var _a, _b, _c;
41
-
42
- var demoRef = useRef();
43
-
44
- var _useContext = useContext(context),
45
- locale = _useContext.locale;
46
-
47
- var props = useLocaleProps(locale, oProps);
48
- var builtinDemoUrl = useDemoUrl(props.identifier);
49
- var demoUrl = props.demoUrl || builtinDemoUrl;
50
- var isActive = (history === null || history === void 0 ? void 0 : history.location.hash) === "#".concat(props.identifier);
51
- var isSingleFile = Object.keys(props.sources).length === 1;
52
- var openCSB = useCodeSandbox(((_a = props.hideActions) === null || _a === void 0 ? void 0 : _a.includes('CSB')) ? null : props);
53
- var openRiddle = useRiddle(((_b = props.hideActions) === null || _b === void 0 ? void 0 : _b.includes('RIDDLE')) ? null : props);
54
-
55
- var _useMotions = useMotions(props.motions || [], demoRef.current),
56
- _useMotions2 = _slicedToArray(_useMotions, 2),
57
- execMotions = _useMotions2[0],
58
- isMotionRunning = _useMotions2[1];
59
-
60
- var _useCopy = useCopy(),
61
- _useCopy2 = _slicedToArray(_useCopy, 2),
62
- copyCode = _useCopy2[0],
63
- copyStatus = _useCopy2[1];
64
-
65
- var _useState = useState(function () {
66
- return props.sources._ ? '_' : Object.keys(props.sources)[0];
67
- }),
68
- _useState2 = _slicedToArray(_useState, 2),
69
- currentFile = _useState2[0],
70
- setCurrentFile = _useState2[1];
71
-
72
- var _useState3 = useState(getSourceType(currentFile, props.sources[currentFile])),
73
- _useState4 = _slicedToArray(_useState3, 2),
74
- sourceType = _useState4[0],
75
- setSourceType = _useState4[1];
76
-
77
- var _useState5 = useState(Boolean(props.defaultShowCode)),
78
- _useState6 = _slicedToArray(_useState5, 2),
79
- showSource = _useState6[0],
80
- setShowSource = _useState6[1];
81
-
82
- var _useState7 = useState(Math.random()),
83
- _useState8 = _slicedToArray(_useState7, 2),
84
- iframeKey = _useState8[0],
85
- setIframeKey = _useState8[1];
86
-
87
- var currentFileCode = props.sources[currentFile][sourceType] || props.sources[currentFile].content;
88
- var playgroundUrl = useTSPlaygroundUrl(locale, currentFileCode);
89
- var iframeRef = useRef();
90
-
91
- var _usePrefersColor = usePrefersColor(),
92
- _usePrefersColor2 = _slicedToArray(_usePrefersColor, 1),
93
- color = _usePrefersColor2[0];
94
-
95
- var _props$actionBarRende = props.actionBarRender,
96
- actionBarRender = _props$actionBarRende === void 0 ? function (o) {
97
- return o;
98
- } : _props$actionBarRende; // re-render iframe if prefers color changed
99
-
100
- useEffect(function () {
101
- setIframeKey(Math.random());
102
- }, [color]);
103
-
104
- function handleFileChange(filename) {
105
- setCurrentFile(filename);
106
- setSourceType(getSourceType(filename, props.sources[filename]));
107
- }
108
-
109
- return /*#__PURE__*/React.createElement("div", {
110
- style: props.style,
111
- className: [props.className, '__dumi-default-previewer', isActive ? '__dumi-default-previewer-target' : ''].filter(Boolean).join(' '),
112
- id: props.identifier,
113
- "data-debug": props.debug || undefined,
114
- "data-iframe": props.iframe || undefined
115
- }, props.iframe && /*#__PURE__*/React.createElement("div", {
116
- className: "__dumi-default-previewer-browser-nav"
117
- }), /*#__PURE__*/React.createElement("div", {
118
- ref: demoRef,
119
- className: "__dumi-default-previewer-demo",
120
- style: {
121
- transform: props.transform ? 'translate(0, 0)' : undefined,
122
- padding: props.compact || props.iframe && props.compact !== false ? '0' : undefined,
123
- background: props.background
124
- }
125
- }, props.iframe ? /*#__PURE__*/React.createElement("iframe", {
126
- title: "dumi-previewer",
127
- style: {
128
- // both compatible with unit or non-unit, such as 100, 100px, 100vh
129
- height: String(props.iframe).replace(/(\d)$/, '$1px')
130
- },
131
- key: iframeKey,
132
- src: demoUrl,
133
- ref: iframeRef
134
- }) : props.children), /*#__PURE__*/React.createElement("div", {
135
- className: "__dumi-default-previewer-desc",
136
- "data-title": props.title
137
- }, props.title && /*#__PURE__*/React.createElement(AnchorLink, {
138
- to: "#".concat(props.identifier)
139
- }, props.title), props.description && /*#__PURE__*/React.createElement("div", {
140
- // eslint-disable-next-line
141
- dangerouslySetInnerHTML: {
142
- __html: props.description
143
- }
144
- })), /*#__PURE__*/React.createElement("div", {
145
- className: "__dumi-default-previewer-actions"
146
- }, actionBarRender( /*#__PURE__*/React.createElement(React.Fragment, null, openCSB && /*#__PURE__*/React.createElement("button", {
147
- title: "Open demo on CodeSandbox.io",
148
- className: "__dumi-default-icon",
149
- role: "codesandbox",
150
- onClick: openCSB
151
- }), openRiddle && /*#__PURE__*/React.createElement("button", {
152
- title: "Open demo on Riddle",
153
- className: "__dumi-default-icon",
154
- role: "riddle",
155
- onClick: openRiddle
156
- }), props.motions && /*#__PURE__*/React.createElement("button", {
157
- title: "Execute motions",
158
- className: "__dumi-default-icon",
159
- role: "motions",
160
- disabled: isMotionRunning,
161
- onClick: function onClick() {
162
- return execMotions();
163
- }
164
- }), props.iframe && /*#__PURE__*/React.createElement("button", {
165
- title: "Reload demo iframe page",
166
- className: "__dumi-default-icon",
167
- role: "refresh",
168
- onClick: function onClick() {
169
- return setIframeKey(Math.random());
170
- }
171
- }), !((_c = props.hideActions) === null || _c === void 0 ? void 0 : _c.includes('EXTERNAL')) && /*#__PURE__*/React.createElement(Link, {
172
- target: "_blank",
173
- to: demoUrl
174
- }, /*#__PURE__*/React.createElement("button", {
175
- title: "Open demo in new tab",
176
- className: "__dumi-default-icon",
177
- role: "open-demo",
178
- type: "button"
179
- })), /*#__PURE__*/React.createElement("span", null), /*#__PURE__*/React.createElement("button", {
180
- title: "Copy source code",
181
- className: "__dumi-default-icon",
182
- role: "copy",
183
- "data-status": copyStatus,
184
- onClick: function onClick() {
185
- return copyCode(currentFileCode);
186
- }
187
- }), sourceType === 'tsx' && showSource && /*#__PURE__*/React.createElement(Link, {
188
- target: "_blank",
189
- to: playgroundUrl
190
- }, /*#__PURE__*/React.createElement("button", {
191
- title: "Get JSX via TypeScript Playground",
192
- className: "__dumi-default-icon",
193
- role: "change-tsx",
194
- type: "button"
195
- })), /*#__PURE__*/React.createElement("button", {
196
- title: "Toggle source code panel",
197
- className: "__dumi-default-icon".concat(showSource ? ' __dumi-default-btn-expand' : ''),
198
- role: "source",
199
- type: "button",
200
- onClick: function onClick() {
201
- return setShowSource(!showSource);
202
- }
203
- })))), showSource && /*#__PURE__*/React.createElement("div", {
204
- className: "__dumi-default-previewer-source-wrapper"
205
- }, !isSingleFile && /*#__PURE__*/React.createElement(Tabs, {
206
- className: "__dumi-default-previewer-source-tab",
207
- prefixCls: "__dumi-default-tabs",
208
- moreIcon: "\xB7\xB7\xB7",
209
- defaultActiveKey: currentFile,
210
- onChange: handleFileChange
211
- }, Object.keys(props.sources).map(function (filename) {
212
- return /*#__PURE__*/React.createElement(TabPane, {
213
- tab: filename === '_' ? "index.".concat(getSourceType(filename, props.sources[filename])) : filename,
214
- key: filename
215
- });
216
- })), /*#__PURE__*/React.createElement("div", {
217
- className: "__dumi-default-previewer-source"
218
- }, /*#__PURE__*/React.createElement(SourceCode, {
219
- code: currentFileCode,
220
- lang: sourceType,
221
- showCopy: false
222
- }))));
223
- };
224
-
225
- export default Previewer;