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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -33
  3. package/dist/builtins/Playground/index.d.ts +24 -0
  4. package/{es/builtins/Example.js → dist/builtins/Playground/index.js} +40 -33
  5. package/dist/builtins/Playground/index.module.less +15 -0
  6. package/dist/context.d.ts +5 -0
  7. package/dist/context.js +2 -0
  8. package/dist/layouts/DocLayout.d.ts +7 -0
  9. package/dist/layouts/DocLayout.js +38 -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 +71 -0
  14. package/dist/layouts/entry/Manual.d.ts +8 -0
  15. package/dist/layouts/entry/Manual.js +14 -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 +14 -0
  20. package/dist/pages/Example/index.d.ts +6 -0
  21. package/dist/pages/Example/index.js +139 -0
  22. package/dist/pages/Example/index.module.less +40 -0
  23. package/dist/pages/Examples/components/Accouncement/index.d.ts +6 -0
  24. package/dist/pages/Examples/components/Accouncement/index.js +60 -0
  25. package/dist/pages/Examples/components/Accouncement/index.module.less +9 -0
  26. package/dist/pages/Examples/components/Article/index.d.ts +2 -0
  27. package/dist/pages/Examples/components/Article/index.js +8 -0
  28. package/dist/pages/Examples/components/Article/index.module.less +2 -0
  29. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.d.ts +10 -0
  30. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +74 -0
  31. package/dist/pages/Examples/components/ExampleTopicMenu/index.d.ts +9 -0
  32. package/{es/builtins/Table.js → dist/pages/Examples/components/ExampleTopicMenu/index.js} +47 -41
  33. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.d.ts +10 -0
  34. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +33 -0
  35. package/dist/pages/Examples/components/GalleryPageContent/index.d.ts +10 -0
  36. package/dist/pages/Examples/components/GalleryPageContent/index.js +81 -0
  37. package/dist/pages/Examples/index.d.ts +8 -0
  38. package/dist/pages/Examples/index.js +75 -0
  39. package/dist/pages/Examples/index.module.less +605 -0
  40. package/dist/pages/Examples/types.d.ts +33 -0
  41. package/dist/pages/Examples/types.js +1 -0
  42. package/dist/plugin/examples.d.ts +7 -0
  43. package/dist/plugin/examples.js +83 -0
  44. package/dist/plugin/index.d.ts +3 -0
  45. package/dist/plugin/index.js +103 -0
  46. package/dist/slots/404.d.ts +2 -0
  47. package/{es/antv/404/index.js → dist/slots/404.js} +4 -9
  48. package/{es/antv/Cases/Cases.d.ts → dist/slots/Cases/index.d.ts} +4 -4
  49. package/{es/antv/Cases/Cases.js → dist/slots/Cases/index.js} +25 -25
  50. package/{src/antv/Cases/Cases.module.less → dist/slots/Cases/index.module.less} +36 -5
  51. package/dist/slots/CodeEditor/Toolbar.d.ts +67 -0
  52. package/dist/slots/CodeEditor/Toolbar.js +152 -0
  53. package/dist/slots/CodeEditor/Toolbar.module.less +81 -0
  54. package/dist/slots/CodeEditor/index.d.ts +58 -0
  55. package/dist/slots/CodeEditor/index.js +200 -0
  56. package/dist/slots/CodeEditor/index.module.less +11 -0
  57. package/dist/slots/CodeEditor/utils.d.ts +42 -0
  58. package/dist/slots/CodeEditor/utils.js +157 -0
  59. package/dist/slots/CodePreview/CodeHeader.d.ts +19 -0
  60. package/dist/slots/CodePreview/CodeHeader.js +32 -0
  61. package/dist/slots/CodePreview/CodeHeader.module.less +0 -0
  62. package/dist/slots/CodePreview/index.d.ts +17 -0
  63. package/dist/slots/CodePreview/index.js +29 -0
  64. package/dist/slots/CodePreview/index.module.less +42 -0
  65. package/dist/slots/CodeRunner/index.d.ts +14 -0
  66. package/dist/slots/CodeRunner/index.js +76 -0
  67. package/dist/slots/CodeRunner/index.module.less +0 -0
  68. package/dist/slots/CodeRunner/utils.d.ts +10 -0
  69. package/dist/slots/CodeRunner/utils.js +36 -0
  70. package/dist/slots/Companies/index.d.ts +13 -0
  71. package/dist/slots/Companies/index.js +49 -0
  72. package/dist/slots/Companies/index.module.less +82 -0
  73. package/dist/slots/Detail/News.d.ts +9 -0
  74. package/{es/antv/Banner/Notification.js → dist/slots/Detail/News.js} +8 -11
  75. package/{src/antv/Banner/Notification.module.less → dist/slots/Detail/News.module.less} +15 -3
  76. package/dist/slots/Detail/index.d.ts +26 -0
  77. package/dist/slots/Detail/index.js +124 -0
  78. package/{src/antv/Banner/Banner.module.less → dist/slots/Detail/index.module.less} +42 -74
  79. package/dist/slots/ExampleSider/index.d.ts +55 -0
  80. package/dist/slots/ExampleSider/index.js +218 -0
  81. package/dist/slots/ExampleSider/index.module.less +141 -0
  82. package/{es/antv → dist/slots}/Features/FeatureCard.d.ts +1 -1
  83. package/{es/antv → dist/slots}/Features/FeatureCard.js +6 -6
  84. package/{src/antv → dist/slots}/Features/FeatureCard.module.less +8 -1
  85. package/{es/antv → dist/slots}/Features/index.d.ts +2 -2
  86. package/{es/antv → dist/slots}/Features/index.js +17 -25
  87. package/{src/antv/Features/Features.module.less → dist/slots/Features/index.module.less} +34 -3
  88. package/dist/slots/Footer/index.d.ts +18 -0
  89. package/dist/slots/Footer/index.js +187 -0
  90. package/dist/slots/Footer/index.module.less +85 -0
  91. package/dist/slots/Header/Logo.d.ts +7 -0
  92. package/{es/antv → dist/slots}/Header/Logo.js +6 -2
  93. package/dist/slots/Header/LogoWhite.d.ts +7 -0
  94. package/dist/slots/Header/LogoWhite.js +19 -0
  95. package/dist/slots/Header/Navs.d.ts +17 -0
  96. package/dist/slots/Header/Navs.js +46 -0
  97. package/dist/slots/Header/Products/NavigatorBanner.d.ts +10 -0
  98. package/dist/slots/Header/Products/NavigatorBanner.js +34 -0
  99. package/dist/slots/Header/Products/NavigatorBanner.module.less +39 -0
  100. package/{es/antv → dist/slots/Header}/Products/Product.d.ts +3 -3
  101. package/{es/antv → dist/slots/Header}/Products/Product.js +11 -16
  102. package/{src/antv → dist/slots/Header}/Products/Product.module.less +10 -8
  103. package/{es/antv → dist/slots/Header}/Products/getProducts.d.ts +2 -7
  104. package/dist/slots/Header/Products/getProducts.js +67 -0
  105. package/dist/slots/Header/Products/index.d.ts +9 -0
  106. package/{es/antv → dist/slots/Header}/Products/index.js +15 -22
  107. package/dist/slots/Header/Search.d.ts +12 -0
  108. package/dist/slots/Header/Search.js +90 -0
  109. package/dist/slots/Header/Search.module.less +39 -0
  110. package/dist/slots/Header/index.d.ts +66 -0
  111. package/dist/slots/Header/index.js +379 -0
  112. package/dist/slots/Header/index.module.less +382 -0
  113. package/dist/slots/Header/utils.d.ts +1 -0
  114. package/dist/slots/Header/utils.js +26 -0
  115. package/dist/slots/Loading/index.d.ts +2 -0
  116. package/dist/slots/Loading/index.js +65 -0
  117. package/dist/slots/Loading/index.module.less +12 -0
  118. package/dist/slots/Loading.d.ts +5 -0
  119. package/dist/slots/Loading.js +8 -0
  120. package/dist/slots/ManualContent/NavigatorBanner.d.ts +9 -0
  121. package/dist/slots/ManualContent/NavigatorBanner.js +36 -0
  122. package/dist/slots/ManualContent/NavigatorBanner.module.less +39 -0
  123. package/dist/slots/ManualContent/ReadingTime.d.ts +3 -0
  124. package/dist/slots/ManualContent/ReadingTime.js +10 -0
  125. package/dist/slots/ManualContent/index.d.ts +9 -0
  126. package/dist/slots/ManualContent/index.js +321 -0
  127. package/dist/slots/ManualContent/index.module.less +656 -0
  128. package/dist/slots/TOC.d.ts +5 -0
  129. package/dist/slots/TOC.js +6 -0
  130. package/dist/slots/_.less +83 -0
  131. package/dist/slots/global.d.ts +1 -0
  132. package/dist/slots/global.js +7 -0
  133. package/dist/slots/hooks.d.ts +16 -0
  134. package/{es/antv → dist/slots}/hooks.js +60 -37
  135. package/dist/slots/utils.d.ts +20 -0
  136. package/dist/slots/utils.js +154 -0
  137. package/dist/types.d.ts +3 -0
  138. package/dist/types.js +1 -0
  139. package/dist/typings.d.ts +137 -0
  140. package/package.json +108 -47
  141. package/es/antv/404/index.d.ts +0 -2
  142. package/es/antv/Banner/Banner.module.less +0 -412
  143. package/es/antv/Banner/Notification.d.ts +0 -10
  144. package/es/antv/Banner/Notification.module.less +0 -108
  145. package/es/antv/Banner/index.d.ts +0 -25
  146. package/es/antv/Banner/index.js +0 -104
  147. package/es/antv/Cases/Cases.module.less +0 -203
  148. package/es/antv/Features/FeatureCard.module.less +0 -51
  149. package/es/antv/Features/Features.module.less +0 -169
  150. package/es/antv/Footer/Footer.module.less +0 -36
  151. package/es/antv/Footer/index.d.ts +0 -12
  152. package/es/antv/Footer/index.js +0 -237
  153. package/es/antv/Header/Logo.d.ts +0 -4
  154. package/es/antv/Products/Product.module.less +0 -146
  155. package/es/antv/Products/getNewProducts.d.ts +0 -24
  156. package/es/antv/Products/getNewProducts.js +0 -35
  157. package/es/antv/Products/getProducts.js +0 -460
  158. package/es/antv/Products/index.d.ts +0 -9
  159. package/es/antv/hooks.d.ts +0 -14
  160. package/es/antv/mixins.less +0 -21
  161. package/es/antv/utils.d.ts +0 -5
  162. package/es/antv/utils.js +0 -49
  163. package/es/builtins/API.d.ts +0 -3
  164. package/es/builtins/API.js +0 -37
  165. package/es/builtins/Alert.d.ts +0 -3
  166. package/es/builtins/Alert.js +0 -7
  167. package/es/builtins/Alert.less +0 -62
  168. package/es/builtins/Badge.d.ts +0 -3
  169. package/es/builtins/Badge.js +0 -7
  170. package/es/builtins/Badge.less +0 -31
  171. package/es/builtins/Example.d.ts +0 -5
  172. package/es/builtins/Example.less +0 -47
  173. package/es/builtins/Previewer.d.ts +0 -39
  174. package/es/builtins/Previewer.js +0 -225
  175. package/es/builtins/Previewer.less +0 -406
  176. package/es/builtins/SourceCode.d.ts +0 -10
  177. package/es/builtins/SourceCode.js +0 -70
  178. package/es/builtins/SourceCode.less +0 -103
  179. package/es/builtins/Table.d.ts +0 -4
  180. package/es/builtins/Table.less +0 -43
  181. package/es/builtins/Tree.d.ts +0 -4
  182. package/es/builtins/Tree.js +0 -213
  183. package/es/builtins/Tree.less +0 -159
  184. package/es/components/Dark.d.ts +0 -9
  185. package/es/components/Dark.js +0 -125
  186. package/es/components/Dark.less +0 -121
  187. package/es/components/LocaleSelect.d.ts +0 -6
  188. package/es/components/LocaleSelect.js +0 -53
  189. package/es/components/LocaleSelect.less +0 -59
  190. package/es/components/Navbar.d.ts +0 -10
  191. package/es/components/Navbar.js +0 -155
  192. package/es/components/Navbar.less +0 -180
  193. package/es/components/SearchBar.d.ts +0 -4
  194. package/es/components/SearchBar.js +0 -81
  195. package/es/components/SearchBar.less +0 -165
  196. package/es/components/SideMenu.d.ts +0 -10
  197. package/es/components/SideMenu.js +0 -99
  198. package/es/components/SideMenu.less +0 -379
  199. package/es/components/SlugList.d.ts +0 -7
  200. package/es/components/SlugList.js +0 -38
  201. package/es/components/SlugList.less +0 -18
  202. package/es/declaration.d.ts +0 -1
  203. package/es/layout.d.ts +0 -5
  204. package/es/layout.js +0 -276
  205. package/es/style/layout.less +0 -402
  206. package/es/style/markdown.less +0 -240
  207. package/es/style/variables.less +0 -37
  208. package/src/antv/404/index.tsx +0 -25
  209. package/src/antv/Banner/Notification.tsx +0 -45
  210. package/src/antv/Banner/index.tsx +0 -139
  211. package/src/antv/Cases/Cases.tsx +0 -116
  212. package/src/antv/Features/FeatureCard.tsx +0 -24
  213. package/src/antv/Features/index.tsx +0 -86
  214. package/src/antv/Footer/Footer.module.less +0 -36
  215. package/src/antv/Footer/index.tsx +0 -272
  216. package/src/antv/Header/Logo.tsx +0 -85
  217. package/src/antv/Products/Product.tsx +0 -80
  218. package/src/antv/Products/getNewProducts.tsx +0 -53
  219. package/src/antv/Products/getProducts.tsx +0 -626
  220. package/src/antv/Products/index.tsx +0 -70
  221. package/src/antv/hooks.ts +0 -87
  222. package/src/antv/mixins.less +0 -21
  223. package/src/antv/utils.ts +0 -44
  224. package/src/builtins/API.tsx +0 -57
  225. package/src/builtins/Alert.less +0 -62
  226. package/src/builtins/Alert.tsx +0 -4
  227. package/src/builtins/Badge.less +0 -31
  228. package/src/builtins/Badge.tsx +0 -4
  229. package/src/builtins/Example.less +0 -47
  230. package/src/builtins/Example.tsx +0 -34
  231. package/src/builtins/Previewer.less +0 -406
  232. package/src/builtins/Previewer.tsx +0 -264
  233. package/src/builtins/SourceCode.less +0 -103
  234. package/src/builtins/SourceCode.tsx +0 -55
  235. package/src/builtins/Table.less +0 -43
  236. package/src/builtins/Table.tsx +0 -42
  237. package/src/builtins/Tree.less +0 -159
  238. package/src/builtins/Tree.tsx +0 -130
  239. package/src/components/Dark.less +0 -121
  240. package/src/components/Dark.tsx +0 -78
  241. package/src/components/LocaleSelect.less +0 -59
  242. package/src/components/LocaleSelect.tsx +0 -53
  243. package/src/components/Navbar.less +0 -180
  244. package/src/components/Navbar.tsx +0 -152
  245. package/src/components/SearchBar.less +0 -165
  246. package/src/components/SearchBar.tsx +0 -68
  247. package/src/components/SideMenu.less +0 -379
  248. package/src/components/SideMenu.tsx +0 -148
  249. package/src/components/SlugList.less +0 -18
  250. package/src/components/SlugList.tsx +0 -20
  251. package/src/declaration.d.ts +0 -1
  252. package/src/layout.tsx +0 -225
  253. package/src/style/layout.less +0 -402
  254. package/src/style/markdown.less +0 -240
  255. package/src/style/variables.less +0 -37
  256. package/src/test/SearchBar.test.ts +0 -32
  257. package/src/test/Table.test.tsx +0 -41
  258. package/src/test/index.test.tsx +0 -377
