@duxweb/dvha-pro 1.1.27 → 1.1.29

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,8 +1,8 @@
1
- import { createVNode as n, defineComponent as u, computed as d, isVNode as g } from "vue";
1
+ import { createVNode as n, defineComponent as s, computed as l, isVNode as g } from "vue";
2
2
  import { useI18n as f } from "@duxweb/dvha-core";
3
3
  import { useVModel as h } from "@vueuse/core";
4
4
  import v from "clsx";
5
- import { NFormItem as a, NInputNumber as c } from "naive-ui";
5
+ import { NFormItem as c, NInputNumber as a } from "naive-ui";
6
6
  import { DuxGrid as b } from "../../layout/grid.js";
7
7
  import "lodash-es";
8
8
  import "vue-router";
@@ -65,10 +65,10 @@ import "../../schemaEditor/schemaEditor.js";
65
65
  import "dayjs";
66
66
  import "@tanstack/vue-query";
67
67
  import "pinia";
68
- function x(o) {
69
- return typeof o == "function" || Object.prototype.toString.call(o) === "[object Object]" && !g(o);
68
+ function x(t) {
69
+ return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !g(t);
70
70
  }
71
- const C = /* @__PURE__ */ u({
71
+ const C = /* @__PURE__ */ s({
72
72
  name: "WidgetEditorGrid",
73
73
  props: {
74
74
  options: Object,
@@ -78,21 +78,21 @@ const C = /* @__PURE__ */ u({
78
78
  },
79
79
  onChildren: Function
80
80
  },
81
- setup(o) {
82
- const r = d(() => o.options?.col || 2), i = d(() => {
83
- const t = [...o.children || []], e = r.value;
84
- for (; t.length < e; )
85
- t.push([]);
81
+ setup(t) {
82
+ const r = l(() => t.options?.col || 2), i = l(() => {
83
+ const o = [...t.children || []], e = r.value;
84
+ for (; o.length < e; )
85
+ o.push([]);
86
86
  for (let p = 0; p < e; p++)
87
- Array.isArray(t[p]) || (t[p] = []);
88
- return t;
87
+ Array.isArray(o[p]) || (o[p] = []);
88
+ return o;
89
89
  });
90
90
  return () => {
91
- let t;
91
+ let o;
92
92
  return n(b, {
93
93
  cols: r.value,
94
- spac: o.options?.spac
95
- }, x(t = i.value.map((e, p) => {
94
+ spac: t.options?.spac
95
+ }, x(o = i.value.map((e, p) => {
96
96
  const m = e;
97
97
  return n("div", {
98
98
  key: p,
@@ -101,17 +101,17 @@ const C = /* @__PURE__ */ u({
101
101
  })
102
102
  }, [n(E, {
103
103
  modelValue: m,
104
- onUpdate: (s) => {
105
- const l = [...i.value];
106
- l[p] = s, o.onChildren?.(l);
104
+ onUpdate: (u) => {
105
+ const d = [...i.value];
106
+ d[p] = u, t.onChildren?.(d);
107
107
  }
108
108
  }, null)]);
109
- })) ? t : {
110
- default: () => [t]
109
+ })) ? o : {
110
+ default: () => [o]
111
111
  });
112
112
  };
113
113
  }
114
- }), G = /* @__PURE__ */ u({
114
+ }), G = /* @__PURE__ */ s({
115
115
  name: "WidgetEditorGridSetting",
116
116
  props: {
117
117
  value: {
@@ -122,34 +122,34 @@ const C = /* @__PURE__ */ u({
122
122
  })
123
123
  }
124
124
  },
125
- setup(o, {
125
+ setup(t, {
126
126
  emit: r
127
127
  }) {
128
128
  const {
129
129
  t: i
130
- } = f(), t = h(o, "value", r);
130
+ } = f(), o = h(t, "value", r);
131
131
  return () => n(y, {
132
132
  title: i("components.designEditor.grid.title"),
133
133
  icon: "i-tabler:grid-4x4"
134
134
  }, {
135
- default: () => [n(a, {
135
+ default: () => [n(c, {
136
136
  label: i("components.designEditor.grid.columns"),
137
137
  path: "col"
138
138
  }, {
139
- default: () => [n(c, {
140
- value: t.value.col,
141
- "onUpdate:value": (e) => t.value.col = e,
139
+ default: () => [n(a, {
140
+ value: o.value.col,
141
+ "onUpdate:value": (e) => o.value.col = e,
142
142
  min: 1,
143
143
  max: 12,
144
144
  placeholder: i("components.designEditor.grid.columnsPlaceholder")
145
145
  }, null)]
146
- }), n(a, {
146
+ }), n(c, {
147
147
  label: i("components.designEditor.grid.spacing"),
148
148
  path: "spac"
149
149
  }, {
150
- default: () => [n(c, {
151
- value: t.value.spac,
152
- "onUpdate:value": (e) => t.value.spac = e,
150
+ default: () => [n(a, {
151
+ value: o.value.spac,
152
+ "onUpdate:value": (e) => o.value.spac = e,
153
153
  min: 0,
154
154
  max: 100,
155
155
  placeholder: i("components.designEditor.grid.spacingPlaceholder")
@@ -158,26 +158,27 @@ const C = /* @__PURE__ */ u({
158
158
  });
159
159
  }
160
160
  });
161
- function j(o) {
161
+ function j(t) {
162
162
  const {
163
163
  children: r,
164
164
  convertToJsonSchema: i
165
- } = o || {};
166
- let t = [];
167
- return r?.length && i && (t = r.flatMap((e) => Array.isArray(e) ? i(e) : [])), {
165
+ } = t || {};
166
+ let o = [];
167
+ return r?.length && i && (o = r.flatMap((e) => Array.isArray(e) ? i(e) : [])), {
168
168
  tag: "dux-grid",
169
169
  attrs: {
170
- cols: o?.options?.col || 2,
171
- spac: o?.options?.spac || 2
170
+ cols: t?.options?.col || 2,
171
+ spac: t?.options?.spac || 2
172
172
  },
173
- children: t
173
+ children: o
174
174
  };
175
175
  }
176
- function Mt(o) {
176
+ function Mt(t) {
177
177
  return {
178
178
  name: "dux-grid",
179
179
  icon: "i-tabler:grid-4x4",
180
- label: o("components.designEditor.grid.label"),
180
+ label: t("components.designEditor.grid.label"),
181
+ description: t("components.designEditor.grid.description") || "",
181
182
  group: "layout",
182
183
  nested: !0,
183
184
  component: (r) => n(C, r, null),
@@ -1,8 +1,8 @@
1
- import { defineComponent as m, inject as l, computed as p, createVNode as o } from "vue";
1
+ import { defineComponent as s, inject as d, computed as n, createVNode as t } from "vue";
2
+ import { useI18n as c } from "@duxweb/dvha-core";
3
+ import l from "clsx";
4
+ import { NScrollbar as u } from "naive-ui";
2
5
  import "@vueuse/core";
3
- import "clsx";
4
- import "naive-ui";
5
- import "@duxweb/dvha-core";
6
6
  import "vue-echarts";
7
7
  import "vue-router";
8
8
  import "@overlastic/vue";
@@ -54,7 +54,7 @@ import "vue-draggable-plus";
54
54
  import "short-unique-id";
55
55
  import "aieditor";
56
56
  import "@vue-flow/core";
57
- import { DuxFormLayout as a } from "../../form/formLayout.js";
57
+ import { DuxFormLayout as g } from "../../form/formLayout.js";
58
58
  import "lodash-es/cloneDeep";
59
59
  import "@vue-flow/background";
60
60
  /* empty css */
@@ -63,55 +63,93 @@ import "@iconify-json/tabler/icons.json";
63
63
  import "../../posterEditor/elements/index.js";
64
64
  import "fabric";
65
65
  import "../../schemaEditor/schemaEditor.js";
66
- const Et = /* @__PURE__ */ m({
66
+ function a({
67
+ icon: p,
68
+ iconBgClass: o = "bg-primary",
69
+ title: e,
70
+ description: i
71
+ }) {
72
+ return t("div", {
73
+ class: "p-4 border-b border-default"
74
+ }, [t("div", {
75
+ class: "flex gap-2 items-center"
76
+ }, [p && t("div", {
77
+ class: l(["rounded p-2 flex-shrink-0", o])
78
+ }, [t("div", {
79
+ class: l(["size-6 text-white", p])
80
+ }, null)]), t("div", {
81
+ class: "flex-1 min-w-0"
82
+ }, [t("h3", {
83
+ class: "text-base font-medium"
84
+ }, [e]), i && t("p", {
85
+ class: "text-sm text-muted mt-1"
86
+ }, [i])])])]);
87
+ }
88
+ const wt = /* @__PURE__ */ s({
67
89
  name: "WidgetEditorSetting",
68
90
  props: {
69
91
  actionRender: Function
70
92
  },
71
- setup(e) {
72
- const t = l("editor.use"), i = p(() => t?.getData(t.selected.value)), n = p(() => t?.components.value?.find((r) => r.name === i.value?.name));
73
- return () => o("div", {
74
- class: "flex-none p-2 max-w-full w-220px overflow-y-auto bg-default",
93
+ setup(p) {
94
+ const {
95
+ t: o
96
+ } = c(), e = d("editor.use"), i = n(() => e?.getData(e.selected.value)), r = n(() => e?.components.value?.find((m) => m.name === i.value?.name));
97
+ return () => t("div", {
98
+ class: "h-full w-full flex flex-col",
75
99
  key: i.value?.key
76
- }, [n.value?.setting?.({
77
- value: i.value?.options,
78
- "update:modelValue": (r) => {
79
- i?.value && (i.value.options = r);
80
- }
81
- }) || o("div", {
82
- class: "flex flex-col gap-2 h-full"
83
- }, [o("div", {
100
+ }, [!r.value && t(a, {
101
+ icon: "i-tabler:settings",
102
+ iconBgClass: "bg-gray-500",
103
+ title: o("components.designEditor.properties") || "Properties",
104
+ description: o("components.designEditor.selectComponent") || "Select a component to configure"
105
+ }, null), r.value && t(a, {
106
+ icon: r.value.icon,
107
+ iconBgClass: "bg-primary",
108
+ title: r.value.label || r.value.name || o("components.designEditor.component") || "Component",
109
+ description: r.value.description || o("components.designEditor.componentSettings") || "Configure component options"
110
+ }, null), t(u, {
84
111
  class: "flex-1 min-h-0"
85
- }, [t?.settingPage?.component?.({
86
- value: t.value.value.config,
87
- "update:modelValue": (r) => {
88
- t.value.value.config = r;
89
- }
90
- })]), e?.actionRender?.(t)])]);
112
+ }, {
113
+ default: () => [t("div", {
114
+ class: "p-3 pr-2"
115
+ }, [r.value?.setting?.({
116
+ value: i.value?.options,
117
+ "update:modelValue": (m) => {
118
+ i?.value && (i.value.options = m);
119
+ }
120
+ }) || t("div", {
121
+ class: "flex flex-col gap-3"
122
+ }, [t("div", null, [e?.settingPage?.component?.({
123
+ value: e.value.value.config,
124
+ "update:modelValue": (m) => {
125
+ e.value.value.config = m;
126
+ }
127
+ })]), p?.actionRender?.(e)])])]
128
+ })]);
91
129
  }
92
- }), Wt = /* @__PURE__ */ m({
130
+ }), Dt = /* @__PURE__ */ s({
93
131
  name: "WidgetEditorSettingCard",
94
132
  props: {
95
133
  title: String,
96
134
  icon: String
97
135
  },
98
- setup(e, {
99
- slots: t
136
+ setup(p, {
137
+ slots: o
100
138
  }) {
101
- return () => o("div", {
139
+ return () => t("div", {
102
140
  class: "flex flex-col"
103
- }, [o("div", {
104
- class: "bg-elevated rounded py-2 px-4 flex justify-center items-center gap-2"
105
- }, [o("div", null, [e.title])]), o("div", {
141
+ }, [t("div", {
142
+ class: "bg-elevated border border-default rounded-md py-2 px-4 flex justify-center items-center gap-2"
143
+ }, [t("div", null, [p.title])]), t("div", {
106
144
  class: "py-4 flex-1"
107
- }, [o(a, {
145
+ }, [t(g, {
108
146
  labelPlacement: "top"
109
147
  }, {
110
- default: () => [t.default?.()]
148
+ default: () => [o.default?.()]
111
149
  })])]);
112
150
  }
113
151
  });
114
152
  export {
115
- Et as WidgetEditorSetting,
116
- Wt as WidgetEditorSettingCard
153
+ wt as WidgetEditorSetting,
154
+ Dt as WidgetEditorSettingCard
117
155
  };
@@ -1,17 +1,17 @@
1
- import { defineComponent as f, provide as g, watch as d, ref as x, createVNode as a } from "vue";
2
- import { useI18n as v } from "@duxweb/dvha-core";
3
- import u from "clsx";
4
- import { cloneDeep as i } from "lodash-es";
5
- import { NScrollbar as b } from "naive-ui";
6
- import w from "short-unique-id";
7
- import { VueDraggable as h } from "vue-draggable-plus";
8
- import { DuxCard as y } from "../card/card.js";
1
+ import { defineComponent as v, provide as x, watch as i, createVNode as t } from "vue";
2
+ import { useI18n as h } from "@duxweb/dvha-core";
3
+ import d from "clsx";
4
+ import { cloneDeep as s } from "lodash-es";
5
+ import { NScrollbar as w } from "naive-ui";
6
+ import y from "short-unique-id";
7
+ import { VueDraggable as D } from "vue-draggable-plus";
8
+ import { DuxCard as k } from "../card/card.js";
9
9
  import "@vueuse/core";
10
- import { duxFormEditorGrid as D } from "./components/grid.js";
11
- import { useEditor as k } from "./editor/hook.js";
12
- import { DuxWidgetEditorPreview as c } from "./editor/preview.js";
13
- import { WidgetEditorSetting as C } from "./editor/setting.js";
14
- const M = /* @__PURE__ */ f({
10
+ import { duxFormEditorGrid as E } from "./components/grid.js";
11
+ import { useEditor as C } from "./editor/hook.js";
12
+ import { DuxWidgetEditorPreview as u } from "./editor/preview.js";
13
+ import { WidgetEditorSetting as U } from "./editor/setting.js";
14
+ const O = /* @__PURE__ */ v({
15
15
  name: "DuxDesignEditor",
16
16
  props: {
17
17
  data: Object,
@@ -22,86 +22,81 @@ const M = /* @__PURE__ */ f({
22
22
  actionRender: Function,
23
23
  previewWrapper: Function
24
24
  },
25
- setup(r) {
25
+ setup(l) {
26
26
  const {
27
27
  t: o
28
- } = v(), t = k({
29
- settingPage: r.settingPage
28
+ } = h(), a = C({
29
+ settingPage: l.settingPage
30
30
  });
31
- g("editor.use", t), d([() => r.components, () => r.groups], () => {
32
- t.clearGroup(), t.clearComponent(), t.addGroup({
31
+ x("editor.use", a), i([() => l.components, () => l.groups], () => {
32
+ a.clearGroup(), a.clearComponent(), a.addGroup({
33
33
  name: "layout",
34
34
  label: o("components.designEditor.layout") || "Layout",
35
35
  icon: "i-tabler:layout"
36
- }), r.groups?.forEach((e) => {
37
- t.addGroup(e);
38
- }), t.addComponent(D(o)), r.components?.forEach((e) => {
39
- t.addComponent(e);
36
+ }), l.groups?.forEach((e) => {
37
+ a.addGroup(e);
38
+ }), a.addComponent(E(o)), l.components?.forEach((e) => {
39
+ a.addComponent(e);
40
40
  });
41
41
  }, {
42
42
  immediate: !0,
43
43
  deep: !0
44
44
  });
45
- const l = x(), {
46
- randomUUID: p
47
- } = new w({
45
+ const {
46
+ randomUUID: g
47
+ } = new y({
48
48
  length: 10
49
49
  }), m = (e) => ({
50
- key: p(),
50
+ key: g(),
51
51
  name: e.name,
52
- options: i(e.settingDefault)
52
+ options: s(e.settingDefault)
53
53
  });
54
- return d(() => r.data, (e) => {
55
- const n = r.settingPage?.default || {};
56
- t.value.value = {
54
+ i(() => l.data, (e) => {
55
+ const r = l.settingPage?.default || {};
56
+ a.value.value = {
57
57
  config: {
58
- ...n,
59
- ...i(e?.config || {})
58
+ ...r,
59
+ ...s(e?.config || {})
60
60
  },
61
- data: i(e?.data || [])
61
+ data: s(e?.data || [])
62
62
  };
63
63
  }, {
64
64
  deep: !0,
65
65
  immediate: !0
66
- }), d(t.value, (e) => {
67
- r.onUpdateData?.(e);
66
+ }), i(a.value, (e) => {
67
+ l.onUpdateData?.(e);
68
68
  }, {
69
69
  deep: !0
70
- }), () => a(y, {
70
+ });
71
+ const c = ["bg-red-500", "bg-orange-500", "bg-amber-500", "bg-yellow-500", "bg-lime-500", "bg-green-500", "bg-emerald-500", "bg-teal-500", "bg-cyan-500", "bg-sky-500", "bg-blue-500", "bg-indigo-500", "bg-violet-500", "bg-purple-500", "bg-fuchsia-500", "bg-pink-500", "bg-rose-500"];
72
+ return () => t(k, {
71
73
  class: "h-full",
72
74
  shadow: !0
73
75
  }, {
74
- default: () => [a("div", {
75
- class: "h-full flex flex-row text-default"
76
- }, [a("div", {
77
- class: "flex-none flex flex-col gap-2 border-r border-default bg-default p-2"
78
- }, [a(s, {
79
- title: o("components.designEditor.all") || "All",
80
- icon: "i-tabler:hexagons",
81
- active: !l.value,
82
- onClick: () => {
83
- l.value = void 0;
84
- }
85
- }, null), t.group.value?.map((e, n) => a(s, {
86
- key: n,
87
- active: l.value === e.name,
88
- title: e.label,
89
- icon: e.icon,
90
- onClick: () => {
91
- l.value = e.name;
92
- }
93
- }, null))]), a("div", {
94
- class: "flex-none text-xs w-180px bg-default",
95
- id: "comp-list"
96
- }, [a(b, null, {
97
- default: () => [a("div", {
98
- class: "flex flex-col gap-4 p-2"
99
- }, [t.tree.value?.filter((e) => l.value ? e.name === l.value : !0).map((e) => a("div", {
76
+ default: () => [t("div", {
77
+ class: "h-full w-full relative text-default bg-muted rounded-md"
78
+ }, [t("div", {
79
+ class: "absolute top-4 left-4 bottom-4 z-10"
80
+ }, [t("div", {
81
+ class: "h-full w-220px bg-default shadow rounded"
82
+ }, [t("div", {
83
+ class: "h-full flex flex-col"
84
+ }, [t(w, {
85
+ class: "flex-1 min-h-0"
86
+ }, {
87
+ default: () => [t("div", {
88
+ class: "p-4 space-y-4",
89
+ id: "comp-list"
90
+ }, [a.tree.value?.filter((e) => e.children && e.children.length > 0).map((e, r) => t("div", {
100
91
  key: e.name,
101
- class: "flex flex-col gap-2"
102
- }, [a("div", {
103
- class: "bg-muted border border-muted rounded p-2 flex justify-center"
104
- }, [e.label]), a(h, {
92
+ class: "space-y-2"
93
+ }, [t("div", {
94
+ class: "flex items-center gap-2 text-sm px-1"
95
+ }, [t("div", {
96
+ class: d(["size-4", e.icon])
97
+ }, null), t("span", {
98
+ class: "truncate"
99
+ }, [e.label])]), t(D, {
105
100
  modelValue: e.children || [],
106
101
  animation: 150,
107
102
  group: {
@@ -111,52 +106,52 @@ const M = /* @__PURE__ */ f({
111
106
  },
112
107
  sort: !1,
113
108
  clone: m,
114
- class: "grid grid-cols-2 items-start gap-2 "
109
+ class: "space-y-2"
115
110
  }, {
116
- default: () => [e.children?.map((n) => a("div", {
117
- key: n.name,
118
- class: "border border-muted rounded-sm p-2 flex flex-col items-center gap-2 cursor-pointer hover:bg-muted edit-drag"
119
- }, [a("div", {
120
- class: u(["size-6", n.icon])
121
- }, null), a("div", {
122
- class: "truncate whitespace-nowrap px-2 overflow-hidden"
123
- }, [n.label])]))]
124
- })]))])]
125
- })]), a("div", {
126
- class: "flex-1 shadow-sm flex flex-col items-center p-6 overflow-auto",
111
+ default: () => [e.children?.map((n, p) => {
112
+ const f = (r * 20 + p) % c.length, b = c[f];
113
+ return t("div", {
114
+ key: n.name,
115
+ class: "rounded-lg px-3 py-2 cursor-move transition-all bg-default dark:bg-muted hover:bg-elevated edit-drag flex items-center gap-3"
116
+ }, [t("div", {
117
+ class: d(["size-8 rounded-lg flex items-center justify-center flex-shrink-0", b])
118
+ }, [t("div", {
119
+ class: d(["size-4 text-white", n.icon])
120
+ }, null)]), t("div", {
121
+ class: "flex-1 min-w-0"
122
+ }, [t("div", {
123
+ class: "text-sm font-medium truncate"
124
+ }, [n.label]), n.description && t("div", {
125
+ class: "text-xs truncate opacity-80"
126
+ }, [n.description])])]);
127
+ })]
128
+ })])), a.tree.value?.filter((e) => e.children && e.children.length > 0).length === 0 && t("div", {
129
+ class: "text-xs text-muted text-center py-4"
130
+ }, [o("components.designEditor.empty") || "No components"])])]
131
+ })])])]), t("div", {
132
+ class: "absolute inset-0 shadow-sm flex flex-col items-center p-6 overflow-auto",
127
133
  style: "background: linear-gradient(45deg, rgba(0,0,0, 0.1) 25%, transparent 25%), linear-gradient(-45deg, rgba(0,0,0, 0.1) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(0,0,0, 0.1) 75%), linear-gradient(-45deg, transparent 75%, rgba(0,0,0, 0.1) 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0px;"
128
- }, [a("div", {
134
+ }, [t("div", {
129
135
  class: "max-w-2xl w-full flex-1 bg-default shadow p-2",
130
136
  onClick: () => {
131
- t.selected.value = void 0;
137
+ a.selected.value = void 0;
132
138
  }
133
- }, [r.previewWrapper ? r.previewWrapper(a(c, {
134
- modelValue: t.value.value?.data,
135
- onUpdate: (e) => t.value.value.data = e
136
- }, null), t) : a(c, {
137
- modelValue: t.value.value?.data,
138
- onUpdate: (e) => t.value.value.data = e
139
- }, null)])]), a(C, {
140
- actionRender: r.actionRender
141
- }, null)])]
139
+ }, [l.previewWrapper ? l.previewWrapper(t(u, {
140
+ modelValue: a.value.value?.data,
141
+ onUpdate: (e) => a.value.value.data = e
142
+ }, null), a) : t(u, {
143
+ modelValue: a.value.value?.data,
144
+ onUpdate: (e) => a.value.value.data = e
145
+ }, null)])]), t("div", {
146
+ class: "absolute top-4 right-4 bottom-4 z-10"
147
+ }, [t("div", {
148
+ class: "h-full w-300px bg-default shadow rounded"
149
+ }, [t(U, {
150
+ actionRender: l.actionRender
151
+ }, null)])])])]
142
152
  });
143
153
  }
144
154
  });
145
- function s({
146
- title: r,
147
- icon: o,
148
- active: t,
149
- onClick: l
150
- }) {
151
- return a("div", {
152
- class: u(["flex flex-col items-center px-3 py-2 hover:bg-primary/10 cursor-pointer rounded-sm", t ? "bg-primary/10 text-primary" : ""]),
153
- onClick: l
154
- }, [a("div", {
155
- class: u(["size-4", o])
156
- }, null), a("div", {
157
- class: "truncate whitespace-nowrap text-default text-sm"
158
- }, [r])]);
159
- }
160
155
  export {
161
- M as DuxDesignEditor
156
+ O as DuxDesignEditor
162
157
  };