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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -33
  3. package/dist/builtins/Playground/index.d.ts +21 -0
  4. package/dist/builtins/Playground/index.js +69 -0
  5. package/dist/builtins/Playground/index.module.less +15 -0
  6. package/dist/context.d.ts +6 -0
  7. package/dist/context.js +2 -0
  8. package/dist/layouts/DocLayout.d.ts +7 -0
  9. package/dist/layouts/DocLayout.js +48 -0
  10. package/dist/layouts/entry/API.d.ts +10 -0
  11. package/dist/layouts/entry/API.js +12 -0
  12. package/dist/layouts/entry/Index.d.ts +7 -0
  13. package/dist/layouts/entry/Index.js +79 -0
  14. package/dist/layouts/entry/Manual.d.ts +8 -0
  15. package/dist/layouts/entry/Manual.js +13 -0
  16. package/dist/locales/en.json +98 -0
  17. package/dist/locales/zh.json +98 -0
  18. package/dist/pages/404.d.ts +6 -0
  19. package/dist/pages/404.js +18 -0
  20. package/dist/pages/Example/index.d.ts +6 -0
  21. package/dist/pages/Example/index.js +115 -0
  22. package/dist/pages/Example/index.module.less +82 -0
  23. package/dist/pages/Example/utils.d.ts +1 -0
  24. package/dist/pages/Example/utils.js +9 -0
  25. package/dist/pages/Examples/components/Accouncement/index.d.ts +6 -0
  26. package/dist/pages/Examples/components/Accouncement/index.js +60 -0
  27. package/dist/pages/Examples/components/Accouncement/index.module.less +9 -0
  28. package/dist/pages/Examples/components/Article/index.d.ts +2 -0
  29. package/dist/pages/Examples/components/Article/index.js +8 -0
  30. package/dist/pages/Examples/components/Article/index.module.less +2 -0
  31. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.d.ts +10 -0
  32. package/dist/pages/Examples/components/ExampleTopicMenu/components/LeftMenu/index.js +74 -0
  33. package/dist/pages/Examples/components/ExampleTopicMenu/index.d.ts +9 -0
  34. package/{es/builtins/Example.js → dist/pages/Examples/components/ExampleTopicMenu/index.js} +47 -33
  35. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.d.ts +10 -0
  36. package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +33 -0
  37. package/dist/pages/Examples/components/GalleryPageContent/index.d.ts +10 -0
  38. package/dist/pages/Examples/components/GalleryPageContent/index.js +81 -0
  39. package/dist/pages/Examples/index.d.ts +8 -0
  40. package/dist/pages/Examples/index.js +95 -0
  41. package/dist/pages/Examples/index.module.less +607 -0
  42. package/dist/pages/Examples/types.d.ts +34 -0
  43. package/dist/pages/Examples/types.js +1 -0
  44. package/dist/plugin/examples.d.ts +21 -0
  45. package/dist/plugin/examples.js +105 -0
  46. package/dist/plugin/index.d.ts +3 -0
  47. package/dist/plugin/index.js +113 -0
  48. package/dist/plugin/utils.d.ts +5 -0
  49. package/dist/plugin/utils.js +46 -0
  50. package/dist/slots/404.d.ts +2 -0
  51. package/{es/antv/404/index.js → dist/slots/404.js} +4 -9
  52. package/{es/antv/Cases/Cases.d.ts → dist/slots/Cases/index.d.ts} +5 -4
  53. package/{es/antv/Cases/Cases.js → dist/slots/Cases/index.js} +25 -25
  54. package/{src/antv/Cases/Cases.module.less → dist/slots/Cases/index.module.less} +36 -5
  55. package/dist/slots/CodeEditor/Toolbar.d.ts +67 -0
  56. package/dist/slots/CodeEditor/Toolbar.js +140 -0
  57. package/dist/slots/CodeEditor/Toolbar.module.less +81 -0
  58. package/dist/slots/CodeEditor/index.d.ts +58 -0
  59. package/dist/slots/CodeEditor/index.js +226 -0
  60. package/dist/slots/CodeEditor/index.module.less +11 -0
  61. package/dist/slots/CodeEditor/utils.d.ts +42 -0
  62. package/dist/slots/CodeEditor/utils.js +157 -0
  63. package/dist/slots/CodePreview/CodeHeader.d.ts +19 -0
  64. package/dist/slots/CodePreview/CodeHeader.js +32 -0
  65. package/dist/slots/CodePreview/CodeHeader.module.less +0 -0
  66. package/dist/slots/CodePreview/index.d.ts +17 -0
  67. package/dist/slots/CodePreview/index.js +29 -0
  68. package/dist/slots/CodePreview/index.module.less +43 -0
  69. package/dist/slots/CodeRunner/index.d.ts +15 -0
  70. package/dist/slots/CodeRunner/index.js +79 -0
  71. package/dist/slots/CodeRunner/index.module.less +0 -0
  72. package/dist/slots/CodeRunner/utils.d.ts +11 -0
  73. package/dist/slots/CodeRunner/utils.js +36 -0
  74. package/dist/slots/Companies/index.d.ts +13 -0
  75. package/dist/slots/Companies/index.js +49 -0
  76. package/dist/slots/Companies/index.module.less +82 -0
  77. package/dist/slots/Detail/News.d.ts +10 -0
  78. package/{es/antv/Banner/Notification.js → dist/slots/Detail/News.js} +8 -11
  79. package/{src/antv/Banner/Notification.module.less → dist/slots/Detail/News.module.less} +15 -3
  80. package/dist/slots/Detail/index.d.ts +27 -0
  81. package/dist/slots/Detail/index.js +124 -0
  82. package/{src/antv/Banner/Banner.module.less → dist/slots/Detail/index.module.less} +42 -74
  83. package/dist/slots/ExampleSider/index.d.ts +21 -0
  84. package/dist/slots/ExampleSider/index.js +196 -0
  85. package/dist/slots/ExampleSider/index.module.less +141 -0
  86. package/{es/antv → dist/slots}/Features/FeatureCard.d.ts +2 -1
  87. package/{es/antv → dist/slots}/Features/FeatureCard.js +6 -6
  88. package/{src/antv → dist/slots}/Features/FeatureCard.module.less +8 -1
  89. package/{es/antv → dist/slots}/Features/index.d.ts +2 -2
  90. package/{es/antv → dist/slots}/Features/index.js +19 -26
  91. package/{src/antv/Features/Features.module.less → dist/slots/Features/index.module.less} +34 -3
  92. package/dist/slots/Footer/index.d.ts +18 -0
  93. package/dist/slots/Footer/index.js +188 -0
  94. package/dist/slots/Footer/index.module.less +86 -0
  95. package/dist/slots/Header/Logo.d.ts +7 -0
  96. package/{es/antv → dist/slots}/Header/Logo.js +6 -2
  97. package/dist/slots/Header/LogoWhite.d.ts +7 -0
  98. package/dist/slots/Header/LogoWhite.js +19 -0
  99. package/dist/slots/Header/Navs.d.ts +26 -0
  100. package/dist/slots/Header/Navs.js +63 -0
  101. package/dist/slots/Header/Products/NavigatorBanner.d.ts +10 -0
  102. package/dist/slots/Header/Products/NavigatorBanner.js +34 -0
  103. package/dist/slots/Header/Products/NavigatorBanner.module.less +39 -0
  104. package/{es/antv → dist/slots/Header}/Products/Product.d.ts +3 -3
  105. package/{es/antv → dist/slots/Header}/Products/Product.js +11 -16
  106. package/{src/antv → dist/slots/Header}/Products/Product.module.less +10 -8
  107. package/{es/antv → dist/slots/Header}/Products/getProducts.d.ts +2 -7
  108. package/dist/slots/Header/Products/getProducts.js +67 -0
  109. package/dist/slots/Header/Products/index.d.ts +9 -0
  110. package/{es/antv → dist/slots/Header}/Products/index.js +15 -22
  111. package/dist/slots/Header/Search.d.ts +12 -0
  112. package/dist/slots/Header/Search.js +90 -0
  113. package/dist/slots/Header/Search.module.less +39 -0
  114. package/dist/slots/Header/index.d.ts +66 -0
  115. package/dist/slots/Header/index.js +380 -0
  116. package/dist/slots/Header/index.module.less +382 -0
  117. package/dist/slots/Header/utils.d.ts +1 -0
  118. package/dist/slots/Header/utils.js +26 -0
  119. package/dist/slots/Loading/index.d.ts +7 -0
  120. package/dist/slots/Loading/index.js +79 -0
  121. package/dist/slots/Loading/index.module.less +279 -0
  122. package/dist/slots/ManualContent/NavigatorBanner.d.ts +9 -0
  123. package/dist/slots/ManualContent/NavigatorBanner.js +36 -0
  124. package/dist/slots/ManualContent/NavigatorBanner.module.less +39 -0
  125. package/dist/slots/ManualContent/ReadingTime.d.ts +3 -0
  126. package/dist/slots/ManualContent/ReadingTime.js +10 -0
  127. package/dist/slots/ManualContent/index.d.ts +9 -0
  128. package/dist/slots/ManualContent/index.js +344 -0
  129. package/dist/slots/ManualContent/index.module.less +668 -0
  130. package/dist/slots/ManualContent/utils.d.ts +3 -0
  131. package/dist/slots/ManualContent/utils.js +35 -0
  132. package/dist/slots/SEO.d.ts +10 -0
  133. package/dist/slots/SEO.js +59 -0
  134. package/dist/slots/TOC.d.ts +5 -0
  135. package/dist/slots/TOC.js +6 -0
  136. package/dist/slots/_.less +83 -0
  137. package/dist/slots/global.d.ts +1 -0
  138. package/dist/slots/global.js +7 -0
  139. package/dist/slots/hooks.d.ts +16 -0
  140. package/{es/antv → dist/slots}/hooks.js +60 -37
  141. package/dist/slots/utils.d.ts +5 -0
  142. package/dist/slots/utils.js +112 -0
  143. package/dist/types.d.ts +86 -0
  144. package/dist/types.js +1 -0
  145. package/dist/typings.d.ts +24 -0
  146. package/package.json +110 -47
  147. package/es/antv/404/index.d.ts +0 -2
  148. package/es/antv/Banner/Banner.module.less +0 -412
  149. package/es/antv/Banner/Notification.d.ts +0 -10
  150. package/es/antv/Banner/Notification.module.less +0 -108
  151. package/es/antv/Banner/index.d.ts +0 -25
  152. package/es/antv/Banner/index.js +0 -104
  153. package/es/antv/Cases/Cases.module.less +0 -203
  154. package/es/antv/Features/FeatureCard.module.less +0 -51
  155. package/es/antv/Features/Features.module.less +0 -169
  156. package/es/antv/Footer/Footer.module.less +0 -36
  157. package/es/antv/Footer/index.d.ts +0 -12
  158. package/es/antv/Footer/index.js +0 -237
  159. package/es/antv/Header/Logo.d.ts +0 -4
  160. package/es/antv/Products/Product.module.less +0 -146
  161. package/es/antv/Products/getNewProducts.d.ts +0 -24
  162. package/es/antv/Products/getNewProducts.js +0 -35
  163. package/es/antv/Products/getProducts.js +0 -460
  164. package/es/antv/Products/index.d.ts +0 -9
  165. package/es/antv/hooks.d.ts +0 -14
  166. package/es/antv/mixins.less +0 -21
  167. package/es/antv/utils.d.ts +0 -5
  168. package/es/antv/utils.js +0 -49
  169. package/es/builtins/API.d.ts +0 -3
  170. package/es/builtins/API.js +0 -37
  171. package/es/builtins/Alert.d.ts +0 -3
  172. package/es/builtins/Alert.js +0 -7
  173. package/es/builtins/Alert.less +0 -62
  174. package/es/builtins/Badge.d.ts +0 -3
  175. package/es/builtins/Badge.js +0 -7
  176. package/es/builtins/Badge.less +0 -31
  177. package/es/builtins/Example.d.ts +0 -5
  178. package/es/builtins/Example.less +0 -47
  179. package/es/builtins/Previewer.d.ts +0 -39
  180. package/es/builtins/Previewer.js +0 -225
  181. package/es/builtins/Previewer.less +0 -406
  182. package/es/builtins/SourceCode.d.ts +0 -10
  183. package/es/builtins/SourceCode.js +0 -70
  184. package/es/builtins/SourceCode.less +0 -103
  185. package/es/builtins/Table.d.ts +0 -4
  186. package/es/builtins/Table.js +0 -56
  187. package/es/builtins/Table.less +0 -43
  188. package/es/builtins/Tree.d.ts +0 -4
  189. package/es/builtins/Tree.js +0 -213
  190. package/es/builtins/Tree.less +0 -159
  191. package/es/components/Dark.d.ts +0 -9
  192. package/es/components/Dark.js +0 -125
  193. package/es/components/Dark.less +0 -121
  194. package/es/components/LocaleSelect.d.ts +0 -6
  195. package/es/components/LocaleSelect.js +0 -53
  196. package/es/components/LocaleSelect.less +0 -59
  197. package/es/components/Navbar.d.ts +0 -10
  198. package/es/components/Navbar.js +0 -155
  199. package/es/components/Navbar.less +0 -180
  200. package/es/components/SearchBar.d.ts +0 -4
  201. package/es/components/SearchBar.js +0 -81
  202. package/es/components/SearchBar.less +0 -165
  203. package/es/components/SideMenu.d.ts +0 -10
  204. package/es/components/SideMenu.js +0 -99
  205. package/es/components/SideMenu.less +0 -379
  206. package/es/components/SlugList.d.ts +0 -7
  207. package/es/components/SlugList.js +0 -38
  208. package/es/components/SlugList.less +0 -18
  209. package/es/declaration.d.ts +0 -1
  210. package/es/layout.d.ts +0 -5
  211. package/es/layout.js +0 -276
  212. package/es/style/layout.less +0 -402
  213. package/es/style/markdown.less +0 -240
  214. package/es/style/variables.less +0 -37
  215. package/src/antv/404/index.tsx +0 -25
  216. package/src/antv/Banner/Notification.tsx +0 -45
  217. package/src/antv/Banner/index.tsx +0 -139
  218. package/src/antv/Cases/Cases.tsx +0 -116
  219. package/src/antv/Features/FeatureCard.tsx +0 -24
  220. package/src/antv/Features/index.tsx +0 -86
  221. package/src/antv/Footer/Footer.module.less +0 -36
  222. package/src/antv/Footer/index.tsx +0 -272
  223. package/src/antv/Header/Logo.tsx +0 -85
  224. package/src/antv/Products/Product.tsx +0 -80
  225. package/src/antv/Products/getNewProducts.tsx +0 -53
  226. package/src/antv/Products/getProducts.tsx +0 -626
  227. package/src/antv/Products/index.tsx +0 -70
  228. package/src/antv/hooks.ts +0 -87
  229. package/src/antv/mixins.less +0 -21
  230. package/src/antv/utils.ts +0 -44
  231. package/src/builtins/API.tsx +0 -57
  232. package/src/builtins/Alert.less +0 -62
  233. package/src/builtins/Alert.tsx +0 -4
  234. package/src/builtins/Badge.less +0 -31
  235. package/src/builtins/Badge.tsx +0 -4
  236. package/src/builtins/Example.less +0 -47
  237. package/src/builtins/Example.tsx +0 -34
  238. package/src/builtins/Previewer.less +0 -406
  239. package/src/builtins/Previewer.tsx +0 -264
  240. package/src/builtins/SourceCode.less +0 -103
  241. package/src/builtins/SourceCode.tsx +0 -55
  242. package/src/builtins/Table.less +0 -43
  243. package/src/builtins/Table.tsx +0 -42
  244. package/src/builtins/Tree.less +0 -159
  245. package/src/builtins/Tree.tsx +0 -130
  246. package/src/components/Dark.less +0 -121
  247. package/src/components/Dark.tsx +0 -78
  248. package/src/components/LocaleSelect.less +0 -59
  249. package/src/components/LocaleSelect.tsx +0 -53
  250. package/src/components/Navbar.less +0 -180
  251. package/src/components/Navbar.tsx +0 -152
  252. package/src/components/SearchBar.less +0 -165
  253. package/src/components/SearchBar.tsx +0 -68
  254. package/src/components/SideMenu.less +0 -379
  255. package/src/components/SideMenu.tsx +0 -148
  256. package/src/components/SlugList.less +0 -18
  257. package/src/components/SlugList.tsx +0 -20
  258. package/src/declaration.d.ts +0 -1
  259. package/src/layout.tsx +0 -225
  260. package/src/style/layout.less +0 -402
  261. package/src/style/markdown.less +0 -240
  262. package/src/style/variables.less +0 -37
  263. package/src/test/SearchBar.test.ts +0 -32
  264. package/src/test/Table.test.tsx +0 -41
  265. package/src/test/index.test.tsx +0 -377
