@dxos/react-ui-table 0.6.7-staging.e9eb1ed → 0.6.8-main.046e6cf
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 +189 -213
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/components/Cell/Cell.d.ts +2 -2
- package/dist/types/src/components/Cell/Cell.d.ts.map +1 -1
- package/dist/types/src/components/Cell/CellCombobox.d.ts +3 -3
- package/dist/types/src/components/Cell/CellCombobox.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnMenu.d.ts +3 -3
- package/dist/types/src/components/ColumnMenu/ColumnMenu.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnMenu.stories.d.ts +3 -3
- package/dist/types/src/components/ColumnMenu/ColumnMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.d.ts +2 -2
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.d.ts.map +1 -1
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.stories.d.ts +63 -0
- package/dist/types/src/components/ColumnMenu/ColumnSettingsForm.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/Table.d.ts +6 -5
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +9 -9
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableBody.d.ts +2 -2
- package/dist/types/src/components/Table/TableBody.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableContext.d.ts +2 -2
- package/dist/types/src/components/Table/TableContext.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableHead.d.ts +2 -2
- package/dist/types/src/components/Table/TableHead.d.ts.map +1 -1
- package/dist/types/src/components/Table/TableRootContext.d.ts +0 -1
- package/dist/types/src/components/Table/TableRootContext.d.ts.map +1 -1
- package/dist/types/src/components/Table/props.d.ts +0 -1
- package/dist/types/src/components/Table/props.d.ts.map +1 -1
- package/dist/types/src/helpers.d.ts +1 -1
- package/dist/types/src/helpers.d.ts.map +1 -1
- package/dist/types/src/hooks/useColumnSizing.d.ts +0 -1
- package/dist/types/src/hooks/useColumnSizing.d.ts.map +1 -1
- package/dist/types/src/hooks/useColumnSorting.d.ts.map +1 -1
- package/dist/types/src/hooks/usePinLastRow.d.ts.map +1 -1
- package/dist/types/src/hooks/useRowSelection.d.ts +1 -1
- package/dist/types/src/hooks/useRowSelection.d.ts.map +1 -1
- package/dist/types/src/schema/SchemaToTable.stories.d.ts +2 -1
- package/dist/types/src/schema/SchemaToTable.stories.d.ts.map +1 -1
- package/dist/types/src/schema/schema.d.ts.map +1 -1
- package/dist/types/src/schema/schemaToColumns.d.ts.map +1 -1
- package/dist/types/src/theme.d.ts +6 -10
- package/dist/types/src/theme.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/components/Cell/Cell.tsx +46 -4
- package/src/components/ColumnMenu/ColumnMenu.tsx +6 -8
- package/src/components/ColumnMenu/ColumnSettingsForm.stories.tsx +104 -0
- package/src/components/ColumnMenu/ColumnSettingsForm.tsx +60 -73
- package/src/components/Table/Table.stories.tsx +2 -2
- package/src/components/Table/Table.tsx +12 -7
- package/src/components/Table/TableBody.tsx +2 -1
- package/src/components/Table/TableContext.tsx +1 -1
- package/src/components/Table/TableHead.tsx +3 -4
- package/src/components/Table/props.ts +0 -1
- package/src/helpers.tsx +2 -0
- package/src/hooks/usePinLastRow.ts +1 -18
- package/src/theme.ts +28 -55
- package/dist/types/src/components/Table/TableFooter.d.ts +0 -9
- package/dist/types/src/components/Table/TableFooter.d.ts.map +0 -1
- package/src/components/Table/TableFooter.tsx +0 -45
|
@@ -91,21 +91,15 @@ var CellCombobox = ({ model, value, onValueChange }) => {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
// packages/ui/react-ui-table/src/components/ColumnMenu/ColumnMenu.tsx
|
|
94
|
-
import { X
|
|
94
|
+
import { X, GearSix, CaretDown as CaretDown2, ArrowDown, ArrowUp, ArrowRight, ArrowLeft } from "@phosphor-icons/react";
|
|
95
95
|
import React4, { useRef as useRef2, useState as useState6, useCallback as useCallback5 } from "react";
|
|
96
|
-
import { Button as Button2,
|
|
97
|
-
import { getSize as
|
|
96
|
+
import { Button as Button2, Popover as Popover2, DropdownMenu } from "@dxos/react-ui";
|
|
97
|
+
import { getSize as getSize2, mx as mx2 } from "@dxos/react-ui-theme";
|
|
98
98
|
|
|
99
99
|
// packages/ui/react-ui-table/src/components/ColumnMenu/ColumnSettingsForm.tsx
|
|
100
|
-
import { Check, Trash, X } from "@phosphor-icons/react";
|
|
101
100
|
import React2, { useRef, useState as useState2 } from "react";
|
|
102
|
-
import { Button, Input, Select,
|
|
103
|
-
import { getSize as getSize2, mx as mx2 } from "@dxos/react-ui-theme";
|
|
101
|
+
import { Button, Input, Select, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
104
102
|
import { safeParseInt } from "@dxos/util";
|
|
105
|
-
var Section = ({ children, className }) => /* @__PURE__ */ React2.createElement("div", {
|
|
106
|
-
role: "none",
|
|
107
|
-
className: mx2("p-2", className)
|
|
108
|
-
}, children);
|
|
109
103
|
var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDelete, onClose }) => {
|
|
110
104
|
const [formState, setFormState] = useState2({
|
|
111
105
|
prop: column.id,
|
|
@@ -117,9 +111,6 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
117
111
|
});
|
|
118
112
|
const propRef = useRef(null);
|
|
119
113
|
const { t } = useTranslation2(translationKey);
|
|
120
|
-
const handleCancel = () => {
|
|
121
|
-
onClose?.();
|
|
122
|
-
};
|
|
123
114
|
const handleSave = () => {
|
|
124
115
|
const { prop, refTable, refProp, type, label, digits } = formState;
|
|
125
116
|
if (!prop.length || !prop.match(/^[a-zA-Z_].+/i)) {
|
|
@@ -149,20 +140,21 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
149
140
|
onClose?.();
|
|
150
141
|
};
|
|
151
142
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
152
|
-
className: "
|
|
153
|
-
}, /* @__PURE__ */ React2.createElement(
|
|
154
|
-
|
|
155
|
-
}, t("column label label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
143
|
+
className: "p-1 space-y-2"
|
|
144
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
145
|
+
className: "space-y-1"
|
|
146
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("column label label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
156
147
|
placeholder: "Column label",
|
|
157
148
|
value: formState.label ?? "",
|
|
158
149
|
onChange: (event) => setFormState((prevState) => ({
|
|
159
150
|
...prevState,
|
|
160
151
|
label: event.target.value
|
|
161
152
|
})),
|
|
162
|
-
autoFocus: true
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
153
|
+
autoFocus: true,
|
|
154
|
+
"data-testid": "table.column-settings.label"
|
|
155
|
+
}))), /* @__PURE__ */ React2.createElement("div", {
|
|
156
|
+
className: "space-y-1"
|
|
157
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("property key label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
166
158
|
ref: propRef,
|
|
167
159
|
placeholder: "Property key",
|
|
168
160
|
value: formState.prop ?? "",
|
|
@@ -170,17 +162,17 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
170
162
|
...prevState,
|
|
171
163
|
prop: event.target.value.replace(/[^\w_]/g, "")
|
|
172
164
|
}))
|
|
173
|
-
})), /* @__PURE__ */ React2.createElement(
|
|
174
|
-
|
|
175
|
-
}, t("column type label")), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
165
|
+
}))), /* @__PURE__ */ React2.createElement("div", {
|
|
166
|
+
className: "space-y-1"
|
|
167
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("column type label")), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
176
168
|
value: formState.type,
|
|
177
169
|
onValueChange: (value) => setFormState((prevState) => ({
|
|
178
170
|
...prevState,
|
|
179
171
|
type: value
|
|
180
172
|
}))
|
|
181
173
|
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
182
|
-
|
|
183
|
-
|
|
174
|
+
classNames: "is-full",
|
|
175
|
+
placeholder: "Type"
|
|
184
176
|
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, [
|
|
185
177
|
"number",
|
|
186
178
|
"boolean",
|
|
@@ -189,17 +181,17 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
189
181
|
].map((type) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
190
182
|
key: type,
|
|
191
183
|
value: type
|
|
192
|
-
}, t(`${type} column type label`))))))))), formState.type === "number" && /* @__PURE__ */ React2.createElement(
|
|
193
|
-
|
|
194
|
-
}, t("digits label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
184
|
+
}, t(`${type} column type label`))))))))), formState.type === "number" && /* @__PURE__ */ React2.createElement("div", {
|
|
185
|
+
className: "space-y-1"
|
|
186
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, t("digits label")), /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
195
187
|
value: formState.digits ?? "",
|
|
196
188
|
onChange: (event) => setFormState((prevState) => ({
|
|
197
189
|
...prevState,
|
|
198
190
|
digits: event.target.value
|
|
199
191
|
}))
|
|
200
|
-
}))), formState.type === "ref" && /* @__PURE__ */ React2.createElement(
|
|
201
|
-
|
|
202
|
-
}, "Table"), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
192
|
+
}))), formState.type === "ref" && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", {
|
|
193
|
+
className: "space-y-1"
|
|
194
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, "Table"), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
203
195
|
value: formState.refTable,
|
|
204
196
|
onValueChange: (value) => setFormState((prevState) => ({
|
|
205
197
|
...prevState,
|
|
@@ -211,49 +203,32 @@ var ColumnSettingsForm = ({ column, tableDef, tablesToReference, onUpdate, onDel
|
|
|
211
203
|
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, tablesToReference.filter((t2) => t2.id !== tableDef.id).map(({ id, name }) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
212
204
|
key: id,
|
|
213
205
|
value: id
|
|
214
|
-
}, name ?? id))))))), formState.refTable && /* @__PURE__ */ React2.createElement(
|
|
215
|
-
|
|
216
|
-
}, "Table property"), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
206
|
+
}, name ?? id)))))))), formState.refTable && /* @__PURE__ */ React2.createElement("div", {
|
|
207
|
+
className: "space-y-1"
|
|
208
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Label, null, "Table property"), /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
217
209
|
value: formState.refProp,
|
|
218
210
|
onValueChange: (value) => setFormState((prevState) => ({
|
|
219
211
|
...prevState,
|
|
220
212
|
refProp: value
|
|
221
213
|
}))
|
|
222
214
|
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
223
|
-
placeholder: "Property"
|
|
224
|
-
classNames: "is-full"
|
|
215
|
+
placeholder: "Property"
|
|
225
216
|
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, tablesToReference.find((tableDef2) => tableDef2.id === formState.refTable)?.columns.map(({ id, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
226
217
|
key: id,
|
|
227
218
|
value: id
|
|
228
|
-
}, label ?? id)))))))), /* @__PURE__ */ React2.createElement(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
219
|
+
}, label ?? id))))))))), /* @__PURE__ */ React2.createElement("div", {
|
|
220
|
+
role: "none",
|
|
221
|
+
className: "h-1"
|
|
222
|
+
}), /* @__PURE__ */ React2.createElement("div", {
|
|
223
|
+
className: "flex flex-row justify-end gap-1"
|
|
232
224
|
}, /* @__PURE__ */ React2.createElement(Button, {
|
|
225
|
+
onClick: handleDelete,
|
|
226
|
+
"data-testid": "table.column-settings.delete"
|
|
227
|
+
}, t("delete label")), /* @__PURE__ */ React2.createElement(Button, {
|
|
233
228
|
variant: "primary",
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
},
|
|
237
|
-
className: "grow"
|
|
238
|
-
}), /* @__PURE__ */ React2.createElement(Check, {
|
|
239
|
-
className: getSize2(5)
|
|
240
|
-
})), /* @__PURE__ */ React2.createElement(Button, {
|
|
241
|
-
classNames: "is-full flex gap-2",
|
|
242
|
-
onClick: handleCancel
|
|
243
|
-
}, /* @__PURE__ */ React2.createElement("span", null, t("cancel label", {
|
|
244
|
-
ns: "os"
|
|
245
|
-
})), /* @__PURE__ */ React2.createElement("div", {
|
|
246
|
-
className: "grow"
|
|
247
|
-
}), /* @__PURE__ */ React2.createElement(X, {
|
|
248
|
-
className: getSize2(5)
|
|
249
|
-
})), /* @__PURE__ */ React2.createElement(Button, {
|
|
250
|
-
classNames: "is-full flex gap-2",
|
|
251
|
-
onClick: handleDelete
|
|
252
|
-
}, /* @__PURE__ */ React2.createElement("span", null, t("delete label")), /* @__PURE__ */ React2.createElement("div", {
|
|
253
|
-
className: "grow"
|
|
254
|
-
}), /* @__PURE__ */ React2.createElement(Trash, {
|
|
255
|
-
className: getSize2(5)
|
|
256
|
-
}))));
|
|
229
|
+
onClick: handleSave,
|
|
230
|
+
"data-testid": "table.column-settings.save"
|
|
231
|
+
}, t("save label"))));
|
|
257
232
|
};
|
|
258
233
|
|
|
259
234
|
// packages/ui/react-ui-table/src/hooks/useColumnSizing.ts
|
|
@@ -363,17 +338,7 @@ var useSortColumn = (column) => {
|
|
|
363
338
|
// packages/ui/react-ui-table/src/hooks/usePinLastRow.ts
|
|
364
339
|
import { useCallback as useCallback3, useEffect as useEffect2, useState as useState5 } from "react";
|
|
365
340
|
var usePinLastRow = (pinLastRow, table, data) => {
|
|
366
|
-
const { scrollContextRef } = useTableRootContext();
|
|
367
341
|
const [pinnedRowKey, setPinnedRowKey] = useState5();
|
|
368
|
-
const scrollToBottom = useCallback3(() => {
|
|
369
|
-
const element = scrollContextRef.current;
|
|
370
|
-
const scrollHeight = element?.scrollHeight;
|
|
371
|
-
if (element && scrollHeight) {
|
|
372
|
-
requestAnimationFrame(() => element.scrollTo({
|
|
373
|
-
top: scrollHeight
|
|
374
|
-
}));
|
|
375
|
-
}
|
|
376
|
-
}, []);
|
|
377
342
|
const pinRow = useCallback3((rowToPin) => {
|
|
378
343
|
table.resetRowPinning();
|
|
379
344
|
rowToPin.pin("bottom");
|
|
@@ -397,12 +362,8 @@ var usePinLastRow = (pinLastRow, table, data) => {
|
|
|
397
362
|
return;
|
|
398
363
|
}
|
|
399
364
|
pinRow(lastRow);
|
|
400
|
-
if (pinnedRowKey !== void 0) {
|
|
401
|
-
scrollToBottom();
|
|
402
|
-
}
|
|
403
365
|
}, [
|
|
404
366
|
table,
|
|
405
|
-
scrollToBottom,
|
|
406
367
|
pinnedRowKey
|
|
407
368
|
]);
|
|
408
369
|
useEffect2(() => {
|
|
@@ -472,7 +433,7 @@ var ColumnMenu = ({ column, columnOrderable, columnPosition, onColumnReorder, ..
|
|
|
472
433
|
shouldPreventFocusOnClose
|
|
473
434
|
]);
|
|
474
435
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
475
|
-
className: "flex items-center justify-
|
|
436
|
+
className: "flex items-center justify-between"
|
|
476
437
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
477
438
|
className: "flex items-center gap-1 truncate",
|
|
478
439
|
title
|
|
@@ -493,9 +454,10 @@ var ColumnMenu = ({ column, columnOrderable, columnPosition, onColumnReorder, ..
|
|
|
493
454
|
}, /* @__PURE__ */ React4.createElement(Popover2.Anchor, {
|
|
494
455
|
asChild: true
|
|
495
456
|
}, /* @__PURE__ */ React4.createElement(Button2, {
|
|
496
|
-
variant: "ghost"
|
|
457
|
+
variant: "ghost",
|
|
458
|
+
"data-testid": "table.column-menu"
|
|
497
459
|
}, /* @__PURE__ */ React4.createElement(CaretDown2, {
|
|
498
|
-
className:
|
|
460
|
+
className: getSize2(4)
|
|
499
461
|
})))), /* @__PURE__ */ React4.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Content, {
|
|
500
462
|
onCloseAutoFocus: onDropdownCloseAutoFocus,
|
|
501
463
|
sideOffset: 4,
|
|
@@ -507,7 +469,7 @@ var ColumnMenu = ({ column, columnOrderable, columnPosition, onColumnReorder, ..
|
|
|
507
469
|
}, "Sort ascending"), /* @__PURE__ */ React4.createElement("span", {
|
|
508
470
|
className: "opacity-50"
|
|
509
471
|
}, /* @__PURE__ */ React4.createElement(ArrowUp, {
|
|
510
|
-
className:
|
|
472
|
+
className: getSize2(4)
|
|
511
473
|
}))), /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
512
474
|
onClick: () => onSelectSort("desc")
|
|
513
475
|
}, /* @__PURE__ */ React4.createElement("span", {
|
|
@@ -515,15 +477,15 @@ var ColumnMenu = ({ column, columnOrderable, columnPosition, onColumnReorder, ..
|
|
|
515
477
|
}, "Sort descending"), /* @__PURE__ */ React4.createElement("span", {
|
|
516
478
|
className: "opacity-50"
|
|
517
479
|
}, /* @__PURE__ */ React4.createElement(ArrowDown, {
|
|
518
|
-
className:
|
|
480
|
+
className: getSize2(4)
|
|
519
481
|
}))), sortDirection && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
520
482
|
onClick: onClearSort
|
|
521
483
|
}, /* @__PURE__ */ React4.createElement("span", {
|
|
522
484
|
className: "grow"
|
|
523
485
|
}, "Clear sort"), /* @__PURE__ */ React4.createElement("span", {
|
|
524
486
|
className: "opacity-50"
|
|
525
|
-
}, /* @__PURE__ */ React4.createElement(
|
|
526
|
-
className:
|
|
487
|
+
}, /* @__PURE__ */ React4.createElement(X, {
|
|
488
|
+
className: getSize2(4)
|
|
527
489
|
})))), columnOrderable && /* @__PURE__ */ React4.createElement(React4.Fragment, null, columnPosition !== "start" && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
528
490
|
onClick: () => onColumnReorder(header.column.id, "left")
|
|
529
491
|
}, /* @__PURE__ */ React4.createElement("span", {
|
|
@@ -531,7 +493,7 @@ var ColumnMenu = ({ column, columnOrderable, columnPosition, onColumnReorder, ..
|
|
|
531
493
|
}, "Move left"), /* @__PURE__ */ React4.createElement("span", {
|
|
532
494
|
className: "opacity-50"
|
|
533
495
|
}, /* @__PURE__ */ React4.createElement(ArrowLeft, {
|
|
534
|
-
className:
|
|
496
|
+
className: mx2(getSize2(4))
|
|
535
497
|
}))), columnPosition !== "end" && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
536
498
|
onClick: () => onColumnReorder(header.column.id, "right")
|
|
537
499
|
}, /* @__PURE__ */ React4.createElement("span", {
|
|
@@ -539,24 +501,21 @@ var ColumnMenu = ({ column, columnOrderable, columnPosition, onColumnReorder, ..
|
|
|
539
501
|
}, "Move right"), /* @__PURE__ */ React4.createElement("span", {
|
|
540
502
|
className: "opacity-50"
|
|
541
503
|
}, /* @__PURE__ */ React4.createElement(ArrowRight, {
|
|
542
|
-
className:
|
|
504
|
+
className: mx2(getSize2(4))
|
|
543
505
|
})))), /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
|
|
544
|
-
onClick: onOpenColumnSettings
|
|
506
|
+
onClick: onOpenColumnSettings,
|
|
507
|
+
"data-testid": "table.open-column-settings"
|
|
545
508
|
}, /* @__PURE__ */ React4.createElement("span", {
|
|
546
509
|
className: "grow"
|
|
547
510
|
}, "Column settings"), /* @__PURE__ */ React4.createElement("span", {
|
|
548
511
|
className: "opacity-50"
|
|
549
512
|
}, /* @__PURE__ */ React4.createElement(GearSix, {
|
|
550
|
-
className:
|
|
551
|
-
})))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))), /* @__PURE__ */ React4.createElement(Popover2.Portal, null, /* @__PURE__ */ React4.createElement(Popover2.Content, null, /* @__PURE__ */ React4.createElement(Popover2.Viewport, {
|
|
552
|
-
classNames: "w-60"
|
|
553
|
-
}, /* @__PURE__ */ React4.createElement(DensityProvider, {
|
|
554
|
-
density: "fine"
|
|
555
|
-
}, /* @__PURE__ */ React4.createElement(ColumnSettingsForm, {
|
|
513
|
+
className: mx2(getSize2(4), "rotate-90")
|
|
514
|
+
})))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))), /* @__PURE__ */ React4.createElement(Popover2.Portal, null, /* @__PURE__ */ React4.createElement(Popover2.Content, null, /* @__PURE__ */ React4.createElement(Popover2.Viewport, null, /* @__PURE__ */ React4.createElement(ColumnSettingsForm, {
|
|
556
515
|
...props,
|
|
557
516
|
column,
|
|
558
517
|
onClose: () => setIsColumnSettingsOpen(false)
|
|
559
|
-
}))
|
|
518
|
+
})), /* @__PURE__ */ React4.createElement(Popover2.Arrow, null))))));
|
|
560
519
|
};
|
|
561
520
|
var SortIndicator = ({ direction, onClick }) => {
|
|
562
521
|
if (direction === void 0) {
|
|
@@ -566,12 +525,12 @@ var SortIndicator = ({ direction, onClick }) => {
|
|
|
566
525
|
switch (direction) {
|
|
567
526
|
case "asc":
|
|
568
527
|
icon = /* @__PURE__ */ React4.createElement(ArrowUp, {
|
|
569
|
-
className:
|
|
528
|
+
className: getSize2(3)
|
|
570
529
|
});
|
|
571
530
|
break;
|
|
572
531
|
case "desc":
|
|
573
532
|
icon = /* @__PURE__ */ React4.createElement(ArrowDown, {
|
|
574
|
-
className:
|
|
533
|
+
className: getSize2(3)
|
|
575
534
|
});
|
|
576
535
|
break;
|
|
577
536
|
}
|
|
@@ -584,9 +543,9 @@ var SortIndicator = ({ direction, onClick }) => {
|
|
|
584
543
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
585
544
|
import { Slot } from "@radix-ui/react-slot";
|
|
586
545
|
import { getCoreRowModel, getExpandedRowModel, getGroupedRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
587
|
-
import
|
|
588
|
-
import { useDefaultValue } from "@dxos/react-ui";
|
|
589
|
-
import { mx as
|
|
546
|
+
import React8, { Fragment, useCallback as useCallback7, useEffect as useEffect3, useState as useState8, useContext as useContext3, memo } from "react";
|
|
547
|
+
import { DensityProvider, useDefaultValue } from "@dxos/react-ui";
|
|
548
|
+
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
590
549
|
|
|
591
550
|
// packages/ui/react-ui-table/src/components/Table/TableBody.tsx
|
|
592
551
|
import { useArrowNavigationGroup } from "@fluentui/react-tabster";
|
|
@@ -623,48 +582,84 @@ var useTableRootContext = () => {
|
|
|
623
582
|
var TableRootContext = createContext2({});
|
|
624
583
|
|
|
625
584
|
// packages/ui/react-ui-table/src/theme.ts
|
|
626
|
-
import {
|
|
585
|
+
import { focusRing, ghostSelected, ghostSelectedCurrent, mx as mx3 } from "@dxos/react-ui-theme";
|
|
627
586
|
var currentRow = "!bg-neutral-75 !dark:bg-neutral-850";
|
|
628
587
|
var selectedRow = "!bg-primary-100 dark:!bg-primary-700";
|
|
629
588
|
var flushPadding = "pli-0 plb-0";
|
|
630
|
-
var textPadding = "pli-2 plb-0
|
|
631
|
-
var headPadding = "pli-2 plb-
|
|
632
|
-
var gridCellFocusRing = "focus-within:outline outline-
|
|
633
|
-
var
|
|
634
|
-
var
|
|
635
|
-
var
|
|
636
|
-
var
|
|
637
|
-
var
|
|
589
|
+
var textPadding = "pli-2 plb-0";
|
|
590
|
+
var headPadding = "pli-2 plb-0";
|
|
591
|
+
var gridCellFocusRing = "relative focus-within:outline focus-within:outline-1 outline-primary-500 outline-offset-[-1px]";
|
|
592
|
+
var borderColors = "border-neutral-200 dark:border-neutral-700";
|
|
593
|
+
var stickyRowColors = "bg-neutral-50 dark:bg-neutral-800";
|
|
594
|
+
var tableRoot = ({ fullWidth }, ...etc) => mx3("table-fixed", "text-neutral-800 dark:text-neutral-200", fullWidth && "is-full", ...etc);
|
|
595
|
+
var groupTh = (_props, ...etc) => mx3("text-start font-medium", flushPadding, ...etc);
|
|
596
|
+
var theadRoot = ({ header, stickyHeader }, ...etc) => mx3(header ? stickyHeader && "sticky block-start-[--sticky-top] z-[1]" : "collapse", stickyRowColors, ...etc);
|
|
597
|
+
var theadTr = (_props, ...etc) => mx3("group", ...etc);
|
|
598
|
+
var theadTh = ({ border }, ...etc) => mx3("relative", "text-start text-xs select-none truncate", headPadding, border && borderColors, border && "border-t border-b border-l last:border-r", ...etc);
|
|
638
599
|
var theadResizeRoot = ({ isResizing }) => {
|
|
639
|
-
return
|
|
600
|
+
return mx3("absolute h-full w-[4px] top-0 right-0", "cursor-col-resize", "user-select-none", "touch-action-none", "pointer-coarse:bg-neutral-100 dark:pointer-coarse:bg-neutral-800", !isResizing && "group-hover:bg-neutral-100 dark:group-hover:bg-neutral-800", isResizing && "bg-primary-500");
|
|
640
601
|
};
|
|
641
|
-
var tbodyRoot = (_props, ...etc) =>
|
|
642
|
-
var tbodyTr = ({ canBeCurrent, isPinned }, ...etc) =>
|
|
643
|
-
var tdRoot = ({ border, isGrid }, ...etc) =>
|
|
644
|
-
var tdContent = (_props, ...etc) => mx4(...etc);
|
|
645
|
-
var tfootRoot = (_props, ...etc) => mx4("sticky block-end-0 z-10", modalSurface, ...etc);
|
|
646
|
-
var tfootTr = (_props, ...etc) => mx4(...etc);
|
|
647
|
-
var tfootTh = ({ border }, ...etc) => mx4(textPadding, modalSurface, border && groupBorder, ...etc);
|
|
602
|
+
var tbodyRoot = (_props, ...etc) => mx3(...etc);
|
|
603
|
+
var tbodyTr = ({ canBeCurrent, isPinned }, ...etc) => mx3("group", canBeCurrent ? ghostSelectedCurrent : ghostSelected, canBeCurrent && focusRing, canBeCurrent && "cursor-pointer", isPinned && "sticky z-1 block-end-0", isPinned && stickyRowColors, ...etc);
|
|
604
|
+
var tdRoot = ({ border, isGrid, pinned }, ...etc) => mx3("relative", "focus-within:!bg-neutral-50 dark:focus-within:!bg-neutral-900", flushPadding, border && "border-b border-l last:border-r border-neutral-200 dark:border-neutral-700", pinned && "border-t", isGrid && gridCellFocusRing, ...etc);
|
|
648
605
|
|
|
649
606
|
// packages/ui/react-ui-table/src/components/Cell/Cell.tsx
|
|
650
607
|
import { useFocusableGroup } from "@fluentui/react-tabster";
|
|
651
|
-
import React5 from "react";
|
|
608
|
+
import React5, { useCallback as useCallback6 } from "react";
|
|
652
609
|
var CELL_NAME = "Cell";
|
|
653
610
|
var FocusableCell = ({ cell, children }) => {
|
|
654
611
|
const tableContext = useTableContext();
|
|
655
612
|
const domAttributes = useFocusableGroup({
|
|
656
613
|
tabBehavior: "limited"
|
|
657
614
|
});
|
|
658
|
-
const
|
|
615
|
+
const pinned = tableContext.table.getState().rowPinning?.bottom?.includes(cell.row.id);
|
|
616
|
+
const className = tdRoot({
|
|
617
|
+
...tableContext,
|
|
618
|
+
pinned
|
|
619
|
+
}, cell.column.columnDef.meta?.cell?.classNames);
|
|
620
|
+
const handleKeyDown = useCallback6(({ key, currentTarget }) => {
|
|
621
|
+
if (key !== "Enter") {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const currentRow2 = currentTarget.closest("tr");
|
|
625
|
+
if (!currentRow2) {
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
const cellIndex = Array.from(currentRow2.cells || []).indexOf(currentTarget);
|
|
629
|
+
const nextSibling = currentRow2.nextElementSibling;
|
|
630
|
+
if (!(nextSibling instanceof HTMLTableRowElement)) {
|
|
631
|
+
let depth = 0;
|
|
632
|
+
const pollForNewRow = () => {
|
|
633
|
+
const newNextSibling = currentRow2.nextElementSibling;
|
|
634
|
+
if (newNextSibling instanceof HTMLTableRowElement) {
|
|
635
|
+
const nextCell = newNextSibling.cells[cellIndex];
|
|
636
|
+
const input = nextCell.querySelector("input");
|
|
637
|
+
if (input) {
|
|
638
|
+
input.focus();
|
|
639
|
+
}
|
|
640
|
+
currentRow2.scrollIntoView({
|
|
641
|
+
behavior: "smooth",
|
|
642
|
+
block: "center"
|
|
643
|
+
});
|
|
644
|
+
} else if (depth++ < 100) {
|
|
645
|
+
requestAnimationFrame(pollForNewRow);
|
|
646
|
+
}
|
|
647
|
+
};
|
|
648
|
+
requestAnimationFrame(pollForNewRow);
|
|
649
|
+
}
|
|
650
|
+
}, []);
|
|
659
651
|
return /* @__PURE__ */ React5.createElement("td", {
|
|
652
|
+
"data-testid": "table.cell",
|
|
660
653
|
tabIndex: 0,
|
|
661
654
|
...domAttributes,
|
|
662
|
-
className
|
|
655
|
+
className,
|
|
656
|
+
onKeyDown: handleKeyDown
|
|
663
657
|
}, children);
|
|
664
658
|
};
|
|
665
659
|
var StaticCell = ({ cell, children }) => {
|
|
666
660
|
const tableContext = useTableContext();
|
|
667
661
|
return /* @__PURE__ */ React5.createElement("td", {
|
|
662
|
+
"data-testid": "table.cell",
|
|
668
663
|
className: tdRoot(tableContext, cell.column.columnDef.meta?.cell?.classNames)
|
|
669
664
|
}, children);
|
|
670
665
|
};
|
|
@@ -699,6 +694,7 @@ var TableBody = ({ rows }) => {
|
|
|
699
694
|
key: keyAccessor ? keyAccessor(row.original) : row.id,
|
|
700
695
|
className: classNames,
|
|
701
696
|
"data-index": row.index,
|
|
697
|
+
"data-testid": "table.data-row",
|
|
702
698
|
ref: virtualizer.measureElement,
|
|
703
699
|
...isCurrent && {
|
|
704
700
|
"aria-current": "location"
|
|
@@ -722,7 +718,6 @@ var TableBody = ({ rows }) => {
|
|
|
722
718
|
key: cell.id,
|
|
723
719
|
cell
|
|
724
720
|
}, flexRender(cell.column.columnDef.cell, {
|
|
725
|
-
className: "pli-2",
|
|
726
721
|
...cell.getContext()
|
|
727
722
|
}));
|
|
728
723
|
}), expand && /* @__PURE__ */ React6.createElement("td", null));
|
|
@@ -730,44 +725,22 @@ var TableBody = ({ rows }) => {
|
|
|
730
725
|
};
|
|
731
726
|
TableBody.displayName = TABLE_BODY_NAME;
|
|
732
727
|
|
|
733
|
-
// packages/ui/react-ui-table/src/components/Table/
|
|
728
|
+
// packages/ui/react-ui-table/src/components/Table/TableHead.tsx
|
|
734
729
|
import { flexRender as flexRender2 } from "@tanstack/react-table";
|
|
735
730
|
import React7 from "react";
|
|
736
|
-
var TABLE_FOOT_NAME = "TableFooter";
|
|
737
|
-
var TableFooter = (props) => {
|
|
738
|
-
const tableContext = useTableContext();
|
|
739
|
-
const { table, expand, debug } = tableContext;
|
|
740
|
-
const footers = table.getFooterGroups();
|
|
741
|
-
return /* @__PURE__ */ React7.createElement("tfoot", {
|
|
742
|
-
className: tfootRoot(props)
|
|
743
|
-
}, footers.map((footerGroup) => /* @__PURE__ */ React7.createElement("tr", {
|
|
744
|
-
key: footerGroup.id,
|
|
745
|
-
className: tfootTr(tableContext)
|
|
746
|
-
}, debug && /* @__PURE__ */ React7.createElement("th", null), footerGroup.headers.map((footer) => {
|
|
747
|
-
return /* @__PURE__ */ React7.createElement("th", {
|
|
748
|
-
key: footer.id,
|
|
749
|
-
className: tfootTh(tableContext, footer.column.columnDef.meta?.footer?.classNames)
|
|
750
|
-
}, footer.isPlaceholder ? null : flexRender2(footer.column.columnDef.footer, footer.getContext()));
|
|
751
|
-
}), expand && /* @__PURE__ */ React7.createElement("th", null))));
|
|
752
|
-
};
|
|
753
|
-
TableFooter.displayName = TABLE_FOOT_NAME;
|
|
754
|
-
|
|
755
|
-
// packages/ui/react-ui-table/src/components/Table/TableHead.tsx
|
|
756
|
-
import { flexRender as flexRender3 } from "@tanstack/react-table";
|
|
757
|
-
import React8 from "react";
|
|
758
731
|
var TABLE_HEAD_NAME = "TableHeader";
|
|
759
732
|
var TableHead = (_props) => {
|
|
760
733
|
const tableContext = useTableContext();
|
|
761
734
|
const headerGroups = tableContext.table.getHeaderGroups();
|
|
762
|
-
return /* @__PURE__ */
|
|
735
|
+
return /* @__PURE__ */ React7.createElement("thead", {
|
|
763
736
|
className: theadRoot(tableContext)
|
|
764
737
|
}, headerGroups.map((headerGroup) => {
|
|
765
738
|
return (
|
|
766
739
|
// Group element to hover resize handles.
|
|
767
|
-
/* @__PURE__ */
|
|
740
|
+
/* @__PURE__ */ React7.createElement("tr", {
|
|
768
741
|
key: headerGroup.id,
|
|
769
742
|
className: theadTr(tableContext)
|
|
770
|
-
}, tableContext.debug && /* @__PURE__ */
|
|
743
|
+
}, tableContext.debug && /* @__PURE__ */ React7.createElement("th", {
|
|
771
744
|
className: "font-mono",
|
|
772
745
|
style: {
|
|
773
746
|
width: 32
|
|
@@ -776,13 +749,14 @@ var TableHead = (_props) => {
|
|
|
776
749
|
const isResizing = header.column.getIsResizing();
|
|
777
750
|
const onResize = header.getResizeHandler();
|
|
778
751
|
const resizable = header.column.columnDef.meta?.resizable;
|
|
779
|
-
return /* @__PURE__ */
|
|
752
|
+
return /* @__PURE__ */ React7.createElement("th", {
|
|
780
753
|
key: header.id,
|
|
781
754
|
style: {
|
|
782
755
|
width: header.getSize()
|
|
783
756
|
},
|
|
784
|
-
className: theadTh(tableContext, header.column.columnDef.meta?.header?.classNames)
|
|
785
|
-
|
|
757
|
+
className: theadTh(tableContext, header.column.columnDef.meta?.header?.classNames),
|
|
758
|
+
"data-testid": "table.header-cell"
|
|
759
|
+
}, !header || header.isPlaceholder ? null : flexRender2(header.column.columnDef.header, header.getContext()), resizable && /* @__PURE__ */ React7.createElement("div", {
|
|
786
760
|
className: theadResizeRoot({
|
|
787
761
|
isResizing
|
|
788
762
|
}),
|
|
@@ -790,7 +764,7 @@ var TableHead = (_props) => {
|
|
|
790
764
|
onMouseDown: onResize,
|
|
791
765
|
onTouchStart: onResize
|
|
792
766
|
}));
|
|
793
|
-
}), tableContext.expand && /* @__PURE__ */
|
|
767
|
+
}), tableContext.expand && /* @__PURE__ */ React7.createElement("th", null))
|
|
794
768
|
);
|
|
795
769
|
}));
|
|
796
770
|
};
|
|
@@ -799,18 +773,20 @@ TableHead.displayName = TABLE_HEAD_NAME;
|
|
|
799
773
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
800
774
|
var TableRoot = ({ children }) => {
|
|
801
775
|
const contextValue = useTableRootContext();
|
|
802
|
-
return /* @__PURE__ */
|
|
776
|
+
return /* @__PURE__ */ React8.createElement(TableRootContext.Provider, {
|
|
803
777
|
value: contextValue
|
|
804
|
-
},
|
|
778
|
+
}, /* @__PURE__ */ React8.createElement(DensityProvider, {
|
|
779
|
+
density: "fine"
|
|
780
|
+
}, children));
|
|
805
781
|
};
|
|
806
782
|
var TableViewport = ({ children, classNames, asChild, ...props }) => {
|
|
807
783
|
const { scrollContextRef } = useContext3(TableRootContext);
|
|
808
|
-
const classes =
|
|
809
|
-
return asChild ? /* @__PURE__ */
|
|
784
|
+
const classes = mx4(classNames, "overflow-auto");
|
|
785
|
+
return asChild ? /* @__PURE__ */ React8.createElement(Slot, {
|
|
810
786
|
ref: scrollContextRef,
|
|
811
787
|
className: classes,
|
|
812
788
|
...props
|
|
813
|
-
}, children) : /* @__PURE__ */
|
|
789
|
+
}, children) : /* @__PURE__ */ React8.createElement("div", {
|
|
814
790
|
role: "none",
|
|
815
791
|
className: classes,
|
|
816
792
|
ref: scrollContextRef,
|
|
@@ -824,7 +800,7 @@ var TablePrimitive = (props) => {
|
|
|
824
800
|
const [data, setData] = useState8([
|
|
825
801
|
...incomingData
|
|
826
802
|
]);
|
|
827
|
-
const forceUpdate =
|
|
803
|
+
const forceUpdate = useCallback7(() => setData([
|
|
828
804
|
...incomingData
|
|
829
805
|
]), [
|
|
830
806
|
incomingData
|
|
@@ -893,37 +869,39 @@ var TablePrimitive = (props) => {
|
|
|
893
869
|
]);
|
|
894
870
|
usePinLastRow(pinLastRow, table, data);
|
|
895
871
|
const expand = false;
|
|
896
|
-
return /* @__PURE__ */
|
|
872
|
+
return /* @__PURE__ */ React8.createElement(TableProvider2, {
|
|
897
873
|
...props,
|
|
898
874
|
...columnSorting,
|
|
899
875
|
table,
|
|
900
876
|
header,
|
|
901
877
|
expand,
|
|
902
878
|
isGrid: role === "grid" || role === "treegrid"
|
|
903
|
-
}, /* @__PURE__ */
|
|
879
|
+
}, /* @__PURE__ */ React8.createElement(TableImpl, {
|
|
904
880
|
debug: false,
|
|
905
881
|
...props
|
|
906
882
|
}));
|
|
907
883
|
};
|
|
908
884
|
var TableImpl = (props) => {
|
|
909
|
-
const { debug, classNames, role,
|
|
885
|
+
const { debug, classNames, role, grouping, fullWidth } = props;
|
|
910
886
|
const { table } = useTableContext();
|
|
911
887
|
if (debug) {
|
|
912
|
-
return /* @__PURE__ */
|
|
888
|
+
return /* @__PURE__ */ React8.createElement("pre", {
|
|
913
889
|
className: "font-mono text-xs text-neutral-500 m-1 p-2 ring"
|
|
914
|
-
}, /* @__PURE__ */
|
|
890
|
+
}, /* @__PURE__ */ React8.createElement("code", null, JSON.stringify(table.getState(), void 0, 2)));
|
|
915
891
|
}
|
|
916
892
|
const isResizingColumn = table.getState().columnSizingInfo.isResizingColumn;
|
|
917
893
|
const TableComponent = isResizingColumn ? MemoizedVirtualizedTableContent : VirtualizedTableContent;
|
|
918
|
-
return /* @__PURE__ */
|
|
894
|
+
return /* @__PURE__ */ React8.createElement("table", {
|
|
919
895
|
role,
|
|
920
896
|
className: tableRoot(props, classNames),
|
|
921
|
-
|
|
922
|
-
|
|
897
|
+
style: {
|
|
898
|
+
// borderCollapse: 'separate',
|
|
899
|
+
borderSpacing: 0,
|
|
900
|
+
...!fullWidth && {
|
|
923
901
|
width: table.getTotalSize()
|
|
924
902
|
}
|
|
925
903
|
}
|
|
926
|
-
}, /* @__PURE__ */
|
|
904
|
+
}, /* @__PURE__ */ React8.createElement(TableHead, null), grouping?.length !== 0 ? /* @__PURE__ */ React8.createElement(TableComponent, null) : /* @__PURE__ */ React8.createElement(GroupedTableContent, null));
|
|
927
905
|
};
|
|
928
906
|
var VirtualizedTableContent = () => {
|
|
929
907
|
const { table } = useTableContext();
|
|
@@ -951,22 +929,22 @@ var VirtualizedTableContent = () => {
|
|
|
951
929
|
...virtualRows.map((virtualRow) => centerRows[virtualRow.index]),
|
|
952
930
|
...pinnedRows
|
|
953
931
|
].filter((r) => !!r);
|
|
954
|
-
return /* @__PURE__ */
|
|
932
|
+
return /* @__PURE__ */ React8.createElement(Fragment, null, paddingTop > 0 && /* @__PURE__ */ React8.createElement("tbody", {
|
|
955
933
|
role: "none"
|
|
956
|
-
}, /* @__PURE__ */
|
|
934
|
+
}, /* @__PURE__ */ React8.createElement("tr", {
|
|
957
935
|
role: "none"
|
|
958
|
-
}, /* @__PURE__ */
|
|
936
|
+
}, /* @__PURE__ */ React8.createElement("td", {
|
|
959
937
|
style: {
|
|
960
938
|
height: `${paddingTop}px`
|
|
961
939
|
},
|
|
962
940
|
role: "none"
|
|
963
|
-
}))), /* @__PURE__ */
|
|
941
|
+
}))), /* @__PURE__ */ React8.createElement(TableBody, {
|
|
964
942
|
rows: rowsToRender
|
|
965
|
-
}), paddingBottom > 0 && /* @__PURE__ */
|
|
943
|
+
}), paddingBottom > 0 && /* @__PURE__ */ React8.createElement("tbody", {
|
|
966
944
|
role: "none"
|
|
967
|
-
}, /* @__PURE__ */
|
|
945
|
+
}, /* @__PURE__ */ React8.createElement("tr", {
|
|
968
946
|
role: "none"
|
|
969
|
-
}, /* @__PURE__ */
|
|
947
|
+
}, /* @__PURE__ */ React8.createElement("td", {
|
|
970
948
|
style: {
|
|
971
949
|
height: `${paddingBottom}px`
|
|
972
950
|
},
|
|
@@ -976,14 +954,14 @@ var VirtualizedTableContent = () => {
|
|
|
976
954
|
var MemoizedVirtualizedTableContent = /* @__PURE__ */ memo(VirtualizedTableContent);
|
|
977
955
|
var GroupedTableContent = () => {
|
|
978
956
|
const { table: { getGroupedRowModel: getGroupedRowModel2, getHeaderGroups, getState }, debug } = useTableContext();
|
|
979
|
-
return /* @__PURE__ */
|
|
980
|
-
return /* @__PURE__ */
|
|
957
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, getGroupedRowModel2().rows.map((row, i) => {
|
|
958
|
+
return /* @__PURE__ */ React8.createElement(Fragment, {
|
|
981
959
|
key: i
|
|
982
|
-
}, /* @__PURE__ */
|
|
960
|
+
}, /* @__PURE__ */ React8.createElement("thead", null, /* @__PURE__ */ React8.createElement("tr", null, debug && /* @__PURE__ */ React8.createElement("th", null), /* @__PURE__ */ React8.createElement("th", {
|
|
983
961
|
// TODO(burdon): Calculate row span.
|
|
984
962
|
colSpan: getHeaderGroups()[0].headers.length,
|
|
985
963
|
className: groupTh({})
|
|
986
|
-
}, getState().grouping[0], "[", String(row.getGroupingValue(getState().grouping[0])), "]"))), /* @__PURE__ */
|
|
964
|
+
}, getState().grouping[0], "[", String(row.getGroupingValue(getState().grouping[0])), "]"))), /* @__PURE__ */ React8.createElement(TableBody, {
|
|
987
965
|
rows: row.subRows
|
|
988
966
|
}));
|
|
989
967
|
}));
|
|
@@ -996,14 +974,14 @@ var Table = {
|
|
|
996
974
|
|
|
997
975
|
// packages/ui/react-ui-table/src/helpers.tsx
|
|
998
976
|
import { useFocusFinders } from "@fluentui/react-tabster";
|
|
999
|
-
import { Check
|
|
977
|
+
import { Check, ClipboardText, X as X2 } from "@phosphor-icons/react";
|
|
1000
978
|
import { createColumnHelper } from "@tanstack/react-table";
|
|
1001
979
|
import { format } from "date-fns/format";
|
|
1002
980
|
import { formatDistanceToNow } from "date-fns/formatDistanceToNow";
|
|
1003
|
-
import
|
|
981
|
+
import React9, { useCallback as useCallback8, useEffect as useEffect4, useRef as useRef4, useState as useState9 } from "react";
|
|
1004
982
|
import { log } from "@dxos/log";
|
|
1005
983
|
import { Input as Input2, Tooltip } from "@dxos/react-ui";
|
|
1006
|
-
import { getSize as
|
|
984
|
+
import { getSize as getSize3, mx as mx5 } from "@dxos/react-ui-theme";
|
|
1007
985
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/helpers.tsx";
|
|
1008
986
|
var createColumnBuilder = () => ({
|
|
1009
987
|
helper: createColumnHelper(),
|
|
@@ -1011,7 +989,7 @@ var createColumnBuilder = () => ({
|
|
|
1011
989
|
});
|
|
1012
990
|
var ComboboxBuilderCell = (cellContext) => {
|
|
1013
991
|
const { model, onUpdate } = cellContext.column.columnDef.meta;
|
|
1014
|
-
return model ? /* @__PURE__ */
|
|
992
|
+
return model ? /* @__PURE__ */ React9.createElement(CellCombobox, {
|
|
1015
993
|
model,
|
|
1016
994
|
value: cellContext.getValue(),
|
|
1017
995
|
onValueChange: (value) => onUpdate?.(cellContext.row.original, cellContext.column.id, value)
|
|
@@ -1022,7 +1000,7 @@ var StringBuilderCell = (cellContext) => {
|
|
|
1022
1000
|
const { findPrevFocusable } = useFocusFinders();
|
|
1023
1001
|
const { onUpdate, cell } = cellContext.column.columnDef.meta;
|
|
1024
1002
|
const initialValue = cellContext.getValue();
|
|
1025
|
-
const getInitialValue =
|
|
1003
|
+
const getInitialValue = useCallback8(() => {
|
|
1026
1004
|
return initialValue?.content ?? initialValue;
|
|
1027
1005
|
}, [
|
|
1028
1006
|
initialValue
|
|
@@ -1044,7 +1022,7 @@ var StringBuilderCell = (cellContext) => {
|
|
|
1044
1022
|
const rowCount = cellContext.table.getRowModel().rows.length;
|
|
1045
1023
|
placeholder = cellContext.row.index === rowCount - 1 && columns[0].id === cellContext.column.id;
|
|
1046
1024
|
}
|
|
1047
|
-
return /* @__PURE__ */
|
|
1025
|
+
return /* @__PURE__ */ React9.createElement(Input2.Root, null, /* @__PURE__ */ React9.createElement(Input2.TextInput, {
|
|
1048
1026
|
ref,
|
|
1049
1027
|
variant: "subdued",
|
|
1050
1028
|
placeholder: placeholder ? "Add row..." : void 0,
|
|
@@ -1056,7 +1034,8 @@ var StringBuilderCell = (cellContext) => {
|
|
|
1056
1034
|
value: value ?? "",
|
|
1057
1035
|
onBlur: handleSave,
|
|
1058
1036
|
onChange: (event) => setValue(event.target.value),
|
|
1059
|
-
onKeyDown: (event) => event.key === "Enter" && handleSave() || event.key === "Escape" && handleCancel()
|
|
1037
|
+
onKeyDown: (event) => event.key === "Enter" && handleSave() || event.key === "Escape" && handleCancel(),
|
|
1038
|
+
autoComplete: "off"
|
|
1060
1039
|
}));
|
|
1061
1040
|
};
|
|
1062
1041
|
var parseNumber = (text) => text?.trim().length ? Number(text) : NaN;
|
|
@@ -1091,7 +1070,7 @@ var NumberBuilderCell = (cellContext) => {
|
|
|
1091
1070
|
setText(displayNumber(value, digits));
|
|
1092
1071
|
ref.current && findPrevFocusable(ref.current)?.focus();
|
|
1093
1072
|
};
|
|
1094
|
-
return /* @__PURE__ */
|
|
1073
|
+
return /* @__PURE__ */ React9.createElement(Input2.Root, null, /* @__PURE__ */ React9.createElement(Input2.TextInput, {
|
|
1095
1074
|
ref,
|
|
1096
1075
|
variant: "subdued",
|
|
1097
1076
|
value: text,
|
|
@@ -1107,17 +1086,18 @@ var NumberBuilderCell = (cellContext) => {
|
|
|
1107
1086
|
/* (event.key === 'Escape' && handleCancel()) || */
|
|
1108
1087
|
event.key === "Enter" && handleSave()
|
|
1109
1088
|
);
|
|
1110
|
-
}
|
|
1089
|
+
},
|
|
1090
|
+
autoComplete: "off"
|
|
1111
1091
|
}));
|
|
1112
1092
|
};
|
|
1113
1093
|
var RowSelectorBuilderCell = (cellContext) => {
|
|
1114
1094
|
const { cell } = cellContext.column.columnDef.meta;
|
|
1115
1095
|
const { row } = cellContext;
|
|
1116
1096
|
const checked = row.getCanSelect() ? row.getIsSelected() : row.getCanSelectSubRows() && (row.getIsSomeSelected() ? "indeterminate" : row.getIsAllSubRowsSelected());
|
|
1117
|
-
return /* @__PURE__ */
|
|
1097
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1118
1098
|
className: "flex justify-center w-full h-full",
|
|
1119
1099
|
role: "presentation"
|
|
1120
|
-
}, /* @__PURE__ */
|
|
1100
|
+
}, /* @__PURE__ */ React9.createElement(Input2.Root, null, /* @__PURE__ */ React9.createElement(Input2.Checkbox, {
|
|
1121
1101
|
size: 4,
|
|
1122
1102
|
classNames: [
|
|
1123
1103
|
cell?.classNames
|
|
@@ -1134,7 +1114,7 @@ var RowSelectorBuilderCell = (cellContext) => {
|
|
|
1134
1114
|
var SwitchBuilderCell = (cellContext) => {
|
|
1135
1115
|
const { onUpdate } = cellContext.column.columnDef.meta;
|
|
1136
1116
|
const value = cellContext.getValue();
|
|
1137
|
-
return /* @__PURE__ */
|
|
1117
|
+
return /* @__PURE__ */ React9.createElement(Input2.Root, null, /* @__PURE__ */ React9.createElement(Input2.Switch, {
|
|
1138
1118
|
classNames: "block mli-auto",
|
|
1139
1119
|
onClick: (event) => event.stopPropagation(),
|
|
1140
1120
|
disabled: !onUpdate,
|
|
@@ -1156,8 +1136,8 @@ var ColumnBuilder = class {
|
|
|
1156
1136
|
},
|
|
1157
1137
|
cell: model && onUpdate ? ComboboxBuilderCell : (cellContext) => {
|
|
1158
1138
|
const cellValue = cellContext.getValue();
|
|
1159
|
-
return /* @__PURE__ */
|
|
1160
|
-
className:
|
|
1139
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1140
|
+
className: mx5("truncate", classNames)
|
|
1161
1141
|
}, cellValue ? model?.getText(cellValue) : "");
|
|
1162
1142
|
},
|
|
1163
1143
|
...props,
|
|
@@ -1187,8 +1167,8 @@ var ColumnBuilder = class {
|
|
|
1187
1167
|
if (typeof value === "object" && value?.__typename === "dxos.Text.v0") {
|
|
1188
1168
|
value = value.content;
|
|
1189
1169
|
}
|
|
1190
|
-
return /* @__PURE__ */
|
|
1191
|
-
className:
|
|
1170
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1171
|
+
className: mx5("truncate", textPadding, classNames)
|
|
1192
1172
|
}, value);
|
|
1193
1173
|
},
|
|
1194
1174
|
...props,
|
|
@@ -1241,15 +1221,15 @@ var ColumnBuilder = class {
|
|
|
1241
1221
|
const str = value ? formatSpec ? format(value, formatSpec) : relative ? formatDistanceToNow(value, {
|
|
1242
1222
|
addSuffix: true
|
|
1243
1223
|
}) : value.toISOString() : void 0;
|
|
1244
|
-
return /* @__PURE__ */
|
|
1245
|
-
className:
|
|
1224
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1225
|
+
className: mx5(textPadding, classNames)
|
|
1246
1226
|
}, str);
|
|
1247
1227
|
} catch (err) {
|
|
1248
1228
|
log.info("formatError", {
|
|
1249
1229
|
value
|
|
1250
1230
|
}, {
|
|
1251
1231
|
F: __dxlog_file,
|
|
1252
|
-
L:
|
|
1232
|
+
L: 378,
|
|
1253
1233
|
S: this,
|
|
1254
1234
|
C: (f, a) => f(...a)
|
|
1255
1235
|
});
|
|
@@ -1283,9 +1263,9 @@ var ColumnBuilder = class {
|
|
|
1283
1263
|
if (!tooltip) {
|
|
1284
1264
|
return element;
|
|
1285
1265
|
}
|
|
1286
|
-
return /* @__PURE__ */
|
|
1266
|
+
return /* @__PURE__ */ React9.createElement(Tooltip.Provider, null, /* @__PURE__ */ React9.createElement(Tooltip.Root, null, /* @__PURE__ */ React9.createElement(Tooltip.Trigger, null, element), /* @__PURE__ */ React9.createElement(Tooltip.Portal, null, /* @__PURE__ */ React9.createElement(Tooltip.Content, {
|
|
1287
1267
|
side: "right"
|
|
1288
|
-
}, /* @__PURE__ */
|
|
1268
|
+
}, /* @__PURE__ */ React9.createElement(Tooltip.Arrow, null), /* @__PURE__ */ React9.createElement(ClipboardText, {
|
|
1289
1269
|
onClick: (ev) => {
|
|
1290
1270
|
ev.stopPropagation();
|
|
1291
1271
|
void navigator.clipboard.writeText(value.toHex());
|
|
@@ -1323,10 +1303,10 @@ var ColumnBuilder = class {
|
|
|
1323
1303
|
header: ({ table }) => {
|
|
1324
1304
|
const { rowsSelectable } = useTableContext();
|
|
1325
1305
|
const checked = table.getIsSomeRowsSelected() ? "indeterminate" : table.getIsAllRowsSelected();
|
|
1326
|
-
return rowsSelectable === "multi" ? /* @__PURE__ */
|
|
1306
|
+
return rowsSelectable === "multi" ? /* @__PURE__ */ React9.createElement("div", {
|
|
1327
1307
|
className: "flex justify-center w-full h-full",
|
|
1328
1308
|
role: "presentation"
|
|
1329
|
-
}, /* @__PURE__ */
|
|
1309
|
+
}, /* @__PURE__ */ React9.createElement(Input2.Root, null, /* @__PURE__ */ React9.createElement(Input2.Checkbox, {
|
|
1330
1310
|
size: 4,
|
|
1331
1311
|
classNames: [
|
|
1332
1312
|
"mli-auto",
|
|
@@ -1368,24 +1348,24 @@ var ColumnBuilder = class {
|
|
|
1368
1348
|
* Icon based on boolean value.
|
|
1369
1349
|
*/
|
|
1370
1350
|
icon({ label, size, on, off, ...props } = {}) {
|
|
1371
|
-
const IconOn = on?.Icon ??
|
|
1372
|
-
const IconOff = off?.Icon ??
|
|
1351
|
+
const IconOn = on?.Icon ?? Check;
|
|
1352
|
+
const IconOff = off?.Icon ?? X2;
|
|
1373
1353
|
return {
|
|
1374
1354
|
size: size ?? 32,
|
|
1375
1355
|
// TODO(zan): Implement sort algorithm
|
|
1376
1356
|
enableSorting: false,
|
|
1377
|
-
header: (column) => /* @__PURE__ */
|
|
1357
|
+
header: (column) => /* @__PURE__ */ React9.createElement("div", {
|
|
1378
1358
|
className: "justify-center"
|
|
1379
1359
|
}, label ?? column.header.id),
|
|
1380
1360
|
cell: (cell) => {
|
|
1381
1361
|
const value = cell.getValue();
|
|
1382
1362
|
if (value) {
|
|
1383
|
-
return /* @__PURE__ */
|
|
1384
|
-
className:
|
|
1363
|
+
return /* @__PURE__ */ React9.createElement(IconOn, {
|
|
1364
|
+
className: mx5("block mli-auto", getSize3(6), on?.className ?? "text-green-700")
|
|
1385
1365
|
});
|
|
1386
1366
|
} else if (value === false) {
|
|
1387
|
-
return /* @__PURE__ */
|
|
1388
|
-
className:
|
|
1367
|
+
return /* @__PURE__ */ React9.createElement(IconOff, {
|
|
1368
|
+
className: mx5("block mli-auto", getSize3(6), off?.className ?? "text-red-700")
|
|
1389
1369
|
});
|
|
1390
1370
|
} else {
|
|
1391
1371
|
return null;
|
|
@@ -1404,9 +1384,9 @@ var ColumnBuilder = class {
|
|
|
1404
1384
|
header: (cell) => label ?? cell.header.id,
|
|
1405
1385
|
cell: (cell) => {
|
|
1406
1386
|
const value = cell.getValue();
|
|
1407
|
-
return /* @__PURE__ */
|
|
1387
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
1408
1388
|
className: "overflow-scroll"
|
|
1409
|
-
}, /* @__PURE__ */
|
|
1389
|
+
}, /* @__PURE__ */ React9.createElement("code", {
|
|
1410
1390
|
className: "text-xs"
|
|
1411
1391
|
}, JSON.stringify(value)));
|
|
1412
1392
|
},
|
|
@@ -1566,12 +1546,8 @@ export {
|
|
|
1566
1546
|
tableRoot,
|
|
1567
1547
|
tbodyRoot,
|
|
1568
1548
|
tbodyTr,
|
|
1569
|
-
tdContent,
|
|
1570
1549
|
tdRoot,
|
|
1571
1550
|
textPadding,
|
|
1572
|
-
tfootRoot,
|
|
1573
|
-
tfootTh,
|
|
1574
|
-
tfootTr,
|
|
1575
1551
|
theadResizeRoot,
|
|
1576
1552
|
theadRoot,
|
|
1577
1553
|
theadTh,
|