@opentiny/tiny-engine-toolbar-media 1.0.3 → 1.0.4

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,18 +1,17 @@
1
1
  import "./style.css";
2
- import { ref as V, computed as E, reactive as K, toRaw as Q, watch as F, watchEffect as Y, onMounted as Z, onUnmounted as $, resolveComponent as k, openBlock as w, createElementBlock as C, createElementVNode as t, Fragment as ee, renderList as te, normalizeClass as ne, createVNode as _, withCtx as p, toDisplayString as c, createTextVNode as W, createBlock as L, createCommentVNode as I, pushScopeId as oe, popScopeId as ie } from "vue";
3
- import { Popover as ae, Input as se, Switch as le } from "@opentiny/vue";
2
+ import { ref as k, computed as A, reactive as Q, toRaw as Y, watch as E, watchEffect as Z, onMounted as $, onUnmounted as ee, resolveComponent as C, openBlock as x, createElementBlock as W, createElementVNode as t, Fragment as te, renderList as ne, normalizeClass as ie, createVNode as w, withCtx as p, toDisplayString as r, createTextVNode as T, createBlock as F, createCommentVNode as I } from "vue";
3
+ import { Popover as oe, Input as ae, Switch as le } from "@opentiny/vue";
4
4
  import { IconWebPlus as P } from "@opentiny/vue-icon";
