dumi 2.0.0-beta.2 → 2.0.0-beta.5
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/assetParsers/atom.d.ts +21 -0
- package/dist/assetParsers/atom.js +112 -0
- package/dist/assetParsers/block.d.ts +1 -4
- package/dist/assetParsers/block.js +2 -12
- package/dist/client/theme-api/DumiDemo.js +1 -1
- package/dist/client/theme-api/DumiPage.d.ts +4 -0
- package/dist/client/theme-api/DumiPage.js +39 -0
- package/dist/client/theme-api/context.d.ts +2 -0
- package/dist/client/theme-api/context.js +1 -0
- package/dist/client/theme-api/index.d.ts +3 -1
- package/dist/client/theme-api/index.js +3 -1
- package/dist/client/theme-api/types.d.ts +14 -1
- package/dist/client/theme-api/useAtomAssets.d.ts +4 -0
- package/dist/client/theme-api/useAtomAssets.js +9 -0
- package/dist/client/theme-api/useSidebarData.js +4 -2
- package/dist/features/compile.js +2 -1
- package/dist/features/configPlugins/schema.js +3 -2
- package/dist/features/meta.d.ts +2 -0
- package/dist/features/meta.js +53 -19
- package/dist/features/parser.d.ts +3 -0
- package/dist/features/parser.js +66 -0
- package/dist/features/routes.js +15 -5
- package/dist/features/tabs.d.ts +5 -0
- package/dist/features/tabs.js +106 -0
- package/dist/features/theme/index.js +2 -1
- package/dist/loaders/markdown/index.js +4 -9
- package/dist/loaders/markdown/transformer/rehypeJsxify.js +1 -1
- package/dist/loaders/markdown/transformer/remarkMeta.js +7 -2
- package/dist/loaders/page/index.d.ts +1 -0
- package/dist/loaders/page/index.js +41 -0
- package/dist/preset.js +3 -1
- package/dist/types.d.ts +7 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +18 -2
- package/package.json +3 -2
- package/theme-default/builtins/API/index.d.ts +5 -0
- package/theme-default/builtins/API/index.js +57 -0
- package/theme-default/locales/en-US.json +9 -1
- package/theme-default/locales/zh-CN.json +9 -1
- package/theme-default/slots/Content/index.less +19 -1
- package/theme-default/slots/ContentTabs/index.d.ts +11 -0
- package/theme-default/slots/ContentTabs/index.js +35 -0
- package/theme-default/slots/ContentTabs/index.less +57 -0
- package/theme-default/styles/variables.less +1 -0
- package/dist/client/tsconfig.json +0 -13
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/features/tabs.ts
|
|
23
|
+
var tabs_exports = {};
|
|
24
|
+
__export(tabs_exports, {
|
|
25
|
+
default: () => tabs_default,
|
|
26
|
+
getTabKeyFromFile: () => getTabKeyFromFile,
|
|
27
|
+
isTabRouteFile: () => isTabRouteFile
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(tabs_exports);
|
|
30
|
+
var import_utils = require("@umijs/core/dist/route/utils");
|
|
31
|
+
var import_path = __toESM(require("path"));
|
|
32
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
33
|
+
var import_meta = require("./meta");
|
|
34
|
+
function isTabRouteFile(file) {
|
|
35
|
+
return file.includes("$tab-");
|
|
36
|
+
}
|
|
37
|
+
function getTabKeyFromFile(file) {
|
|
38
|
+
return file.match(/\$tab-([^.]+)/)[1];
|
|
39
|
+
}
|
|
40
|
+
var tabs_default = (api) => {
|
|
41
|
+
const tabs = [];
|
|
42
|
+
api.describe({ key: void 0 });
|
|
43
|
+
api.modifyRoutes((routes) => {
|
|
44
|
+
tabs.length = 0;
|
|
45
|
+
Object.values(routes).forEach((route) => {
|
|
46
|
+
if (isTabRouteFile(route.file)) {
|
|
47
|
+
delete routes[route.id];
|
|
48
|
+
const rtlFile = (0, import_plugin_utils.winPath)(import_path.default.relative(api.cwd, route.file));
|
|
49
|
+
const routeId = (0, import_utils.createRouteId)(rtlFile);
|
|
50
|
+
const tabKey = getTabKeyFromFile(rtlFile);
|
|
51
|
+
const parentFile = route.file.replace(/\$tab-[^.]+\./, "");
|
|
52
|
+
tabs.push({
|
|
53
|
+
index: tabs.length,
|
|
54
|
+
key: tabKey,
|
|
55
|
+
id: `${routeId}`,
|
|
56
|
+
file: route.file,
|
|
57
|
+
parentFile
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return routes;
|
|
62
|
+
});
|
|
63
|
+
api.register({
|
|
64
|
+
key: "dumi.modifyMetaFiles",
|
|
65
|
+
fn: (metaFiles) => {
|
|
66
|
+
const tabsMapping = tabs.reduce((ret, tab) => ({
|
|
67
|
+
...ret,
|
|
68
|
+
[tab.parentFile]: [...ret[tab.parentFile] || [], tab]
|
|
69
|
+
}), {});
|
|
70
|
+
Object.values(metaFiles).forEach((metaFile) => {
|
|
71
|
+
if (tabsMapping[metaFile.file]) {
|
|
72
|
+
metaFile.tabs = JSON.stringify(tabsMapping[metaFile.file].map(({ id }) => id));
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
tabs.forEach((tab) => {
|
|
76
|
+
metaFiles.push({
|
|
77
|
+
id: tab.id,
|
|
78
|
+
file: tab.file,
|
|
79
|
+
index: metaFiles.length
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
return metaFiles;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
api.onGenerateFiles(() => {
|
|
86
|
+
api.writeTmpFile({
|
|
87
|
+
noPluginDir: true,
|
|
88
|
+
path: import_meta.TABS_META_PATH,
|
|
89
|
+
content: import_plugin_utils.Mustache.render(`{{#tabs}}
|
|
90
|
+
import * as tab{{{index}}} from '{{{file}}}';
|
|
91
|
+
{{/tabs}}
|
|
92
|
+
|
|
93
|
+
export const tabs = {
|
|
94
|
+
{{#tabs}}
|
|
95
|
+
'{{{id}}}': { key: '{{{key}}}', components: tab{{{index}}} },
|
|
96
|
+
{{/tabs}}
|
|
97
|
+
}
|
|
98
|
+
`, { tabs })
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
getTabKeyFromFile,
|
|
105
|
+
isTabRouteFile
|
|
106
|
+
});
|
|
@@ -109,7 +109,7 @@ export { default } from '${item.source}';`
|
|
|
109
109
|
content: `import React, { useState, useEffect } from 'react';
|
|
110
110
|
import { useOutlet, history } from 'dumi';
|
|
111
111
|
import { SiteContext } from '${(0, import_plugin_utils.winPath)(require.resolve("../../client/theme-api/context"))}';
|
|
112
|
-
import { demos } from '../meta';
|
|
112
|
+
import { demos, components } from '../meta';
|
|
113
113
|
import { locales } from '../locales/config';
|
|
114
114
|
|
|
115
115
|
export default function DumiContextWrapper() {
|
|
@@ -124,6 +124,7 @@ export default function DumiContextWrapper() {
|
|
|
124
124
|
return (
|
|
125
125
|
<SiteContext.Provider value={{
|
|
126
126
|
demos,
|
|
127
|
+
components,
|
|
127
128
|
locales,
|
|
128
129
|
loading,
|
|
129
130
|
setLoading,
|
|
@@ -71,20 +71,15 @@ export const toc = {{{toc}}}
|
|
|
71
71
|
}
|
|
72
72
|
}));
|
|
73
73
|
} else {
|
|
74
|
+
const isFragment = Boolean(this.resourcePath.includes("$tab-") || this.resourceQuery);
|
|
74
75
|
cb(null, `${Object.values(opts.builtins).map((item) => `import ${item.specifier} from '${item.source}';`).join("\n")}
|
|
75
|
-
import React
|
|
76
|
-
import {
|
|
76
|
+
import React from 'react';${isFragment ? "" : `
|
|
77
|
+
import { DumiPage } from 'dumi'`}
|
|
77
78
|
|
|
78
79
|
// export named function for fastRefresh
|
|
79
80
|
// ref: https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/docs/TROUBLESHOOTING.md#edits-always-lead-to-full-reload
|
|
80
81
|
function DumiMarkdownContent() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
setLoading(false);
|
|
85
|
-
}, []);
|
|
86
|
-
|
|
87
|
-
return ${ret.content};
|
|
82
|
+
return ${isFragment ? ret.content : `<DumiPage>${ret.content}</DumiPage>`};
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
export default DumiMarkdownContent;`);
|
|
@@ -25,6 +25,7 @@ __export(remarkMeta_exports, {
|
|
|
25
25
|
default: () => remarkMeta
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(remarkMeta_exports);
|
|
28
|
+
var import_tabs = require("../../../features/tabs");
|
|
28
29
|
var import_js_yaml = __toESM(require("js-yaml"));
|
|
29
30
|
var import_path = __toESM(require("path"));
|
|
30
31
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
@@ -52,8 +53,12 @@ function remarkMeta(opts) {
|
|
|
52
53
|
});
|
|
53
54
|
},
|
|
54
55
|
() => {
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
if ((0, import_tabs.isTabRouteFile)(opts.fileAbsPath)) {
|
|
57
|
+
vFile.data.frontmatter.title = import_plugin_utils.lodash.startCase((0, import_tabs.getTabKeyFromFile)(opts.fileAbsPath));
|
|
58
|
+
} else {
|
|
59
|
+
const pathWithoutIndex = opts.fileAbsPath.replace(/(\/index([^/]+)?)?\.md$/, "");
|
|
60
|
+
vFile.data.frontmatter.title = import_plugin_utils.lodash.startCase(import_path.default.basename(pathWithoutIndex));
|
|
61
|
+
}
|
|
57
62
|
}
|
|
58
63
|
];
|
|
59
64
|
while (!vFile.data.frontmatter.title && titleReaders.length) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function pageMetaLoader(this: any, raw: string): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/loaders/page/index.ts
|
|
23
|
+
var page_exports = {};
|
|
24
|
+
__export(page_exports, {
|
|
25
|
+
default: () => pageMetaLoader
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(page_exports);
|
|
28
|
+
var import_utils = require("../../utils");
|
|
29
|
+
var import_path = __toESM(require("path"));
|
|
30
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
31
|
+
function pageMetaLoader(raw) {
|
|
32
|
+
const pathWithoutIndex = this.resourcePath.replace(/(\/index([^/]+)?)?\.(j|t)sx?$/, "");
|
|
33
|
+
let { frontmatter } = (0, import_utils.parseCodeFrontmatter)(raw);
|
|
34
|
+
frontmatter || (frontmatter = {});
|
|
35
|
+
frontmatter.title ?? (frontmatter.title = import_plugin_utils.lodash.startCase(import_path.default.basename(pathWithoutIndex)));
|
|
36
|
+
return `export const frontmatter = ${JSON.stringify(frontmatter)};
|
|
37
|
+
export const toc = [];
|
|
38
|
+
export const demos = {};`;
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {});
|
package/dist/preset.js
CHANGED
|
@@ -36,8 +36,10 @@ var preset_default = (api) => {
|
|
|
36
36
|
require.resolve("./features/compile"),
|
|
37
37
|
require.resolve("./features/routes"),
|
|
38
38
|
require.resolve("./features/meta"),
|
|
39
|
+
require.resolve("./features/tabs"),
|
|
39
40
|
require.resolve("./features/theme"),
|
|
40
|
-
require.resolve("./features/locales")
|
|
41
|
+
require.resolve("./features/locales"),
|
|
42
|
+
require.resolve("./features/parser")
|
|
41
43
|
]
|
|
42
44
|
};
|
|
43
45
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type AtomAssetsParser from "./assetParsers/atom";
|
|
1
2
|
import type { IDumiDemoProps } from "./client/theme-api/DumiDemo";
|
|
2
3
|
import type { ILocalesConfig, IThemeConfig } from "./client/theme-api/types";
|
|
3
4
|
import type { IThemeLoadResult } from "./features/theme/loader";
|
|
@@ -8,12 +9,16 @@ import type { IApi as IUmiApi } from 'umi';
|
|
|
8
9
|
declare type IUmiConfig = IUmiApi['config'];
|
|
9
10
|
export interface IDumiConfig extends IUmiConfig {
|
|
10
11
|
resolve: {
|
|
11
|
-
docDirs: string
|
|
12
|
+
docDirs: (string | {
|
|
13
|
+
type?: string;
|
|
14
|
+
dir: string;
|
|
15
|
+
})[];
|
|
12
16
|
entityDirs: {
|
|
13
17
|
type: string;
|
|
14
18
|
dir: string;
|
|
15
19
|
}[];
|
|
16
20
|
codeBlockMode: 'active' | 'passive';
|
|
21
|
+
entryFile?: string;
|
|
17
22
|
};
|
|
18
23
|
locales: ILocalesConfig;
|
|
19
24
|
themeConfig: IThemeConfig;
|
|
@@ -62,6 +67,7 @@ export declare type IApi = IUmiApi & {
|
|
|
62
67
|
userConfig: IDumiUserConfig;
|
|
63
68
|
service: IUmiApi['service'] & {
|
|
64
69
|
themeData: IThemeLoadResult;
|
|
70
|
+
atomParser: AtomAssetsParser;
|
|
65
71
|
};
|
|
66
72
|
/**
|
|
67
73
|
* register a new tech stack
|
package/dist/utils.d.ts
CHANGED
|
@@ -13,3 +13,10 @@ export declare const getFileRangeLines: (content: string, range: string) => stri
|
|
|
13
13
|
* @param filePath source file path
|
|
14
14
|
*/
|
|
15
15
|
export declare const getFileContentByRegExp: (content: string, regexp: string, filePath: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* parse frontmatter from code string
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseCodeFrontmatter(raw: string): {
|
|
20
|
+
code: string;
|
|
21
|
+
frontmatter: Record<string, any> | null;
|
|
22
|
+
};
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
21
|
|
|
19
22
|
// src/utils.ts
|
|
@@ -21,9 +24,11 @@ var utils_exports = {};
|
|
|
21
24
|
__export(utils_exports, {
|
|
22
25
|
getFileContentByRegExp: () => getFileContentByRegExp,
|
|
23
26
|
getFileRangeLines: () => getFileRangeLines,
|
|
24
|
-
getRoutePathFromFsPath: () => getRoutePathFromFsPath
|
|
27
|
+
getRoutePathFromFsPath: () => getRoutePathFromFsPath,
|
|
28
|
+
parseCodeFrontmatter: () => parseCodeFrontmatter
|
|
25
29
|
});
|
|
26
30
|
module.exports = __toCommonJS(utils_exports);
|
|
31
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
27
32
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
28
33
|
function getRoutePathFromFsPath(fsPath) {
|
|
29
34
|
return import_plugin_utils.lodash.kebabCase((0, import_plugin_utils.winPath)(fsPath).replace(/((\/|^)index(\.[a-zA-Z-]+)?)?\.\w+$/g, ""));
|
|
@@ -48,9 +53,20 @@ Error: ${err}`);
|
|
|
48
53
|
return content;
|
|
49
54
|
}
|
|
50
55
|
};
|
|
56
|
+
function parseCodeFrontmatter(raw) {
|
|
57
|
+
const [, comment = "", code = ""] = raw.replace(/^\n\s*/, "").match(/^(\/\*\*[^]*?\n\s*\*\/)?(?:\s|\n)*([^]+)?$/);
|
|
58
|
+
const yamlComment = comment.replace(/^\/|\/$/g, "").replace(/(^|\n)\s*\*+/g, "$1");
|
|
59
|
+
let frontmatter = null;
|
|
60
|
+
try {
|
|
61
|
+
frontmatter = import_js_yaml.default.load(yamlComment);
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
return { code: frontmatter ? code : raw, frontmatter };
|
|
65
|
+
}
|
|
51
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
67
|
0 && (module.exports = {
|
|
53
68
|
getFileContentByRegExp,
|
|
54
69
|
getFileRangeLines,
|
|
55
|
-
getRoutePathFromFsPath
|
|
70
|
+
getRoutePathFromFsPath,
|
|
71
|
+
parseCodeFrontmatter
|
|
56
72
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.5",
|
|
4
4
|
"description": "Framework for developing UI components",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@types/mdast": "^3.0.10",
|
|
60
60
|
"@umijs/bundler-utils": "^4.0.22",
|
|
61
61
|
"@umijs/core": "^4.0.22",
|
|
62
|
+
"dumi-afx-deps": "^1.0.0-alpha.1",
|
|
62
63
|
"dumi-assets-types": "2.0.0-alpha.0",
|
|
63
64
|
"estree-util-to-js": "^1.1.0",
|
|
64
65
|
"estree-util-visit": "^1.2.0",
|
|
@@ -110,7 +111,7 @@
|
|
|
110
111
|
"@umijs/test": "^4.0.22",
|
|
111
112
|
"cross-env": "^7.0.3",
|
|
112
113
|
"eslint": "^8.20.0",
|
|
113
|
-
"father": "^4.0.
|
|
114
|
+
"father": "^4.0.7",
|
|
114
115
|
"husky": "^8.0.1",
|
|
115
116
|
"jest": "^27.0.0",
|
|
116
117
|
"lint-staged": "^13.0.3",
|
|
@@ -0,0 +1,57 @@
|
|
|
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 { useAtomAssets, useIntl } from 'dumi';
|
|
14
|
+
import React from 'react';
|
|
15
|
+
|
|
16
|
+
var API = function API(_ref) {
|
|
17
|
+
var _definition$propsConf;
|
|
18
|
+
|
|
19
|
+
var id = _ref.id;
|
|
20
|
+
|
|
21
|
+
var _useAtomAssets = useAtomAssets(),
|
|
22
|
+
components = _useAtomAssets.components;
|
|
23
|
+
|
|
24
|
+
var definition = components === null || components === void 0 ? void 0 : components[id];
|
|
25
|
+
var intl = useIntl();
|
|
26
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
className: "markdown"
|
|
28
|
+
}, /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
|
|
29
|
+
id: 'api.component.name'
|
|
30
|
+
})), /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
|
|
31
|
+
id: 'api.component.description'
|
|
32
|
+
})), /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
|
|
33
|
+
id: 'api.component.type'
|
|
34
|
+
})), /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
|
|
35
|
+
id: 'api.component.default'
|
|
36
|
+
})))), /*#__PURE__*/React.createElement("tbody", null, definition && (_definition$propsConf = definition.propsConfig) !== null && _definition$propsConf !== void 0 && _definition$propsConf.properties ? Object.entries(definition.propsConfig.properties).map(function (_ref2) {
|
|
37
|
+
var _definition$propsConf2;
|
|
38
|
+
|
|
39
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
40
|
+
name = _ref3[0],
|
|
41
|
+
prop = _ref3[1];
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
44
|
+
key: name
|
|
45
|
+
}, /*#__PURE__*/React.createElement("td", null, name), /*#__PURE__*/React.createElement("td", null, prop.description || '--'), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, prop.type)), /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("code", null, (_definition$propsConf2 = definition.propsConfig.required) !== null && _definition$propsConf2 !== void 0 && _definition$propsConf2.includes(name) ? intl.formatMessage({
|
|
46
|
+
id: 'api.component.required'
|
|
47
|
+
}) : prop.default || '--')));
|
|
48
|
+
}) : /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
49
|
+
colSpan: 4
|
|
50
|
+
}, intl.formatMessage({
|
|
51
|
+
id: "api.component.".concat(components ? 'not.found' : 'loading')
|
|
52
|
+
}, {
|
|
53
|
+
id: id
|
|
54
|
+
}))))));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default API;
|
|
@@ -7,5 +7,13 @@
|
|
|
7
7
|
"previewer.actions.codepen": "Open in CodePen (Not implemented)",
|
|
8
8
|
"previewer.actions.separate": "Open in separate page",
|
|
9
9
|
"404.title": "PAGE NOT FOUND",
|
|
10
|
-
"404.back": "Back to homepage"
|
|
10
|
+
"404.back": "Back to homepage",
|
|
11
|
+
"api.component.name": "Name",
|
|
12
|
+
"api.component.description": "Description",
|
|
13
|
+
"api.component.type": "Type",
|
|
14
|
+
"api.component.default": "Default",
|
|
15
|
+
"api.component.required": "(required)",
|
|
16
|
+
"api.component.loading": "Properties definition is resolving, wait a moment...",
|
|
17
|
+
"api.component.not.found": "Properties definition not found for {id} component",
|
|
18
|
+
"content.tabs.default": "Doc"
|
|
11
19
|
}
|
|
@@ -7,5 +7,13 @@
|
|
|
7
7
|
"previewer.actions.codepen": "在 CodePen 中打开(未实现)",
|
|
8
8
|
"previewer.actions.separate": "在独立页面中打开",
|
|
9
9
|
"404.title": "页面未找到",
|
|
10
|
-
"404.back": "返回首页"
|
|
10
|
+
"404.back": "返回首页",
|
|
11
|
+
"api.component.name": "属性名",
|
|
12
|
+
"api.component.description": "描述",
|
|
13
|
+
"api.component.type": "类型",
|
|
14
|
+
"api.component.default": "默认值",
|
|
15
|
+
"api.component.required": "(必选)",
|
|
16
|
+
"api.component.loading": "属性定义正在解析中,稍等片刻...",
|
|
17
|
+
"api.component.not.found": "未找到 {id} 组件的属性定义",
|
|
18
|
+
"content.tabs.default": "文档"
|
|
11
19
|
}
|
|
@@ -23,6 +23,24 @@
|
|
|
23
23
|
padding-right: 24px;
|
|
24
24
|
background-color: tint(@c-site-bg, 50%);
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
// table
|
|
28
|
+
table {
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
th {
|
|
33
|
+
background-color: tint(@c-site-bg, 50%);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
th,
|
|
37
|
+
td {
|
|
38
|
+
padding-block-start: 10px;
|
|
39
|
+
padding-block-end: 10px;
|
|
40
|
+
padding-inline-start: 16px;
|
|
41
|
+
padding-inline-end: 16px;
|
|
42
|
+
border-color: @c-border-light;
|
|
43
|
+
}
|
|
26
44
|
}
|
|
27
45
|
|
|
28
46
|
.@{prefix}-content {
|
|
@@ -30,7 +48,7 @@
|
|
|
30
48
|
max-width: 100%;
|
|
31
49
|
|
|
32
50
|
&:not([data-no-sidebar]) {
|
|
33
|
-
padding:
|
|
51
|
+
padding: @s-content-padding;
|
|
34
52
|
background-color: #fff;
|
|
35
53
|
border-top-left-radius: 10px;
|
|
36
54
|
border-top-right-radius: 10px;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useRouteMeta } from 'dumi';
|
|
2
|
+
import { type FC } from 'react';
|
|
3
|
+
import './index.less';
|
|
4
|
+
declare type IContentTabs = ReturnType<typeof useRouteMeta>['tabs'];
|
|
5
|
+
export interface IContentTabsProps {
|
|
6
|
+
tabs: IContentTabs;
|
|
7
|
+
tabKey?: string;
|
|
8
|
+
onChange: (tab?: NonNullable<IContentTabs>[0]) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const ContentTabs: FC<IContentTabsProps>;
|
|
11
|
+
export default ContentTabs;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useIntl } from 'dumi';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import "./index.less";
|
|
4
|
+
|
|
5
|
+
var ContentTabs = function ContentTabs(_ref) {
|
|
6
|
+
var tabs = _ref.tabs,
|
|
7
|
+
key = _ref.tabKey,
|
|
8
|
+
onChange = _ref.onChange;
|
|
9
|
+
var intl = useIntl(); // TODO: tab.Extra & tab.Action render
|
|
10
|
+
|
|
11
|
+
return Boolean(tabs === null || tabs === void 0 ? void 0 : tabs.length) ? /*#__PURE__*/React.createElement("ul", {
|
|
12
|
+
className: "dumi-default-content-tabs"
|
|
13
|
+
}, /*#__PURE__*/React.createElement("li", {
|
|
14
|
+
onClick: function onClick() {
|
|
15
|
+
return onChange();
|
|
16
|
+
},
|
|
17
|
+
"data-active": !key || undefined
|
|
18
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
19
|
+
type: "button"
|
|
20
|
+
}, intl.formatMessage({
|
|
21
|
+
id: 'content.tabs.default'
|
|
22
|
+
}))), tabs.map(function (tab) {
|
|
23
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
24
|
+
key: tab.key,
|
|
25
|
+
onClick: function onClick() {
|
|
26
|
+
return onChange(tab);
|
|
27
|
+
},
|
|
28
|
+
"data-active": key === tab.key || undefined
|
|
29
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
30
|
+
type: "button"
|
|
31
|
+
}, tab.frontmatter.title));
|
|
32
|
+
})) : null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default ContentTabs;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@import (reference) '../../styles/variables.less';
|
|
2
|
+
|
|
3
|
+
.@{prefix}-content-tabs {
|
|
4
|
+
list-style-type: none;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
height: 60px;
|
|
8
|
+
margin: -@s-content-padding -@s-content-padding @s-content-padding -@s-content-padding;
|
|
9
|
+
padding: 0 @s-content-padding;
|
|
10
|
+
border-bottom: 1px solid @c-border-light;
|
|
11
|
+
|
|
12
|
+
[data-no-sidebar] & {
|
|
13
|
+
margin: 0 0 @s-content-padding;
|
|
14
|
+
padding: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
> li {
|
|
18
|
+
height: inherit;
|
|
19
|
+
|
|
20
|
+
> button {
|
|
21
|
+
padding: 0;
|
|
22
|
+
height: inherit;
|
|
23
|
+
color: @c-text-secondary;
|
|
24
|
+
font-size: 17px;
|
|
25
|
+
border: 0;
|
|
26
|
+
background: transparent;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
transition: all 0.2s;
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
color: @c-primary;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:not(last-child) {
|
|
36
|
+
margin-right: 42px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&[data-active] {
|
|
40
|
+
position: relative;
|
|
41
|
+
|
|
42
|
+
> button {
|
|
43
|
+
color: @c-text;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&::after {
|
|
47
|
+
content: '';
|
|
48
|
+
position: absolute;
|
|
49
|
+
left: 0;
|
|
50
|
+
right: 0;
|
|
51
|
+
bottom: -1px;
|
|
52
|
+
height: 1px;
|
|
53
|
+
background-color: @c-primary;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"paths": {
|
|
5
|
-
"@/*": ["src/*"],
|
|
6
|
-
"@@/*": ["src/.umi/*"],
|
|
7
|
-
"dumi": ["."],
|
|
8
|
-
"dumi/theme": ["src/client/theme-api"],
|
|
9
|
-
"dumi/theme/*": ["src/client/theme-default/*"]
|
|
10
|
-
},
|
|
11
|
-
"types": ["../../src/.umi/typings"]
|
|
12
|
-
}
|
|
13
|
-
}
|