@@ -1,213 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _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; }
6
-
7
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
-
9
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
-
11
- 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."); }
12
-
13
- 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); }
14
-
15
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
16
-
17
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
18
-
19
- 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; }
20
-
21
- import React, { useEffect, useState, createRef } from 'react';
22
- import Tree from 'rc-tree';
23
- import './Tree.less';
24
- var FileOutlined = /*#__PURE__*/React.createElement("svg", {
25
- xmlns: "http://www.w3.org/2000/svg",
26
- className: "__dumi-site-tree-icon icon-file",
27
- fill: "currentcolor",
28
- viewBox: "0 0 1024 1024"
29
- }, /*#__PURE__*/React.createElement("path", {
30
- d: "M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0 0 42 42h216v494z"
31
- }));
32
- var FolderOpenOutlined = /*#__PURE__*/React.createElement("svg", {
33
- xmlns: "http://www.w3.org/2000/svg",
34
- className: "__dumi-site-tree-icon icon-folder-open",
35
- fill: "currentcolor",
36
- viewBox: "0 0 1024 1024"
37
- }, /*#__PURE__*/React.createElement("path", {
38
- d: "M928 444H820V330.4c0-17.7-14.3-32-32-32H473L355.7 186.2a8.15 8.15 0 0 0-5.5-2.2H96c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h698c13 0 24.8-7.9 29.7-20l134-332c1.5-3.8 2.3-7.9 2.3-12 0-17.7-14.3-32-32-32zM136 256h188.5l119.6 114.4H748V444H238c-13 0-24.8 7.9-29.7 20L136 643.2V256zm635.3 512H159l103.3-256h612.4L771.3 768z"
39
- }));
40
- var FolderOutlined = /*#__PURE__*/React.createElement("svg", {
41
- xmlns: "http://www.w3.org/2000/svg",
42
- className: "__dumi-site-tree-icon icon-folder",
43
- fill: "currentcolor",
44
- viewBox: "0 0 1024 1024"
45
- }, /*#__PURE__*/React.createElement("path", {
46
- d: "M880 298.4H521L403.7 186.2a8.15 8.15 0 0 0-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z"
47
- }));
48
- var MinusSquareOutlined = /*#__PURE__*/React.createElement("svg", {
49
- xmlns: "http://www.w3.org/2000/svg",
50
- className: "__dumi-site-tree-icon icon-minus-square",
51
- fill: "currentcolor",
52
- viewBox: "0 0 1024 1024"
53
- }, /*#__PURE__*/React.createElement("path", {
54
- d: "M328 544h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"
55
- }), /*#__PURE__*/React.createElement("path", {
56
- d: "M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"
57
- }));
58
- var PlusSquareOutlined = /*#__PURE__*/React.createElement("svg", {
59
- xmlns: "http://www.w3.org/2000/svg",
60
- className: "__dumi-site-tree-icon icon-plus-square",
61
- fill: "currentcolor",
62
- viewBox: "0 0 1024 1024"
63
- }, /*#__PURE__*/React.createElement("path", {
64
- d: "M328 544h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z"
65
- }), /*#__PURE__*/React.createElement("path", {
66
- d: "M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zm-40 728H184V184h656v656z"
67
- }));
68
-
69
- function getTreeFromList(nodes) {
70
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
71
- var data = [];
72
- [].concat(nodes).forEach(function (node, i) {
73
- var _a;
74
-
75
- var key = "".concat(prefix ? "".concat(prefix, "-") : '').concat(i);
76
-
77
- switch (node.type) {
78
- case 'ul':
79
- var parent = ((_a = data[data.length - 1]) === null || _a === void 0 ? void 0 : _a.children) || data;
80
- var ulLeafs = getTreeFromList(node.props.children || [], key);
81
- parent.push.apply(parent, _toConsumableArray(ulLeafs));
82
- break;
83
-
84
- case 'li':
85
- var liLeafs = getTreeFromList(node.props.children, key);
86
- data.push({
87
- title: [].concat(node.props.children).filter(function (child) {
88
- return child.type !== 'ul';
89
- }),
90
- key: key,
91
- children: liLeafs,
92
- isLeaf: !liLeafs.length
93
- });
94
- break;
95
-
96
- default:
97
- }
98
- });
99
- return data;
100
- }
101
-
102
- var useListToTree = function useListToTree(nodes) {
103
- var _useState = useState(getTreeFromList(nodes)),
104
- _useState2 = _slicedToArray(_useState, 2),
105
- tree = _useState2[0],
106
- setTree = _useState2[1];
107
-
108
- useEffect(function () {
109
- setTree(getTreeFromList(nodes));
110
- }, [nodes]);
111
- return tree;
112
- };
113
-
114
- var getIcon = function getIcon(props) {
115
- var isLeaf = props.isLeaf,
116
- expanded = props.expanded;
117
-
118
- if (isLeaf) {
119
- return FileOutlined;
120
- }
121
-
122
- return expanded ? FolderOpenOutlined : FolderOutlined;
123
- };
124
-
125
- var renderSwitcherIcon = function renderSwitcherIcon(props) {
126
- var isLeaf = props.isLeaf,
127
- expanded = props.expanded;
128
-
129
- if (isLeaf) {
130
- return /*#__PURE__*/React.createElement("span", {
131
- className: "tree-switcher-leaf-line"
132
- });
133
- }
134
-
135
- return expanded ? /*#__PURE__*/React.createElement("span", {
136
- className: "tree-switcher-line-icon"
137
- }, MinusSquareOutlined) : /*#__PURE__*/React.createElement("span", {
138
- className: "tree-switcher-line-icon"
139
- }, PlusSquareOutlined);
140
- }; // ================== Collapse Motion ==================
141
-
142
-
143
- var getCollapsedHeight = function getCollapsedHeight() {
144
- return {
145
- height: 0,
146
- opacity: 0
147
- };
148
- };
149
-
150
- var getRealHeight = function getRealHeight(node) {
151
- return {
152
- height: node.scrollHeight,
153
- opacity: 1
154
- };
155
- };
156
-
157
- var getCurrentHeight = function getCurrentHeight(node) {
158
- return {
159
- height: node.offsetHeight
160
- };
161
- };
162
-
163
- var skipOpacityTransition = function skipOpacityTransition(_, event) {
164
- return event.propertyName === 'height';
165
- };
166
-
167
- var collapseMotion = {
168
- motionName: 'ant-motion-collapse',
169
- onAppearStart: getCollapsedHeight,
170
- onEnterStart: getCollapsedHeight,
171
- onAppearActive: getRealHeight,
172
- onEnterActive: getRealHeight,
173
- onLeaveStart: getCurrentHeight,
174
- onLeaveActive: getCollapsedHeight,
175
- onAppearEnd: skipOpacityTransition,
176
- onEnterEnd: skipOpacityTransition,
177
- onLeaveEnd: skipOpacityTransition,
178
- motionDeadline: 500
179
- };
180
- export default (function (props) {
181
- var data = useListToTree(props.children);
182
- var treeRef = /*#__PURE__*/createRef();
183
-
184
- var onClick = function onClick(event, node) {
185
- var isLeaf = node.isLeaf;
186
-
187
- if (isLeaf || event.shiftKey || event.metaKey || event.ctrlKey) {
188
- return;
189
- }
190
-
191
- treeRef.current.onNodeExpand(event, node);
192
- };
193
-
194
- return /*#__PURE__*/React.createElement(Tree, {
195
- className: "__dumi-site-tree",
196
- icon: getIcon,
197
- ref: treeRef,
198
- itemHeight: 20,
199
- showLine: true,
200
- selectable: false,
201
- motion: Object.assign(Object.assign({}, collapseMotion), {
202
- motionAppear: false
203
- }),
204
- onClick: onClick,
205
- treeData: [{
206
- key: '0',
207
- title: props.title || '<root>',
208
- children: data
209
- }],
210
- defaultExpandAll: true,
211
- switcherIcon: renderSwitcherIcon
212
- });
213
- });
@@ -1,159 +0,0 @@
1
- @import (reference) '../style/variables.less';
2
- @treePrefixCls: ~'rc-tree';
3
- @treeNodePrefixCls: ~'@{treePrefixCls}-treenode';
4
-
5
- .__dumi-site-tree {
6
- padding: 16px;
7
- background-color: @c-light-bg;
8
- border: 1px solid @c-border;
9
- border-radius: 2px;
10
-
11
- [data-prefers-color='dark'] & {
12
- color: @c-text-dark;
13
- background-color: @c-light-bg-dark;
14
- border-color: @c-border-dark;
15
- }
16
-
17
- small {
18
- padding-left: 24px;
19
- color: @c-secondary;
20
- font-size: 14px;
21
-
22
- [data-prefers-color='dark'] & {
23
- color: @c-secondary-dark;
24
- }
25
-
26
- &::before {
27
- content: '# ';
28
- }
29
- }
30
-
31
- &.@{treePrefixCls} {
32
- transition: all 0.3s;
33
- line-height: 1.5715;
34
- list-style: none;
35
- font-size: 14px;
36
-
37
- .@{treeNodePrefixCls} {
38
- position: relative;
39
- display: flex;
40
- align-items: flex-start;
41
- padding-bottom: 4px;
42
- &:before {
43
- position: absolute;
44
- top: 0;
45
- right: 0;
46
- bottom: 4px;
47
- left: 0;
48
- transition: background 0.3s;
49
- content: '';
50
- }
51
- &:hover:before {
52
- background: #f5f5f5;
53
-
54
- [data-prefers-color='dark'] & {
55
- background: @c-light-bg-dark;
56
- }
57
- }
58
- > * {
59
- z-index: 1;
60
- }
61
- }
62
-
63
- .@{treeNodePrefixCls} span.@{treePrefixCls}-switcher {
64
- display: flex;
65
- align-items: center;
66
- justify-content: center;
67
- width: 24px;
68
- height: 24px;
69
- margin-right: 2px;
70
- line-height: 24px;
71
- background: transparent;
72
- cursor: pointer;
73
- }
74
-
75
- .@{treeNodePrefixCls} .@{treePrefixCls}-node-content-wrapper {
76
- flex: auto;
77
- min-height: 24px;
78
- margin: 0;
79
- padding: 0 4px;
80
- line-height: 24px;
81
- cursor: pointer;
82
- .@{treePrefixCls}-iconEle {
83
- margin-right: 6px;
84
- vertical-align: 0;
85
- }
86
- }
87
-
88
- &.@{treePrefixCls}-show-line {
89
- .@{treePrefixCls}-indent {
90
- display: inline-block;
91
- height: 0;
92
- vertical-align: bottom;
93
-
94
- &-unit {
95
- position: relative;
96
- display: inline-block;
97
- width: 24px;
98
- height: 24px;
99
-
100
- &::before {
101
- position: absolute;
102
- top: 0;
103
- right: 12px;
104
- bottom: -4px;
105
- border-right: 1px solid #d9d9d9;
106
- content: '';
107
- }
108
-
109
- &-end::before {
110
- display: none;
111
- }
112
- }
113
- }
114
-
115
- .tree-switcher-leaf-line {
116
- position: relative;
117
- z-index: 1;
118
- display: inline-block;
119
- width: 100%;
120
- height: 100%;
121
- text-align: center;
122
- &::before {
123
- position: absolute;
124
- top: 0;
125
- bottom: -4px;
126
- margin-left: -1px;
127
- border-left: 1px solid #d9d9d9;
128
- content: ' ';
129
- }
130
-
131
- &::after {
132
- position: absolute;
133
- top: 0;
134
- bottom: 10px;
135
- width: 12px;
136
- margin-left: -1px;
137
- border-bottom: 1px solid #d9d9d9;
138
- content: ' ';
139
- }
140
- }
141
-
142
- .@{treeNodePrefixCls}-leaf-last {
143
- .tree-switcher-leaf-line::before {
144
- height: 14px;
145
- }
146
- }
147
- }
148
- }
149
-
150
- &-icon {
151
- width: 16px;
152
- color: @c-text;
153
- vertical-align: -0.225em;
154
-
155
- [data-prefers-color='dark'] & {
156
- color: @c-text-dark;
157
- }
158
- }
159
- }
@@ -1,9 +0,0 @@
1
- import type { FC } from 'react';
2
- import './Dark.less';
3
- interface darkProps {
4
- darkSwitch: boolean;
5
- isSideMenu: boolean;
6
- onDarkSwitchClick?: (ev: any) => void;
7
- }
8
- declare const Dark: FC<darkProps>;
9
- export default Dark;
@@ -1,125 +0,0 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
-
9
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
-
11
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
- import React from 'react';
14
- import { usePrefersColor } from 'dumi/theme';
15
- import './Dark.less';
16
- ;
17
-
18
- var Dark = function Dark(_ref) {
19
- var darkSwitch = _ref.darkSwitch,
20
- onDarkSwitchClick = _ref.onDarkSwitchClick,
21
- isSideMenu = _ref.isSideMenu;
22
- var allState = ['dark', 'light', 'auto'];
23
-
24
- var _usePrefersColor = usePrefersColor(),
25
- _usePrefersColor2 = _slicedToArray(_usePrefersColor, 2),
26
- color = _usePrefersColor2[0],
27
- setColor = _usePrefersColor2[1];
28
-
29
- var prefersColor = color;
30
- var sunSvg = /*#__PURE__*/React.createElement("svg", {
31
- viewBox: "0 0 1024 1024",
32
- version: "1.1",
33
- xmlns: "http://www.w3.org/2000/svg",
34
- "p-id": "4026",
35
- width: "22",
36
- height: "22"
37
- }, /*#__PURE__*/React.createElement("path", {
38
- d: "M915.2 476.16h-43.968c-24.704 0-44.736 16-44.736 35.84s20.032 35.904 44.736 35.904H915.2c24.768 0 44.8-16.064 44.8-35.904s-20.032-35.84-44.8-35.84zM512 265.6c-136.704 0-246.464 109.824-246.464 246.4 0 136.704 109.76 246.464 246.464 246.464S758.4 648.704 758.4 512c0-136.576-109.696-246.4-246.4-246.4z m0 425.6c-99.008 0-179.2-80.128-179.2-179.2 0-98.944 80.192-179.2 179.2-179.2S691.2 413.056 691.2 512c0 99.072-80.192 179.2-179.2 179.2zM197.44 512c0-19.84-19.136-35.84-43.904-35.84H108.8c-24.768 0-44.8 16-44.8 35.84s20.032 35.904 44.8 35.904h44.736c24.768 0 43.904-16.064 43.904-35.904zM512 198.464c19.776 0 35.84-20.032 35.84-44.8v-44.8C547.84 84.032 531.84 64 512 64s-35.904 20.032-35.904 44.8v44.8c0 24.768 16.128 44.864 35.904 44.864z m0 627.136c-19.776 0-35.904 20.032-35.904 44.8v44.736C476.096 940.032 492.16 960 512 960s35.84-20.032 35.84-44.8v-44.736c0-24.768-16.064-44.864-35.84-44.864z m329.92-592.832c17.472-17.536 20.288-43.072 6.4-57.024-14.016-14.016-39.488-11.2-57.024 6.336-4.736 4.864-26.496 26.496-31.36 31.36-17.472 17.472-20.288 43.008-6.336 57.024 13.952 14.016 39.488 11.2 57.024-6.336 4.8-4.864 26.496-26.56 31.296-31.36zM213.376 759.936c-4.864 4.8-26.56 26.624-31.36 31.36-17.472 17.472-20.288 42.944-6.4 56.96 14.016 13.952 39.552 11.2 57.024-6.336 4.8-4.736 26.56-26.496 31.36-31.36 17.472-17.472 20.288-43.008 6.336-56.96-14.016-13.952-39.552-11.072-56.96 6.336z m19.328-577.92c-17.536-17.536-43.008-20.352-57.024-6.336-14.08 14.016-11.136 39.488 6.336 57.024 4.864 4.864 26.496 26.56 31.36 31.424 17.536 17.408 43.008 20.288 56.96 6.336 14.016-14.016 11.264-39.488-6.336-57.024-4.736-4.864-26.496-26.56-31.296-31.424z m527.168 628.608c4.864 4.864 26.624 26.624 31.36 31.424 17.536 17.408 43.072 20.224 57.088 6.336 13.952-14.016 11.072-39.552-6.4-57.024-4.864-4.8-26.56-26.496-31.36-31.36-17.472-17.408-43.072-20.288-57.024-6.336-13.952 14.016-11.008 39.488 6.336 56.96z",
39
- "p-id": "4027"
40
- }));
41
- var moonSvg = /*#__PURE__*/React.createElement("svg", {
42
- viewBox: "0 0 1024 1024",
43
- version: "1.1",
44
- xmlns: "http://www.w3.org/2000/svg",
45
- "p-id": "3854",
46
- width: "22",
47
- height: "22"
48
- }, /*#__PURE__*/React.createElement("path", {
49
- d: "M991.816611 674.909091a69.166545 69.166545 0 0 0-51.665455-23.272727 70.795636 70.795636 0 0 0-27.438545 5.585454A415.674182 415.674182 0 0 1 754.993338 698.181818c-209.594182 0-393.472-184.785455-393.472-395.636363 0-52.363636 38.539636-119.621818 69.515637-173.614546 4.887273-8.610909 9.634909-16.756364 14.103272-24.901818A69.818182 69.818182 0 0 0 384.631156 0a70.842182 70.842182 0 0 0-27.438545 5.585455C161.678429 90.298182 14.362065 307.898182 14.362065 512c0 282.298182 238.824727 512 532.38691 512a522.286545 522.286545 0 0 0 453.957818-268.334545A69.818182 69.818182 0 0 0 991.816611 674.909091zM546.679156 954.181818c-248.785455 0-462.941091-192-462.941091-442.181818 0-186.647273 140.637091-372.829091 300.939637-442.181818-36.817455 65.629091-92.578909 151.970909-92.578909 232.727273 0 250.181818 214.109091 465.454545 462.917818 465.454545a488.331636 488.331636 0 0 0 185.181091-46.545455 453.003636 453.003636 0 0 1-393.565091 232.727273z m103.656728-669.323636l-14.266182 83.781818a34.909091 34.909091 0 0 0 50.362182 36.770909l74.775272-39.563636 74.752 39.563636a36.142545 36.142545 0 0 0 16.174546 3.956364 34.909091 34.909091 0 0 0 34.210909-40.727273l-14.289455-83.781818 60.509091-59.345455a35.025455 35.025455 0 0 0-19.223272-59.578182l-83.61891-12.101818-37.376-76.101818a34.56 34.56 0 0 0-62.254545 0l-37.376 76.101818-83.618909 12.101818a34.909091 34.909091 0 0 0-19.246546 59.578182z m70.423272-64.698182a34.280727 34.280727 0 0 0 26.135273-19.083636l14.312727-29.090909 14.336 29.090909a34.257455 34.257455 0 0 0 26.135273 19.083636l32.046546 4.887273-23.272728 22.574545a35.234909 35.234909 0 0 0-10.007272 30.952727l5.46909 32.116364-28.625454-15.127273a34.490182 34.490182 0 0 0-32.302546 0l-28.695272 15.127273 5.469091-32.116364a35.141818 35.141818 0 0 0-9.984-30.952727l-23.272728-22.574545z",
50
- "p-id": "3855"
51
- }));
52
- var autoSvg = /*#__PURE__*/React.createElement("svg", {
53
- viewBox: "0 0 1024 1024",
54
- version: "1.1",
55
- xmlns: "http://www.w3.org/2000/svg",
56
- "p-id": "11002",
57
- width: "22",
58
- height: "22"
59
- }, /*#__PURE__*/React.createElement("path", {
60
- d: "M127.658667 492.885333c0-51.882667 10.24-101.717333 30.378666-149.162666s47.786667-88.064 81.92-122.538667 75.093333-61.781333 122.538667-81.92 96.938667-30.378667 149.162667-30.378667 101.717333 10.24 149.162666 30.378667 88.405333 47.786667 122.88 81.92 61.781333 75.093333 81.92 122.538667 30.378667 96.938667 30.378667 149.162666-10.24 101.717333-30.378667 149.162667-47.786667 88.405333-81.92 122.88-75.093333 61.781333-122.88 81.92-97.28 30.378667-149.162666 30.378667-101.717333-10.24-149.162667-30.378667-88.064-47.786667-122.538667-81.92-61.781333-75.093333-81.92-122.88-30.378667-96.938667-30.378666-149.162667z m329.045333 0c0 130.048 13.994667 244.394667 41.984 343.381334h12.970667c46.762667 0 91.136-9.216 133.461333-27.306667s78.848-42.666667 109.568-73.386667 54.954667-67.242667 73.386667-109.568 27.306667-86.698667 27.306666-133.461333c0-46.421333-9.216-90.794667-27.306666-133.12s-42.666667-78.848-73.386667-109.568-67.242667-54.954667-109.568-73.386667-86.698667-27.306667-133.461333-27.306666h-11.605334c-28.672 123.562667-43.349333 237.909333-43.349333 343.722666z",
61
- "p-id": "11003"
62
- }));
63
- var list = allState.filter(function (state) {
64
- return state !== prefersColor;
65
- });
66
-
67
- var changeColor = function changeColor(ev, toColor) {
68
- if (!isSideMenu && onDarkSwitchClick) {
69
- onDarkSwitchClick(ev);
70
- }
71
-
72
- if (toColor === prefersColor) return;
73
- setColor(toColor);
74
- };
75
-
76
- var getSvg = function getSvg(baseColor) {
77
- switch (baseColor) {
78
- case 'dark':
79
- return /*#__PURE__*/React.createElement("button", {
80
- key: "dumi-dark-btn-moon",
81
- title: "Dark theme",
82
- onClick: function onClick(ev) {
83
- return changeColor(ev, baseColor);
84
- },
85
- className: "__dumi-default-dark-moon ".concat(baseColor === prefersColor ? '__dumi-default-dark-switch-active' : '')
86
- }, moonSvg);
87
-
88
- case 'light':
89
- return /*#__PURE__*/React.createElement("button", {
90
- key: "dumi-dark-btn-sun",
91
- title: "Light theme",
92
- onClick: function onClick(ev) {
93
- return changeColor(ev, baseColor);
94
- },
95
- className: "__dumi-default-dark-sun ".concat(baseColor === prefersColor ? '__dumi-default-dark-switch-active' : '')
96
- }, sunSvg);
97
-
98
- case 'auto':
99
- return /*#__PURE__*/React.createElement("button", {
100
- key: "dumi-dark-btn-auto",
101
- title: "Default to system",
102
- onClick: function onClick(ev) {
103
- return changeColor(ev, baseColor);
104
- },
105
- className: "__dumi-default-dark-auto ".concat(baseColor === prefersColor ? '__dumi-default-dark-switch-active' : '')
106
- }, autoSvg);
107
-
108
- default:
109
- }
110
- };
111
-
112
- return /*#__PURE__*/React.createElement("div", {
113
- className: "__dumi-default-dark"
114
- }, /*#__PURE__*/React.createElement("div", {
115
- className: "__dumi-default-dark-switch ".concat(!isSideMenu && darkSwitch ? "__dumi-default-dark-switch-open" : "")
116
- }, isSideMenu ? allState.map(function (item) {
117
- return getSvg(item);
118
- }) : getSvg(prefersColor)), !isSideMenu && darkSwitch && /*#__PURE__*/React.createElement("div", {
119
- className: "__dumi-default-dark-switch-list"
120
- }, list.map(function (item) {
121
- return getSvg(item);
122
- })));
123
- };
124
-
125
- export default Dark;
@@ -1,121 +0,0 @@
1
- @import (reference) '../style/variables.less';
2
-
3
- .@{prefix}-dark {
4
- position: fixed;
5
- right: 20px;
6
- top: 16px;
7
-
8
- [data-mode="doc"] & {
9
- position: relative;
10
- top: 0;
11
- right: 0;
12
- display: inline-block;
13
- }
14
-
15
- @media @mobile {
16
- position: relative;
17
- top: 6px;
18
- right: auto;
19
- display: flex;
20
- justify-content: center;
21
-
22
- .@{prefix}-navbar & {
23
- display: none;
24
- }
25
- }
26
-
27
- &-sun,
28
- &-moon,
29
- &-auto {
30
- position: relative;
31
- border-radius: 50%;
32
- outline: none;
33
- cursor: pointer;
34
- width: 30px;
35
- height: 30px;
36
- display: flex;
37
- justify-content: center;
38
- align-items: center;
39
-
40
- svg {
41
- transition: all 0.3s linear;
42
- &:hover {
43
- transform: scale(1.2);
44
- }
45
- }
46
- }
47
-
48
- &-sun,
49
- &-moon,
50
- &-auto {
51
- border: 1px solid @c-btn-border;
52
- background-color: @c-light-bg;
53
-
54
- svg {
55
- fill: @c-text;
56
- [data-prefers-color=dark] & {
57
- fill: @c-text-dark;
58
- }
59
- }
60
-
61
- [data-prefers-color=dark] & {
62
- border-color: @c-btn-border-dark;
63
- background-color: @c-bg-dark;
64
- }
65
- }
66
-
67
- &-switch {
68
- [data-mode=doc] & {
69
- display: flex;
70
- button + button {
71
- margin-left: 4px;
72
- }
73
- }
74
-
75
- @media @mobile {
76
- display: flex;
77
- button + button {
78
- margin-left: 10px;
79
- }
80
- }
81
-
82
- &-active {
83
- .@{prefix}-menu & {
84
- border-color: @c-primary;
85
- [data-prefers-color=dark] & {
86
- border-color: @c-primary-dark;
87
- }
88
- }
89
- }
90
-
91
- [data-mode=doc][data-mobile-show=true] & {
92
- margin-bottom: 10px;
93
- }
94
-
95
- button {
96
- z-index: 102;
97
- }
98
-
99
- &-list {
100
- animation: dropDown 0.2s linear 0s 1;
101
-
102
- button {
103
- z-index: 101;
104
- margin-top: 4px;
105
- }
106
-
107
- [data-mode="doc"] & {
108
- position: absolute;
109
- }
110
- }
111
- }
112
- }
113
-
114
- @keyframes dropDown {
115
- 0% {
116
- margin-top: -100%;
117
- }
118
- 100% {
119
- margin-top: 0;
120
- }
121
- }
@@ -1,6 +0,0 @@
1
- import type { FC } from 'react';
2
- import './LocaleSelect.less';
3
- declare const LocaleSelect: FC<{
4
- location: any;
5
- }>;
6
- export default LocaleSelect;
@@ -1,53 +0,0 @@
1
- import React, { useContext } from 'react'; // @ts-ignore
2
-
3
- import { history } from 'dumi';
4
- import { context, Link } from 'dumi/theme';
5
- import './LocaleSelect.less';
6
-
7
- var LocaleSelect = function LocaleSelect(_ref) {
8
- var location = _ref.location;
9
-
10
- var _useContext = useContext(context),
11
- base = _useContext.base,
12
- locale = _useContext.locale,
13
- locales = _useContext.config.locales;
14
-
15
- var firstDiffLocale = locales.find(function (_ref2) {
16
- var name = _ref2.name;
17
- return name !== locale;
18
- });
19
-
20
- function getLocaleTogglePath(target) {
21
- var baseWithoutLocale = base.replace("/".concat(locale), '');
22
- var pathnameWithoutLocale = location.pathname.replace(new RegExp("^".concat(base, "(/|$)")), "".concat(baseWithoutLocale, "$1")) || '/'; // append locale prefix to path if it is not the default locale
23
-
24
- if (target !== locales[0].name) {
25
- // compatiable with integrate route prefix /~docs
26
- var routePrefix = "".concat(baseWithoutLocale, "/").concat(target).replace(/\/\//, '/');
27
- var pathnameWithoutBase = location.pathname.replace( // to avoid stripped the first /
28
- base.replace(/^\/$/, '//'), '');
29
- return "".concat(routePrefix).concat(pathnameWithoutBase).replace(/\/$/, '');
30
- }
31
-
32
- return pathnameWithoutLocale;
33
- }
34
-
35
- return firstDiffLocale ? /*#__PURE__*/React.createElement("div", {
36
- className: "__dumi-default-locale-select",
37
- "data-locale-count": locales.length
38
- }, locales.length > 2 ? /*#__PURE__*/React.createElement("select", {
39
- value: locale,
40
- onChange: function onChange(ev) {
41
- return history.push(getLocaleTogglePath(ev.target.value));
42
- }
43
- }, locales.map(function (localeItem) {
44
- return /*#__PURE__*/React.createElement("option", {
45
- value: localeItem.name,
46
- key: localeItem.name
47
- }, localeItem.label);
48
- })) : /*#__PURE__*/React.createElement(Link, {
49
- to: getLocaleTogglePath(firstDiffLocale.name)
50
- }, firstDiffLocale.label)) : null;
51
- };
52
-
53
- export default LocaleSelect;