@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,6 @@
1
+ import React from 'react';
2
+ /**
3
+ * 具体单个案例的页面
4
+ */
5
+ declare const Example: React.FC;
6
+ export default Example;
@@ -0,0 +1,139 @@
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+
9
+ 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."); }
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 _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; }
14
+
15
+ 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; }
16
+
17
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
+
19
+ import React, { useContext, useEffect, useState } from 'react';
20
+ import { useParams, useLocation, useNavigate } from 'react-router-dom';
21
+ import { Layout } from 'antd';
22
+ import { useLocale } from 'dumi';
23
+ import { Header } from "../../slots/Header";
24
+ import { ExampleSider } from "../../slots/ExampleSider";
25
+ import { CodeRunner } from "../../slots/CodeRunner";
26
+ import { getDemoInfo } from "../../slots/CodeRunner/utils";
27
+ import { ThemeAntVContext } from "../../context";
28
+ import styles from "./index.module.less";
29
+ var Sider = Layout.Sider,
30
+ Content = Layout.Content;
31
+
32
+ /**
33
+ * 具体单个案例的页面
34
+ */
35
+ var Example = function Example() {
36
+ var _useLocation = useLocation(),
37
+ hash = _useLocation.hash;
38
+
39
+ var nav = useNavigate();
40
+
41
+ var _useParams = useParams(),
42
+ _useParams$language = _useParams.language,
43
+ language = _useParams$language === void 0 ? 'zh' : _useParams$language,
44
+ topic = _useParams.topic,
45
+ example = _useParams.example;
46
+ /** 示例页面的元数据信息 */
47
+
48
+
49
+ var metaData = useContext(ThemeAntVContext);
50
+ var locale = useLocale();
51
+ var exampleTopics = metaData.meta.exampleTopics;
52
+ var demo = hash.slice(1);
53
+
54
+ var _useState = useState(),
55
+ _useState2 = _slicedToArray(_useState, 2),
56
+ currentDemo = _useState2[0],
57
+ setCurrentDemo = _useState2[1];
58
+
59
+ useEffect(function () {
60
+ if (topic && example && demo) {
61
+ var targetDemoInfo = getDemoInfo(exampleTopics, topic, example, demo);
62
+ setCurrentDemo(targetDemoInfo);
63
+ }
64
+ }, [topic, example, hash]); // 提取出来获取 唯一value值的 方法
65
+
66
+ var getPath = function getPath(item) {
67
+ var _item$relativePath;
68
+
69
+ if (!item) {// @todo 怀策
70
+ // debugger
71
+ }
72
+
73
+ var demoSlug = (_item$relativePath = item.relativePath) === null || _item$relativePath === void 0 ? void 0 : _item$relativePath.replace(/\/demo\/(.*)\..*/, function (_, filename) {
74
+ return "#".concat(filename);
75
+ });
76
+ return "/".concat(locale.id, "/examples/").concat(demoSlug);
77
+ }; // 一级菜单,二级菜单 数据 treeData + 二级菜单,示例 数据 result 写成一个 一级,二级,示例的三层树结构 数据
78
+
79
+
80
+ var transformNode = function transformNode(data, result) {
81
+ return data.map(function (item) {
82
+ var _result$find;
83
+
84
+ if (item.children && !item.node) {
85
+ return _objectSpread(_objectSpread({}, item), {}, {
86
+ children: transformNode(item.children, result)
87
+ });
88
+ }
89
+
90
+ var _item$node = item.node,
91
+ frontmatter = _item$node.frontmatter,
92
+ fields = _item$node.fields;
93
+ return _objectSpread(_objectSpread({}, frontmatter), {}, {
94
+ // 提前给二级菜单的key值加入 特殊值 好辨别
95
+ value: "secondaryKey-".concat(fields === null || fields === void 0 ? void 0 : fields.slug),
96
+ children: (_result$find = result.find(function (_ref) {
97
+ var k = _ref.title;
98
+ return k === frontmatter.title;
99
+ })) === null || _result$find === void 0 ? void 0 : _result$find.children
100
+ });
101
+ });
102
+ };
103
+
104
+ return /*#__PURE__*/React.createElement("div", {
105
+ className: styles.example
106
+ }, /*#__PURE__*/React.createElement(Header, {
107
+ isHomePage: false
108
+ }), /*#__PURE__*/React.createElement(Layout, {
109
+ className: styles.container
110
+ }, /*#__PURE__*/React.createElement(Sider, {
111
+ collapsedWidth: 0,
112
+ width: 250,
113
+ trigger: null,
114
+ collapsible: true,
115
+ className: styles.sider,
116
+ theme: "light"
117
+ }, currentDemo && /*#__PURE__*/React.createElement(ExampleSider, {
118
+ showExampleDemoTitle: true,
119
+ currentDemo: currentDemo,
120
+ onDemoClicked: function onDemoClicked(example) {
121
+ var demoId = example.id,
122
+ targetExample = example.targetExample,
123
+ targetTopic = example.targetTopic; // eg: /zh/examples/case/area/#area1
124
+
125
+ var newURL = "/".concat(locale.id, "/examples/").concat(targetTopic === null || targetTopic === void 0 ? void 0 : targetTopic.id, "/").concat(targetExample === null || targetExample === void 0 ? void 0 : targetExample.id, "/#").concat(demoId);
126
+ nav(newURL);
127
+ },
128
+ exampleTopics: exampleTopics
129
+ })), /*#__PURE__*/React.createElement(Content, {
130
+ className: styles.content
131
+ }, topic && example && /*#__PURE__*/React.createElement(CodeRunner, {
132
+ exampleTopics: exampleTopics,
133
+ topic: topic,
134
+ example: example,
135
+ demo: demo
136
+ }))));
137
+ };
138
+
139
+ export default Example;
@@ -0,0 +1,40 @@
1
+ @import 'antd/es/style/themes/default.less';
2
+ @import '../../slots/_.less';
3
+
4
+ :global(#root) {
5
+ width: 100%;
6
+ height: 100%;
7
+ }
8
+
9
+ .example {
10
+ width: 100%;
11
+ height: 100%;
12
+ display: flex;
13
+ flex-direction: column;
14
+
15
+ .container {
16
+ flex: 1;
17
+ background-color: #fff;
18
+
19
+ .sider {
20
+ height: 100%;
21
+
22
+ .exampleList {
23
+
24
+ }
25
+ }
26
+
27
+ .content {
28
+ position: relative;
29
+ height: 100%;
30
+
31
+ .left {
32
+ height: 100%;
33
+ }
34
+
35
+ .right {
36
+ height: 100%;
37
+ }
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { AnnouncementProps } from '../../types';
3
+ /**
4
+ * 通用公告组件,根据 bannerId 来更新 localStorage
5
+ */
6
+ export declare const Announcement: React.FC<AnnouncementProps>;
@@ -0,0 +1,60 @@
1
+ var _excluded = ["message", "bannerId", "localStorageId"];
2
+
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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 _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
+
9
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
+
11
+ import React, { useEffect } from 'react';
12
+ import { Alert } from 'antd';
13
+ import { get } from 'lodash-es';
14
+ import { NotificationFilled } from '@ant-design/icons';
15
+ import cx from 'classnames';
16
+ import styles from "./index.module.less";
17
+ /**
18
+ * 通用公告组件,根据 bannerId 来更新 localStorage
19
+ */
20
+
21
+ export var Announcement = function Announcement(props) {
22
+ var message = props.message,
23
+ bannerId = props.bannerId,
24
+ localStorageId = props.localStorageId,
25
+ alertProps = _objectWithoutProperties(props, _excluded);
26
+
27
+ var isBrowser = typeof window !== 'undefined';
28
+ /** 公告 id 更新,更新下本地缓存 */
29
+
30
+ useEffect(function () {
31
+ try {
32
+ var item = isBrowser && localStorage.getItem(localStorageId) || '{}';
33
+
34
+ if (get(JSON.parse(item), [bannerId]) !== false && isBrowser) {
35
+ localStorage.setItem(localStorageId, JSON.stringify(_defineProperty({}, bannerId, true)));
36
+ }
37
+ } catch (e) {
38
+ console.error(e); // eslint-disable-line no-console
39
+ }
40
+ }, [bannerId]);
41
+ return get(JSON.parse(isBrowser && localStorage.getItem(localStorageId) || '{}'), [bannerId]) ? /*#__PURE__*/React.createElement(Alert, _extends({
42
+ message: message,
43
+ type: "info",
44
+ showIcon: true,
45
+ icon: /*#__PURE__*/React.createElement(NotificationFilled, {
46
+ style: {
47
+ height: '16px',
48
+ color: '#4776E8'
49
+ }
50
+ }),
51
+ closable: true,
52
+ className: cx('banner-announcement', styles.bannerAnnouncement),
53
+ onClose: function onClose() {
54
+ // 关闭公告
55
+ if (isBrowser) {
56
+ localStorage.setItem(localStorageId, JSON.stringify(_defineProperty({}, bannerId, false)));
57
+ }
58
+ }
59
+ }, alertProps)) : null;
60
+ };
@@ -0,0 +1,9 @@
1
+ .bannerAnnouncement {
2
+ background: #e6f7ff;
3
+ border-color: rgba(71, 118, 232, 0.65);
4
+ color: #4776e8;
5
+
6
+ a {
7
+ color: #4776e8 !important;
8
+ }
9
+ }
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const Article: React.FC<any>;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { Layout } from 'antd';
3
+ import styles from "./index.module.less";
4
+ export var Article = function Article(props) {
5
+ return /*#__PURE__*/React.createElement(Layout.Content, {
6
+ className: styles.article
7
+ }, /*#__PURE__*/React.createElement("article", props));
8
+ };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { LeftMenuProps } from '../../../../types';
3
+ /**
4
+ * LeftMenu
5
+ *
6
+ * @param {LeftMenuProps} props 相关参数,详见类型定义
7
+ * @returns {React.FC} React.FC
8
+ * @author YuZhanglong <loveyzl1123@gmail.com>
9
+ */
10
+ export declare const LeftMenu: React.FC<LeftMenuProps>;
@@ -0,0 +1,74 @@
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 { Anchor, Menu } from 'antd';
15
+ import { useLocale } from 'dumi';
16
+ import { createFromIconfontCN } from '@ant-design/icons';
17
+ import styles from "../../../../index.module.less";
18
+ var MenuIcon = createFromIconfontCN({
19
+ scriptUrl: '//at.alicdn.com/t/font_470089_1lnym745udm.js' // generated by iconfont.cn
20
+
21
+ });
22
+ /**
23
+ * LeftMenu
24
+ *
25
+ * @param {LeftMenuProps} props 相关参数,详见类型定义
26
+ * @returns {React.FC} React.FC
27
+ * @author YuZhanglong <loveyzl1123@gmail.com>
28
+ */
29
+
30
+ export var LeftMenu = function LeftMenu(props) {
31
+ var exampleTopics = props.exampleTopics;
32
+
33
+ var _useState = useState([]),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ selectedKeys = _useState2[0],
36
+ setSelectedKeys = _useState2[1];
37
+
38
+ var locale = useLocale();
39
+
40
+ var _useState3 = useState([]),
41
+ _useState4 = _slicedToArray(_useState3, 2),
42
+ openKeys = _useState4[0],
43
+ setOpenKeys = _useState4[1];
44
+
45
+ return /*#__PURE__*/React.createElement(Anchor, {
46
+ className: styles.galleryAnchor
47
+ }, /*#__PURE__*/React.createElement(Menu, {
48
+ mode: "inline",
49
+ selectedKeys: selectedKeys,
50
+ style: {
51
+ height: '100%'
52
+ },
53
+ openKeys: openKeys,
54
+ onOpenChange: function onOpenChange(currentOpenKeys) {
55
+ return setOpenKeys(currentOpenKeys);
56
+ },
57
+ forceSubMenuRender: true
58
+ }, exampleTopics.map(function (topic) {
59
+ return /*#__PURE__*/React.createElement(Menu.SubMenu, {
60
+ key: topic.id,
61
+ title: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(MenuIcon, {
62
+ className: styles.menuIcon,
63
+ type: "icon-".concat(topic.icon)
64
+ }), /*#__PURE__*/React.createElement("span", null, topic.title[locale.id]))
65
+ }, topic.examples.map(function (example) {
66
+ return /*#__PURE__*/React.createElement(Menu.Item, {
67
+ key: example.id
68
+ }, /*#__PURE__*/React.createElement(Anchor.Link, {
69
+ href: "#category-".concat(example.id.replace(/\s/g, '')),
70
+ title: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", null, example.title[locale.id]))
71
+ }));
72
+ }));
73
+ })));
74
+ };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { LeftMenuProps } from '../../types';
3
+ /**
4
+ * Examples 左侧 LeftMenu
5
+ *
6
+ * @param {LeftMenuProps} props 相关参数,详见类型定义
7
+ * @returns {React.FC} React.FC
8
+ */
9
+ export declare const ExampleTopicMenu: React.FC<LeftMenuProps>;
@@ -10,47 +10,53 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- import React, { useEffect, useRef, useState } from 'react';
14
- import throttle from 'lodash.throttle';
15
- import './Table.less';
16
-
17
- var Table = function Table(_ref) {
18
- var children = _ref.children;
19
- var container = useRef();
13
+ import React, { useState } from 'react';
14
+ import { Affix, Layout as AntLayout } from 'antd';
15
+ import Drawer from 'rc-drawer';
16
+ import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
17
+ import { useMedia } from 'react-use';
18
+ import { LeftMenu } from "./components/LeftMenu";
19
+ import styles from "../../index.module.less";
20
+ /**
21
+ * Examples 左侧 LeftMenu
22
+ *
23
+ * @param {LeftMenuProps} props 相关参数,详见类型定义
24
+ * @returns {React.FC} React.FC
25
+ */
26
+
27
+ export var ExampleTopicMenu = function ExampleTopicMenu(props) {
28
+ var exampleTopics = props.exampleTopics;
29
+ var isWide = useMedia('(min-width: 767.99px)', true);
20
30
 
21
31
  var _useState = useState(false),
22
32
  _useState2 = _slicedToArray(_useState, 2),
23
- leftFolded = _useState2[0],
24
- setLeftFolded = _useState2[1];
25
-
26
- var _useState3 = useState(false),
27
- _useState4 = _slicedToArray(_useState3, 2),
28
- rightFolded = _useState4[0],
29
- setRightFolded = _useState4[1]; // watch content scroll to render folded shadow
30
-
31
-
32
- useEffect(function () {
33
- var elm = container.current;
34
- var handler = throttle(function () {
35
- setLeftFolded(elm.scrollLeft > 0);
36
- setRightFolded(elm.scrollLeft < elm.scrollWidth - elm.offsetWidth);
37
- }, 100);
38
- handler();
39
- elm.addEventListener('scroll', handler);
40
- window.addEventListener('resize', handler);
41
- return function () {
42
- elm.removeEventListener('scroll', handler);
43
- window.removeEventListener('resize', handler);
44
- };
45
- }, []);
46
- return /*#__PURE__*/React.createElement("div", {
47
- className: "__dumi-default-table"
48
- }, /*#__PURE__*/React.createElement("div", {
49
- className: "__dumi-default-table-content",
50
- ref: container,
51
- "data-left-folded": leftFolded || undefined,
52
- "data-right-folded": rightFolded || undefined
53
- }, /*#__PURE__*/React.createElement("table", null, children)));
54
- };
55
-
56
- export default Table;
33
+ drawOpen = _useState2[0],
34
+ setDrawOpen = _useState2[1];
35
+
36
+ return /*#__PURE__*/React.createElement(Affix, {
37
+ offsetTop: 0,
38
+ className: styles.affix,
39
+ style: {
40
+ height: isWide ? '100vh' : 'inherit'
41
+ }
42
+ }, isWide ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(AntLayout.Sider, {
43
+ width: "auto",
44
+ theme: "light",
45
+ className: styles.sider
46
+ }, /*#__PURE__*/React.createElement(LeftMenu, {
47
+ exampleTopics: exampleTopics
48
+ }))) : /*#__PURE__*/React.createElement(Drawer, {
49
+ handler: drawOpen ? /*#__PURE__*/React.createElement(MenuFoldOutlined, {
50
+ className: styles.menuSwitch
51
+ }) : /*#__PURE__*/React.createElement(MenuUnfoldOutlined, {
52
+ className: styles.menuSwitch
53
+ }),
54
+ wrapperClassName: styles.menuDrawer,
55
+ onChange: function onChange(open) {
56
+ return setDrawOpen(!!open);
57
+ },
58
+ width: 280
59
+ }, /*#__PURE__*/React.createElement(LeftMenu, {
60
+ exampleTopics: exampleTopics
61
+ })));
62
+ };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { DemoCardProps } from '../../../types';
3
+ /**
4
+ * DEMO 的卡片预览
5
+ *
6
+ * @param {DemoCardProps} props 相关参数,详见类型定义
7
+ * @returns {React.FC} React.FC
8
+ * @author YuZhanglong <loveyzl1123@gmail.com>
9
+ */
10
+ export declare const DemoCard: React.FC<DemoCardProps>;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { Link, useLocale } from 'dumi';
3
+ import { Badge } from 'antd';
4
+ import styles from "../../../index.module.less";
5
+ /**
6
+ * DEMO 的卡片预览
7
+ *
8
+ * @param {DemoCardProps} props 相关参数,详见类型定义
9
+ * @returns {React.FC} React.FC
10
+ * @author YuZhanglong <loveyzl1123@gmail.com>
11
+ */
12
+
13
+ export var DemoCard = function DemoCard(props) {
14
+ var demo = props.demo,
15
+ topicId = props.topicId,
16
+ exampleId = props.exampleId;
17
+ var locale = useLocale();
18
+
19
+ var renderCardInternal = function renderCardInternal() {
20
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("img", {
21
+ src: demo.screenshot || 'https://gw.alipayobjects.com/os/s/prod/antv/assets/image/screenshot-placeholder-b8e70.png',
22
+ alt: demo.title[locale.id]
23
+ })));
24
+ };
25
+
26
+ return /*#__PURE__*/React.createElement(Link, {
27
+ className: styles.galleryCardLink,
28
+ to: "/".concat(locale.id, "/examples/").concat(topicId, "/").concat(exampleId, "/#").concat(demo.id)
29
+ }, demo.isNew ? /*#__PURE__*/React.createElement(Badge.Ribbon, {
30
+ text: "new",
31
+ className: styles.customRibbon
32
+ }, renderCardInternal()) : renderCardInternal(), /*#__PURE__*/React.createElement("h4", null, demo.title[locale.id]));
33
+ };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { GalleryPageContentProps } from '../../types';
3
+ /**
4
+ * Examples 首页内容预览组件
5
+ *
6
+ * @param {GalleryPageContentProps} props 相关参数,详见类型定义
7
+ * @returns {React.FC} React.FC
8
+ * @author YuZhanglong <loveyzl1123@gmail.com>
9
+ */
10
+ export declare const GalleryPageContent: React.FC<GalleryPageContentProps>;
@@ -0,0 +1,81 @@
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 React from 'react';
8
+ import { useLocale } from 'dumi';
9
+ import { DemoCard } from "./DemoCard";
10
+ import styles from "../../index.module.less";
11
+ /**
12
+ * Examples 首页内容预览组件
13
+ *
14
+ * @param {GalleryPageContentProps} props 相关参数,详见类型定义
15
+ * @returns {React.FC} React.FC
16
+ * @author YuZhanglong <loveyzl1123@gmail.com>
17
+ */
18
+
19
+ export var GalleryPageContent = function GalleryPageContent(props) {
20
+ var exampleTopics = props.exampleTopics;
21
+ var locale = useLocale(); // TODO: 公告功能待后续补充
22
+ // /** 获取上新的 demo. 直接用英文 title 作为 id */
23
+ // const demosOnTheNew = useMemo((): Array<NewDemo> => {
24
+ // const result: NewDemo[] = [];
25
+ // each(allDemosInCategory, (categoryDemos, category) => {
26
+ // const newDemos = filter(categoryDemos, (d) => d.new);
27
+ // // 大于4个新增 demo 或全部新增,则直接使用 category 作为代替
28
+ // if (
29
+ // size(newDemos) > 6 ||
30
+ // (size(newDemos) && size(newDemos) === size(categoryDemos))
31
+ // ) {
32
+ // result.push({
33
+ // title: category,
34
+ // id: getDemoCategory(newDemos[0], 'en'),
35
+ // category,
36
+ // });
37
+ // } else {
38
+ // each(newDemos, (demo) =>
39
+ // result.push({
40
+ // title: demo.title[locale.id],
41
+ // id: demo.title.en,
42
+ // category: getDemoCategory(demo),
43
+ // }),
44
+ // );
45
+ // }
46
+ // });
47
+ // return result;
48
+ // }, [allDemosInCategory, allDemos, locale.id]);
49
+
50
+ var flattenExamples = exampleTopics.reduce(function (prev, current) {
51
+ var exampleWithTopic = current.examples.map(function (item) {
52
+ return _objectSpread(_objectSpread({}, item), {}, {
53
+ targetTopic: current
54
+ });
55
+ });
56
+ return prev.concat(exampleWithTopic);
57
+ }, []);
58
+ return /*#__PURE__*/React.createElement("div", {
59
+ className: styles.gallery
60
+ }, /*#__PURE__*/React.createElement("div", {
61
+ className: styles.galleryContent
62
+ }, flattenExamples.map(function (example, i) {
63
+ return /*#__PURE__*/React.createElement("div", {
64
+ key: i
65
+ }, /*#__PURE__*/React.createElement("h2", {
66
+ id: "category-".concat(example.id.replace(/\s/g, ''))
67
+ }, example.title[locale.id]), /*#__PURE__*/React.createElement("ul", {
68
+ className: styles.galleryList
69
+ }, example.demos.map(function (demo) {
70
+ return /*#__PURE__*/React.createElement("li", {
71
+ className: styles.galleryCard,
72
+ key: demo.id,
73
+ title: demo.title[locale.id]
74
+ }, /*#__PURE__*/React.createElement(DemoCard, {
75
+ demo: demo,
76
+ topicId: example.targetTopic.id,
77
+ exampleId: example.id
78
+ }));
79
+ })));
80
+ })));
81
+ };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * Examples 页面
4
+ *
5
+ * @author YuZhanglong <loveyzl1123@gmail.com>
6
+ */
7
+ declare const Example: () => JSX.Element;
8
+ export default Example;