@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 CHANGED
@@ -1,16 +1,18 @@
1
- import { resolveComponent as _, createElementBlock as f, openBlock as u, createVNode as S, withCtx as y, createCommentVNode as A, createElementVNode as k, computed as p, reactive as x } from "vue";
2
- import { ToolbarBase as M, setGlobalMonacoEditorTheme as w } from "@opentiny/tiny-engine-common";
3
- import { RadioGroup as D } from "@opentiny/vue";
4
- import { getMetaApi as T, META_SERVICE as r, defineService as I, getMergeMeta as V } from "@opentiny/tiny-engine-meta-register";
5
- const L = (t, o) => {
6
- const n = t.__vccOpts || t;
7
- for (const [e, c] of o)
8
- n[e] = c;
9
- return n;
10
- }, B = {
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: M,
13
- TinyRadioGroup: D
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(t) {
26
- const { getThemeData: o, getThemeState: n, themeChange: e, getTheme: c } = T(r.ThemeSwitch), s = n(), h = o(), i = "collapse", d = p(() => {
27
- const m = { ...t.options };
28
- return t.position === i && (m.renderType = ""), m;
29
- }), E = p(() => t.position === i ? "" : s.themeLabel), v = p(() => t.position === i ? "" : s.theme);
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: h,
32
- state: s,
33
- optionsData: d,
39
+ THEME_DATA: r,
40
+ state: l,
41
+ optionsData: u,
42
+ radioThemeList: a,
34
43
  baseContent: E,
35
- baseIcon: v,
36
- toChangeTheme: () => {
37
- if (t.position === i)
38
- return;
39
- const m = c(s.theme).oppositeTheme;
40
- e(m);
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
- themeChange: e
52
+ changeThemeType: () => {
53
+ o.position !== c && (w.value ? I() : y.value = !0);
54
+ }
43
55
  };
44
56
  }
45
- }, G = { class: "toolbar-theme-switch" }, H = {
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 N(t, o, n, e, c, s) {
50
- const h = _("tiny-radio-group"), i = _("toolbar-base");
51
- return u(), f("div", G, [
52
- S(i, {
53
- content: e.baseContent,
54
- icon: e.baseIcon,
55
- options: e.optionsData,
56
- onClickApi: e.toChangeTheme
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
- default: y(() => [
59
- n.position === "collapse" ? (u(), f("div", H, [
60
- o[1] || (o[1] = k("div", { class: "toolbar-theme-switch-radio-title" }, "主题", -1)),
61
- S(h, {
62
- modelValue: e.state.theme,
63
- "onUpdate:modelValue": o[0] || (o[0] = (d) => e.state.theme = d),
64
- options: e.THEME_DATA,
65
- class: "theme-radio-group",
66
- onChange: e.themeChange
67
- }, null, 8, ["modelValue", "options", "onChange"])
68
- ])) : A("", !0)
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, ["content", "icon", "options", "onClickApi"])
105
+ }, 8, ["modelValue"])
72
106
  ]);
73
107
  }
74
- const O = /* @__PURE__ */ L(B, [["render", N]]), R = {
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
- }, b = [
82
- {
83
- text: "浅色模式",
84
- label: "light",
85
- oppositeTheme: "dark"
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
- a.theme = g(t).label, a.themeLabel = g(a.theme).text, document.documentElement.setAttribute("data-theme", a.theme);
98
- const o = T(r.GlobalService).getBaseInfo().id, n = (e = a.theme) != null && e.includes("dark") ? "vs-dark" : "vs";
99
- localStorage.setItem(`tiny-engine-theme-${o}`, a.theme), w(n);
100
- }, K = I({
101
- id: r.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,
102
128
  type: "MetaService",
103
129
  init: () => {
104
- const t = T(r.GlobalService).getBaseInfo().id, o = localStorage.getItem(`tiny-engine-theme-${t}`) || V("engine.config").theme || l.label;
105
- C(o);
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: U,
109
- getThemeState: j,
136
+ getThemeData: ee,
137
+ getThemeState: te,
110
138
  getTheme: g,
111
- themeChange: C
139
+ themeChange: k
112
140
  })
113
- }), Q = {
114
- ...R,
115
- entry: O
141
+ }), me = {
142
+ ...$,
143
+ entry: Z
116
144
  };
117
145
  export {
118
- K as ThemeSwitchService,
119
- Q as default
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.0",
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.3.0",
29
- "@opentiny/tiny-engine-meta-register": "2.3.0",
30
- "@opentiny/tiny-engine-utils": "2.3.0"
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.3.0",
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": "330c4d2b319d5b5ba6ad64c270c21a7931a2e400"
42
+ "gitHead": "40df6ee51c80bf918c176f7e8ad97b6b687ddc7b"
43
43
  }