@opentiny/tiny-engine-toolbar-media 1.0.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 ADDED
@@ -0,0 +1,383 @@
1
+ import "./style.css";
2
+ import { ref as V, computed as M, reactive as z, toRaw as R, watchEffect as j, watch as G, onMounted as H, onUnmounted as J, resolveComponent as C, openBlock as v, createElementBlock as W, createElementVNode as i, Fragment as K, renderList as Q, normalizeClass as Y, createVNode as b, withCtx as p, toDisplayString as c, createTextVNode as I, createBlock as E, createCommentVNode as N, pushScopeId as Z, popScopeId as $ } from "vue";
3
+ import { Popover as ee, Input as te, Switch as ie } from "@opentiny/vue";
4
+ import { IconWebPlus as D } from "@opentiny/vue-icon";
5
+ import { useLayout as h } from "@opentiny/tiny-engine-controller";
6
+ import { getCanvasType as ne, setCanvasType as oe } from "@opentiny/tiny-engine-canvas";
7
+ const se = (d, l) => {
8
+ const r = d.__vccOpts || d;
9
+ for (const [n, u] of l)
10
+ r[n] = u;
11
+ return r;
12
+ }, ae = {
13
+ components: {
14
+ TinyPopover: ee,
15
+ TinyInput: te,
16
+ TinySwitch: ie
17
+ },
18
+ props: {
19
+ data: {
20
+ type: Object,
21
+ default: () => ({})
22
+ },
23
+ isCanvas: {
24
+ type: Boolean,
25
+ default: !0
26
+ }
27
+ },
28
+ setup(d, { emit: l }) {
29
+ let r = null, n = "", u = "";
30
+ const { layoutState: _ } = h(), m = V(!1), w = V(!1), x = V(!1), T = V(ne() === "absolute"), s = M(() => h().getDimension()), y = M(() => s.value.scale * 100), t = z({
31
+ activeIndex: 0,
32
+ guideValue: "",
33
+ width: "",
34
+ scaleValue: "",
35
+ readonly: !1,
36
+ viewWidth: null,
37
+ moreData: {
38
+ title: "添加大断点",
39
+ list: [
40
+ {
41
+ icon: D(),
42
+ text: "1280px"
43
+ },
44
+ {
45
+ icon: D(),
46
+ text: "1440px"
47
+ },
48
+ {
49
+ icon: D(),
50
+ text: "1920px"
51
+ }
52
+ ],
53
+ tips: "将鼠标悬停在断点上以了解更多信息"
54
+ },
55
+ textData: {
56
+ title: "画布设置",
57
+ width: "宽度",
58
+ scale: "缩放",
59
+ list: [
60
+ {
61
+ text: "自由布局"
62
+ }
63
+ ],
64
+ vision: "视觉预览"
65
+ },
66
+ guideOptions: [
67
+ {
68
+ value: "选项1",
69
+ label: "No guide"
70
+ },
71
+ {
72
+ value: "选项2",
73
+ label: "Line guide(960px)"
74
+ },
75
+ {
76
+ value: "选项3",
77
+ label: "Filled guide(960px)"
78
+ }
79
+ ],
80
+ media: [
81
+ {
82
+ idx: 0,
83
+ view: "mdx",
84
+ icon: "IconDesktopView",
85
+ liked: "desktop-large",
86
+ width: "1920px",
87
+ minWidth: "1200px",
88
+ maxWidth: "1920px",
89
+ title: "大屏",
90
+ subTitle: "1200px 及以上",
91
+ content: "此处添加的样式将适用于 1200 像素及以上,除非它们在更大的断点处进行编辑",
92
+ enContent: "Style added here will apply at 1200px and up,unless they′re edited at a larger breakpoint"
93
+ },
94
+ {
95
+ idx: 1,
96
+ view: "desktop",
97
+ icon: "IconDesktopView",
98
+ liked: "laptop-cut-corner",
99
+ width: "1200px",
100
+ minWidth: "992px",
101
+ maxWidth: "1200px",
102
+ title: "PC 端",
103
+ subTitle: "基本断点",
104
+ content: "桌面端样式适用于所有断点,除非它们在更大或更小的断点处进行编辑,在这里开始你的布局。",
105
+ enContent: "Desktop styles apply at all breakpoints,unless they′re edited at a larger or smaller breakpoints. Start your stying here."
106
+ },
107
+ {
108
+ idx: 2,
109
+ view: "tablet",
110
+ icon: "IconTabletView",
111
+ liked: "tablet-portrait",
112
+ width: "992px",
113
+ minWidth: "768px",
114
+ maxWidth: "992px",
115
+ title: "平板",
116
+ subTitle: "992px 及以下",
117
+ content: "此处添加的样式将适用于 992 像素及以下,除非它们在较小的断点处进行编辑。",
118
+ enContent: "styles added here will apply at 992px and down,unless they′re edited at smaller breakpoints."
119
+ },
120
+ {
121
+ idx: 3,
122
+ view: "lanMobile",
123
+ icon: "IconMobileView",
124
+ liked: "mobile-landscape",
125
+ width: "768px",
126
+ minWidth: "480px",
127
+ maxWidth: "768px",
128
+ title: "手机横屏",
129
+ subTitle: "768px 及以下",
130
+ content: "此处添加的样式将适用于 768 像素及以下,除非它们在较小的断点处进行编辑。",
131
+ enContent: "styles added here will apply at 768px and down,unless they′re edited at smaller breakpoints."
132
+ },
133
+ {
134
+ idx: 4,
135
+ view: "mobile",
136
+ icon: "IconMobileView",
137
+ liked: "mobile-portrai",
138
+ width: "480px",
139
+ minWidth: "240px",
140
+ maxWidth: "480px",
141
+ title: "手机竖屏",
142
+ subTitle: "480px 及以下",
143
+ content: "此处添加的样式将适用于 480 像素及以下。",
144
+ enContent: "styles added here will apply at 480px and down."
145
+ }
146
+ ]
147
+ }), L = () => {
148
+ w.value = !1;
149
+ }, B = () => {
150
+ r = setTimeout(() => {
151
+ m.value = !0;
152
+ }, 1e3);
153
+ }, F = () => {
154
+ m.value = !1, clearTimeout(r);
155
+ }, U = () => {
156
+ _.toolbars.visiblePopover = !0, x.value = !0;
157
+ }, A = () => {
158
+ _.toolbars.visiblePopover = !1, x.value = !1;
159
+ }, P = (e) => {
160
+ const o = document.querySelector(".reference-text"), a = o == null ? void 0 : o.contains(e.target);
161
+ o !== e.target && !a && (_.toolbars.visiblePopover = !1);
162
+ }, g = t.media.reduce((e, o, a) => (e[o.view] = { ...R(o), index: a }, e), {}), S = (e) => {
163
+ d.isCanvas ? (h().setDimension({
164
+ deviceType: e.view,
165
+ width: e.width,
166
+ minWidth: e.minWidth,
167
+ maxWidth: e.maxWidth
168
+ }), t.width = parseInt(e.width, 10), t.scaleValue = y.value.toFixed(2), t.readonly = e.view !== "mdx") : (t.activeIndex = e.idx, l("setViewPort", e.width));
169
+ }, f = (e, o) => {
170
+ const a = g[o];
171
+ t.activeIndex = g[o].index, h().setDimension({
172
+ deviceType: a.view,
173
+ width: e ? `${e}px` : a.width,
174
+ minWidth: a.minWidth,
175
+ maxWidth: a.maxWidth
176
+ });
177
+ }, O = (e) => {
178
+ const o = "^[0-9]*$", a = h().getDimension();
179
+ switch (String(e).match(o) ? String(e) === "0" || Number(e) < 240 ? (t.width = 240, n = 240) : Number(e) > 1920 ? (t.width = 1920, n = 1920) : n = e : t.width = n || parseInt(a.width), !0) {
180
+ case (1200 < Number(t.width) && Number(t.width) <= 1920):
181
+ f(e, "mdx");
182
+ break;
183
+ case (992 < Number(t.width) && Number(t.width) <= 1200):
184
+ f(e, "desktop");
185
+ break;
186
+ case (768 < Number(t.width) && Number(t.width) <= 992):
187
+ f(e, "tablet");
188
+ break;
189
+ case (480 < Number(t.width) && Number(t.width) <= 768):
190
+ f(e, "lanMobile");
191
+ break;
192
+ case (240 <= Number(t.width) && Number(t.width) <= 480):
193
+ f(e, "mobile");
194
+ break;
195
+ }
196
+ }, X = (e) => {
197
+ const o = g.mdx, a = "^[0-9]*$";
198
+ String(e).match(a) ? Number(e) > 100 ? t.scaleValue = 100 : Number(e) < 20 ? t.scaleValue = 20 : u = e : t.scaleValue = u || parseInt(o.scale), h().setDimension({
199
+ deviceType: o.view,
200
+ width: o.width,
201
+ minWidth: o.minWidth,
202
+ maxWidth: o.maxWidth,
203
+ scale: Number(t.scaleValue) / 100
204
+ });
205
+ }, q = (e) => {
206
+ oe(e ? "absolute" : "normal");
207
+ };
208
+ return j(
209
+ () => {
210
+ const e = s.value.deviceType || "desktop";
211
+ t.activeIndex = g[e].index || 0, S(g[e]);
212
+ },
213
+ { flush: "post" }
214
+ ), G(
215
+ () => h().getDimension().width,
216
+ (e) => {
217
+ const o = parseInt(e, 10);
218
+ Number.isInteger(o) && o !== t.width && (t.width = o);
219
+ }
220
+ ), H(() => {
221
+ document.addEventListener("click", P);
222
+ }), J(() => {
223
+ document.removeEventListener("click", P);
224
+ }), {
225
+ scale: y,
226
+ state: t,
227
+ active: w,
228
+ flag: x,
229
+ hide: L,
230
+ layoutState: _,
231
+ visible: m,
232
+ showTips: B,
233
+ hideTips: F,
234
+ timer: r,
235
+ dimension: s,
236
+ setViewPort: S,
237
+ showPopover: U,
238
+ hidePopover: A,
239
+ widthChange: O,
240
+ scaleChange: X,
241
+ isAbsolute: T,
242
+ changeCanvasType: q
243
+ };
244
+ }
245
+ }, k = (d) => (Z("data-v-c1e7d8e3"), d = d(), $(), d), le = { class: "toolbar-wrap" }, de = { class: "toolbar-icon-wrap" }, ce = ["onClick"], re = { class: "media-content" }, pe = { class: "media-title" }, he = {
246
+ key: 0,
247
+ class: "sub-title"
248
+ }, ue = { class: "content" }, me = { class: "reference-text" }, we = /* @__PURE__ */ k(() => /* @__PURE__ */ i("span", { class: "symbol" }, "PX", -1)), xe = /* @__PURE__ */ k(() => /* @__PURE__ */ i("span", { class: "symbol" }, "%", -1)), ve = { class: "content-wrap text-content" }, be = { class: "title text-title" }, _e = { class: "setting" }, ye = { for: "" }, ge = /* @__PURE__ */ k(() => /* @__PURE__ */ i("span", null, "PX", -1)), fe = { for: "" }, ke = /* @__PURE__ */ k(() => /* @__PURE__ */ i("span", null, "%", -1)), Ve = { class: "more-setting" }, Ce = /* @__PURE__ */ k(() => /* @__PURE__ */ i("div", null, [
249
+ /* @__PURE__ */ i("span", null, /* @__PURE__ */ c("自由布局"))
250
+ ], -1));
251
+ function We(d, l, r, n, u, _) {
252
+ const m = C("svg-icon"), w = C("tiny-popover"), x = C("tiny-input"), T = C("tiny-switch");
253
+ return v(), W("div", le, [
254
+ i("div", de, [
255
+ (v(!0), W(K, null, Q(n.state.media, (s, y) => (v(), W("span", {
256
+ key: y,
257
+ class: Y(["icon", { active: n.state.activeIndex === y, "is-rotate": s.view === "lanMobile" }]),
258
+ onClick: (t) => n.setViewPort(s)
259
+ }, [
260
+ b(w, {
261
+ trigger: "hover",
262
+ width: "225",
263
+ "append-to-body": "",
264
+ "open-delay": 1e3,
265
+ "popper-class": "media-icon-popover"
266
+ }, {
267
+ reference: p(() => [
268
+ b(m, {
269
+ name: s.liked,
270
+ class: "media-icon"
271
+ }, null, 8, ["name"])
272
+ ]),
273
+ default: p(() => [
274
+ i("div", re, [
275
+ i("div", pe, [
276
+ i("div", null, c(s.title), 1),
277
+ s.subTitle ? (v(), W("div", he, [
278
+ I(" ("),
279
+ s.view === "desktop" ? (v(), E(m, {
280
+ key: 0,
281
+ name: "stars"
282
+ })) : N("", !0),
283
+ I(),
284
+ i("span", null, c(s.subTitle), 1),
285
+ I(") ")
286
+ ])) : N("", !0)
287
+ ]),
288
+ i("div", ue, c(s.content), 1)
289
+ ])
290
+ ]),
291
+ _: 2
292
+ }, 1024)
293
+ ], 10, ce))), 128))
294
+ ]),
295
+ r.isCanvas ? (v(), E(w, {
296
+ key: 0,
297
+ width: "290",
298
+ trigger: "click",
299
+ "popper-class": "toolbar-media-popper"
300
+ }, {
301
+ reference: p(() => [
302
+ b(w, {
303
+ trigger: "hover",
304
+ "open-delay": 1e3,
305
+ "popper-class": "toolbar-right-popover",
306
+ "append-to-body": "",
307
+ content: "画布设置"
308
+ }, {
309
+ reference: p(() => [
310
+ i("span", me, [
311
+ i("span", null, [
312
+ i("span", null, c(parseInt(n.state.width)), 1),
313
+ we
314
+ ]),
315
+ i("span", null, [
316
+ i("span", null, c(n.scale.toFixed(2)), 1),
317
+ xe
318
+ ])
319
+ ])
320
+ ]),
321
+ _: 1
322
+ })
323
+ ]),
324
+ default: p(() => [
325
+ i("div", ve, [
326
+ i("span", be, c(n.state.textData.title), 1),
327
+ i("div", _e, [
328
+ i("div", null, [
329
+ i("label", ye, c(n.state.textData.width), 1),
330
+ b(x, {
331
+ modelValue: n.state.width,
332
+ "onUpdate:modelValue": l[0] || (l[0] = (s) => n.state.width = s),
333
+ onChange: n.widthChange
334
+ }, {
335
+ suffix: p(() => [
336
+ ge
337
+ ]),
338
+ _: 1
339
+ }, 8, ["modelValue", "onChange"])
340
+ ]),
341
+ i("div", null, [
342
+ i("label", fe, c(n.state.textData.scale), 1),
343
+ b(x, {
344
+ modelValue: n.state.scaleValue,
345
+ "onUpdate:modelValue": l[1] || (l[1] = (s) => n.state.scaleValue = s),
346
+ readonly: n.state.readonly,
347
+ onChange: n.scaleChange
348
+ }, {
349
+ suffix: p(() => [
350
+ ke
351
+ ]),
352
+ _: 1
353
+ }, 8, ["modelValue", "readonly", "onChange"])
354
+ ])
355
+ ]),
356
+ i("ul", Ve, [
357
+ i("li", null, [
358
+ Ce,
359
+ i("div", null, [
360
+ b(T, {
361
+ modelValue: n.isAbsolute,
362
+ "onUpdate:modelValue": l[2] || (l[2] = (s) => n.isAbsolute = s),
363
+ onChange: n.changeCanvasType
364
+ }, null, 8, ["modelValue", "onChange"])
365
+ ])
366
+ ])
367
+ ])
368
+ ])
369
+ ]),
370
+ _: 1
371
+ })) : N("", !0)
372
+ ]);
373
+ }
374
+ const Te = /* @__PURE__ */ se(ae, [["render", We], ["__scopeId", "data-v-c1e7d8e3"]]), Ee = {
375
+ id: "media",
376
+ title: "media",
377
+ icon: "",
378
+ align: "center",
379
+ component: Te
380
+ };
381
+ export {
382
+ Ee as default
383
+ };
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .toolbar-wrap[data-v-c1e7d8e3]{display:flex;align-items:center}.toolbar-wrap .reference-text[data-v-c1e7d8e3]{cursor:pointer;height:var(--base-top-panel-height);line-height:var(--base-top-panel-height);padding:0 7px;color:var(--ti-lowcode-toolbar-breadcrumb-color);display:inline-block}.toolbar-wrap .reference-text>span[data-v-c1e7d8e3]:last-child{margin-left:8px}.toolbar-wrap .toolbar-icon-wrap[data-v-c1e7d8e3]{display:flex;flex-wrap:nowrap;align-items:center;gap:6px}.toolbar-wrap .toolbar-icon-wrap .icon[data-v-c1e7d8e3]{width:32px;height:32px;display:inline-flex;justify-content:center;align-items:center;border-radius:6px}.toolbar-wrap .toolbar-icon-wrap .icon svg[data-v-c1e7d8e3]{cursor:pointer;color:var(--ti-lowcode-toolbar-title-color);outline:none;width:22px;height:22px;margin-top:-.5px}.toolbar-wrap .toolbar-icon-wrap .icon.active[data-v-c1e7d8e3],.toolbar-wrap .toolbar-icon-wrap .icon[data-v-c1e7d8e3]:hover{background:var(--ti-lowcode-toolbar-view-active-bg)}.toolbar-wrap .toolbar-icon-wrap .icon.active svg[data-v-c1e7d8e3]{color:var(--ti-lowcode-common-primary-color)}.toolbar-wrap .more-setting .setting-item[data-v-c1e7d8e3]{display:flex;justify-content:space-between;padding:12px}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@opentiny/tiny-engine-toolbar-media",
3
+ "version": "1.0.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "scripts": {
8
+ "build": "vite build"
9
+ },
10
+ "main": "dist/index.js",
11
+ "module": "dist/index.js",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "dependencies": {
16
+ "@opentiny/vue": "^3.8.0",
17
+ "vue": "3.2.45"
18
+ },
19
+ "devDependencies": {
20
+ "@vitejs/plugin-vue": "^4.2.3",
21
+ "@vitejs/plugin-vue-jsx": "^1.3.10",
22
+ "vite": "^4.3.7"
23
+ }
24
+ }