@hankchen/canvas-editor-vue 2.1.0 → 2.2.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.
@@ -1,9 +1,8 @@
1
1
  import { t as e } from "./createLucideIcon-SCvtEGVf.js";
2
- import { i as t, r as n, t as r } from "./layerPath-uy2ywyld.js";
3
- import { c as i, o as a, p as o, t as s } from "./ExpressionPathPicker-DchGsK70.js";
4
- import { a as c, d as l, i as ee, s as u, t as d, u as f } from "./useTransientFeedback-BN_O7V2w.js";
5
- import { t as te } from "./DropdownMenu-CeUNKMDQ.js";
6
- import { Fragment as ne, computed as p, createBlock as re, createCommentVNode as m, createElementBlock as h, createElementVNode as g, createVNode as _, defineComponent as v, nextTick as ie, normalizeClass as y, normalizeStyle as ae, onScopeDispose as b, openBlock as x, ref as S, renderList as oe, shallowRef as C, toDisplayString as w, unref as T, vModelText as se, watch as ce, withCtx as E, withDirectives as le, withKeys as D, withModifiers as O } from "vue";
2
+ import { a as t, n, o as r, r as i } from "./_plugin-vue_export-helper-CBNdHDnS.js";
3
+ import { n as a, p as o, s, t as c } from "./Tooltip-9lQOwB7r.js";
4
+ import { f as l, l as u, n as ee, o as te, p as d, s as f, t as p } from "./useTransientFeedback-CI3j6r7y.js";
5
+ import { Fragment as ne, computed as m, createBlock as h, createCommentVNode as g, createElementBlock as _, createElementVNode as v, createVNode as y, defineComponent as b, nextTick as re, normalizeClass as x, normalizeStyle as ie, onScopeDispose as S, openBlock as C, ref as w, renderList as ae, shallowRef as T, toDisplayString as E, unref as D, vModelText as oe, watch as se, withCtx as O, withDirectives as ce, withKeys as le, withModifiers as k } from "vue";
7
6
  var ue = e({
8
7
  name: "eye-off",
9
8
  size: 24,
@@ -122,7 +121,7 @@ var ue = e({
122
121
  });
123
122
  //#endregion
124
123
  //#region ../canvas-editor/src/editing/layerPanel.ts
125
- function k(e) {
124
+ function A(e) {
126
125
  switch (e.type) {
127
126
  case "TableLayer": return e.template === null ? [{
128
127
  key: "rows",
@@ -148,7 +147,7 @@ function k(e) {
148
147
  }];
149
148
  }
150
149
  }
151
- function A(e) {
150
+ function j(e) {
152
151
  switch (e.type) {
153
152
  case "TextLayer":
154
153
  case "ImageLayer":
@@ -156,22 +155,22 @@ function A(e) {
156
155
  default: return null;
157
156
  }
158
157
  }
159
- var j = "{{…}}";
160
- function M(e) {
161
- let t = A(e);
158
+ var M = "{{…}}";
159
+ function N(e) {
160
+ let t = j(e);
162
161
  if (t === null) return "";
163
162
  let n = o(t).parts.flatMap((e) => e.kind === "fragment" && e.expr !== "" ? [e.expr] : []);
164
- return n.length === 0 ? j : n.map((e) => `{{${e}}}`).join(" ");
163
+ return n.length === 0 ? M : n.map((e) => `{{${e}}}`).join(" ");
165
164
  }
166
- function N(e, t, n, i) {
165
+ function P(e, t, n, r) {
167
166
  let a = [];
168
- for (let { key: n, layers: r } of k(e)) for (let e = 0; e < r.length; e += 1) {
167
+ for (let { key: n, layers: i } of A(e)) for (let e = 0; e < i.length; e += 1) {
169
168
  let o = n === "rows" ? "row" : n === "cells" ? "cell" : n === "template" ? "templateRow" : "content", s = n === "content" ? [...t, "content"] : n === "template" ? [...t, "template"] : [
170
169
  ...t,
171
170
  n,
172
171
  e
173
172
  ];
174
- a.push(N(r[e], s, o, i));
173
+ a.push(P(i[e], s, o, r));
175
174
  }
176
175
  return {
177
176
  type: e.type,
@@ -179,18 +178,18 @@ function N(e, t, n, i) {
179
178
  role: n,
180
179
  name: e.name,
181
180
  visible: e.visible,
182
- locked: r(t, i),
183
- expressionPrefix: M(e),
181
+ locked: i(t, r),
182
+ expressionPrefix: N(e),
184
183
  ...e.type === "TableLayer" ? { templated: e.template !== null } : null,
185
184
  children: a
186
185
  };
187
186
  }
188
- function P(e, t = []) {
187
+ function F(e, t = []) {
189
188
  let n = [];
190
- for (let r = e.layers.length - 1; r >= 0; --r) n.push(N(e.layers[r], ["layers", r], "root", t));
189
+ for (let r = e.layers.length - 1; r >= 0; --r) n.push(P(e.layers[r], ["layers", r], "root", t));
191
190
  return n;
192
191
  }
193
- var F = [
192
+ var I = [
194
193
  {
195
194
  id: "heading",
196
195
  fontSize: 40
@@ -203,7 +202,7 @@ var F = [
203
202
  id: "body",
204
203
  fontSize: 16
205
204
  }
206
- ], I = [
205
+ ], L = [
207
206
  {
208
207
  id: "free",
209
208
  ratio: null
@@ -243,7 +242,7 @@ var F = [
243
242
  h: 16
244
243
  }
245
244
  }
246
- ], L = [
245
+ ], R = [
247
246
  {
248
247
  kind: "layer",
249
248
  type: "TextLayer",
@@ -273,66 +272,66 @@ var F = [
273
272
  label: "模板表",
274
273
  title: "新增模板表(行模板 + 数据行展开)"
275
274
  }
276
- ], R = {
275
+ ], z = {
277
276
  heading: "标题",
278
277
  subheading: "副标题",
279
278
  body: "正文"
280
- }, z = F.map(({ id: e, fontSize: t }) => ({
279
+ }, B = I.map(({ id: e, fontSize: t }) => ({
281
280
  kind: "text-preset",
282
281
  preset: e,
283
- label: R[e],
282
+ label: z[e],
284
283
  shortcut: `${t}号`,
285
- title: `画拉建${R[e]}文本层(字号 ${t},点击后在画布拖拽定落位与尺寸,Esc 取消)`
284
+ title: `画拉建${z[e]}文本层(字号 ${t},点击后在画布拖拽定落位与尺寸,Esc 取消)`
286
285
  }));
287
- function B(e) {
286
+ function V(e) {
288
287
  return e === null ? "任意宽高" : e.w === e.h ? "正方形" : e.w > e.h ? "横向" : "纵向";
289
288
  }
290
- var V = I.flatMap(({ id: e, ratio: t }) => e === "free" ? [] : [{
289
+ var H = L.flatMap(({ id: e, ratio: t }) => e === "free" ? [] : [{
291
290
  kind: "ratio-preset",
292
291
  preset: e,
293
292
  label: e,
294
- shortcut: B(t),
295
- title: `画拉建 ${e} 图片层(${B(t)},画拉中按住 Shift 临时自由;点击后在画布拖拽定落位与尺寸,Esc 取消)`
296
- }]), H = L.map((e) => e.kind === "layer" ? e.type === "TextLayer" ? {
293
+ shortcut: V(t),
294
+ title: `画拉建 ${e} 图片层(${V(t)},画拉中按住 Shift 临时自由;点击后在画布拖拽定落位与尺寸,Esc 取消)`
295
+ }]), U = R.map((e) => e.kind === "layer" ? e.type === "TextLayer" ? {
297
296
  ...e,
298
- children: z
297
+ children: B
299
298
  } : e.type === "ImageLayer" ? {
300
299
  ...e,
301
- children: V
302
- } : e : e), U = L;
300
+ children: H
301
+ } : e : e), W = R;
303
302
  function ge(e, t) {
304
303
  return `画拉建${e}(${t}),${u}`;
305
304
  }
306
305
  //#endregion
307
306
  //#region src/layer-panel/TemplateTableForm.vue?vue&type=script&setup=true&lang.ts
308
- var W = { class: "mx-1 my-1" }, G = { class: "flex gap-1 p-1" }, K = ["disabled"], q = /* @__PURE__ */ v({
307
+ var G = { class: "mx-1 my-1" }, K = { class: "flex gap-1 p-1" }, q = ["disabled"], J = /* @__PURE__ */ b({
309
308
  __name: "TemplateTableForm",
310
309
  props: { editor: {} },
311
310
  emits: ["confirm", "cancel"],
312
311
  setup(e, { emit: t }) {
313
- let n = e, r = t, i = S("");
312
+ let n = e, r = t, i = w("");
314
313
  function o() {
315
314
  i.value !== "" && r("confirm", i.value);
316
315
  }
317
- let l = c(n.editor), ee = p(() => a(l.value));
318
- return (e, t) => (x(), h("div", null, [
319
- t[2] ||= g("p", { class: "px-2 pt-1 text-[11px] leading-4 text-cn-muted" }, "模板行按取行路径展开成表", -1),
320
- g("div", W, [_(s, {
316
+ let c = f(n.editor), l = m(() => s(c.value));
317
+ return (e, t) => (C(), _("div", null, [
318
+ t[2] ||= v("p", { class: "px-2 pt-1 text-[11px] leading-4 text-cn-muted" }, "模板行按取行路径展开成表", -1),
319
+ v("div", G, [y(a, {
321
320
  modelValue: i.value,
322
321
  "onUpdate:modelValue": t[0] ||= (e) => i.value = e,
323
322
  "data-template-rows-path": "",
324
323
  mode: "rowsPath",
325
- source: ee.value,
324
+ source: l.value,
326
325
  "aria-label": "取行路径",
327
326
  placeholder: "未选择行路径"
328
327
  }, null, 8, ["modelValue", "source"])]),
329
- g("div", G, [g("button", {
328
+ v("div", K, [v("button", {
330
329
  type: "button",
331
330
  "data-template-confirm": "",
332
331
  disabled: i.value === "",
333
332
  class: "flex-1 rounded bg-cn-accent/20 px-2 py-1 text-[12px] text-cn-accent hover:bg-cn-accent/30 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-cn-accent/20",
334
333
  onClick: o
335
- }, " 创建 ", 8, K), g("button", {
334
+ }, " 创建 ", 8, q), v("button", {
336
335
  type: "button",
337
336
  "data-template-cancel": "",
338
337
  class: "flex-1 rounded px-2 py-1 text-[12px] text-cn-muted hover:text-cn-fg",
@@ -343,30 +342,30 @@ var W = { class: "mx-1 my-1" }, G = { class: "flex gap-1 p-1" }, K = ["disabled"
343
342
  });
344
343
  //#endregion
345
344
  //#region src/layer-panel/useLayerPanel.ts
346
- function J(e) {
347
- let t = C(e.store.doc), n = C(e.store.ui.selection), r = C(e.store.ui.hovered), i = C(e.store.ui.renaming), a = C(e.store.ui.lockedPaths), o = e.subscribe((o) => {
345
+ function _e(e) {
346
+ let t = T(e.store.doc), n = T(e.store.ui.selection), r = T(e.store.ui.hovered), i = T(e.store.ui.renaming), a = T(e.store.ui.lockedPaths), o = e.subscribe((o) => {
348
347
  o.scope === "doc" ? (t.value = e.store.doc, n.value = e.store.ui.selection, r.value = e.store.ui.hovered, i.value = e.store.ui.renaming, a.value = e.store.ui.lockedPaths) : o.branch === "selection" ? n.value = e.store.ui.selection : o.branch === "hovered" ? r.value = e.store.ui.hovered : o.branch === "renaming" ? i.value = e.store.ui.renaming : o.branch === "lockedPaths" && (a.value = e.store.ui.lockedPaths);
349
348
  });
350
- return b(o, !0), {
351
- outline: p(() => t.value ? P(t.value, a.value) : []),
352
- selection: p(() => n.value),
353
- hovered: p(() => r.value),
354
- renaming: p(() => i.value)
349
+ return S(o, !0), {
350
+ outline: m(() => t.value ? F(t.value, a.value) : []),
351
+ selection: m(() => n.value),
352
+ hovered: m(() => r.value),
353
+ renaming: m(() => i.value)
355
354
  };
356
355
  }
357
- function Y(e, t) {
356
+ function ve(e, t) {
358
357
  return t > 0 && e < t / 2;
359
358
  }
360
359
  //#endregion
361
360
  //#region src/layer-panel/LayerPanel.vue?vue&type=script&setup=true&lang.ts
362
- var _e = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rounded-xl border border-cn-line bg-cn-bg text-cn-fg shadow-[0_16px_40px_-12px_rgba(2,6,23,0.55)]" }, ve = { class: "sticky top-0 z-10 flex items-center justify-between border-b border-cn-line bg-cn-bg-elevated/95 px-3.5 py-2.5" }, ye = { class: "flex items-center gap-1" }, be = [
361
+ var ye = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rounded-xl border border-cn-line bg-cn-bg text-cn-fg shadow-(--cn-shadow-md)" }, be = { class: "sticky top-0 z-10 flex items-center justify-between border-b border-cn-line bg-cn-bg-elevated/95 px-3.5 py-2.5" }, xe = { class: "flex items-center gap-1" }, Se = [
363
362
  "aria-expanded",
364
363
  "onClick",
365
364
  "onKeydown"
366
- ], xe = {
365
+ ], Ce = {
367
366
  key: 0,
368
367
  class: "mx-3.5 my-4 rounded-lg border border-dashed border-cn-line px-3 py-6 text-center text-[11px] leading-5 text-cn-muted"
369
- }, Se = [
368
+ }, we = [
370
369
  "data-key",
371
370
  "draggable",
372
371
  "onClick",
@@ -374,42 +373,34 @@ var _e = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
374
373
  "onDragstart",
375
374
  "onDragover",
376
375
  "onDrop"
377
- ], Ce = ["onDragstart"], we = ["title"], Te = ["onDblclick"], Ee = [
378
- "title",
379
- "aria-pressed",
380
- "onClick"
381
- ], De = [
382
- "title",
383
- "aria-pressed",
384
- "onClick"
385
- ], Oe = ["onClick"], ke = [
376
+ ], Te = ["onDragstart"], Ee = ["title"], De = ["onDblclick"], Oe = ["aria-pressed", "onClick"], ke = ["aria-pressed", "onClick"], Ae = ["onClick"], je = [
386
377
  "disabled",
387
378
  "title",
388
379
  "onClick"
389
- ], Ae = ["onClick"], je = ["onClick"], Me = [
380
+ ], Me = ["onClick"], Ne = ["onClick"], Pe = [
390
381
  "disabled",
391
382
  "title",
392
383
  "onClick"
393
- ], X = /* @__PURE__ */ v({
384
+ ], Y = /* @__PURE__ */ b({
394
385
  __name: "LayerPanel",
395
386
  props: { editor: {} },
396
387
  setup(e) {
397
- let r = e, a = `解锁图层(${l("toggleLayerLock", f())})`, o = `图层已锁定(${l("toggleLayerLock", f())} 解锁后可删除)`, s = J(r.editor), v = c(r.editor), b = S(!1), C = p(() => b.value ? [] : H.map((e) => {
388
+ let i = e, a = `解锁图层(${d("toggleLayerLock", l())})`, o = `图层已锁定(${d("toggleLayerLock", l())} 解锁后可删除)`, s = _e(i.editor), b = f(i.editor), S = w(!1), T = m(() => S.value ? [] : U.map((e) => {
398
389
  if (e.kind === "template-table") {
399
- let t = v.value === null;
390
+ let t = b.value === null;
400
391
  return {
401
392
  label: e.label,
402
- title: t ? ee : e.title,
393
+ title: t ? te : e.title,
403
394
  disabled: t,
404
395
  dataAttrs: { "data-add-layer": "template-table" },
405
396
  keepsOpen: !0,
406
397
  run: () => {
407
- b.value = !0;
398
+ S.value = !0;
408
399
  }
409
400
  };
410
401
  }
411
402
  let t = { "data-add-layer": e.type }, n = () => {
412
- r.editor.armLayerCreate(e.type), d().show(u);
403
+ i.editor.armLayerCreate(e.type), p().show(u);
413
404
  };
414
405
  return e.children === void 0 ? {
415
406
  label: e.label,
@@ -431,21 +422,21 @@ var _e = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
431
422
  ...t.kind === "text-preset" ? { "data-text-preset": t.preset } : { "data-ratio-preset": t.preset }
432
423
  },
433
424
  run: () => {
434
- r.editor.armLayerCreate(e.type, t.preset), d().show(ge(e.label, t.label));
425
+ i.editor.armLayerCreate(e.type, t.preset), p().show(ge(e.label, t.label));
435
426
  }
436
427
  }))
437
428
  };
438
429
  }));
439
- function k(e, t) {
440
- r.editor.armTemplateTableCreate(e), d().show(u), t();
430
+ function A(e, t) {
431
+ i.editor.armTemplateTableCreate(e), p().show(u), t();
441
432
  }
442
- function A(e) {
443
- b.value = !1, e();
433
+ function j(e) {
434
+ S.value = !1, e();
444
435
  }
445
- function j() {
446
- b.value = !1;
436
+ function M() {
437
+ S.value = !1;
447
438
  }
448
- function M(e, t) {
439
+ function N(e, t) {
449
440
  switch (e.role) {
450
441
  case "root": return e.name === "" ? `${e.type} ${t}` : e.name;
451
442
  case "row": return `行 ${Number(e.path[e.path.length - 1]) + 1}`;
@@ -454,62 +445,62 @@ var _e = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
454
445
  case "content": return e.type;
455
446
  }
456
447
  }
457
- let N = p(() => {
458
- let e = [], t = /* @__PURE__ */ new Map();
448
+ let P = m(() => {
449
+ let e = [], n = /* @__PURE__ */ new Map();
459
450
  function r(i, a, o, s) {
460
451
  let c = i.role === "row" ? i.path.slice(0, -2) : i.role === "templateRow" ? i.path.slice(0, -1) : s, l = 0;
461
- i.role === "root" && (l = (t.get(i.type) ?? 0) + 1, t.set(i.type, l)), e.push({
452
+ i.role === "root" && (l = (n.get(i.type) ?? 0) + 1, n.set(i.type, l)), e.push({
462
453
  key: i.path.join("."),
463
454
  node: i,
464
455
  indentLevel: a,
465
- label: M(i, l),
456
+ label: N(i, l),
466
457
  indexInGroup: o,
467
458
  tablePath: c,
468
- inTemplate: n(i.path),
459
+ inTemplate: t(i.path),
469
460
  draggable: i.role === "root" || i.role === "row" || i.role === "cell"
470
461
  }), i.children.forEach((e, t) => r(e, a + 1, t, c));
471
462
  }
472
463
  return s.outline.value.forEach((e, t) => r(e, 0, t, null)), e;
473
- }), P = p(() => N.value.length > 0);
474
- function F(e) {
475
- r.editor.setSelection(e.node.path);
476
- }
464
+ }), F = m(() => P.value.length > 0);
477
465
  function I(e) {
478
- r.editor.setHovered(e === null ? null : e.node.path);
466
+ i.editor.setSelection(e.node.path);
479
467
  }
480
468
  function L(e) {
481
- r.editor.addTableRow(e.node.path);
469
+ i.editor.setHovered(e === null ? null : e.node.path);
482
470
  }
483
471
  function R(e) {
484
- r.editor.addTableCell(e.node.path);
472
+ i.editor.addTableRow(e.node.path);
485
473
  }
486
474
  function z(e) {
487
- r.editor.addTemplateCell(e.node.path.slice(0, -1));
475
+ i.editor.addTableCell(e.node.path);
488
476
  }
489
477
  function B(e) {
490
- r.editor.deleteLayer(e.node.path);
478
+ i.editor.addTemplateCell(e.node.path.slice(0, -1));
491
479
  }
492
480
  function V(e) {
493
- r.editor.toggleLayerVisibility(e.node.path);
481
+ i.editor.deleteLayer(e.node.path);
494
482
  }
495
- function U(e) {
496
- r.editor.toggleLayerLock(e.node.path);
483
+ function H(e) {
484
+ i.editor.toggleLayerVisibility(e.node.path);
497
485
  }
498
- let W = S(null), G = S(null);
499
- function K(e) {
500
- let r = W.value;
501
- if (!r) return !1;
502
- if (r.kind === "root") return e.node.role === "root";
503
- if (r.kind === "row") return e.node.role === "row";
486
+ function W(e) {
487
+ i.editor.toggleLayerLock(e.node.path);
488
+ }
489
+ let G = w(null), K = w(null);
490
+ function q(e) {
491
+ let n = G.value;
492
+ if (!n) return !1;
493
+ if (n.kind === "root") return e.node.role === "root";
494
+ if (n.kind === "row") return e.node.role === "row";
504
495
  if (e.node.role !== "cell") return !1;
505
- let i = n(r.cellPath);
506
- return i === e.inTemplate ? !i || t(r.cellPath.slice(0, -2), e.node.path.slice(0, -2)) : !1;
496
+ let i = t(n.cellPath);
497
+ return i === e.inTemplate ? !i || r(n.cellPath.slice(0, -2), e.node.path.slice(0, -2)) : !1;
507
498
  }
508
- function X(e) {
499
+ function Y(e) {
509
500
  return e.node.role === "root";
510
501
  }
511
- function Z(e, t) {
512
- e.draggable && (W.value = e.node.role === "root" ? {
502
+ function Fe(e, t) {
503
+ e.draggable && (G.value = e.node.role === "root" ? {
513
504
  kind: "root",
514
505
  from: e.indexInGroup
515
506
  } : e.node.role === "row" ? {
@@ -523,74 +514,74 @@ var _e = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
523
514
  cellPath: e.node.path
524
515
  }, t.dataTransfer?.setData("text/plain", e.key), t.dataTransfer && (t.dataTransfer.effectAllowed = "move"));
525
516
  }
526
- function Ne(e, t) {
527
- X(e) || Z(e, t);
517
+ function Ie(e, t) {
518
+ Y(e) || Fe(e, t);
528
519
  }
529
- function Pe(e) {
530
- if (!X(e)) return e.draggable || void 0;
520
+ function Le(e) {
521
+ if (!Y(e)) return e.draggable || void 0;
531
522
  }
532
- function Fe(e, t) {
533
- if (!K(e)) return;
534
- let n = t.currentTarget.getBoundingClientRect(), r = Y(t.clientY - n.top, n.height);
535
- t.preventDefault(), G.value = {
523
+ function Re(e, t) {
524
+ if (!q(e)) return;
525
+ let n = t.currentTarget.getBoundingClientRect(), r = ve(t.clientY - n.top, n.height);
526
+ t.preventDefault(), K.value = {
536
527
  key: e.key,
537
528
  edge: r ? "before" : "after"
538
529
  };
539
530
  }
540
- function Ie(e, t) {
541
- if (!K(e)) return;
542
- let n = G.value, i = W.value;
543
- if (!i || !n || n.key !== e.key) return;
531
+ function ze(e, t) {
532
+ if (!q(e)) return;
533
+ let n = K.value, r = G.value;
534
+ if (!r || !n || n.key !== e.key) return;
544
535
  t.preventDefault();
545
536
  let a = n.edge === "before" ? e.indexInGroup : e.indexInGroup + 1;
546
- i.kind === "root" ? r.editor.moveRootLayer(i.from, a) : i.kind === "row" ? e.tablePath !== null && e.tablePath.join(".") === i.tablePath.join(".") ? r.editor.moveTableRow(i.tablePath, i.from, a) : r.editor.moveTableRowToTable(i.rowPath, e.tablePath, a) : r.editor.moveTableCellToRow(i.cellPath, e.node.path.slice(0, -2), a), W.value = null, G.value = null;
537
+ r.kind === "root" ? i.editor.moveRootLayer(r.from, a) : r.kind === "row" ? e.tablePath !== null && e.tablePath.join(".") === r.tablePath.join(".") ? i.editor.moveTableRow(r.tablePath, r.from, a) : i.editor.moveTableRowToTable(r.rowPath, e.tablePath, a) : i.editor.moveTableCellToRow(r.cellPath, e.node.path.slice(0, -2), a), G.value = null, K.value = null;
547
538
  }
548
- function Le() {
549
- W.value = null, G.value = null;
539
+ function Be() {
540
+ G.value = null, K.value = null;
550
541
  }
551
- function Re(e) {
552
- return t(s.selection.value, e.node.path);
553
- }
554
- function ze(e) {
555
- return t(s.hovered.value, e.node.path);
542
+ function X(e) {
543
+ return r(s.selection.value, e.node.path);
556
544
  }
557
- let Q = S(""), $ = null, Be = null;
558
545
  function Ve(e) {
559
- Be = e instanceof HTMLInputElement ? e : null;
560
- }
561
- function He(e) {
562
- return t(s.renaming.value, e.node.path);
546
+ return r(s.hovered.value, e.node.path);
563
547
  }
548
+ let Z = w(""), Q = null, He = null;
564
549
  function Ue(e) {
565
- X(e) && r.editor.beginRename(e.node.path);
550
+ He = e instanceof HTMLInputElement ? e : null;
566
551
  }
567
- function We() {
568
- let e = Q.value.trim();
569
- if ($ !== null && e === $.trim()) {
570
- r.editor.cancelRename();
552
+ function We(e) {
553
+ return r(s.renaming.value, e.node.path);
554
+ }
555
+ function Ge(e) {
556
+ Y(e) && i.editor.beginRename(e.node.path);
557
+ }
558
+ function $() {
559
+ let e = Z.value.trim();
560
+ if (Q !== null && e === Q.trim()) {
561
+ i.editor.cancelRename();
571
562
  return;
572
563
  }
573
- r.editor.commitRename(e);
564
+ i.editor.commitRename(e);
574
565
  }
575
- function Ge() {
576
- r.editor.cancelRename();
566
+ function Ke() {
567
+ i.editor.cancelRename();
577
568
  }
578
- return ce(s.renaming, async (e) => {
569
+ return se(s.renaming, async (e) => {
579
570
  if (e === null) {
580
- $ = null;
571
+ Q = null;
581
572
  return;
582
573
  }
583
- let n = N.value.find((n) => t(n.node.path, e));
584
- Q.value = n?.label ?? "", $ = Q.value, await ie();
585
- let r = Be;
586
- r && (r.focus({ preventScroll: !0 }), r.select());
587
- }), (e, t) => (x(), h("aside", _e, [
588
- g("header", ve, [t[7] ||= g("span", { class: "text-[12px] font-medium tracking-wide text-cn-fg/90" }, "图层", -1), g("div", ye, [_(te, {
574
+ let t = P.value.find((t) => r(t.node.path, e));
575
+ Z.value = t?.label ?? "", Q = Z.value, await re();
576
+ let n = He;
577
+ n && (n.focus({ preventScroll: !0 }), n.select());
578
+ }), (e, t) => (C(), _("aside", ye, [
579
+ v("header", be, [t[7] ||= v("span", { class: "text-[12px] font-medium tracking-wide text-cn-fg/90" }, "图层", -1), v("div", xe, [y(ee, {
589
580
  label: "新增图层",
590
- items: C.value,
591
- onClosed: j
581
+ items: T.value,
582
+ onClosed: M
592
583
  }, {
593
- trigger: E(({ open: e, toggle: t, triggerRef: n, onKeydown: r }) => [g("button", {
584
+ trigger: O(({ open: e, toggle: t, triggerRef: n, onKeydown: r }) => [v("button", {
594
585
  ref: n,
595
586
  type: "button",
596
587
  "data-add-menu": "",
@@ -600,151 +591,166 @@ var _e = { class: "cn-props flex w-[232px] shrink-0 flex-col overflow-y-auto rou
600
591
  class: "flex size-6 items-center justify-center rounded border border-cn-field-line bg-cn-field text-[13px] leading-none text-cn-fg/80 hover:border-cn-accent/40 hover:text-cn-accent",
601
592
  onClick: t,
602
593
  onKeydown: r
603
- }, " + ", 40, be)]),
604
- body: E(({ closeMenu: e }) => [b.value ? (x(), re(q, {
594
+ }, " + ", 40, Se)]),
595
+ body: O(({ closeMenu: e }) => [S.value ? (C(), h(J, {
605
596
  key: 0,
606
- editor: r.editor,
607
- onConfirm: (t) => k(t, e),
608
- onCancel: (t) => A(e)
597
+ editor: i.editor,
598
+ onConfirm: (t) => A(t, e),
599
+ onCancel: (t) => j(e)
609
600
  }, null, 8, [
610
601
  "editor",
611
602
  "onConfirm",
612
603
  "onCancel"
613
- ])) : m("", !0)]),
604
+ ])) : g("", !0)]),
614
605
  _: 1
615
606
  }, 8, ["items"])])]),
616
- P.value ? m("", !0) : (x(), h("p", xe, " 画布还没有图层,用上方按钮新增 ")),
617
- g("ul", {
607
+ F.value ? g("", !0) : (C(), _("p", Ce, " 画布还没有图层,用上方按钮新增 ")),
608
+ v("ul", {
618
609
  class: "cn-layers__tree flex flex-col gap-0.5 px-1.5 py-1",
619
- onDragend: Le
620
- }, [(x(!0), h(ne, null, oe(N.value, (e) => (x(), h("li", {
610
+ onDragend: Be
611
+ }, [(C(!0), _(ne, null, ae(P.value, (e) => (C(), _("li", {
621
612
  key: e.key,
622
613
  "data-key": e.key,
623
- draggable: Pe(e),
624
- class: y(["cn-layers__row group flex cursor-default select-none items-center gap-1 py-1 pr-1 text-[12px]", {
625
- "cn-layers__row--selected": Re(e),
626
- "cn-layers__row--hovered": ze(e) && !Re(e),
627
- "cn-layers__row--hidden": X(e) && !e.node.visible,
614
+ draggable: Le(e),
615
+ class: x(["cn-layers__row group flex cursor-default select-none items-center gap-1 py-1 pr-1 text-[12px]", {
616
+ "cn-layers__row--selected": X(e),
617
+ "cn-layers__row--hovered": Ve(e) && !X(e),
618
+ "cn-layers__row--hidden": Y(e) && !e.node.visible,
628
619
  "cn-layers__row--template": e.inTemplate,
629
- "cursor-grab": e.draggable && !X(e),
630
- "cn-layers__row--drop-before": G.value?.key === e.key && G.value?.edge === "before",
631
- "cn-layers__row--drop-after": G.value?.key === e.key && G.value?.edge === "after"
620
+ "cursor-grab": e.draggable && !Y(e),
621
+ "cn-layers__row--drop-before": K.value?.key === e.key && K.value?.edge === "before",
622
+ "cn-layers__row--drop-after": K.value?.key === e.key && K.value?.edge === "after"
632
623
  }]),
633
- style: ae({ paddingLeft: `${4 + e.indentLevel * 14}px` }),
634
- onClick: (t) => F(e),
635
- onMouseenter: (t) => I(e),
636
- onMouseleave: t[6] ||= (e) => I(null),
637
- onDragstart: (t) => Ne(e, t),
638
- onDragover: (t) => Fe(e, t),
639
- onDrop: (t) => Ie(e, t)
624
+ style: ie({ paddingLeft: `${4 + e.indentLevel * 14}px` }),
625
+ onClick: (t) => I(e),
626
+ onMouseenter: (t) => L(e),
627
+ onMouseleave: t[6] ||= (e) => L(null),
628
+ onDragstart: (t) => Ie(e, t),
629
+ onDragover: (t) => Re(e, t),
630
+ onDrop: (t) => ze(e, t)
640
631
  }, [
641
- X(e) ? (x(), h("span", {
632
+ Y(e) ? (C(), _("span", {
642
633
  key: 0,
643
634
  "data-drag-handle": "",
644
635
  draggable: "true",
645
636
  title: "拖动排序",
646
637
  class: "cn-layers__handle shrink-0",
647
- onDragstart: (t) => Z(e, t)
648
- }, [_(i, {
649
- icon: T(fe),
638
+ onDragstart: (t) => Fe(e, t)
639
+ }, [y(n, {
640
+ icon: D(fe),
650
641
  size: 12,
651
642
  "stroke-width": 2.5
652
- }, null, 8, ["icon"])], 40, Ce)) : m("", !0),
653
- e.node.expressionPrefix === "" ? m("", !0) : (x(), h("span", {
643
+ }, null, 8, ["icon"])], 40, Te)) : g("", !0),
644
+ e.node.expressionPrefix === "" ? g("", !0) : (C(), _("span", {
654
645
  key: 1,
655
646
  class: "cn-layers__prefix",
656
647
  title: e.node.expressionPrefix
657
- }, w(e.node.expressionPrefix), 9, we)),
658
- He(e) ? le((x(), h("input", {
648
+ }, E(e.node.expressionPrefix), 9, Ee)),
649
+ We(e) ? ce((C(), _("input", {
659
650
  key: 2,
660
651
  ref_for: !0,
661
- ref: Ve,
662
- "onUpdate:modelValue": t[0] ||= (e) => Q.value = e,
652
+ ref: Ue,
653
+ "onUpdate:modelValue": t[0] ||= (e) => Z.value = e,
663
654
  "data-rename-input": "",
664
655
  "aria-label": "图层重命名",
665
656
  class: "cn-layers__rename-input min-w-0 flex-1",
666
- onClick: t[1] ||= O(() => {}, ["stop"]),
667
- onDblclick: t[2] ||= O(() => {}, ["stop"]),
668
- onKeydown: [t[3] ||= D(O((e) => We(), ["prevent"]), ["enter"]), t[4] ||= D(O((e) => Ge(), ["prevent"]), ["esc"])],
669
- onBlur: t[5] ||= (e) => We()
670
- }, null, 544)), [[se, Q.value]]) : (x(), h("span", {
657
+ onClick: t[1] ||= k(() => {}, ["stop"]),
658
+ onDblclick: t[2] ||= k(() => {}, ["stop"]),
659
+ onKeydown: [t[3] ||= le(k((e) => $(), ["prevent"]), ["enter"]), t[4] ||= le(k((e) => Ke(), ["prevent"]), ["esc"])],
660
+ onBlur: t[5] ||= (e) => $()
661
+ }, null, 544)), [[oe, Z.value]]) : (C(), _("span", {
671
662
  key: 3,
672
663
  class: "cn-layers__label min-w-0 flex-1 truncate font-mono text-[11px] leading-4",
673
- onDblclick: (t) => Ue(e)
674
- }, w(e.label), 41, Te)),
675
- X(e) ? (x(), h("button", {
664
+ onDblclick: (t) => Ge(e)
665
+ }, E(e.label), 41, De)),
666
+ Y(e) ? (C(), h(c, {
676
667
  key: 4,
677
- type: "button",
678
- "data-visibility": "",
679
- class: y(["cn-layers__eye size-5 shrink-0 items-center justify-center rounded text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent", e.node.visible ? "hidden group-hover:flex" : "flex"]),
680
- title: e.node.visible ? "隐藏图层(最终输出不含该层)" : "显示图层",
681
- "aria-pressed": !e.node.visible,
682
- onClick: O((t) => V(e), ["stop"])
683
- }, [_(i, {
684
- icon: e.node.visible ? T(de) : T(ue),
685
- size: 11,
686
- "stroke-width": 2
687
- }, null, 8, ["icon"])], 10, Ee)) : m("", !0),
688
- X(e) ? (x(), h("button", {
668
+ label: e.node.visible ? "隐藏图层(最终输出不含该层)" : "显示图层",
669
+ class: x(["shrink-0", e.node.visible ? "hidden! group-hover:flex!" : "flex!"])
670
+ }, {
671
+ default: O(() => [v("button", {
672
+ type: "button",
673
+ "data-visibility": "",
674
+ class: x(["cn-layers__eye size-5 shrink-0 items-center justify-center rounded text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent", e.node.visible ? "hidden group-hover:flex" : "flex"]),
675
+ "aria-pressed": !e.node.visible,
676
+ onClick: k((t) => H(e), ["stop"])
677
+ }, [y(n, {
678
+ icon: e.node.visible ? D(de) : D(ue),
679
+ size: 11,
680
+ "stroke-width": 2
681
+ }, null, 8, ["icon"])], 10, Oe)]),
682
+ _: 2
683
+ }, 1032, ["label", "class"])) : g("", !0),
684
+ Y(e) ? (C(), h(c, {
689
685
  key: 5,
690
- type: "button",
691
- "data-lock": "",
692
- class: y(["cn-layers__lock size-5 shrink-0 items-center justify-center rounded text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent", e.node.locked ? "flex" : "hidden group-hover:flex"]),
693
- title: e.node.locked ? a : "锁定图层(画布不可点选/拖动/删除,渲染照常)",
694
- "aria-pressed": e.node.locked,
695
- onClick: O((t) => U(e), ["stop"])
696
- }, [_(i, {
697
- icon: e.node.locked ? T(me) : T(pe),
698
- size: 11,
699
- "stroke-width": 2
700
- }, null, 8, ["icon"])], 10, De)) : m("", !0),
701
- X(e) ? (x(), h("button", {
686
+ label: e.node.locked ? a : "锁定图层(画布不可点选/拖动/删除,渲染照常)",
687
+ class: x(["shrink-0", e.node.locked ? "flex!" : "hidden! group-hover:flex!"])
688
+ }, {
689
+ default: O(() => [v("button", {
690
+ type: "button",
691
+ "data-lock": "",
692
+ class: x(["cn-layers__lock size-5 shrink-0 items-center justify-center rounded text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent", e.node.locked ? "flex" : "hidden group-hover:flex"]),
693
+ "aria-pressed": e.node.locked,
694
+ onClick: k((t) => W(e), ["stop"])
695
+ }, [y(n, {
696
+ icon: e.node.locked ? D(me) : D(pe),
697
+ size: 11,
698
+ "stroke-width": 2
699
+ }, null, 8, ["icon"])], 10, ke)]),
700
+ _: 2
701
+ }, 1032, ["label", "class"])) : g("", !0),
702
+ Y(e) ? (C(), h(c, {
702
703
  key: 6,
703
- type: "button",
704
- "data-rename": "",
705
- class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent group-hover:flex",
706
- title: "重命名(双击名称或 F2)",
707
- onClick: O((t) => Ue(e), ["stop"])
708
- }, [_(i, {
709
- icon: T(he),
710
- size: 11,
711
- "stroke-width": 2
712
- }, null, 8, ["icon"])], 8, Oe)) : m("", !0),
713
- e.node.role === "root" && e.node.type === "TableLayer" ? (x(), h("button", {
704
+ label: "重命名(双击名称或 F2)",
705
+ class: "hidden! group-hover:flex! shrink-0"
706
+ }, {
707
+ default: O(() => [v("button", {
708
+ type: "button",
709
+ "data-rename": "",
710
+ class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent group-hover:flex",
711
+ onClick: k((t) => Ge(e), ["stop"])
712
+ }, [y(n, {
713
+ icon: D(he),
714
+ size: 11,
715
+ "stroke-width": 2
716
+ }, null, 8, ["icon"])], 8, Ae)]),
717
+ _: 2
718
+ }, 1024)) : g("", !0),
719
+ e.node.role === "root" && e.node.type === "TableLayer" ? (C(), _("button", {
714
720
  key: 7,
715
721
  type: "button",
716
722
  "data-add-row": "",
717
723
  class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-[10px] leading-none text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent group-hover:flex disabled:cursor-not-allowed disabled:text-cn-muted/50 disabled:hover:bg-transparent",
718
724
  disabled: e.node.templated === !0,
719
725
  title: e.node.templated === !0 ? "模板态不可加行——行由数据展开" : "加行(缺省行 + 缺省格与文本,行宽=表宽)",
720
- onClick: O((t) => L(e), ["stop"])
721
- }, " +行 ", 8, ke)) : m("", !0),
722
- e.node.role === "row" ? (x(), h("button", {
726
+ onClick: k((t) => R(e), ["stop"])
727
+ }, " +行 ", 8, je)) : g("", !0),
728
+ e.node.role === "row" ? (C(), _("button", {
723
729
  key: 8,
724
730
  type: "button",
725
731
  "data-add-cell": "",
726
732
  class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-[10px] leading-none text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent group-hover:flex",
727
733
  title: "加格(缺省格 + 文本内容,行高取最高格)",
728
- onClick: O((t) => R(e), ["stop"])
729
- }, " +格 ", 8, Ae)) : m("", !0),
730
- e.node.role === "templateRow" ? (x(), h("button", {
734
+ onClick: k((t) => z(e), ["stop"])
735
+ }, " +格 ", 8, Me)) : g("", !0),
736
+ e.node.role === "templateRow" ? (C(), _("button", {
731
737
  key: 9,
732
738
  type: "button",
733
739
  "data-add-template-cell": "",
734
740
  class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-[10px] leading-none text-cn-muted hover:bg-cn-accent/15 hover:text-cn-accent group-hover:flex",
735
741
  title: "加格(缺省格 + 文本内容,零高度耦合——行高由数据展开定稿)",
736
- onClick: O((t) => z(e), ["stop"])
737
- }, " +格 ", 8, je)) : m("", !0),
738
- g("button", {
742
+ onClick: k((t) => B(e), ["stop"])
743
+ }, " +格 ", 8, Ne)) : g("", !0),
744
+ v("button", {
739
745
  type: "button",
740
746
  class: "cn-layers__delete hidden size-5 shrink-0 items-center justify-center rounded text-[10px] leading-none text-cn-muted hover:bg-cn-danger/15 hover:text-cn-danger group-hover:flex disabled:cursor-not-allowed disabled:text-cn-muted/50 disabled:hover:bg-transparent disabled:hover:text-cn-muted/50",
741
747
  disabled: e.node.role === "templateRow" || e.node.locked,
742
748
  title: e.node.role === "templateRow" ? "行模板由表持有——转换回普通表请用 V2 转换入口" : e.node.locked ? o : "删除(含子层)",
743
- onClick: O((t) => B(e), ["stop"])
744
- }, " ✕ ", 8, Me)
745
- ], 46, Se))), 128))], 32)
749
+ onClick: k((t) => V(e), ["stop"])
750
+ }, " ✕ ", 8, Pe)
751
+ ], 46, we))), 128))], 32)
746
752
  ]));
747
753
  }
748
754
  });
749
755
  //#endregion
750
- export { U as a, z as c, q as i, H as l, Y as n, L as o, J as r, V as s, X as t };
756
+ export { W as a, B as c, J as i, U as l, ve as n, R as o, _e as r, H as s, Y as t };