angel-table 0.0.0-stage → 0.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.
- package/README.md +368 -2
- package/dist/angel-table.css +2 -0
- package/dist/angel-table.js +919 -0
- package/dist/angel-table.umd.cjs +5 -0
- package/dist/lib/Table/Table.d.ts +2 -0
- package/dist/lib/Table/components/Select.d.ts +3 -0
- package/dist/lib/Table/components/SelectCheck.d.ts +3 -0
- package/dist/lib/Table/components/Sort.d.ts +3 -0
- package/dist/lib/Table/hook/useAngelCheck.d.ts +19 -0
- package/dist/lib/Table/hook/useAngelColumn.d.ts +33 -0
- package/dist/lib/Table/hook/useAngelData.d.ts +40 -0
- package/dist/lib/Table/hook/useAngelFilterSerchSort.d.ts +21 -0
- package/dist/lib/Table/hook/useAngelPagination.d.ts +17 -0
- package/dist/lib/Table/type.d.ts +83 -0
- package/dist/lib/main.d.ts +1 -0
- package/dist/src/App.d.ts +2 -0
- package/dist/src/main.d.ts +0 -0
- package/dist/src/utils/createFilter.d.ts +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/package.json +42 -4
|
@@ -0,0 +1,919 @@
|
|
|
1
|
+
import { Fragment as e, memo as t, useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
3
|
+
// \0rolldown/runtime.js
|
|
4
|
+
var u = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), d = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
5
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
6
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
7
|
+
}), f = /* @__PURE__ */ u(((e) => {
|
|
8
|
+
var t = d("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
9
|
+
e.c = function(e) {
|
|
10
|
+
return t.H.useMemoCache(e);
|
|
11
|
+
};
|
|
12
|
+
})), p = /* @__PURE__ */ u(((e) => {
|
|
13
|
+
process.env.NODE_ENV !== "production" && (function() {
|
|
14
|
+
var t = d("react").__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
15
|
+
e.c = function(e) {
|
|
16
|
+
var n = t.H;
|
|
17
|
+
return n === null && console.error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."), n.useMemoCache(e);
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
})), m = (/* @__PURE__ */ u(((e, t) => {
|
|
21
|
+
t.exports = process.env.NODE_ENV === "production" ? f() : p();
|
|
22
|
+
})))(), h = (e) => {
|
|
23
|
+
let t = (0, m.c)(26), { value: n, options: i, noLabel: a, title: s, onChange: u, direction: d } = e, f = n === void 0 ? "" : n, p = a !== void 0 && a, h = d === void 0 ? "bottom" : d, [g, _] = o(!1), [v, y] = o(s), [b, x] = o(f), S;
|
|
24
|
+
t[0] !== s || t[1] !== f ? (S = () => {
|
|
25
|
+
(f === void 0 || f === "") && y(s);
|
|
26
|
+
}, t[0] = s, t[1] = f, t[2] = S) : S = t[2];
|
|
27
|
+
let C;
|
|
28
|
+
t[3] === f ? C = t[4] : (C = [f], t[3] = f, t[4] = C), r(S, C);
|
|
29
|
+
let w;
|
|
30
|
+
t[5] === Symbol.for("react.memo_cache_sentinel") ? (w = (e) => {
|
|
31
|
+
e.currentTarget.contains(e.relatedTarget) || _(!1);
|
|
32
|
+
}, t[5] = w) : w = t[5];
|
|
33
|
+
let T = `angel-table__dropdown ${g ? "is-open" : ""}`, E;
|
|
34
|
+
t[6] === g ? E = t[7] : (E = () => _(!g), t[6] = g, t[7] = E);
|
|
35
|
+
let D;
|
|
36
|
+
t[8] === v ? D = t[9] : (D = /* @__PURE__ */ c("span", { children: v }), t[8] = v, t[9] = D);
|
|
37
|
+
let O;
|
|
38
|
+
t[10] === Symbol.for("react.memo_cache_sentinel") ? (O = /* @__PURE__ */ c("svg", {
|
|
39
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
40
|
+
width: "10",
|
|
41
|
+
height: "10",
|
|
42
|
+
fill: "currentColor",
|
|
43
|
+
viewBox: "0 0 16 16",
|
|
44
|
+
className: "angel-table__dropdown-arrow",
|
|
45
|
+
children: /* @__PURE__ */ c("path", {
|
|
46
|
+
fillRule: "evenodd",
|
|
47
|
+
d: "M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708"
|
|
48
|
+
})
|
|
49
|
+
}), t[10] = O) : O = t[10];
|
|
50
|
+
let k;
|
|
51
|
+
t[11] !== E || t[12] !== D ? (k = /* @__PURE__ */ l("button", {
|
|
52
|
+
onClick: E,
|
|
53
|
+
className: "angel-table__button angel-table__button--secondary angel-table__dropdown-trigger",
|
|
54
|
+
children: [D, O]
|
|
55
|
+
}), t[11] = E, t[12] = D, t[13] = k) : k = t[13];
|
|
56
|
+
let A;
|
|
57
|
+
t[14] !== p || t[15] !== u || t[16] !== i || t[17] !== g || t[18] !== s || t[19] !== b ? (A = g && /* @__PURE__ */ l("div", {
|
|
58
|
+
className: "angel-table__dropdown-menu",
|
|
59
|
+
children: [!p && /* @__PURE__ */ c("button", {
|
|
60
|
+
type: "button",
|
|
61
|
+
onClick: () => {
|
|
62
|
+
x(""), y(s), u && u(""), _(!1);
|
|
63
|
+
},
|
|
64
|
+
className: `angel-table__dropdown-item ${b === "" ? "active" : ""}`,
|
|
65
|
+
children: s
|
|
66
|
+
}), i.map((e) => /* @__PURE__ */ c("button", {
|
|
67
|
+
type: "button",
|
|
68
|
+
onClick: () => {
|
|
69
|
+
x(e.value + ""), y(e.title), u && u(e.value), _(!1);
|
|
70
|
+
},
|
|
71
|
+
className: `angel-table__dropdown-item ${e.value + "" === b ? "active" : ""}`,
|
|
72
|
+
children: e.title
|
|
73
|
+
}, e.value))]
|
|
74
|
+
}), t[14] = p, t[15] = u, t[16] = i, t[17] = g, t[18] = s, t[19] = b, t[20] = A) : A = t[20];
|
|
75
|
+
let j;
|
|
76
|
+
return t[21] !== h || t[22] !== k || t[23] !== A || t[24] !== T ? (j = /* @__PURE__ */ l("div", {
|
|
77
|
+
onBlur: w,
|
|
78
|
+
"data-direction": h,
|
|
79
|
+
className: T,
|
|
80
|
+
children: [k, A]
|
|
81
|
+
}), t[21] = h, t[22] = k, t[23] = A, t[24] = T, t[25] = j) : j = t[25], j;
|
|
82
|
+
}, g = t((e) => {
|
|
83
|
+
let t = (0, m.c)(15), { options: n, onChange: r, direction: i } = e, a = i === void 0 ? "bottom" : i, [s, u] = o(!1), [d, f] = o(n), p;
|
|
84
|
+
t[0] === Symbol.for("react.memo_cache_sentinel") ? (p = (e) => {
|
|
85
|
+
e.currentTarget.contains(e.relatedTarget) || u(!1);
|
|
86
|
+
}, t[0] = p) : p = t[0];
|
|
87
|
+
let h = `angel-table__dropdown ${s ? "is-open" : ""}`, g;
|
|
88
|
+
t[1] === s ? g = t[2] : (g = () => u(!s), t[1] = s, t[2] = g);
|
|
89
|
+
let v;
|
|
90
|
+
t[3] === Symbol.for("react.memo_cache_sentinel") ? (v = /* @__PURE__ */ l("svg", {
|
|
91
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
92
|
+
width: "16",
|
|
93
|
+
height: "16",
|
|
94
|
+
fill: "currentColor",
|
|
95
|
+
viewBox: "0 0 16 16",
|
|
96
|
+
children: [/* @__PURE__ */ c("path", { d: "M2 2a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1zm12-1a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2z" }), /* @__PURE__ */ c("path", { d: "M13 4a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1z" })]
|
|
97
|
+
}), t[3] = v) : v = t[3];
|
|
98
|
+
let y;
|
|
99
|
+
t[4] === g ? y = t[5] : (y = /* @__PURE__ */ c("button", {
|
|
100
|
+
onClick: g,
|
|
101
|
+
className: "angel-table__button angel-table__button--secondary ",
|
|
102
|
+
children: v
|
|
103
|
+
}), t[4] = g, t[5] = y);
|
|
104
|
+
let b;
|
|
105
|
+
t[6] !== r || t[7] !== d || t[8] !== s ? (b = s && /* @__PURE__ */ c("div", {
|
|
106
|
+
className: "angel-table__dropdown-menu",
|
|
107
|
+
children: d.map((e, t) => /* @__PURE__ */ l("button", {
|
|
108
|
+
type: "button",
|
|
109
|
+
onClick: () => {
|
|
110
|
+
let e = d.map((e, n) => ({
|
|
111
|
+
...e,
|
|
112
|
+
show: n === t ? !e.show : e.show
|
|
113
|
+
}));
|
|
114
|
+
e.filter(_).length > 1 && (r?.(t), f(e));
|
|
115
|
+
},
|
|
116
|
+
className: "angel-table__dropdown-item angel-table__button",
|
|
117
|
+
children: [e.show ? /* @__PURE__ */ c("svg", {
|
|
118
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
119
|
+
width: "16",
|
|
120
|
+
height: "16",
|
|
121
|
+
fill: "blue",
|
|
122
|
+
className: " selected",
|
|
123
|
+
viewBox: "0 0 16 16",
|
|
124
|
+
children: /* @__PURE__ */ c("path", { d: "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" })
|
|
125
|
+
}) : /* @__PURE__ */ l("svg", {
|
|
126
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
127
|
+
width: "16",
|
|
128
|
+
height: "16",
|
|
129
|
+
fill: "currentColor",
|
|
130
|
+
className: "not-selected",
|
|
131
|
+
viewBox: "0 0 16 16",
|
|
132
|
+
children: [/* @__PURE__ */ c("path", { d: "M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16" }), /* @__PURE__ */ c("path", { d: "m10.97 4.97-.02.022-3.473 4.425-2.093-2.094a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05" })]
|
|
133
|
+
}), /* @__PURE__ */ c("p", { children: e.title })]
|
|
134
|
+
}, e.value))
|
|
135
|
+
}), t[6] = r, t[7] = d, t[8] = s, t[9] = b) : b = t[9];
|
|
136
|
+
let x;
|
|
137
|
+
return t[10] !== a || t[11] !== h || t[12] !== y || t[13] !== b ? (x = /* @__PURE__ */ l("div", {
|
|
138
|
+
onBlur: p,
|
|
139
|
+
"data-direction": a,
|
|
140
|
+
className: h,
|
|
141
|
+
children: [y, b]
|
|
142
|
+
}), t[10] = a, t[11] = h, t[12] = y, t[13] = b, t[14] = x) : x = t[14], x;
|
|
143
|
+
});
|
|
144
|
+
function _(e) {
|
|
145
|
+
return e.show;
|
|
146
|
+
}
|
|
147
|
+
// lib/Table/hook/useAngelPagination.ts
|
|
148
|
+
function v(e) {
|
|
149
|
+
let t = (0, m.c)(9), n;
|
|
150
|
+
t[0] === e ? n = t[1] : (n = e === void 0 ? {} : e, t[0] = e, t[1] = n);
|
|
151
|
+
let { pageOption: r, perPageOption: i } = n, a = r === void 0 ? 1 : r, s = i === void 0 ? 10 : i, [c, l] = o(a), [u, d] = o(0), [f, p] = o(s), h;
|
|
152
|
+
t[2] !== c || t[3] !== f || t[4] !== u ? (h = {
|
|
153
|
+
page: c,
|
|
154
|
+
perPage: f,
|
|
155
|
+
totalPage: u
|
|
156
|
+
}, t[2] = c, t[3] = f, t[4] = u, t[5] = h) : h = t[5];
|
|
157
|
+
let g;
|
|
158
|
+
t[6] === Symbol.for("react.memo_cache_sentinel") ? (g = {
|
|
159
|
+
setPage: l,
|
|
160
|
+
setPerPage: p,
|
|
161
|
+
setTotalPage: d
|
|
162
|
+
}, t[6] = g) : g = t[6];
|
|
163
|
+
let _;
|
|
164
|
+
return t[7] === h ? _ = t[8] : (_ = {
|
|
165
|
+
data: h,
|
|
166
|
+
handle: g
|
|
167
|
+
}, t[7] = h, t[8] = _), _;
|
|
168
|
+
}
|
|
169
|
+
// lib/Table/hook/useAngelFilterSerchSort.ts
|
|
170
|
+
function y() {
|
|
171
|
+
let e = (0, m.c)(14), t;
|
|
172
|
+
e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = {}, e[0] = t) : t = e[0];
|
|
173
|
+
let [n, i] = o(t), [a, s] = o(""), [c, l] = o(""), u;
|
|
174
|
+
e[1] === Symbol.for("react.memo_cache_sentinel") ? (u = {
|
|
175
|
+
field: "",
|
|
176
|
+
direction: "asc"
|
|
177
|
+
}, e[1] = u) : u = e[1];
|
|
178
|
+
let [d, f] = o(u), p;
|
|
179
|
+
e[2] === Symbol.for("react.memo_cache_sentinel") ? (p = (e) => {
|
|
180
|
+
f((t) => ({
|
|
181
|
+
field: e,
|
|
182
|
+
direction: t.field === e && t.direction === "asc" ? "desc" : "asc"
|
|
183
|
+
}));
|
|
184
|
+
}, e[2] = p) : p = e[2];
|
|
185
|
+
let h = p, g, _;
|
|
186
|
+
e[3] === a ? (g = e[4], _ = e[5]) : (g = () => {
|
|
187
|
+
let e = setTimeout(() => {
|
|
188
|
+
l(a);
|
|
189
|
+
}, 500);
|
|
190
|
+
return () => clearTimeout(e);
|
|
191
|
+
}, _ = [a], e[3] = a, e[4] = g, e[5] = _), r(g, _);
|
|
192
|
+
let v;
|
|
193
|
+
e[6] !== c || e[7] !== n || e[8] !== a || e[9] !== d ? (v = {
|
|
194
|
+
filter: n,
|
|
195
|
+
search: a,
|
|
196
|
+
debouncedSearch: c,
|
|
197
|
+
sort: d
|
|
198
|
+
}, e[6] = c, e[7] = n, e[8] = a, e[9] = d, e[10] = v) : v = e[10];
|
|
199
|
+
let y;
|
|
200
|
+
e[11] === Symbol.for("react.memo_cache_sentinel") ? (y = {
|
|
201
|
+
setFilter: i,
|
|
202
|
+
setSearch: s,
|
|
203
|
+
setSort: f,
|
|
204
|
+
setDebouncedSearch: l,
|
|
205
|
+
handleSort: h
|
|
206
|
+
}, e[11] = y) : y = e[11];
|
|
207
|
+
let b;
|
|
208
|
+
return e[12] === v ? b = e[13] : (b = {
|
|
209
|
+
data: v,
|
|
210
|
+
handle: y
|
|
211
|
+
}, e[12] = v, e[13] = b), b;
|
|
212
|
+
}
|
|
213
|
+
// lib/Table/hook/useAngelCheck.ts
|
|
214
|
+
function b({ rowData: e, keyObject: t, is_select: r, selectedItem: a }) {
|
|
215
|
+
let [s, c] = o({}), { checkAll: l, selectedCount: u } = i(() => {
|
|
216
|
+
let n = e.filter((e) => s[String(e[t])]).length;
|
|
217
|
+
if (r && a) {
|
|
218
|
+
a(e);
|
|
219
|
+
let t = [];
|
|
220
|
+
for (let e in s) t.push(e);
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
checkAll: e.length > 0 && n === e.length,
|
|
224
|
+
selectedCount: n
|
|
225
|
+
};
|
|
226
|
+
}, [
|
|
227
|
+
s,
|
|
228
|
+
e,
|
|
229
|
+
t
|
|
230
|
+
]), d = n(() => {
|
|
231
|
+
let n = {};
|
|
232
|
+
e.forEach((e) => {
|
|
233
|
+
n[String(e[t])] = !l;
|
|
234
|
+
}), c(n);
|
|
235
|
+
}, [e]);
|
|
236
|
+
return {
|
|
237
|
+
handle: {
|
|
238
|
+
handleCheck: n((e) => {
|
|
239
|
+
let n = String(e[t]);
|
|
240
|
+
c((e) => ({
|
|
241
|
+
...e,
|
|
242
|
+
[n]: !e[n]
|
|
243
|
+
}));
|
|
244
|
+
}, []),
|
|
245
|
+
handleCheckAll: d,
|
|
246
|
+
setCheckedId: c
|
|
247
|
+
},
|
|
248
|
+
data: {
|
|
249
|
+
selectedCount: u,
|
|
250
|
+
checkedId: s,
|
|
251
|
+
checkAll: l
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
// lib/Table/hook/useAngelData.ts
|
|
256
|
+
function x(e) {
|
|
257
|
+
let t = new URLSearchParams();
|
|
258
|
+
return Object.entries(e).forEach(([e, n]) => {
|
|
259
|
+
n !== "" && t.set(e, n);
|
|
260
|
+
}), t;
|
|
261
|
+
}
|
|
262
|
+
function S({ rows: e = [], setup: t = {} }) {
|
|
263
|
+
let { url: i = "", viewDefault: s = "table", angelFetch: c, keyObject: l = "id", is_select: u = !1, selectedItem: d } = t, { data: { page: f, perPage: p, totalPage: m }, handle: { setPage: h, setPerPage: g, setTotalPage: _ } } = v(), { data: { debouncedSearch: S, filter: C, search: w, sort: T }, handle: { handleSort: E, setFilter: D, setSearch: O, setSort: k, setDebouncedSearch: A } } = y(), { data: { checkedId: j, selectedCount: M, checkAll: N }, handle: { handleCheck: P, handleCheckAll: F, setCheckedId: I } } = b({
|
|
264
|
+
is_select: u,
|
|
265
|
+
keyObject: l,
|
|
266
|
+
rowData: e,
|
|
267
|
+
selectedItem: d
|
|
268
|
+
}), [L, R] = o(e), [z, B] = o(!1), [V, H] = o(s), U = a(null), W = n(() => {
|
|
269
|
+
D({}), h(1), O(""), A(""), k({
|
|
270
|
+
direction: "asc",
|
|
271
|
+
field: ""
|
|
272
|
+
});
|
|
273
|
+
}, []);
|
|
274
|
+
return r(() => {
|
|
275
|
+
let e = new AbortController(), t = AbortSignal.timeout(5e3);
|
|
276
|
+
return (async () => {
|
|
277
|
+
B(!0);
|
|
278
|
+
try {
|
|
279
|
+
let n = x(C);
|
|
280
|
+
n.set("page", String(f)), n.set("perPage", String(p)), S.trim() !== "" && n.set("search", S.trim()), T.field && (n.set("field", T.field), n.set("direction", T.direction));
|
|
281
|
+
let r = i.includes("?") ? "&" : "?", a = `${i}${r}${n.toString()}`;
|
|
282
|
+
if (c) {
|
|
283
|
+
let e = await c(a);
|
|
284
|
+
R(e.data ?? []), _(Math.max(1, Number(e.totalPage ?? 1))), I({});
|
|
285
|
+
} else {
|
|
286
|
+
let n = await fetch(a, {
|
|
287
|
+
method: "GET",
|
|
288
|
+
signal: AbortSignal.any([e.signal, t])
|
|
289
|
+
});
|
|
290
|
+
if (!n.ok) throw Error(`Request failed: ${n.status}`);
|
|
291
|
+
let r = await n.json();
|
|
292
|
+
if (e.signal.aborted) return;
|
|
293
|
+
R(r.data ?? []), _(Math.max(1, Number(r.totalPage ?? 1))), I({});
|
|
294
|
+
}
|
|
295
|
+
U.current?.scrollIntoView({
|
|
296
|
+
behavior: "smooth",
|
|
297
|
+
block: "start"
|
|
298
|
+
});
|
|
299
|
+
} catch (e) {
|
|
300
|
+
if (e instanceof Error && e.name === "AbortError") return;
|
|
301
|
+
R([]), _(1);
|
|
302
|
+
} finally {
|
|
303
|
+
e.signal.aborted || B(!1);
|
|
304
|
+
}
|
|
305
|
+
})(), () => e.abort();
|
|
306
|
+
}, [
|
|
307
|
+
C,
|
|
308
|
+
f,
|
|
309
|
+
p,
|
|
310
|
+
i,
|
|
311
|
+
S,
|
|
312
|
+
T
|
|
313
|
+
]), {
|
|
314
|
+
data: {
|
|
315
|
+
page: f,
|
|
316
|
+
perPage: p,
|
|
317
|
+
totalPage: m,
|
|
318
|
+
debouncedSearch: S,
|
|
319
|
+
filter: C,
|
|
320
|
+
search: w,
|
|
321
|
+
sort: T,
|
|
322
|
+
checkedId: j,
|
|
323
|
+
selectedCount: M,
|
|
324
|
+
rowData: L,
|
|
325
|
+
view: V,
|
|
326
|
+
loading: z,
|
|
327
|
+
targetRef: U,
|
|
328
|
+
checkAll: N
|
|
329
|
+
},
|
|
330
|
+
handle: {
|
|
331
|
+
setPage: h,
|
|
332
|
+
setPerPage: g,
|
|
333
|
+
setTotalPage: _,
|
|
334
|
+
handleResetFilter: W,
|
|
335
|
+
handleSort: E,
|
|
336
|
+
setFilter: D,
|
|
337
|
+
setSearch: O,
|
|
338
|
+
setSort: k,
|
|
339
|
+
handleCheck: P,
|
|
340
|
+
handleCheckAll: F,
|
|
341
|
+
setCheckedId: I,
|
|
342
|
+
setRowData: R,
|
|
343
|
+
setView: H
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
// lib/Table/hook/useAngelColumn.ts
|
|
348
|
+
function C(e) {
|
|
349
|
+
let t = (0, m.c)(4), { columns: n } = e, r;
|
|
350
|
+
t[0] === n ? r = t[1] : (r = [...n.map(w)], t[0] = n, t[1] = r);
|
|
351
|
+
let [i, a] = o(r), s;
|
|
352
|
+
return t[2] === i ? s = t[3] : (s = {
|
|
353
|
+
setShowColumm: a,
|
|
354
|
+
showColumm: i
|
|
355
|
+
}, t[2] = i, t[3] = s), s;
|
|
356
|
+
}
|
|
357
|
+
function w(e) {
|
|
358
|
+
return {
|
|
359
|
+
...e,
|
|
360
|
+
show: !0
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
// lib/Table/components/Sort.tsx
|
|
364
|
+
var T = (t) => {
|
|
365
|
+
let n = (0, m.c)(20), { columns: i, field: a, sortDirection: s, onSort: u } = t, [d, f] = o(!1), [p, h] = o(a), [g, _] = o(s), v;
|
|
366
|
+
n[0] === i ? v = n[1] : (v = i.filter(E), n[0] = i, n[1] = v);
|
|
367
|
+
let y = v, b, x;
|
|
368
|
+
n[2] === a ? (b = n[3], x = n[4]) : (b = () => (h(a), D), x = [a], n[2] = a, n[3] = b, n[4] = x), r(b, x);
|
|
369
|
+
let S;
|
|
370
|
+
n[5] === Symbol.for("react.memo_cache_sentinel") ? (S = (e) => {
|
|
371
|
+
e.currentTarget.contains(e.relatedTarget) || f(!1);
|
|
372
|
+
}, n[5] = S) : S = n[5];
|
|
373
|
+
let C;
|
|
374
|
+
n[6] === d ? C = n[7] : (C = () => f(!d), n[6] = d, n[7] = C);
|
|
375
|
+
let w;
|
|
376
|
+
n[8] === Symbol.for("react.memo_cache_sentinel") ? (w = /* @__PURE__ */ c("svg", {
|
|
377
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
378
|
+
width: "16",
|
|
379
|
+
height: "16",
|
|
380
|
+
fill: "currentColor",
|
|
381
|
+
viewBox: "0 0 16 16",
|
|
382
|
+
children: /* @__PURE__ */ c("path", {
|
|
383
|
+
fillRule: "evenodd",
|
|
384
|
+
d: "M11.5 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L11 2.707V14.5a.5.5 0 0 0 .5.5m-7-14a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L4 13.293V1.5a.5.5 0 0 1 .5-.5"
|
|
385
|
+
})
|
|
386
|
+
}), n[8] = w) : w = n[8];
|
|
387
|
+
let T;
|
|
388
|
+
n[9] === C ? T = n[10] : (T = /* @__PURE__ */ c("button", {
|
|
389
|
+
onClick: C,
|
|
390
|
+
className: "angel-table__button angel-table__button--secondary ",
|
|
391
|
+
children: w
|
|
392
|
+
}), n[9] = C, n[10] = T);
|
|
393
|
+
let O;
|
|
394
|
+
n[11] !== d || n[12] !== u || n[13] !== p || n[14] !== g || n[15] !== y ? (O = d && /* @__PURE__ */ l("div", {
|
|
395
|
+
className: "angel-table__dropdown-menu",
|
|
396
|
+
children: [
|
|
397
|
+
y.map((e) => /* @__PURE__ */ c("button", {
|
|
398
|
+
type: "button",
|
|
399
|
+
onClick: () => {
|
|
400
|
+
(g !== "asc" || e.field !== p) && (h(e.field), _("asc"), u && u({
|
|
401
|
+
field: e.field,
|
|
402
|
+
sortDirection: "asc"
|
|
403
|
+
}));
|
|
404
|
+
},
|
|
405
|
+
className: `angel-table__dropdown-item angel-table__button ${p === e.field ? "active" : ""}`,
|
|
406
|
+
children: /* @__PURE__ */ l("p", { children: [" ", e.title] })
|
|
407
|
+
}, e.field)),
|
|
408
|
+
/* @__PURE__ */ c("hr", {}),
|
|
409
|
+
y.filter((e) => e.field === p).map((t) => /* @__PURE__ */ l(e, { children: [/* @__PURE__ */ l("button", {
|
|
410
|
+
onClick: () => {
|
|
411
|
+
_("asc"), u && u({
|
|
412
|
+
field: t.field,
|
|
413
|
+
sortDirection: "asc"
|
|
414
|
+
});
|
|
415
|
+
},
|
|
416
|
+
className: `angel-table__dropdown-item angel-table__button ${g === "asc" ? "active" : ""}`,
|
|
417
|
+
children: [/* @__PURE__ */ c("svg", {
|
|
418
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
419
|
+
width: "16",
|
|
420
|
+
height: "16",
|
|
421
|
+
fill: "currentColor",
|
|
422
|
+
className: "bi bi-arrow-up",
|
|
423
|
+
viewBox: "0 0 16 16",
|
|
424
|
+
children: /* @__PURE__ */ c("path", {
|
|
425
|
+
fillRule: "evenodd",
|
|
426
|
+
d: "M8 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L7.5 2.707V14.5a.5.5 0 0 0 .5.5"
|
|
427
|
+
})
|
|
428
|
+
}), /* @__PURE__ */ c("p", { children: t.sortLabel?.ascLabel ?? "Ascending" })]
|
|
429
|
+
}), /* @__PURE__ */ l("button", {
|
|
430
|
+
onClick: () => {
|
|
431
|
+
_("desc"), u && u({
|
|
432
|
+
field: t.field,
|
|
433
|
+
sortDirection: "desc"
|
|
434
|
+
});
|
|
435
|
+
},
|
|
436
|
+
className: `angel-table__dropdown-item angel-table__button ${g === "desc" ? "active" : ""}`,
|
|
437
|
+
children: [/* @__PURE__ */ c("svg", {
|
|
438
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
439
|
+
width: "16",
|
|
440
|
+
height: "16",
|
|
441
|
+
fill: "currentColor",
|
|
442
|
+
viewBox: "0 0 16 16",
|
|
443
|
+
children: /* @__PURE__ */ c("path", {
|
|
444
|
+
fillRule: "evenodd",
|
|
445
|
+
d: "M8 1a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L7.5 13.293V1.5A.5.5 0 0 1 8 1"
|
|
446
|
+
})
|
|
447
|
+
}), /* @__PURE__ */ c("p", { children: t.sortLabel?.descLabel ?? "Descending" })]
|
|
448
|
+
})] }, t.field))
|
|
449
|
+
]
|
|
450
|
+
}), n[11] = d, n[12] = u, n[13] = p, n[14] = g, n[15] = y, n[16] = O) : O = n[16];
|
|
451
|
+
let k;
|
|
452
|
+
return n[17] !== T || n[18] !== O ? (k = /* @__PURE__ */ l("div", {
|
|
453
|
+
onBlur: S,
|
|
454
|
+
"data-direction": "bottom",
|
|
455
|
+
className: "angel-table__dropdown ",
|
|
456
|
+
children: [T, O]
|
|
457
|
+
}), n[17] = T, n[18] = O, n[19] = k) : k = n[19], k;
|
|
458
|
+
};
|
|
459
|
+
function E(e) {
|
|
460
|
+
return e.sort && e.show;
|
|
461
|
+
}
|
|
462
|
+
function D() {}
|
|
463
|
+
// lib/Table/Table.tsx
|
|
464
|
+
var O = (t) => {
|
|
465
|
+
let { columns: r, card: a, className: o, empty: u, perPages: d, selector: f, setup: p } = i(() => {
|
|
466
|
+
let { columns: e, card: n, className: r, empty: i, perPages: a = [
|
|
467
|
+
10,
|
|
468
|
+
15,
|
|
469
|
+
20
|
|
470
|
+
], rows: o, selector: s, setup: c = {} } = t;
|
|
471
|
+
return {
|
|
472
|
+
columns: e,
|
|
473
|
+
card: n,
|
|
474
|
+
className: r,
|
|
475
|
+
empty: i,
|
|
476
|
+
perPages: a,
|
|
477
|
+
rows: o,
|
|
478
|
+
selector: s,
|
|
479
|
+
setup: c
|
|
480
|
+
};
|
|
481
|
+
}, [t]), { keyObject: m = "id", contentPage: _ = "Page", mode: v = "light", selectedRender: y = (e) => /* @__PURE__ */ l("span", { children: [
|
|
482
|
+
"Selected: ",
|
|
483
|
+
/* @__PURE__ */ c("strong", { children: e }),
|
|
484
|
+
" items"
|
|
485
|
+
] }), is_select: b = !1, showColumns: x } = i(() => p, [p]), { data: { checkedId: w, filter: E, loading: D, page: O, perPage: k, rowData: A, search: j, selectedCount: M, sort: N, totalPage: P, view: F, targetRef: I, checkAll: L }, handle: { handleCheck: R, handleCheckAll: z, handleResetFilter: B, handleSort: V, setCheckedId: H, setFilter: U, setPage: W, setPerPage: G, setSearch: K, setView: q } } = S(t), { setShowColumm: J, showColumm: Y } = C({ columns: r }), X = n(() => u ? u.render() : /* @__PURE__ */ l("div", {
|
|
486
|
+
className: "angel-table__empty",
|
|
487
|
+
children: [
|
|
488
|
+
/* @__PURE__ */ c("div", {
|
|
489
|
+
className: "angel-table__empty-icon",
|
|
490
|
+
children: /* @__PURE__ */ l("svg", {
|
|
491
|
+
viewBox: "0 0 24 24",
|
|
492
|
+
fill: "none",
|
|
493
|
+
stroke: "currentColor",
|
|
494
|
+
strokeWidth: "1.5",
|
|
495
|
+
"aria-hidden": "true",
|
|
496
|
+
children: [/* @__PURE__ */ c("path", {
|
|
497
|
+
strokeLinecap: "round",
|
|
498
|
+
strokeLinejoin: "round",
|
|
499
|
+
d: "M4 5.5A1.5 1.5 0 0 1 5.5 4h13A1.5 1.5 0 0 1 20 5.5v13a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 4 18.5v-13Z"
|
|
500
|
+
}), /* @__PURE__ */ c("path", {
|
|
501
|
+
strokeLinecap: "round",
|
|
502
|
+
strokeLinejoin: "round",
|
|
503
|
+
d: "M8 9h8M8 13h5m2 4 2 2 4-4"
|
|
504
|
+
})]
|
|
505
|
+
})
|
|
506
|
+
}),
|
|
507
|
+
/* @__PURE__ */ c("h3", {
|
|
508
|
+
className: "angel-table__empty-title",
|
|
509
|
+
children: "No data found"
|
|
510
|
+
}),
|
|
511
|
+
/* @__PURE__ */ c("p", {
|
|
512
|
+
className: "angel-table__empty-description",
|
|
513
|
+
children: "No data available to display. Please try again later."
|
|
514
|
+
}),
|
|
515
|
+
/* @__PURE__ */ c("button", {
|
|
516
|
+
type: "button",
|
|
517
|
+
className: "angel-table__button angel-table__button--secondary",
|
|
518
|
+
onClick: () => W(1),
|
|
519
|
+
children: "Refresh"
|
|
520
|
+
})
|
|
521
|
+
]
|
|
522
|
+
}), [u]), Z = /* @__PURE__ */ c("tr", { children: Y.filter((e) => e.show).map((e) => e.field === "check_field" ? /* @__PURE__ */ c("th", {
|
|
523
|
+
style: { width: e.width },
|
|
524
|
+
className: `angel-table__check-cell ${e.className ?? ""}`,
|
|
525
|
+
children: /* @__PURE__ */ c("input", {
|
|
526
|
+
type: "checkbox",
|
|
527
|
+
checked: L,
|
|
528
|
+
onChange: z,
|
|
529
|
+
"aria-label": "Chọn tất cả"
|
|
530
|
+
})
|
|
531
|
+
}, e.field) : e.field === "action_field" ? /* @__PURE__ */ c("th", {
|
|
532
|
+
style: { width: e.width },
|
|
533
|
+
className: `angel-table__index-cell ${e.className ?? ""}`,
|
|
534
|
+
children: e.title
|
|
535
|
+
}, e.field) : e.field === "index_field" ? /* @__PURE__ */ c("th", {
|
|
536
|
+
style: { width: e.width },
|
|
537
|
+
onClick: () => {
|
|
538
|
+
e.sort && V(e.field);
|
|
539
|
+
},
|
|
540
|
+
className: `angel-table__index-cell ${e.className ?? ""}`,
|
|
541
|
+
children: /* @__PURE__ */ c("span", {
|
|
542
|
+
className: "angel-table__sort",
|
|
543
|
+
children: "#"
|
|
544
|
+
})
|
|
545
|
+
}, e.field) : /* @__PURE__ */ c("th", {
|
|
546
|
+
style: { width: e.width },
|
|
547
|
+
onClick: () => V(e.field),
|
|
548
|
+
className: e.className ?? "",
|
|
549
|
+
children: /* @__PURE__ */ l("span", {
|
|
550
|
+
className: "angel-table__sort",
|
|
551
|
+
children: [e.title, e.sort && /* @__PURE__ */ l("span", {
|
|
552
|
+
className: "angel-table__sort-icon",
|
|
553
|
+
children: [
|
|
554
|
+
N.field === e.field && N.direction === "asc" && /* @__PURE__ */ c("svg", {
|
|
555
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
556
|
+
width: "16",
|
|
557
|
+
height: "16",
|
|
558
|
+
fill: "currentColor",
|
|
559
|
+
className: "bi bi-arrow-up",
|
|
560
|
+
viewBox: "0 0 16 16",
|
|
561
|
+
children: /* @__PURE__ */ c("path", {
|
|
562
|
+
fillRule: "evenodd",
|
|
563
|
+
d: "M8 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L7.5 2.707V14.5a.5.5 0 0 0 .5.5"
|
|
564
|
+
})
|
|
565
|
+
}),
|
|
566
|
+
N.field === e.field && N.direction === "desc" && /* @__PURE__ */ c("svg", {
|
|
567
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
568
|
+
width: "16",
|
|
569
|
+
height: "16",
|
|
570
|
+
fill: "currentColor",
|
|
571
|
+
className: "bi bi-arrow-down",
|
|
572
|
+
viewBox: "0 0 16 16",
|
|
573
|
+
children: /* @__PURE__ */ c("path", {
|
|
574
|
+
fillRule: "evenodd",
|
|
575
|
+
d: "M8 1a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L7.5 13.293V1.5A.5.5 0 0 1 8 1"
|
|
576
|
+
})
|
|
577
|
+
}),
|
|
578
|
+
N.field !== e.field && /* @__PURE__ */ c("svg", {
|
|
579
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
580
|
+
width: "16",
|
|
581
|
+
height: "16",
|
|
582
|
+
fill: "currentColor",
|
|
583
|
+
viewBox: "0 0 16 16",
|
|
584
|
+
children: /* @__PURE__ */ c("path", {
|
|
585
|
+
fillRule: "evenodd",
|
|
586
|
+
d: "M11.5 15a.5.5 0 0 0 .5-.5V2.707l3.146 3.147a.5.5 0 0 0 .708-.708l-4-4a.5.5 0 0 0-.708 0l-4 4a.5.5 0 1 0 .708.708L11 2.707V14.5a.5.5 0 0 0 .5.5m-7-14a.5.5 0 0 1 .5.5v11.793l3.146-3.147a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 0 1 .708-.708L4 13.293V1.5a.5.5 0 0 1 .5-.5"
|
|
587
|
+
})
|
|
588
|
+
})
|
|
589
|
+
]
|
|
590
|
+
})]
|
|
591
|
+
})
|
|
592
|
+
}, e.field)) });
|
|
593
|
+
return /* @__PURE__ */ l("div", {
|
|
594
|
+
"data-theme": v,
|
|
595
|
+
className: `angel-table-container ${o}`,
|
|
596
|
+
children: [/* @__PURE__ */ c("div", {
|
|
597
|
+
className: "angel-table-toolbar",
|
|
598
|
+
children: /* @__PURE__ */ l("div", {
|
|
599
|
+
className: "angel-table__toolbar",
|
|
600
|
+
children: [/* @__PURE__ */ l("div", {
|
|
601
|
+
className: "angel-table__toolbar-left",
|
|
602
|
+
children: [f?.map((e) => /* @__PURE__ */ c(h, {
|
|
603
|
+
value: E[e.field],
|
|
604
|
+
...e,
|
|
605
|
+
onChange: (t) => {
|
|
606
|
+
U((n) => ({
|
|
607
|
+
...n,
|
|
608
|
+
[e.field]: t
|
|
609
|
+
})), W(1);
|
|
610
|
+
},
|
|
611
|
+
direction: "bottom"
|
|
612
|
+
}, e.field)), M > 0 && b && /* @__PURE__ */ l("div", {
|
|
613
|
+
className: "angel-table__selection",
|
|
614
|
+
children: [y(M), /* @__PURE__ */ c("button", {
|
|
615
|
+
type: "button",
|
|
616
|
+
onClick: () => H({}),
|
|
617
|
+
children: "Clear selection"
|
|
618
|
+
})]
|
|
619
|
+
})]
|
|
620
|
+
}), /* @__PURE__ */ l("div", {
|
|
621
|
+
className: "angel-table__toolbar-left",
|
|
622
|
+
children: [
|
|
623
|
+
x && /* @__PURE__ */ c(g, {
|
|
624
|
+
onChange: (e) => {
|
|
625
|
+
let t = Y.map((t, n) => ({
|
|
626
|
+
...t,
|
|
627
|
+
show: n === e ? !t.show : t.show
|
|
628
|
+
}));
|
|
629
|
+
J([...t]);
|
|
630
|
+
},
|
|
631
|
+
options: [...r.map((e) => ({
|
|
632
|
+
value: e.field,
|
|
633
|
+
title: e.title,
|
|
634
|
+
show: !0
|
|
635
|
+
}))]
|
|
636
|
+
}),
|
|
637
|
+
/* @__PURE__ */ c(T, {
|
|
638
|
+
columns: Y,
|
|
639
|
+
onSort: (e) => {
|
|
640
|
+
V(e.field);
|
|
641
|
+
},
|
|
642
|
+
field: N.field,
|
|
643
|
+
sortDirection: N.direction
|
|
644
|
+
}),
|
|
645
|
+
/* @__PURE__ */ c("button", {
|
|
646
|
+
onClick: () => {
|
|
647
|
+
q(F === "table" ? "card" : "table");
|
|
648
|
+
},
|
|
649
|
+
className: "angel-table__button angel-table__button--secondary",
|
|
650
|
+
children: F === "table" ? /* @__PURE__ */ l("svg", {
|
|
651
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
652
|
+
fill: "currentColor",
|
|
653
|
+
viewBox: "0 0 16 16",
|
|
654
|
+
children: [/* @__PURE__ */ c("path", { d: "M14.5 3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2z" }), /* @__PURE__ */ c("path", { d: "M5 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 5 8m0-2.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5m0 5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5m-1-5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0M4 8a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0m0 2.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0" })]
|
|
655
|
+
}) : /* @__PURE__ */ c("svg", {
|
|
656
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
657
|
+
width: "16",
|
|
658
|
+
height: "16",
|
|
659
|
+
fill: "currentColor",
|
|
660
|
+
viewBox: "0 0 16 16",
|
|
661
|
+
children: /* @__PURE__ */ c("path", { d: "M1 2.5A1.5 1.5 0 0 1 2.5 1h3A1.5 1.5 0 0 1 7 2.5v3A1.5 1.5 0 0 1 5.5 7h-3A1.5 1.5 0 0 1 1 5.5zM2.5 2a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5zm6.5.5A1.5 1.5 0 0 1 10.5 1h3A1.5 1.5 0 0 1 15 2.5v3A1.5 1.5 0 0 1 13.5 7h-3A1.5 1.5 0 0 1 9 5.5zm1.5-.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5zM1 10.5A1.5 1.5 0 0 1 2.5 9h3A1.5 1.5 0 0 1 7 10.5v3A1.5 1.5 0 0 1 5.5 15h-3A1.5 1.5 0 0 1 1 13.5zm1.5-.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5zm6.5.5A1.5 1.5 0 0 1 10.5 9h3a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1-1.5 1.5h-3A1.5 1.5 0 0 1 9 13.5zm1.5-.5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5z" })
|
|
662
|
+
})
|
|
663
|
+
}),
|
|
664
|
+
/* @__PURE__ */ l("div", {
|
|
665
|
+
className: "angel-table__search-box",
|
|
666
|
+
children: [/* @__PURE__ */ l("svg", {
|
|
667
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
668
|
+
width: "16",
|
|
669
|
+
height: "16",
|
|
670
|
+
fill: "currentColor",
|
|
671
|
+
viewBox: "0 0 16 16",
|
|
672
|
+
children: [/* @__PURE__ */ c("path", { d: "M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0" }), " "]
|
|
673
|
+
}), /* @__PURE__ */ c("input", {
|
|
674
|
+
type: "text",
|
|
675
|
+
name: "angel-table__search",
|
|
676
|
+
placeholder: "Search...",
|
|
677
|
+
value: j,
|
|
678
|
+
onChange: (e) => {
|
|
679
|
+
K(e.currentTarget.value);
|
|
680
|
+
}
|
|
681
|
+
})]
|
|
682
|
+
}),
|
|
683
|
+
/* @__PURE__ */ c("button", {
|
|
684
|
+
type: "button",
|
|
685
|
+
className: "angel-table__button angel-table__button--secondary",
|
|
686
|
+
onClick: B,
|
|
687
|
+
children: /* @__PURE__ */ l("svg", {
|
|
688
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
689
|
+
width: "16",
|
|
690
|
+
height: "16",
|
|
691
|
+
fill: "currentColor",
|
|
692
|
+
viewBox: "0 0 16 16",
|
|
693
|
+
children: [/* @__PURE__ */ c("path", {
|
|
694
|
+
fillRule: "evenodd",
|
|
695
|
+
d: "M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2z"
|
|
696
|
+
}), /* @__PURE__ */ c("path", { d: "M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466" })]
|
|
697
|
+
})
|
|
698
|
+
})
|
|
699
|
+
]
|
|
700
|
+
})]
|
|
701
|
+
})
|
|
702
|
+
}), /* @__PURE__ */ l("div", {
|
|
703
|
+
className: "angel-table-body",
|
|
704
|
+
children: [
|
|
705
|
+
D && /* @__PURE__ */ c(s, { children: /* @__PURE__ */ l("div", {
|
|
706
|
+
className: "angel-table__loading-container",
|
|
707
|
+
children: [/* @__PURE__ */ c("div", { className: "angel-table__loading-backdrop" }), /* @__PURE__ */ c("div", {
|
|
708
|
+
className: "angel-table__loading-overlay",
|
|
709
|
+
children: /* @__PURE__ */ c("div", {
|
|
710
|
+
className: "angel-table__loading-text",
|
|
711
|
+
children: "Loading..."
|
|
712
|
+
})
|
|
713
|
+
})]
|
|
714
|
+
}) }),
|
|
715
|
+
/* @__PURE__ */ c("div", {
|
|
716
|
+
className: "angel-table__desktop",
|
|
717
|
+
ref: I,
|
|
718
|
+
children: F === "table" ? /* @__PURE__ */ c("div", {
|
|
719
|
+
style: { maxHeight: p.heightTable ?? 600 },
|
|
720
|
+
className: "angel-table ",
|
|
721
|
+
children: /* @__PURE__ */ l("table", { children: [/* @__PURE__ */ c("thead", { children: Z }), /* @__PURE__ */ c("tbody", { children: A.length === 0 && !D ? /* @__PURE__ */ c("tr", {
|
|
722
|
+
className: "",
|
|
723
|
+
children: /* @__PURE__ */ c("td", {
|
|
724
|
+
colSpan: r.length,
|
|
725
|
+
children: X()
|
|
726
|
+
})
|
|
727
|
+
}) : A.map((e, t) => {
|
|
728
|
+
let n = String(e[m]);
|
|
729
|
+
return /* @__PURE__ */ c("tr", {
|
|
730
|
+
className: w[n] ? "is-selected" : "",
|
|
731
|
+
children: Y.filter((e) => e.show).map((r) => r.field === "action_field" ? /* @__PURE__ */ c("td", {
|
|
732
|
+
className: r.className ?? "",
|
|
733
|
+
children: r.render ? r.render(e) : ""
|
|
734
|
+
}, r.field) : r.field === "check_field" ? /* @__PURE__ */ c("td", {
|
|
735
|
+
className: `angel-table__check-cell ${r.className ?? ""}`,
|
|
736
|
+
children: /* @__PURE__ */ c("input", {
|
|
737
|
+
type: "checkbox",
|
|
738
|
+
checked: !!w[n],
|
|
739
|
+
onChange: () => R(e),
|
|
740
|
+
"aria-label": `Chọn dòng ${n}`
|
|
741
|
+
})
|
|
742
|
+
}, r.field) : r.field === "index_field" ? /* @__PURE__ */ c("td", {
|
|
743
|
+
className: `angel-table__index-cell ${r.className ?? ""}`,
|
|
744
|
+
children: t + 1
|
|
745
|
+
}, r.field) : /* @__PURE__ */ c("td", {
|
|
746
|
+
className: r.className ?? "",
|
|
747
|
+
children: r.render ? r.render(e) : e[r.field]
|
|
748
|
+
}, r.field))
|
|
749
|
+
}, n);
|
|
750
|
+
}) })] })
|
|
751
|
+
}) : /* @__PURE__ */ c(e, { children: A.length === 0 ? X() : /* @__PURE__ */ c("ul", {
|
|
752
|
+
className: "angel-table__cards",
|
|
753
|
+
children: A.map((t, n) => {
|
|
754
|
+
let r = t[m];
|
|
755
|
+
return /* @__PURE__ */ c(e, { children: a ? a.render(t, () => R(t), w[r]) : /* @__PURE__ */ l("li", {
|
|
756
|
+
onClick: () => {
|
|
757
|
+
R(t);
|
|
758
|
+
},
|
|
759
|
+
className: "angel-table__card ",
|
|
760
|
+
children: [w[r] && b && /* @__PURE__ */ c("span", {
|
|
761
|
+
className: "is-selected",
|
|
762
|
+
children: "Selected"
|
|
763
|
+
}), Y.filter((e) => e.show).map((e, i) => ["check_field", "index_field"].includes(e.field) ? null : e.field === "action_field" ? /* @__PURE__ */ c("div", { children: e.render ? e.render(t) : /* @__PURE__ */ c(s, {}) }, `${r ?? n}-${e.field ?? i}`) : /* @__PURE__ */ l("div", {
|
|
764
|
+
className: "angel-table__card_row",
|
|
765
|
+
children: [/* @__PURE__ */ c("div", {
|
|
766
|
+
className: "angel-table__card_column_left",
|
|
767
|
+
children: e.title
|
|
768
|
+
}), /* @__PURE__ */ c("div", {
|
|
769
|
+
className: "angel-table__card_column_right",
|
|
770
|
+
children: e.render ? e.render(t) : t[e.field]
|
|
771
|
+
})]
|
|
772
|
+
}, `${r ?? n}-${e.field ?? i}`))]
|
|
773
|
+
}) }, r ?? n);
|
|
774
|
+
})
|
|
775
|
+
}) })
|
|
776
|
+
}),
|
|
777
|
+
/* @__PURE__ */ c("ul", {
|
|
778
|
+
className: "angel-table__mobile",
|
|
779
|
+
children: /* @__PURE__ */ c(e, { children: A.length === 0 ? X() : /* @__PURE__ */ c("li", {
|
|
780
|
+
className: "angel-table__cards",
|
|
781
|
+
children: A.map((t, n) => {
|
|
782
|
+
let r = String(t[m]);
|
|
783
|
+
return w[r], /* @__PURE__ */ c(e, { children: a ? a.render(t, () => R(t), w[r]) : /* @__PURE__ */ l("div", {
|
|
784
|
+
className: "angel-table__card",
|
|
785
|
+
children: [w[r] && b && /* @__PURE__ */ c("span", {
|
|
786
|
+
className: "is-selected",
|
|
787
|
+
children: "Selected"
|
|
788
|
+
}), Y.filter((e) => e.show).map((e, i) => ["check_field", "index_field"].includes(e.field) ? null : e.field === "action_field" ? /* @__PURE__ */ c("div", { children: e.render ? e.render(t) : /* @__PURE__ */ c(s, {}) }, `${String(r ?? n)}-${e.field ?? i}`) : /* @__PURE__ */ l("div", {
|
|
789
|
+
className: "angel-table__card_row",
|
|
790
|
+
children: [/* @__PURE__ */ c("div", {
|
|
791
|
+
className: "angel-table__card_column_left",
|
|
792
|
+
children: e.title
|
|
793
|
+
}), /* @__PURE__ */ c("div", {
|
|
794
|
+
className: "angel-table__card_column_right",
|
|
795
|
+
children: e.render ? e.render(t) : t[e.field]
|
|
796
|
+
})]
|
|
797
|
+
}, `${String(r ?? n)}-${e.field ?? i}`))]
|
|
798
|
+
}) }, String(r ?? n));
|
|
799
|
+
})
|
|
800
|
+
}) })
|
|
801
|
+
}),
|
|
802
|
+
/* @__PURE__ */ l("div", {
|
|
803
|
+
className: "angel-table__footer",
|
|
804
|
+
children: [/* @__PURE__ */ c("div", {
|
|
805
|
+
className: "angel-table__footer-info",
|
|
806
|
+
children: D ? "Đang tải..." : /* @__PURE__ */ l(s, { children: [
|
|
807
|
+
_,
|
|
808
|
+
" ",
|
|
809
|
+
/* @__PURE__ */ c("strong", { children: O }),
|
|
810
|
+
" /",
|
|
811
|
+
" ",
|
|
812
|
+
/* @__PURE__ */ c("strong", { children: P })
|
|
813
|
+
] })
|
|
814
|
+
}), /* @__PURE__ */ l("div", {
|
|
815
|
+
className: "angel-table__pagination",
|
|
816
|
+
children: [
|
|
817
|
+
/* @__PURE__ */ c(h, {
|
|
818
|
+
field: "",
|
|
819
|
+
onChange: (e) => {
|
|
820
|
+
G(Number(e)), W(1);
|
|
821
|
+
},
|
|
822
|
+
noLabel: !0,
|
|
823
|
+
direction: "top",
|
|
824
|
+
options: [...d.map((e) => ({
|
|
825
|
+
title: e + "",
|
|
826
|
+
value: e + ""
|
|
827
|
+
}))],
|
|
828
|
+
title: k + ""
|
|
829
|
+
}),
|
|
830
|
+
/* @__PURE__ */ c("button", {
|
|
831
|
+
type: "button",
|
|
832
|
+
className: "angel-table__page-button",
|
|
833
|
+
disabled: O <= 1 || D,
|
|
834
|
+
onClick: () => W(() => 1),
|
|
835
|
+
"aria-label": "Trang trước",
|
|
836
|
+
children: /* @__PURE__ */ l("svg", {
|
|
837
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
838
|
+
width: "16",
|
|
839
|
+
height: "16",
|
|
840
|
+
fill: "currentColor",
|
|
841
|
+
viewBox: "0 0 16 16",
|
|
842
|
+
children: [/* @__PURE__ */ c("path", {
|
|
843
|
+
fillRule: "evenodd",
|
|
844
|
+
d: "M8.354 1.646a.5.5 0 0 1 0 .708L2.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"
|
|
845
|
+
}), /* @__PURE__ */ c("path", {
|
|
846
|
+
fillRule: "evenodd",
|
|
847
|
+
d: "M12.354 1.646a.5.5 0 0 1 0 .708L6.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"
|
|
848
|
+
})]
|
|
849
|
+
})
|
|
850
|
+
}),
|
|
851
|
+
/* @__PURE__ */ c("button", {
|
|
852
|
+
type: "button",
|
|
853
|
+
className: "angel-table__page-button",
|
|
854
|
+
disabled: O <= 1 || D,
|
|
855
|
+
onClick: () => W((e) => Math.max(1, e - 1)),
|
|
856
|
+
"aria-label": "Trang trước",
|
|
857
|
+
children: /* @__PURE__ */ c("svg", {
|
|
858
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
859
|
+
width: "16",
|
|
860
|
+
height: "16",
|
|
861
|
+
fill: "currentColor",
|
|
862
|
+
viewBox: "0 0 16 16",
|
|
863
|
+
children: /* @__PURE__ */ c("path", {
|
|
864
|
+
fillRule: "evenodd",
|
|
865
|
+
d: "M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0"
|
|
866
|
+
})
|
|
867
|
+
})
|
|
868
|
+
}),
|
|
869
|
+
/* @__PURE__ */ c("span", {
|
|
870
|
+
className: "angel-table__page-number",
|
|
871
|
+
children: O
|
|
872
|
+
}),
|
|
873
|
+
/* @__PURE__ */ c("button", {
|
|
874
|
+
type: "button",
|
|
875
|
+
className: "angel-table__page-button",
|
|
876
|
+
disabled: O >= P || D,
|
|
877
|
+
onClick: () => W((e) => Math.min(P, e + 1)),
|
|
878
|
+
"aria-label": "Trang tiếp theo",
|
|
879
|
+
children: /* @__PURE__ */ c("svg", {
|
|
880
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
881
|
+
width: "16",
|
|
882
|
+
height: "16",
|
|
883
|
+
fill: "currentColor",
|
|
884
|
+
viewBox: "0 0 16 16",
|
|
885
|
+
children: /* @__PURE__ */ c("path", {
|
|
886
|
+
fillRule: "evenodd",
|
|
887
|
+
d: "M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708"
|
|
888
|
+
})
|
|
889
|
+
})
|
|
890
|
+
}),
|
|
891
|
+
/* @__PURE__ */ c("button", {
|
|
892
|
+
type: "button",
|
|
893
|
+
className: "angel-table__page-button",
|
|
894
|
+
disabled: O >= P || D,
|
|
895
|
+
onClick: () => W(() => P),
|
|
896
|
+
"aria-label": "Trang tiếp theo",
|
|
897
|
+
children: /* @__PURE__ */ l("svg", {
|
|
898
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
899
|
+
width: "16",
|
|
900
|
+
height: "16",
|
|
901
|
+
fill: "currentColor",
|
|
902
|
+
viewBox: "0 0 16 16",
|
|
903
|
+
children: [/* @__PURE__ */ c("path", {
|
|
904
|
+
fillRule: "evenodd",
|
|
905
|
+
d: "M3.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L9.293 8 3.646 2.354a.5.5 0 0 1 0-.708"
|
|
906
|
+
}), /* @__PURE__ */ c("path", {
|
|
907
|
+
fillRule: "evenodd",
|
|
908
|
+
d: "M7.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L13.293 8 7.646 2.354a.5.5 0 0 1 0-.708"
|
|
909
|
+
})]
|
|
910
|
+
})
|
|
911
|
+
})
|
|
912
|
+
]
|
|
913
|
+
})]
|
|
914
|
+
})
|
|
915
|
+
]
|
|
916
|
+
})]
|
|
917
|
+
});
|
|
918
|
+
};
|
|
919
|
+
export { O as Table };
|