@opentiny/tiny-engine-toolbar-theme-switch 2.3.0 → 2.4.0-rc.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.
- package/dist/index.js +107 -79
- package/dist/style.css +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import "./style.css";
|
|
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 = {
|
|
11
12
|
components: {
|
|
12
|
-
ToolbarBase:
|
|
13
|
-
TinyRadioGroup:
|
|
13
|
+
ToolbarBase: O,
|
|
14
|
+
TinyRadioGroup: F,
|
|
15
|
+
TinyPopover: U
|
|
14
16
|
},
|
|
15
17
|
props: {
|
|
16
18
|
options: {
|
|
@@ -22,99 +24,125 @@ const L = (t, o) => {
|
|
|
22
24
|
default: "right"
|
|
23
25
|
}
|
|
24
26
|
},
|
|
25
|
-
setup(
|
|
26
|
-
const { getThemeData:
|
|
27
|
-
const
|
|
28
|
-
return
|
|
29
|
-
}), E =
|
|
27
|
+
setup(o) {
|
|
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
|
+
};
|
|
30
38
|
return {
|
|
31
|
-
THEME_DATA:
|
|
32
|
-
state:
|
|
33
|
-
optionsData:
|
|
39
|
+
THEME_DATA: r,
|
|
40
|
+
state: l,
|
|
41
|
+
optionsData: u,
|
|
42
|
+
radioThemeList: a,
|
|
34
43
|
baseContent: E,
|
|
35
|
-
baseIcon:
|
|
36
|
-
toChangeTheme:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
baseIcon: D,
|
|
45
|
+
toChangeTheme: I,
|
|
46
|
+
themeChange: e,
|
|
47
|
+
showpopover: y,
|
|
48
|
+
themeShowType: w,
|
|
49
|
+
themeItemChange: (n) => {
|
|
50
|
+
e(n), y.value = !1;
|
|
41
51
|
},
|
|
42
|
-
|
|
52
|
+
changeThemeType: () => {
|
|
53
|
+
o.position !== c && (w.value ? I() : y.value = !0);
|
|
54
|
+
}
|
|
43
55
|
};
|
|
44
56
|
}
|
|
45
|
-
},
|
|
57
|
+
}, K = { class: "toolbar-theme-switch" }, Q = { class: "theme-list" }, W = ["onClick"], X = {
|
|
46
58
|
key: 0,
|
|
47
59
|
class: "toolbar-theme-switch-radio"
|
|
48
60
|
};
|
|
49
|
-
function
|
|
50
|
-
const
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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, {
|
|
65
|
+
width: "130",
|
|
66
|
+
trigger: "manual",
|
|
67
|
+
modelValue: e.showpopover,
|
|
68
|
+
"onUpdate:modelValue": t[1] || (t[1] = (a) => e.showpopover = a),
|
|
69
|
+
"visible-arrow": !1,
|
|
70
|
+
"popper-class": "theme-popover"
|
|
57
71
|
}, {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
reference: b(() => [
|
|
73
|
+
f(c, {
|
|
74
|
+
content: e.baseContent,
|
|
75
|
+
icon: e.baseIcon,
|
|
76
|
+
options: e.optionsData,
|
|
77
|
+
onClickApi: e.changeThemeType
|
|
78
|
+
}, {
|
|
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, {
|
|
83
|
+
modelValue: e.state.theme,
|
|
84
|
+
"onUpdate:modelValue": t[0] || (t[0] = (a) => e.state.theme = a),
|
|
85
|
+
options: e.radioThemeList,
|
|
86
|
+
vertical: !e.themeShowType,
|
|
87
|
+
class: "theme-radio-group",
|
|
88
|
+
onChange: e.themeChange
|
|
89
|
+
}, null, 8, ["modelValue", "options", "vertical", "onChange"])
|
|
90
|
+
])) : H("", !0)
|
|
91
|
+
]),
|
|
92
|
+
_: 1
|
|
93
|
+
}, 8, ["content", "icon", "options", "onClickApi"])
|
|
94
|
+
]),
|
|
95
|
+
default: b(() => [
|
|
96
|
+
A("div", Q, [
|
|
97
|
+
(d(!0), p(V, null, x(e.THEME_DATA, (a) => (d(), p("div", {
|
|
98
|
+
key: a.type,
|
|
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))
|
|
102
|
+
])
|
|
69
103
|
]),
|
|
70
104
|
_: 1
|
|
71
|
-
}, 8, ["
|
|
105
|
+
}, 8, ["modelValue"])
|
|
72
106
|
]);
|
|
73
107
|
}
|
|
74
|
-
const
|
|
108
|
+
const Z = /* @__PURE__ */ q(J, [["render", Y], ["__scopeId", "data-v-e0cba3bc"]]), $ = {
|
|
75
109
|
id: "engine.toolbars.themeSwitch",
|
|
76
110
|
type: "toolbars",
|
|
77
111
|
title: "themeSwitch",
|
|
78
112
|
options: {
|
|
79
113
|
renderType: "icon"
|
|
80
114
|
}
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
text: "深色模式",
|
|
89
|
-
label: "dark",
|
|
90
|
-
oppositeTheme: "light"
|
|
91
|
-
}
|
|
92
|
-
], l = b[0], a = x({
|
|
93
|
-
theme: l.label,
|
|
94
|
-
themeLabel: l.text
|
|
95
|
-
}), U = () => b, j = () => a, g = (t) => b.find((o) => t === o.label) || l, C = (t) => {
|
|
115
|
+
}, T = M([]);
|
|
116
|
+
let C = null;
|
|
117
|
+
const i = N({
|
|
118
|
+
theme: "",
|
|
119
|
+
themeLabel: "",
|
|
120
|
+
themeIcon: ""
|
|
121
|
+
}), ee = () => T, te = () => i, g = (o) => T.value.find((t) => o === t.type) || C, k = (o) => {
|
|
96
122
|
var e;
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
localStorage.setItem(`tiny-engine-theme-${
|
|
100
|
-
},
|
|
101
|
-
id:
|
|
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,
|
|
102
128
|
type: "MetaService",
|
|
103
129
|
init: () => {
|
|
104
|
-
const
|
|
105
|
-
|
|
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);
|
|
106
134
|
},
|
|
107
135
|
apis: () => ({
|
|
108
|
-
getThemeData:
|
|
109
|
-
getThemeState:
|
|
136
|
+
getThemeData: ee,
|
|
137
|
+
getThemeState: te,
|
|
110
138
|
getTheme: g,
|
|
111
|
-
themeChange:
|
|
139
|
+
themeChange: k
|
|
112
140
|
})
|
|
113
|
-
}),
|
|
114
|
-
|
|
115
|
-
entry:
|
|
141
|
+
}), me = {
|
|
142
|
+
...$,
|
|
143
|
+
entry: Z
|
|
116
144
|
};
|
|
117
145
|
export {
|
|
118
|
-
|
|
119
|
-
|
|
146
|
+
le as ThemeSwitchService,
|
|
147
|
+
me as default
|
|
120
148
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.toolbar-theme-switch{--te-toolbar-theme-switch-radio-title: var(--te-common-text-secondary)}
|
|
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.
|
|
3
|
+
"version": "2.4.0-rc.0",
|
|
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.4.0-rc.0",
|
|
29
|
+
"@opentiny/tiny-engine-meta-register": "2.4.0-rc.0",
|
|
30
|
+
"@opentiny/tiny-engine-utils": "2.4.0-rc.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.
|
|
33
|
+
"@opentiny/tiny-engine-vite-plugin-meta-comments": "2.4.0-rc.0",
|
|
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": "40df6ee51c80bf918c176f7e8ad97b6b687ddc7b"
|
|
43
43
|
}
|