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