@@ -0,0 +1,157 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+
9
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+
11
+ 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); }
12
+
13
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
+
15
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
16
+
17
+ 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; }
18
+
19
+ import path from 'path'; // @ts-ignore
20
+
21
+ import { transform } from '@babel/standalone';
22
+ import indentString from 'indent-string';
23
+ export function replaceFetchUrl(sourceCode) {
24
+ var dataFileMatch = sourceCode.match(/fetch\('(.*)'\)/);
25
+
26
+ if (dataFileMatch && dataFileMatch.length > 0 && !dataFileMatch[1].startsWith('http')) {
27
+ return sourceCode.replace(dataFileMatch[1], path.join(location.origin || '', location.pathname || '', '..', dataFileMatch[1]));
28
+ }
29
+
30
+ return sourceCode;
31
+ }
32
+ /**
33
+ * 通过代码提取代码片段的 pkg 依赖
34
+ * @param sourceCode
35
+ */
36
+
37
+ export function extractImportDeps(sourceCode) {
38
+ var requireMatches = sourceCode.match(/require\(['"](.*)['"]\)/g) || [];
39
+ var importMatches = sourceCode.match(/from\s+['"](.*)['"]/g) || [];
40
+ var deps = {};
41
+ [].concat(_toConsumableArray(requireMatches), _toConsumableArray(importMatches)).forEach(function (match) {
42
+ var requireMatch = match.match(/require\(['"](.*)['"]\)/);
43
+
44
+ if (requireMatch && requireMatch[1]) {
45
+ deps[requireMatch[1]] = 'latest';
46
+ }
47
+
48
+ var importMatch = match.match(/from\s+['"](.*)['"]/);
49
+
50
+ if (importMatch && importMatch[1]) {
51
+ deps[importMatch[1]] = 'latest';
52
+ }
53
+ });
54
+ return deps;
55
+ }
56
+ export function getCodeSandboxConfig(title, sourceCode, fileExtension, deps, devDependencies, playground) {
57
+ var _files;
58
+
59
+ return {
60
+ files: (_files = {
61
+ 'package.json': {
62
+ content: {
63
+ main: "index.".concat(fileExtension),
64
+ dependencies: deps,
65
+ devDependencies: devDependencies
66
+ }
67
+ }
68
+ }, _defineProperty(_files, "index.".concat(fileExtension), {
69
+ content: replaceFetchUrl(sourceCode)
70
+ }), _defineProperty(_files, 'index.html', {
71
+ content: playground.container || '<div id="container" />'
72
+ }), _files)
73
+ };
74
+ }
75
+ export function getRiddleConfig(title, sourceCode, fileExtension, deps, devDependencies, playground) {
76
+ return {
77
+ title: title,
78
+ js: sourceCode,
79
+ html: playground.container || '<div id="container" />',
80
+ // 预填的 package.json 代码
81
+ json: JSON.stringify(_objectSpread({
82
+ dependencies: deps,
83
+ devDependencies: devDependencies
84
+ }, playground.json))
85
+ };
86
+ }
87
+ export function getStackblitzConfig(title, sourceCode, fileExtension, deps, devDependencies, playground) {
88
+ var _files2;
89
+
90
+ return {
91
+ title: title || '',
92
+ description: '',
93
+ template: 'create-react-app',
94
+ dependencies: deps,
95
+ files: (_files2 = {}, _defineProperty(_files2, "index.".concat(fileExtension.startsWith('ts') ? 'ts' : 'js'), sourceCode), _defineProperty(_files2, 'index.html', playground.container || '<div id="container" />'), _files2)
96
+ };
97
+ }
98
+ export function getHtmlCodeTemplate(title, sourceCode, fileExtension, deps, devDependencies, playground) {
99
+ var _playground$htmlCodeT = playground.htmlCodeTemplate,
100
+ htmlCodeTemplate = _playground$htmlCodeT === void 0 ? '' : _playground$htmlCodeT,
101
+ _playground$container = playground.container,
102
+ container = _playground$container === void 0 ? '' : _playground$container;
103
+ var insertCssMatcher = /insertCss\(`\s*(.*)\s*`\);/;
104
+ var code = replaceFetchUrl(sourceCode).replace(/import\s+.*\s+from\s+['"].*['"];?/g, '').replace(insertCssMatcher, '').replace(/^\s+|\s+$/g, '');
105
+ var result = htmlCodeTemplate.replace('{{code}}', indentString(code, 4)).replace('{{title}}', title || 'example');
106
+ var customStyles = sourceCode.match(insertCssMatcher);
107
+
108
+ if (customStyles && customStyles[1]) {
109
+ result = result.replace('</head>', " <style>\n".concat(indentString(customStyles[1], 4), "\n </style>\n </head>"));
110
+ }
111
+
112
+ if (container) {
113
+ result = result.replace('<body>', "<body>\n".concat(indentString(container, 4)));
114
+ }
115
+
116
+ return result;
117
+ }
118
+ export function replaceInsertCss(str, lang) {
119
+ var comment = lang === 'zh' ? "// \u6211\u4EEC\u7528 insert-css \u6F14\u793A\u5F15\u5165\u81EA\u5B9A\u4E49\u6837\u5F0F\n// \u63A8\u8350\u5C06\u6837\u5F0F\u6DFB\u52A0\u5230\u81EA\u5DF1\u7684\u6837\u5F0F\u6587\u4EF6\u4E2D\n// \u82E5\u62F7\u8D1D\u5B98\u65B9\u4EE3\u7801\uFF0C\u522B\u5FD8\u4E86 npm install insert-css\ninsertCss(" : "// We use 'insert-css' to insert custom styles\n// It is recommended to add the style to your own style sheet files\n// If you want to copy the code directly, please remember to install the npm package 'insert-css\ninsertCss("; // 统一增加对 insert-css 的使用注释
120
+
121
+ return str.replace(/^insertCss\(/gm, comment);
122
+ }
123
+ /**
124
+ * 执行代码
125
+ * @param code 运行的代码
126
+ * @param playgroundScriptContainer 运行的节点
127
+ * @param container 代码中 container dom
128
+ * @param replaceId rid
129
+ * @param cb 回调错误
130
+ */
131
+
132
+ export function execute(code, playgroundScriptContainer, container) {
133
+ var replaceId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'container';
134
+ var node = document.getElementById(playgroundScriptContainer);
135
+ var script = document.createElement('script'); // replace container id in case of multi demos in document
136
+
137
+ var newCode = code.replace(/'container'|"container"/, "'".concat(replaceId, "'"));
138
+ script.innerHTML = "\n// Can only have one anonymous define call per script file\n// \u548C monaco loader \u52A0\u8F7D\u51B2\u7A81\nvar __runnerDefine = window['define'];\nwindow['define'] = null;\ntry {\n ".concat(newCode, "\n\n window.__reportErrorInPlayground && window.__reportErrorInPlayground(null);\n} catch(e) {\n window.__reportErrorInPlayground && window.__reportErrorInPlayground(e);\n} finally {\n window['define'] = __runnerDefine;\n}\n "); // 追加图表容器
139
+
140
+ node.innerHTML = container || "<div id=".concat(replaceId, " />"); // 运行 script
141
+
142
+ node.appendChild(script);
143
+ }
144
+ /**
145
+ * 编译代码
146
+ */
147
+
148
+ export function compile(value, relativePath) {
149
+ var _transform = transform(value, {
150
+ filename: relativePath,
151
+ presets: ['react', 'typescript', 'es2015', 'stage-3'],
152
+ plugins: ['transform-modules-umd']
153
+ }),
154
+ code = _transform.code;
155
+
156
+ return code;
157
+ }
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ export declare type CodeHeaderProps = {
3
+ /**
4
+ * 代码的标题
5
+ */
6
+ title: string;
7
+ /**
8
+ * 代码的路径
9
+ */
10
+ relativePath: string;
11
+ /**
12
+ * GitHub 的地址,用于拼接最后 GitHub 编辑地址
13
+ */
14
+ githubUrl: string;
15
+ };
16
+ /**
17
+ * 组件的 header
18
+ */
19
+ export declare const CodeHeader: React.FC<any>;
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { PageHeader, Tooltip, Space, Divider } from 'antd';
3
+ import { EditOutlined } from '@ant-design/icons';
4
+ import { useT } from "../hooks";
5
+ import { getGithubSourceUrl } from "../utils";
6
+ import styles from "./CodeHeader.module.less";
7
+
8
+ /**
9
+ * 组件的 header
10
+ */
11
+ export var CodeHeader = function CodeHeader(_ref) {
12
+ var title = _ref.title,
13
+ relativePath = _ref.relativePath,
14
+ githubUrl = _ref.githubUrl;
15
+ return /*#__PURE__*/React.createElement(PageHeader, {
16
+ ghost: false,
17
+ title: title,
18
+ subTitle: /*#__PURE__*/React.createElement(Tooltip, {
19
+ title: useT('在 GitHub 上编辑')
20
+ }, /*#__PURE__*/React.createElement("a", {
21
+ href: getGithubSourceUrl(githubUrl, relativePath, 'examples'),
22
+ target: "_blank",
23
+ rel: "noopener noreferrer",
24
+ className: styles.editOnGtiHubButton
25
+ }, /*#__PURE__*/React.createElement(EditOutlined, null))),
26
+ extra: /*#__PURE__*/React.createElement(Space, {
27
+ split: /*#__PURE__*/React.createElement(Divider, {
28
+ type: "vertical"
29
+ })
30
+ })
31
+ });
32
+ };
File without changes
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ export declare type CodePreviewProps = {
3
+ /**
4
+ * 预览页面头部组件,用于显示 demo 名称,一些操作栏等
5
+ */
6
+ header?: React.ReactElement;
7
+ /**
8
+ * 需要展示的错误信息
9
+ */
10
+ error: any;
11
+ };
12
+ /**
13
+ * DEMO 预览页面的预览,主要包含有:
14
+ * 1. 一些 header 菜单
15
+ * 2. 错误预览
16
+ */
17
+ export declare const CodePreview: React.FC<CodePreviewProps>;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { Result } from 'antd';
3
+ import { useT } from "../hooks";
4
+ import styles from "./index.module.less";
5
+
6
+ /**
7
+ * DEMO 预览页面的预览,主要包含有:
8
+ * 1. 一些 header 菜单
9
+ * 2. 错误预览
10
+ */
11
+ export var CodePreview = function CodePreview(_ref) {
12
+ var header = _ref.header,
13
+ error = _ref.error;
14
+ return /*#__PURE__*/React.createElement("div", {
15
+ className: styles.preview
16
+ }, /*#__PURE__*/React.createElement("div", {
17
+ className: styles.header
18
+ }, header), /*#__PURE__*/React.createElement("div", {
19
+ className: styles.content
20
+ }, /*#__PURE__*/React.createElement("div", {
21
+ id: "playgroundScriptContainer",
22
+ className: styles.playgroundScriptContainer
23
+ }), error ? /*#__PURE__*/React.createElement(Result, {
24
+ className: styles.result,
25
+ status: "error",
26
+ title: useT('演示代码报错,请检查'),
27
+ subTitle: /*#__PURE__*/React.createElement("pre", null, error && error.message)
28
+ }) : null));
29
+ };
@@ -0,0 +1,42 @@
1
+ .preview {
2
+ width: 100%;
3
+ height: 100%;
4
+ position: relative;
5
+
6
+ padding: 16px;
7
+ overflow: auto;
8
+
9
+ display: flex;
10
+ flex-direction: column;
11
+
12
+ .header {
13
+ flex: 0
14
+ }
15
+
16
+ .content {
17
+ width: 100%;
18
+ height: 100%;
19
+ position: relative;
20
+
21
+ .playgroundScriptContainer {
22
+ flex: 1;
23
+ position: relative;
24
+ :global(#container) {
25
+ width: 100%;
26
+ height: 100%;
27
+ position: relative;
28
+ }
29
+ }
30
+
31
+ // 盖在 DEMO 运行的 container 上
32
+ .result {
33
+ width: 100%;
34
+ height: 100%;
35
+ position: absolute;
36
+ top: 0;
37
+ left: 0;
38
+
39
+ background: #fff;
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { ExamplesPage } from '../../typings';
3
+ declare type CodeRunnerProps = {
4
+ topic: string;
5
+ example: string;
6
+ demo: string;
7
+ exampleTopics: ExamplesPage.ExampleTopic[];
8
+ notFound?: React.Element;
9
+ };
10
+ /**
11
+ * 代码编辑器 + 代码预览区域
12
+ */
13
+ export declare const CodeRunner: React.FC<CodeRunnerProps>;
14
+ export {};
@@ -0,0 +1,76 @@
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 } from 'react';
14
+ import { useSiteData, useLocale } from 'dumi';
15
+ import { noop } from 'lodash-es';
16
+ import SplitPane from 'react-split-pane';
17
+ import { CodeEditor } from "../CodeEditor";
18
+ import { CodePreview } from "../CodePreview";
19
+ import { CodeHeader } from "../CodePreview/CodeHeader";
20
+ import { getDemoInfo } from "./utils";
21
+ import { NotFound } from "../404";
22
+
23
+ /**
24
+ * 代码编辑器 + 代码预览区域
25
+ */
26
+ export var CodeRunner = function CodeRunner(_ref) {
27
+ var exampleTopics = _ref.exampleTopics,
28
+ topic = _ref.topic,
29
+ example = _ref.example,
30
+ demo = _ref.demo,
31
+ _ref$notFound = _ref.notFound,
32
+ notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound;
33
+ var demoInfo = getDemoInfo(exampleTopics, topic, example, demo); // 找不到,啥也别干了,404 页面
34
+
35
+ if (!demoInfo) return notFound;
36
+ var title = demoInfo.title,
37
+ source = demoInfo.source,
38
+ relativePath = demoInfo.relativePath;
39
+
40
+ var _useSiteData = useSiteData(),
41
+ themeConfig = _useSiteData.themeConfig;
42
+
43
+ var githubUrl = themeConfig.githubUrl;
44
+
45
+ var _useState = useState(),
46
+ _useState2 = _slicedToArray(_useState, 2),
47
+ error = _useState2[0],
48
+ setError = _useState2[1];
49
+
50
+ var _useState3 = useState(false),
51
+ _useState4 = _slicedToArray(_useState3, 2),
52
+ isFullScreen = _useState4[0],
53
+ setFullscreen = _useState4[1];
54
+
55
+ var locale = useLocale();
56
+ var header = /*#__PURE__*/React.createElement(CodeHeader, {
57
+ title: title[locale.id],
58
+ relativePath: relativePath,
59
+ githubUrl: githubUrl
60
+ });
61
+ return /*#__PURE__*/React.createElement(SplitPane, {
62
+ split: "vertical",
63
+ defaultSize: "50%",
64
+ minSize: 100
65
+ }, /*#__PURE__*/React.createElement(CodePreview, {
66
+ error: error,
67
+ header: header
68
+ }), /*#__PURE__*/React.createElement(CodeEditor, {
69
+ source: source,
70
+ relativePath: relativePath,
71
+ onError: setError,
72
+ onFullscreen: setFullscreen,
73
+ onDestroy: noop,
74
+ onReady: noop
75
+ }));
76
+ };
File without changes
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 将数据结构转化成 map,便于后续检索的速度
3
+ * @param exampleTopics
4
+ * @returns
5
+ */
6
+ export declare function getExampleTopicMap(exampleTopics: ExamplesPage.ExampleTopic[]): Map<string, ExamplesPage.Demo>;
7
+ /**
8
+ * 从 Context 信息中,获取到 Example 相关的信息,用于页面渲染
9
+ */
10
+ export declare function getDemoInfo(exampleTopics: ExamplesPage.ExampleTopic[], topic: string, example: string, demo: string): ExamplesPage.Demo | undefined;
@@ -0,0 +1,36 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ import { map } from 'lodash-es';
8
+ /**
9
+ * 将数据结构转化成 map,便于后续检索的速度
10
+ * @param exampleTopics
11
+ * @returns
12
+ */
13
+
14
+ export function getExampleTopicMap(exampleTopics) {
15
+ var exampleTopicMap = new Map();
16
+ map(exampleTopics, function (topic) {
17
+ map(topic.examples, function (example) {
18
+ map(example.demos, function (demo) {
19
+ exampleTopicMap.set("".concat(topic.id, "-").concat(example.id, "-").concat(demo.id), _objectSpread(_objectSpread({}, demo), {}, {
20
+ relativePath: "".concat(topic.id, "/").concat(example.id, "/demo/").concat(demo.filename),
21
+ targetExample: example,
22
+ targetTopic: topic
23
+ }));
24
+ });
25
+ });
26
+ });
27
+ return exampleTopicMap;
28
+ }
29
+ /**
30
+ * 从 Context 信息中,获取到 Example 相关的信息,用于页面渲染
31
+ */
32
+
33
+ export function getDemoInfo(exampleTopics, topic, example, demo) {
34
+ var m = getExampleTopicMap(exampleTopics);
35
+ return m.get("".concat(topic, "-").concat(example, "-").concat(demo));
36
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ declare type Company = {
3
+ name: string;
4
+ img: string;
5
+ };
6
+ interface CompaniesProps {
7
+ title: string;
8
+ companies: Company[];
9
+ className?: string;
10
+ style?: React.CSSProperties;
11
+ }
12
+ export declare const Companies: React.FC<CompaniesProps>;
13
+ export {};
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { Row, Col } from 'antd';
3
+ import cx from 'classnames';
4
+ import styles from "./index.module.less";
5
+ export var Companies = function Companies(_ref) {
6
+ var title = _ref.title,
7
+ _ref$companies = _ref.companies,
8
+ companies = _ref$companies === void 0 ? [] : _ref$companies,
9
+ className = _ref.className,
10
+ style = _ref.style;
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ className: cx(styles.wrapper, className),
13
+ style: style
14
+ }, /*#__PURE__*/React.createElement("div", {
15
+ key: "content",
16
+ className: styles.content
17
+ }, /*#__PURE__*/React.createElement("p", {
18
+ key: "title",
19
+ className: styles.title
20
+ }, title), /*#__PURE__*/React.createElement("div", {
21
+ key: "slicer",
22
+ className: styles.slicer
23
+ }), /*#__PURE__*/React.createElement("div", {
24
+ key: "companies-container",
25
+ className: styles.companiesContainer
26
+ }, /*#__PURE__*/React.createElement(Row, {
27
+ key: "companies",
28
+ gutter: [{
29
+ xs: 77,
30
+ sm: 77,
31
+ md: 50,
32
+ lg: 124
33
+ }, 10],
34
+ wrap: true,
35
+ className: styles.companies
36
+ }, companies.map(function (company) {
37
+ return /*#__PURE__*/React.createElement(Col, {
38
+ key: company.name,
39
+ className: styles.company,
40
+ md: 6,
41
+ sm: 8,
42
+ xs: 12
43
+ }, /*#__PURE__*/React.createElement("img", {
44
+ className: styles.companyimg,
45
+ src: company.img,
46
+ alt: company.name
47
+ }));
48
+ })))));
49
+ };
@@ -0,0 +1,82 @@
1
+ @import '../_.less';
2
+
3
+ .wrapper {
4
+ display: flex;
5
+ margin: auto;
6
+ position: relative;
7
+ flex-direction: column;
8
+ padding: 0;
9
+ height: auto;
10
+ overflow-x: hidden;
11
+
12
+ .content {
13
+ height: 100%;
14
+ margin-bottom: 5%;
15
+ position: relative;
16
+ .container1440;
17
+ padding-left: 4.5%;
18
+ }
19
+
20
+ .title {
21
+ font-size: 2.714em;
22
+ font-weight: 500;
23
+ margin: 118px 0 0 0;
24
+ position: relative;
25
+ height: min-content;
26
+ color: rgba(0, 0, 0, 1);
27
+ }
28
+
29
+ .slicer {
30
+ width: 32px;
31
+ height: 6px;
32
+ background: linear-gradient(145deg,
33
+ fade(@primary-color, 70%),
34
+ shade(@primary-color, 20%));
35
+ margin-top: 64px;
36
+ }
37
+
38
+ .companiesContainer {
39
+ position: relative;
40
+ margin: auto;
41
+ margin-top: 52px;
42
+
43
+ .company {
44
+ margin-bottom: 20px;
45
+
46
+ .companyimg {
47
+ width: 100%;
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ @media (max-width: 768px) {
54
+ .wrapper {
55
+ .title {
56
+ font-size: 1.9rem;
57
+ margin: 98px 0 0 0;
58
+ }
59
+
60
+ .slicer {
61
+ width: 25px;
62
+ height: 6px;
63
+ margin: 44px 0 44px 0;
64
+ }
65
+
66
+ .content {
67
+ margin-left: 4.27%;
68
+ width: 91.64%;
69
+ max-width: 91.64%;
70
+ }
71
+
72
+ .companiesContainer {
73
+ margin-top: 50px;
74
+
75
+ .company {
76
+ .companyimg {
77
+ width: 100%;
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface NewsProps {
3
+ index?: number;
4
+ type: IC;
5
+ title: IC;
6
+ date: string;
7
+ link: string;
8
+ }
9
+ export declare const News: React.FC<NewsProps>;
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
- import { Link } from 'react-router-dom'; // @ts-ignore
3
-
4
- import styles from './Notification.module.less';
2
+ import { Link } from 'dumi';
3
+ import { ic } from "../hooks";
4
+ import styles from "./News.module.less";
5
5
  var numberImages = ['https://gw.alipayobjects.com/zos/antfincdn/IqREAm36K7/1.png', 'https://gw.alipayobjects.com/zos/antfincdn/3fG1Iqjfnz/2.png'];
6
-
7
- var Notification = function Notification(_ref) {
6
+ export var News = function News(_ref) {
8
7
  var _ref$index = _ref.index,
9
8
  index = _ref$index === void 0 ? 0 : _ref$index,
10
9
  type = _ref.type,
@@ -22,7 +21,7 @@ var Notification = function Notification(_ref) {
22
21
  className: styles.content
23
22
  }, /*#__PURE__*/React.createElement("p", {
24
23
  className: styles.description
25
- }, type, " \u2027 ", title), /*#__PURE__*/React.createElement("p", {
24
+ }, ic(type), " \u2027 ", ic(title)), /*#__PURE__*/React.createElement("p", {
26
25
  className: styles.date
27
26
  }, date)));
28
27
 
@@ -31,14 +30,12 @@ var Notification = function Notification(_ref) {
31
30
  href: link,
32
31
  target: "_blank",
33
32
  rel: "noopener noreferrer",
34
- className: styles.notification
33
+ className: styles.news
35
34
  }, children);
36
35
  }
37
36
 
38
37
  return /*#__PURE__*/React.createElement(Link, {
39
38
  to: link,
40
- className: styles.notification
39
+ className: styles.news
41
40
  }, children);
42
- };
43
-
44
- export default Notification;
41
+ };