dumi 2.0.0-rc.4 → 2.0.0-rc.6

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 (29) hide show
  1. package/dist/client/pages/{Demo.d.ts → Demo/index.d.ts} +1 -0
  2. package/dist/client/pages/{Demo.js → Demo/index.js} +1 -0
  3. package/dist/client/pages/Demo/index.less +4 -0
  4. package/dist/client/theme-api/DumiPage.js +6 -9
  5. package/dist/features/routes.js +21 -4
  6. package/dist/features/theme/index.js +27 -5
  7. package/dist/loaders/markdown/transformer/index.js +3 -1
  8. package/dist/loaders/markdown/transformer/rehypeSlug.js +5 -1
  9. package/dist/loaders/markdown/transformer/remarkContainer.d.ts +3 -0
  10. package/dist/loaders/markdown/transformer/remarkContainer.js +53 -0
  11. package/dist/loaders/markdown/transformer/remarkEmbed.js +3 -0
  12. package/package.json +2 -1
  13. package/theme-default/builtins/Badge/index.d.ts +7 -0
  14. package/theme-default/builtins/Badge/index.js +12 -0
  15. package/theme-default/builtins/Badge/index.less +33 -0
  16. package/theme-default/builtins/Container/index.d.ts +8 -0
  17. package/theme-default/builtins/Container/index.js +39 -0
  18. package/theme-default/builtins/Container/index.less +70 -0
  19. package/theme-default/builtins/Table/index.js +10 -2
  20. package/theme-default/builtins/Table/index.less +9 -9
  21. package/theme-default/layouts/DocLayout/index.less +2 -1
  22. package/theme-default/slots/Content/index.less +48 -0
  23. package/theme-default/slots/Features/index.less +2 -2
  24. package/theme-default/slots/Hero/index.less +1 -1
  25. package/theme-default/slots/SearchBar/index.js +1 -1
  26. package/theme-default/slots/SearchResult/index.d.ts +2 -2
  27. package/theme-default/slots/SearchResult/index.js +4 -2
  28. package/theme-default/slots/Sidebar/index.js +2 -1
  29. package/theme-default/styles/variables.less +6 -4
@@ -1,3 +1,4 @@
1
1
  import { type FC } from 'react';
2
+ import './index.less';
2
3
  declare const DemoRenderPage: FC;
3
4
  export default DemoRenderPage;
@@ -1,5 +1,6 @@
1
1
  import { useParams, useSiteData } from 'dumi';
2
2
  import { createElement } from 'react';
3
+ import "./index.less";
3
4
 
