@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.
- package/dist/builtins/Playground/index.d.ts +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/layouts/entry/API.d.ts +1 -1
- package/dist/layouts/entry/Manual.d.ts +1 -1
- package/dist/locales/en.json +2 -1
- package/dist/locales/zh.json +2 -1
- package/dist/pages/Example/index.js +11 -3
- package/dist/slots/Banner/index.d.ts +1 -1
- package/dist/slots/CodeEditor/Toolbar.d.ts +1 -1
- package/dist/slots/CodeEditor/Toolbar.js +3 -3
- package/dist/slots/CodeEditor/index.d.ts +1 -1
- package/dist/slots/CodePreview/CodeHeader.d.ts +1 -1
- package/dist/slots/CodePreview/index.d.ts +1 -1
- package/dist/slots/CodeRunner/index.d.ts +1 -1
- package/dist/slots/Companies/index.d.ts +1 -1
- package/dist/slots/ContentTable/index.d.ts +1 -1
- package/dist/slots/Detail/index.d.ts +2 -2
- package/dist/slots/Header/Navs.d.ts +3 -3
- package/dist/slots/Header/Navs.js +3 -1
- package/dist/slots/Header/Products/getProducts.d.ts +2 -2
- package/dist/slots/Header/Search/SearchResult.d.ts +2 -2
- package/dist/slots/Header/Search/SearchResult.js +13 -2
- package/dist/slots/Header/Search/SearchResult.module.less +10 -0
- package/dist/slots/Header/Search/index.js +8 -3
- package/dist/slots/Header/index.d.ts +1 -1
- package/dist/slots/Header/index.js +70 -23
- package/dist/slots/Header/index.module.less +7 -0
- package/dist/slots/ManualContent/Preview.d.ts +1 -1
- package/dist/slots/ManualContent/index.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ExampleTopic } from './types';
|
|
3
|
-
export
|
|
3
|
+
export type IThemeAntVContext = {
|
|
4
4
|
exampleTopics?: ExampleTopic[];
|
|
5
5
|
};
|
|
6
6
|
export declare const ThemeAntVContext: import("react").Context<IThemeAntVContext>;
|
package/dist/locales/en.json
CHANGED
package/dist/locales/zh.json
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
4
|
+
type BannerButtonShape = 'round' | 'square';
|
|
5
5
|
interface BannerButton {
|
|
6
6
|
text: string;
|
|
7
7
|
link: string;
|
|
@@ -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
|
-
|
|
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,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IC } from '../../types';
|
|
3
3
|
import { NewsProps } from './News';
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
22
|
+
export type ProductType = {
|
|
23
23
|
links: {
|
|
24
24
|
/** 产品首页 */
|
|
25
25
|
readonly home?: {
|
|
@@ -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
|
};
|
|
@@ -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
|
-
|
|
26
|
-
|
|
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;
|
|
@@ -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
|
-
|
|
84
|
-
|
|
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
|
|
98
|
-
|
|
99
|
-
lang =
|
|
100
|
-
setLang =
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
productMenuVisible =
|
|
104
|
-
setProductMenuVisible =
|
|
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
|
|
129
|
-
|
|
130
|
-
popupMenuVisible =
|
|
131
|
-
setPopupMenuVisible =
|
|
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 (
|
|
184
|
-
var url =
|
|
185
|
-
ecosystemName =
|
|
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(
|
|
315
|
-
var 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(
|
|
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
|
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export interface IThemeConfig {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}
|
|
4
|
-
export
|
|
4
|
+
export type Status = 'responded' | 'error' | 'timeout';
|
|
5
5
|
/**
|
|
6
6
|
* 配置文件中的国际化配置
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type IC = string | {
|
|
9
9
|
zh: string;
|
|
10
10
|
en: string;
|
|
11
11
|
};
|