@dxos/react-ui-table 0.3.9-main.cea1d3b → 0.3.9-main.d5f3fd3
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/lib/browser/index.mjs +168 -145
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Cell/CellCombobox.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/props.d.ts +3 -0
- package/dist/types/src/components/Table/props.d.ts.map +1 -1
- package/dist/types/src/helpers.d.ts +2 -2
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/schema.d.ts +0 -1
- package/dist/types/src/schema.d.ts.map +1 -1
- package/dist/types/src/theme.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +11 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/components/Cell/CellCombobox.tsx +4 -1
- package/src/components/ColumnMenu.tsx +16 -16
- package/src/components/Table/Table.tsx +6 -1
- package/src/components/Table/props.ts +5 -0
- package/src/helpers.tsx +105 -84
- package/src/index.ts +1 -0
- package/src/schema.ts +0 -8
- package/src/theme.ts +2 -2
- package/src/translations.ts +11 -0
|
@@ -1,45 +1,42 @@
|
|
|
1
1
|
// packages/ui/react-ui-table/src/components/ColumnMenu.tsx
|
|
2
2
|
import { Check, CaretDown, Trash, X } from "@phosphor-icons/react";
|
|
3
3
|
import React, { useRef, useState } from "react";
|
|
4
|
-
import { Button, DensityProvider, Input, Popover, Select, Separator } from "@dxos/react-ui";
|
|
4
|
+
import { Button, DensityProvider, Input, Popover, Select, Separator, useTranslation } from "@dxos/react-ui";
|
|
5
5
|
import { getSize, mx } from "@dxos/react-ui-theme";
|
|
6
6
|
import { safeParseInt } from "@dxos/util";
|
|
7
7
|
|
|
8
|
-
// packages/ui/react-ui-table/src/
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
]);
|
|
8
|
+
// packages/ui/react-ui-table/src/translations.ts
|
|
9
|
+
var translationKey = "table";
|
|
10
|
+
var translations_default = [
|
|
11
|
+
{
|
|
12
|
+
"en-US": {
|
|
13
|
+
[translationKey]: {
|
|
14
|
+
"no selection label": "\xA0",
|
|
15
|
+
"number column type label": "Number",
|
|
16
|
+
"boolean column type label": "Toggle",
|
|
17
|
+
"date column type label": "Date",
|
|
18
|
+
"string column type label": "Text",
|
|
19
|
+
"ref column type label": "Reference",
|
|
20
|
+
"digits label": "Decimal places",
|
|
21
|
+
"save label": "Save",
|
|
22
|
+
"delete label": "Delete",
|
|
23
|
+
"column label label": "Label",
|
|
24
|
+
"property key label": "Property",
|
|
25
|
+
"column type label": "Type"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
];
|
|
31
30
|
|
|
32
31
|
// packages/ui/react-ui-table/src/components/ColumnMenu.tsx
|
|
33
32
|
var ColumnMenu = ({ column, ...props }) => {
|
|
34
33
|
const title = column.label?.length ? column.label : column.id;
|
|
35
34
|
return /* @__PURE__ */ React.createElement("div", {
|
|
36
|
-
className: "flex
|
|
35
|
+
className: "flex items-center gap-2"
|
|
37
36
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
38
|
-
className: "truncate",
|
|
37
|
+
className: "flex-1 min-is-0 truncate",
|
|
39
38
|
title
|
|
40
39
|
}, title), /* @__PURE__ */ React.createElement("div", {
|
|
41
|
-
className: "grow"
|
|
42
|
-
}), /* @__PURE__ */ React.createElement("div", {
|
|
43
40
|
className: "flex shrink-0"
|
|
44
41
|
}, /* @__PURE__ */ React.createElement(ColumnPanel, {
|
|
45
42
|
...props,
|
|
@@ -59,6 +56,7 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
|
|
|
59
56
|
const [label, setLabel] = useState(column.label);
|
|
60
57
|
const [digits, setDigits] = useState(String(column.digits ?? "0"));
|
|
61
58
|
const propRef = useRef(null);
|
|
59
|
+
const { t } = useTranslation(translationKey);
|
|
62
60
|
const handleCancel = () => {
|
|
63
61
|
setProp(column.id);
|
|
64
62
|
setOpen(false);
|
|
@@ -93,7 +91,7 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
|
|
|
93
91
|
asChild: true
|
|
94
92
|
}, /* @__PURE__ */ React.createElement(Button, {
|
|
95
93
|
variant: "ghost",
|
|
96
|
-
classNames: "p-
|
|
94
|
+
classNames: "p-1"
|
|
97
95
|
}, /* @__PURE__ */ React.createElement(CaretDown, {
|
|
98
96
|
className: getSize(4)
|
|
99
97
|
}))), /* @__PURE__ */ React.createElement(Popover.Portal, null, /* @__PURE__ */ React.createElement(Popover.Content, null, /* @__PURE__ */ React.createElement(Popover.Viewport, {
|
|
@@ -104,14 +102,14 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
|
|
|
104
102
|
className: "flex flex-col gap-1"
|
|
105
103
|
}, /* @__PURE__ */ React.createElement(Section, null, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
106
104
|
classNames: "mbe-1"
|
|
107
|
-
}, "
|
|
105
|
+
}, t("column label label")), /* @__PURE__ */ React.createElement(Input.TextInput, {
|
|
108
106
|
placeholder: "Column label",
|
|
109
107
|
value: label ?? "",
|
|
110
108
|
onChange: (event) => setLabel(event.target.value),
|
|
111
109
|
autoFocus: true
|
|
112
110
|
})), /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
113
111
|
classNames: "mbe-1 mbs-3"
|
|
114
|
-
}, "
|
|
112
|
+
}, t("property key label")), /* @__PURE__ */ React.createElement(Input.TextInput, {
|
|
115
113
|
ref: propRef,
|
|
116
114
|
placeholder: "Property key",
|
|
117
115
|
// TODO(burdon): Provide hooks for value normalization, ENTER, ESC, etc.
|
|
@@ -119,18 +117,23 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
|
|
|
119
117
|
onChange: (event) => setProp(event.target.value.replace(/[^\w_]/g, ""))
|
|
120
118
|
})), /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
121
119
|
classNames: "mbe-1 mbs-3"
|
|
122
|
-
}, "
|
|
120
|
+
}, t("column type label")), /* @__PURE__ */ React.createElement(Select.Root, {
|
|
123
121
|
value: type,
|
|
124
122
|
onValueChange: setType
|
|
125
123
|
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
126
124
|
placeholder: "Type",
|
|
127
125
|
classNames: "is-full"
|
|
128
|
-
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null,
|
|
126
|
+
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, [
|
|
127
|
+
"number",
|
|
128
|
+
"boolean",
|
|
129
|
+
"string",
|
|
130
|
+
"ref"
|
|
131
|
+
].map((type2) => /* @__PURE__ */ React.createElement(Select.Option, {
|
|
129
132
|
key: type2,
|
|
130
133
|
value: type2
|
|
131
|
-
},
|
|
134
|
+
}, t(`${type2} column type label`))))))))), type === "number" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Section, null, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
132
135
|
classNames: "mbe-1 mbs-3"
|
|
133
|
-
}, "
|
|
136
|
+
}, t("digits label")), /* @__PURE__ */ React.createElement(Input.TextInput, {
|
|
134
137
|
value: digits ?? "",
|
|
135
138
|
onChange: (event) => setDigits(event.target.value)
|
|
136
139
|
})))), type === "ref" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Section, null, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
@@ -141,7 +144,7 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
|
|
|
141
144
|
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
142
145
|
placeholder: "Table",
|
|
143
146
|
classNames: "is-full"
|
|
144
|
-
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, tableDefs.filter((
|
|
147
|
+
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, tableDefs.filter((t2) => t2.id !== tableDef.id).map(({ id, name }) => /* @__PURE__ */ React.createElement(Select.Option, {
|
|
145
148
|
key: id,
|
|
146
149
|
value: id
|
|
147
150
|
}, name ?? id))))))), refTable && /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
@@ -163,21 +166,23 @@ var ColumnPanel = ({ context, tableDefs, tableDef, column, onUpdate, onDelete })
|
|
|
163
166
|
variant: "primary",
|
|
164
167
|
classNames: "is-full flex gap-2",
|
|
165
168
|
onClick: handleSave
|
|
166
|
-
}, /* @__PURE__ */ React.createElement("span", null, "
|
|
169
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("save label")), /* @__PURE__ */ React.createElement("div", {
|
|
167
170
|
className: "grow"
|
|
168
171
|
}), /* @__PURE__ */ React.createElement(Check, {
|
|
169
172
|
className: getSize(5)
|
|
170
173
|
})), /* @__PURE__ */ React.createElement(Button, {
|
|
171
174
|
classNames: "is-full flex gap-2",
|
|
172
175
|
onClick: handleCancel
|
|
173
|
-
}, /* @__PURE__ */ React.createElement("span", null, "
|
|
176
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("cancel label", {
|
|
177
|
+
ns: "os"
|
|
178
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
174
179
|
className: "grow"
|
|
175
180
|
}), /* @__PURE__ */ React.createElement(X, {
|
|
176
181
|
className: getSize(5)
|
|
177
182
|
})), /* @__PURE__ */ React.createElement(Button, {
|
|
178
183
|
classNames: "is-full flex gap-2",
|
|
179
184
|
onClick: () => onDelete?.(column.id)
|
|
180
|
-
}, /* @__PURE__ */ React.createElement("span", null, "
|
|
185
|
+
}, /* @__PURE__ */ React.createElement("span", null, t("delete label")), /* @__PURE__ */ React.createElement("div", {
|
|
181
186
|
className: "grow"
|
|
182
187
|
}), /* @__PURE__ */ React.createElement(Trash, {
|
|
183
188
|
className: getSize(5)
|
|
@@ -211,7 +216,7 @@ var headPadding = "pli-2 plb-1.5";
|
|
|
211
216
|
var gridCellFocusRing = "focus:z-[11] focus:outline outline-2 outline-primary-500 dark:outline-primary-400";
|
|
212
217
|
var tableRoot = ({ fullWidth }, ...etc) => mx2("table-fixed", fullWidth && "is-full", ...etc);
|
|
213
218
|
var groupTh = (_props, ...etc) => mx2("text-start font-medium", flushPadding, ...etc);
|
|
214
|
-
var theadRoot = ({ header }, ...etc) => mx2(header ? "sticky block-start-
|
|
219
|
+
var theadRoot = ({ header, stickyHeader }, ...etc) => mx2(header ? stickyHeader && "sticky block-start-[--sticky-top] z-[1]" : "collapse", header && fixedSurface, ...etc);
|
|
215
220
|
var theadTr = (_props, ...etc) => mx2("group", ...etc);
|
|
216
221
|
var theadTh = ({ border }, ...etc) => mx2("relative text-start font-medium select-none truncate", headPadding, border && "border", border && groupBorder, ...etc);
|
|
217
222
|
var theadResizeRoot = (_props, ...etc) => mx2("absolute top-0 pis-1 h-full z-[10] w-[7px] -right-[5px] cursor-col-resize select-none touch-none opacity-20 hover:opacity-100", ...etc);
|
|
@@ -372,7 +377,7 @@ TableHead.displayName = TABLE_HEAD_NAME;
|
|
|
372
377
|
|
|
373
378
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
374
379
|
var Table = (props) => {
|
|
375
|
-
const { role, data = [], columns = [], onColumnResize, columnVisibility, header = true, footer, rowsSelectable, fullWidth, debug, onDataSelectionChange } = props;
|
|
380
|
+
const { role, data = [], columns = [], onColumnResize, columnVisibility, header = true, footer, rowsSelectable, fullWidth, debug, onDataSelectionChange, classNames } = props;
|
|
376
381
|
const TableProvider2 = TableProvider;
|
|
377
382
|
const [rowSelection = {}, directlySetRowSelection] = useControllableState({
|
|
378
383
|
prop: props.rowSelection,
|
|
@@ -462,7 +467,7 @@ var Table = (props) => {
|
|
|
462
467
|
isGrid: role === "grid" || role === "treegrid"
|
|
463
468
|
}, /* @__PURE__ */ React6.createElement("table", {
|
|
464
469
|
role,
|
|
465
|
-
className: tableRoot(props),
|
|
470
|
+
className: tableRoot(props, classNames),
|
|
466
471
|
...!fullWidth && {
|
|
467
472
|
style: {
|
|
468
473
|
width: table.getTotalSize()
|
|
@@ -488,23 +493,9 @@ var Table = (props) => {
|
|
|
488
493
|
// packages/ui/react-ui-table/src/components/Cell/CellCombobox.tsx
|
|
489
494
|
import { CaretDown as CaretDown2 } from "@phosphor-icons/react";
|
|
490
495
|
import React7, { useCallback as useCallback2, useState as useState3 } from "react";
|
|
491
|
-
import { Popover as Popover2, useTranslation } from "@dxos/react-ui";
|
|
496
|
+
import { Popover as Popover2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
492
497
|
import { PopoverCombobox } from "@dxos/react-ui-searchlist";
|
|
493
498
|
import { descriptionText, getSize as getSize2, mx as mx4, staticPlaceholderText } from "@dxos/react-ui-theme";
|
|
494
|
-
|
|
495
|
-
// packages/ui/react-ui-table/src/translations.ts
|
|
496
|
-
var translationKey = "table";
|
|
497
|
-
var translations_default = [
|
|
498
|
-
{
|
|
499
|
-
"en-US": {
|
|
500
|
-
[translationKey]: {
|
|
501
|
-
"no selection label": "\xA0"
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
];
|
|
506
|
-
|
|
507
|
-
// packages/ui/react-ui-table/src/components/Cell/CellCombobox.tsx
|
|
508
499
|
var initialItems = (model, value) => value ? {
|
|
509
500
|
[model.getId(value)]: {
|
|
510
501
|
label: model.getText(value),
|
|
@@ -512,7 +503,7 @@ var initialItems = (model, value) => value ? {
|
|
|
512
503
|
}
|
|
513
504
|
} : {};
|
|
514
505
|
var CellCombobox = ({ model, value, onValueChange }) => {
|
|
515
|
-
const { t } =
|
|
506
|
+
const { t } = useTranslation2(translationKey);
|
|
516
507
|
const [items, setItems] = useState3(initialItems(model, value));
|
|
517
508
|
const [loading, setLoading] = useState3(false);
|
|
518
509
|
const [searchInputValue, setSearchInputValue] = useState3("");
|
|
@@ -541,7 +532,7 @@ var CellCombobox = ({ model, value, onValueChange }) => {
|
|
|
541
532
|
variant: "ghost",
|
|
542
533
|
classNames: "is-full rounded-none ring-inset"
|
|
543
534
|
}, value ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("span", {
|
|
544
|
-
className: mx4("font-normal text-start flex-1 min-is-0 truncate mie-2", !value && staticPlaceholderText)
|
|
535
|
+
className: mx4("font-normal text-start text-base flex-1 min-is-0 truncate mie-2", !value && staticPlaceholderText)
|
|
545
536
|
}, model.getText(value)), /* @__PURE__ */ React7.createElement(CaretDown2, {
|
|
546
537
|
weight: "bold",
|
|
547
538
|
className: getSize2(3)
|
|
@@ -569,29 +560,25 @@ var CellCombobox = ({ model, value, onValueChange }) => {
|
|
|
569
560
|
};
|
|
570
561
|
|
|
571
562
|
// packages/ui/react-ui-table/src/helpers.tsx
|
|
563
|
+
import { useFocusFinders } from "@fluentui/react-tabster";
|
|
572
564
|
import { Check as Check2, ClipboardText, X as X2 } from "@phosphor-icons/react";
|
|
573
565
|
import { createColumnHelper } from "@tanstack/react-table";
|
|
574
566
|
import format from "date-fns/format";
|
|
575
567
|
import formatDistanceToNow from "date-fns/formatDistanceToNow";
|
|
576
|
-
import
|
|
577
|
-
import React8, { useRef as useRef2, useState as useState4 } from "react";
|
|
568
|
+
import React8, { useEffect as useEffect2, useRef as useRef2, useState as useState4 } from "react";
|
|
578
569
|
import { Input as Input2, Tooltip } from "@dxos/react-ui";
|
|
579
570
|
import { getSize as getSize3, mx as mx5 } from "@dxos/react-ui-theme";
|
|
580
|
-
import { stripUndefinedValues } from "@dxos/util";
|
|
581
571
|
var createColumnBuilder = () => ({
|
|
582
572
|
helper: createColumnHelper(),
|
|
583
573
|
builder: new ColumnBuilder()
|
|
584
574
|
});
|
|
585
|
-
var defaults = (options, ...sources) => {
|
|
586
|
-
return stripUndefinedValues(defaultsDeep({}, options, ...sources));
|
|
587
|
-
};
|
|
588
575
|
var ComboboxBuilderCell = (cellContext) => {
|
|
589
576
|
const { model, onUpdate } = cellContext.column.columnDef.meta;
|
|
590
|
-
return /* @__PURE__ */ React8.createElement(CellCombobox, {
|
|
577
|
+
return model ? /* @__PURE__ */ React8.createElement(CellCombobox, {
|
|
591
578
|
model,
|
|
592
579
|
value: cellContext.getValue(),
|
|
593
580
|
onValueChange: (value) => onUpdate?.(cellContext.row.original, cellContext.column.id, value)
|
|
594
|
-
});
|
|
581
|
+
}) : null;
|
|
595
582
|
};
|
|
596
583
|
var StringBuilderCell = (cellContext) => {
|
|
597
584
|
const { onUpdate } = cellContext.column.columnDef.meta;
|
|
@@ -624,40 +611,55 @@ var StringBuilderCell = (cellContext) => {
|
|
|
624
611
|
onKeyDown: (event) => event.key === "Enter" && handleSave() || event.key === "Escape" && handleCancel()
|
|
625
612
|
}));
|
|
626
613
|
};
|
|
614
|
+
var parseNumber = (text) => text?.trim().length ? Number(text) : NaN;
|
|
615
|
+
var displayNumber = (value, digits) => value || value === 0 ? value.toLocaleString(void 0, {
|
|
616
|
+
minimumFractionDigits: digits ?? 0,
|
|
617
|
+
maximumFractionDigits: digits ?? 2
|
|
618
|
+
}) : "";
|
|
627
619
|
var NumberBuilderCell = (cellContext) => {
|
|
628
|
-
const { onUpdate,
|
|
620
|
+
const { onUpdate, digits } = cellContext.column.columnDef.meta;
|
|
629
621
|
const value = cellContext.getValue();
|
|
630
|
-
const [text, setText] = useState4();
|
|
622
|
+
const [text, setText] = useState4(displayNumber(value, digits));
|
|
623
|
+
const { findPrevFocusable } = useFocusFinders();
|
|
624
|
+
const ref = useRef2(null);
|
|
625
|
+
useEffect2(() => {
|
|
626
|
+
(!document.activeElement || document.activeElement !== ref.current) && setText(displayNumber(value, digits));
|
|
627
|
+
}, [
|
|
628
|
+
digits,
|
|
629
|
+
value
|
|
630
|
+
]);
|
|
631
631
|
const handleEdit = () => {
|
|
632
632
|
if (onUpdate) {
|
|
633
633
|
setText(value !== void 0 ? String(value) : "");
|
|
634
634
|
}
|
|
635
635
|
};
|
|
636
636
|
const handleSave = () => {
|
|
637
|
-
const
|
|
638
|
-
onUpdate?.(cellContext.row.original, cellContext.column.id, isNaN(
|
|
639
|
-
setText(
|
|
637
|
+
const nextValue = parseNumber(text);
|
|
638
|
+
onUpdate?.(cellContext.row.original, cellContext.column.id, isNaN(nextValue) ? void 0 : nextValue);
|
|
639
|
+
setText(displayNumber(nextValue, digits));
|
|
640
|
+
ref.current && document.activeElement === ref.current && findPrevFocusable(ref.current)?.focus();
|
|
640
641
|
};
|
|
641
|
-
const
|
|
642
|
-
setText(
|
|
642
|
+
const _handleCancel = () => {
|
|
643
|
+
setText(displayNumber(value, digits));
|
|
644
|
+
ref.current && findPrevFocusable(ref.current)?.focus();
|
|
643
645
|
};
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
646
|
+
return /* @__PURE__ */ React8.createElement(Input2.Root, null, /* @__PURE__ */ React8.createElement(Input2.TextInput, {
|
|
647
|
+
ref,
|
|
648
|
+
variant: "subdued",
|
|
649
|
+
value: text,
|
|
650
|
+
classNames: [
|
|
651
|
+
"is-full text-end font-mono",
|
|
652
|
+
textPadding
|
|
653
|
+
],
|
|
654
|
+
onBlur: handleSave,
|
|
655
|
+
onFocus: handleEdit,
|
|
656
|
+
onChange: ({ target: { value: value2 } }) => setText(value2),
|
|
657
|
+
onKeyDown: (event) => {
|
|
658
|
+
return (
|
|
659
|
+
/* (event.key === 'Escape' && handleCancel()) || */
|
|
660
|
+
event.key === "Enter" && handleSave()
|
|
661
|
+
);
|
|
662
|
+
}
|
|
661
663
|
}));
|
|
662
664
|
};
|
|
663
665
|
var RowSelectorBuilderCell = (cellContext) => {
|
|
@@ -697,15 +699,8 @@ var ColumnBuilder = class {
|
|
|
697
699
|
* Combobox value
|
|
698
700
|
*/
|
|
699
701
|
combobox({ label, classNames, model, onUpdate, ...props }) {
|
|
700
|
-
return
|
|
702
|
+
return {
|
|
701
703
|
minSize: 100,
|
|
702
|
-
meta: {
|
|
703
|
-
model,
|
|
704
|
-
onUpdate,
|
|
705
|
-
cell: {
|
|
706
|
-
classNames
|
|
707
|
-
}
|
|
708
|
-
},
|
|
709
704
|
header: (column) => {
|
|
710
705
|
return label ?? column.header.id;
|
|
711
706
|
},
|
|
@@ -714,21 +709,25 @@ var ColumnBuilder = class {
|
|
|
714
709
|
return /* @__PURE__ */ React8.createElement("div", {
|
|
715
710
|
className: mx5("truncate", classNames)
|
|
716
711
|
}, cellValue ? model?.getText(cellValue) : "");
|
|
712
|
+
},
|
|
713
|
+
...props,
|
|
714
|
+
meta: {
|
|
715
|
+
...props.meta,
|
|
716
|
+
model,
|
|
717
|
+
onUpdate,
|
|
718
|
+
cell: {
|
|
719
|
+
classNames,
|
|
720
|
+
...props.meta?.cell
|
|
721
|
+
}
|
|
717
722
|
}
|
|
718
|
-
}
|
|
723
|
+
};
|
|
719
724
|
}
|
|
720
725
|
/**
|
|
721
726
|
* String formats.
|
|
722
727
|
*/
|
|
723
728
|
string({ label, classNames, onUpdate, ...props } = {}) {
|
|
724
|
-
return
|
|
729
|
+
return {
|
|
725
730
|
minSize: 100,
|
|
726
|
-
meta: {
|
|
727
|
-
onUpdate,
|
|
728
|
-
cell: {
|
|
729
|
-
classNames
|
|
730
|
-
}
|
|
731
|
-
},
|
|
732
731
|
// TODO(burdon): Default.
|
|
733
732
|
header: (column) => {
|
|
734
733
|
return label ?? column.header.id;
|
|
@@ -738,43 +737,51 @@ var ColumnBuilder = class {
|
|
|
738
737
|
return /* @__PURE__ */ React8.createElement("div", {
|
|
739
738
|
className: mx5("truncate", textPadding, classNames)
|
|
740
739
|
}, value);
|
|
740
|
+
},
|
|
741
|
+
...props,
|
|
742
|
+
meta: {
|
|
743
|
+
...props.meta,
|
|
744
|
+
onUpdate,
|
|
745
|
+
cell: {
|
|
746
|
+
...props.meta?.cell,
|
|
747
|
+
classNames
|
|
748
|
+
}
|
|
741
749
|
}
|
|
742
|
-
}
|
|
750
|
+
};
|
|
743
751
|
}
|
|
744
752
|
/**
|
|
745
753
|
* Number formats.
|
|
746
754
|
*/
|
|
747
755
|
number({ label, minSize, classNames, digits, onUpdate, ...props } = {}) {
|
|
748
|
-
return
|
|
756
|
+
return {
|
|
749
757
|
size: 100,
|
|
750
758
|
minSize: 100,
|
|
759
|
+
header: (cell) => label ?? cell.header.id,
|
|
760
|
+
cell: NumberBuilderCell,
|
|
761
|
+
...props,
|
|
751
762
|
meta: {
|
|
763
|
+
...props.meta,
|
|
752
764
|
onUpdate,
|
|
753
765
|
digits,
|
|
754
766
|
header: {
|
|
755
|
-
classNames: "text-end"
|
|
767
|
+
classNames: "text-end",
|
|
768
|
+
...props.meta?.header
|
|
756
769
|
},
|
|
757
770
|
cell: {
|
|
771
|
+
...props.meta?.cell,
|
|
758
772
|
classNames
|
|
759
773
|
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
cell: NumberBuilderCell
|
|
763
|
-
});
|
|
774
|
+
}
|
|
775
|
+
};
|
|
764
776
|
}
|
|
765
777
|
/**
|
|
766
778
|
* Date formats.
|
|
767
779
|
*/
|
|
768
780
|
// TODO(burdon): Date picker (pluggable renderers?)
|
|
769
781
|
date({ label, format: formatSpec, relative, classNames, ...props } = {}) {
|
|
770
|
-
return
|
|
782
|
+
return {
|
|
771
783
|
size: 220,
|
|
772
784
|
minSize: 100,
|
|
773
|
-
meta: {
|
|
774
|
-
cell: {
|
|
775
|
-
classNames
|
|
776
|
-
}
|
|
777
|
-
},
|
|
778
785
|
header: (cell) => label ?? cell.header.id,
|
|
779
786
|
cell: (cell) => {
|
|
780
787
|
const value = cell.getValue();
|
|
@@ -789,24 +796,24 @@ var ColumnBuilder = class {
|
|
|
789
796
|
console.log(value);
|
|
790
797
|
return null;
|
|
791
798
|
}
|
|
799
|
+
},
|
|
800
|
+
...props,
|
|
801
|
+
meta: {
|
|
802
|
+
...props.meta,
|
|
803
|
+
cell: {
|
|
804
|
+
...props.meta?.cell,
|
|
805
|
+
classNames
|
|
806
|
+
}
|
|
792
807
|
}
|
|
793
|
-
}
|
|
808
|
+
};
|
|
794
809
|
}
|
|
795
810
|
/**
|
|
796
811
|
* PublicKey with tooltip.
|
|
797
812
|
*/
|
|
798
|
-
key({ label, tooltip, ...props } = {}) {
|
|
799
|
-
return
|
|
813
|
+
key({ label, tooltip, classNames, ...props } = {}) {
|
|
814
|
+
return {
|
|
800
815
|
size: 94,
|
|
801
816
|
minSize: 94,
|
|
802
|
-
meta: {
|
|
803
|
-
cell: {
|
|
804
|
-
classNames: [
|
|
805
|
-
"font-mono",
|
|
806
|
-
textPadding
|
|
807
|
-
]
|
|
808
|
-
}
|
|
809
|
-
},
|
|
810
817
|
header: (cell) => label ?? cell.header.id,
|
|
811
818
|
cell: (cell) => {
|
|
812
819
|
const value = cell.getValue();
|
|
@@ -817,21 +824,33 @@ var ColumnBuilder = class {
|
|
|
817
824
|
if (!tooltip) {
|
|
818
825
|
return element;
|
|
819
826
|
}
|
|
820
|
-
return /* @__PURE__ */ React8.createElement(Tooltip.Provider, null, /* @__PURE__ */ React8.createElement(Tooltip.Root, null, /* @__PURE__ */ React8.createElement(Tooltip.Trigger, null, element), /* @__PURE__ */ React8.createElement(Tooltip.Content, {
|
|
827
|
+
return /* @__PURE__ */ React8.createElement(Tooltip.Provider, null, /* @__PURE__ */ React8.createElement(Tooltip.Root, null, /* @__PURE__ */ React8.createElement(Tooltip.Trigger, null, element), /* @__PURE__ */ React8.createElement(Tooltip.Portal, null, /* @__PURE__ */ React8.createElement(Tooltip.Content, {
|
|
821
828
|
side: "right"
|
|
822
829
|
}, /* @__PURE__ */ React8.createElement(Tooltip.Arrow, null), /* @__PURE__ */ React8.createElement(ClipboardText, {
|
|
823
830
|
onClick: (ev) => {
|
|
824
831
|
ev.stopPropagation();
|
|
825
832
|
void navigator.clipboard.writeText(value.toHex());
|
|
826
833
|
}
|
|
827
|
-
}))));
|
|
834
|
+
})))));
|
|
835
|
+
},
|
|
836
|
+
...props,
|
|
837
|
+
meta: {
|
|
838
|
+
...props.meta,
|
|
839
|
+
cell: {
|
|
840
|
+
...props.meta?.cell,
|
|
841
|
+
classNames: [
|
|
842
|
+
"font-mono",
|
|
843
|
+
textPadding,
|
|
844
|
+
classNames
|
|
845
|
+
]
|
|
846
|
+
}
|
|
828
847
|
}
|
|
829
|
-
}
|
|
848
|
+
};
|
|
830
849
|
}
|
|
831
850
|
/**
|
|
832
851
|
* Row selector
|
|
833
852
|
*/
|
|
834
|
-
selectRow({
|
|
853
|
+
selectRow({ classNames, onUpdate, id = "selectRow" } = {}) {
|
|
835
854
|
return {
|
|
836
855
|
id,
|
|
837
856
|
size: 32,
|
|
@@ -863,21 +882,24 @@ var ColumnBuilder = class {
|
|
|
863
882
|
* Switch
|
|
864
883
|
*/
|
|
865
884
|
switch({ label, classNames, onUpdate, ...props } = {}) {
|
|
866
|
-
return
|
|
885
|
+
return {
|
|
867
886
|
size: 50,
|
|
868
887
|
minSize: 50,
|
|
888
|
+
header: (column) => label ?? column.header.id,
|
|
889
|
+
cell: SwitchBuilderCell,
|
|
890
|
+
...props,
|
|
869
891
|
meta: {
|
|
892
|
+
...props.meta,
|
|
870
893
|
onUpdate,
|
|
871
894
|
cell: {
|
|
895
|
+
...props.meta?.cell,
|
|
872
896
|
classNames: [
|
|
873
897
|
textPadding,
|
|
874
898
|
classNames
|
|
875
899
|
]
|
|
876
900
|
}
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
cell: SwitchBuilderCell
|
|
880
|
-
});
|
|
901
|
+
}
|
|
902
|
+
};
|
|
881
903
|
}
|
|
882
904
|
/**
|
|
883
905
|
* Icon based on boolean value.
|
|
@@ -885,7 +907,7 @@ var ColumnBuilder = class {
|
|
|
885
907
|
icon({ label, size, on, off, ...props } = {}) {
|
|
886
908
|
const IconOn = on?.Icon ?? Check2;
|
|
887
909
|
const IconOff = off?.Icon ?? X2;
|
|
888
|
-
return
|
|
910
|
+
return {
|
|
889
911
|
size: size ?? 32,
|
|
890
912
|
header: (column) => /* @__PURE__ */ React8.createElement("div", {
|
|
891
913
|
className: "justify-center"
|
|
@@ -903,8 +925,9 @@ var ColumnBuilder = class {
|
|
|
903
925
|
} else {
|
|
904
926
|
return null;
|
|
905
927
|
}
|
|
906
|
-
}
|
|
907
|
-
|
|
928
|
+
},
|
|
929
|
+
...props
|
|
930
|
+
};
|
|
908
931
|
}
|
|
909
932
|
};
|
|
910
933
|
export {
|
|
@@ -913,7 +936,6 @@ export {
|
|
|
913
936
|
ColumnMenu,
|
|
914
937
|
ColumnPanel,
|
|
915
938
|
Table,
|
|
916
|
-
columnTypes,
|
|
917
939
|
createColumnBuilder,
|
|
918
940
|
currentRow,
|
|
919
941
|
flushPadding,
|
|
@@ -934,6 +956,7 @@ export {
|
|
|
934
956
|
theadResizeThumb,
|
|
935
957
|
theadRoot,
|
|
936
958
|
theadTh,
|
|
937
|
-
theadTr
|
|
959
|
+
theadTr,
|
|
960
|
+
translations_default as translations
|
|
938
961
|
};
|
|
939
962
|
//# sourceMappingURL=index.mjs.map
|