@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,83 @@
1
+ @import "~antd/dist/antd.less";
2
+
3
+ @primary-color: #873bf4;
4
+
5
+ .container1440() {
6
+ width: 1440px;
7
+ max-width: calc(100% - 80px);
8
+ margin-left: auto;
9
+ margin-right: auto;
10
+
11
+ @media only screen and (max-width: 931.99px) {
12
+ & {
13
+ max-width: calc(100% - 60px);
14
+ }
15
+ }
16
+
17
+ @media only screen and (max-width: 767.99px) {
18
+ & {
19
+ max-width: calc(100% - 32px);
20
+ }
21
+ }
22
+ }
23
+
24
+ // 非常关键,用于 react-split-pane 的样式,如果没有,会没有办法鼠标拖拽
25
+ // 参考:https://codesandbox.io/s/mow7x4zyqx
26
+ :global {
27
+
28
+ .Pane1,
29
+ .Pane2 {
30
+ overflow: auto;
31
+ }
32
+
33
+ .Resizer {
34
+ background: #000;
35
+ opacity: 0.1;
36
+ z-index: 1;
37
+ box-sizing: border-box;
38
+ background-clip: padding-box;
39
+
40
+ &:hover {
41
+ transition: all 2s ease;
42
+ }
43
+
44
+ &.horizontal {
45
+ height: 11px;
46
+ margin: -5px 0;
47
+ border-top: 5px solid rgba(255, 255, 255, 0);
48
+ border-bottom: 5px solid rgba(255, 255, 255, 0);
49
+ cursor: row-resize;
50
+ width: 100%;
51
+
52
+ &:hover {
53
+ border-top: 5px solid rgba(0, 0, 0, 0.5);
54
+ border-bottom: 5px solid rgba(0, 0, 0, 0.5);
55
+ }
56
+ }
57
+
58
+ &.vertical {
59
+ width: 11px;
60
+ margin: 0 -5px;
61
+ border-left: 5px solid rgba(255, 255, 255, 0);
62
+ border-right: 5px solid rgba(255, 255, 255, 0);
63
+ cursor: col-resize;
64
+
65
+ Pane2 {
66
+ border-left: 1px solid #e6e6e6;
67
+ }
68
+
69
+ &:hover {
70
+ border-left: 5px solid rgba(0, 0, 0, 0.5);
71
+ border-right: 5px solid rgba(0, 0, 0, 0.5);
72
+ }
73
+ }
74
+
75
+ &.disabled {
76
+ cursor: not-allowed;
77
+
78
+ &:hover {
79
+ border-color: transparent;
80
+ }
81
+ }
82
+ }
83
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import * as _ from 'lodash-es';
2
+ import insertCss from 'insert-css'; // 挂载一些全局变量
3
+
4
+ if (window) {
5
+ window.lodash = _;
6
+ window.insertCss = insertCss;
7
+ }
@@ -0,0 +1,16 @@
1
+ import { NavigatorBannerProps } from './ManualContent/NavigatorBanner';
2
+ export declare const useChinaMirrorHost: () => [boolean];
3
+ export declare const useScrollToTop: () => void;
4
+ export declare const useT: (transformedMessage: string) => string;
5
+ export declare const useLogoLink: ({ link, siteUrl, lang, }: {
6
+ link?: string | undefined;
7
+ siteUrl?: string | undefined;
8
+ lang?: string | undefined;
9
+ }) => [string];
10
+ export declare const usePrevAndNext: () => NavigatorBannerProps['post'][];
11
+ /**
12
+ * i18n .umirc config
13
+ * 如果是 object,则取 locale,否则直接用
14
+ * @param v
15
+ */
16
+ export declare function ic(v: string | object): any;
@@ -1,3 +1,5 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
1
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
4
 
3
5
  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,7 +12,9 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
12
 
11
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
14
 
13
- import { useEffect, useState } from "react";
15
+ import { useEffect, useState } from 'react';
16
+ import { get } from 'lodash-es';
17
+ import { useIntl, useLocale } from 'dumi';
14
18
  export var useChinaMirrorHost = function useChinaMirrorHost() {
15
19
  var _useState = useState(false),
16
20
  _useState2 = _slicedToArray(_useState, 2),
@@ -18,64 +22,83 @@ export var useChinaMirrorHost = function useChinaMirrorHost() {
18
22
  setIsChinaMirrorHost = _useState2[1];
19
23
 
20
24
  useEffect(function () {
21
- if (window.location.host.includes("gitee.io") && window.location.host.includes("antv")) {
25
+ if (window.location.host.includes('gitee.io') && window.location.host.includes('antv')) {
22
26
  setIsChinaMirrorHost(true);
23
27
  }
24
28
  }, []);
25
29
  return [isChinaMirrorHost];
26
30
  };
27
- export var usePrevAndNext = function usePrevAndNext() {
28
- var _useState3 = useState([]),
29
- _useState4 = _slicedToArray(_useState3, 2),
30
- prevAndNext = _useState4[0],
31
- setPrevAndNext = _useState4[1];
32
-
33
- useEffect(function () {
34
- var menuNodes = document.querySelectorAll("aside .ant-menu-item a");
35
- var currentMenuNode = document.querySelector("aside .ant-menu-item-selected a");
36
- var currentIndex = Array.from(menuNodes).findIndex(function (node) {
37
- return node === currentMenuNode;
38
- });
39
- var prevNode = currentIndex - 1 >= 0 ? menuNodes[currentIndex - 1] : undefined;
40
- var nextNode = currentIndex + 1 < menuNodes.length ? menuNodes[currentIndex + 1] : undefined;
41
- var prev = prevNode ? {
42
- slug: prevNode.getAttribute("href") || undefined,
43
- title: prevNode.textContent || undefined
44
- } : undefined;
45
- var next = nextNode ? {
46
- slug: nextNode.getAttribute("href") || undefined,
47
- title: nextNode.textContent || undefined
48
- } : undefined;
49
- setPrevAndNext([prev, next]);
50
- }, []);
51
- return prevAndNext;
31
+ export var useScrollToTop = function useScrollToTop() {
32
+ document.body.scrollTop = document.documentElement.scrollTop = 0;
33
+ };
34
+ export var useT = function useT(transformedMessage) {
35
+ var intl = useIntl();
36
+ return intl.formatMessage({
37
+ id: transformedMessage
38
+ });
52
39
  };
53
40
  export var useLogoLink = function useLogoLink(_ref) {
54
41
  var _ref$link = _ref.link,
55
- link = _ref$link === void 0 ? "" : _ref$link,
42
+ link = _ref$link === void 0 ? '' : _ref$link,
56
43
  _ref$siteUrl = _ref.siteUrl,
57
- siteUrl = _ref$siteUrl === void 0 ? "" : _ref$siteUrl,
44
+ siteUrl = _ref$siteUrl === void 0 ? '' : _ref$siteUrl,
58
45
  _ref$lang = _ref.lang,
59
- lang = _ref$lang === void 0 ? "" : _ref$lang;
46
+ lang = _ref$lang === void 0 ? '' : _ref$lang;
60
47
  var defaultLogoLink;
61
48
 
62
49
  if (link) {
63
50
  defaultLogoLink = link;
64
- } else if (siteUrl === "https://antv.vision") {
51
+ } else if (siteUrl === 'https://antv.vision') {
65
52
  defaultLogoLink = "/".concat(lang);
66
53
  } else {
67
54
  defaultLogoLink = "https://antv.vision/".concat(lang);
68
55
  }
69
56
 
70
- var _useState5 = useState(""),
71
- _useState6 = _slicedToArray(_useState5, 2),
72
- giteeLogoLink = _useState6[0],
73
- setGiteeLogoLink = _useState6[1];
57
+ var _useState3 = useState(''),
58
+ _useState4 = _slicedToArray(_useState3, 2),
59
+ giteeLogoLink = _useState4[0],
60
+ setGiteeLogoLink = _useState4[1];
74
61
 
75
62
  useEffect(function () {
76
- if (window.location.host.includes("gitee.io") && window.location.host.includes("antv")) {
63
+ if (window.location.host.includes('gitee.io') && window.location.host.includes('antv')) {
77
64
  setGiteeLogoLink("https://antv.gitee.io/".concat(lang));
78
65
  }
79
66
  }, []);
80
67
  return [giteeLogoLink || defaultLogoLink];
81
- };
68
+ };
69
+ export var usePrevAndNext = function usePrevAndNext() {
70
+ var _useState5 = useState([]),
71
+ _useState6 = _slicedToArray(_useState5, 2),
72
+ prevAndNext = _useState6[0],
73
+ setPrevAndNext = _useState6[1];
74
+
75
+ useEffect(function () {
76
+ var menuNodes = document.querySelectorAll('aside .ant-menu-item a');
77
+ var currentMenuNode = document.querySelector('aside .ant-menu-item-selected a');
78
+ var currentIndex = Array.from(menuNodes).findIndex(function (node) {
79
+ return node === currentMenuNode;
80
+ });
81
+ var prevNode = currentIndex - 1 >= 0 ? menuNodes[currentIndex - 1] : undefined;
82
+ var nextNode = currentIndex + 1 < menuNodes.length ? menuNodes[currentIndex + 1] : undefined;
83
+ var prev = prevNode ? {
84
+ slug: prevNode.getAttribute('href') || undefined,
85
+ title: prevNode.textContent || undefined
86
+ } : undefined;
87
+ var next = nextNode ? {
88
+ slug: nextNode.getAttribute('href') || undefined,
89
+ title: nextNode.textContent || undefined
90
+ } : undefined;
91
+ setPrevAndNext([prev, next]);
92
+ }, []);
93
+ return prevAndNext;
94
+ };
95
+ /**
96
+ * i18n .umirc config
97
+ * 如果是 object,则取 locale,否则直接用
98
+ * @param v
99
+ */
100
+
101
+ export function ic(v) {
102
+ var locale = useLocale();
103
+ return _typeof(v) === 'object' ? get(v, [locale.id]) : v;
104
+ }
@@ -0,0 +1,20 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
5
+ /// <reference types="lodash" />
6
+ declare type Status = 'responded' | 'error' | 'timeout';
7
+ export declare const ping: (callback: (status: Status) => void) => NodeJS.Timeout;
8
+ export declare const getChinaMirrorHost: (host?: string) => string;
9
+ export declare function getGithubSourceUrl(githubUrl: string, relativePath: string, prefix?: string): string;
10
+ export declare const getAllDemosInCategory: (allDemos: any[], lang: string) => import("lodash").Dictionary<any[]>;
11
+ export declare const getSortedCategories: (allDemosInCategory: any, locale: string) => string[];
12
+ export declare const getGroupedEdges: (edges: any) => import("lodash").Dictionary<any[]>;
13
+ export declare const getGroupedEdgesDataEdit: (examples: any, edges: any, local: string) => string[];
14
+ export declare const getTreeDataByExamplesAndEdges: (examples: any, edges: any, locale: string) => {
15
+ title: any;
16
+ value: string;
17
+ icon: any;
18
+ children: any[];
19
+ }[];
20
+ export {};
@@ -0,0 +1,154 @@
1
+ import { groupBy } from 'lodash-es';
2
+ export var ping = function ping(callback) {
3
+ var url = 'https://private-a' + 'lipay' + 'objects.alip' + 'ay.com/alip' + 'ay-rmsdeploy-image/rmsportal/RKuAiriJqrUhyqW.png';
4
+ var img = new Image();
5
+ var done = false;
6
+
7
+ var finish = function finish(status) {
8
+ if (!done) {
9
+ done = true;
10
+ img.src = '';
11
+ callback(status);
12
+ }
13
+ };
14
+
15
+ img.onload = function () {
16
+ return finish('responded');
17
+ };
18
+
19
+ img.onerror = function () {
20
+ return finish('error');
21
+ };
22
+
23
+ img.src = url;
24
+ return setTimeout(function () {
25
+ return finish('timeout');
26
+ }, 1500);
27
+ };
28
+ export var getChinaMirrorHost = function getChinaMirrorHost(host) {
29
+ var hostString = typeof host === 'undefined' ? window.location.host : host; // antv.vision => antv.gitee.io
30
+
31
+ if (hostString === 'antv.vision') {
32
+ return 'antv.gitee.io';
33
+ } // g2plot.antv.vision => antv-g2plot.gitee.io
34
+
35
+
36
+ var match = hostString.match(/(.*)\.antv\.vision/);
37
+
38
+ if (match && match[1]) {
39
+ return "antv-".concat(match[1], ".gitee.io");
40
+ }
41
+
42
+ return hostString;
43
+ };
44
+ export function getGithubSourceUrl(githubUrl, relativePath) {
45
+ var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'examples';
46
+
47
+ // https://github.com/antvis/x6/tree/master/packages/x6-sites
48
+ if (githubUrl.includes('/tree/master/')) {
49
+ return "".concat(githubUrl.replace('/tree/master/', '/edit/master/'), "/").concat(prefix, "/").concat(relativePath);
50
+ }
51
+
52
+ return "".concat(githubUrl, "/edit/master/").concat(prefix, "/").concat(relativePath);
53
+ }
54
+ export var getAllDemosInCategory = function getAllDemosInCategory(allDemos, lang) {
55
+ return groupBy(allDemos || [], function (demo) {
56
+ if (!demo.postFrontmatter || !demo.postFrontmatter[lang]) {
57
+ return 'OTHER';
58
+ }
59
+
60
+ return demo.postFrontmatter[lang].title;
61
+ });
62
+ };
63
+ export var getSortedCategories = function getSortedCategories(allDemosInCategory, locale) {
64
+ return Object.keys(allDemosInCategory).sort(function (a, b) {
65
+ if (a === 'OTHER') {
66
+ return -1;
67
+ }
68
+
69
+ if (b === 'OTHER') {
70
+ return 1;
71
+ }
72
+
73
+ return allDemosInCategory[a][0].postFrontmatter[locale].order - allDemosInCategory[b][0].postFrontmatter[locale].order;
74
+ });
75
+ };
76
+
77
+ var getMenuItemLocaleKey = function getMenuItemLocaleKey() {
78
+ var slug = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
79
+ var slugPieces = slug.split('/');
80
+ return slugPieces.slice(slugPieces.indexOf('examples') + 1).filter(function (key) {
81
+ return key;
82
+ }).join('/');
83
+ };
84
+
85
+ var getExampleOrder = function getExampleOrder(options) {
86
+ var groupedEdgeKey = options.groupedEdgeKey,
87
+ groupedEdges = options.groupedEdges,
88
+ examples = options.examples;
89
+ var key = getMenuItemLocaleKey(groupedEdgeKey);
90
+
91
+ if (examples.find(function (item) {
92
+ return item.slug === key;
93
+ })) {
94
+ return (examples.findIndex(function (item) {
95
+ return item.slug === key;
96
+ }) || 0) + 100;
97
+ }
98
+
99
+ if (!groupedEdges[groupedEdgeKey] && !groupedEdges[groupedEdgeKey].length) {
100
+ return 0;
101
+ }
102
+
103
+ return groupedEdges[groupedEdgeKey][0].node.frontmatter.order || 0;
104
+ };
105
+
106
+ export var getGroupedEdges = function getGroupedEdges(edges) {
107
+ return groupBy(edges, function (_ref) {
108
+ var slugString = _ref.node.fields.slug;
109
+
110
+ // API.md and design.md
111
+ if (slugString.endsWith('/API') || slugString.endsWith('/design')) {
112
+ return slugString.split('/').slice(0, -2).join('/');
113
+ } // index.md
114
+
115
+
116
+ return slugString.split('/').slice(0, -1).join('/');
117
+ });
118
+ }; // 提取出筛选 和 排序的方法 好在获取treeData 的时候使用
119
+
120
+ export var getGroupedEdgesDataEdit = function getGroupedEdgesDataEdit(examples, edges, local) {
121
+ var groupedEdges = getGroupedEdges(edges);
122
+ return Object.keys(groupedEdges).filter(function (key) {
123
+ return key.startsWith("/".concat(local, "/"));
124
+ }).sort(function (a, b) {
125
+ var aOrder = getExampleOrder({
126
+ groupedEdgeKey: a,
127
+ examples: examples,
128
+ groupedEdges: groupedEdges
129
+ });
130
+ var bOrder = getExampleOrder({
131
+ groupedEdgeKey: b,
132
+ examples: examples,
133
+ groupedEdges: groupedEdges
134
+ });
135
+ return aOrder - bOrder;
136
+ });
137
+ };
138
+ export var getTreeDataByExamplesAndEdges = function getTreeDataByExamplesAndEdges(examples, edges, locale) {
139
+ return getGroupedEdgesDataEdit(examples, edges, locale).map(function (slugString) {
140
+ var menuItemLocaleKey = getMenuItemLocaleKey(slugString);
141
+ var doc = examples.find(function (item) {
142
+ return item.slug === menuItemLocaleKey;
143
+ }) || {};
144
+ return {
145
+ title: doc && doc.title ? doc.title[locale] : menuItemLocaleKey,
146
+ value: slugString,
147
+ icon: doc.icon,
148
+ children: getGroupedEdges(edges)[slugString].filter(function (edge) {
149
+ var slug = edge.node.fields.slug;
150
+ return !(slug.endsWith('/API') || slug.endsWith('/design') || slug.endsWith('/gallery'));
151
+ })
152
+ };
153
+ });
154
+ };
@@ -0,0 +1,3 @@
1
+ export interface IThemeConfig {
2
+ [key: string]: any;
3
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,137 @@
1
+ declare module '\*.jpg' {
2
+ const content: string;
3
+ export default content;
4
+ }
5
+
6
+ declare module '\*.png' {
7
+ const content: string;
8
+ export default content;
9
+ }
10
+
11
+ declare module '\*.json' {
12
+ const content: string;
13
+ export default content;
14
+ }
15
+
16
+ declare module '\*.less' {
17
+ const content: any;
18
+ export default content;
19
+ }
20
+
21
+ declare module '\*.svg' {
22
+ const content: any;
23
+ export default content;
24
+ }
25
+
26
+ declare namespace ExamplesPage {
27
+ /** 案例 DEMO */
28
+ export interface Demo {
29
+ /**
30
+ * id
31
+ */
32
+ id: string;
33
+
34
+ /**
35
+ * 标题(支持国际化)
36
+ */
37
+ title: {
38
+ zh: string;
39
+ en: string;
40
+ };
41
+
42
+ /**
43
+ * 截图
44
+ */
45
+ screenshot: string;
46
+
47
+ /**
48
+ * TypeScript 源码文件
49
+ */
50
+ source: string;
51
+
52
+ /**
53
+ * DEMO 代码文件名称
54
+ */
55
+ filename: string;
56
+
57
+ /**
58
+ * 衍生属性,通过 topic.id + example.id + demo.id 可以计算获取
59
+ */
60
+ relativePath?: string;
61
+
62
+ /**
63
+ * 是否为新品
64
+ */
65
+ isNew?: boolean;
66
+
67
+ /**
68
+ * 目标 example
69
+ */
70
+ targetExample?: ExamplesPage.Example;
71
+
72
+ /**
73
+ * 目标主题
74
+ */
75
+ targetTopic?: ExamplesPage.ExampleTopic;
76
+ }
77
+
78
+ /** 示例 */
79
+ export interface Example {
80
+ /**
81
+ * id
82
+ */
83
+ id: string;
84
+
85
+ /**
86
+ * 标题(支持国际化)
87
+ */
88
+ title: {
89
+ zh: string;
90
+ en: string;
91
+ };
92
+
93
+ /**
94
+ * 图标
95
+ */
96
+ icon: string;
97
+
98
+ /**
99
+ * DEMO
100
+ */
101
+ demos: Demo[];
102
+ }
103
+
104
+ /** 案例主题 */
105
+ export interface ExampleTopic {
106
+ /**
107
+ * id
108
+ */
109
+ id: string;
110
+
111
+ /**
112
+ * 标题
113
+ */
114
+ title: {
115
+ zh: string;
116
+ en: string;
117
+ };
118
+
119
+ /**
120
+ * 图标
121
+ */
122
+ icon: string;
123
+
124
+ /**
125
+ * 所有案例
126
+ */
127
+ examples: Example[];
128
+ }
129
+ }
130
+
131
+ /**
132
+ * 配置文件中的国际化配置
133
+ */
134
+ declare type IC = string | {
135
+ zh: string;
136
+ en: string;
137
+ }