@studio-west/component-sw 0.10.9 → 0.10.11

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,152 +0,0 @@
1
- import { useSlots as W, ref as G, onMounted as J, computed as m, createElementBlock as p, openBlock as u, createElementVNode as S, Fragment as w, renderList as g, normalizeStyle as T, toDisplayString as x, renderSlot as K, createTextVNode as O } from "vue";
2
- import P from "./SwTableColumn-BLF5bPuJ.js";
3
- const Q = { class: "sw-table" }, U = ["colspan", "rowspan"], X = ["colspan", "rowspan"], I = {
4
- __name: "SwTable",
5
- props: {
6
- data: {
7
- type: Array,
8
- required: !0
9
- }
10
- },
11
- setup(E) {
12
- const V = E, b = W(), d = G([]);
13
- function k(r) {
14
- var t, o;
15
- const n = [];
16
- for (const e of r)
17
- if (e.type === P) {
18
- const s = {
19
- ...e.props,
20
- children: []
21
- }, c = (o = (t = e.children) == null ? void 0 : t.default) == null ? void 0 : o.call(t);
22
- c && c.length > 0 && (s.children = k(c)), n.push(s);
23
- }
24
- return n;
25
- }
26
- function $(r) {
27
- if (!r || r.length === 0) return 1;
28
- let n = 1;
29
- for (const t of r)
30
- if (t.children && t.children.length > 0) {
31
- const o = $(t.children);
32
- n = Math.max(n, 1 + o);
33
- }
34
- return n;
35
- }
36
- function B(r, n) {
37
- const t = Array.from({ length: n }, () => []);
38
- function o(e, s, c = "") {
39
- for (let i = 0; i < e.length; i++) {
40
- const l = e[i], h = c ? `${c}-${l.prop || i}` : l.prop || i;
41
- if (l.children && l.children.length > 0) {
42
- const a = L(l.children);
43
- t[s].push({
44
- key: h,
45
- label: l.label,
46
- colspan: a,
47
- rowspan: 1,
48
- width: l.width,
49
- height: l.height
50
- }), o(l.children, s + 1, h);
51
- } else
52
- t[s].push({
53
- key: l.prop,
54
- label: l.label,
55
- colspan: 1,
56
- rowspan: n - s,
57
- width: l.width,
58
- height: l.height,
59
- prop: l.prop
60
- });
61
- }
62
- }
63
- return o(r, 0), t;
64
- }
65
- function L(r) {
66
- let n = 0;
67
- function t(o) {
68
- for (const e of o)
69
- e.children && e.children.length > 0 ? t(e.children) : n++;
70
- }
71
- return t(r), n;
72
- }
73
- function N(r) {
74
- const n = [];
75
- function t(o) {
76
- for (const e of o)
77
- e.children && e.children.length > 0 ? t(e.children) : n.push(e);
78
- }
79
- return t(r), n;
80
- }
81
- function A(r, n) {
82
- const t = [], o = /* @__PURE__ */ new Map();
83
- return r.forEach((e, s) => {
84
- const c = [];
85
- n.forEach((i, l) => {
86
- var R;
87
- const h = `${s}-${i.prop}`;
88
- if (o.has(h))
89
- return;
90
- const a = e[i.prop];
91
- let D = a, _ = 1, v = 1, C = {};
92
- a && typeof a == "object" && a !== null && (D = a.label || a.value || "", _ = a.colspan || 1, v = a.rowspan || 1, C = a.style || {});
93
- const F = {
94
- key: h,
95
- label: D,
96
- prop: i.prop,
97
- colspan: _,
98
- rowspan: v,
99
- style: C,
100
- originalRow: e,
101
- rowIndex: s
102
- };
103
- c.push(F);
104
- for (let f = 0; f < v; f++)
105
- for (let y = 0; y < _; y++) {
106
- if (f === 0 && y === 0) continue;
107
- const M = `${s + f}-${(R = n[l + y]) == null ? void 0 : R.prop}`;
108
- M && o.set(M, !0);
109
- }
110
- }), c.length > 0 && t.push(c);
111
- }), t;
112
- }
113
- J(() => {
114
- var n;
115
- const r = ((n = b.default) == null ? void 0 : n.call(b)) || [];
116
- d.value = k(r);
117
- });
118
- const H = m(() => $(d.value)), j = m(() => B(d.value, H.value)), q = m(() => N(d.value)), z = m(() => A(V.data, q.value));
119
- return (r, n) => (u(), p("table", Q, [
120
- S("thead", null, [
121
- (u(!0), p(w, null, g(j.value, (t, o) => (u(), p("tr", { key: o }, [
122
- (u(!0), p(w, null, g(t, (e) => (u(), p("th", {
123
- key: e.key,
124
- colspan: e.colspan,
125
- rowspan: e.rowspan,
126
- style: T({ minWidth: e.width, minHeight: e.height })
127
- }, x(e.label), 13, U))), 128))
128
- ]))), 128))
129
- ]),
130
- S("tbody", null, [
131
- (u(!0), p(w, null, g(z.value, (t, o) => (u(), p("tr", { key: o }, [
132
- (u(!0), p(w, null, g(t, (e) => (u(), p("td", {
133
- key: e.key,
134
- colspan: e.colspan,
135
- rowspan: e.rowspan,
136
- style: T(e.style)
137
- }, [
138
- K(r.$slots, e.prop, {
139
- row: e.originalRow,
140
- $index: e.rowIndex
141
- }, () => [
142
- O(x(e.label), 1)
143
- ])
144
- ], 12, X))), 128))
145
- ]))), 128))
146
- ])
147
- ]));
148
- }
149
- };
150
- export {
151
- I as default
152
- };