@seanyeh77/ui 0.22.0 → 0.24.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/dist/bundle.js +18 -18
- package/dist/bundle.js.map +1 -1
- package/dist/{format-entry-CKLBdBpY.js → format-entry-CwOAT4YT.js} +19 -1
- package/dist/format-entry-CwOAT4YT.js.map +1 -0
- package/dist/format.js +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +435 -108
- package/dist/index.js.map +1 -1
- package/dist/styles.css +285 -17
- package/docs/Card.md +7 -1
- package/docs/DataTable.md +19 -3
- package/docs/InlineCode.md +1 -0
- package/docs/guidelines.md +2 -2
- package/package.json +2 -2
- package/dist/format-entry-CKLBdBpY.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-
|
|
2
|
+
import { a as parseDate, c as addMessages, d as unitFor, i as format, l as setLocale, n as fileSize, o as sameDay, r as fmtDate, s as I18N, t as dayAdd, u as tr } from "./format-entry-CwOAT4YT.js";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
|
|
6
6
|
import { Dialog as Dialog$1 } from "@base-ui/react/dialog";
|
|
7
7
|
import { Menu as Menu$1 } from "@base-ui/react/menu";
|
|
8
8
|
import { PreviewCard } from "@base-ui/react/preview-card";
|
|
9
|
+
import { createPortal } from "react-dom";
|
|
9
10
|
import { Popover as Popover$1 } from "@base-ui/react/popover";
|
|
10
11
|
import { Combobox } from "@base-ui/react/combobox";
|
|
11
12
|
import { Select as Select$1 } from "@base-ui/react/select";
|
|
@@ -104,7 +105,9 @@ const PH = {
|
|
|
104
105
|
"file-code": "<path d=\"M181.66,146.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32-11.32L164.69,152l-18.35-18.34a8,8,0,0,1,11.32-11.32Zm-72-24a8,8,0,0,0-11.32,0l-24,24a8,8,0,0,0,0,11.32l24,24a8,8,0,0,0,11.32-11.32L91.31,152l18.35-18.34A8,8,0,0,0,109.66,122.34ZM216,88V216a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-56-8h28.69L160,51.31Zm40,136V96H152a8,8,0,0,1-8-8V40H56V216H200Z\"/>",
|
|
105
106
|
hash: "<path d=\"M224,88H175.4l8.47-46.57a8,8,0,0,0-15.74-2.86l-9,49.43H111.4l8.47-46.57a8,8,0,0,0-15.74-2.86L95.14,88H48a8,8,0,0,0,0,16H92.23L83.5,152H32a8,8,0,0,0,0,16H80.6l-8.47,46.57a8,8,0,0,0,6.44,9.3A7.79,7.79,0,0,0,80,224a8,8,0,0,0,7.86-6.57l9-49.43H144.6l-8.47,46.57a8,8,0,0,0,6.44,9.3A7.79,7.79,0,0,0,144,224a8,8,0,0,0,7.86-6.57l9-49.43H208a8,8,0,0,0,0-16H163.77l8.73-48H224a8,8,0,0,0,0-16Zm-76.5,64H99.77l8.73-48h47.73Z\"/>",
|
|
106
107
|
command: "<path d=\"M180,144H160V112h20a36,36,0,1,0-36-36V96H112V76a36,36,0,1,0-36,36H96v32H76a36,36,0,1,0,36,36V160h32v20a36,36,0,1,0,36-36ZM160,76a20,20,0,1,1,20,20H160ZM56,76a20,20,0,0,1,40,0V96H76A20,20,0,0,1,56,76ZM96,180a20,20,0,1,1-20-20H96Zm16-68h32v32H112Zm68,88a20,20,0,0,1-20-20V160h20a20,20,0,0,1,0,40Z\"/>",
|
|
107
|
-
tag: "<path d=\"M243.31,136,144,36.69A15.86,15.86,0,0,0,132.69,32H40a8,8,0,0,0-8,8v92.69A15.86,15.86,0,0,0,36.69,144L136,243.31a16,16,0,0,0,22.63,0l84.68-84.68a16,16,0,0,0,0-22.63Zm-96,96L48,132.69V48h84.69L232,147.31ZM96,84A12,12,0,1,1,84,72,12,12,0,0,1,96,84Z\"/>"
|
|
108
|
+
tag: "<path d=\"M243.31,136,144,36.69A15.86,15.86,0,0,0,132.69,32H40a8,8,0,0,0-8,8v92.69A15.86,15.86,0,0,0,36.69,144L136,243.31a16,16,0,0,0,22.63,0l84.68-84.68a16,16,0,0,0,0-22.63Zm-96,96L48,132.69V48h84.69L232,147.31ZM96,84A12,12,0,1,1,84,72,12,12,0,0,1,96,84Z\"/>",
|
|
109
|
+
"sort-ascending": "<path d=\"M128,128a8,8,0,0,1-8,8H48a8,8,0,0,1,0-16h72A8,8,0,0,1,128,128ZM48,72H184a8,8,0,0,0,0-16H48a8,8,0,0,0,0,16Zm56,112H48a8,8,0,0,0,0,16h56a8,8,0,0,0,0-16Zm125.66-21.66a8,8,0,0,0-11.32,0L192,188.69V112a8,8,0,0,0-16,0v76.69l-26.34-26.35a8,8,0,0,0-11.32,11.32l40,40a8,8,0,0,0,11.32,0l40-40A8,8,0,0,0,229.66,162.34Z\"/>",
|
|
110
|
+
"dots-six-vertical": "<path d=\"M104,60A12,12,0,1,1,92,48,12,12,0,0,1,104,60Zm60,12a12,12,0,1,0-12-12A12,12,0,0,0,164,72ZM92,116a12,12,0,1,0,12,12A12,12,0,0,0,92,116Zm72,0a12,12,0,1,0,12,12A12,12,0,0,0,164,116ZM92,184a12,12,0,1,0,12,12A12,12,0,0,0,92,184Zm72,0a12,12,0,1,0,12,12A12,12,0,0,0,164,184Z\"/>"
|
|
108
111
|
};
|
|
109
112
|
const PH_FILL = {
|
|
110
113
|
archive: "<path d=\"M224,48H32A16,16,0,0,0,16,64V88a16,16,0,0,0,16,16v88a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V104a16,16,0,0,0,16-16V64A16,16,0,0,0,224,48Zm-72,96H104a8,8,0,0,1,0-16h48a8,8,0,0,1,0,16Zm72-56H32V64H224V88Z\"/>",
|
|
@@ -200,7 +203,9 @@ const PH_FILL = {
|
|
|
200
203
|
"file-code": "<path d=\"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34Zm-104,88a8,8,0,0,1-11.32,11.32l-24-24a8,8,0,0,1,0-11.32l24-24a8,8,0,0,1,11.32,11.32L91.31,152Zm72-12.68-24,24a8,8,0,0,1-11.32-11.32L164.69,152l-18.35-18.34a8,8,0,0,1,11.32-11.32l24,24A8,8,0,0,1,181.66,157.66ZM152,88V44l44,44Z\"/>",
|
|
201
204
|
hash: "<path d=\"M116.25,112h31.5l-8,32h-31.5ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48Zm-16,56a8,8,0,0,0-8-8H168.25l7.51-30.06a8,8,0,0,0-15.52-3.88L151.75,96h-31.5l7.51-30.06a8,8,0,0,0-15.52-3.88L103.75,96H64a8,8,0,0,0,0,16H99.75l-8,32H56a8,8,0,0,0,0,16H87.75l-7.51,30.06a8,8,0,0,0,5.82,9.7,8.13,8.13,0,0,0,2,.24,8,8,0,0,0,7.75-6.06L104.25,160h31.5l-7.51,30.06a8,8,0,0,0,5.82,9.7A8.13,8.13,0,0,0,136,200a8,8,0,0,0,7.75-6.06L152.25,160H192a8,8,0,0,0,0-16H156.25l8-32H200A8,8,0,0,0,208,104Z\"/>",
|
|
202
205
|
command: "<path d=\"M116,116h24v24H116ZM86,72a14,14,0,0,0,0,28h14V86A14,14,0,0,0,86,72Zm98,14a14,14,0,0,0-28,0v14h14A14,14,0,0,0,184,86ZM72,170a14,14,0,0,0,28,0V156H86A14,14,0,0,0,72,170ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48Zm-68,92V116h14a30,30,0,1,0-30-30v14H116V86a30,30,0,1,0-30,30h14v24H86a30,30,0,1,0,30,30V156h24v14a30,30,0,1,0,30-30Zm0,30a14,14,0,1,0,14-14H156Z\"/>",
|
|
203
|
-
tag: "<path d=\"M243.31,136,144,36.69A15.86,15.86,0,0,0,132.69,32H40a8,8,0,0,0-8,8v92.69A15.86,15.86,0,0,0,36.69,144L136,243.31a16,16,0,0,0,22.63,0l84.68-84.68a16,16,0,0,0,0-22.63ZM84,96A12,12,0,1,1,96,84,12,12,0,0,1,84,96Z\"/>"
|
|
206
|
+
tag: "<path d=\"M243.31,136,144,36.69A15.86,15.86,0,0,0,132.69,32H40a8,8,0,0,0-8,8v92.69A15.86,15.86,0,0,0,36.69,144L136,243.31a16,16,0,0,0,22.63,0l84.68-84.68a16,16,0,0,0,0-22.63ZM84,96A12,12,0,1,1,96,84,12,12,0,0,1,84,96Z\"/>",
|
|
207
|
+
"sort-ascending": "<path d=\"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM72,72h96a8,8,0,0,1,0,16H72a8,8,0,0,1,0-16Zm40,112H72a8,8,0,0,1,0-16h40a8,8,0,0,1,0,16Zm8-48H72a8,8,0,0,1,0-16h48a8,8,0,0,1,0,16Zm77.66,29.66-24,24a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L160,164.69V120a8,8,0,0,1,16,0v44.69l10.34-10.35a8,8,0,0,1,11.32,11.32Z\"/>",
|
|
208
|
+
"dots-six-vertical": "<path d=\"M192,16H64A16,16,0,0,0,48,32V224a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V32A16,16,0,0,0,192,16ZM100,200a12,12,0,1,1,12-12A12,12,0,0,1,100,200Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,100,140Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,100,80Zm56,120a12,12,0,1,1,12-12A12,12,0,0,1,156,200Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,156,140Zm0-60a12,12,0,1,1,12-12A12,12,0,0,1,156,80Z\"/>"
|
|
204
209
|
};
|
|
205
210
|
/** Lucide names that map to a Phosphor icon. */
|
|
206
211
|
const PH_ALIAS = {
|
|
@@ -3207,10 +3212,11 @@ function ColResize(p) {
|
|
|
3207
3212
|
}
|
|
3208
3213
|
});
|
|
3209
3214
|
}
|
|
3210
|
-
/** The 「放大表格」 icon: 32 px, no border, at
|
|
3211
|
-
|
|
3215
|
+
/** The 「放大表格」 icon: 32 px, no border, at a Markdown table's top right; in a DataTable's toolbar (inToolbar) it is a
|
|
3216
|
+
* toolbar button like 「複製成 Markdown」. */
|
|
3217
|
+
function ZoomButton({ onClick, inToolbar }) {
|
|
3212
3218
|
return /* @__PURE__ */ jsx(IconButton, {
|
|
3213
|
-
className: "ui-table-zoom",
|
|
3219
|
+
className: inToolbar ? "ui-dt-zoombtn" : "ui-table-zoom",
|
|
3214
3220
|
icon: "corners-out",
|
|
3215
3221
|
label: tr("放大表格"),
|
|
3216
3222
|
onClick
|
|
@@ -3367,6 +3373,27 @@ function writeUrl(prefix, filters, values, q) {
|
|
|
3367
3373
|
const s = sp.toString();
|
|
3368
3374
|
history.replaceState(history.state, "", location.pathname + (s ? "?" + s : "") + location.hash);
|
|
3369
3375
|
}
|
|
3376
|
+
/** The sort from the URL (?sort=prog,-dt: in order, a leading - is descending); null when the URL has none. */
|
|
3377
|
+
function readSort(prefix) {
|
|
3378
|
+
const v = new URLSearchParams(location.search).get(param(prefix, "sort"));
|
|
3379
|
+
if (v == null) return null;
|
|
3380
|
+
return v.split(",").filter(Boolean).map((t) => t.startsWith("-") ? {
|
|
3381
|
+
key: t.slice(1),
|
|
3382
|
+
dir: "desc"
|
|
3383
|
+
} : {
|
|
3384
|
+
key: t,
|
|
3385
|
+
dir: "asc"
|
|
3386
|
+
});
|
|
3387
|
+
}
|
|
3388
|
+
/** Writes the sort into the URL without a history entry; nothing when it is the table's default. */
|
|
3389
|
+
function writeSort(prefix, levels, initial) {
|
|
3390
|
+
const sp = new URLSearchParams(location.search);
|
|
3391
|
+
const text = (l) => l.map((s) => (s.dir === "desc" ? "-" : "") + s.key).join(",");
|
|
3392
|
+
if (text(levels) === text(initial)) sp.delete(param(prefix, "sort"));
|
|
3393
|
+
else sp.set(param(prefix, "sort"), text(levels));
|
|
3394
|
+
const s = sp.toString();
|
|
3395
|
+
history.replaceState(history.state, "", location.pathname + (s ? "?" + s : "") + location.hash);
|
|
3396
|
+
}
|
|
3370
3397
|
// src/internal/FloatingPanel.tsx
|
|
3371
3398
|
/** A positioned panel next to its trigger: flips when there is no room, closes on Esc and outside press, returns focus. */
|
|
3372
3399
|
function FloatingPanel({ open, onOpenChange, trigger, side = "bottom", align = "start", sideOffset = 6, className, openOnHover, anchor, boundary, children, ...aria }) {
|
|
@@ -3426,10 +3453,14 @@ function ColumnMenu({ cols, hidden, onToggle }) {
|
|
|
3426
3453
|
trigger: /* @__PURE__ */ jsxs("button", {
|
|
3427
3454
|
type: "button",
|
|
3428
3455
|
className: cx("ui-btn", "ui-btn-secondary", "ui-dt-colbtn", open && "is-open"),
|
|
3456
|
+
"aria-label": tr("欄位"),
|
|
3429
3457
|
children: [/* @__PURE__ */ jsx(Icon, {
|
|
3430
3458
|
name: "columns",
|
|
3431
3459
|
size: 18
|
|
3432
|
-
}),
|
|
3460
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
3461
|
+
className: "ui-dt-btntext",
|
|
3462
|
+
children: tr("欄位")
|
|
3463
|
+
})]
|
|
3433
3464
|
}),
|
|
3434
3465
|
children: [/* @__PURE__ */ jsx("div", {
|
|
3435
3466
|
className: "ui-noti-group",
|
|
@@ -3472,7 +3503,10 @@ function FilterButton({ filters, values, activeCount, count, onChange, onClear,
|
|
|
3472
3503
|
name: "funnel",
|
|
3473
3504
|
size: 18
|
|
3474
3505
|
}),
|
|
3475
|
-
|
|
3506
|
+
/* @__PURE__ */ jsx("span", {
|
|
3507
|
+
className: "ui-dt-btntext",
|
|
3508
|
+
children: tr("篩選")
|
|
3509
|
+
}),
|
|
3476
3510
|
activeCount ? /* @__PURE__ */ jsx("span", {
|
|
3477
3511
|
className: "ui-pop-count",
|
|
3478
3512
|
children: activeCount
|
|
@@ -3640,6 +3674,218 @@ function LongText({ children }) {
|
|
|
3640
3674
|
children: body
|
|
3641
3675
|
});
|
|
3642
3676
|
}
|
|
3677
|
+
// src/components/DataTable/SortButton.tsx
|
|
3678
|
+
/** 「由小到大」 or 「由大到小」. */
|
|
3679
|
+
const dirWord = (dir) => dir === "asc" ? tr("由小到大") : tr("由大到小");
|
|
3680
|
+
const ARROW = {
|
|
3681
|
+
asc: "↑",
|
|
3682
|
+
desc: "↓"
|
|
3683
|
+
};
|
|
3684
|
+
/** The whole sort read out: 「依 程式 由小到大,再依 ΔT 由大到小排序」. */
|
|
3685
|
+
function sortSentence(levels, cols) {
|
|
3686
|
+
if (!levels.length) return tr("已還原原本的順序");
|
|
3687
|
+
const name = (k) => cols.find((c) => c.key === k)?.label ?? k;
|
|
3688
|
+
return tr("依 {list} 排序", { list: levels.map((l) => name(l.key) + " " + dirWord(l.dir)).join(tr(",再依 ")) });
|
|
3689
|
+
}
|
|
3690
|
+
/** The toolbar's 「排序」 button: it shows the current sort and opens a panel to add, order, flip and remove levels. */
|
|
3691
|
+
function SortButton({ cols, levels, max, onChange, boundary }) {
|
|
3692
|
+
const [open, setOpen] = React.useState(false);
|
|
3693
|
+
const [adding, setAdding] = React.useState(false);
|
|
3694
|
+
const [drag, setDrag] = React.useState(null);
|
|
3695
|
+
const listRef = React.useRef(null);
|
|
3696
|
+
const firstAdd = React.useRef(null);
|
|
3697
|
+
const addId = React.useId();
|
|
3698
|
+
React.useEffect(() => {
|
|
3699
|
+
if (adding) firstAdd.current?.focus();
|
|
3700
|
+
}, [adding]);
|
|
3701
|
+
const name = (k) => cols.find((c) => c.key === k)?.label ?? k;
|
|
3702
|
+
const first = (k) => cols.find((c) => c.key === k)?.numeric ? "desc" : "asc";
|
|
3703
|
+
const rest = cols.filter((c) => !levels.some((l) => l.key === c.key));
|
|
3704
|
+
const move = (from, to, focus) => {
|
|
3705
|
+
if (to < 0 || to >= levels.length || from === to) return;
|
|
3706
|
+
const next = levels.slice();
|
|
3707
|
+
next.splice(to, 0, next.splice(from, 1)[0]);
|
|
3708
|
+
onChange(next);
|
|
3709
|
+
if (focus) requestAnimationFrame(() => listRef.current?.querySelectorAll(".ui-dt-sortgrip")[to]?.focus());
|
|
3710
|
+
};
|
|
3711
|
+
const shown = levels.map((l) => name(l.key) + " " + ARROW[l.dir]).join(tr("、"));
|
|
3712
|
+
const read = levels.map((l) => name(l.key) + " " + dirWord(l.dir)).join(tr("、"));
|
|
3713
|
+
return /* @__PURE__ */ jsxs(FloatingPanel, {
|
|
3714
|
+
open,
|
|
3715
|
+
onOpenChange: (o) => {
|
|
3716
|
+
setOpen(o);
|
|
3717
|
+
if (!o) setAdding(false);
|
|
3718
|
+
},
|
|
3719
|
+
boundary,
|
|
3720
|
+
className: "ui-dt-sortpop",
|
|
3721
|
+
"aria-label": tr("排序"),
|
|
3722
|
+
trigger: /* @__PURE__ */ jsxs("button", {
|
|
3723
|
+
type: "button",
|
|
3724
|
+
className: cx("ui-btn", "ui-btn-secondary", "ui-dt-sortbtn", open && "is-open", levels.length > 0 && "is-on"),
|
|
3725
|
+
"aria-label": levels.length ? tr("排序:{list}", { list: read }) : tr("排序"),
|
|
3726
|
+
children: [
|
|
3727
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
3728
|
+
name: "sort-ascending",
|
|
3729
|
+
size: 18
|
|
3730
|
+
}),
|
|
3731
|
+
/* @__PURE__ */ jsx("span", {
|
|
3732
|
+
className: "ui-dt-sortbtn-text",
|
|
3733
|
+
children: levels.length ? tr("排序:{list}", { list: shown }) : tr("排序")
|
|
3734
|
+
}),
|
|
3735
|
+
levels.length ? /* @__PURE__ */ jsxs("span", {
|
|
3736
|
+
className: "ui-dt-sortbtn-short",
|
|
3737
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3738
|
+
className: "ui-dt-btntext",
|
|
3739
|
+
children: tr("排序")
|
|
3740
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
3741
|
+
className: "ui-pop-count",
|
|
3742
|
+
children: levels.length
|
|
3743
|
+
})]
|
|
3744
|
+
}) : null
|
|
3745
|
+
]
|
|
3746
|
+
}),
|
|
3747
|
+
children: [
|
|
3748
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3749
|
+
className: "ui-dt-filterhead",
|
|
3750
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3751
|
+
className: "ui-popover-title",
|
|
3752
|
+
children: tr("排序")
|
|
3753
|
+
}), levels.length ? /* @__PURE__ */ jsx("button", {
|
|
3754
|
+
type: "button",
|
|
3755
|
+
className: "ui-link-btn",
|
|
3756
|
+
onClick: () => onChange([]),
|
|
3757
|
+
children: tr("清除全部")
|
|
3758
|
+
}) : null]
|
|
3759
|
+
}),
|
|
3760
|
+
levels.length ? /* @__PURE__ */ jsx("ol", {
|
|
3761
|
+
className: "ui-dt-sortlist",
|
|
3762
|
+
ref: listRef,
|
|
3763
|
+
children: levels.map((l, i) => /* @__PURE__ */ jsxs("li", {
|
|
3764
|
+
className: cx("ui-dt-sortlvl", drag?.from === i && "is-dragging", drag && drag.over === i && drag.from !== i && "is-over"),
|
|
3765
|
+
draggable: true,
|
|
3766
|
+
onDragStart: (e) => {
|
|
3767
|
+
e.dataTransfer.effectAllowed = "move";
|
|
3768
|
+
e.dataTransfer.setData("text/plain", String(i));
|
|
3769
|
+
setDrag({
|
|
3770
|
+
from: i,
|
|
3771
|
+
over: i
|
|
3772
|
+
});
|
|
3773
|
+
},
|
|
3774
|
+
onDragOver: (e) => {
|
|
3775
|
+
e.preventDefault();
|
|
3776
|
+
if (drag && drag.over !== i) setDrag({
|
|
3777
|
+
...drag,
|
|
3778
|
+
over: i
|
|
3779
|
+
});
|
|
3780
|
+
},
|
|
3781
|
+
onDrop: (e) => {
|
|
3782
|
+
e.preventDefault();
|
|
3783
|
+
if (drag) move(drag.from, i);
|
|
3784
|
+
setDrag(null);
|
|
3785
|
+
},
|
|
3786
|
+
onDragEnd: () => setDrag(null),
|
|
3787
|
+
children: [
|
|
3788
|
+
/* @__PURE__ */ jsx("button", {
|
|
3789
|
+
type: "button",
|
|
3790
|
+
className: "ui-dt-sortgrip",
|
|
3791
|
+
"aria-label": tr("「{name}」第 {n} 排序;按 Alt+↑ ↓ 調整順序", {
|
|
3792
|
+
name: name(l.key),
|
|
3793
|
+
n: i + 1
|
|
3794
|
+
}),
|
|
3795
|
+
"aria-keyshortcuts": "Alt+ArrowUp Alt+ArrowDown",
|
|
3796
|
+
onKeyDown: (e) => {
|
|
3797
|
+
if (!e.altKey || e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
3798
|
+
e.preventDefault();
|
|
3799
|
+
move(i, i + (e.key === "ArrowUp" ? -1 : 1), true);
|
|
3800
|
+
},
|
|
3801
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3802
|
+
name: "dots-six-vertical",
|
|
3803
|
+
size: 16
|
|
3804
|
+
})
|
|
3805
|
+
}),
|
|
3806
|
+
/* @__PURE__ */ jsx("span", {
|
|
3807
|
+
className: "ui-dt-sortn",
|
|
3808
|
+
children: i + 1
|
|
3809
|
+
}),
|
|
3810
|
+
/* @__PURE__ */ jsx("span", {
|
|
3811
|
+
className: "ui-dt-sortname",
|
|
3812
|
+
children: name(l.key)
|
|
3813
|
+
}),
|
|
3814
|
+
/* @__PURE__ */ jsx("span", {
|
|
3815
|
+
className: "ui-dt-sortdir",
|
|
3816
|
+
role: "radiogroup",
|
|
3817
|
+
"aria-label": tr("「{name}」的方向", { name: name(l.key) }),
|
|
3818
|
+
children: ["asc", "desc"].map((d) => /* @__PURE__ */ jsxs("button", {
|
|
3819
|
+
type: "button",
|
|
3820
|
+
role: "radio",
|
|
3821
|
+
"aria-checked": l.dir === d,
|
|
3822
|
+
className: cx(l.dir === d && "is-on"),
|
|
3823
|
+
onClick: () => onChange(levels.map((x, j) => j === i ? {
|
|
3824
|
+
key: x.key,
|
|
3825
|
+
dir: d
|
|
3826
|
+
} : x)),
|
|
3827
|
+
children: [
|
|
3828
|
+
ARROW[d],
|
|
3829
|
+
" ",
|
|
3830
|
+
dirWord(d)
|
|
3831
|
+
]
|
|
3832
|
+
}, d))
|
|
3833
|
+
}),
|
|
3834
|
+
/* @__PURE__ */ jsx("button", {
|
|
3835
|
+
type: "button",
|
|
3836
|
+
className: "ui-dt-sortrm",
|
|
3837
|
+
"aria-label": tr("移除「{name}」排序", { name: name(l.key) }),
|
|
3838
|
+
onClick: () => onChange(levels.filter((_, j) => j !== i)),
|
|
3839
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3840
|
+
name: "x",
|
|
3841
|
+
size: 16
|
|
3842
|
+
})
|
|
3843
|
+
})
|
|
3844
|
+
]
|
|
3845
|
+
}, l.key))
|
|
3846
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
3847
|
+
className: "ui-dt-sortnone",
|
|
3848
|
+
children: tr("照資料原本的順序。")
|
|
3849
|
+
}),
|
|
3850
|
+
rest.length && levels.length < max ? adding ? /* @__PURE__ */ jsxs("div", {
|
|
3851
|
+
className: "ui-dt-sortadd",
|
|
3852
|
+
role: "group",
|
|
3853
|
+
"aria-labelledby": addId,
|
|
3854
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3855
|
+
id: addId,
|
|
3856
|
+
className: "ui-dt-sortaddhead",
|
|
3857
|
+
children: levels.length ? tr("再依哪一欄") : tr("依哪一欄排序")
|
|
3858
|
+
}), rest.map((c, i) => /* @__PURE__ */ jsxs("button", {
|
|
3859
|
+
ref: i === 0 ? firstAdd : void 0,
|
|
3860
|
+
type: "button",
|
|
3861
|
+
className: "ui-dt-opt",
|
|
3862
|
+
onClick: () => {
|
|
3863
|
+
onChange([...levels, {
|
|
3864
|
+
key: c.key,
|
|
3865
|
+
dir: first(c.key)
|
|
3866
|
+
}]);
|
|
3867
|
+
setAdding(false);
|
|
3868
|
+
},
|
|
3869
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
3870
|
+
name: "plus",
|
|
3871
|
+
size: 16
|
|
3872
|
+
}), c.label]
|
|
3873
|
+
}, c.key))]
|
|
3874
|
+
}) : /* @__PURE__ */ jsxs("button", {
|
|
3875
|
+
type: "button",
|
|
3876
|
+
className: "ui-link-btn ui-dt-sortmore",
|
|
3877
|
+
onClick: () => setAdding(true),
|
|
3878
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
3879
|
+
name: "plus",
|
|
3880
|
+
size: 16
|
|
3881
|
+
}), levels.length ? tr("再依…") : tr("排序依據…")]
|
|
3882
|
+
}) : levels.length >= max && rest.length ? /* @__PURE__ */ jsx("p", {
|
|
3883
|
+
className: "ui-dt-sortnone",
|
|
3884
|
+
children: tr("最多 {n} 層排序。", { n: max })
|
|
3885
|
+
}) : null
|
|
3886
|
+
]
|
|
3887
|
+
});
|
|
3888
|
+
}
|
|
3643
3889
|
// src/components/DataTable/DataTable.tsx
|
|
3644
3890
|
const MOVE = {
|
|
3645
3891
|
dur: 320,
|
|
@@ -3689,10 +3935,19 @@ function DataTable(p) {
|
|
|
3689
3935
|
q: "",
|
|
3690
3936
|
values: {}
|
|
3691
3937
|
};
|
|
3692
|
-
const
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3938
|
+
const maxSort = Math.max(1, p.maxSort ?? Infinity);
|
|
3939
|
+
const sortCols = cols.filter((c) => c.sortable !== false).map((c) => ({
|
|
3940
|
+
key: c.key,
|
|
3941
|
+
label: c.label,
|
|
3942
|
+
numeric: c.numeric
|
|
3943
|
+
}));
|
|
3944
|
+
const firstDir = (key) => sortCols.find((c) => c.key === key)?.numeric ? "desc" : "asc";
|
|
3945
|
+
const validSort = (l) => l.filter((x, i) => sortCols.some((c) => c.key === x.key) && l.findIndex((y) => y.key === x.key) === i).slice(0, maxSort).map((x) => ({
|
|
3946
|
+
key: x.key,
|
|
3947
|
+
dir: x.dir ?? firstDir(x.key)
|
|
3948
|
+
}));
|
|
3949
|
+
const initialSort = validSort(p.defaultSort ?? []);
|
|
3950
|
+
const [sort, setSort] = React.useState(() => validSort((urlSync && typeof location !== "undefined" ? readSort(urlKey) : null) ?? initialSort));
|
|
3696
3951
|
const [page, setPage] = React.useState(0);
|
|
3697
3952
|
const [q, setQ] = React.useState(() => fromUrl().q);
|
|
3698
3953
|
const [values, setValues] = React.useState(() => fromUrl().values);
|
|
@@ -3725,6 +3980,12 @@ function DataTable(p) {
|
|
|
3725
3980
|
const [zoomed, setZoomed] = React.useState(false);
|
|
3726
3981
|
const [zoomWidths, setZoomWidths] = React.useState(null);
|
|
3727
3982
|
const zoomRef = React.useRef(null);
|
|
3983
|
+
const [headSlot, setHeadSlot] = React.useState(null);
|
|
3984
|
+
const noSearch = search === false && !p.caption;
|
|
3985
|
+
React.useLayoutEffect(() => {
|
|
3986
|
+
const prev = noSearch ? rootRef.current?.previousElementSibling : null;
|
|
3987
|
+
setHeadSlot(prev instanceof HTMLElement && prev.classList.contains("ui-card-head") && prev.parentElement?.classList.contains("ui-card") ? prev : null);
|
|
3988
|
+
}, [noSearch]);
|
|
3728
3989
|
const [resetKey, setResetKey] = React.useState(p.resetKey);
|
|
3729
3990
|
const resetting = resetKey !== p.resetKey;
|
|
3730
3991
|
if (resetting) {
|
|
@@ -3734,15 +3995,16 @@ function DataTable(p) {
|
|
|
3734
3995
|
setPage(0);
|
|
3735
3996
|
setSel({});
|
|
3736
3997
|
setSumVal("all");
|
|
3737
|
-
setSort(
|
|
3738
|
-
key: null,
|
|
3739
|
-
dir: "desc"
|
|
3740
|
-
});
|
|
3998
|
+
setSort(initialSort);
|
|
3741
3999
|
setToggled({});
|
|
3742
4000
|
setOpened({});
|
|
3743
4001
|
setFit({});
|
|
3744
4002
|
}
|
|
3745
4003
|
const valuesKey = JSON.stringify(values);
|
|
4004
|
+
const sortKey = JSON.stringify(sort);
|
|
4005
|
+
React.useEffect(() => {
|
|
4006
|
+
if (urlSync && typeof location !== "undefined") writeSort(urlKey, sort, initialSort);
|
|
4007
|
+
}, [sortKey]);
|
|
3746
4008
|
React.useEffect(() => {
|
|
3747
4009
|
if (urlSync && filters.length) writeUrl(urlKey, filters, values, q);
|
|
3748
4010
|
}, [valuesKey, q]);
|
|
@@ -3771,15 +4033,22 @@ function DataTable(p) {
|
|
|
3771
4033
|
const passes = (r, skip) => (!searching || searchHit(r, cols, filters, q, search ? search.keys : void 0)) && filters.every((f) => f.key === skip || matches(f, r, values[f.key]));
|
|
3772
4034
|
let list = all.filter((x) => passes(x.r));
|
|
3773
4035
|
const activeN = filters.filter((f) => isActive(values[f.key])).length;
|
|
3774
|
-
if (sort.
|
|
3775
|
-
const
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
4036
|
+
if (sort.length) {
|
|
4037
|
+
const by = sort.map((l) => {
|
|
4038
|
+
const col = cols.find((c) => c.key === l.key);
|
|
4039
|
+
return {
|
|
4040
|
+
val: (r) => col?.sortValue ? col.sortValue(r) : get(r, l.key),
|
|
4041
|
+
d: l.dir === "asc" ? 1 : -1
|
|
4042
|
+
};
|
|
4043
|
+
});
|
|
3779
4044
|
list = [...list].sort((a, b) => {
|
|
3780
|
-
const
|
|
3781
|
-
|
|
3782
|
-
|
|
4045
|
+
for (const { val, d } of by) {
|
|
4046
|
+
const x = val(a.r);
|
|
4047
|
+
const y = val(b.r);
|
|
4048
|
+
const c = typeof x === "number" && typeof y === "number" ? x - y : String(x).localeCompare(String(y), "zh-Hant");
|
|
4049
|
+
if (c) return c * d;
|
|
4050
|
+
}
|
|
4051
|
+
return a.i - b.i;
|
|
3783
4052
|
});
|
|
3784
4053
|
}
|
|
3785
4054
|
const shownKey = `${q}|${valuesKey}|${sumVal}|${view}`;
|
|
@@ -3894,22 +4163,39 @@ function DataTable(p) {
|
|
|
3894
4163
|
}).onfinish = () => ghost.remove();
|
|
3895
4164
|
});
|
|
3896
4165
|
});
|
|
3897
|
-
const
|
|
3898
|
-
if (c.sortable === false) return;
|
|
3899
|
-
const first = c.numeric ? "desc" : "asc";
|
|
4166
|
+
const changeSort = (next) => {
|
|
3900
4167
|
capture("sort");
|
|
3901
|
-
|
|
4168
|
+
setSort(next);
|
|
4169
|
+
announce(sortSentence(next, sortCols));
|
|
4170
|
+
};
|
|
4171
|
+
const sortBy = (c, add = false) => {
|
|
4172
|
+
if (c.sortable === false) return;
|
|
4173
|
+
const first = firstDir(c.key);
|
|
4174
|
+
const flip = first === "asc" ? "desc" : "asc";
|
|
4175
|
+
const i = sort.findIndex((l) => l.key === c.key);
|
|
4176
|
+
if (add) {
|
|
4177
|
+
if (i < 0) {
|
|
4178
|
+
if (sort.length < maxSort) changeSort([...sort, {
|
|
4179
|
+
key: c.key,
|
|
4180
|
+
dir: first
|
|
4181
|
+
}]);
|
|
4182
|
+
else announce(tr("最多 {n} 層排序。", { n: maxSort }));
|
|
4183
|
+
} else if (sort[i].dir === first) changeSort(sort.map((l, j) => j === i ? {
|
|
4184
|
+
key: l.key,
|
|
4185
|
+
dir: flip
|
|
4186
|
+
} : l));
|
|
4187
|
+
else changeSort(sort.filter((_, j) => j !== i));
|
|
4188
|
+
return;
|
|
4189
|
+
}
|
|
4190
|
+
if (sort.length !== 1 || i !== 0) changeSort([{
|
|
3902
4191
|
key: c.key,
|
|
3903
4192
|
dir: first
|
|
3904
|
-
});
|
|
3905
|
-
else if (sort.dir === first)
|
|
4193
|
+
}]);
|
|
4194
|
+
else if (sort[0].dir === first) changeSort([{
|
|
3906
4195
|
key: c.key,
|
|
3907
|
-
dir:
|
|
3908
|
-
});
|
|
3909
|
-
else
|
|
3910
|
-
key: null,
|
|
3911
|
-
dir: "desc"
|
|
3912
|
-
});
|
|
4196
|
+
dir: flip
|
|
4197
|
+
}]);
|
|
4198
|
+
else changeSort([]);
|
|
3913
4199
|
};
|
|
3914
4200
|
const goPage = (n) => {
|
|
3915
4201
|
if (n === pageNow || n < 0 || n >= pages) return;
|
|
@@ -4060,22 +4346,44 @@ function DataTable(p) {
|
|
|
4060
4346
|
})
|
|
4061
4347
|
}) : null,
|
|
4062
4348
|
shownCols.map((c, ci) => {
|
|
4063
|
-
const
|
|
4349
|
+
const at = sort.findIndex((l) => l.key === c.key);
|
|
4350
|
+
const cur = at >= 0;
|
|
4351
|
+
const many = sort.length > 1;
|
|
4064
4352
|
return /* @__PURE__ */ jsxs("div", {
|
|
4065
4353
|
role: "columnheader",
|
|
4066
|
-
"aria-sort":
|
|
4354
|
+
"aria-sort": at === 0 ? sort[0].dir === "asc" ? "ascending" : "descending" : "none",
|
|
4067
4355
|
className: cellClass(c, ci),
|
|
4068
4356
|
style: stickyStyle(ci),
|
|
4069
4357
|
"data-col": c.key,
|
|
4070
4358
|
children: [c.sortable === false ? c.label : /* @__PURE__ */ jsxs("button", {
|
|
4071
4359
|
type: "button",
|
|
4072
4360
|
className: cx("ui-dt-sort", cur && "is-on"),
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4361
|
+
"aria-label": cur && many ? tr("{name},第 {n} 排序,{dir}", {
|
|
4362
|
+
name: c.label,
|
|
4363
|
+
n: at + 1,
|
|
4364
|
+
dir: dirWord(sort[at].dir)
|
|
4365
|
+
}) : void 0,
|
|
4366
|
+
"aria-keyshortcuts": "Shift+Enter",
|
|
4367
|
+
onClick: (e) => sortBy(c, e.shiftKey),
|
|
4368
|
+
onKeyDown: (e) => {
|
|
4369
|
+
if (e.shiftKey && (e.key === "Enter" || e.key === " ")) {
|
|
4370
|
+
e.preventDefault();
|
|
4371
|
+
sortBy(c, true);
|
|
4372
|
+
}
|
|
4373
|
+
},
|
|
4374
|
+
children: [
|
|
4375
|
+
/* @__PURE__ */ jsx("span", { children: c.label }),
|
|
4376
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
4377
|
+
d: ARROWS[cur ? sort[at].dir : "none"],
|
|
4378
|
+
size: 14,
|
|
4379
|
+
className: "ui-dt-arrow"
|
|
4380
|
+
}),
|
|
4381
|
+
cur && many ? /* @__PURE__ */ jsx("span", {
|
|
4382
|
+
className: "ui-dt-sortpri",
|
|
4383
|
+
"aria-hidden": "true",
|
|
4384
|
+
children: at + 1
|
|
4385
|
+
}) : null
|
|
4386
|
+
]
|
|
4079
4387
|
}), narrow ? null : /* @__PURE__ */ jsx(ColResize, {
|
|
4080
4388
|
name: c.label,
|
|
4081
4389
|
width: w?.[c.key] ?? minOf(c),
|
|
@@ -4101,17 +4409,20 @@ function DataTable(p) {
|
|
|
4101
4409
|
const raw = get(r, c.key);
|
|
4102
4410
|
let v;
|
|
4103
4411
|
if (c.render) v = c.render(r);
|
|
4104
|
-
else if (c.unit && raw !== null && raw !== void 0 && raw !== "") v = /* @__PURE__ */ jsxs(
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4412
|
+
else if (c.unit && raw !== null && raw !== void 0 && raw !== "") v = /* @__PURE__ */ jsxs("span", {
|
|
4413
|
+
className: "ui-dt-qty",
|
|
4414
|
+
children: [
|
|
4415
|
+
markMatch(cellText({
|
|
4416
|
+
...c,
|
|
4417
|
+
unit: void 0
|
|
4418
|
+
}, raw), mark),
|
|
4419
|
+
" ",
|
|
4420
|
+
/* @__PURE__ */ jsx("span", {
|
|
4421
|
+
className: "ui-unit",
|
|
4422
|
+
children: c.unit
|
|
4423
|
+
})
|
|
4424
|
+
]
|
|
4425
|
+
});
|
|
4115
4426
|
else v = markMatch(cellText(c, raw), mark);
|
|
4116
4427
|
return v;
|
|
4117
4428
|
};
|
|
@@ -4142,9 +4453,13 @@ function DataTable(p) {
|
|
|
4142
4453
|
if (p.copyText) return p.copyText(all);
|
|
4143
4454
|
return markdownTable(shownCols.map((c) => c.label), all.map((r) => shownCols.map((c) => String(c.fullText?.(r) ?? c.searchText?.(r) ?? cellText(c, get(r, c.key)) ?? ""))));
|
|
4144
4455
|
};
|
|
4145
|
-
const toolsView = (inZoom) => /* @__PURE__ */ jsxs("div", {
|
|
4146
|
-
className: "ui-dt-tools",
|
|
4456
|
+
const toolsView = (inZoom, inHead = false) => /* @__PURE__ */ jsxs("div", {
|
|
4457
|
+
className: cx("ui-dt-tools", inHead && "is-inhead"),
|
|
4147
4458
|
children: [
|
|
4459
|
+
search === false && p.caption && !inZoom && !inHead ? /* @__PURE__ */ jsx("div", {
|
|
4460
|
+
className: "ui-dt-caption",
|
|
4461
|
+
children: p.caption
|
|
4462
|
+
}) : null,
|
|
4148
4463
|
search !== false ? /* @__PURE__ */ jsx(SearchField, {
|
|
4149
4464
|
value: q,
|
|
4150
4465
|
onChange: (v) => {
|
|
@@ -4155,49 +4470,65 @@ function DataTable(p) {
|
|
|
4155
4470
|
label: search.placeholder || tr("搜尋"),
|
|
4156
4471
|
className: "ui-dt-search"
|
|
4157
4472
|
}) : null,
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4473
|
+
/* @__PURE__ */ jsxs("div", {
|
|
4474
|
+
className: "ui-dt-actions",
|
|
4475
|
+
children: [
|
|
4476
|
+
filters.length ? /* @__PURE__ */ jsx(FilterButton, {
|
|
4477
|
+
boundary: inZoom ? zoomRef : rootRef,
|
|
4478
|
+
filters,
|
|
4479
|
+
values,
|
|
4480
|
+
activeCount: activeN,
|
|
4481
|
+
count: (f, v) => all.filter((x) => passes(x.r, f.key) && matches(f, x.r, f.type === "list" ? [v] : void 0)).length,
|
|
4482
|
+
onChange: (key, v) => {
|
|
4483
|
+
setValues({
|
|
4484
|
+
...values,
|
|
4485
|
+
[key]: v
|
|
4486
|
+
});
|
|
4487
|
+
setPage(0);
|
|
4488
|
+
},
|
|
4489
|
+
onClear: () => {
|
|
4490
|
+
setValues({});
|
|
4491
|
+
setPage(0);
|
|
4492
|
+
}
|
|
4493
|
+
}) : null,
|
|
4494
|
+
/* @__PURE__ */ jsxs("span", {
|
|
4495
|
+
className: "ui-dt-result",
|
|
4496
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
4497
|
+
"aria-hidden": "true",
|
|
4498
|
+
children: seenOnly(tr("{n} / {total} 筆", {
|
|
4499
|
+
n: "",
|
|
4500
|
+
total: ""
|
|
4501
|
+
}), [format.number(list.length), format.number(baseCount)])
|
|
4502
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
4503
|
+
className: "ui-visually-hidden",
|
|
4504
|
+
children: format.fractionLabel(list.length, baseCount, tr("筆"))
|
|
4505
|
+
})]
|
|
4506
|
+
}),
|
|
4507
|
+
p.copy !== false && !narrow ? /* @__PURE__ */ jsx(CopyMarkdownButton, {
|
|
4508
|
+
text: copyMarkdown,
|
|
4509
|
+
onCopyError: p.onCopyError
|
|
4510
|
+
}) : null,
|
|
4511
|
+
sortCols.length ? /* @__PURE__ */ jsx(SortButton, {
|
|
4512
|
+
cols: sortCols,
|
|
4513
|
+
levels: sort,
|
|
4514
|
+
max: maxSort,
|
|
4515
|
+
onChange: changeSort,
|
|
4516
|
+
boundary: inZoom ? zoomRef : rootRef
|
|
4517
|
+
}) : null,
|
|
4518
|
+
p.columnMenu !== false && cols.length > 2 ? /* @__PURE__ */ jsx(ColumnMenu, {
|
|
4519
|
+
cols,
|
|
4520
|
+
hidden,
|
|
4521
|
+
onToggle: (k) => setToggled({
|
|
4522
|
+
...toggled,
|
|
4523
|
+
[k]: !hidden[k]
|
|
4524
|
+
})
|
|
4525
|
+
}) : null,
|
|
4526
|
+
p.zoom !== false && !narrow && !inZoom ? /* @__PURE__ */ jsx(ZoomButton, {
|
|
4527
|
+
inToolbar: true,
|
|
4528
|
+
onClick: () => setZoomed(true)
|
|
4529
|
+
}) : null
|
|
4530
|
+
]
|
|
4531
|
+
})
|
|
4201
4532
|
]
|
|
4202
4533
|
});
|
|
4203
4534
|
const tableView = (inZoom) => {
|
|
@@ -4206,7 +4537,7 @@ function DataTable(p) {
|
|
|
4206
4537
|
return /* @__PURE__ */ jsx("div", {
|
|
4207
4538
|
className: cx("ui-dt-scroller", scrollMore && !inZoom && "has-more"),
|
|
4208
4539
|
children: /* @__PURE__ */ jsx("div", {
|
|
4209
|
-
className: "ui-dt-scroll",
|
|
4540
|
+
className: cx("ui-dt-scroll", pages > 1 && "is-paged"),
|
|
4210
4541
|
ref: inZoom ? void 0 : scrollRef,
|
|
4211
4542
|
onScroll: inZoom ? void 0 : onScroll,
|
|
4212
4543
|
children: /* @__PURE__ */ jsxs("div", {
|
|
@@ -4392,9 +4723,9 @@ function DataTable(p) {
|
|
|
4392
4723
|
}) : null });
|
|
4393
4724
|
return /* @__PURE__ */ jsxs("div", {
|
|
4394
4725
|
ref: rootRef,
|
|
4395
|
-
className: cx("ui-dt", selIds.length && "has-sel", p.className),
|
|
4726
|
+
className: cx("ui-dt", search === false && "is-nosearch", selIds.length && "has-sel", p.className),
|
|
4396
4727
|
children: [
|
|
4397
|
-
p.caption ? /* @__PURE__ */ jsx("div", {
|
|
4728
|
+
p.caption && search !== false ? /* @__PURE__ */ jsx("div", {
|
|
4398
4729
|
className: "ui-dt-caption",
|
|
4399
4730
|
children: p.caption
|
|
4400
4731
|
}) : null,
|
|
@@ -4448,11 +4779,7 @@ function DataTable(p) {
|
|
|
4448
4779
|
count: sumAll.filter((x) => String(get(x.r, summary.key)) === String(it.value)).length
|
|
4449
4780
|
}))]
|
|
4450
4781
|
}) : null,
|
|
4451
|
-
toolsView(false),
|
|
4452
|
-
p.zoom !== false && !narrow ? /* @__PURE__ */ jsx("div", {
|
|
4453
|
-
className: "ui-dt-zoom",
|
|
4454
|
-
children: /* @__PURE__ */ jsx(ZoomButton, { onClick: () => setZoomed(true) })
|
|
4455
|
-
}) : null,
|
|
4782
|
+
headSlot ? createPortal(toolsView(false, true), headSlot) : toolsView(false),
|
|
4456
4783
|
tableView(false),
|
|
4457
4784
|
/* @__PURE__ */ jsx(ScrollHint, {
|
|
4458
4785
|
show: overflows,
|