dumi 2.0.0-rc.9 → 2.0.0

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 (52) hide show
  1. package/dist/client/theme-api/DumiDemo.js +5 -2
  2. package/dist/client/theme-api/DumiDemoGrid.js +23 -8
  3. package/dist/client/theme-api/index.d.ts +1 -0
  4. package/dist/client/theme-api/index.js +1 -0
  5. package/dist/client/theme-api/openStackBlitz.d.ts +1 -0
  6. package/dist/client/theme-api/openStackBlitz.js +60 -0
  7. package/dist/client/theme-api/useSiteSearch/index.d.ts +7 -0
  8. package/dist/client/theme-api/useSiteSearch/index.js +108 -0
  9. package/dist/client/theme-api/{useSiteSearch.d.ts → useSiteSearch/worker.d.ts} +1 -7
  10. package/dist/client/theme-api/{useSiteSearch.js → useSiteSearch/worker.js} +36 -69
  11. package/dist/constants.js +0 -1
  12. package/dist/features/exportStatic.js +18 -3
  13. package/dist/features/routes.js +18 -3
  14. package/dist/features/tabs.js +7 -4
  15. package/dist/features/theme/loader.js +1 -1
  16. package/dist/loaders/markdown/index.js +6 -5
  17. package/dist/loaders/markdown/transformer/index.d.ts +1 -1
  18. package/dist/loaders/markdown/transformer/rehypeEnhancedTag.js +12 -2
  19. package/dist/loaders/markdown/transformer/remarkEmbed.js +33 -9
  20. package/dist/loaders/markdown/transformer/remarkMeta.js +1 -1
  21. package/dist/loaders/page/index.js +1 -1
  22. package/dist/service/cli.js +1 -0
  23. package/package.json +7 -8
  24. package/theme-default/builtins/Badge/index.less +1 -1
  25. package/theme-default/builtins/Container/index.js +1 -1
  26. package/theme-default/builtins/Container/index.less +15 -11
  27. package/theme-default/builtins/Previewer/index.less +1 -1
  28. package/theme-default/builtins/SourceCode/index.less +1 -0
  29. package/theme-default/layouts/DocLayout/index.js +1 -2
  30. package/theme-default/layouts/DocLayout/index.less +2 -1
  31. package/theme-default/locales/en-US.json +1 -0
  32. package/theme-default/locales/zh-CN.json +1 -0
  33. package/theme-default/slots/Content/index.less +6 -2
  34. package/theme-default/slots/ContentTabs/index.less +2 -2
  35. package/theme-default/slots/Features/index.less +4 -4
  36. package/theme-default/slots/Header/index.js +2 -1
  37. package/theme-default/slots/Hero/index.less +1 -1
  38. package/theme-default/slots/LangSwitch/index.less +5 -2
  39. package/theme-default/slots/Logo/index.less +1 -1
  40. package/theme-default/slots/Navbar/index.less +2 -2
  41. package/theme-default/slots/PreviewerActions/index.d.ts +1 -1
  42. package/theme-default/slots/PreviewerActions/index.js +13 -3
  43. package/theme-default/slots/PreviewerActions/index.less +147 -148
  44. package/theme-default/slots/RtlSwitch/index.d.ts +4 -0
  45. package/theme-default/slots/RtlSwitch/index.js +50 -0
  46. package/theme-default/slots/RtlSwitch/index.less +5 -0
  47. package/theme-default/slots/SearchBar/index.js +2 -2
  48. package/theme-default/slots/SearchBar/index.less +9 -7
  49. package/theme-default/slots/SearchResult/index.js +7 -0
  50. package/theme-default/slots/SearchResult/index.less +12 -9
  51. package/theme-default/slots/Sidebar/index.less +5 -2
  52. package/theme-default/slots/Toc/index.less +2 -2
@@ -1,168 +1,167 @@
1
1
  @import (reference) '../../styles/variables.less';
2
2
  @import '../../styles/utils.less';
3
3
 
