@opentiny/tiny-engine-toolbar-theme-switch 2.4.0 → 2.5.0-alpha.1
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/index.js +242 -81
- package/dist/style.css +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import { getMetaApi as m, META_SERVICE as c, callEntry as T, getMergeMeta as f, defineService as E } from "@opentiny/tiny-engine-meta-register";
|
|
3
|
+
import { resolveComponent as H, createElementBlock as M, openBlock as V, createVNode as N, withCtx as O, createElementVNode as U, Fragment as R, renderList as j, normalizeClass as z, toDisplayString as q, createCommentVNode as J, computed as w, ref as F, reactive as K } from "vue";
|
|
4
|
+
import { ToolbarBase as B, setGlobalMonacoEditorTheme as D } from "@opentiny/tiny-engine-common";
|
|
5
|
+
import { TinyPopover as Q, TinyRadioGroup as W } from "@opentiny/vue";
|
|
6
|
+
const G = {
|
|
7
|
+
id: "engine.toolbars.themeSwitch",
|
|
8
|
+
type: "toolbars",
|
|
9
|
+
title: "themeSwitch",
|
|
10
|
+
options: {
|
|
11
|
+
renderType: "icon"
|
|
12
|
+
}
|
|
13
|
+
}, X = (o, t) => {
|
|
14
|
+
const n = o.__vccOpts || o;
|
|
15
|
+
for (const [e, g] of t)
|
|
16
|
+
n[e] = g;
|
|
17
|
+
return n;
|
|
18
|
+
}, Y = {
|
|
12
19
|
components: {
|
|
13
|
-
ToolbarBase:
|
|
14
|
-
TinyRadioGroup:
|
|
15
|
-
TinyPopover:
|
|
20
|
+
ToolbarBase: B,
|
|
21
|
+
TinyRadioGroup: W,
|
|
22
|
+
TinyPopover: Q
|
|
16
23
|
},
|
|
17
24
|
props: {
|
|
18
25
|
options: {
|
|
@@ -25,43 +32,131 @@ const q = (o, t) => {
|
|
|
25
32
|
}
|
|
26
33
|
},
|
|
27
34
|
setup(o) {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const {
|
|
36
|
+
getThemeData: t,
|
|
37
|
+
getThemeState: n,
|
|
38
|
+
themeChange: e,
|
|
39
|
+
getTheme: g
|
|
40
|
+
} = m(c.ThemeSwitch), h = n(), r = t(), l = "collapse", u = w(() => {
|
|
41
|
+
const s = {
|
|
42
|
+
...o.options
|
|
43
|
+
};
|
|
44
|
+
return o.position === l && (s.renderType = ""), s;
|
|
45
|
+
}), a = w(() => r.value.map((s) => ({
|
|
46
|
+
...s,
|
|
47
|
+
label: s.type
|
|
48
|
+
}))), b = w(() => o.position === l ? "" : h.themeLabel), A = w(() => o.position === l ? "" : h.themeIcon), y = F(!1), S = w(() => {
|
|
49
|
+
const s = r.value.filter((P) => ["light", "dark"].includes(P.type)) || [];
|
|
50
|
+
return r.value.length === s.length;
|
|
51
|
+
}), C = T(() => {
|
|
52
|
+
const s = g(h.theme).oppositeTheme;
|
|
53
|
+
e(s);
|
|
54
|
+
}, {
|
|
55
|
+
metaData: {
|
|
56
|
+
id: `${G.id}.toChangeTheme`
|
|
57
|
+
},
|
|
58
|
+
ctx: () => ({
|
|
59
|
+
props: o,
|
|
60
|
+
getThemeData: t,
|
|
61
|
+
getThemeState: n,
|
|
62
|
+
themeChange: e,
|
|
63
|
+
getTheme: g,
|
|
64
|
+
state: h,
|
|
65
|
+
THEME_DATA: r,
|
|
66
|
+
COLLAPSE: l,
|
|
67
|
+
optionsData: u,
|
|
68
|
+
radioThemeList: a,
|
|
69
|
+
baseContent: b,
|
|
70
|
+
baseIcon: A,
|
|
71
|
+
showpopover: y,
|
|
72
|
+
themeShowType: S,
|
|
73
|
+
toChangeTheme: C,
|
|
74
|
+
changeThemeType: k,
|
|
75
|
+
themeItemChange: L,
|
|
76
|
+
ToolbarBase: B,
|
|
77
|
+
getMetaApi: m,
|
|
78
|
+
META_SERVICE: c
|
|
79
|
+
})
|
|
80
|
+
}), k = T(() => {
|
|
81
|
+
o.position !== l && (S.value ? C() : y.value = !0);
|
|
82
|
+
}, {
|
|
83
|
+
metaData: {
|
|
84
|
+
id: `${G.id}.changeThemeType`
|
|
85
|
+
},
|
|
86
|
+
ctx: () => ({
|
|
87
|
+
props: o,
|
|
88
|
+
getThemeData: t,
|
|
89
|
+
getThemeState: n,
|
|
90
|
+
themeChange: e,
|
|
91
|
+
getTheme: g,
|
|
92
|
+
state: h,
|
|
93
|
+
THEME_DATA: r,
|
|
94
|
+
COLLAPSE: l,
|
|
95
|
+
optionsData: u,
|
|
96
|
+
radioThemeList: a,
|
|
97
|
+
baseContent: b,
|
|
98
|
+
baseIcon: A,
|
|
99
|
+
showpopover: y,
|
|
100
|
+
themeShowType: S,
|
|
101
|
+
toChangeTheme: C,
|
|
102
|
+
changeThemeType: k,
|
|
103
|
+
themeItemChange: L,
|
|
104
|
+
ToolbarBase: B,
|
|
105
|
+
getMetaApi: m,
|
|
106
|
+
META_SERVICE: c
|
|
107
|
+
})
|
|
108
|
+
}), L = T((s) => {
|
|
109
|
+
e(s), y.value = !1;
|
|
110
|
+
}, {
|
|
111
|
+
metaData: {
|
|
112
|
+
id: `${G.id}.themeItemChange`
|
|
113
|
+
},
|
|
114
|
+
ctx: () => ({
|
|
115
|
+
props: o,
|
|
116
|
+
getThemeData: t,
|
|
117
|
+
getThemeState: n,
|
|
118
|
+
themeChange: e,
|
|
119
|
+
getTheme: g,
|
|
120
|
+
state: h,
|
|
121
|
+
THEME_DATA: r,
|
|
122
|
+
COLLAPSE: l,
|
|
123
|
+
optionsData: u,
|
|
124
|
+
radioThemeList: a,
|
|
125
|
+
baseContent: b,
|
|
126
|
+
baseIcon: A,
|
|
127
|
+
showpopover: y,
|
|
128
|
+
themeShowType: S,
|
|
129
|
+
toChangeTheme: C,
|
|
130
|
+
changeThemeType: k,
|
|
131
|
+
themeItemChange: L,
|
|
132
|
+
ToolbarBase: B,
|
|
133
|
+
getMetaApi: m,
|
|
134
|
+
META_SERVICE: c
|
|
135
|
+
})
|
|
136
|
+
});
|
|
38
137
|
return {
|
|
39
138
|
THEME_DATA: r,
|
|
40
|
-
state:
|
|
139
|
+
state: h,
|
|
41
140
|
optionsData: u,
|
|
42
141
|
radioThemeList: a,
|
|
43
|
-
baseContent:
|
|
44
|
-
baseIcon:
|
|
45
|
-
toChangeTheme:
|
|
142
|
+
baseContent: b,
|
|
143
|
+
baseIcon: A,
|
|
144
|
+
toChangeTheme: C,
|
|
46
145
|
themeChange: e,
|
|
47
146
|
showpopover: y,
|
|
48
|
-
themeShowType:
|
|
49
|
-
themeItemChange:
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
changeThemeType: () => {
|
|
53
|
-
o.position !== c && (w.value ? I() : y.value = !0);
|
|
54
|
-
}
|
|
147
|
+
themeShowType: S,
|
|
148
|
+
themeItemChange: L,
|
|
149
|
+
changeThemeType: k
|
|
55
150
|
};
|
|
56
151
|
}
|
|
57
|
-
},
|
|
152
|
+
}, Z = { class: "toolbar-theme-switch" }, $ = { class: "theme-list" }, ee = ["onClick"], te = {
|
|
58
153
|
key: 0,
|
|
59
154
|
class: "toolbar-theme-switch-radio"
|
|
60
155
|
};
|
|
61
|
-
function
|
|
62
|
-
const r =
|
|
63
|
-
return
|
|
64
|
-
|
|
156
|
+
function oe(o, t, n, e, g, h) {
|
|
157
|
+
const r = H("tiny-radio-group"), l = H("toolbar-base"), u = H("tiny-popover");
|
|
158
|
+
return V(), M("div", Z, [
|
|
159
|
+
N(u, {
|
|
65
160
|
width: "130",
|
|
66
161
|
trigger: "manual",
|
|
67
162
|
modelValue: e.showpopover,
|
|
@@ -69,17 +164,17 @@ function Y(o, t, s, e, h, l) {
|
|
|
69
164
|
"visible-arrow": !1,
|
|
70
165
|
"popper-class": "theme-popover"
|
|
71
166
|
}, {
|
|
72
|
-
reference:
|
|
73
|
-
|
|
167
|
+
reference: O(() => [
|
|
168
|
+
N(l, {
|
|
74
169
|
content: e.baseContent,
|
|
75
170
|
icon: e.baseIcon,
|
|
76
171
|
options: e.optionsData,
|
|
77
172
|
onClickApi: e.changeThemeType
|
|
78
173
|
}, {
|
|
79
|
-
default:
|
|
80
|
-
|
|
81
|
-
t[2] || (t[2] =
|
|
82
|
-
|
|
174
|
+
default: O(() => [
|
|
175
|
+
n.position === "collapse" ? (V(), M("div", te, [
|
|
176
|
+
t[2] || (t[2] = U("div", { class: "toolbar-theme-switch-radio-title" }, "主题", -1)),
|
|
177
|
+
N(r, {
|
|
83
178
|
modelValue: e.state.theme,
|
|
84
179
|
"onUpdate:modelValue": t[0] || (t[0] = (a) => e.state.theme = a),
|
|
85
180
|
options: e.radioThemeList,
|
|
@@ -87,62 +182,128 @@ function Y(o, t, s, e, h, l) {
|
|
|
87
182
|
class: "theme-radio-group",
|
|
88
183
|
onChange: e.themeChange
|
|
89
184
|
}, null, 8, ["modelValue", "options", "vertical", "onChange"])
|
|
90
|
-
])) :
|
|
185
|
+
])) : J("", !0)
|
|
91
186
|
]),
|
|
92
187
|
_: 1
|
|
93
188
|
}, 8, ["content", "icon", "options", "onClickApi"])
|
|
94
189
|
]),
|
|
95
|
-
default:
|
|
96
|
-
|
|
97
|
-
(
|
|
190
|
+
default: O(() => [
|
|
191
|
+
U("div", $, [
|
|
192
|
+
(V(!0), M(R, null, j(e.THEME_DATA, (a) => (V(), M("div", {
|
|
98
193
|
key: a.type,
|
|
99
|
-
class:
|
|
100
|
-
onClick: (
|
|
101
|
-
},
|
|
194
|
+
class: z(["theme-item", { active: e.state.theme === a.type }]),
|
|
195
|
+
onClick: (b) => e.themeItemChange(a.type)
|
|
196
|
+
}, q(a.text), 11, ee))), 128))
|
|
102
197
|
])
|
|
103
198
|
]),
|
|
104
199
|
_: 1
|
|
105
200
|
}, 8, ["modelValue"])
|
|
106
201
|
]);
|
|
107
202
|
}
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
title: "themeSwitch",
|
|
112
|
-
options: {
|
|
113
|
-
renderType: "icon"
|
|
114
|
-
}
|
|
115
|
-
}, T = M([]);
|
|
116
|
-
let C = null;
|
|
117
|
-
const i = N({
|
|
203
|
+
const ne = /* @__PURE__ */ X(Y, [["render", oe], ["__scopeId", "data-v-3b11b072"]]), p = F([]);
|
|
204
|
+
let v = null;
|
|
205
|
+
const i = K({
|
|
118
206
|
theme: "",
|
|
119
207
|
themeLabel: "",
|
|
120
208
|
themeIcon: ""
|
|
121
|
-
}),
|
|
209
|
+
}), I = T(() => p, {
|
|
210
|
+
metaData: {
|
|
211
|
+
id: "engine.toolbars.themeSwitch.getThemeData"
|
|
212
|
+
},
|
|
213
|
+
ctx: () => ({
|
|
214
|
+
defineService: E,
|
|
215
|
+
getMetaApi: m,
|
|
216
|
+
getMergeMeta: f,
|
|
217
|
+
META_SERVICE: c,
|
|
218
|
+
setGlobalMonacoEditorTheme: D,
|
|
219
|
+
THEME_DATA: p,
|
|
220
|
+
DEFAULT_THEME: v,
|
|
221
|
+
themeState: i,
|
|
222
|
+
getThemeData: I,
|
|
223
|
+
getThemeState: x,
|
|
224
|
+
getTheme: d,
|
|
225
|
+
themeChange: _
|
|
226
|
+
})
|
|
227
|
+
}), x = T(() => i, {
|
|
228
|
+
metaData: {
|
|
229
|
+
id: "engine.toolbars.themeSwitch.getThemeState"
|
|
230
|
+
},
|
|
231
|
+
ctx: () => ({
|
|
232
|
+
defineService: E,
|
|
233
|
+
getMetaApi: m,
|
|
234
|
+
getMergeMeta: f,
|
|
235
|
+
META_SERVICE: c,
|
|
236
|
+
setGlobalMonacoEditorTheme: D,
|
|
237
|
+
THEME_DATA: p,
|
|
238
|
+
DEFAULT_THEME: v,
|
|
239
|
+
themeState: i,
|
|
240
|
+
getThemeData: I,
|
|
241
|
+
getThemeState: x,
|
|
242
|
+
getTheme: d,
|
|
243
|
+
themeChange: _
|
|
244
|
+
})
|
|
245
|
+
}), d = T((o) => p.value.find((t) => o === t.type) || v, {
|
|
246
|
+
metaData: {
|
|
247
|
+
id: "engine.toolbars.themeSwitch.getTheme"
|
|
248
|
+
},
|
|
249
|
+
ctx: () => ({
|
|
250
|
+
defineService: E,
|
|
251
|
+
getMetaApi: m,
|
|
252
|
+
getMergeMeta: f,
|
|
253
|
+
META_SERVICE: c,
|
|
254
|
+
setGlobalMonacoEditorTheme: D,
|
|
255
|
+
THEME_DATA: p,
|
|
256
|
+
DEFAULT_THEME: v,
|
|
257
|
+
themeState: i,
|
|
258
|
+
getThemeData: I,
|
|
259
|
+
getThemeState: x,
|
|
260
|
+
getTheme: d,
|
|
261
|
+
themeChange: _
|
|
262
|
+
})
|
|
263
|
+
}), _ = T((o) => {
|
|
122
264
|
var e;
|
|
123
|
-
i.theme =
|
|
124
|
-
const t =
|
|
125
|
-
localStorage.setItem(`tiny-engine-theme-${t}`, i.theme),
|
|
126
|
-
},
|
|
127
|
-
|
|
265
|
+
i.theme = d(o).type, i.themeLabel = d(i.theme).text, i.themeIcon = d(i.theme).icon, document.documentElement.setAttribute("data-theme", i.theme);
|
|
266
|
+
const t = m(c.GlobalService).getBaseInfo().id, n = (e = i.theme) != null && e.includes("dark") ? "vs-dark" : "vs";
|
|
267
|
+
localStorage.setItem(`tiny-engine-theme-${t}`, i.theme), D(n);
|
|
268
|
+
}, {
|
|
269
|
+
metaData: {
|
|
270
|
+
id: "engine.toolbars.themeSwitch.themeChange"
|
|
271
|
+
},
|
|
272
|
+
ctx: () => ({
|
|
273
|
+
defineService: E,
|
|
274
|
+
getMetaApi: m,
|
|
275
|
+
getMergeMeta: f,
|
|
276
|
+
META_SERVICE: c,
|
|
277
|
+
setGlobalMonacoEditorTheme: D,
|
|
278
|
+
THEME_DATA: p,
|
|
279
|
+
DEFAULT_THEME: v,
|
|
280
|
+
themeState: i,
|
|
281
|
+
getThemeData: I,
|
|
282
|
+
getThemeState: x,
|
|
283
|
+
getTheme: d,
|
|
284
|
+
themeChange: _
|
|
285
|
+
})
|
|
286
|
+
}), re = E({
|
|
287
|
+
id: c.ThemeSwitch,
|
|
128
288
|
type: "MetaService",
|
|
129
289
|
init: () => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
290
|
+
var n;
|
|
291
|
+
const o = m(c.GlobalService).getBaseInfo().id;
|
|
292
|
+
p.value = ((n = f("engine.config")) == null ? void 0 : n.themesList) || [], v = p.value[0];
|
|
293
|
+
const t = localStorage.getItem(`tiny-engine-theme-${o}`) || f("engine.config").theme || v.type;
|
|
294
|
+
_(t);
|
|
134
295
|
},
|
|
135
296
|
apis: () => ({
|
|
136
|
-
getThemeData:
|
|
137
|
-
getThemeState:
|
|
138
|
-
getTheme:
|
|
139
|
-
themeChange:
|
|
297
|
+
getThemeData: I,
|
|
298
|
+
getThemeState: x,
|
|
299
|
+
getTheme: d,
|
|
300
|
+
themeChange: _
|
|
140
301
|
})
|
|
141
|
-
}),
|
|
142
|
-
|
|
143
|
-
entry:
|
|
302
|
+
}), le = {
|
|
303
|
+
...G,
|
|
304
|
+
entry: ne
|
|
144
305
|
};
|
|
145
306
|
export {
|
|
146
|
-
|
|
147
|
-
|
|
307
|
+
re as ThemeSwitchService,
|
|
308
|
+
le as default
|
|
148
309
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.theme-list .theme-item[data-v-
|
|
1
|
+
.theme-list .theme-item[data-v-3b11b072]{padding:4px 16px;margin:0 -16px}.theme-list .theme-item[data-v-3b11b072]:hover{background-color:var(--te-toolbar-theme-popover-list-item-bg-color-hover)}.theme-list .active[data-v-3b11b072]{background-color:var(--te-toolbar-theme-popover-list-item-bg-color-active)}.toolbar-theme-switch{--te-toolbar-theme-switch-radio-title: var(--te-common-text-secondary)}.theme-list{--te-toolbar-theme-popover-list-item-bg-color-hover: var(--te-common-bg-container);--te-toolbar-theme-popover-list-item-bg-color-active: var(--te-common-bg-container)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/tiny-engine-toolbar-theme-switch",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-alpha.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"homepage": "https://opentiny.design/tiny-engine",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@opentiny/tiny-engine-common": "2.
|
|
29
|
-
"@opentiny/tiny-engine-meta-register": "2.
|
|
30
|
-
"@opentiny/tiny-engine-utils": "2.
|
|
28
|
+
"@opentiny/tiny-engine-common": "2.5.0-alpha.1",
|
|
29
|
+
"@opentiny/tiny-engine-meta-register": "2.5.0-alpha.1",
|
|
30
|
+
"@opentiny/tiny-engine-utils": "2.5.0-alpha.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.
|
|
33
|
+
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.5.0-alpha.1",
|
|
34
34
|
"@vitejs/plugin-vue": "^5.1.2",
|
|
35
35
|
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
|
36
36
|
"vite": "^5.4.2"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"@opentiny/vue": "^3.20.0",
|
|
40
40
|
"vue": "^3.4.15"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "018ca6054f72ee559f0d3ca4dfcbeef4fb411e01"
|
|
43
43
|
}
|