@versa-stack/v-craft 1.0.1 → 1.0.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.
@@ -1,5 +1,6 @@
1
- import { CraftEditorConfig } from '../lib/model';
1
+ import { HTMLAttributes } from 'vue';
2
2
  import { CraftNode } from '../lib/craftNode';
3
+ import { CraftEditorConfig } from '../lib/model';
3
4
  declare const _default: <T extends object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
5
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
5
6
  readonly onNodeDragEnd?: (() => any) | undefined;
@@ -9,6 +10,7 @@ declare const _default: <T extends object>(__VLS_props: NonNullable<Awaited<type
9
10
  config: CraftEditorConfig<T>;
10
11
  useIframe?: boolean;
11
12
  iFrameStyleSheets?: string[];
13
+ iFrameClass?: HTMLAttributes["class"];
12
14
  inheritStyles?: boolean;
13
15
  } & Partial<{}>> & import('vue').PublicProps;
14
16
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
@@ -1,4 +1,4 @@
1
- import { StyleValue } from 'vue';
1
+ import { StyleValue, HTMLAttributes } from 'vue';
2
2
  import { CraftNodeResolverMap } from '../lib/CraftNodeResolver';
3
3
  declare const _default: <T extends object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
4
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
@@ -9,6 +9,7 @@ declare const _default: <T extends object>(__VLS_props: NonNullable<Awaited<type
9
9
  iFrameStyleSheets?: string[];
10
10
  iFrameStyles?: string[];
11
11
  iFrameWidth?: "auto" | number;
12
+ iFrameClass?: HTMLAttributes["class"];
12
13
  inheritStyles?: boolean;
13
14
  resolverMap?: CraftNodeResolverMap<T>;
14
15
  useIframe?: boolean;
@@ -1,6 +1,6 @@
1
- import { StyleValue } from 'vue';
1
+ import { StyleValue, HTMLAttributes } from 'vue';
2
2
  type __VLS_Props = {
3
- iframeClass?: string | Record<string, boolean>;
3
+ iframeClass?: HTMLAttributes["class"];
4
4
  iframeStyle?: StyleValue;
5
5
  inheritStyles?: boolean;
6
6
  styleSheets?: string[];
@@ -28,7 +28,7 @@ declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}
28
28
  inheritStyles: boolean;
29
29
  width: "auto" | number;
30
30
  height: "auto" | number;
31
- iframeClass: string | Record<string, boolean>;
31
+ iframeClass: string | false | Record<string, any> | import('vue').ClassValue[] | null;
32
32
  iframeStyle: string | false | import('vue').CSSProperties | StyleValue[] | null;
33
33
  styleSheets: string[];
34
34
  styles: string[];
@@ -1,4 +1,4 @@
1
- import { defineComponent as $, useSlots as Ue, useAttrs as ot, inject as ae, computed as w, openBlock as v, createBlock as N, resolveDynamicComponent as me, normalizeProps as Ae, mergeProps as Oe, unref as f, createSlots as ge, renderList as M, withCtx as X, renderSlot as W, guardReactiveProps as it, createCommentVNode as x, markRaw as Be, ref as K, watch as le, normalizeClass as oe, createTextVNode as at, toDisplayString as ne, createElementBlock as E, withKeys as Pe, withModifiers as V, nextTick as ue, provide as re, resolveComponent as U, createVNode as G, Fragment as T, createElementVNode as O, toRef as ce, onUnmounted as Le, toRefs as fe, normalizeStyle as je, withDirectives as lt, Teleport as ut, vShow as ct, onMounted as Ne, onBeforeMount as dt, onBeforeUnmount as ft, readonly as ht, toHandlers as Fe, h as pt } from "vue";
1
+ import { defineComponent as $, useSlots as Be, useAttrs as ot, inject as ae, computed as w, openBlock as v, createBlock as N, resolveDynamicComponent as me, normalizeProps as Ae, mergeProps as Oe, unref as f, createSlots as ge, renderList as M, withCtx as X, renderSlot as W, guardReactiveProps as it, createCommentVNode as x, markRaw as Ue, ref as K, watch as le, normalizeClass as oe, createTextVNode as at, toDisplayString as ne, createElementBlock as E, withKeys as Pe, withModifiers as V, nextTick as ue, provide as re, resolveComponent as B, createVNode as G, Fragment as T, createElementVNode as O, toRef as ce, onUnmounted as Le, toRefs as fe, normalizeStyle as je, withDirectives as lt, Teleport as ut, vShow as ct, onMounted as Ne, onBeforeMount as dt, onBeforeUnmount as ft, readonly as ht, toHandlers as Fe, h as pt } from "vue";
2
2
  import { defineStore as He, storeToRefs as Z } from "pinia";
3
3
  import { v4 as de } from "uuid";
4
4
  import { debounce as Ve } from "lodash-es";
@@ -10,7 +10,7 @@ const vt = /* @__PURE__ */ $({
10
10
  componentName: {}
11
11
  },
12
12
  setup(t) {
13
- const e = Ue(), r = ot(), n = t, s = ae("resolver"), o = w(() => s?.value.resolve(n.componentName)), i = w(() => o.value?.componentName || n.componentName);
13
+ const e = Be(), r = ot(), n = t, s = ae("resolver"), o = w(() => s?.value.resolve(n.componentName)), i = w(() => o.value?.componentName || n.componentName);
14
14
  return (a, c) => i.value ? (v(), N(me(i.value), Ae(Oe({ key: 0 }, f(r))), ge({ _: 2 }, [
15
15
  M(f(e), (u, d) => ({
16
16
  name: d,
@@ -148,7 +148,7 @@ const vt = /* @__PURE__ */ $({
148
148
  },
149
149
  addNodeRecursively(t, e = null) {
150
150
  const r = t.uuid || de(), n = { ...t, uuid: r, parentUuid: e };
151
- this.nodeMap.set(r, Be(n)), e || this.rootNodes.push(r), t.slots && Object.values(t.slots).forEach((s) => {
151
+ this.nodeMap.set(r, Ue(n)), e || this.rootNodes.push(r), t.slots && Object.values(t.slots).forEach((s) => {
152
152
  s.forEach((o) => this.addNodeRecursively(o, r));
153
153
  });
154
154
  },
@@ -342,7 +342,7 @@ const vt = /* @__PURE__ */ $({
342
342
  class ye {
343
343
  resolverMap = {};
344
344
  constructor(e = {}) {
345
- return this.setResolverMap(e), Be(this);
345
+ return this.setResolverMap(e), Ue(this);
346
346
  }
347
347
  setResolverMap(e) {
348
348
  this.resolverMap = {}, Object.entries(e).forEach(([r, n]) => {
@@ -374,6 +374,7 @@ const Ct = /* @__PURE__ */ $({
374
374
  config: {},
375
375
  useIframe: { type: Boolean, default: !1 },
376
376
  iFrameStyleSheets: { default: () => [] },
377
+ iFrameClass: { type: [Boolean, null, String, Object, Array], default: "" },
377
378
  inheritStyles: { type: Boolean, default: !1 }
378
379
  },
379
380
  emits: ["nodeDragStart", "nodeDragEnd", "iframeLoad"],
@@ -388,7 +389,7 @@ const Ct = /* @__PURE__ */ $({
388
389
  });
389
390
  const i = K(new ye(r.config.resolverMap));
390
391
  return re("resolver", i), (a, c) => {
391
- const u = U("CraftFrame"), d = U("CraftEditorPanelLayout");
392
+ const u = B("CraftFrame"), d = B("CraftEditorPanelLayout");
392
393
  return v(), N(d, {
393
394
  blueprints: t.config.blueprintsLibrary
394
395
  }, ge({ _: 2 }, [
@@ -408,6 +409,7 @@ const Ct = /* @__PURE__ */ $({
408
409
  useIframe: t.useIframe,
409
410
  inheritStyles: t.inheritStyles,
410
411
  iFrameStyleSheets: t.iFrameStyleSheets,
412
+ iFrameClass: t.iFrameClass,
411
413
  resolverMap: t.config.resolverMap,
412
414
  onIframeLoad: c[0] || (c[0] = (h) => n("iframeLoad", h))
413
415
  }, {
@@ -415,7 +417,7 @@ const Ct = /* @__PURE__ */ $({
415
417
  W(a.$slots, "default")
416
418
  ]),
417
419
  _: 3
418
- }, 8, ["useIframe", "inheritStyles", "iFrameStyleSheets", "resolverMap"])
420
+ }, 8, ["useIframe", "inheritStyles", "iFrameStyleSheets", "iFrameClass", "resolverMap"])
419
421
  ]),
420
422
  key: "1"
421
423
  }
@@ -525,7 +527,7 @@ const wt = /* @__PURE__ */ $({
525
527
  setup(t) {
526
528
  const e = ae("resolver");
527
529
  return (r, n) => {
528
- const s = U("CraftEditorBlueprint");
530
+ const s = B("CraftEditorBlueprint");
529
531
  return f(e) ? (v(), E("div", Ot, [
530
532
  (v(!0), E(T, null, M(t.blueprints.groups, (o) => (v(), E("div", null, [
531
533
  W(r.$slots, "blueprint-group", {
@@ -560,7 +562,7 @@ const wt = /* @__PURE__ */ $({
560
562
  emits: ["close"],
561
563
  setup(t) {
562
564
  return (e, r) => {
563
- const n = U("CraftEditorBlueprintsList");
565
+ const n = B("CraftEditorBlueprintsList");
564
566
  return v(), E("div", Pt, [
565
567
  r[0] || (r[0] = O("h3", { class: "v-craft-title" }, "blueprints", -1)),
566
568
  O("div", Dt, [
@@ -597,7 +599,7 @@ const wt = /* @__PURE__ */ $({
597
599
  schema: o.value
598
600
  });
599
601
  }
600
- }), It = { class: "v-craft-panel v-craft-layers-panel" }, Mt = { class: "v-craft-layers" }, Tt = { class: "v-craft-node-layers" }, Ut = /* @__PURE__ */ $({
602
+ }), It = { class: "v-craft-panel v-craft-layers-panel" }, Mt = { class: "v-craft-layers" }, Tt = { class: "v-craft-node-layers" }, Bt = /* @__PURE__ */ $({
601
603
  name: "CraftEditorPanelLayers",
602
604
  __name: "CraftEditorPanelLayers",
603
605
  setup(t) {
@@ -605,7 +607,7 @@ const wt = /* @__PURE__ */ $({
605
607
  e.selectNode(s);
606
608
  };
607
609
  return (s, o) => {
608
- const i = U("CraftEditorPanelNodeLayer");
610
+ const i = B("CraftEditorPanelNodeLayer");
609
611
  return v(), E("div", It, [
610
612
  o[0] || (o[0] = O("h3", { class: "v-craft-title" }, "tree", -1)),
611
613
  O("div", Mt, [
@@ -620,7 +622,7 @@ const wt = /* @__PURE__ */ $({
620
622
  ]);
621
623
  };
622
624
  }
623
- }), Bt = /* @__PURE__ */ be(Ut, [["__scopeId", "data-v-e2502bab"]]), Lt = { key: 0 }, jt = {
625
+ }), Ut = /* @__PURE__ */ be(Bt, [["__scopeId", "data-v-e2502bab"]]), Lt = { key: 0 }, jt = {
624
626
  key: 1,
625
627
  class: "v-craft-panel-manager"
626
628
  }, Ft = { class: "flex w-full justify-between gap-10" }, Ht = { class: "v-craft-grid-panel v-craft-panel-left shrink" }, Vt = { class: "v-craft-grid-panel v-craft-panel-right shrink" }, Kt = /* @__PURE__ */ $({
@@ -633,7 +635,7 @@ const wt = /* @__PURE__ */ $({
633
635
  e.selectNode(null);
634
636
  };
635
637
  return (n, s) => {
636
- const o = U("CraftEditorPanelBlueprints"), i = U("CraftEditorPanelLayers"), a = U("CraftEditorPanelSettings");
638
+ const o = B("CraftEditorPanelBlueprints"), i = B("CraftEditorPanelLayers"), a = B("CraftEditorPanelSettings");
637
639
  return n.$slots["panel-layout"] ? (v(), E("div", Lt, [
638
640
  W(n.$slots, "panel-layout", {
639
641
  blueprints: t.blueprints,
@@ -671,7 +673,7 @@ const wt = /* @__PURE__ */ $({
671
673
  setup(t, { emit: e }) {
672
674
  const r = t, { craftNode: n, schema: s } = fe(r), o = e;
673
675
  return (i, a) => {
674
- const c = U("CraftEditorPanelForm");
676
+ const c = B("CraftEditorPanelForm");
675
677
  return v(), N(c, {
676
678
  craftNode: f(n),
677
679
  schema: f(s),
@@ -720,7 +722,7 @@ const wt = /* @__PURE__ */ $({
720
722
  a.toggleNodeVisibility(n.value);
721
723
  };
722
724
  return (m, p) => {
723
- const b = U("CraftEditorPanelNodeLayer", !0);
725
+ const b = B("CraftEditorPanelNodeLayer", !0);
724
726
  return v(), E("li", {
725
727
  class: oe(["v-craft-node-layer", {
726
728
  "v-craft-node-layer-selected": d.value
@@ -761,7 +763,7 @@ const wt = /* @__PURE__ */ $({
761
763
  setup(t, { emit: e }) {
762
764
  const r = t, { craftNode: n, schema: s } = fe(r), o = e;
763
765
  return (i, a) => {
764
- const c = U("CraftEditorPanelForm");
766
+ const c = B("CraftEditorPanelForm");
765
767
  return v(), N(c, {
766
768
  craftNode: f(n),
767
769
  schema: f(s),
@@ -815,7 +817,7 @@ const wt = /* @__PURE__ */ $({
815
817
  r.value && h && e.updateNodeEvents(r.value.uuid, h);
816
818
  };
817
819
  return (h, m) => {
818
- const p = U("CraftEditorPanelNodeSettings"), b = U("CraftEditorPanelNodeEventsSettings");
820
+ const p = B("CraftEditorPanelNodeSettings"), b = B("CraftEditorPanelNodeEventsSettings");
819
821
  return W(h.$slots, "panel-content", {
820
822
  selectedNode: f(r),
821
823
  nodeName: c.value,
@@ -887,7 +889,7 @@ const wt = /* @__PURE__ */ $({
887
889
  }), Qe = /* @__PURE__ */ $({
888
890
  __name: "CraftIframe",
889
891
  props: {
890
- iframeClass: { default: "" },
892
+ iframeClass: { type: [Boolean, null, String, Object, Array], default: "" },
891
893
  iframeStyle: { type: [Boolean, null, String, Object, Array], default: () => ({}) },
892
894
  inheritStyles: { type: Boolean, default: !1 },
893
895
  styleSheets: { default: () => [] },
@@ -949,8 +951,8 @@ const wt = /* @__PURE__ */ $({
949
951
  const k = n.value?.parentElement;
950
952
  let I = 0;
951
953
  if (k) {
952
- const B = k.clientHeight, Q = n.value?.offsetTop || 0;
953
- I = B - Q;
954
+ const U = k.clientHeight, Q = n.value?.offsetTop || 0;
955
+ I = U - Q;
954
956
  }
955
957
  const J = y.body, he = y.documentElement, P = Math.max(
956
958
  150,
@@ -1025,7 +1027,7 @@ const wt = /* @__PURE__ */ $({
1025
1027
  n?.value && e.setResolver(n.value), t && re("resolver", n);
1026
1028
  const s = () => {
1027
1029
  if (n?.value && !r.value) {
1028
- const o = Ue(), a = (o.default ? o.default() : []).flatMap((c) => {
1030
+ const o = Be(), a = (o.default ? o.default() : []).flatMap((c) => {
1029
1031
  if (c.key === "_default" && c.children && Array.isArray(c.children))
1030
1032
  return c.children.map((u) => {
1031
1033
  const d = Ce(n.value, u);
@@ -1057,6 +1059,7 @@ const wt = /* @__PURE__ */ $({
1057
1059
  iFrameStyleSheets: { default: () => [] },
1058
1060
  iFrameStyles: { default: () => [] },
1059
1061
  iFrameWidth: { default: "auto" },
1062
+ iFrameClass: { type: [Boolean, null, String, Object, Array] },
1060
1063
  inheritStyles: { type: Boolean, default: !1 },
1061
1064
  resolverMap: {},
1062
1065
  useIframe: { type: Boolean, default: !1 },
@@ -1068,7 +1071,7 @@ const wt = /* @__PURE__ */ $({
1068
1071
  i("iframeLoad", h);
1069
1072
  }, i = e, { editor: a } = lr(r.resolverMap), { nodeTree: c, hasNodes: u, enabled: d } = Z(a);
1070
1073
  return (h, m) => {
1071
- const p = U("CraftNodeViewer"), b = U("CraftNodeEditor");
1074
+ const p = B("CraftNodeViewer"), b = B("CraftNodeEditor");
1072
1075
  return v(), E("div", ur, [
1073
1076
  t.useIframe ? (v(), N(Qe, {
1074
1077
  key: 0,
@@ -1078,6 +1081,7 @@ const wt = /* @__PURE__ */ $({
1078
1081
  ...t.iFrameStyles
1079
1082
  ],
1080
1083
  "iframe-style": t.iFrameStyle,
1084
+ "iframe-class": t.iFrameClass,
1081
1085
  "style-sheets": t.iFrameStyleSheets,
1082
1086
  width: f(n),
1083
1087
  height: f(s)
@@ -1094,7 +1098,7 @@ const wt = /* @__PURE__ */ $({
1094
1098
  !t.viewOnly && f(d) ? (v(), N(ke, { key: 2 })) : x("", !0)
1095
1099
  ]),
1096
1100
  _: 1
1097
- }, 8, ["inheritStyles", "styles", "iframe-style", "style-sheets", "width", "height"])) : x("", !0),
1101
+ }, 8, ["inheritStyles", "styles", "iframe-style", "iframe-class", "style-sheets", "width", "height"])) : x("", !0),
1098
1102
  !t.useIframe && (t.viewOnly || !f(d)) && f(u) ? (v(!0), E(T, { key: 1 }, M(f(c), (g) => (v(), N(p, {
1099
1103
  key: `${g.uuid}-view`,
1100
1104
  craftNode: g
@@ -1325,21 +1329,21 @@ Error:`,
1325
1329
  let S = 0;
1326
1330
  for (let L = 0; L < P.length; L++)
1327
1331
  S = P.charCodeAt(L) + ((S << 5) - S);
1328
- const B = S % 360, Q = 70 + S % 30, H = 45 + S % 30;
1329
- return `hsla(${B}, ${Q}%, ${H}%, 0.9)`;
1332
+ const U = S % 360, Q = 70 + S % 30, H = 45 + S % 30;
1333
+ return `hsla(${U}, ${Q}%, ${H}%, 0.9)`;
1330
1334
  }, y = w(() => R(r.value.uuid)), k = w(() => {
1331
- const P = [], B = a?.value?.resolveNode?.(r.value)?.slots;
1332
- return B && B.length > 0 ? P.push(...B) : P.push("default"), P;
1333
- }), I = w(() => q(r.value) ? !0 : Object.values(r.value.slots || {}).some((P) => P.length > 0)), J = (P, S) => u.value ? u.value.slotName && u.value.slotName !== S ? [] : he(u.value, P) : [], he = (P, S) => P.type === "single" ? S.map((B) => ({
1334
- key: `${B.uuid}-single`,
1335
+ const P = [], U = a?.value?.resolveNode?.(r.value)?.slots;
1336
+ return U && U.length > 0 ? P.push(...U) : P.push("default"), P;
1337
+ }), I = w(() => q(r.value) ? !0 : Object.values(r.value.slots || {}).some((P) => P.length > 0)), J = (P, S) => u.value ? u.value.slotName && u.value.slotName !== S ? [] : he(u.value, P) : [], he = (P, S) => P.type === "single" ? S.map((U) => ({
1338
+ key: `${U.uuid}-single`,
1335
1339
  craftNode: {
1336
- ...B,
1340
+ ...U,
1337
1341
  props: {
1338
- ...B.props,
1342
+ ...U.props,
1339
1343
  ...P.item || {}
1340
1344
  }
1341
1345
  }
1342
- })) : P.type === "list" ? P.list ? S.reduce((B, Q) => B.concat(
1346
+ })) : P.type === "list" ? P.list ? S.reduce((U, Q) => U.concat(
1343
1347
  P.list.map((H, L) => ({
1344
1348
  key: `${Q.uuid}-data-${L}`,
1345
1349
  craftNode: {
@@ -1352,7 +1356,7 @@ Error:`,
1352
1356
  }))
1353
1357
  ), []) : [] : [];
1354
1358
  return (P, S) => {
1355
- const B = U("CraftNodeViewer"), Q = U("CraftNodeEditor", !0);
1359
+ const U = B("CraftNodeViewer"), Q = B("CraftNodeEditor", !0);
1356
1360
  return f(s) && r.value && f(o) ? (v(), N(me(f(o).componentName), Oe({
1357
1361
  key: 0,
1358
1362
  ref_key: "nodeRef",
@@ -1396,7 +1400,7 @@ Error:`,
1396
1400
  O("span", yr, ne(H), 1)
1397
1401
  ], 40, gr)) : x("", !0),
1398
1402
  I.value ? (v(), E(T, { key: 1 }, [
1399
- u.value?.type && u.value.slotName === H ? (v(!0), E(T, { key: 0 }, M(J(r.value.slots?.[H] || [], H), (L) => (v(), N(B, {
1403
+ u.value?.type && u.value.slotName === H ? (v(!0), E(T, { key: 0 }, M(J(r.value.slots?.[H] || [], H), (L) => (v(), N(U, {
1400
1404
  key: L.key,
1401
1405
  craftNode: L.craftNode
1402
1406
  }, null, 8, ["craftNode"]))), 128)) : x("", !0),
@@ -1505,7 +1509,7 @@ Error:`,
1505
1509
  CraftEditorBlueprintsList: At,
1506
1510
  CraftEditorPanelBlueprints: $t,
1507
1511
  CraftEditorPanelForm: Rt,
1508
- CraftEditorPanelLayers: Bt,
1512
+ CraftEditorPanelLayers: Ut,
1509
1513
  CraftEditorPanelLayout: Xt,
1510
1514
  CraftEditorPanelNodeEventsSettings: qt,
1511
1515
  CraftEditorPanelNodeLayer: Zt,
@@ -2979,10 +2983,10 @@ const qr = {
2979
2983
  CraftCanvas: {
2980
2984
  componentName: "CraftCanvas"
2981
2985
  }
2982
- }, Ur = (t) => {
2986
+ }, Br = (t) => {
2983
2987
  for (const e in Ie)
2984
2988
  t.component(e, Ie[e]);
2985
- }, Wr = { install: Ur };
2989
+ }, Wr = { install: Br };
2986
2990
  export {
2987
2991
  vt as CraftCanvas,
2988
2992
  Et as CraftComponentSimpleText,
@@ -2991,7 +2995,7 @@ export {
2991
2995
  At as CraftEditorBlueprintsList,
2992
2996
  $t as CraftEditorPanelBlueprints,
2993
2997
  Rt as CraftEditorPanelForm,
2994
- Bt as CraftEditorPanelLayers,
2998
+ Ut as CraftEditorPanelLayers,
2995
2999
  Xt as CraftEditorPanelLayout,
2996
3000
  qt as CraftEditorPanelNodeEventsSettings,
2997
3001
  Zt as CraftEditorPanelNodeLayer,