4
5
  var DemoRenderPage = function DemoRenderPage() {
5
6
  var _useParams = useParams(),
@@ -0,0 +1,4 @@
1
+ body {
2
+ margin: 0;
3
+ padding: 0;
4
+ }
@@ -16,8 +16,7 @@ import React, { useEffect, useState } from 'react';
16
16
  import { useTabQueryState } from "./useTabMeta";
17
17
  export var DumiPage = function DumiPage(props) {
18
18
  var _useLocation = useLocation(),
19
- hash = _useLocation.hash,
20
- pathname = _useLocation.pathname;
19
+ hash = _useLocation.hash;
21
20
 
22
21
  var _useRouteMeta = useRouteMeta(),
23
22
  tabs = _useRouteMeta.tabs;
@@ -47,13 +46,11 @@ export var DumiPage = function DumiPage(props) {
47
46
 
48
47
  useEffect(function () {
49
48
  var id = hash.replace('#', '');
50
- var elm = id && document.getElementById(id);
51
- if (elm) elm.scrollIntoView();
52
- }, [hash]); // handle pathname change
53
-
54
- useEffect(function () {
55
- document.documentElement.scrollTo(0, 0);
56
- }, [pathname]);
49
+ setTimeout(function () {
50
+ var elm = id && document.getElementById(decodeURIComponent(id));
51
+ if (elm) document.documentElement.scrollTo(0, elm.offsetTop - 80);
52
+ }, 1);
53
+ }, [hash]);
57
54
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ContentTabs, {
58
55
  tabs: tabs,
59
56
  tabKey: tabKey,
@@ -47,7 +47,17 @@ function localizeUmiRoute(route, locales) {
47
47
  function flatRoute(route) {
48
48
  if (route.parentId !== "DocLayout") {
49
49
  route.parentId = "DocLayout";
50
- route.path = route.path === "*" ? route.path : route.absPath.slice(1);
50
+ route.path = route.path === "*" ? route.path.toLowerCase() : route.absPath.slice(1).toLowerCase();
51
+ }
52
+ }
53
+ function getClientPageFile(file, cwd) {
54
+ try {
55
+ return import_plugin_utils.resolve.sync(`dumi/dist/${file}`, {
56
+ basedir: cwd,
57
+ preserveSymlinks: false
58
+ });
59
+ } catch {
60
+ return require.resolve(`../${file}`);
51
61
  }
52
62
  }
53
63
  var routes_default = (api) => {
@@ -112,6 +122,7 @@ var routes_default = (api) => {
112
122
  Object.entries(pages).forEach(([, route]) => {
113
123
  route.file = (0, import_plugin_utils.winPath)(import_path.default.resolve(api.config.conventionRoutes.base, route.file));
114
124
  flatRoute(route);
125
+ localizeUmiRoute(route, api.config.locales);
115
126
  routes[route.id] = route;
116
127
  });
117
128
  docDirs.map(normalizeDocDir).forEach(({ type, dir }) => {
@@ -137,7 +148,7 @@ var routes_default = (api) => {
137
148
  const base = import_path.default.join(api.cwd, dir);
138
149
  const atomFiles = import_plugin_utils.glob.sync("{*,*/index,*/index.*,*/README,*/README.*}.md", { cwd: base });
139
150
  atomFiles.forEach((file) => {
140
- const routePath = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file)).replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/");
151
+ const routePath = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file)).replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/").toLowerCase();
141
152
  const routeId = (0, import_utils.createRouteId)(file);
142
153
  routes[routeId] = {
143
154
  id: routeId,
@@ -155,7 +166,7 @@ var routes_default = (api) => {
155
166
  path: "*",
156
167
  absPath: "/*",
157
168
  parentId: docLayoutId,
158
- file: require.resolve("../client/pages/404")
169
+ file: getClientPageFile("client/pages/404", api.cwd)
159
170
  };
160
171
  }
161
172
  routes["demo-render"] = {
@@ -163,8 +174,14 @@ var routes_default = (api) => {
163
174
  path: `${import_constants.SP_ROUTE_PREFIX}demos/:id`,
164
175
  absPath: `/${import_constants.SP_ROUTE_PREFIX}demos/:id`,
165
176
  parentId: demoLayoutId,
166
- file: require.resolve("../client/pages/Demo")
177
+ file: getClientPageFile("client/pages/Demo", api.cwd)
167
178
  };
179
+ Object.values(routes).forEach((route) => {
180
+ if (route.path !== encodeURI(route.path)) {
181
+ throw new Error(`Invalid route path: ${route.path}, please rename it with only alphanumeric, dash and slash.
182
+ at ${route.file}`);
183
+ }
184
+ });
168
185
  return routes;
169
186
  });
170
187
  api.addLayouts(() => {
@@ -26,6 +26,7 @@ __export(theme_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(theme_exports);
28
28
  var import_constants = require("../../constants");
29
+ var import_bundler_utils = require("@umijs/bundler-utils");
29
30
  var import_fs = __toESM(require("fs"));
30
31
  var import_path = __toESM(require("path"));
31
32
  var import_plugin_utils = require("umi/plugin-utils");
@@ -109,18 +110,30 @@ var theme_default = (api) => {
109
110
  api.onGenerateFiles(() => {
110
111
  themeMapKeys.forEach((key) => {
111
112
  Object.values(originalThemeData[key] || {}).forEach((item) => {
113
+ if (item.source === "dumi")
114
+ return;
115
+ let contents = [];
116
+ const [, exports] = (0, import_bundler_utils.parseModuleSync)({
117
+ path: item.source,
118
+ content: import_fs.default.readFileSync(item.source, "utf-8")
119
+ });
120
+ if (exports.includes("default")) {
121
+ contents.push(`export { default } from '${item.source}';`);
122
+ }
123
+ if (exports.some((exp) => exp !== "default")) {
124
+ contents.push(`export * from '${item.source}';`);
125
+ }
112
126
  api.writeTmpFile({
113
127
  noPluginDir: true,
114
128
  path: `dumi/theme/${key}/${item.specifier}.ts`,
115
- content: `export * from '${item.source}';
116
- export { default } from '${item.source}';`
129
+ content: contents.join("\n")
117
130
  });
118
131
  });
119
132
  });
120
133
  api.writeTmpFile({
121
134
  noPluginDir: true,
122
135
  path: "dumi/theme/ContextWrapper.tsx",
123
- content: `import React, { useState, useEffect } from 'react';
136
+ content: `import React, { useState, useEffect, useRef } from 'react';
124
137
  import { useOutlet, history } from 'dumi';
125
138
  import { SiteContext } from '${(0, import_plugin_utils.winPath)(require.resolve("../../client/theme-api/context"))}';
126
139
  import { demos, components } from '../meta';
@@ -129,10 +142,19 @@ import { locales } from '../locales/config';
129
142
  export default function DumiContextWrapper() {
130
143
  const outlet = useOutlet();
131
144
  const [loading, setLoading] = useState(true);
145
+ const prev = useRef(history.location.pathname);
132
146
 
133
- // mark loading when route change, page component will set false when loaded
134
147
  useEffect(() => {
135
- return history.listen(() => setLoading(true));
148
+ return history.listen((next) => {
149
+ // mark loading when route change, page component will set false when loaded
150
+ setLoading(true);
151
+
152
+ // scroll to top when route changed
153
+ if (next.location.pathname !== prev.current) {
154
+ prev.current = next.location.pathname;
155
+ document.documentElement.scrollTo(0, 0);
156
+ }
157
+ });
136
158
  }, []);
137
159
 
138
160
  return (
@@ -37,6 +37,7 @@ var import_rehypeRaw = __toESM(require("./rehypeRaw"));
37
37
  var import_rehypeSlug = __toESM(require("./rehypeSlug"));
38
38
  var import_rehypeStrip = __toESM(require("./rehypeStrip"));
39
39
  var import_rehypeText = __toESM(require("./rehypeText"));
40
+ var import_remarkContainer = __toESM(require("./remarkContainer"));
40
41
  var import_remarkEmbed = __toESM(require("./remarkEmbed"));
41
42
  var import_remarkMeta = __toESM(require("./remarkMeta"));
42
43
  function applyUnifiedPlugin(opts) {
@@ -50,6 +51,7 @@ var transformer_default = async (raw, opts) => {
50
51
  const { unified } = await import("unified");
51
52
  const { default: remarkParse } = await import("remark-parse");
52
53
  const { default: remarkFrontmatter } = await import("remark-frontmatter");
54
+ const { default: remarkDirective } = await import("remark-directive");
53
55
  const { default: remarkBreaks } = await import("remark-breaks");
54
56
  const { default: remarkGfm } = await import("remark-gfm");
55
57
  const { default: remarkRehype } = await import("remark-rehype");
@@ -63,7 +65,7 @@ var transformer_default = async (raw, opts) => {
63
65
  cwd: opts.cwd,
64
66
  fileAbsPath: opts.fileAbsPath,
65
67
  resolve: opts.resolve
66
- }).use(remarkBreaks).use(remarkGfm);
68
+ }).use(remarkDirective).use(import_remarkContainer.default).use(remarkBreaks).use(remarkGfm);
67
69
  (_a = opts.extraRemarkPlugins) == null ? void 0 : _a.forEach((plugin) => applyUnifiedPlugin({
68
70
  plugin,
69
71
  processor,
@@ -42,7 +42,11 @@ function rehypeSlug() {
42
42
  visit(tree, "element", (node) => {
43
43
  var _a, _b;
44
44
  if (HEADING_TAGS.includes(node.tagName)) {
45
- const title = toString(node);
45
+ const title = toString({
46
+ type: "element",
47
+ tagName: node.tagName,
48
+ children: node.children.filter((child) => child.type !== "element" || child.tagName !== "Badge")
49
+ }).trim();
46
50
  const depth = Number(node.tagName.slice(1));
47
51
  const id = slugger.slug(title);
48
52
  node.properties.id = id;
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ import type { Transformer } from 'unified';
3
+ export default function remarkContainer(): Transformer<Root>;
@@ -0,0 +1,53 @@
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/markdown/transformer/remarkContainer.ts
23
+ var remarkContainer_exports = {};
24
+ __export(remarkContainer_exports, {
25
+ default: () => remarkContainer
26
+ });
27
+ module.exports = __toCommonJS(remarkContainer_exports);
28
+ var visit;
29
+ var SKIP;
30
+ var VALID_CONTAINER_TYPES = ["info", "warning", "success", "error"];
31
+ (async () => {
32
+ ({ visit, SKIP } = await import("unist-util-visit"));
33
+ })();
34
+ function remarkContainer() {
35
+ return (tree) => {
36
+ visit(tree, (node, i, parent) => {
37
+ if (node.type === "containerDirective" && VALID_CONTAINER_TYPES.includes(node.name)) {
38
+ const attrs = Object.entries(node.attributes || {}).reduce((ret, [name, value]) => `${ret} ${value ? `${name}="${value}"` : name}`, "");
39
+ parent.children.splice(i, 1, {
40
+ type: "html",
41
+ value: `<Container type="${node.name}"${attrs}>`,
42
+ position: node.position
43
+ }, ...(node.children || []).concat({
44
+ type: "html",
45
+ value: "</Container>"
46
+ }));
47
+ return SKIP;
48
+ }
49
+ });
50
+ };
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {});
@@ -44,6 +44,9 @@ var visit;
44
44
  })();
45
45
  function remarkRawAST() {
46
46
  this.Compiler = function Compiler(ast) {
47
+ visit(ast, "yaml", (_node, i, parent) => {
48
+ parent.children.splice(i, 1);
49
+ });
47
50
  return ast;
48
51
  };
49
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0-rc.6",
4
4
  "description": "Framework for developing UI components",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -91,6 +91,7 @@
91
91
  "rehype-remove-comments": "^5.0.0",
92
92
  "rehype-stringify": "^9.0.3",
93
93
  "remark-breaks": "^3.0.2",
94
+ "remark-directive": "^2.0.1",
94
95
  "remark-frontmatter": "^4.0.1",
95
96
  "remark-gfm": "^3.0.1",
96
97
  "remark-parse": "^10.0.1",
@@ -0,0 +1,7 @@
1
+ import { type FC, type ReactNode } from 'react';
2
+ import './index.less';
3
+ declare const Badge: FC<{
4
+ children: ReactNode;
5
+ type: 'info' | 'warning' | 'error' | 'success';
6
+ }>;
7
+ export default Badge;
@@ -0,0 +1,12 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React from 'react';
4
+ import "./index.less";
5
+
6
+ var Badge = function Badge(props) {
7
+ return /*#__PURE__*/React.createElement("span", _extends({
8
+ className: "dumi-default-badge"
9
+ }, props));
10
+ };
11
+
12
+ export default Badge;
@@ -0,0 +1,33 @@
1
+ @import (reference) '../../styles/variables.less';
2
+
3
+ .@{prefix}-badge {
4
+ display: inline-block;
5
+ margin-left: 2px;
6
+ padding: 1px 8px;
7
+ font-size: 12px;
8
+ font-weight: 400;
9
+ line-height: 20px;
10
+ border-radius: 4px;
11
+ vertical-align: top;
12
+
13
+ &:not([type]),
14
+ &[type='info'] {
15
+ color: @c-primary;
16
+ background: lighten(@c-primary, 40%);
17
+ }
18
+
19
+ &[type='warning'] {
20
+ color: @c-warning;
21
+ background: lighten(@c-warning, 48%);
22
+ }
23
+
24
+ &[type='success'] {
25
+ color: @c-success;
26
+ background: lighten(@c-success, 54%);
27
+ }
28
+
29
+ &[type='error'] {
30
+ color: @c-error;
31
+ background: lighten(@c-error, 47%);
32
+ }
33
+ }
@@ -0,0 +1,8 @@
1
+ import { type FC, type ReactNode } from 'react';
2
+ import './index.less';
3
+ declare const Container: FC<{
4
+ type: string;
5
+ title?: string;
6
+ children: ReactNode;
7
+ }>;
8
+ export default Container;
@@ -0,0 +1,39 @@
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 { ReactComponent as IconSuccess } from '@ant-design/icons-svg/inline-svg/outlined/check-circle.svg';
14
+ import { ReactComponent as IconError } from '@ant-design/icons-svg/inline-svg/outlined/close-circle.svg';
15
+ import { ReactComponent as IconInfo } from '@ant-design/icons-svg/inline-svg/outlined/info-circle.svg';
16
+ import { ReactComponent as IconWarning } from '@ant-design/icons-svg/inline-svg/outlined/warning.svg';
17
+ import React, { useState } from 'react';
18
+ import "./index.less";
19
+ var ICONS = {
20
+ info: IconInfo,
21
+ warning: IconWarning,
22
+ success: IconSuccess,
23
+ error: IconError
24
+ };
25
+
26
+ var Container = function Container(props) {
27
+ var _useState = useState(function () {
28
+ return ICONS[props.type];
29
+ }),
30
+ _useState2 = _slicedToArray(_useState, 1),
31
+ Icon = _useState2[0];
32
+
33
+ return /*#__PURE__*/React.createElement("div", {
34
+ className: "dumi-default-container markdown",
35
+ "data-type": props.type
36
+ }, /*#__PURE__*/React.createElement(Icon, null), /*#__PURE__*/React.createElement("h4", null, props.title || props.type.toUpperCase()), props.children);
37
+ };
38
+
39
+ export default Container;
@@ -0,0 +1,70 @@
1
+ @import (reference) '../../styles/variables.less';
2
+
3
+ .@{prefix}-container {
4
+ margin: 24px 0 32px;
5
+ padding: 18px 16px 18px 44px;
6
+ border-radius: 4px;
7
+
8
+ > svg {
9
+ float: left;
10
+ fill: currentcolor;
11
+ margin-left: -26px;
12
+ width: 18px;
13
+ }
14
+
15
+ > h4 {
16
+ margin: 1px 0 0;
17
+ font-size: 15px;
18
+ line-height: 1;
19
+ }
20
+
21
+ > p {
22
+ margin: 8px 0 0;
23
+ font-size: 15px;
24
+ line-height: 1.2;
25
+ }
26
+
27
+ &[data-type='info'] {
28
+ @color: darken(desaturate(@c-primary, 45%), 10%);
29
+
30
+ color: @color;
31
+ background: lighten(@c-primary, 42%);
32
+
33
+ > p {
34
+ color: desaturate(@color, 20%);
35
+ }
36
+ }
37
+
38
+ &[data-type='warning'] {
39
+ @color: darken(desaturate(@c-warning, 20%), 2%);
40
+
41
+ color: @color;
42
+ background: lighten(@c-warning, 51%);
43
+
44
+ > p {
45
+ color: desaturate(@color, 24%);
46
+ }
47
+ }
48
+
49
+ &[data-type='success'] {
50
+ @color: darken(desaturate(@c-success, 5%), 1%);
51
+
52
+ color: @color;
53
+ background: lighten(@c-success, 59%);
54
+
55
+ > p {
56
+ color: desaturate(@color, 22%);
57
+ }
58
+ }
59
+
60
+ &[data-type='error'] {
61
+ @color: darken(desaturate(@c-error, 20%), 1%);
62
+
63
+ color: @color;
64
+ background: lighten(@c-error, 51%);
65
+
66
+ > p {
67
+ color: desaturate(@color, 25%);
68
+ }
69
+ }
70
+ }
@@ -1,3 +1,5 @@
1
+ var _excluded = ["children"];
2
+
1
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
4
 
3
5
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -10,12 +12,18 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
12
 
11
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
14
 
15
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
16
+
17
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
18
+
13
19
  import throttle from 'lodash.throttle';
14
20
  import React, { useEffect, useRef, useState } from 'react';
15
21
  import "./index.less";
16
22
 
17
23
  var Table = function Table(_ref) {
18
- var children = _ref.children;
24
+ var children = _ref.children,
25
+ props = _objectWithoutProperties(_ref, _excluded);
26
+
19
27
  var container = useRef(null);
20
28
 
21
29
  var _useState = useState(false),
@@ -53,7 +61,7 @@ var Table = function Table(_ref) {
53
61
  ref: container,
54
62
  "data-left-folded": leftFolded || undefined,
55
63
  "data-right-folded": rightFolded || undefined
56
- }, /*#__PURE__*/React.createElement("table", null, children)));
64
+ }, /*#__PURE__*/React.createElement("table", props, children)));
57
65
  };
58
66
 
59
67
  export default Table;
@@ -1,7 +1,7 @@
1
1
  @import (reference) '../../styles/variables.less';
2
2
 
3
3
  .@{prefix}-table {
4
- margin: 16px 0 32px;
4
+ margin: 24px 0 32px;
5
5
  transform: translate(0, 0);
6
6
 
7
7
  &-content {
@@ -23,15 +23,15 @@
23
23
  left: 0;
24
24
  background-image: linear-gradient(
25
25
  to right,
26
- rgba(0, 0, 0, 0.1),
27
- rgba(0, 0, 0, 0)
26
+ rgb(0 0 0 / 10%),
27
+ rgb(0 0 0 / 0%)
28
28
  );
29
29
 
30
30
  [data-prefers-color='dark'] & {
31
31
  background-image: linear-gradient(
32
32
  to right,
33
- rgba(0, 0, 0, 0.5),
34
- rgba(0, 0, 0, 0)
33
+ rgb(0 0 0 / 50%),
34
+ rgb(0 0 0 / 0%)
35
35
  );
36
36
  }
37
37
  }
@@ -40,15 +40,15 @@
40
40
  right: 0;
41
41
  background-image: linear-gradient(
42
42
  to left,
43
- rgba(0, 0, 0, 0.1),
44
- rgba(0, 0, 0, 0)
43
+ rgb(0 0 0 / 10%),
44
+ rgb(0 0 0 / 0%)
45
45
  );
46
46
 
47
47
  [data-prefers-color='dark'] & {
48
48
  background-image: linear-gradient(
49
49
  to left,
50
- rgba(0, 0, 0, 0.5),
51
- rgba(0, 0, 0, 0)
50
+ rgb(0 0 0 / 50%),
51
+ rgb(0 0 0 / 0%)
52
52
  );
53
53
  }
54
54
  }
@@ -3,10 +3,11 @@
3
3
  body {
4
4
  margin: 0;
5
5
  padding: 0;
6
- background-color: @c-site-bg;
7
6
  }
8
7
 
9
8
  .@{prefix}-doc-layout {
9
+ background-color: @c-site-bg;
10
+
10
11
  @media @mobile {
11
12
  &::before {
12
13
  content: '';
@@ -41,6 +41,54 @@
41
41
  padding-inline-end: 16px;
42
42
  border-color: @c-border-light;
43
43
  }
44
+
45
+ // blockquote
46
+ blockquote {
47
+ font-style: italic;
48
+ margin-inline-start: 0;
49
+ margin-inline-end: 0;
50
+ background-color: tint(@c-site-bg, 50%);
51
+ border-left: 5px solid @c-border-light;
52
+ }
53
+
54
+ // list
55
+ ul li {
56
+ line-height: 1.8;
57
+ }
58
+
59
+ // anchor of headings
60
+ h1,
61
+ h2,
62
+ h3,
63
+ h4,
64
+ h5,
65
+ h6 {
66
+ > a[aria-hidden]:first-child {
67
+ float: left;
68
+ width: 20px;
69
+ padding-right: 4px;
70
+ margin-left: -24px;
71
+ color: @c-text;
72
+ // hide phantom blank node
73
+ font-size: 0;
74
+ text-align: right;
75
+ line-height: inherit;
76
+
77
+ &:hover {
78
+ border: 0;
79
+ }
80
+
81
+ > .icon-link::before {
82
+ content: '#';
83
+ color: @c-text-secondary;
84
+ font-size: 20px;
85
+ }
86
+ }
87
+
88
+ &:not(:hover) > a[aria-hidden]:first-child > .icon-link {
89
+ visibility: hidden;
90
+ }
91
+ }
44
92
  }
45
93
 
46
94
  .@{prefix}-content {
@@ -48,7 +48,7 @@
48
48
 
49
49
  > h3 {
50
50
  margin: 4px 0;
51
- color: #2c4262;
51
+ color: @c-text;
52
52
  font-weight: normal;
53
53
  font-size: 20px;
54
54
 
@@ -59,7 +59,7 @@
59
59
 
60
60
  > p {
61
61
  margin: 12px 0;
62
- color: #61728a;
62
+ color: @c-text-secondary;
63
63
  font-size: 16px;
64
64
  line-height: 1.475;
65
65
 
@@ -35,7 +35,7 @@
35
35
 
36
36
  > p {
37
37
  margin: 32px;
38
- color: #4e6789;
38
+ color: @c-text-secondary;
39
39
  font-size: 20px;
40
40
  line-height: 1.6;
41
41
 
@@ -15,7 +15,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  import { ReactComponent as IconSearch } from '@ant-design/icons-svg/inline-svg/outlined/search.svg';
16
16
  import { useIntl, useSiteSearch } from 'dumi';
17
17
  import React, { useEffect, useRef, useState } from 'react';
18
- import { SearchResult } from "../SearchResult";
18
+ import SearchResult from "../SearchResult";
19
19
  import "./index.less";
20
20
  var isAppleDevice = /(mac|iphone|ipod|ipad)/i.test(typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.platform : '');
21
21
 
@@ -2,8 +2,8 @@ import { type useSiteSearch } from 'dumi';
2
2
  import { type FC } from 'react';
3
3
  import './index.less';
4
4
  declare type ISearchResult = ReturnType<typeof useSiteSearch>['result'];
5
- export declare const SearchResult: FC<{
5
+ declare const SearchResult: FC<{
6
6
  data: ISearchResult;
7
7
  loading: boolean;
8
8
  }>;
9
- export {};
9
+ export default SearchResult;
@@ -106,7 +106,7 @@ var useFlatSearchData = function useFlatSearchData(data) {
106
106
  return flatData;
107
107
  };
108
108
 
109
- export var SearchResult = function SearchResult(props) {
109
+ var SearchResult = function SearchResult(props) {
110
110
  var _useFlatSearchData = useFlatSearchData(props.data),
111
111
  _useFlatSearchData2 = _slicedToArray(_useFlatSearchData, 2),
112
112
  data = _useFlatSearchData2[0],
@@ -165,4 +165,6 @@ export var SearchResult = function SearchResult(props) {
165
165
  }, /*#__PURE__*/React.createElement(IconInbox, null), /*#__PURE__*/React.createElement(FormattedMessage, {
166
166
  id: "search.not.found"
167
167
  })));
168
- };
168
+ };
169
+
170
+ export default SearchResult;
@@ -9,7 +9,8 @@ var Sidebar = function Sidebar() {
9
9
 
10
10
  var meta = useRouteMeta();
11
11
  var sidebar = useSidebarData();
12
- return sidebar && /*#__PURE__*/React.createElement("div", {
12
+ if (!sidebar) return null;
13
+ return /*#__PURE__*/React.createElement("div", {
13
14
  className: "dumi-default-sidebar"
14
15
  }, sidebar.map(function (item, i) {
15
16
  return /*#__PURE__*/React.createElement("dl", {
@@ -7,13 +7,15 @@
7
7
  @s-header-height-m: 52px;
8
8
 
9
9
  @c-primary: #1677ff;
10
- @c-text: #333;
11
- @c-text-secondary: #666;
12
- @c-text-note: #999;
10
+ @c-warning: #d59200;
11
+ @c-success: #208a41;
12
+ @c-error: #ce1f31;
13
+ @c-text: #30363f;
14
+ @c-text-secondary: #4f5866;
15
+ @c-text-note: #8a9099;
13
16
  @c-border: #d0d5d8;
14
17
  @c-border-light: #e4e9ec;
15
18
  @c-site-bg: #f7f9fb;
16
- @c-warning: #dd9600;
17
19
 
18
20
  @mobile: ~'only screen and (max-width: 767px)';
19
21
  @tablet: ~'only screen and (min-width: 768px) and (max-width: 1024px)';