@apliteni/apliteni-ui 0.25.3 → 0.27.0
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 +2 -2
- package/package.json +1 -1
- package/react/README.md +92 -2
- package/react/dist/index.css +0 -12
- package/react/dist/index.d.ts +73 -6
- package/react/dist/index.js +380 -114
- package/src/components/pagination.js +344 -0
- package/src/index.css +1 -0
- package/src/index.js +1 -0
- package/src/inline.js +2 -0
- package/src/styles/button.css +14 -0
- package/src/styles/input.css +6 -0
- package/src/styles/pagination.css +124 -0
- package/src/tokens/tokens.css +6 -0
package/react/dist/index.js
CHANGED
|
@@ -170,117 +170,375 @@ function Modal({ open, title, onClose, footer, children }) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// src/DataTable.tsx
|
|
173
|
-
import { useMemo, useState } from "react";
|
|
174
|
-
import {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
173
|
+
import { useMemo, useState as useState2 } from "react";
|
|
174
|
+
import { DEFAULT_PAGE_SIZE as DEFAULT_PAGE_SIZE2 } from "@apliteni/apliteni-ui";
|
|
175
|
+
|
|
176
|
+
// src/Pagination.tsx
|
|
177
|
+
import { useEffect as useEffect2, useId, useRef as useRef2, useState } from "react";
|
|
178
|
+
import { DEFAULT_PAGE_SIZE } from "@apliteni/apliteni-ui";
|
|
179
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
180
|
+
var GHOST_SM = "ui-btn ui-btn--ghost ui-btn--sm";
|
|
181
|
+
var VARIANTS = ["steps", "numbered", "jump"];
|
|
182
|
+
var cx2 = (...a) => a.filter(Boolean).join(" ");
|
|
183
|
+
var CAP = Number.MAX_SAFE_INTEGER;
|
|
184
|
+
var int = (v, fallback) => {
|
|
185
|
+
const raw = typeof v === "number" ? v : typeof v === "string" && v.trim() !== "" ? Number(v) : NaN;
|
|
186
|
+
if (!Number.isFinite(raw)) return fallback;
|
|
187
|
+
return Math.min(Math.max(Math.trunc(raw), -CAP), CAP);
|
|
188
|
+
};
|
|
189
|
+
var sizeOf = (v, fallback) => {
|
|
190
|
+
const asked = int(v, fallback);
|
|
191
|
+
return asked > 0 ? asked : fallback;
|
|
192
|
+
};
|
|
193
|
+
var fmt = (n) => n.toLocaleString("en-US");
|
|
194
|
+
function slotsFor(page, pageCount) {
|
|
195
|
+
const wanted = [1, pageCount, page - 1, page, page + 1].filter((n) => n >= 1 && n <= pageCount);
|
|
196
|
+
const shown = [...new Set(wanted)].sort((a, b) => a - b);
|
|
197
|
+
const out = [];
|
|
198
|
+
for (const n of shown) {
|
|
199
|
+
const prev = out.length ? out[out.length - 1] : null;
|
|
200
|
+
if (prev != null) {
|
|
201
|
+
if (n - prev === 2) out.push(prev + 1);
|
|
202
|
+
else if (n - prev > 2) out.push(null);
|
|
203
|
+
}
|
|
204
|
+
out.push(n);
|
|
205
|
+
}
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
function Pagination({
|
|
209
|
+
page = 1,
|
|
210
|
+
pageSize,
|
|
211
|
+
total = null,
|
|
212
|
+
hasMore = false,
|
|
213
|
+
pageSizes = null,
|
|
214
|
+
variant = "steps",
|
|
215
|
+
label = "Pagination",
|
|
216
|
+
loading = false,
|
|
217
|
+
id,
|
|
218
|
+
onPageChange,
|
|
219
|
+
onPageSizeChange
|
|
182
220
|
}) {
|
|
183
|
-
const
|
|
184
|
-
|
|
221
|
+
const auto = useId();
|
|
222
|
+
const [draft, setDraft] = useState("");
|
|
223
|
+
const [drafting, setDrafting] = useState(false);
|
|
224
|
+
const nav = useRef2(null);
|
|
225
|
+
const pressed = useRef2(null);
|
|
226
|
+
const uid = id ?? auto;
|
|
227
|
+
const kind = VARIANTS.includes(variant) ? variant : "steps";
|
|
228
|
+
const size = sizeOf(pageSize, DEFAULT_PAGE_SIZE);
|
|
229
|
+
const asRows = int(total, null);
|
|
230
|
+
const counted = total != null && asRows !== null;
|
|
231
|
+
const rows = counted ? Math.max(0, asRows) : null;
|
|
232
|
+
const last = counted ? Math.max(1, Math.ceil(rows / size)) : null;
|
|
233
|
+
const at = counted ? Math.min(Math.max(1, int(page, 1)), last) : Math.min(Math.max(1, int(page, 1)), CAP - 1);
|
|
234
|
+
const [draftFor, setDraftFor] = useState(at);
|
|
235
|
+
if (draftFor !== at) {
|
|
236
|
+
setDraftFor(at);
|
|
237
|
+
setDraft("");
|
|
238
|
+
setDrafting(false);
|
|
239
|
+
}
|
|
240
|
+
const offered = (Array.isArray(pageSizes) ? pageSizes : []).slice(0, 12).map((s) => int(s, 0)).filter((s) => s > 0);
|
|
241
|
+
const sizes = offered.length ? [.../* @__PURE__ */ new Set([...offered, size])].sort((a, b) => a - b) : [];
|
|
242
|
+
useEffect2(() => {
|
|
243
|
+
const was = pressed.current;
|
|
244
|
+
if (!was || loading) return;
|
|
245
|
+
pressed.current = null;
|
|
246
|
+
const lost = document.activeElement === document.body || document.activeElement === was;
|
|
247
|
+
if (!lost || !nav.current?.contains(was)) return;
|
|
248
|
+
if (!was.disabled) {
|
|
249
|
+
was.focus();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const strip = [...nav.current.querySelectorAll(".ui-pager__step")];
|
|
253
|
+
const from2 = strip.indexOf(was);
|
|
254
|
+
for (let d = 1; d < strip.length; d += 1) {
|
|
255
|
+
const near = [strip[from2 - d], strip[from2 + d]].find((el) => el && !el.disabled);
|
|
256
|
+
if (near) {
|
|
257
|
+
near.focus();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}, [at, loading]);
|
|
262
|
+
const single = counted && last === 1;
|
|
263
|
+
if (single && !sizes.length) return null;
|
|
264
|
+
const from = (at - 1) * size + 1;
|
|
265
|
+
const to = counted ? Math.min(at * size, rows) : null;
|
|
266
|
+
const status = !counted ? `Page ${fmt(at)}` : rows === 0 ? "0 of 0" : from === to ? `${fmt(from)} of ${fmt(rows)}` : `${fmt(from)}\u2013${fmt(to)} of ${fmt(rows)}`;
|
|
267
|
+
const go = (n) => onPageChange?.(n);
|
|
268
|
+
const step = (label_, target, disabled) => (
|
|
269
|
+
// A control at an end is disabled and stays where it is: removing it slides
|
|
270
|
+
// the next control under a pointer already travelling toward it.
|
|
271
|
+
/* @__PURE__ */ jsx6(
|
|
272
|
+
"button",
|
|
273
|
+
{
|
|
274
|
+
type: "button",
|
|
275
|
+
className: `${GHOST_SM} ui-pager__step`,
|
|
276
|
+
"data-page": target,
|
|
277
|
+
disabled: loading || disabled,
|
|
278
|
+
"aria-disabled": loading || disabled ? true : void 0,
|
|
279
|
+
onClick: (e) => {
|
|
280
|
+
pressed.current = e.currentTarget;
|
|
281
|
+
go(target);
|
|
282
|
+
},
|
|
283
|
+
children: label_
|
|
284
|
+
},
|
|
285
|
+
label_
|
|
286
|
+
)
|
|
185
287
|
);
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const onSort = (k) => {
|
|
196
|
-
setSort((s) => s.key === k ? { key: k, dir: s.dir === 1 ? -1 : 1 } : { key: k, dir: -1 });
|
|
197
|
-
setPage(0);
|
|
288
|
+
const atStart = at === 1;
|
|
289
|
+
const atEnd = counted && at === last;
|
|
290
|
+
const ends = kind !== "numbered";
|
|
291
|
+
const commitJump = () => {
|
|
292
|
+
setDrafting(false);
|
|
293
|
+
const typed = draft.trim();
|
|
294
|
+
if (typed === "") return;
|
|
295
|
+
const n = Math.min(Math.max(1, int(typed, at)), last);
|
|
296
|
+
if (n !== at) go(n);
|
|
198
297
|
};
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
298
|
+
const leaveJump = (to2) => {
|
|
299
|
+
if (to2 && nav.current?.contains(to2)) {
|
|
300
|
+
setDrafting(false);
|
|
301
|
+
setDraft("");
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
commitJump();
|
|
305
|
+
};
|
|
306
|
+
let steps = null;
|
|
307
|
+
if (single) {
|
|
308
|
+
steps = null;
|
|
309
|
+
} else if (!counted) {
|
|
310
|
+
steps = /* @__PURE__ */ jsxs4("div", { className: "ui-pager__steps", children: [
|
|
311
|
+
step("Prev", Math.max(1, at - 1), atStart),
|
|
312
|
+
step("Next", at + 1, !hasMore)
|
|
313
|
+
] });
|
|
314
|
+
} else {
|
|
315
|
+
let middle = null;
|
|
316
|
+
if (kind === "numbered") {
|
|
317
|
+
middle = slotsFor(at, last).map((n, i) => n == null ? /* @__PURE__ */ jsx6("span", { className: "ui-pager__gap", "aria-hidden": "true", children: "\u2026" }, `gap${i}`) : /* @__PURE__ */ jsx6(
|
|
318
|
+
"button",
|
|
319
|
+
{
|
|
320
|
+
type: "button",
|
|
321
|
+
"data-page": n,
|
|
322
|
+
className: cx2(`${GHOST_SM} ui-pager__page`, n === at && "is-current"),
|
|
323
|
+
"aria-current": n === at ? "page" : void 0,
|
|
324
|
+
disabled: loading,
|
|
325
|
+
"aria-disabled": loading ? true : void 0,
|
|
326
|
+
onClick: () => go(n),
|
|
327
|
+
children: fmt(n)
|
|
328
|
+
},
|
|
329
|
+
n
|
|
330
|
+
));
|
|
331
|
+
} else if (kind === "jump") {
|
|
332
|
+
middle = /* @__PURE__ */ jsxs4("span", { className: "ui-pager__jump", children: [
|
|
333
|
+
/* @__PURE__ */ jsx6("label", { htmlFor: `${uid}-jump`, children: "Page" }),
|
|
334
|
+
/* @__PURE__ */ jsx6(
|
|
205
335
|
"input",
|
|
206
336
|
{
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
337
|
+
className: "ui-input ui-pager__jump-input",
|
|
338
|
+
id: `${uid}-jump`,
|
|
339
|
+
type: "number",
|
|
340
|
+
min: 1,
|
|
341
|
+
max: last,
|
|
342
|
+
disabled: loading,
|
|
343
|
+
value: drafting ? draft : String(at),
|
|
344
|
+
onChange: (e) => {
|
|
345
|
+
setDrafting(true);
|
|
346
|
+
setDraft(e.target.value);
|
|
347
|
+
},
|
|
348
|
+
onBlur: (e) => leaveJump(e.relatedTarget),
|
|
349
|
+
onKeyDown: (e) => {
|
|
350
|
+
if (e.key === "Enter") {
|
|
351
|
+
e.preventDefault();
|
|
352
|
+
commitJump();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
211
355
|
}
|
|
212
|
-
)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
356
|
+
),
|
|
357
|
+
/* @__PURE__ */ jsxs4("span", { className: "ui-pager__jump-of", children: [
|
|
358
|
+
"of ",
|
|
359
|
+
fmt(last)
|
|
360
|
+
] })
|
|
361
|
+
] });
|
|
362
|
+
}
|
|
363
|
+
steps = /* @__PURE__ */ jsxs4("div", { className: "ui-pager__steps", children: [
|
|
364
|
+
ends ? step("First", 1, atStart) : null,
|
|
365
|
+
step("Prev", Math.max(1, at - 1), atStart),
|
|
366
|
+
middle,
|
|
367
|
+
step("Next", Math.min(last, at + 1), atEnd),
|
|
368
|
+
ends ? step("Last", last, atEnd) : null
|
|
369
|
+
] });
|
|
370
|
+
}
|
|
371
|
+
return /* @__PURE__ */ jsxs4(
|
|
372
|
+
"nav",
|
|
373
|
+
{
|
|
374
|
+
ref: nav,
|
|
375
|
+
className: cx2("ui-pager", `ui-pager--${kind}`, !counted && "ui-pager--open", single && "ui-pager--single"),
|
|
376
|
+
"aria-label": label,
|
|
377
|
+
"aria-busy": loading ? true : void 0,
|
|
378
|
+
children: [
|
|
379
|
+
/* @__PURE__ */ jsx6("p", { className: "ui-pager__status", "aria-live": "polite", "aria-atomic": "true", children: status }),
|
|
380
|
+
sizes.length ? /* @__PURE__ */ jsxs4("div", { className: "ui-pager__size", children: [
|
|
381
|
+
/* @__PURE__ */ jsx6("label", { className: "ui-pager__size-label", htmlFor: `${uid}-size`, children: "Rows" }),
|
|
217
382
|
/* @__PURE__ */ jsx6(
|
|
218
|
-
"
|
|
383
|
+
"select",
|
|
219
384
|
{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
},
|
|
228
|
-
c.key
|
|
385
|
+
className: "ui-select ui-pager__size-select",
|
|
386
|
+
id: `${uid}-size`,
|
|
387
|
+
disabled: loading,
|
|
388
|
+
value: size,
|
|
389
|
+
onChange: (e) => onPageSizeChange?.(Number(e.target.value)),
|
|
390
|
+
children: sizes.map((s) => /* @__PURE__ */ jsx6("option", { value: s, children: fmt(s) }, s))
|
|
391
|
+
}
|
|
229
392
|
)
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
393
|
+
] }) : null,
|
|
394
|
+
steps
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// src/DataTable.tsx
|
|
401
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
402
|
+
var NO_SORT = { key: void 0, dir: -1 };
|
|
403
|
+
function sortTableRows(rows, sort) {
|
|
404
|
+
if (sort.key === void 0) return [...rows];
|
|
405
|
+
const key = sort.key;
|
|
406
|
+
return [...rows].sort((a, b) => (a[key] > b[key] ? 1 : a[key] < b[key] ? -1 : 0) * sort.dir);
|
|
407
|
+
}
|
|
408
|
+
function DataTable({
|
|
409
|
+
columns,
|
|
410
|
+
rows,
|
|
411
|
+
pageSize,
|
|
412
|
+
pageSizes = null,
|
|
413
|
+
onPageSizeChange,
|
|
414
|
+
pager = true,
|
|
415
|
+
pagerLabel,
|
|
416
|
+
loading = false,
|
|
417
|
+
selectable = true,
|
|
418
|
+
selected = /* @__PURE__ */ new Set(),
|
|
419
|
+
onToggle = () => {
|
|
420
|
+
},
|
|
421
|
+
onTogglePage = () => {
|
|
422
|
+
},
|
|
423
|
+
sort: controlledSort,
|
|
424
|
+
onSortChange,
|
|
425
|
+
page: controlledPage,
|
|
426
|
+
onPageChange,
|
|
427
|
+
total,
|
|
428
|
+
hasMore = false
|
|
429
|
+
}) {
|
|
430
|
+
const [localSort, setLocalSort] = useState2(
|
|
431
|
+
{ key: columns.find((c) => c.sortable)?.key, dir: -1 }
|
|
432
|
+
);
|
|
433
|
+
const owned = controlledPage === void 0;
|
|
434
|
+
const sort = controlledSort ?? (owned ? localSort : NO_SORT);
|
|
435
|
+
const sortIsKnown = owned || controlledSort !== void 0;
|
|
436
|
+
const [localPage, setLocalPage] = useState2(1);
|
|
437
|
+
const [localSize, setLocalSize] = useState2(DEFAULT_PAGE_SIZE2);
|
|
438
|
+
const size = sizeOf(pageSize, owned ? localSize : rows.length || DEFAULT_PAGE_SIZE2);
|
|
439
|
+
const [pagedSort, setPagedSort] = useState2(sort);
|
|
440
|
+
if (pagedSort.key !== sort.key || pagedSort.dir !== sort.dir) {
|
|
441
|
+
setPagedSort(sort);
|
|
442
|
+
setLocalPage(1);
|
|
443
|
+
}
|
|
444
|
+
const ordered = useMemo(
|
|
445
|
+
() => owned ? sortTableRows(rows, sort) : rows,
|
|
446
|
+
[owned, rows, sort.key, sort.dir]
|
|
447
|
+
);
|
|
448
|
+
const pages = Math.max(1, Math.ceil(ordered.length / size));
|
|
449
|
+
const page = owned ? Math.min(Math.max(1, localPage), pages) : controlledPage;
|
|
450
|
+
const slice = owned ? ordered.slice((page - 1) * size, page * size) : ordered;
|
|
451
|
+
const goTo = (n) => owned ? setLocalPage(n) : onPageChange?.(n);
|
|
452
|
+
const toFirstPage = () => {
|
|
453
|
+
if (owned) setLocalPage(1);
|
|
454
|
+
else if (page !== 1) onPageChange?.(1);
|
|
455
|
+
};
|
|
456
|
+
const onSort = (key) => {
|
|
457
|
+
const next = sort.key === key ? { key, dir: sort.dir === 1 ? -1 : 1 } : { key, dir: -1 };
|
|
458
|
+
if (controlledSort === void 0) setLocalSort(next);
|
|
459
|
+
onSortChange?.(next);
|
|
460
|
+
toFirstPage();
|
|
461
|
+
};
|
|
462
|
+
const caret = (k) => sort.key === k ? sort.dir === 1 ? " \u25B2" : " \u25BC" : " \u2195";
|
|
463
|
+
const pageAllOn = selectable && slice.length > 0 && slice.every((r) => selected.has(r.name));
|
|
464
|
+
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
465
|
+
/* @__PURE__ */ jsxs5(
|
|
466
|
+
"table",
|
|
467
|
+
{
|
|
468
|
+
className: "ui-table ui-table--hover ui-table--zebra",
|
|
469
|
+
"aria-busy": loading || void 0,
|
|
470
|
+
children: [
|
|
471
|
+
/* @__PURE__ */ jsx7("thead", { children: /* @__PURE__ */ jsxs5("tr", { children: [
|
|
472
|
+
selectable ? /* @__PURE__ */ jsx7("th", { scope: "col", children: /* @__PURE__ */ jsx7(
|
|
473
|
+
"input",
|
|
474
|
+
{
|
|
475
|
+
type: "checkbox",
|
|
476
|
+
checked: pageAllOn,
|
|
477
|
+
"aria-label": "Select all rows on this page",
|
|
478
|
+
onChange: () => onTogglePage(slice.map((r) => r.name))
|
|
479
|
+
}
|
|
480
|
+
) }) : null,
|
|
481
|
+
columns.map((c) => (
|
|
482
|
+
// The sort control is a real <button> inside the header cell. It used to be
|
|
483
|
+
// role="button" ON the <th>, which threw away the columnheader role and put
|
|
484
|
+
// aria-sort on a role that forbids it.
|
|
485
|
+
/* @__PURE__ */ jsx7(
|
|
486
|
+
"th",
|
|
487
|
+
{
|
|
488
|
+
scope: "col",
|
|
489
|
+
className: [c.num && "ui-table__num", c.sortable && "rx-sortable"].filter(Boolean).join(" "),
|
|
490
|
+
"aria-sort": sort.key === c.key ? sort.dir === 1 ? "ascending" : "descending" : c.sortable && sortIsKnown ? "none" : void 0,
|
|
491
|
+
children: c.sortable ? /* @__PURE__ */ jsxs5("button", { type: "button", className: "rx-sort", onClick: () => onSort(c.key), children: [
|
|
492
|
+
c.label,
|
|
493
|
+
/* @__PURE__ */ jsx7("span", { className: "rx-caret", "aria-hidden": "true", children: caret(c.key) })
|
|
494
|
+
] }) : c.label
|
|
495
|
+
},
|
|
496
|
+
c.key
|
|
497
|
+
)
|
|
498
|
+
))
|
|
499
|
+
] }) }),
|
|
500
|
+
/* @__PURE__ */ jsx7("tbody", { children: slice.map((r) => /* @__PURE__ */ jsxs5("tr", { children: [
|
|
501
|
+
selectable ? /* @__PURE__ */ jsx7("td", { children: /* @__PURE__ */ jsx7(
|
|
502
|
+
"input",
|
|
503
|
+
{
|
|
504
|
+
type: "checkbox",
|
|
505
|
+
checked: selected.has(r.name),
|
|
506
|
+
"aria-label": `Select ${r.name}`,
|
|
507
|
+
onChange: () => onToggle(r.name)
|
|
508
|
+
}
|
|
509
|
+
) }) : null,
|
|
510
|
+
columns.map((c) => /* @__PURE__ */ jsx7("td", { className: c.num ? "ui-table__num" : void 0, children: c.render ? c.render(r) : String(r[c.key]) }, c.key))
|
|
511
|
+
] }, r.name)) })
|
|
512
|
+
]
|
|
513
|
+
}
|
|
514
|
+
),
|
|
515
|
+
pager ? /* @__PURE__ */ jsx7(
|
|
516
|
+
Pagination,
|
|
517
|
+
{
|
|
518
|
+
page,
|
|
519
|
+
pageSize: size,
|
|
520
|
+
total: owned ? ordered.length : total ?? null,
|
|
521
|
+
hasMore,
|
|
522
|
+
pageSizes,
|
|
523
|
+
loading,
|
|
524
|
+
...pagerLabel === void 0 ? {} : { label: pagerLabel },
|
|
525
|
+
onPageChange: goTo,
|
|
526
|
+
onPageSizeChange: (s) => {
|
|
527
|
+
if (pageSize === void 0) setLocalSize(s);
|
|
528
|
+
onPageSizeChange?.(s);
|
|
529
|
+
if (owned) setLocalPage(1);
|
|
275
530
|
}
|
|
276
|
-
|
|
277
|
-
|
|
531
|
+
}
|
|
532
|
+
) : null
|
|
278
533
|
] });
|
|
279
534
|
}
|
|
280
535
|
|
|
536
|
+
// src/index.ts
|
|
537
|
+
import { PAGE_SIZES as KIT_PAGE_SIZES, DEFAULT_PAGE_SIZE as KIT_DEFAULT_PAGE_SIZE } from "@apliteni/apliteni-ui";
|
|
538
|
+
|
|
281
539
|
// src/Loading.tsx
|
|
282
|
-
import { jsx as
|
|
283
|
-
var
|
|
540
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
541
|
+
var cx3 = (...a) => a.filter(Boolean).join(" ");
|
|
284
542
|
function Skeleton({ lines = 3, width, height, radius, className }) {
|
|
285
543
|
const widths = Array.isArray(lines) ? lines : null;
|
|
286
544
|
const n = widths ? widths.length : Math.max(1, lines);
|
|
@@ -289,19 +547,19 @@ function Skeleton({ lines = 3, width, height, radius, className }) {
|
|
|
289
547
|
if (!w && !height && !radius) return void 0;
|
|
290
548
|
return { ...w && { width: w }, ...height && { height }, ...radius && { borderRadius: radius } };
|
|
291
549
|
};
|
|
292
|
-
return /* @__PURE__ */
|
|
550
|
+
return /* @__PURE__ */ jsx8("div", { className: cx3("ui-skel", className), "aria-hidden": "true", children: Array.from({ length: n }, (_, i) => /* @__PURE__ */ jsx8("span", { className: "ui-skel__bar m-skeleton", style: styleFor(i) }, i)) });
|
|
293
551
|
}
|
|
294
552
|
function SkeletonTable({ rows = 5, cols = 4, head = true }) {
|
|
295
|
-
const cells = Array.from({ length: Math.max(1, cols) }, (_, i) => /* @__PURE__ */
|
|
296
|
-
return /* @__PURE__ */
|
|
553
|
+
const cells = Array.from({ length: Math.max(1, cols) }, (_, i) => /* @__PURE__ */ jsx8("span", { className: "ui-skel__bar m-skeleton" }, i));
|
|
554
|
+
return /* @__PURE__ */ jsxs6(
|
|
297
555
|
"div",
|
|
298
556
|
{
|
|
299
557
|
className: "ui-skel ui-skel--table",
|
|
300
558
|
style: { "--skel-cols": Math.max(1, cols) },
|
|
301
559
|
"aria-hidden": "true",
|
|
302
560
|
children: [
|
|
303
|
-
head && /* @__PURE__ */
|
|
304
|
-
Array.from({ length: Math.max(1, rows) }, (_, i) => /* @__PURE__ */
|
|
561
|
+
head && /* @__PURE__ */ jsx8("div", { className: "ui-skel__row ui-skel__row--head", children: cells }),
|
|
562
|
+
Array.from({ length: Math.max(1, rows) }, (_, i) => /* @__PURE__ */ jsx8("div", { className: "ui-skel__row", children: cells }, i))
|
|
305
563
|
]
|
|
306
564
|
}
|
|
307
565
|
);
|
|
@@ -314,16 +572,16 @@ function BusyRegion({
|
|
|
314
572
|
className,
|
|
315
573
|
children
|
|
316
574
|
}) {
|
|
317
|
-
return /* @__PURE__ */
|
|
575
|
+
return /* @__PURE__ */ jsxs6(
|
|
318
576
|
"div",
|
|
319
577
|
{
|
|
320
|
-
className:
|
|
578
|
+
className: cx3("ui-busy", className),
|
|
321
579
|
role: "status",
|
|
322
580
|
"aria-live": "polite",
|
|
323
581
|
"aria-busy": busy,
|
|
324
582
|
children: [
|
|
325
|
-
/* @__PURE__ */
|
|
326
|
-
/* @__PURE__ */
|
|
583
|
+
/* @__PURE__ */ jsx8("span", { className: "ui-sr", children: busy ? label : message }),
|
|
584
|
+
/* @__PURE__ */ jsx8("div", { className: "ui-busy__body", children: busy ? placeholder ?? /* @__PURE__ */ jsx8(Skeleton, { lines: 3 }) : children })
|
|
327
585
|
]
|
|
328
586
|
}
|
|
329
587
|
);
|
|
@@ -336,26 +594,34 @@ function Denied({
|
|
|
336
594
|
className,
|
|
337
595
|
children
|
|
338
596
|
}) {
|
|
339
|
-
return /* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
341
|
-
/* @__PURE__ */
|
|
342
|
-
sub && /* @__PURE__ */
|
|
343
|
-
need && /* @__PURE__ */
|
|
597
|
+
return /* @__PURE__ */ jsxs6("div", { className: cx3("ui-denied", className), children: [
|
|
598
|
+
/* @__PURE__ */ jsx8("div", { className: "ui-denied__seal", children: /* @__PURE__ */ jsx8(Icon, { name: icon2 }) }),
|
|
599
|
+
/* @__PURE__ */ jsx8("div", { className: "ui-denied__title", children: title }),
|
|
600
|
+
sub && /* @__PURE__ */ jsx8("div", { className: "ui-denied__sub", children: sub }),
|
|
601
|
+
need && /* @__PURE__ */ jsxs6("div", { className: "ui-denied__need", children: [
|
|
344
602
|
"Needs ",
|
|
345
|
-
/* @__PURE__ */
|
|
603
|
+
/* @__PURE__ */ jsx8("code", { className: "ui-code", children: need })
|
|
346
604
|
] }),
|
|
347
|
-
children && /* @__PURE__ */
|
|
605
|
+
children && /* @__PURE__ */ jsx8("div", { className: "ui-denied__actions", children })
|
|
348
606
|
] });
|
|
349
607
|
}
|
|
608
|
+
|
|
609
|
+
// src/index.ts
|
|
610
|
+
var PAGE_SIZES = KIT_PAGE_SIZES;
|
|
611
|
+
var DEFAULT_PAGE_SIZE3 = KIT_DEFAULT_PAGE_SIZE;
|
|
350
612
|
export {
|
|
351
613
|
Badge,
|
|
352
614
|
BusyRegion,
|
|
353
615
|
Button,
|
|
354
616
|
Card,
|
|
617
|
+
DEFAULT_PAGE_SIZE3 as DEFAULT_PAGE_SIZE,
|
|
355
618
|
DataTable,
|
|
356
619
|
Denied,
|
|
357
620
|
Icon,
|
|
358
621
|
Modal,
|
|
622
|
+
PAGE_SIZES,
|
|
623
|
+
Pagination,
|
|
359
624
|
Skeleton,
|
|
360
|
-
SkeletonTable
|
|
625
|
+
SkeletonTable,
|
|
626
|
+
sortTableRows
|
|
361
627
|
};
|