react-gridix 0.1.0 → 0.1.1
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.html +1742 -0
- package/README.md +1043 -0
- package/dist/index.d.ts +76 -70
- package/dist/react-gridix.cjs +1 -1
- package/dist/react-gridix.js +482 -428
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/react-gridix.js
CHANGED
|
@@ -1,99 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import {
|
|
3
|
-
import { createPortal as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
return /* @__PURE__ */
|
|
7
|
-
h && /* @__PURE__ */ o("span", { className: "rk-spinner", "aria-hidden": "true" }),
|
|
8
|
-
_
|
|
9
|
-
] });
|
|
10
|
-
}), ft = je(function({ label: s, error: c, hint: h, id: v, className: b, ..._ }, m) {
|
|
11
|
-
const E = Me(), x = v ?? E, I = c || h ? `${x}-desc` : void 0;
|
|
12
|
-
return /* @__PURE__ */ p("div", { className: ["rk-field", b].filter(Boolean).join(" "), children: [
|
|
13
|
-
s && /* @__PURE__ */ o("label", { className: "rk-label", htmlFor: x, children: s }),
|
|
14
|
-
/* @__PURE__ */ o(
|
|
15
|
-
"input",
|
|
16
|
-
{
|
|
17
|
-
ref: m,
|
|
18
|
-
id: x,
|
|
19
|
-
className: `rk-input${c ? " rk-input--error" : ""}`,
|
|
20
|
-
"aria-invalid": c ? !0 : void 0,
|
|
21
|
-
"aria-describedby": I,
|
|
22
|
-
..._
|
|
23
|
-
}
|
|
24
|
-
),
|
|
25
|
-
(c || h) && /* @__PURE__ */ o("span", { id: I, className: c ? "rk-error-text" : "rk-hint", children: c ?? h })
|
|
26
|
-
] });
|
|
27
|
-
});
|
|
28
|
-
function ht({ title: l, footer: s, className: c, children: h, ...v }) {
|
|
29
|
-
return /* @__PURE__ */ p("div", { className: ["rk-card", c].filter(Boolean).join(" "), ...v, children: [
|
|
30
|
-
l && /* @__PURE__ */ o("div", { className: "rk-card__header", children: l }),
|
|
31
|
-
/* @__PURE__ */ o("div", { className: "rk-card__body", children: h }),
|
|
32
|
-
s && /* @__PURE__ */ o("div", { className: "rk-card__footer", children: s })
|
|
33
|
-
] });
|
|
34
|
-
}
|
|
35
|
-
function kt({ tone: l = "neutral", className: s, children: c, ...h }) {
|
|
36
|
-
return /* @__PURE__ */ o("span", { className: ["rk-badge", `rk-badge--${l}`, s].filter(Boolean).join(" "), ...h, children: c });
|
|
37
|
-
}
|
|
38
|
-
function bt({ tone: l = "info", title: s, onClose: c, className: h, children: v, ...b }) {
|
|
39
|
-
return /* @__PURE__ */ p(
|
|
40
|
-
"div",
|
|
41
|
-
{
|
|
42
|
-
role: l === "danger" || l === "warning" ? "alert" : "status",
|
|
43
|
-
className: ["rk-alert", `rk-alert--${l}`, h].filter(Boolean).join(" "),
|
|
44
|
-
...b,
|
|
45
|
-
children: [
|
|
46
|
-
/* @__PURE__ */ p("div", { className: "rk-alert__content", children: [
|
|
47
|
-
s && /* @__PURE__ */ o("strong", { className: "rk-alert__title", children: s }),
|
|
48
|
-
/* @__PURE__ */ o("div", { children: v })
|
|
49
|
-
] }),
|
|
50
|
-
c && /* @__PURE__ */ o("button", { type: "button", className: "rk-alert__close", "aria-label": "Dismiss", onClick: c, children: "×" })
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
function gt({ open: l, onClose: s, title: c, footer: h, children: v }) {
|
|
56
|
-
const b = Me(), _ = Q(null);
|
|
57
|
-
return be(() => {
|
|
58
|
-
var I;
|
|
59
|
-
if (!l) return;
|
|
60
|
-
const m = document.activeElement;
|
|
61
|
-
(I = _.current) == null || I.focus();
|
|
62
|
-
const E = (P) => {
|
|
63
|
-
P.key === "Escape" && s();
|
|
64
|
-
};
|
|
65
|
-
document.addEventListener("keydown", E);
|
|
66
|
-
const x = document.body.style.overflow;
|
|
67
|
-
return document.body.style.overflow = "hidden", () => {
|
|
68
|
-
var P;
|
|
69
|
-
document.removeEventListener("keydown", E), document.body.style.overflow = x, (P = m == null ? void 0 : m.focus) == null || P.call(m);
|
|
70
|
-
};
|
|
71
|
-
}, [l, s]), !l || typeof document > "u" ? null : lt(
|
|
72
|
-
/* @__PURE__ */ o("div", { className: "rk-overlay", onMouseDown: (m) => m.target === m.currentTarget && s(), children: /* @__PURE__ */ p(
|
|
73
|
-
"div",
|
|
74
|
-
{
|
|
75
|
-
ref: _,
|
|
76
|
-
role: "dialog",
|
|
77
|
-
"aria-modal": "true",
|
|
78
|
-
"aria-labelledby": c ? b : void 0,
|
|
79
|
-
tabIndex: -1,
|
|
80
|
-
className: "rk-modal",
|
|
81
|
-
children: [
|
|
82
|
-
c && /* @__PURE__ */ p("div", { className: "rk-modal__header", children: [
|
|
83
|
-
/* @__PURE__ */ o("h2", { id: b, className: "rk-modal__title", children: c }),
|
|
84
|
-
/* @__PURE__ */ o("button", { type: "button", className: "rk-alert__close", "aria-label": "Close", onClick: s, children: "×" })
|
|
85
|
-
] }),
|
|
86
|
-
/* @__PURE__ */ o("div", { className: "rk-modal__body", children: v }),
|
|
87
|
-
h && /* @__PURE__ */ o("div", { className: "rk-modal__footer", children: h })
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
) }),
|
|
91
|
-
document.body
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
const J = (...l) => l.filter(Boolean).join(" ");
|
|
95
|
-
function it() {
|
|
96
|
-
return /* @__PURE__ */ o("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ o(
|
|
1
|
+
import { jsxs as $, jsx as d, Fragment as gt } from "react/jsx-runtime";
|
|
2
|
+
import { useState as V, useRef as W, useCallback as kt, useEffect as ae, createElement as se, useLayoutEffect as bt, useMemo as qe } from "react";
|
|
3
|
+
import { createPortal as _t } from "react-dom";
|
|
4
|
+
const le = (...o) => o.filter(Boolean).join(" ");
|
|
5
|
+
function mt() {
|
|
6
|
+
return /* @__PURE__ */ d("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ d(
|
|
97
7
|
"path",
|
|
98
8
|
{
|
|
99
9
|
d: "M3.5 8.5l3 3 6-7",
|
|
@@ -105,510 +15,654 @@ function it() {
|
|
|
105
15
|
}
|
|
106
16
|
) });
|
|
107
17
|
}
|
|
108
|
-
function
|
|
109
|
-
return /* @__PURE__ */
|
|
18
|
+
function vt() {
|
|
19
|
+
return /* @__PURE__ */ d("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ d("path", { d: "M4 8h8", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round" }) });
|
|
110
20
|
}
|
|
111
|
-
function
|
|
112
|
-
checked:
|
|
21
|
+
function Ge({
|
|
22
|
+
checked: o,
|
|
113
23
|
onChange: s,
|
|
114
24
|
indeterminate: c = !1,
|
|
115
25
|
variant: h = "native",
|
|
116
|
-
disabled:
|
|
26
|
+
disabled: I = !1,
|
|
117
27
|
label: b,
|
|
118
|
-
"aria-label":
|
|
119
|
-
id:
|
|
120
|
-
name:
|
|
121
|
-
indicator:
|
|
122
|
-
className:
|
|
123
|
-
style:
|
|
124
|
-
classNames:
|
|
125
|
-
styles:
|
|
28
|
+
"aria-label": m,
|
|
29
|
+
id: O,
|
|
30
|
+
name: H,
|
|
31
|
+
indicator: B,
|
|
32
|
+
className: G,
|
|
33
|
+
style: w,
|
|
34
|
+
classNames: k = {},
|
|
35
|
+
styles: E = {}
|
|
126
36
|
}) {
|
|
127
|
-
const
|
|
128
|
-
return /* @__PURE__ */
|
|
37
|
+
const F = c ? "indeterminate" : o ? "checked" : "unchecked";
|
|
38
|
+
return /* @__PURE__ */ $(
|
|
129
39
|
"label",
|
|
130
40
|
{
|
|
131
|
-
className:
|
|
41
|
+
className: le(
|
|
132
42
|
"rk-checkbox",
|
|
133
43
|
`rk-checkbox--${h}`,
|
|
134
|
-
|
|
44
|
+
F === "checked" && "rk-checkbox--checked",
|
|
135
45
|
c && "rk-checkbox--indeterminate",
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
46
|
+
I && "rk-checkbox--disabled",
|
|
47
|
+
k.root,
|
|
48
|
+
G
|
|
139
49
|
),
|
|
140
|
-
style: { ...
|
|
141
|
-
"data-state":
|
|
50
|
+
style: { ...E.root, ...w },
|
|
51
|
+
"data-state": F,
|
|
142
52
|
children: [
|
|
143
|
-
h === "native" ? /* @__PURE__ */
|
|
53
|
+
h === "native" ? /* @__PURE__ */ d(
|
|
144
54
|
"input",
|
|
145
55
|
{
|
|
146
56
|
type: "checkbox",
|
|
147
|
-
id:
|
|
148
|
-
name:
|
|
149
|
-
ref: (
|
|
150
|
-
|
|
57
|
+
id: O,
|
|
58
|
+
name: H,
|
|
59
|
+
ref: (y) => {
|
|
60
|
+
y && (y.indeterminate = c);
|
|
151
61
|
},
|
|
152
|
-
className:
|
|
153
|
-
style:
|
|
154
|
-
checked:
|
|
155
|
-
disabled:
|
|
156
|
-
"aria-label":
|
|
157
|
-
"data-state":
|
|
158
|
-
onChange: (
|
|
62
|
+
className: le("rk-checkbox__control", k.control),
|
|
63
|
+
style: E.control,
|
|
64
|
+
checked: o,
|
|
65
|
+
disabled: I,
|
|
66
|
+
"aria-label": m,
|
|
67
|
+
"data-state": F,
|
|
68
|
+
onChange: (y) => s(y.target.checked)
|
|
159
69
|
}
|
|
160
|
-
) : /* @__PURE__ */
|
|
70
|
+
) : /* @__PURE__ */ d(
|
|
161
71
|
"button",
|
|
162
72
|
{
|
|
163
73
|
type: "button",
|
|
164
74
|
role: "checkbox",
|
|
165
|
-
id:
|
|
166
|
-
className:
|
|
167
|
-
style:
|
|
168
|
-
"aria-checked": c ? "mixed" :
|
|
169
|
-
"aria-label":
|
|
170
|
-
disabled:
|
|
171
|
-
"data-state":
|
|
172
|
-
onClick: () => s(!
|
|
173
|
-
children: /* @__PURE__ */
|
|
75
|
+
id: O,
|
|
76
|
+
className: le("rk-checkbox__control", k.control),
|
|
77
|
+
style: E.control,
|
|
78
|
+
"aria-checked": c ? "mixed" : o,
|
|
79
|
+
"aria-label": m,
|
|
80
|
+
disabled: I,
|
|
81
|
+
"data-state": F,
|
|
82
|
+
onClick: () => s(!o),
|
|
83
|
+
children: /* @__PURE__ */ d(
|
|
174
84
|
"span",
|
|
175
85
|
{
|
|
176
|
-
className:
|
|
86
|
+
className: le(
|
|
177
87
|
"rk-checkbox__indicator",
|
|
178
|
-
|
|
179
|
-
|
|
88
|
+
B !== void 0 && !c && "rk-checkbox__indicator--custom",
|
|
89
|
+
k.indicator
|
|
180
90
|
),
|
|
181
|
-
style:
|
|
182
|
-
"data-state":
|
|
91
|
+
style: E.indicator,
|
|
92
|
+
"data-state": F,
|
|
183
93
|
"aria-hidden": "true",
|
|
184
|
-
children: c ? h === "tick" ? /* @__PURE__ */
|
|
94
|
+
children: c ? h === "tick" ? /* @__PURE__ */ d(vt, {}) : null : B !== void 0 ? B : h === "tick" ? /* @__PURE__ */ d(mt, {}) : null
|
|
185
95
|
}
|
|
186
96
|
)
|
|
187
97
|
}
|
|
188
98
|
),
|
|
189
|
-
b != null && /* @__PURE__ */
|
|
99
|
+
b != null && b !== !1 && b !== "" && /* @__PURE__ */ d("span", { className: le("rk-checkbox__label", k.label), style: E.label, children: b })
|
|
190
100
|
]
|
|
191
101
|
}
|
|
192
102
|
);
|
|
193
103
|
}
|
|
194
|
-
const
|
|
195
|
-
function
|
|
196
|
-
|
|
197
|
-
|
|
104
|
+
const Ne = (...o) => o.filter(Boolean).join(" "), yt = typeof window < "u" ? bt : ae;
|
|
105
|
+
function xt({
|
|
106
|
+
column: o,
|
|
107
|
+
label: s,
|
|
108
|
+
value: c,
|
|
109
|
+
onChange: h,
|
|
110
|
+
theme: I,
|
|
111
|
+
indicatorClassName: b,
|
|
112
|
+
indicatorStyle: m,
|
|
113
|
+
popupClassName: O,
|
|
114
|
+
popupStyle: H,
|
|
115
|
+
inputClassName: B,
|
|
116
|
+
inputStyle: G
|
|
117
|
+
}) {
|
|
118
|
+
const [w, k] = V(!1), [E, F] = V({ top: 0, left: 0 }), y = W(null), R = W(null), q = c.trim() !== "", L = kt(() => {
|
|
119
|
+
var j;
|
|
120
|
+
const g = y.current;
|
|
121
|
+
if (!g) return;
|
|
122
|
+
const K = g.getBoundingClientRect(), A = ((j = R.current) == null ? void 0 : j.offsetWidth) ?? 260, T = Math.max(8, Math.min(K.left, window.innerWidth - A - 8));
|
|
123
|
+
F({ top: K.bottom + 6, left: T });
|
|
124
|
+
}, []);
|
|
125
|
+
yt(() => {
|
|
126
|
+
w && L();
|
|
127
|
+
}, [w, L]), ae(() => {
|
|
128
|
+
if (!w) return;
|
|
129
|
+
const g = (A) => {
|
|
130
|
+
var j, de;
|
|
131
|
+
const T = A.target;
|
|
132
|
+
(j = R.current) != null && j.contains(T) || (de = y.current) != null && de.contains(T) || k(!1);
|
|
133
|
+
}, K = (A) => {
|
|
134
|
+
var T;
|
|
135
|
+
A.key === "Escape" && (k(!1), (T = y.current) == null || T.focus());
|
|
136
|
+
};
|
|
137
|
+
return document.addEventListener("mousedown", g), document.addEventListener("keydown", K), window.addEventListener("resize", L), window.addEventListener("scroll", L, !0), () => {
|
|
138
|
+
document.removeEventListener("mousedown", g), document.removeEventListener("keydown", K), window.removeEventListener("resize", L), window.removeEventListener("scroll", L, !0);
|
|
139
|
+
};
|
|
140
|
+
}, [w, L]);
|
|
141
|
+
const _e = () => {
|
|
142
|
+
var g;
|
|
143
|
+
k(!1), (g = y.current) == null || g.focus();
|
|
144
|
+
};
|
|
145
|
+
return /* @__PURE__ */ $(gt, { children: [
|
|
146
|
+
/* @__PURE__ */ d(
|
|
147
|
+
"button",
|
|
148
|
+
{
|
|
149
|
+
ref: y,
|
|
150
|
+
type: "button",
|
|
151
|
+
className: Ne(
|
|
152
|
+
"rk-grid__filter-btn",
|
|
153
|
+
q && "rk-grid__filter-btn--active",
|
|
154
|
+
w && "rk-grid__filter-btn--open",
|
|
155
|
+
b
|
|
156
|
+
),
|
|
157
|
+
style: m,
|
|
158
|
+
"aria-label": `Filter ${s}`,
|
|
159
|
+
"aria-haspopup": "dialog",
|
|
160
|
+
"aria-expanded": w,
|
|
161
|
+
"data-active": q || void 0,
|
|
162
|
+
onClick: (g) => {
|
|
163
|
+
g.stopPropagation(), w || L(), k((K) => !K);
|
|
164
|
+
},
|
|
165
|
+
children: o.filterIndicator ? se(o.filterIndicator, { column: o, active: q, open: w }) : /* @__PURE__ */ d("span", { className: "rk-grid__filter-dot", "aria-hidden": "true" })
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
w && typeof document < "u" && _t(
|
|
169
|
+
/* @__PURE__ */ $(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
ref: R,
|
|
173
|
+
role: "dialog",
|
|
174
|
+
"aria-label": `Filter ${s}`,
|
|
175
|
+
"data-rk-theme": I || void 0,
|
|
176
|
+
className: Ne("rk-grid-popup", O),
|
|
177
|
+
style: { position: "fixed", top: E.top, left: E.left, ...H },
|
|
178
|
+
children: [
|
|
179
|
+
o.filterRenderer ? se(o.filterRenderer, { column: o, value: c, onChange: h }) : /* @__PURE__ */ d(
|
|
180
|
+
"input",
|
|
181
|
+
{
|
|
182
|
+
autoFocus: !0,
|
|
183
|
+
type: "text",
|
|
184
|
+
className: Ne("rk-grid__filter-input", B),
|
|
185
|
+
style: G,
|
|
186
|
+
value: c,
|
|
187
|
+
placeholder: o.filterPlaceholder ?? `Filter ${s}…`,
|
|
188
|
+
"aria-label": `Filter text for ${s}`,
|
|
189
|
+
onChange: (g) => h(g.target.value),
|
|
190
|
+
onKeyDown: (g) => {
|
|
191
|
+
g.key === "Enter" && _e();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
q && /* @__PURE__ */ d("button", { type: "button", className: "rk-grid__filter-clear", onClick: () => h(""), children: "Clear" })
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
),
|
|
199
|
+
document.body
|
|
200
|
+
)
|
|
201
|
+
] });
|
|
202
|
+
}
|
|
203
|
+
const Se = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Ye = (o, s) => Object.prototype.hasOwnProperty.call(o, s);
|
|
204
|
+
function z(o, s) {
|
|
205
|
+
if (o === null || typeof o != "object") return;
|
|
206
|
+
if (Ye(o, s)) return o[s];
|
|
207
|
+
let c = o;
|
|
208
|
+
for (const h of s.split(".")) {
|
|
209
|
+
if (c == null || typeof c != "object" || Se.has(h)) return;
|
|
210
|
+
c = c[h];
|
|
211
|
+
}
|
|
212
|
+
return c;
|
|
198
213
|
}
|
|
199
|
-
function
|
|
200
|
-
|
|
214
|
+
function Je(o, s, c) {
|
|
215
|
+
if (Array.isArray(o)) {
|
|
216
|
+
const h = [...o];
|
|
217
|
+
return h[s] = c, h;
|
|
218
|
+
}
|
|
219
|
+
return { ...o, [s]: c };
|
|
201
220
|
}
|
|
202
|
-
function
|
|
203
|
-
|
|
221
|
+
function De(o, s, c) {
|
|
222
|
+
const h = o ?? {};
|
|
223
|
+
if (Ye(h, s) || !s.includes("."))
|
|
224
|
+
return Se.has(s) ? o : Je(h, s, c);
|
|
225
|
+
const [I, ...b] = s.split(".");
|
|
226
|
+
if (Se.has(I)) return o;
|
|
227
|
+
const m = h[I];
|
|
228
|
+
return Je(h, I, De(m !== null && typeof m == "object" ? m : {}, b.join("."), c));
|
|
229
|
+
}
|
|
230
|
+
const D = (...o) => o.filter(Boolean).join(" "), Ue = (o, s) => `${typeof o}:${o}\0${s}`, Ie = (o) => o.headerName ?? (o.type === "boolean" ? "" : o.field), be = (o) => Ie(o) || o.field;
|
|
231
|
+
function Ce(o, s) {
|
|
232
|
+
const c = z(s, o.field);
|
|
233
|
+
return o.valueFormatter ? o.valueFormatter(c, s) : o.type === "boolean" && typeof c == "boolean" ? c ? "Yes" : "No" : c == null ? "" : c instanceof Date ? c.toLocaleDateString() : String(c);
|
|
234
|
+
}
|
|
235
|
+
function wt(o, s) {
|
|
236
|
+
return typeof o == "number" && typeof s == "number" ? o - s : o instanceof Date && s instanceof Date ? o.getTime() - s.getTime() : typeof o == "boolean" && typeof s == "boolean" ? Number(o) - Number(s) : String(o).localeCompare(String(s), void 0, { numeric: !0, sensitivity: "base" });
|
|
237
|
+
}
|
|
238
|
+
function St({
|
|
239
|
+
columns: o,
|
|
204
240
|
rows: s,
|
|
205
241
|
getRowId: c,
|
|
206
242
|
editable: h = !1,
|
|
207
|
-
enterMovesDown:
|
|
243
|
+
enterMovesDown: I = !0,
|
|
208
244
|
onCellEdit: b,
|
|
209
|
-
onRowsChange:
|
|
210
|
-
sortable:
|
|
211
|
-
defaultSort:
|
|
212
|
-
onSortChange:
|
|
213
|
-
searchable:
|
|
214
|
-
searchPlaceholder:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
paginationPosition: B = "bottom",
|
|
245
|
+
onRowsChange: m,
|
|
246
|
+
sortable: O = !0,
|
|
247
|
+
defaultSort: H = null,
|
|
248
|
+
onSortChange: B,
|
|
249
|
+
searchable: G = !0,
|
|
250
|
+
searchPlaceholder: w = "Search…",
|
|
251
|
+
pagination: k = !0,
|
|
252
|
+
paginationPosition: E = "bottom",
|
|
218
253
|
pageSize: F = 10,
|
|
219
|
-
pageSizeOptions:
|
|
220
|
-
onRowClick:
|
|
221
|
-
toolbar:
|
|
222
|
-
emptyMessage:
|
|
223
|
-
striped:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
254
|
+
pageSizeOptions: y = [5, 10, 25, 50],
|
|
255
|
+
onRowClick: R,
|
|
256
|
+
toolbar: q,
|
|
257
|
+
emptyMessage: L = "No rows to show",
|
|
258
|
+
striped: _e = !1,
|
|
259
|
+
stripeColors: g,
|
|
260
|
+
checkboxVariant: K = "native",
|
|
261
|
+
animateRows: A = !0,
|
|
262
|
+
theme: T,
|
|
263
|
+
maxHeight: j,
|
|
264
|
+
className: de,
|
|
265
|
+
style: He,
|
|
266
|
+
classNames: N = {},
|
|
267
|
+
styles: x = {},
|
|
268
|
+
rowClassName: me,
|
|
269
|
+
rowStyle: ve
|
|
232
270
|
}) {
|
|
233
|
-
const
|
|
234
|
-
className:
|
|
235
|
-
style:
|
|
236
|
-
}), [
|
|
237
|
-
|
|
238
|
-
|
|
271
|
+
const _ = (e, t) => ({
|
|
272
|
+
className: D(t, N[e]),
|
|
273
|
+
style: x[e]
|
|
274
|
+
}), [Pe, $e] = V(s), Q = W(s);
|
|
275
|
+
ae(() => {
|
|
276
|
+
Q.current = s, $e(s);
|
|
239
277
|
}, [s]);
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
}, [
|
|
243
|
-
() =>
|
|
244
|
-
[
|
|
245
|
-
),
|
|
246
|
-
const e =
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
278
|
+
const Le = (e) => {
|
|
279
|
+
Q.current = e, $e(e);
|
|
280
|
+
}, [X, Qe] = V(""), [Z, Xe] = V({}), [v, Ze] = V(H), [et, ee] = V(0), [P, tt] = V(F), [te, re] = V(null), J = W(0), ce = W(null), ye = W(/* @__PURE__ */ new Map()), Te = qe(
|
|
281
|
+
() => Pe.map((e, t) => ({ row: e, index: t, id: c ? c(e, t) : t })),
|
|
282
|
+
[Pe, c]
|
|
283
|
+
), ne = qe(() => {
|
|
284
|
+
const e = X.trim().toLowerCase(), t = Object.entries(Z).filter(
|
|
285
|
+
([n, i]) => i.trim() !== "" && o.some((l) => l.field === n && l.filterable)
|
|
286
|
+
);
|
|
287
|
+
let r = Te.filter(({ row: n }) => e && !o.some((l) => Ce(l, n).toLowerCase().includes(e)) ? !1 : t.every(([i, l]) => {
|
|
288
|
+
const f = o.find((a) => a.field === i);
|
|
289
|
+
return f ? Ce(f, n).toLowerCase().includes(l.trim().toLowerCase()) : !0;
|
|
250
290
|
}));
|
|
251
|
-
if (
|
|
252
|
-
const n =
|
|
291
|
+
if (v) {
|
|
292
|
+
const n = o.find((i) => i.field === v.field);
|
|
253
293
|
if (n) {
|
|
254
|
-
const i =
|
|
255
|
-
r = [...r].sort((
|
|
256
|
-
const a =
|
|
257
|
-
return
|
|
294
|
+
const i = v.direction === "asc" ? 1 : -1;
|
|
295
|
+
r = [...r].sort((l, f) => {
|
|
296
|
+
const a = z(l.row, n.field), u = z(f.row, n.field), p = a == null || a === "", C = u == null || u === "";
|
|
297
|
+
return p || C ? p === C ? 0 : p ? 1 : -1 : (n.comparator ? n.comparator(a, u, l.row, f.row) : wt(a, u)) * i;
|
|
258
298
|
});
|
|
259
299
|
}
|
|
260
300
|
}
|
|
261
301
|
return r;
|
|
262
|
-
}, [
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
302
|
+
}, [Te, o, X, Z, v]);
|
|
303
|
+
ae(() => ee(0), [X, Z, v, P]);
|
|
304
|
+
const Be = W(null), U = ne.length, oe = k ? Math.max(1, Math.ceil(U / P)) : 1, S = Math.min(et, oe - 1), M = k ? ne.slice(S * P, S * P + P) : ne, rt = U === 0 ? 0 : k ? S * P + 1 : 1, nt = k ? Math.min(U, (S + 1) * P) : U, Fe = (e) => e.sortable ?? O, Ke = `${S}|${P}|${v ? `${v.field}:${v.direction}` : ""}|${X}|${JSON.stringify(Z)}`, Me = W(!0);
|
|
305
|
+
ae(() => {
|
|
306
|
+
if (Me.current) {
|
|
307
|
+
Me.current = !1;
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const e = Be.current;
|
|
311
|
+
e && typeof e.scrollTo == "function" && e.scrollTop > 0 && e.scrollTo({ top: 0, behavior: "smooth" });
|
|
312
|
+
}, [Ke]);
|
|
313
|
+
const ue = (e, t, r) => ({
|
|
314
|
+
value: z(t, e.field),
|
|
315
|
+
formattedValue: Ce(e, t),
|
|
267
316
|
row: t,
|
|
268
317
|
rowIndex: r,
|
|
269
318
|
field: e.field,
|
|
270
319
|
column: e
|
|
271
|
-
}),
|
|
320
|
+
}), xe = (e, t) => {
|
|
272
321
|
const r = e.editable ?? h;
|
|
273
322
|
return typeof r == "function" ? r(t) : !!r;
|
|
274
|
-
},
|
|
275
|
-
const r =
|
|
323
|
+
}, fe = (e, t) => xe(e, t) && !(e.type === "boolean" && !e.cellEditor), ot = (e, t) => {
|
|
324
|
+
const r = ue(e, t.row, t.index), n = xe(e, r);
|
|
276
325
|
return {
|
|
277
326
|
...r,
|
|
278
327
|
editable: n,
|
|
279
|
-
updateValue: (i) => n &&
|
|
328
|
+
updateValue: (i) => n && Ae(t, e, { value: i })
|
|
280
329
|
};
|
|
281
|
-
},
|
|
282
|
-
if (!
|
|
330
|
+
}, Ve = (e) => {
|
|
331
|
+
if (!Fe(e)) return;
|
|
283
332
|
let t;
|
|
284
|
-
!
|
|
285
|
-
},
|
|
333
|
+
!v || v.field !== e.field ? t = { field: e.field, direction: "asc" } : v.direction === "asc" ? t = { field: e.field, direction: "desc" } : t = null, Ze(t), B == null || B(t);
|
|
334
|
+
}, pe = (e, t) => {
|
|
286
335
|
var r;
|
|
287
|
-
return (r =
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
},
|
|
291
|
-
if (!
|
|
292
|
-
const n = e.row
|
|
293
|
-
return
|
|
336
|
+
return (r = ye.current.get(Ue(e, t))) == null ? void 0 : r.focus();
|
|
337
|
+
}, Y = () => {
|
|
338
|
+
J.current += 1, re(null);
|
|
339
|
+
}, he = (e, t, r = {}) => {
|
|
340
|
+
if (!fe(t, ue(t, e.row, e.index))) return !1;
|
|
341
|
+
const n = z(e.row, t.field), i = t.cellEditor ? n : r.text ?? (n == null ? "" : String(n));
|
|
342
|
+
return ce.current = i, J.current += 1, re({
|
|
294
343
|
id: e.id,
|
|
295
344
|
field: t.field,
|
|
296
345
|
draft: i,
|
|
297
|
-
session:
|
|
346
|
+
session: J.current,
|
|
298
347
|
select: r.select ?? "end",
|
|
299
348
|
invalid: !1
|
|
300
349
|
}), !0;
|
|
301
|
-
},
|
|
302
|
-
const n =
|
|
303
|
-
let
|
|
350
|
+
}, Ae = (e, t, r) => {
|
|
351
|
+
const n = Q.current[e.index] ?? e.row, i = z(n, t.field);
|
|
352
|
+
let l;
|
|
304
353
|
if ("value" in r)
|
|
305
|
-
|
|
354
|
+
l = r.value;
|
|
306
355
|
else if (t.valueParser)
|
|
307
|
-
|
|
356
|
+
l = t.valueParser(r.text, n);
|
|
308
357
|
else if (t.type === "number")
|
|
309
|
-
if (r.text.trim() === "")
|
|
358
|
+
if (r.text.trim() === "") l = null;
|
|
310
359
|
else {
|
|
311
360
|
const u = Number(r.text);
|
|
312
361
|
if (!Number.isFinite(u)) return !1;
|
|
313
|
-
|
|
362
|
+
l = u;
|
|
314
363
|
}
|
|
315
364
|
else
|
|
316
|
-
|
|
317
|
-
if (Object.is(
|
|
318
|
-
if (t.validate && !t.validate(
|
|
319
|
-
const f =
|
|
320
|
-
return
|
|
321
|
-
},
|
|
322
|
-
const n =
|
|
365
|
+
l = r.text;
|
|
366
|
+
if (Object.is(l, i)) return !0;
|
|
367
|
+
if (t.validate && !t.validate(l, n)) return !1;
|
|
368
|
+
const f = De(n, t.field, l), a = Q.current.map((u, p) => p === e.index ? f : u);
|
|
369
|
+
return Le(a), b == null || b({ rowId: e.id, rowIndex: e.index, field: t.field, oldValue: i, newValue: l, row: f }), m == null || m(a), !0;
|
|
370
|
+
}, je = (e, t, r) => {
|
|
371
|
+
const n = M.findIndex((p) => p.id === e.id), i = o.findIndex((p) => p.field === t);
|
|
323
372
|
if (n < 0 || i < 0) return null;
|
|
324
|
-
const
|
|
373
|
+
const l = (p, C) => fe(C, ue(C, p.row, p.index));
|
|
325
374
|
if (r === "down" || r === "up") {
|
|
326
|
-
const
|
|
327
|
-
for (let
|
|
328
|
-
if (
|
|
375
|
+
const p = r === "down" ? 1 : -1;
|
|
376
|
+
for (let C = n + p; C >= 0 && C < M.length; C += p)
|
|
377
|
+
if (l(M[C], o[i])) return { entry: M[C], col: o[i] };
|
|
329
378
|
return null;
|
|
330
379
|
}
|
|
331
380
|
const f = r === "right" ? 1 : -1;
|
|
332
381
|
let a = n, u = i + f;
|
|
333
|
-
for (; a >= 0 && a <
|
|
334
|
-
for (; u >= 0 && u <
|
|
335
|
-
if (
|
|
382
|
+
for (; a >= 0 && a < M.length; ) {
|
|
383
|
+
for (; u >= 0 && u < o.length; ) {
|
|
384
|
+
if (l(M[a], o[u])) return { entry: M[a], col: o[u] };
|
|
336
385
|
u += f;
|
|
337
386
|
}
|
|
338
|
-
a += f, u = f > 0 ? 0 :
|
|
387
|
+
a += f, u = f > 0 ? 0 : o.length - 1;
|
|
339
388
|
}
|
|
340
389
|
return null;
|
|
341
|
-
},
|
|
342
|
-
const { move: i = "none", focus:
|
|
343
|
-
if (!
|
|
344
|
-
return
|
|
345
|
-
const f = i === "none" ? null :
|
|
346
|
-
return f ?
|
|
347
|
-
},
|
|
390
|
+
}, ie = (e, t, r, n = {}) => {
|
|
391
|
+
const { move: i = "none", focus: l = !0 } = n;
|
|
392
|
+
if (!Ae(e, t, r))
|
|
393
|
+
return re((a) => a && { ...a, invalid: !0 }), !1;
|
|
394
|
+
const f = i === "none" ? null : je(e, t.field, i);
|
|
395
|
+
return f ? he(f.entry, f.col, { select: "all" }) : (Y(), l && pe(e.id, t.field)), !0;
|
|
396
|
+
}, it = (e, t, r) => {
|
|
348
397
|
if (e.nativeEvent.isComposing) return;
|
|
349
398
|
const n = e.currentTarget.value;
|
|
350
399
|
if (e.key === "Enter") {
|
|
351
400
|
e.preventDefault();
|
|
352
|
-
const i =
|
|
353
|
-
|
|
401
|
+
const i = I ? e.shiftKey ? "up" : "down" : "none";
|
|
402
|
+
ie(t, r, { text: n }, { move: i });
|
|
354
403
|
} else if (e.key === "Escape")
|
|
355
|
-
e.preventDefault(),
|
|
404
|
+
e.preventDefault(), Y(), pe(t.id, r.field);
|
|
356
405
|
else if (e.key === "Tab") {
|
|
357
406
|
const i = e.shiftKey ? "left" : "right";
|
|
358
|
-
|
|
407
|
+
je(t, r.field, i) && (e.preventDefault(), ie(t, r, { text: n }, { move: i }));
|
|
359
408
|
}
|
|
360
|
-
},
|
|
361
|
-
e.target !== e.currentTarget || !
|
|
362
|
-
},
|
|
409
|
+
}, lt = (e, t, r, n) => {
|
|
410
|
+
e.target !== e.currentTarget || !fe(r, n) || (e.key === "Enter" || e.key === "F2" ? (e.preventDefault(), he(t, r)) : !r.cellEditor && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), he(t, r, { text: e.key })));
|
|
411
|
+
}, at = (e, t, r) => t.cellEditor ? /* @__PURE__ */ d(
|
|
363
412
|
"div",
|
|
364
413
|
{
|
|
365
414
|
className: "rk-grid__custom-editor",
|
|
366
415
|
onBlur: (n) => {
|
|
367
|
-
n.currentTarget.contains(n.relatedTarget) || r.session ===
|
|
416
|
+
n.currentTarget.contains(n.relatedTarget) || r.session === J.current && (ie(e, t, { value: ce.current }, { focus: !1 }) || Y());
|
|
368
417
|
},
|
|
369
418
|
onKeyDown: (n) => {
|
|
370
|
-
n.key === "Escape" && (n.preventDefault(), n.stopPropagation(),
|
|
419
|
+
n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), Y(), pe(e.id, t.field));
|
|
371
420
|
},
|
|
372
|
-
children:
|
|
421
|
+
children: se(t.cellEditor, {
|
|
373
422
|
value: r.draft,
|
|
374
423
|
row: e.row,
|
|
375
424
|
rowIndex: e.index,
|
|
376
425
|
field: t.field,
|
|
377
426
|
column: t,
|
|
378
427
|
onChange: (n) => {
|
|
379
|
-
|
|
428
|
+
ce.current = n, re((i) => i && i.session === r.session ? { ...i, draft: n, invalid: !1 } : i);
|
|
380
429
|
},
|
|
381
430
|
onCommit: (n, i = "none") => {
|
|
382
|
-
r.session ===
|
|
431
|
+
r.session === J.current && ie(e, t, { value: n === void 0 ? ce.current : n }, { move: i });
|
|
383
432
|
},
|
|
384
433
|
onCancel: () => {
|
|
385
|
-
|
|
434
|
+
Y(), pe(e.id, t.field);
|
|
386
435
|
}
|
|
387
436
|
})
|
|
388
437
|
}
|
|
389
|
-
) : /* @__PURE__ */
|
|
438
|
+
) : /* @__PURE__ */ d(
|
|
390
439
|
"input",
|
|
391
440
|
{
|
|
392
441
|
autoFocus: !0,
|
|
393
|
-
className:
|
|
394
|
-
style: { textAlign: t.align, ...
|
|
442
|
+
className: D("rk-grid__editor", r.invalid && "rk-grid__editor--invalid", N.editor),
|
|
443
|
+
style: { textAlign: t.align, ...x.editor },
|
|
395
444
|
value: r.draft === null || r.draft === void 0 ? "" : String(r.draft),
|
|
396
445
|
inputMode: t.type === "number" ? "decimal" : void 0,
|
|
397
|
-
"aria-label": `Edit ${t
|
|
446
|
+
"aria-label": `Edit ${be(t)}`,
|
|
398
447
|
"aria-invalid": r.invalid || void 0,
|
|
399
448
|
onChange: (n) => {
|
|
400
449
|
const i = n.target.value;
|
|
401
|
-
|
|
450
|
+
re((l) => l && { ...l, draft: i, invalid: !1 });
|
|
402
451
|
},
|
|
403
452
|
onFocus: (n) => {
|
|
404
453
|
const i = n.currentTarget;
|
|
405
454
|
r.select === "all" ? i.select() : i.setSelectionRange(i.value.length, i.value.length);
|
|
406
455
|
},
|
|
407
456
|
onBlur: (n) => {
|
|
408
|
-
r.session ===
|
|
457
|
+
r.session === J.current && (ie(e, t, { text: n.currentTarget.value }, { focus: !1 }) || Y());
|
|
409
458
|
},
|
|
410
|
-
onKeyDown: (n) =>
|
|
459
|
+
onKeyDown: (n) => it(n, e, t)
|
|
411
460
|
}
|
|
412
|
-
),
|
|
413
|
-
var r, n, i,
|
|
461
|
+
), ze = (e) => {
|
|
462
|
+
var r, n, i, l, f, a, u, p;
|
|
414
463
|
const t = e.checkbox ?? {};
|
|
415
464
|
return {
|
|
416
|
-
variant: t.variant ??
|
|
465
|
+
variant: t.variant ?? K,
|
|
417
466
|
indicator: t.indicator,
|
|
418
467
|
className: t.className,
|
|
419
468
|
style: t.style,
|
|
420
469
|
classNames: {
|
|
421
|
-
root:
|
|
422
|
-
control:
|
|
423
|
-
indicator:
|
|
424
|
-
label: (
|
|
470
|
+
root: D(N.checkbox, (r = t.classNames) == null ? void 0 : r.root),
|
|
471
|
+
control: D(N.checkboxControl, (n = t.classNames) == null ? void 0 : n.control),
|
|
472
|
+
indicator: D(N.checkboxIndicator, (i = t.classNames) == null ? void 0 : i.indicator),
|
|
473
|
+
label: (l = t.classNames) == null ? void 0 : l.label
|
|
425
474
|
},
|
|
426
475
|
styles: {
|
|
427
|
-
root: { ...
|
|
428
|
-
control: { ...
|
|
429
|
-
indicator: { ...
|
|
430
|
-
label: (
|
|
476
|
+
root: { ...x.checkbox, ...(f = t.styles) == null ? void 0 : f.root },
|
|
477
|
+
control: { ...x.checkboxControl, ...(a = t.styles) == null ? void 0 : a.control },
|
|
478
|
+
indicator: { ...x.checkboxIndicator, ...(u = t.styles) == null ? void 0 : u.indicator },
|
|
479
|
+
label: (p = t.styles) == null ? void 0 : p.label
|
|
431
480
|
}
|
|
432
481
|
};
|
|
433
|
-
},
|
|
434
|
-
|
|
482
|
+
}, ge = (e) => e.stopPropagation(), st = (e, t) => /* @__PURE__ */ d("span", { className: "rk-grid__checkbox-cell", onClick: ge, onDoubleClick: ge, children: /* @__PURE__ */ d(
|
|
483
|
+
Ge,
|
|
435
484
|
{
|
|
436
|
-
...
|
|
485
|
+
...ze(e),
|
|
437
486
|
checked: !!t.value,
|
|
438
487
|
disabled: !t.editable,
|
|
439
|
-
"aria-label": `Toggle ${e
|
|
488
|
+
"aria-label": `Toggle ${be(e)}`,
|
|
440
489
|
onChange: (r) => t.updateValue(r)
|
|
441
490
|
}
|
|
442
|
-
) }),
|
|
443
|
-
const r = new Map(
|
|
491
|
+
) }), We = (e) => ne.filter((t) => xe(e, ue(e, t.row, t.index))), dt = (e, t) => {
|
|
492
|
+
const r = new Map(We(e).map((l) => [l.index, l])), n = [], i = Q.current.map((l, f) => {
|
|
444
493
|
const a = r.get(f);
|
|
445
|
-
if (!a) return
|
|
446
|
-
const u =
|
|
447
|
-
if (!!u === t || e.validate && !e.validate(t,
|
|
448
|
-
const
|
|
449
|
-
return n.push({ rowId: a.id, rowIndex: f, field: e.field, oldValue: u, newValue: t, row:
|
|
494
|
+
if (!a) return l;
|
|
495
|
+
const u = z(l, e.field);
|
|
496
|
+
if (!!u === t || e.validate && !e.validate(t, l)) return l;
|
|
497
|
+
const p = De(l, e.field, t);
|
|
498
|
+
return n.push({ rowId: a.id, rowIndex: f, field: e.field, oldValue: u, newValue: t, row: p }), p;
|
|
450
499
|
});
|
|
451
|
-
n.length !== 0 && (
|
|
452
|
-
},
|
|
453
|
-
const t =
|
|
454
|
-
return /* @__PURE__ */
|
|
455
|
-
|
|
500
|
+
n.length !== 0 && (Le(i), n.forEach((l) => b == null ? void 0 : b(l)), m == null || m(i));
|
|
501
|
+
}, ct = (e) => {
|
|
502
|
+
const t = We(e), r = t.length > 0 ? t : ne, n = r.filter((l) => !!z(l.row, e.field)).length, i = r.length > 0 && n === r.length;
|
|
503
|
+
return /* @__PURE__ */ d("span", { className: "rk-grid__header-checkbox", onClick: ge, onDoubleClick: ge, children: /* @__PURE__ */ d(
|
|
504
|
+
Ge,
|
|
456
505
|
{
|
|
457
|
-
...
|
|
506
|
+
...ze(e),
|
|
458
507
|
checked: i,
|
|
459
508
|
indeterminate: n > 0 && !i,
|
|
460
509
|
disabled: t.length === 0,
|
|
461
|
-
label: e
|
|
462
|
-
|
|
510
|
+
label: Ie(e) || void 0,
|
|
511
|
+
"aria-label": `Select all ${be(e)}`,
|
|
512
|
+
onChange: (l) => dt(e, l)
|
|
463
513
|
}
|
|
464
514
|
) });
|
|
465
|
-
},
|
|
515
|
+
}, ut = _e || !!g, ft = g ? { "--rk-stripe-a": g[0], "--rk-stripe-b": g[1] } : void 0, pt = k && (E === "top" || E === "both"), ht = !k || E === "bottom" || E === "both", Oe = (e) => /* @__PURE__ */ $(
|
|
466
516
|
"div",
|
|
467
517
|
{
|
|
468
|
-
className:
|
|
469
|
-
style:
|
|
518
|
+
className: D("rk-grid__footer", e === "top" && "rk-grid__footer--top", N.footer),
|
|
519
|
+
style: x.footer,
|
|
470
520
|
"data-position": e,
|
|
471
521
|
children: [
|
|
472
|
-
/* @__PURE__ */
|
|
473
|
-
|
|
474
|
-
/* @__PURE__ */
|
|
522
|
+
/* @__PURE__ */ d("span", { ..._("rowCount", "rk-grid__count"), children: U === 0 ? "0 rows" : `${rt}–${nt} of ${U}` }),
|
|
523
|
+
k && /* @__PURE__ */ $("div", { ..._("pagination", "rk-grid__pagination"), children: [
|
|
524
|
+
/* @__PURE__ */ $("label", { className: "rk-grid__page-size-label", children: [
|
|
475
525
|
"Rows per page",
|
|
476
|
-
/* @__PURE__ */
|
|
526
|
+
/* @__PURE__ */ d(
|
|
477
527
|
"select",
|
|
478
528
|
{
|
|
479
|
-
value:
|
|
480
|
-
onChange: (t) =>
|
|
481
|
-
...
|
|
482
|
-
children: (
|
|
483
|
-
(t) => /* @__PURE__ */
|
|
529
|
+
value: P,
|
|
530
|
+
onChange: (t) => tt(Number(t.target.value)),
|
|
531
|
+
..._("pageSize", "rk-grid__page-size"),
|
|
532
|
+
children: (y.includes(P) ? y : [...y, P].sort((t, r) => t - r)).map(
|
|
533
|
+
(t) => /* @__PURE__ */ d("option", { value: t, children: t }, t)
|
|
484
534
|
)
|
|
485
535
|
}
|
|
486
536
|
)
|
|
487
537
|
] }),
|
|
488
|
-
/* @__PURE__ */
|
|
489
|
-
/* @__PURE__ */
|
|
490
|
-
/* @__PURE__ */
|
|
538
|
+
/* @__PURE__ */ d("button", { type: "button", "aria-label": "First page", disabled: S === 0, onClick: () => ee(0), ..._("pageButton", "rk-grid__page-btn"), children: "«" }),
|
|
539
|
+
/* @__PURE__ */ d("button", { type: "button", "aria-label": "Previous page", disabled: S === 0, onClick: () => ee(S - 1), ..._("pageButton", "rk-grid__page-btn"), children: "‹" }),
|
|
540
|
+
/* @__PURE__ */ $("span", { ..._("pageInfo", "rk-grid__page-info"), children: [
|
|
491
541
|
"Page ",
|
|
492
|
-
|
|
542
|
+
S + 1,
|
|
493
543
|
" of ",
|
|
494
|
-
|
|
544
|
+
oe
|
|
495
545
|
] }),
|
|
496
|
-
/* @__PURE__ */
|
|
497
|
-
/* @__PURE__ */
|
|
546
|
+
/* @__PURE__ */ d("button", { type: "button", "aria-label": "Next page", disabled: S >= oe - 1, onClick: () => ee(S + 1), ..._("pageButton", "rk-grid__page-btn"), children: "›" }),
|
|
547
|
+
/* @__PURE__ */ d("button", { type: "button", "aria-label": "Last page", disabled: S >= oe - 1, onClick: () => ee(oe - 1), ..._("pageButton", "rk-grid__page-btn"), children: "»" })
|
|
498
548
|
] })
|
|
499
549
|
]
|
|
500
550
|
}
|
|
501
|
-
)
|
|
502
|
-
return /* @__PURE__ */
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
...g("search", "rk-grid__search")
|
|
513
|
-
}
|
|
514
|
-
) : /* @__PURE__ */ o("span", {}),
|
|
515
|
-
ge
|
|
516
|
-
] }),
|
|
517
|
-
tt && Se("top"),
|
|
518
|
-
/* @__PURE__ */ o("div", { ...g("scroll", "rk-grid__scroll"), style: { ...D.scroll, ...me !== void 0 ? { maxHeight: me } : null }, children: /* @__PURE__ */ p("table", { ...g("table", "rk-grid__table"), role: "grid", children: [
|
|
519
|
-
/* @__PURE__ */ p("thead", { ...g("thead", "rk-grid__thead"), children: [
|
|
520
|
-
/* @__PURE__ */ o("tr", { ...g("headerRow", "rk-grid__tr"), children: l.map((e) => {
|
|
521
|
-
const t = (w == null ? void 0 : w.field) === e.field ? w.direction : null, r = Ne(e);
|
|
522
|
-
return /* @__PURE__ */ o(
|
|
523
|
-
"th",
|
|
551
|
+
);
|
|
552
|
+
return /* @__PURE__ */ $(
|
|
553
|
+
"div",
|
|
554
|
+
{
|
|
555
|
+
className: D("rk-grid", N.root, de),
|
|
556
|
+
style: { ...ft, ...x.root, ...He },
|
|
557
|
+
"data-rk-theme": T || void 0,
|
|
558
|
+
children: [
|
|
559
|
+
(G || q) && /* @__PURE__ */ $("div", { ..._("toolbar", "rk-grid__toolbar"), children: [
|
|
560
|
+
G ? /* @__PURE__ */ d(
|
|
561
|
+
"input",
|
|
524
562
|
{
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
{
|
|
549
|
-
value: z[e.field] ?? "",
|
|
550
|
-
onChange: (t) => xe((r) => ({ ...r, [e.field]: t.target.value })),
|
|
551
|
-
placeholder: "Filter",
|
|
552
|
-
"aria-label": `Filter ${e.headerName ?? e.field}`,
|
|
553
|
-
...g("filterInput", "rk-grid__filter-input")
|
|
554
|
-
}
|
|
555
|
-
)) }, e.field)) })
|
|
556
|
-
] }),
|
|
557
|
-
/* @__PURE__ */ o("tbody", { ...g("tbody", "rk-grid__tbody"), children: K.length === 0 ? /* @__PURE__ */ o("tr", { children: /* @__PURE__ */ o("td", { colSpan: l.length, ...g("empty", "rk-grid__empty"), children: Fe }) }) : K.map((e, t) => {
|
|
558
|
-
const { row: r, id: n, index: i } = e, d = typeof de == "function" ? de(r, i) : de, f = typeof se == "function" ? se(r, i) : se;
|
|
559
|
-
return /* @__PURE__ */ o(
|
|
560
|
-
"tr",
|
|
561
|
-
{
|
|
562
|
-
onClick: ae ? () => ae(r, i) : void 0,
|
|
563
|
-
className: $(
|
|
564
|
-
"rk-grid__tr",
|
|
565
|
-
"rk-grid__row",
|
|
566
|
-
Le && t % 2 === 1 && "rk-grid__row--striped",
|
|
567
|
-
ae && "rk-grid__row--clickable",
|
|
568
|
-
S.row,
|
|
569
|
-
d
|
|
570
|
-
),
|
|
571
|
-
style: { ...D.row, ...f },
|
|
572
|
-
children: l.map((a) => {
|
|
573
|
-
const u = He(a, e), k = typeof a.cellClassName == "function" ? a.cellClassName(u) : a.cellClassName, N = typeof a.cellStyle == "function" ? a.cellStyle(u) : a.cellStyle, fe = q !== null && q.id === n && q.field === a.field, he = ee(a, u);
|
|
574
|
-
return /* @__PURE__ */ o(
|
|
575
|
-
"td",
|
|
576
|
-
{
|
|
577
|
-
ref: (le) => {
|
|
578
|
-
const Te = Pe(n, a.field);
|
|
579
|
-
le ? ce.current.set(Te, le) : ce.current.delete(Te);
|
|
580
|
-
},
|
|
581
|
-
tabIndex: he ? 0 : void 0,
|
|
582
|
-
onDoubleClick: he ? () => re(e, a) : void 0,
|
|
583
|
-
onKeyDown: (le) => Qe(le, e, a, u),
|
|
584
|
-
className: $(
|
|
585
|
-
"rk-grid__td",
|
|
586
|
-
he && "rk-grid__td--editable",
|
|
587
|
-
fe && "rk-grid__td--editing",
|
|
588
|
-
S.cell,
|
|
589
|
-
k
|
|
590
|
-
),
|
|
591
|
-
style: { textAlign: a.align, ...D.cell, ...N },
|
|
592
|
-
children: fe && q ? Ue(e, a, q) : a.cellRenderer ? ie(a.cellRenderer, u) : a.type === "boolean" && !a.cellEditor ? Xe(a, u) : u.formattedValue
|
|
563
|
+
type: "search",
|
|
564
|
+
value: X,
|
|
565
|
+
onChange: (e) => Qe(e.target.value),
|
|
566
|
+
placeholder: w,
|
|
567
|
+
"aria-label": "Search all columns",
|
|
568
|
+
..._("search", "rk-grid__search")
|
|
569
|
+
}
|
|
570
|
+
) : /* @__PURE__ */ d("span", {}),
|
|
571
|
+
q
|
|
572
|
+
] }),
|
|
573
|
+
pt && Oe("top"),
|
|
574
|
+
/* @__PURE__ */ d("div", { ref: Be, ..._("scroll", "rk-grid__scroll"), style: { ...x.scroll, ...j !== void 0 ? { maxHeight: j } : null }, children: /* @__PURE__ */ $("table", { ..._("table", "rk-grid__table"), role: "grid", children: [
|
|
575
|
+
/* @__PURE__ */ d("thead", { ..._("thead", "rk-grid__thead"), children: /* @__PURE__ */ d("tr", { ..._("headerRow", "rk-grid__tr"), children: o.map((e) => {
|
|
576
|
+
const t = (v == null ? void 0 : v.field) === e.field ? v.direction : null, r = Fe(e);
|
|
577
|
+
return /* @__PURE__ */ d(
|
|
578
|
+
"th",
|
|
579
|
+
{
|
|
580
|
+
scope: "col",
|
|
581
|
+
"aria-sort": t ? t === "asc" ? "ascending" : "descending" : r ? "none" : void 0,
|
|
582
|
+
tabIndex: r ? 0 : void 0,
|
|
583
|
+
onClick: () => Ve(e),
|
|
584
|
+
onKeyDown: (n) => {
|
|
585
|
+
r && n.target === n.currentTarget && (n.key === "Enter" || n.key === " ") && (n.preventDefault(), Ve(e));
|
|
593
586
|
},
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
587
|
+
className: D("rk-grid__th", r && "rk-grid__th--sortable", N.headerCell, e.className, e.headerClassName),
|
|
588
|
+
style: { width: e.width, minWidth: e.minWidth, textAlign: e.align, ...x.headerCell, ...e.style, ...e.headerStyle },
|
|
589
|
+
children: /* @__PURE__ */ $("span", { className: "rk-grid__th-content", children: [
|
|
590
|
+
e.headerRenderer ? se(e.headerRenderer, { column: e, sortDirection: t }) : e.headerCheckbox && e.type === "boolean" ? ct(e) : Ie(e),
|
|
591
|
+
e.filterable && /* @__PURE__ */ d(
|
|
592
|
+
xt,
|
|
593
|
+
{
|
|
594
|
+
column: e,
|
|
595
|
+
label: be(e),
|
|
596
|
+
value: Z[e.field] ?? "",
|
|
597
|
+
onChange: (n) => Xe((i) => ({ ...i, [e.field]: n })),
|
|
598
|
+
theme: T,
|
|
599
|
+
indicatorClassName: D(N.filterIndicator, e.filterIndicatorClassName),
|
|
600
|
+
indicatorStyle: { ...x.filterIndicator, ...e.filterIndicatorStyle },
|
|
601
|
+
popupClassName: D(N.filterPopup, e.filterPopupClassName),
|
|
602
|
+
popupStyle: { ...x.filterPopup, ...e.filterPopupStyle },
|
|
603
|
+
inputClassName: N.filterInput,
|
|
604
|
+
inputStyle: x.filterInput
|
|
605
|
+
}
|
|
606
|
+
),
|
|
607
|
+
r && /* @__PURE__ */ d("span", { className: "rk-grid__sort", "aria-hidden": "true", children: t === "asc" ? "▲" : t === "desc" ? "▼" : "↕" })
|
|
608
|
+
] })
|
|
609
|
+
},
|
|
610
|
+
e.field
|
|
611
|
+
);
|
|
612
|
+
}) }) }),
|
|
613
|
+
/* @__PURE__ */ d("tbody", { ..._("tbody", "rk-grid__tbody"), children: M.length === 0 ? /* @__PURE__ */ d("tr", { children: /* @__PURE__ */ d("td", { colSpan: o.length, ..._("empty", "rk-grid__empty"), children: L }) }) : M.map((e, t) => {
|
|
614
|
+
const { row: r, id: n, index: i } = e, l = typeof me == "function" ? me(r, i) : me, f = typeof ve == "function" ? ve(r, i) : ve;
|
|
615
|
+
return /* @__PURE__ */ d(
|
|
616
|
+
"tr",
|
|
617
|
+
{
|
|
618
|
+
onClick: R ? () => R(r, i) : void 0,
|
|
619
|
+
className: D(
|
|
620
|
+
"rk-grid__tr",
|
|
621
|
+
"rk-grid__row",
|
|
622
|
+
ut && (t % 2 === 0 ? "rk-grid__row--stripe-a" : "rk-grid__row--stripe-b"),
|
|
623
|
+
A && "rk-grid__row--enter",
|
|
624
|
+
R && "rk-grid__row--clickable",
|
|
625
|
+
N.row,
|
|
626
|
+
l
|
|
627
|
+
),
|
|
628
|
+
style: { ...A ? { "--rk-i": Math.min(t, 24) } : null, ...x.row, ...f },
|
|
629
|
+
children: o.map((a) => {
|
|
630
|
+
const u = ot(a, e), p = typeof a.cellClassName == "function" ? a.cellClassName(u) : a.cellClassName, C = typeof a.cellStyle == "function" ? a.cellStyle(u) : a.cellStyle, we = te !== null && te.id === n && te.field === a.field, Ee = fe(a, u);
|
|
631
|
+
return /* @__PURE__ */ d(
|
|
632
|
+
"td",
|
|
633
|
+
{
|
|
634
|
+
ref: (ke) => {
|
|
635
|
+
const Re = Ue(n, a.field);
|
|
636
|
+
ke ? ye.current.set(Re, ke) : ye.current.delete(Re);
|
|
637
|
+
},
|
|
638
|
+
tabIndex: Ee ? 0 : void 0,
|
|
639
|
+
onDoubleClick: Ee ? () => he(e, a) : void 0,
|
|
640
|
+
onKeyDown: (ke) => lt(ke, e, a, u),
|
|
641
|
+
className: D(
|
|
642
|
+
"rk-grid__td",
|
|
643
|
+
Ee && "rk-grid__td--editable",
|
|
644
|
+
we && "rk-grid__td--editing",
|
|
645
|
+
N.cell,
|
|
646
|
+
a.className,
|
|
647
|
+
p
|
|
648
|
+
),
|
|
649
|
+
style: { textAlign: a.align, ...x.cell, ...a.style, ...C },
|
|
650
|
+
children: we && te ? at(e, a, te) : a.cellRenderer ? se(a.cellRenderer, u) : a.type === "boolean" && !a.cellEditor ? st(a, u) : u.formattedValue
|
|
651
|
+
},
|
|
652
|
+
a.field
|
|
653
|
+
);
|
|
654
|
+
})
|
|
655
|
+
},
|
|
656
|
+
n
|
|
657
|
+
);
|
|
658
|
+
}) }, Ke)
|
|
659
|
+
] }) }),
|
|
660
|
+
ht && Oe("bottom")
|
|
661
|
+
]
|
|
662
|
+
}
|
|
663
|
+
);
|
|
604
664
|
}
|
|
605
665
|
export {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
ut as Button,
|
|
609
|
-
ht as Card,
|
|
610
|
-
Ke as Checkbox,
|
|
611
|
-
mt as DataGrid,
|
|
612
|
-
ft as Input,
|
|
613
|
-
gt as Modal
|
|
666
|
+
Ge as Checkbox,
|
|
667
|
+
St as DataGrid
|
|
614
668
|
};
|