4
- .@{prefix}-previewer{
5
- &-actions {
6
- display: flex;
7
- height: 32px;
8
- align-items: center;
9
- justify-content: center;
10
-
11
- &:not(:last-child) {
12
- border-bottom: 1px dashed @c-border-light;
13
- }
14
- }
15
-
16
- &-action-btn {
17
- display: flex;
18
- align-items: center;
19
- justify-content: center;
20
- width: 24px;
21
- height: 24px;
22
- padding: 0;
23
- border: 0;
24
- background: transparent;
25
- cursor: pointer;
26
-
27
- > svg {
28
- width: 16px;
29
- fill: darken(@c-border, 20%);
30
- transition: fill 0.2s;
31
- }
32
-
33
- &:hover > svg {
34
- fill: darken(@c-border, 30%);
35
- }
36
-
37
- &:not(:last-child) {
38
- margin-right: 4px;
39
- }
40
- }
41
-
42
- &-tabs {
43
- position: relative;
44
- padding: 0 12px;
45
-
46
- &::after {
47
- content: '';
48
- position: absolute;
49
- left: 0;
50
- bottom: 0;
51
- width: 100%;
52
- height: 0;
53
- border-bottom: 1px dashed @c-border-light;
54
- }
55
- }
4
+ .@{prefix}-previewer {
5
+ &-actions {
6
+ display: flex;
7
+ height: 32px;
8
+ align-items: center;
9
+ justify-content: center;
10
+
11
+ &:not(:last-child) {
12
+ border-bottom: 1px dashed @c-border-light;
13
+ }
14
+ }
15
+
16
+ &-action-btn {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ width: 24px;
21
+ height: 24px;
22
+ padding: 0;
23
+ border: 0;
24
+ background: transparent;
25
+ cursor: pointer;
26
+
27
+ > svg {
28
+ width: 16px;
29
+ fill: darken(@c-border, 20%);
30
+ transition: fill 0.2s;
31
+ }
32
+
33
+ &:hover > svg {
34
+ fill: darken(@c-border, 30%);
35
+ }
36
+
37
+ &:not(:last-child) {
38
+ margin-inline-end: 4px;
39
+ }
40
+ }
41
+
42
+ &-tabs {
43
+ position: relative;
44
+ padding: 0 12px;
45
+
46
+ &::after {
47
+ content: '';
48
+ position: absolute;
49
+ left: 0;
50
+ bottom: 0;
51
+ width: 100%;
52
+ height: 0;
53
+ border-bottom: 1px dashed @c-border-light;
54
+ }
55
+ }
56
56
  }
57
57
 
58
58
  .@{prefix}-tabs {
59
- overflow: hidden;
60
-
61
- &-top {
62
- flex-direction: column;
63
-
64
- .@{prefix}-tabs-ink-bar {
65
- bottom: 0;
66
- }
59
+ overflow: hidden;
60
+
61
+ &-top {
62
+ flex-direction: column;
63
+
64
+ .@{prefix}-tabs-ink-bar {
65
+ bottom: 0;
67
66
  }
68
-
69
- &-nav {
67
+ }
68
+
69
+ &-nav {
70
+ display: flex;
71
+
72
+ &-wrap {
70
73
  display: flex;
71
-
72
- &-wrap {
73
- display: flex;
74
- white-space: nowrap;
75
- overflow: hidden;
76
-
77
- &&-ping-left {
78
- box-shadow: 5px 0 5px -5px rgb(0 0 0 / 10%) inset;
79
- }
80
-
81
- &&-ping-right ~ * > .@{prefix}-tabs-nav-more {
82
- box-shadow: 0 0 5px rgb(0 0 0 / 10%);
83
- }
84
- }
85
-
86
- &-list {
87
- position: relative;
88
- z-index: 1;
89
- display: flex;
90
- transition: transform 0.2s;
74
+ white-space: nowrap;
75
+ overflow: hidden;
76
+
77
+ &&-ping-left {
78
+ box-shadow: 5px 0 5px -5px rgb(0 0 0 / 10%) inset;
91
79
  }
92
-
93
- &-more {
94
- height: 100%;
95
- cursor: pointer;
96
- background: none;
97
- border: 0;
98
- transition: box-shadow 0.2s;
80
+
81
+ &&-ping-right ~ * > .@{prefix}-tabs-nav-more {
82
+ box-shadow: 0 0 5px rgb(0 0 0 / 10%);
99
83
  }
100
84
  }
101
-
102
- &-tab {
85
+
86
+ &-list {
87
+ position: relative;
88
+ z-index: 1;
103
89
  display: flex;
104
- margin: 0 12px;
105
-
106
- &-btn {
107
- padding: 0;
108
- color: @c-text-secondary;
109
- font-size: 14px;
110
- line-height: 36px;
111
- border: 0;
112
- outline: none;
113
- background: transparent;
114
- box-sizing: border-box;
115
- cursor: pointer;
116
- transition: all 0.2s;
117
-
118
- &:hover {
119
- color: @c-text;
120
- }
121
- }
122
-
123
- &-active &-btn {
90
+ transition: transform 0.2s;
91
+ }
92
+
93
+ &-more {
94
+ height: 100%;
95
+ cursor: pointer;
96
+ background: none;
97
+ border: 0;
98
+ transition: box-shadow 0.2s;
99
+ }
100
+ }
101
+
102
+ &-tab {
103
+ display: flex;
104
+ margin: 0 12px;
105
+
106
+ &-btn {
107
+ padding: 0;
108
+ color: @c-text-secondary;
109
+ font-size: 14px;
110
+ line-height: 36px;
111
+ border: 0;
112
+ outline: none;
113
+ background: transparent;
114
+ box-sizing: border-box;
115
+ cursor: pointer;
116
+ transition: all 0.2s;
117
+
118
+ &:hover {
124
119
  color: @c-text;
125
120
  }
126
121
  }
127
-
128
- &-ink-bar {
129
- position: absolute;
130
- height: 1px;
131
- background: @c-primary;
132
- transition: left 0.2s, width 0.2s;
133
- pointer-events: none;
122
+
123
+ &-active &-btn {
124
+ color: @c-text;
134
125
  }
135
-
136
- &-dropdown {
137
- position: absolute;
138
- background: #fff;
139
- border: 1px solid @c-border;
140
- max-height: 200px;
141
- overflow: auto;
142
-
143
- > ul {
144
- list-style: none;
145
- margin: 0;
146
- padding: 0;
147
-
148
- > li {
149
- padding: 4px 12px;
150
- font-size: 14px;
151
- cursor: pointer;
152
-
153
- &:hover {
154
- color: @c-primary;
155
- }
156
-
157
- &:not(:last-child) {
158
- border-bottom: 1px dashed @c-border;
159
- }
126
+ }
127
+
128
+ &-ink-bar {
129
+ position: absolute;
130
+ height: 1px;
131
+ background: @c-primary;
132
+ transition: left 0.2s, width 0.2s;
133
+ pointer-events: none;
134
+ }
135
+
136
+ &-dropdown {
137
+ position: absolute;
138
+ background: #fff;
139
+ border: 1px solid @c-border;
140
+ max-height: 200px;
141
+ overflow: auto;
142
+
143
+ > ul {
144
+ list-style: none;
145
+ margin: 0;
146
+ padding: 0;
147
+
148
+ > li {
149
+ padding: 4px 12px;
150
+ font-size: 14px;
151
+ cursor: pointer;
152
+
153
+ &:hover {
154
+ color: @c-primary;
155
+ }
156
+
157
+ &:not(:last-child) {
158
+ border-bottom: 1px dashed @c-border;
160
159
  }
161
160
  }
162
-
163
- &-hidden {
164
- display: none;
165
- }
161
+ }
162
+
163
+ &-hidden {
164
+ display: none;
166
165
  }
167
166
  }
168
-
167
+ }
@@ -0,0 +1,4 @@
1
+ import { type FC } from 'react';
2
+ import './index.less';
3
+ declare const RtlSwitch: FC;
4
+ export default RtlSwitch;
@@ -0,0 +1,50 @@
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 { useSiteData } from 'dumi';
14
+ import React, { useEffect, useState } from 'react';
15
+ import "./index.less";
16
+ var LS_RTL_KEY = 'dumi:rtl';
17
+
18
+ var RtlSwitch = function RtlSwitch() {
19
+ var _useState = useState(false),
20
+ _useState2 = _slicedToArray(_useState, 2),
21
+ rtl = _useState2[0],
22
+ setRtl = _useState2[1];
23
+
24
+ var _useSiteData = useSiteData(),
25
+ themeConfig = _useSiteData.themeConfig;
26
+
27
+ useEffect(function () {
28
+ if (localStorage.getItem(LS_RTL_KEY)) {
29
+ setRtl(true);
30
+ document.documentElement.setAttribute('data-direction', 'rtl');
31
+ }
32
+ }, []);
33
+ if (!themeConfig.rtl) return null;
34
+ return /*#__PURE__*/React.createElement("span", {
35
+ className: "dumi-default-lang-switch",
36
+ onClick: function onClick() {
37
+ if (rtl) {
38
+ document.documentElement.removeAttribute('data-direction');
39
+ localStorage.removeItem(LS_RTL_KEY);
40
+ } else {
41
+ document.documentElement.setAttribute('data-direction', 'rtl');
42
+ localStorage.setItem(LS_RTL_KEY, '1');
43
+ }
44
+
45
+ setRtl(!rtl);
46
+ }
47
+ }, rtl ? 'LTR' : 'RTL');
48
+ };
49
+
50
+ export default RtlSwitch;
@@ -0,0 +1,5 @@
1
+ @import '../LangSwitch/index.less';
2
+
3
+ html[data-direction='rtl'] {
4
+ direction: rtl;
5
+ }
@@ -80,7 +80,7 @@ var SearchBar = function SearchBar() {
80
80
  // wait for item click
81
81
  setTimeout(function () {
82
82
  setFocusing(false);
83
- }, 100);
83
+ }, 1);
84
84
  },
85
85
  onKeyDown: function onKeyDown(ev) {
86
86
  if (['ArrowDown', 'ArrowUp'].includes(ev.key)) ev.preventDefault(); // esc to blur input
@@ -101,7 +101,7 @@ var SearchBar = function SearchBar() {
101
101
  ref: input
102
102
  }), /*#__PURE__*/React.createElement("span", {
103
103
  className: "dumi-default-search-shortcut"
104
- }, symbol, " K"), keywords.trim() && focusing && /*#__PURE__*/React.createElement("div", {
104
+ }, symbol, " K"), keywords.trim() && focusing && (result.length || !loading) && /*#__PURE__*/React.createElement("div", {
105
105
  className: "dumi-default-search-popover"
106
106
  }, /*#__PURE__*/React.createElement("section", null, /*#__PURE__*/React.createElement(SearchResult, {
107
107
  data: result,
@@ -9,14 +9,14 @@
9
9
  }
10
10
 
11
11
  &:not(:last-child) {
12
- margin-right: 28px;
12
+ margin-inline-end: 28px;
13
13
  }
14
14
 
15
15
  > svg {
16
16
  position: absolute;
17
17
  top: 50%;
18
18
  margin-top: 1px;
19
- left: 16px;
19
+ inset-inline-start: 16px;
20
20
  width: 16px;
21
21
  fill: @c-text-note;
22
22
  transform: translateY(-50%);
@@ -25,7 +25,9 @@
25
25
  > input {
26
26
  width: 280px;
27
27
  height: 40px;
28
- padding: 0 12px 0 40px;
28
+ padding: 0;
29
+ padding-inline-start: 40px;
30
+ padding-inline-end: 12px;
29
31
  color: @c-text;
30
32
  font-size: 14px;
31
33
  border: 1px solid @c-border;
@@ -49,7 +51,7 @@
49
51
  .@{prefix}-search-shortcut {
50
52
  position: absolute;
51
53
  top: 50%;
52
- right: 11px;
54
+ inset-inline-end: 11px;
53
55
  display: inline-block;
54
56
  padding: 4px 8px;
55
57
  color: @c-text-note;
@@ -71,10 +73,10 @@
71
73
  .@{prefix}-search-popover {
72
74
  position: absolute;
73
75
  top: 100%;
74
- right: 0;
76
+ inset-inline-end: 0;
75
77
  display: flex;
76
78
  flex-direction: column;
77
- width: 600px;
79
+ width: 540px;
78
80
  max-height: 460px;
79
81
  margin-top: 18px;
80
82
  background-color: #fff;
@@ -85,7 +87,7 @@
85
87
  content: '';
86
88
  position: absolute;
87
89
  bottom: 100%;
88
- right: 100px;
90
+ inset-inline-end: 100px;
89
91
  display: inline-block;
90
92
  width: 0;
91
93
  height: 0;
@@ -146,6 +146,13 @@ var SearchResult = function SearchResult(props) {
146
146
  className: "dumi-default-search-result",
147
147
  onMouseEnter: function onMouseEnter() {
148
148
  return setActiveIndex(-1);
149
+ } // for ux, only hide result when mouse up
150
+ ,
151
+ onMouseDownCapture: function onMouseDownCapture(ev) {
152
+ return ev.preventDefault();
153
+ },
154
+ onMouseUpCapture: function onMouseUpCapture() {
155
+ document.activeElement.blur();
149
156
  }
150
157
  }, Boolean(props.data.length || props.loading) ? /*#__PURE__*/React.createElement("dl", null, data.map(function (item, i) {
151
158
  return item.type === 'title' ? /*#__PURE__*/React.createElement("dt", {
@@ -40,7 +40,10 @@
40
40
  height: 60px;
41
41
  flex-direction: column;
42
42
  justify-content: center;
43
- padding: 6px 12px 8px 54px;
43
+ padding-top: 6px;
44
+ padding-bottom: 8px;
45
+ padding-inline-start: 54px;
46
+ padding-inline-end: 12px;
44
47
  text-decoration: none;
45
48
  box-sizing: border-box;
46
49
  border-radius: 4px;
@@ -61,8 +64,8 @@
61
64
 
62
65
  > svg {
63
66
  position: absolute;
64
- top: 16px;
65
- left: 14px;
67
+ top: 14px;
68
+ inset-inline-start: 14px;
66
69
  width: 32px;
67
70
  height: 32px;
68
71
  fill: darken(@c-border, 5%);
@@ -79,12 +82,12 @@
79
82
 
80
83
  > h4 {
81
84
  color: @c-text-secondary;
82
- font-size: 16px;
85
+ font-size: 14px;
83
86
  }
84
87
 
85
88
  > p {
86
89
  margin-top: 2px;
87
- font-size: 14px;
90
+ font-size: 13px;
88
91
  color: @c-text-note;
89
92
 
90
93
  &:empty {
@@ -99,7 +102,7 @@
99
102
  color: rgb(72 70 7);
100
103
  padding: 0 2px;
101
104
  border-radius: 2px;
102
- background-color: rgb(252 249 168);
105
+ background-color: rgb(255 249 197);
103
106
  }
104
107
 
105
108
  .@{prefix}-search-empty {
@@ -107,13 +110,13 @@
107
110
  height: 140px;
108
111
  align-items: center;
109
112
  justify-content: center;
110
- color: @c-text-secondary;
113
+ color: @c-text-note;
111
114
  font-size: 16px;
112
115
 
113
116
  > svg {
114
- margin-right: 8px;
117
+ margin-inline-end: 8px;
115
118
  width: 48px;
116
- fill: @c-border;
119
+ fill: lighten(@c-text-note, 20%);
117
120
  }
118
121
  }
119
122
  }
@@ -5,7 +5,10 @@
5
5
  top: @s-header-height;
6
6
  width: @s-sidebar-width;
7
7
  max-height: calc(100vh - @s-header-height);
8
- padding: 20px 32px 24px 8px;
8
+ padding-top: 20px;
9
+ padding-bottom: 24px;
10
+ padding-inline-start: 8px;
11
+ padding-inline-end: 32px;
9
12
  box-sizing: border-box;
10
13
  overflow: auto;
11
14
 
@@ -16,7 +19,7 @@
16
19
  left: 0;
17
20
  bottom: 0;
18
21
  max-height: initial;
19
- padding-left: 32px;
22
+ padding-inline-start: 32px;
20
23
  background-color: @c-site-bg;
21
24
  border-top: 1px solid @c-border-light;
22
25
  box-shadow: 0 0 20px rgb(0 0 0 / 10%);
@@ -28,14 +28,14 @@
28
28
  }
29
29
 
30
30
  &.active {
31
- margin-left: -1px;
31
+ margin-inline-start: -1px;
32
32
  color: @c-text;
33
33
  border-left: 1px solid @c-primary;
34
34
  }
35
35
  }
36
36
 
37
37
  &[data-depth='3'] > a {
38
- padding-left: 20px;
38
+ padding-inline-start: 20px;
39
39
  }
40
40
  }
41
41
  }