@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 CHANGED
@@ -1,25 +1,18 @@
1
1
  import "./style.css";
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 = {
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: B,
21
- TinyRadioGroup: W,
22
- TinyPopover: Q
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
- 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
- });
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: h,
40
+ state: l,
140
41
  optionsData: u,
141
42
  radioThemeList: a,
142
- baseContent: b,
143
- baseIcon: A,
144
- toChangeTheme: C,
43
+ baseContent: E,
44
+ baseIcon: D,
45
+ toChangeTheme: I,
145
46
  themeChange: e,
146
47
  showpopover: y,
147
- themeShowType: S,
148
- themeItemChange: L,
149
- changeThemeType: k
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
- }, Z = { class: "toolbar-theme-switch" }, $ = { class: "theme-list" }, ee = ["onClick"], te = {
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 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, {
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: O(() => [
168
- N(l, {
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: 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, {
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
- ])) : J("", !0)
90
+ ])) : H("", !0)
186
91
  ]),
187
92
  _: 1
188
93
  }, 8, ["content", "icon", "options", "onClickApi"])
189
94
  ]),
190
- default: O(() => [
191
- U("div", $, [
192
- (V(!0), M(R, null, j(e.THEME_DATA, (a) => (V(), M("div", {
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: z(["theme-item", { active: e.state.theme === a.type }]),
195
- onClick: (b) => e.themeItemChange(a.type)
196
- }, q(a.text), 11, ee))), 128))
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 ne = /* @__PURE__ */ X(Y, [["render", oe], ["__scopeId", "data-v-3b11b072"]]), p = F([]);
204
- let v = null;
205
- const i = K({
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
- }), 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) => {
121
+ }), ee = () => T, te = () => i, g = (o) => T.value.find((t) => o === t.type) || C, k = (o) => {
264
122
  var e;
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,
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
- 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);
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: I,
298
- getThemeState: x,
299
- getTheme: d,
300
- themeChange: _
136
+ getThemeData: ee,
137
+ getThemeState: te,
138
+ getTheme: g,
139
+ themeChange: k
301
140
  })
302
- }), le = {
303
- ...G,
304
- entry: ne
141
+ }), me = {
142
+ ...$,
143
+ entry: Z
305
144
  };
306
145
  export {
307
- re as ThemeSwitchService,
308
- le as default
146
+ le as ThemeSwitchService,
147
+ me as default
309
148
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
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)}
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.0",
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.0",
29
- "@opentiny/tiny-engine-meta-register": "2.5.0-alpha.0",
30
- "@opentiny/tiny-engine-utils": "2.5.0-alpha.0"
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.0",
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": "ae59c82734d79f650c9221cb9702714814b099c8"
42
+ "gitHead": "f5707c379397bffc9a63c50c695f3ee3340ad0c6"
43
43
  }