@seanyeh77/ui 0.51.0 → 0.52.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/dist/bundle.js +13 -13
- package/dist/components/DataTable/DataTable.d.ts +3 -2
- package/dist/components/DataTable/DataTable.js +9 -2
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/css/DataTable.css +6 -0
- package/dist/format-entry.d.ts +2 -2
- package/dist/format-entry.js +2 -2
- package/dist/format.d.ts +3 -1
- package/dist/format.js +16 -13
- package/dist/format.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/internal/tableTools.js.map +1 -1
- package/dist/styles.css +6 -0
- package/docs/DataTable.md +1 -1
- package/docs/Format.md +2 -1
- package/docs/agents.md +5 -5
- package/docs/guidelines.md +1 -1
- package/package.json +2 -2
|
@@ -69,8 +69,9 @@ export interface DataTableProps<R extends Row = Record<string, unknown>> {
|
|
|
69
69
|
* links, buttons or checkbox, nor a click that ends a text selection) opens it. Like a link, Ctrl, ⌘ or Shift + click
|
|
70
70
|
* and a middle click open it in a new tab. */
|
|
71
71
|
rowHref?: (row: R) => string;
|
|
72
|
-
/** With rowHref: called instead of following the link on a plain
|
|
73
|
-
* app router can push the route. Ctrl, ⌘, Shift and middle clicks
|
|
72
|
+
/** With rowHref (alone it does nothing, and development warns): called instead of following the link on a plain
|
|
73
|
+
* click (on the row or its first cell's link), so an app router can push the route. Ctrl, ⌘, Shift and middle clicks
|
|
74
|
+
* still open the href in a new tab. */
|
|
74
75
|
onRowOpen?: (row: R, event: React.MouseEvent) => void;
|
|
75
76
|
/** Write search and filters into the URL. Default true. */
|
|
76
77
|
urlSync?: boolean;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Button } from "../Button/Button.js";
|
|
3
3
|
import { SearchField } from "../SearchField/SearchField.js";
|
|
4
4
|
import { Tabs } from "../Tabs/Tabs.js";
|
|
5
|
-
import { format } from "../../format.js";
|
|
5
|
+
import { format, plainMinus } from "../../format.js";
|
|
6
6
|
import { tr, unitFor } from "../../i18n.js";
|
|
7
7
|
import { Icon } from "../../icons/Icon.js";
|
|
8
8
|
import { TOUCH_ONLY, copyText, cssZoom, cx, idPart, monoNums, reduced, resizeObserver, seenOnly, useMedia, useNarrow } from "../../internal/util.js";
|
|
@@ -311,6 +311,7 @@ function DataTable(p) {
|
|
|
311
311
|
React.useEffect(() => {
|
|
312
312
|
if (urlSync && filters.length) writeUrl(urlKey, filters, values, q);
|
|
313
313
|
}, [valuesKey, q]);
|
|
314
|
+
devWarn(p.onRowOpen !== void 0 && p.rowHref === void 0, "DataTable", "onRowOpen is only called with rowHref, so clicking a row does nothing. Pass rowHref too: it gives each row a link that keyboard users can open, and onRowOpen still takes the plain click (e.g. for a router).");
|
|
314
315
|
devWarn(p.widthKey !== void 0, "DataTable", "`widthKey` is deprecated: rename it to `storageKey`, as in every other component that remembers a choice. The stored widths and columns carry over.");
|
|
315
316
|
devWarn(() => cols.some((c) => c.format === "percent" && !c.unit), "DataTable", "format: 'percent' sets 1 decimal and shows no % sign; add unit: '%' to that column.");
|
|
316
317
|
devWarn(() => rows.length > 1 && rows.every((r) => get(r, "id") == null) && selectable, "DataTable", "rows have no id, so a selection follows the position, not the row. Add an id to each row.");
|
|
@@ -1019,7 +1020,7 @@ function DataTable(p) {
|
|
|
1019
1020
|
const [copied, setCopied] = React.useState(false);
|
|
1020
1021
|
const copiedTimer = React.useRef(void 0);
|
|
1021
1022
|
React.useEffect(() => () => clearTimeout(copiedTimer.current), []);
|
|
1022
|
-
const doCopy = () => copyText(copyMarkdown()).then(() => {
|
|
1023
|
+
const doCopy = () => copyText(plainMinus(copyMarkdown())).then(() => {
|
|
1023
1024
|
setCopied(true);
|
|
1024
1025
|
announce(tr("已複製"));
|
|
1025
1026
|
clearTimeout(copiedTimer.current);
|
|
@@ -1499,6 +1500,12 @@ function DataTable(p) {
|
|
|
1499
1500
|
ref: rootRef,
|
|
1500
1501
|
className: cx("ui-dt", search === false && "is-nosearch", selIds.length && "has-sel", hasAct && "has-acts", p.className),
|
|
1501
1502
|
style: hasAct ? { "--dt-acts-w": (p.actionsWidth ?? actsW ?? 72) + "px" } : void 0,
|
|
1503
|
+
onCopy: (e) => {
|
|
1504
|
+
const text = typeof window !== "undefined" ? window.getSelection()?.toString() ?? "" : "";
|
|
1505
|
+
if (!text.includes("−") || !e.clipboardData) return;
|
|
1506
|
+
e.preventDefault();
|
|
1507
|
+
e.clipboardData.setData("text/plain", plainMinus(text));
|
|
1508
|
+
},
|
|
1502
1509
|
children: [
|
|
1503
1510
|
p.caption && search !== false ? /* @__PURE__ */ jsx("div", {
|
|
1504
1511
|
className: "ui-dt-caption",
|