intable 0.0.43 → 0.0.45
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.
- package/dist/index.d.ts +3 -2
- package/dist/index.js +34 -40
- package/dist/plugins/RenderPlugin/index.js +8 -12
- package/dist/test.d.ts +4 -0
- package/dist/test.js +40 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -114,16 +114,17 @@ export type THProps = {
|
|
|
114
114
|
colspan?: number;
|
|
115
115
|
style?: any;
|
|
116
116
|
};
|
|
117
|
-
|
|
117
|
+
interface TDProps {
|
|
118
118
|
x: number;
|
|
119
119
|
y: number;
|
|
120
120
|
data: any;
|
|
121
121
|
col: TableColumn;
|
|
122
122
|
value?: any;
|
|
123
|
+
onChange?: (v: any) => void;
|
|
123
124
|
children?: JSX.Element;
|
|
124
125
|
rowspan?: number;
|
|
125
126
|
colspan?: number;
|
|
126
|
-
}
|
|
127
|
+
}
|
|
127
128
|
type Obj = Record<string | symbol, any>;
|
|
128
129
|
export interface TableColumn extends Obj {
|
|
129
130
|
id: any;
|
package/dist/index.js
CHANGED
|
@@ -109,40 +109,44 @@ var THead = () => {
|
|
|
109
109
|
} });
|
|
110
110
|
} });
|
|
111
111
|
}, TBody = () => {
|
|
112
|
-
let { props: _ } = useContext(Ctx);
|
|
112
|
+
let { props: _, store: K } = useContext(Ctx);
|
|
113
113
|
return createComponent(_.Tbody, { get children() {
|
|
114
114
|
return createComponent(_.EachRows, {
|
|
115
115
|
get each() {
|
|
116
116
|
return _.data;
|
|
117
117
|
},
|
|
118
|
-
children: (
|
|
118
|
+
children: (q, J) => createComponent(_.Tr, {
|
|
119
119
|
get y() {
|
|
120
|
-
return
|
|
120
|
+
return J();
|
|
121
121
|
},
|
|
122
122
|
get data() {
|
|
123
|
-
return
|
|
123
|
+
return q();
|
|
124
124
|
},
|
|
125
125
|
get children() {
|
|
126
126
|
return createComponent(_.EachCells, {
|
|
127
127
|
get each() {
|
|
128
128
|
return _.columns;
|
|
129
129
|
},
|
|
130
|
-
children: (
|
|
130
|
+
children: (Y, X) => createComponent(_.Td, {
|
|
131
131
|
get col() {
|
|
132
|
-
return
|
|
132
|
+
return Y();
|
|
133
133
|
},
|
|
134
134
|
get x() {
|
|
135
|
-
return
|
|
135
|
+
return X();
|
|
136
136
|
},
|
|
137
137
|
get y() {
|
|
138
|
-
return
|
|
138
|
+
return J();
|
|
139
139
|
},
|
|
140
140
|
get data() {
|
|
141
|
-
return
|
|
141
|
+
return q();
|
|
142
142
|
},
|
|
143
143
|
get value() {
|
|
144
|
-
return
|
|
145
|
-
}
|
|
144
|
+
return q()[Y().id];
|
|
145
|
+
},
|
|
146
|
+
onChange: (_) => K.commands.rowChange({
|
|
147
|
+
...q(),
|
|
148
|
+
[Y().id]: _
|
|
149
|
+
})
|
|
146
150
|
})
|
|
147
151
|
});
|
|
148
152
|
}
|
|
@@ -153,7 +157,8 @@ var THead = () => {
|
|
|
153
157
|
function BasePlugin() {
|
|
154
158
|
let _ = {
|
|
155
159
|
col: null,
|
|
156
|
-
data: null
|
|
160
|
+
data: null,
|
|
161
|
+
onChange: null
|
|
157
162
|
}, K = (_) => (() => {
|
|
158
163
|
var K = _tmpl$();
|
|
159
164
|
return spread(K, _, !1, !1), K;
|
|
@@ -273,23 +278,19 @@ function BasePlugin() {
|
|
|
273
278
|
}), createComponent(_, q);
|
|
274
279
|
},
|
|
275
280
|
Th: ({ Th: _ = Q }, { store: K }) => (J) => {
|
|
276
|
-
let [Y, X] = createSignal(), { props: Z } = useContext(Ctx), Q = combineProps(J, {
|
|
277
|
-
|
|
278
|
-
return unFn(Z.cellClass, J);
|
|
279
|
-
},
|
|
280
|
-
get style() {
|
|
281
|
-
return unFn(Z.cellStyle, J);
|
|
282
|
-
}
|
|
283
|
-
}, {
|
|
281
|
+
let [Y, X] = createSignal(), { props: Z } = useContext(Ctx), Q = combineProps(J, {
|
|
282
|
+
ref: X,
|
|
284
283
|
get class() {
|
|
285
|
-
return J.col.class;
|
|
284
|
+
return [unFn(Z.cellClass, J), J.col.class].filter(Boolean).join(" ");
|
|
286
285
|
},
|
|
287
286
|
get style() {
|
|
288
|
-
return
|
|
287
|
+
return [
|
|
288
|
+
unFn(Z.cellStyle, J),
|
|
289
|
+
J.col.style,
|
|
290
|
+
J.col.width && `width: ${J.col.width}px; max-width: ${J.col.width}px`
|
|
291
|
+
].filter(Boolean).join(";");
|
|
289
292
|
}
|
|
290
|
-
}
|
|
291
|
-
return J.col.width ? `width: ${J.col.width}px; max-width: ${J.col.width}px` : "";
|
|
292
|
-
} });
|
|
293
|
+
});
|
|
293
294
|
return createEffect(() => {
|
|
294
295
|
if (J.covered || (J.colspan ?? 1) != 1) return;
|
|
295
296
|
let { x: _ } = J;
|
|
@@ -303,24 +304,17 @@ function BasePlugin() {
|
|
|
303
304
|
Td: ({ Td: _ = $ }, { store: K }) => (K) => {
|
|
304
305
|
let { props: J } = useContext(Ctx), Y = combineProps(K, {
|
|
305
306
|
get class() {
|
|
306
|
-
return unFn(J.cellClass, K);
|
|
307
|
+
return [unFn(J.cellClass, K), K.col.class].filter(Boolean).join(" ");
|
|
307
308
|
},
|
|
308
309
|
get style() {
|
|
309
|
-
return
|
|
310
|
+
return [
|
|
311
|
+
unFn(J.cellStyle, K),
|
|
312
|
+
K.col.style,
|
|
313
|
+
K.col.width && `width: ${K.col.width}px; max-width: ${K.col.width}px`
|
|
314
|
+
].filter(Boolean).join(";");
|
|
310
315
|
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
return K.col.class;
|
|
314
|
-
},
|
|
315
|
-
get style() {
|
|
316
|
-
return K.col.style;
|
|
317
|
-
}
|
|
318
|
-
}, { get style() {
|
|
319
|
-
return K.col.width ? `width: ${K.col.width}px; max-width: ${K.col.width}px` : "";
|
|
320
|
-
} });
|
|
321
|
-
return createComponent(_, mergeProps(Y, { get children() {
|
|
322
|
-
return K.children;
|
|
323
|
-
} }));
|
|
316
|
+
});
|
|
317
|
+
return createComponent(_, Y);
|
|
324
318
|
},
|
|
325
319
|
EachRows: ({ EachRows: _ }) => _ || ((_) => createComponent(For, {
|
|
326
320
|
get each() {
|
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
import { renderComponent, solidComponent } from "../../components/utils.js";
|
|
2
2
|
import { resolveOptions, toArr } from "../../utils.js";
|
|
3
3
|
import { Checkbox, Files } from "./components.js";
|
|
4
|
-
import { createComponent, insert,
|
|
5
|
-
import { mergeProps as mergeProps$1 } from "solid-js";
|
|
4
|
+
import { createComponent, insert, mergeProps, template } from "solid-js/web";
|
|
6
5
|
var _tmpl$ = /* @__PURE__ */ template("<div class=\"flex items-center h-full\">");
|
|
7
6
|
const RenderPlugin = {
|
|
8
7
|
name: "render",
|
|
9
8
|
priority: -Infinity,
|
|
10
9
|
store: () => ({ renders: { ...renders } }),
|
|
11
|
-
rewriteProps: { Td: ({ Td:
|
|
10
|
+
rewriteProps: { Td: ({ Td: d }, { store: f }) => (p) => createComponent(d, mergeProps(p, { get children() {
|
|
12
11
|
return (() => {
|
|
13
|
-
let
|
|
14
|
-
return renderComponent(
|
|
15
|
-
...h.data,
|
|
16
|
-
[h.col.id]: e
|
|
17
|
-
}) }), m);
|
|
12
|
+
let d = ((e) => typeof e == "string" ? f.renders[e] : e)(p.col.render ?? p.col.type);
|
|
13
|
+
return d ? renderComponent(d, p, f) : text(p);
|
|
18
14
|
})();
|
|
19
15
|
} })) }
|
|
20
16
|
};
|
|
21
|
-
var text = (e) =>
|
|
17
|
+
var text = (e) => e.col.enum ? toArr(e.value).map((d) => resolveOptions(e.col.enum).find((e) => e.value == d)?.label ?? d).join(", ") : e.value;
|
|
22
18
|
const renders = {
|
|
23
19
|
text,
|
|
24
20
|
number: text,
|
|
25
21
|
date: text,
|
|
26
22
|
checkbox: (e) => (() => {
|
|
27
|
-
var
|
|
28
|
-
return insert(
|
|
23
|
+
var d = _tmpl$();
|
|
24
|
+
return insert(d, createComponent(Checkbox, {
|
|
29
25
|
class: "",
|
|
30
26
|
get value() {
|
|
31
27
|
return e.value;
|
|
@@ -33,7 +29,7 @@ const renders = {
|
|
|
33
29
|
get onChange() {
|
|
34
30
|
return e.onChange;
|
|
35
31
|
}
|
|
36
|
-
})),
|
|
32
|
+
})), d;
|
|
37
33
|
})(),
|
|
38
34
|
file: (e) => createComponent(Files, {
|
|
39
35
|
get value() {
|
package/dist/test.d.ts
ADDED
package/dist/test.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import './style.css';import './__uno.css';/* empty css */
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { createComponent, effect, insert, setAttribute, template } from "solid-js/web";
|
|
4
|
+
import { For } from "solid-js";
|
|
5
|
+
var _tmpl$ = /* @__PURE__ */ template("<table><thead><tr></tr></thead><thead>"), _tmpl$2 = /* @__PURE__ */ template("<th>"), _tmpl$3 = /* @__PURE__ */ template("<tr>"), _tmpl$4 = /* @__PURE__ */ template("<td>");
|
|
6
|
+
const TestTable = (o) => (() => {
|
|
7
|
+
var u = _tmpl$(), d = u.firstChild, f = d.firstChild, p = d.nextSibling;
|
|
8
|
+
return insert(f, createComponent(For, {
|
|
9
|
+
get each() {
|
|
10
|
+
return o.columns;
|
|
11
|
+
},
|
|
12
|
+
children: (e) => (() => {
|
|
13
|
+
var i = _tmpl$2();
|
|
14
|
+
return insert(i, () => e.name), i;
|
|
15
|
+
})()
|
|
16
|
+
})), insert(p, createComponent(For, {
|
|
17
|
+
get each() {
|
|
18
|
+
return o.data;
|
|
19
|
+
},
|
|
20
|
+
children: (c, l) => (() => {
|
|
21
|
+
var u = _tmpl$3();
|
|
22
|
+
return setAttribute(u, "data", c), insert(u, createComponent(For, {
|
|
23
|
+
get each() {
|
|
24
|
+
return o.columns;
|
|
25
|
+
},
|
|
26
|
+
children: (e, o) => (() => {
|
|
27
|
+
var s = _tmpl$4();
|
|
28
|
+
return setAttribute(s, "data", c), insert(s, () => c[e.id]), effect((e) => {
|
|
29
|
+
var i = o(), a = l();
|
|
30
|
+
return i !== e.e && setAttribute(s, "x", e.e = i), a !== e.t && setAttribute(s, "y", e.t = a), e;
|
|
31
|
+
}, {
|
|
32
|
+
e: void 0,
|
|
33
|
+
t: void 0
|
|
34
|
+
}), s;
|
|
35
|
+
})()
|
|
36
|
+
})), effect(() => setAttribute(u, "y", l())), u;
|
|
37
|
+
})()
|
|
38
|
+
})), u;
|
|
39
|
+
})();
|
|
40
|
+
export { TestTable };
|