@antv/dumi-theme-antv 0.3.18 → 0.3.20

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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare type PlaygroundProps = {
2
+ export type PlaygroundProps = {
3
3
  /**
4
4
  * 代码示例的地址
5
5
  */
package/dist/context.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ExampleTopic } from './types';
3
- export declare type IThemeAntVContext = {
3
+ export type IThemeAntVContext = {
4
4
  exampleTopics?: ExampleTopic[];
5
5
  };
6
6
  export declare const ThemeAntVContext: import("react").Context<IThemeAntVContext>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare type APIProps = {
2
+ export type APIProps = {
3
3
  readonly children: any;
4
4
  };
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare type ManualProps = {
2
+ export type ManualProps = {
3
3
  readonly children: any;
4
4
  };
5
5
  /**
@@ -94,5 +94,6 @@
94
94
  "下一篇":"Next",
95
95
  "演示代码报错,请检查": "演示代码报错,请检查",
96
96
  "阅读时间约":"Reading needs",
97
- "分钟":"minutes"
97
+ "分钟":"minutes",
98
+ "没有找到查询结果":"No query result found"
98
99
  }
@@ -94,5 +94,6 @@
94
94
  "下一篇": "下一篇",
95
95
  "演示代码报错,请检查": "演示代码报错,请检查",
96
96
  "阅读时间约":"阅读时间约",
97
- "分钟":"分钟"
97
+ "分钟":"分钟",
98
+ "没有找到查询结果":"没有找到查询结果"
98
99
  }
@@ -6,8 +6,8 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { Layout } from 'antd';
8
8
  import { useLocale, useSiteData } from 'dumi';
9
- import { get } from 'lodash-es';
10
- import React, { useContext, useEffect, useState } from 'react';
9
+ import { get, find } from 'lodash-es';
10
+ import React, { useContext, useEffect, useState, useMemo } from 'react';
11
11
  import { useLocation, useNavigate, useParams } from 'react-router-dom';
12
12
  import { ThemeAntVContext } from "../../context";
13
13
  import { CodeRunner } from "dumi/theme/slots/CodeRunner";
@@ -35,7 +35,15 @@ var Example = function Example() {
35
35
  var _useSiteData = useSiteData(),
36
36
  themeConfig = _useSiteData.themeConfig;
37
37
  var exampleTopics = metaData.meta.exampleTopics;
38
- var demo = hash.slice(1);
38
+ var demo = useMemo(function () {
39
+ var examples = get(exampleTopics, ['0', 'examples']);
40
+ var exampleDemo = find(examples, function (_ref) {
41
+ var id = _ref.id;
42
+ return id === example;
43
+ });
44
+ // examples/case/id hash 为空,可以默认第一个 example 对应的 demo
45
+ return hash.slice(1) || get(exampleDemo, ['demos', '0', 'id']);
46
+ }, [hash, exampleTopics, example]);
39
47
  var _useState = useState(),
40
48
  _useState2 = _slicedToArray(_useState, 2),
41
49
  currentDemo = _useState2[0],
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { NotificationProps } from './Notification';
3
3
  import 'video-react/dist/video-react.css';
4
- declare type BannerButtonShape = 'round' | 'square';
4
+ type BannerButtonShape = 'round' | 'square';
5
5
  interface BannerButton {
6
6
  text: string;
7
7
  link: string;
@@ -4,7 +4,7 @@ export declare enum EDITOR_TABS {
4
4
  SPEC = "Spec",
5
5
  DATA = "Data"
6
6
  }
7
- declare type ToolbarProps = {
7
+ type ToolbarProps = {
8
8
  /**
9
9
  * 源码文件,用于传入到三方代码平台
10
10
  */
@@ -20,12 +20,12 @@ import { ping } from "../utils";
20
20
  import { extractImportDeps, getCodeSandboxConfig, getRiddleConfig, getStackblitzConfig } from "./utils";
21
21
  import styles from "./Toolbar.module.less";
22
22
  var Paragraph = Typography.Paragraph;
23
- export var EDITOR_TABS;
24
- (function (EDITOR_TABS) {
23
+ export var EDITOR_TABS = /*#__PURE__*/function (EDITOR_TABS) {
25
24
  EDITOR_TABS["JAVASCRIPT"] = "JavaScript";
26
25
  EDITOR_TABS["SPEC"] = "Spec";
27
26
  EDITOR_TABS["DATA"] = "Data";
28
- })(EDITOR_TABS || (EDITOR_TABS = {}));
27
+ return EDITOR_TABS;
28
+ }({});
29
29
  export var Toolbar = function Toolbar(_ref) {
30
30
  var sourceCode = _ref.sourceCode,
31
31
  fileExtension = _ref.fileExtension,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare type CodeEditorProps = {
2
+ export type CodeEditorProps = {
3
3
  /**
4
4
  * 标题
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare type CodeHeaderProps = {
2
+ export type CodeHeaderProps = {
3
3
  /**
4
4
  * 代码的标题
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare type CodePreviewProps = {
2
+ export type CodePreviewProps = {
3
3
  /**
4
4
  * 在文档中预览
5
5
  */
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ExampleTopic } from '../../types';
3
- declare type CodeRunnerProps = {
3
+ type CodeRunnerProps = {
4
4
  isPlayground?: boolean;
5
5
  topic: string;
6
6
  example: string;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type Company = {
2
+ type Company = {
3
3
  name: string;
4
4
  img: string;
5
5
  };
@@ -3,4 +3,4 @@ import './index.module.less';
3
3
  /**
4
4
  * 文档右侧的指示器(table of content)
5
5
  */
6
- export declare const ContentTable: React.FC<{}>;
6
+ export declare const ContentTable: React.FC;
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
2
  import { IC } from '../../types';
3
3
  import { NewsProps } from './News';
4
- declare type DetailButtonProps = {
4
+ type DetailButtonProps = {
5
5
  text: IC;
6
6
  link: string;
7
7
  style?: React.CSSProperties;
8
8
  type?: string;
9
9
  shape?: 'round' | 'square';
10
10
  };
11
- declare type DetailProps = {
11
+ type DetailProps = {
12
12
  className?: string;
13
13
  style?: React.CSSProperties;
14
14
  title: IC;
@@ -1,12 +1,12 @@
1
1
  import React from 'react';
2
- declare type dropdownItem = {
2
+ type dropdownItem = {
3
3
  name: {
4
4
  [key: string]: string;
5
5
  };
6
6
  url: string;
7
7
  target?: '_blank';
8
8
  };
9
- export declare type INav = {
9
+ export type INav = {
10
10
  slug?: string;
11
11
  order: number;
12
12
  title: {
@@ -16,7 +16,7 @@ export declare type INav = {
16
16
  notPage?: boolean;
17
17
  dropdownItems?: dropdownItem[];
18
18
  };
19
- export declare type NavProps = {
19
+ export type NavProps = {
20
20
  navs: INav[];
21
21
  path: string;
22
22
  };
@@ -23,10 +23,12 @@ export var Navs = function Navs(_ref) {
23
23
  var className = '';
24
24
  if (nav.slug) {
25
25
  href = nav.slug.startsWith('http') ? nav.slug : "/".concat(nav.slug);
26
+
27
+ // 去除 docs 防止新页面 404 和 本页重新刷新。
28
+ href = href.replace(/^\/docs(?=\/)/, '');
26
29
  if (locale.id == 'en' && !href.startsWith('http')) {
27
30
  href = "/en".concat(href);
28
31
  }
29
- // 去除 docs 防止二次点击相同 nav 跳转出现04
30
32
  className = cx('header-menu-item-active', _defineProperty({}, styles.activeItem, getNavCategory(path) === getNavCategory(href)));
31
33
  }
32
34
  return size(nav.dropdownItems) ? /*#__PURE__*/React.createElement("li", {
@@ -13,13 +13,13 @@ export interface ProductItem {
13
13
  openExternal?: boolean;
14
14
  }>;
15
15
  }
16
- export declare type ValuesOf<T extends any[]> = T[number];
16
+ export type ValuesOf<T extends any[]> = T[number];
17
17
  declare const CATEGORY_TYPE: ["basic", "extension", "mobile", "ecology"];
18
18
  export declare const CATEGORIES: Array<{
19
19
  type: typeof CATEGORY_TYPE[number];
20
20
  name: string;
21
21
  }>;
22
- export declare type ProductType = {
22
+ export type ProductType = {
23
23
  links: {
24
24
  /** 产品首页 */
25
25
  readonly home?: {
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- export declare type ITextSegment = {
2
+ export type ITextSegment = {
3
3
  text: string;
4
4
  highlighted?: boolean;
5
5
  };
6
- export declare type ISearchResult = {
6
+ export type ISearchResult = {
7
7
  /**
8
8
  * 搜索结果的主题,显示在最左边,一般是页面的标题。
9
9
  */
@@ -1,4 +1,6 @@
1
1
  import React from 'react';
2
+ import { useIntl } from 'dumi';
3
+ import { InboxOutlined } from '@ant-design/icons';
2
4
  import styles from "./SearchResult.module.less";
3
5
  var getHighlightInfo = function getHighlightInfo(textSegments) {
4
6
  return /*#__PURE__*/React.createElement(React.Fragment, null, textSegments.map(function (segment) {
@@ -14,9 +16,10 @@ var getHighlightInfo = function getHighlightInfo(textSegments) {
14
16
  */
15
17
  export var SearchResult = function SearchResult(_ref) {
16
18
  var results = _ref.results;
19
+ var intl = useIntl();
17
20
  return /*#__PURE__*/React.createElement("div", {
18
21
  className: styles.searchResult
19
- }, results.map(function (r) {
22
+ }, results !== null && results !== void 0 && results.length ? results.map(function (r) {
20
23
  return /*#__PURE__*/React.createElement("div", {
21
24
  className: styles.item
22
25
  }, /*#__PURE__*/React.createElement("div", {
@@ -31,5 +34,13 @@ export var SearchResult = function SearchResult(_ref) {
31
34
  }, getHighlightInfo(r.tilte)), /*#__PURE__*/React.createElement("div", {
32
35
  className: styles.description
33
36
  }, getHighlightInfo(r.description))));
34
- }));
37
+ }) : /*#__PURE__*/React.createElement("div", {
38
+ className: styles.empty
39
+ }, /*#__PURE__*/React.createElement(InboxOutlined, {
40
+ style: {
41
+ fontSize: 20
42
+ }
43
+ }), /*#__PURE__*/React.createElement("div", null, intl.formatMessage({
44
+ id: '没有找到查询结果'
45
+ }))));
35
46
  };
@@ -62,4 +62,14 @@
62
62
  }
63
63
  }
64
64
  }
65
+
66
+ .empty {
67
+ height: 70px;
68
+ display: flex;
69
+ flex-direction: column;
70
+ align-items: center;
71
+ justify-content: space-evenly;
72
+ color: rgb(160, 161, 167);
73
+ font-size: 16px;
74
+ }
65
75
  }
@@ -17,13 +17,18 @@ export var Search = function Search() {
17
17
  _useState2 = _slicedToArray(_useState, 2),
18
18
  open = _useState2[0],
19
19
  setOpen = _useState2[1];
20
+ // useSiteSearch 错误 keywords 为空时 loading 为 true
20
21
  var _useSiteSearch = useSiteSearch(),
21
22
  keywords = _useSiteSearch.keywords,
22
23
  setKeywords = _useSiteSearch.setKeywords,
23
- result = _useSiteSearch.result;
24
+ result = _useSiteSearch.result,
25
+ loading = _useSiteSearch.loading;
24
26
  useEffect(function () {
25
- setOpen(!!(result !== null && result !== void 0 && result.length));
26
- }, [result]);
27
+ // keywords 为空 loading false 查找结束, 进行开关
28
+ if (!keywords || !loading) {
29
+ setOpen(!!keywords);
30
+ }
31
+ }, [keywords, loading]);
27
32
  useEffect(function () {
28
33
  var close = function close(e) {
29
34
  var _e$target;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { INav } from './Navs';
3
- export declare type HeaderProps = {
3
+ export type HeaderProps = {
4
4
  pathPrefix?: string;
5
5
  /** 子标题 */
6
6
  subTitle?: React.ReactNode;
@@ -17,7 +17,7 @@ import { useNavigate } from "react-router-dom";
17
17
  import cx from 'classnames';
18
18
  import { useSiteData, useLocale, FormattedMessage } from 'dumi';
19
19
  import { GithubOutlined, MenuOutlined, CaretDownFilled, DownOutlined, WechatOutlined, LinkOutlined, CheckOutlined } from '@ant-design/icons';
20
- import { Modal, Button, Popover, Menu, Dropdown, Select } from 'antd';
20
+ import { Alert, Modal, Button, Popover, Menu, Dropdown, Select } from 'antd';
21
21
  import { get, map, size } from 'lodash-es';
22
22
  import { Search } from "./Search";
23
23
  import { Products } from "./Products";
@@ -30,6 +30,13 @@ import styles from "./index.module.less";
30
30
  function redirectChinaMirror(chinaMirrorOrigin) {
31
31
  window.location.href = window.location.href.replace(window.location.origin, chinaMirrorOrigin);
32
32
  }
33
+ function fetchBanner() {
34
+ return fetch('https://assets.antv.antgroup.com/antv/banner.json' // 生产环境
35
+ // 'https://site-data-pre.alipay.com/antv/banner.json', // 预发测试
36
+ ).then(function (res) {
37
+ return res.json();
38
+ });
39
+ }
33
40
 
34
41
  /**
35
42
  * 头部菜单
@@ -76,12 +83,40 @@ var HeaderComponent = function HeaderComponent(_ref) {
76
83
  searchOptions = _ref.searchOptions;
77
84
  var isAntVHome = isAntVSite && isHomePage; // 是否为AntV官网首页
78
85
 
79
- var showChinaMirror = !!internalSite;
80
- var chinaMirrorUrl = get(internalSite, 'url');
81
86
  var _useState = useState(false),
82
87
  _useState2 = _slicedToArray(_useState, 2),
83
- chinaMirrorHintVisible = _useState2[0],
84
- updateChinaMirrorHintVisible = _useState2[1];
88
+ bannerVisible = _useState2[0],
89
+ setBannerVisible = _useState2[1];
90
+ var _useState3 = useState(null),
91
+ _useState4 = _slicedToArray(_useState3, 2),
92
+ banner = _useState4[0],
93
+ setBanner = _useState4[1];
94
+ useEffect(function () {
95
+ fetchBanner().then(function (_ref2) {
96
+ var id = _ref2.id,
97
+ html = _ref2.html;
98
+ if (id && html) {
99
+ setBanner({
100
+ id: id,
101
+ html: html
102
+ });
103
+ setBannerVisible(localStorage.getItem(id) !== 'x');
104
+ }
105
+ }).catch(function () {
106
+ setBanner(null);
107
+ setBannerVisible(false);
108
+ });
109
+ }, []);
110
+ function onBannerClose() {
111
+ localStorage.setItem(banner.id, 'x');
112
+ setBannerVisible(false);
113
+ }
114
+ var showChinaMirror = !!internalSite;
115
+ var chinaMirrorUrl = get(internalSite, 'url');
116
+ var _useState5 = useState(false),
117
+ _useState6 = _slicedToArray(_useState5, 2),
118
+ chinaMirrorHintVisible = _useState6[0],
119
+ updateChinaMirrorHintVisible = _useState6[1];
85
120
  useEffect(function () {
86
121
  var timeout = setTimeout(function () {
87
122
  if (showChinaMirror && lang === 'zh' && !localStorage.getItem('china-mirror-no-more-hint') && window.location.host.includes('antv.vision')) {
@@ -94,14 +129,14 @@ var HeaderComponent = function HeaderComponent(_ref) {
94
129
  });
95
130
  var locale = useLocale();
96
131
  var nav = useNavigate();
97
- var _useState3 = useState(locale.id),
98
- _useState4 = _slicedToArray(_useState3, 2),
99
- lang = _useState4[0],
100
- setLang = _useState4[1];
101
- var _useState5 = useState(false),
102
- _useState6 = _slicedToArray(_useState5, 2),
103
- productMenuVisible = _useState6[0],
104
- setProductMenuVisible = _useState6[1];
132
+ var _useState7 = useState(locale.id),
133
+ _useState8 = _slicedToArray(_useState7, 2),
134
+ lang = _useState8[0],
135
+ setLang = _useState8[1];
136
+ var _useState9 = useState(false),
137
+ _useState10 = _slicedToArray(_useState9, 2),
138
+ productMenuVisible = _useState10[0],
139
+ setProductMenuVisible = _useState10[1];
105
140
  var productMenuHovering = false;
106
141
  var onProductMouseEnter = function onProductMouseEnter(e) {
107
142
  productMenuHovering = true;
@@ -125,10 +160,10 @@ var HeaderComponent = function HeaderComponent(_ref) {
125
160
  var onToggleProductMenuVisible = function onToggleProductMenuVisible() {
126
161
  setProductMenuVisible(!productMenuVisible);
127
162
  };
128
- var _useState7 = useState(false),
129
- _useState8 = _slicedToArray(_useState7, 2),
130
- popupMenuVisible = _useState8[0],
131
- setPopupMenuVisible = _useState8[1];
163
+ var _useState11 = useState(false),
164
+ _useState12 = _slicedToArray(_useState11, 2),
165
+ popupMenuVisible = _useState12[0],
166
+ setPopupMenuVisible = _useState12[1];
132
167
  var onTogglePopupMenuVisible = function onTogglePopupMenuVisible() {
133
168
  setPopupMenuVisible(!popupMenuVisible);
134
169
  };
@@ -180,9 +215,9 @@ var HeaderComponent = function HeaderComponent(_ref) {
180
215
  }) : null, /** 生态产品 */
181
216
  size(ecosystems) ? /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement(Dropdown, {
182
217
  className: styles.ecoSystems,
183
- overlay: /*#__PURE__*/React.createElement(Menu, null, map(ecosystems, function (_ref2) {
184
- var url = _ref2.url,
185
- ecosystemName = _ref2.name;
218
+ overlay: /*#__PURE__*/React.createElement(Menu, null, map(ecosystems, function (_ref3) {
219
+ var url = _ref3.url,
220
+ ecosystemName = _ref3.name;
186
221
  return /*#__PURE__*/React.createElement(Menu.Item, {
187
222
  key: ecosystemName === null || ecosystemName === void 0 ? void 0 : ecosystemName[lang]
188
223
  }, /*#__PURE__*/React.createElement("a", {
@@ -311,8 +346,8 @@ var HeaderComponent = function HeaderComponent(_ref) {
311
346
  overlay: /*#__PURE__*/React.createElement(Menu, {
312
347
  defaultSelectedKeys: [lang],
313
348
  selectable: true,
314
- onSelect: function onSelect(_ref3) {
315
- var key = _ref3.key;
349
+ onSelect: function onSelect(_ref4) {
350
+ var key = _ref4.key;
316
351
  if (key === lang) {
317
352
  return;
318
353
  }
@@ -382,7 +417,19 @@ var HeaderComponent = function HeaderComponent(_ref) {
382
417
  }, /*#__PURE__*/React.createElement(GithubOutlined, null))));
383
418
  return /*#__PURE__*/React.createElement("header", {
384
419
  className: cx(styles.header, (_cx4 = {}, _defineProperty(_cx4, styles.transparent, !!transparent && !productMenuVisible), _defineProperty(_cx4, styles.isHomePage, !!isHomePage && !isAntVHome), _defineProperty(_cx4, styles.lightTheme, !!isAntVHome && !productMenuVisible && isWide), _defineProperty(_cx4, styles.fixed, popupMenuVisible), _cx4))
385
- }, /*#__PURE__*/React.createElement("div", {
420
+ }, bannerVisible && /*#__PURE__*/React.createElement(Alert, {
421
+ className: styles.banner,
422
+ message: /*#__PURE__*/React.createElement("div", {
423
+ dangerouslySetInnerHTML: {
424
+ __html: banner.html
425
+ }
426
+ }),
427
+ type: "info",
428
+ banner: true,
429
+ closable: true,
430
+ showIcon: false,
431
+ onClose: onBannerClose
432
+ }), /*#__PURE__*/React.createElement("div", {
386
433
  className: styles.container
387
434
  }, /*#__PURE__*/React.createElement("div", {
388
435
  className: styles.left
@@ -67,6 +67,13 @@
67
67
  }
68
68
  }
69
69
 
70
+ .banner {
71
+ width: 100%;
72
+ background: #daf5eb;
73
+ text-align: center;
74
+ word-break: keep-all;
75
+ }
76
+
70
77
  .left {
71
78
  display: flex;
72
79
  align-items: center;
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- export declare type PreviewProps = {
2
+ export type PreviewProps = {
3
3
  source: string;
4
4
  pin: boolean;
5
5
  code: HTMLDivElement;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import 'rc-drawer/assets/index.css';
3
- export declare type ManualContent = {
3
+ export type ManualContent = {
4
4
  readonly children: any;
5
5
  };
6
6
  /**
package/dist/types.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export interface IThemeConfig {
2
2
  [key: string]: any;
3
3
  }
4
- export declare type Status = 'responded' | 'error' | 'timeout';
4
+ export type Status = 'responded' | 'error' | 'timeout';
5
5
  /**
6
6
  * 配置文件中的国际化配置
7
7
  */
8
- export declare type IC = string | {
8
+ export type IC = string | {
9
9
  zh: string;
10
10
  en: string;
11
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "types": "dist/types.d.ts",
6
6
  "scripts": {