@studio-west/component-sw 0.12.12 → 0.12.14

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,167 +0,0 @@
1
- import e from "./SwTableColumn-S8ldvuhL.js";
2
- import { Fragment as t, computed as n, createElementBlock as r, createElementVNode as i, createTextVNode as a, normalizeStyle as o, onMounted as s, openBlock as c, ref as l, renderList as u, renderSlot as d, toDisplayString as f, unref as p, useSlots as m } from "vue";
3
- //#region src/components/SwTable.vue
4
- var h = { class: "sw-table" }, g = ["colspan", "rowspan"], _ = ["colspan", "rowspan"], v = {
5
- __name: "SwTable",
6
- props: { data: {
7
- type: Array,
8
- required: !0
9
- } },
10
- setup(v) {
11
- let y = v, b = m(), x = l([]);
12
- function S(t) {
13
- let n = [];
14
- for (let r of t) {
15
- if (r.type === Symbol.for("v-fgt") || Array.isArray(r.children)) {
16
- let e = S(Array.isArray(r.children) ? r.children : []);
17
- n.push(...e);
18
- continue;
19
- }
20
- if (r.type === e || r.type.__name === "SwTableColumn" || r.type.name === "SwTableColumn" || typeof r.type == "object" && r.type.name === "AsyncComponentWrapper" && r.props?.prop !== void 0 || typeof r.type == "object" && r.props?.prop !== void 0 || typeof r.type == "object" && r.props?.label !== void 0) {
21
- let e = {
22
- ...r.props,
23
- children: []
24
- }, t = [];
25
- if (typeof r.children?.default == "function") try {
26
- t = r.children.default();
27
- } catch (e) {
28
- console.warn("Error calling default slot:", e);
29
- }
30
- else Array.isArray(r.children) && (t = r.children);
31
- if (t && t.length > 0) {
32
- let n = S(t);
33
- n.length > 0 && (e.children = n);
34
- }
35
- n.push(e);
36
- }
37
- }
38
- return n;
39
- }
40
- function C(e) {
41
- if (!e || e.length === 0) return 1;
42
- let t = 1;
43
- for (let n of e) if (n.children && n.children.length > 0) {
44
- let e = C(n.children);
45
- t = Math.max(t, 1 + e);
46
- }
47
- return t;
48
- }
49
- function w(e, t) {
50
- let n = Array.from({ length: t }, () => []);
51
- function r(e, i, a = "") {
52
- for (let o = 0; o < e.length; o++) {
53
- let s = e[o], c = a ? `${a}-${s.prop || o}` : s.prop || o;
54
- if (s.children && s.children.length > 0) {
55
- let e = T(s.children);
56
- n[i].push({
57
- key: c,
58
- label: s.label,
59
- colspan: e,
60
- rowspan: 1,
61
- width: s.width,
62
- height: s.height
63
- }), r(s.children, i + 1, c);
64
- } else n[i].push({
65
- key: s.prop,
66
- label: s.label,
67
- colspan: 1,
68
- rowspan: t - i,
69
- width: s.width,
70
- height: s.height,
71
- prop: s.prop
72
- });
73
- }
74
- }
75
- return r(e, 0), n;
76
- }
77
- function T(e) {
78
- let t = 0;
79
- function n(e) {
80
- for (let r of e) r.children && r.children.length > 0 ? n(r.children) : t++;
81
- }
82
- return n(e), t;
83
- }
84
- function E(e) {
85
- let t = [];
86
- function n(e) {
87
- for (let r of e) r.children && r.children.length > 0 ? n(r.children) : t.push(r);
88
- }
89
- return n(e), t;
90
- }
91
- function D(e, t) {
92
- if (!e || !Array.isArray(e) || !t || !Array.isArray(t)) return [];
93
- function n(e, t) {
94
- if (!e || !t) return;
95
- let n = t.split("."), r = e;
96
- for (let e of n) {
97
- if (r == null) return;
98
- r = r[e];
99
- }
100
- return r;
101
- }
102
- let r = [], i = /* @__PURE__ */ new Map();
103
- return e.forEach((e, a) => {
104
- let o = [];
105
- t.forEach((r, s) => {
106
- let c = `${a}-${r.prop}`;
107
- if (i.has(c)) return;
108
- let l = n(e, r.prop), u = l, d = 1, f = 1, p = {};
109
- l && typeof l == "object" && l && (u = l.label || l.value || "", d = l.colspan || 1, f = l.rowspan || 1, p = l.style || {});
110
- let m = {
111
- key: c,
112
- label: u,
113
- prop: r.prop,
114
- colspan: d,
115
- rowspan: f,
116
- style: p,
117
- originalRow: e,
118
- rowIndex: a
119
- };
120
- o.push(m);
121
- for (let e = 0; e < f; e++) for (let n = 0; n < d; n++) {
122
- if (e === 0 && n === 0) continue;
123
- let r = `${a + e}-${t[s + n]?.prop}`;
124
- r && i.set(r, !0);
125
- }
126
- }), o.length > 0 && r.push(o);
127
- }), r;
128
- }
129
- let O = n(() => C(x.value)), k = n(() => w(x.value, O.value)), A = n(() => E(x.value)), j = n(() => D(y.data, A.value));
130
- return s(() => {
131
- let e = b.default?.() || [];
132
- console.log("Raw slot VNodes:", e);
133
- let t = e.filter((e) => {
134
- console.log("VNode type:", e.type, "props:", e.props);
135
- let t = e.type && (typeof e.type == "object" || typeof e.type == "function");
136
- return console.log("Is component:", t), t;
137
- });
138
- console.log("Valid VNodes:", t), x.value = S(t), console.log("SwTable mounted - columnTree:", x.value), console.log("SwTable mounted - flatColumns:", A.value), console.log("SwTable mounted - data:", y.data);
139
- }), (e, n) => (c(), r("table", h, [i("thead", null, [(c(!0), r(t, null, u(k.value, (e, n) => (c(), r("tr", { key: n }, [(c(!0), r(t, null, u(e, (e) => (c(), r("th", {
140
- key: e.key,
141
- colspan: e.colspan,
142
- rowspan: e.rowspan,
143
- style: o({
144
- minWidth: e.width,
145
- minHeight: e.height
146
- })
147
- }, f(e.label), 13, g))), 128))]))), 128))]), i("tbody", null, [(c(!0), r(t, null, u(j.value, (n, i) => (c(), r("tr", { key: i }, [(c(!0), r(t, null, u(n, (n) => (c(), r("td", {
148
- key: n.key,
149
- colspan: n.colspan,
150
- rowspan: n.rowspan,
151
- style: o(n.style)
152
- }, [p(b)[n.prop] ? d(e.$slots, n.prop, {
153
- key: 0,
154
- row: n.originalRow,
155
- $index: n.rowIndex,
156
- value: n.label
157
- }) : p(b).default ? d(e.$slots, "default", {
158
- key: 1,
159
- row: n.originalRow,
160
- $index: n.rowIndex,
161
- column: n.prop,
162
- value: n.label
163
- }, () => [a(f(n.label), 1)]) : (c(), r(t, { key: 2 }, [a(f(n.label), 1)], 64))], 12, _))), 128))]))), 128))])]));
164
- }
165
- };
166
- //#endregion
167
- export { v as default };
@@ -1,28 +0,0 @@
1
- import { createElementBlock as e, openBlock as t } from "vue";
2
- //#region src/components/SwTableColumn.vue
3
- var n = { style: { display: "none" } }, r = {
4
- __name: "SwTableColumn",
5
- props: {
6
- prop: {
7
- type: String,
8
- required: !0
9
- },
10
- label: {
11
- type: String,
12
- default: ""
13
- },
14
- width: {
15
- type: [String, Number],
16
- default: "auto"
17
- },
18
- height: {
19
- type: [String, Number],
20
- default: "auto"
21
- }
22
- },
23
- setup(r) {
24
- return (r, i) => (t(), e("div", n));
25
- }
26
- };
27
- //#endregion
28
- export { r as default };