5
- import { useLayout as y } from "@opentiny/tiny-engine-controller";
6
- import { getCanvasType as de, setCanvasType as ce } from "@opentiny/tiny-engine-canvas";
7
- const re = (d, l) => {
8
- const r = d.__vccOpts || d;
9
- for (const [n, u] of l)
10
- r[n] = u;
11
- return r;
12
- }, pe = {
5
+ import { useLayout as g, useCanvas as L } from "@opentiny/tiny-engine-controller";
6
+ const se = (b, n) => {
7
+ const c = b.__vccOpts || b;
8
+ for (const [i, u] of n)
9
+ c[i] = u;
10
+ return c;
11
+ }, de = {
13
12
  components: {
14
- TinyPopover: ae,
15
- TinyInput: se,
13
+ TinyPopover: oe,
14
+ TinyInput: ae,
16
15
  TinySwitch: le
17
16
  },
18
17
  props: {
@@ -25,9 +24,9 @@ const re = (d, l) => {
25
24
  default: !0
26
25
  }
27
26
  },
28
- setup(d, { emit: l }) {
29
- let r = null, n = "", u = "";
30
- const { layoutState: b } = y(), m = V(!1), h = V(!1), v = V(!1), T = V(de() === "absolute"), o = E(() => y().getDimension()), x = E(() => o.value.scale * 100), i = K({
27
+ setup(b, { emit: n }) {
28
+ let c = null, i = "", u = "";
29
+ const { layoutState: y } = g(), m = k(!1), v = k(!1), h = k(!1), { getCanvasType: f } = L().canvasApi.value, l = k((f == null ? void 0 : f()) === "absolute"), d = A(() => g().getDimension()), _ = A(() => d.value.scale * 100), o = Q({
31
30
  activeIndex: 0,
32
31
  guideValue: "",
33
32
  width: "",
@@ -145,112 +144,111 @@ const re = (d, l) => {
145
144
  }
146
145
  ]
147
146
  }), B = () => {
148
- h.value = !1;
147
+ v.value = !1;
149
148
  }, U = () => {
150
- r = setTimeout(() => {
149
+ c = setTimeout(() => {
151
150
  m.value = !0;
152
151
  }, 1e3);
153
- }, A = () => {
154
- m.value = !1, clearTimeout(r);
155
152
  }, O = () => {
156
- b.toolbars.visiblePopover = !0, v.value = !0;
153
+ m.value = !1, clearTimeout(c);
157
154
  }, X = () => {
158
- b.toolbars.visiblePopover = !1, v.value = !1;
155
+ y.toolbars.visiblePopover = !0, h.value = !0;
156
+ }, q = () => {
157
+ y.toolbars.visiblePopover = !1, h.value = !1;
159
158
  }, D = (e) => {
160
159
  const a = document.querySelector(".reference-text"), s = a == null ? void 0 : a.contains(e.target);
161
- a !== e.target && !s && (b.toolbars.visiblePopover = !1);
162
- }, g = i.media.reduce((e, a, s) => (e[a.view] = { ...Q(a), index: s }, e), {}), N = (e) => {
163
- d.isCanvas ? y().setDimension({
160
+ a !== e.target && !s && (y.toolbars.visiblePopover = !1);
161
+ }, V = o.media.reduce((e, a, s) => (e[a.view] = { ...Y(a), index: s }, e), {}), N = (e) => {
162
+ b.isCanvas ? g().setDimension({
164
163
  deviceType: e.view,
165
164
  width: e.width,
166
165
  minWidth: e.minWidth,
167
166
  maxWidth: e.maxWidth
168
- }) : (i.activeIndex = e.idx, l("setViewPort", e.width));
169
- }, q = (e, a) => {
170
- const s = g[a];
171
- y().setDimension({
167
+ }) : (o.activeIndex = e.idx, n("setViewPort", e.width));
168
+ }, z = (e, a) => {
169
+ const s = V[a];
170
+ g().setDimension({
172
171
  deviceType: s.view,
173
172
  width: e ? `${e}px` : s.width,
174
173
  minWidth: s.minWidth,
175
174
  maxWidth: s.maxWidth
176
175
  });
177
- }, z = [
176
+ }, R = [
178
177
  { type: "mobile", min: 240, max: 480 },
179
178
  { type: "lanMobile", min: 480, max: 768 },
180
179
  { type: "tablet", min: 768, max: 992 },
181
180
  { type: "desktop", min: 992, max: 1200 },
182
181
  { type: "mdx", min: 1200, max: 1920 }
183
- ], R = (e) => {
182
+ ], j = (e) => {
184
183
  var S;
185
184
  const a = /^\d+$/;
186
- String(e).match(a) ? Number(e) < 240 ? i.width = 240 : Number(e) > 1920 ? i.width = 1920 : i.width = e : i.width = n || parseInt(o.value.width, 10);
187
- const s = Number(i.width), J = ((S = z.find((M) => M.min <= s && s <= M.max)) == null ? void 0 : S.type) || "desktop";
188
- q(s, J);
189
- }, j = (e) => {
190
- const a = g.mdx, s = /^\d+(\.\d+)?$/;
191
- String(e).match(s) ? Number(e) > 100 ? i.scaleValue = 100 : Number(e) < 20 ? i.scaleValue = 20 : i.scaleValue = e : i.scaleValue = u || parseInt(a.scale), i.scaleValue = Number(i.scaleValue).toFixed(2), y().setDimension({
192
- scale: Number(i.scaleValue) / 100
193
- });
185
+ String(e).match(a) ? Number(e) < 240 ? o.width = 240 : Number(e) > 1920 ? o.width = 1920 : o.width = e : o.width = i || parseInt(d.value.width, 10);
186
+ const s = Number(o.width), K = ((S = R.find((M) => M.min <= s && s <= M.max)) == null ? void 0 : S.type) || "desktop";
187
+ z(s, K);
194
188
  }, G = (e) => {
195
- ce(e ? "absolute" : "normal");
189
+ const a = V.mdx, s = /^\d+(\.\d+)?$/;
190
+ String(e).match(s) ? Number(e) > 100 ? o.scaleValue = 100 : Number(e) < 20 ? o.scaleValue = 20 : o.scaleValue = e : o.scaleValue = u || parseInt(a.scale), o.scaleValue = Number(o.scaleValue).toFixed(2), g().setDimension({
191
+ scale: Number(o.scaleValue) / 100
192
+ });
193
+ }, H = (e) => {
194
+ const { setCanvasType: a } = L().canvasApi.value;
195
+ a(e ? "absolute" : "normal");
196
196
  };
197
- F(
198
- () => o.value.deviceType,
197
+ E(
198
+ () => d.value.deviceType,
199
199
  (e) => {
200
- i.activeIndex = g[e].index, i.readonly = e !== "mdx";
200
+ o.activeIndex = V[e].index, o.readonly = e !== "mdx";
201
201
  },
202
202
  { immediate: !0 }
203
- ), Y(() => {
204
- i.scaleValue = x.value.toFixed(2), u = x.value;
205
- }), F(
206
- () => o.value.width,
203
+ ), Z(() => {
204
+ o.scaleValue = _.value.toFixed(2), u = _.value;
205
+ }), E(
206
+ () => d.value.width,
207
207
  (e) => {
208
208
  const a = parseInt(e, 10);
209
- Number.isInteger(a) && (i.width = a, n = a);
209
+ Number.isInteger(a) && (o.width = a, i = a);
210
210
  }
211
- ), Z(() => {
211
+ ), $(() => {
212
212
  document.addEventListener("click", D);
213
- }), $(() => {
213
+ }), ee(() => {
214
214
  document.removeEventListener("click", D);
215
215
  });
216
- const H = o.value.deviceType || "desktop";
217
- return N(g[H]), {
218
- scale: x,
219
- state: i,
220
- active: h,
221
- flag: v,
216
+ const J = d.value.deviceType || "desktop";
217
+ return N(V[J]), {
218
+ scale: _,
219
+ state: o,
220
+ active: v,
221
+ flag: h,
222
222
  hide: B,
223
- layoutState: b,
223
+ layoutState: y,
224
224
  visible: m,
225
225
  showTips: U,
226
- hideTips: A,
227
- timer: r,
228
- dimension: o,
226
+ hideTips: O,
227
+ timer: c,
228
+ dimension: d,
229
229
  setViewPort: N,
230
- showPopover: O,
231
- hidePopover: X,
232
- widthChange: R,
233
- scaleChange: j,
234
- isAbsolute: T,
235
- changeCanvasType: G
230
+ showPopover: X,
231
+ hidePopover: q,
232
+ widthChange: j,
233
+ scaleChange: G,
234
+ isAbsolute: l,
235
+ changeCanvasType: H
236
236
  };
237
237
  }
238
- }, f = (d) => (oe("data-v-9eb930f1"), d = d(), ie(), d), ue = { class: "toolbar-wrap" }, me = { class: "toolbar-icon-wrap" }, he = ["onClick"], ve = { class: "media-content" }, xe = { class: "media-title" }, we = {
238
+ }, re = { class: "toolbar-wrap" }, ce = { class: "toolbar-icon-wrap" }, pe = ["onClick"], ue = { class: "media-content" }, me = { class: "media-title" }, ve = {
239
239
  key: 0,
240
240
  class: "sub-title"
241
- }, _e = { class: "content" }, be = { class: "reference-text" }, ye = /* @__PURE__ */ f(() => /* @__PURE__ */ t("span", { class: "symbol" }, "PX", -1)), fe = /* @__PURE__ */ f(() => /* @__PURE__ */ t("span", { class: "symbol" }, "%", -1)), ge = { class: "content-wrap text-content" }, Ve = { class: "title text-title" }, ke = { class: "setting" }, Ce = { for: "" }, Te = /* @__PURE__ */ f(() => /* @__PURE__ */ t("span", null, "PX", -1)), We = { for: "" }, Ie = /* @__PURE__ */ f(() => /* @__PURE__ */ t("span", null, "%", -1)), Pe = { class: "more-setting" }, De = /* @__PURE__ */ f(() => /* @__PURE__ */ t("div", null, [
242
- /* @__PURE__ */ t("span", null, /* @__PURE__ */ c("自由布局"))
243
- ], -1));
244
- function Ne(d, l, r, n, u, b) {
245
- const m = k("svg-icon"), h = k("tiny-popover"), v = k("tiny-input"), T = k("tiny-switch");
246
- return w(), C("div", ue, [
247
- t("div", me, [
248
- (w(!0), C(ee, null, te(n.state.media, (o, x) => (w(), C("span", {
249
- key: x,
250
- class: ne(["icon", { active: n.state.activeIndex === x, "is-rotate": o.view === "lanMobile" }]),
251
- onClick: (i) => n.setViewPort(o)
241
+ }, he = { class: "content" }, xe = { class: "reference-text" }, we = { class: "content-wrap text-content" }, be = { class: "title text-title" }, ye = { class: "setting" }, fe = { for: "" }, ge = { for: "" }, _e = { class: "more-setting" };
242
+ function Ve(b, n, c, i, u, y) {
243
+ const m = C("svg-icon"), v = C("tiny-popover"), h = C("tiny-input"), f = C("tiny-switch");
244
+ return x(), W("div", re, [
245
+ t("div", ce, [
246
+ (x(!0), W(te, null, ne(i.state.media, (l, d) => (x(), W("span", {
247
+ key: d,
248
+ class: ie(["icon", { active: i.state.activeIndex === d, "is-rotate": l.view === "lanMobile" }]),
249
+ onClick: (_) => i.setViewPort(l)
252
250
  }, [
253
- _(h, {
251
+ w(v, {
254
252
  trigger: "hover",
255
253
  width: "225",
256
254
  "append-to-body": "",
@@ -258,41 +256,41 @@ function Ne(d, l, r, n, u, b) {
258
256
  "popper-class": "media-icon-popover"
259
257
  }, {
260
258
  reference: p(() => [
261
- _(m, {
262
- name: o.liked,
259
+ w(m, {
260
+ name: l.liked,
263
261
  class: "media-icon"
264
262
  }, null, 8, ["name"])
265
263
  ]),
266
264
  default: p(() => [
267
- t("div", ve, [
268
- t("div", xe, [
269
- t("div", null, c(o.title), 1),
270
- o.subTitle ? (w(), C("div", we, [
271
- W(" ("),
272
- o.view === "desktop" ? (w(), L(m, {
265
+ t("div", ue, [
266
+ t("div", me, [
267
+ t("div", null, r(l.title), 1),
268
+ l.subTitle ? (x(), W("div", ve, [
269
+ n[3] || (n[3] = T(" (")),
270
+ l.view === "desktop" ? (x(), F(m, {
273
271
  key: 0,
274
272
  name: "stars"
275
273
  })) : I("", !0),
276
- W(),
277
- t("span", null, c(o.subTitle), 1),
278
- W(") ")
274
+ n[4] || (n[4] = T()),
275
+ t("span", null, r(l.subTitle), 1),
276
+ n[5] || (n[5] = T(") "))
279
277
  ])) : I("", !0)
280
278
  ]),
281
- t("div", _e, c(o.content), 1)
279
+ t("div", he, r(l.content), 1)
282
280
  ])
283
281
  ]),
284
282
  _: 2
285
283
  }, 1024)
286
- ], 10, he))), 128))
284
+ ], 10, pe))), 128))
287
285
  ]),
288
- r.isCanvas ? (w(), L(h, {
286
+ c.isCanvas ? (x(), F(v, {
289
287
  key: 0,
290
288
  width: "290",
291
289
  trigger: "click",
292
290
  "popper-class": "toolbar-media-popper"
293
291
  }, {
294
292
  reference: p(() => [
295
- _(h, {
293
+ w(v, {
296
294
  trigger: "hover",
297
295
  "open-delay": 1e3,
298
296
  "popper-class": "toolbar-right-popover",
@@ -300,14 +298,14 @@ function Ne(d, l, r, n, u, b) {
300
298
  content: "画布设置"
301
299
  }, {
302
300
  reference: p(() => [
303
- t("span", be, [
301
+ t("span", xe, [
304
302
  t("span", null, [
305
- t("span", null, c(parseInt(n.state.width)), 1),
306
- ye
303
+ t("span", null, r(parseInt(i.state.width)), 1),
304
+ n[6] || (n[6] = t("span", { class: "symbol" }, "PX", -1))
307
305
  ]),
308
306
  t("span", null, [
309
- t("span", null, c(n.scale.toFixed(2)), 1),
310
- fe
307
+ t("span", null, r(i.scale.toFixed(2)), 1),
308
+ n[7] || (n[7] = t("span", { class: "symbol" }, "%", -1))
311
309
  ])
312
310
  ])
313
311
  ]),
@@ -315,45 +313,47 @@ function Ne(d, l, r, n, u, b) {
315
313
  })
316
314
  ]),
317
315
  default: p(() => [
318
- t("div", ge, [
319
- t("span", Ve, c(n.state.textData.title), 1),
320
- t("div", ke, [
316
+ t("div", we, [
317
+ t("span", be, r(i.state.textData.title), 1),
318
+ t("div", ye, [
321
319
  t("div", null, [
322
- t("label", Ce, c(n.state.textData.width), 1),
323
- _(v, {
324
- modelValue: n.state.width,
325
- "onUpdate:modelValue": l[0] || (l[0] = (o) => n.state.width = o),
326
- onChange: n.widthChange
320
+ t("label", fe, r(i.state.textData.width), 1),
321
+ w(h, {
322
+ modelValue: i.state.width,
323
+ "onUpdate:modelValue": n[0] || (n[0] = (l) => i.state.width = l),
324
+ onChange: i.widthChange
327
325
  }, {
328
- suffix: p(() => [
329
- Te
330
- ]),
326
+ suffix: p(() => n[8] || (n[8] = [
327
+ t("span", null, "PX", -1)
328
+ ])),
331
329
  _: 1
332
330
  }, 8, ["modelValue", "onChange"])
333
331
  ]),
334
332
  t("div", null, [
335
- t("label", We, c(n.state.textData.scale), 1),
336
- _(v, {
337
- modelValue: n.state.scaleValue,
338
- "onUpdate:modelValue": l[1] || (l[1] = (o) => n.state.scaleValue = o),
339
- readonly: n.state.readonly,
340
- onChange: n.scaleChange
333
+ t("label", ge, r(i.state.textData.scale), 1),
334
+ w(h, {
335
+ modelValue: i.state.scaleValue,
336
+ "onUpdate:modelValue": n[1] || (n[1] = (l) => i.state.scaleValue = l),
337
+ readonly: i.state.readonly,
338
+ onChange: i.scaleChange
341
339
  }, {
342
- suffix: p(() => [
343
- Ie
344
- ]),
340
+ suffix: p(() => n[9] || (n[9] = [
341
+ t("span", null, "%", -1)
342
+ ])),
345
343
  _: 1
346
344
  }, 8, ["modelValue", "readonly", "onChange"])
347
345
  ])
348
346
  ]),
349
- t("ul", Pe, [
347
+ t("ul", _e, [
350
348
  t("li", null, [
351
- De,
349
+ n[10] || (n[10] = t("div", null, [
350
+ t("span", null, r("自由布局"))
351
+ ], -1)),
352
352
  t("div", null, [
353
- _(T, {
354
- modelValue: n.isAbsolute,
355
- "onUpdate:modelValue": l[2] || (l[2] = (o) => n.isAbsolute = o),
356
- onChange: n.changeCanvasType
353
+ w(f, {
354
+ modelValue: i.isAbsolute,
355
+ "onUpdate:modelValue": n[2] || (n[2] = (l) => i.isAbsolute = l),
356
+ onChange: i.changeCanvasType
357
357
  }, null, 8, ["modelValue", "onChange"])
358
358
  ])
359
359
  ])
@@ -364,13 +364,13 @@ function Ne(d, l, r, n, u, b) {
364
364
  })) : I("", !0)
365
365
  ]);
366
366
  }
367
- const Se = /* @__PURE__ */ re(pe, [["render", Ne], ["__scopeId", "data-v-9eb930f1"]]), Ae = {
367
+ const ke = /* @__PURE__ */ se(de, [["render", Ve], ["__scopeId", "data-v-4f3e1155"]]), De = {
368
368
  id: "media",
369
369
  title: "media",
370
370
  icon: "",
371
371
  align: "center",
372
- component: Se
372
+ component: ke
373
373
  };
374
374
  export {
375
- Ae as default
375
+ De as default
376
376
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .toolbar-wrap[data-v-9eb930f1]{display:flex;align-items:center}.toolbar-wrap .reference-text[data-v-9eb930f1]{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-9eb930f1]:last-child{margin-left:8px}.toolbar-wrap .toolbar-icon-wrap[data-v-9eb930f1]{display:flex;flex-wrap:nowrap;align-items:center;gap:6px}.toolbar-wrap .toolbar-icon-wrap .icon[data-v-9eb930f1]{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-9eb930f1]{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-9eb930f1],.toolbar-wrap .toolbar-icon-wrap .icon[data-v-9eb930f1]:hover{background:var(--ti-lowcode-toolbar-view-active-bg)}.toolbar-wrap .toolbar-icon-wrap .icon.active svg[data-v-9eb930f1]{color:var(--ti-lowcode-common-primary-color)}.toolbar-wrap .more-setting .setting-item[data-v-9eb930f1]{display:flex;justify-content:space-between;padding:12px}
1
+ .toolbar-wrap[data-v-4f3e1155]{display:flex;align-items:center}.toolbar-wrap .reference-text[data-v-4f3e1155]{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-4f3e1155]:last-child{margin-left:8px}.toolbar-wrap .toolbar-icon-wrap[data-v-4f3e1155]{display:flex;flex-wrap:nowrap;align-items:center;gap:6px}.toolbar-wrap .toolbar-icon-wrap .icon[data-v-4f3e1155]{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-4f3e1155]{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-4f3e1155],.toolbar-wrap .toolbar-icon-wrap .icon[data-v-4f3e1155]:hover{background:var(--ti-lowcode-toolbar-view-active-bg)}.toolbar-wrap .toolbar-icon-wrap .icon.active svg[data-v-4f3e1155]{color:var(--ti-lowcode-common-primary-color)}.toolbar-wrap .more-setting .setting-item[data-v-4f3e1155]{display:flex;justify-content:space-between;padding:12px}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/tiny-engine-toolbar-media",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -24,18 +24,18 @@
24
24
  "license": "MIT",
25
25
  "homepage": "https://opentiny.design/tiny-engine",
26
26
  "dependencies": {
27
- "@opentiny/tiny-engine-canvas": "1.0.3",
28
- "@opentiny/tiny-engine-controller": "1.0.3",
29
- "@opentiny/vue": "~3.10.0",
30
- "@opentiny/vue-icon": "~3.10.0"
27
+ "@opentiny/tiny-engine-canvas": "1.0.4",
28
+ "@opentiny/tiny-engine-controller": "1.0.4"
31
29
  },
32
30
  "devDependencies": {
33
31
  "@vitejs/plugin-vue": "^4.2.3",
34
- "@vitejs/plugin-vue-jsx": "^1.3.10",
32
+ "@vitejs/plugin-vue-jsx": "^3.1.0",
35
33
  "vite": "^4.3.7"
36
34
  },
37
35
  "peerDependencies": {
36
+ "@opentiny/vue": "^3.14.0",
37
+ "@opentiny/vue-icon": "^3.14.0",
38
38
  "vue": "^3.4.15"
39
39
  },
40
- "gitHead": "9a6cce3988accb39c97a9a21169c022c65a8e27f"
40
+ "gitHead": "aa79110d52c3e77f6e664c22983c93bd74d9406d"
41
41
  }