@dxos/react-ui-table 0.8.2-main.36232bc → 0.8.2-main.5885341
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 +29 -97
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +49 -115
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +29 -97
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/types/table.d.ts +2 -2
- package/dist/types/src/types/table.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +0 -14
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/components/Table/Table.tsx +0 -6
- package/src/model/table-presentation.ts +3 -5
- package/src/util/table-buttons.ts +0 -23
- package/dist/types/src/components/Table/RefPanel.d.ts +0 -9
- package/dist/types/src/components/Table/RefPanel.d.ts.map +0 -1
- package/src/components/Table/RefPanel.tsx +0 -52
|
@@ -36,7 +36,7 @@ var translations_default = [
|
|
|
36
36
|
];
|
|
37
37
|
|
|
38
38
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
39
|
-
import
|
|
39
|
+
import React6, { forwardRef, useCallback as useCallback4, useImperativeHandle, useState as useState2, useMemo as useMemo4, useEffect as useEffect2 } from "react";
|
|
40
40
|
import { getValue as getValue4 } from "@dxos/echo-schema";
|
|
41
41
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
42
42
|
import { Filter } from "@dxos/react-client/echo";
|
|
@@ -223,46 +223,8 @@ var CreateRefPanel = ({ model, modals, __gridScope }) => {
|
|
|
223
223
|
}), /* @__PURE__ */ React3.createElement(Popover.Arrow, null))));
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
-
// packages/ui/react-ui-table/src/components/Table/RefPanel.tsx
|
|
227
|
-
import React4 from "react";
|
|
228
|
-
import { Popover as Popover2 } from "@dxos/react-ui";
|
|
229
|
-
import { Form as Form2 } from "@dxos/react-ui-form";
|
|
230
|
-
var getRefTargetObj = (space, id) => {
|
|
231
|
-
if (space && id) {
|
|
232
|
-
return space?.db.getObjectById(id);
|
|
233
|
-
} else {
|
|
234
|
-
return void 0;
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
var RefPanel = ({ model, modals }) => {
|
|
238
|
-
const state = modals.state.value;
|
|
239
|
-
const space = model?.space;
|
|
240
|
-
const targetObj = getRefTargetObj(space, state?.type === "refPanel" ? state.targetId : void 0);
|
|
241
|
-
const schema = space && state?.type === "refPanel" ? space.db.schemaRegistry.getSchema(state.typename) : void 0;
|
|
242
|
-
if (!model.view || !model.projection) {
|
|
243
|
-
return null;
|
|
244
|
-
}
|
|
245
|
-
return /* @__PURE__ */ React4.createElement(Popover2.Root, {
|
|
246
|
-
modal: false,
|
|
247
|
-
open: state?.type === "refPanel" && !!targetObj && !!schema,
|
|
248
|
-
onOpenChange: (nextOpen) => {
|
|
249
|
-
if (!nextOpen) {
|
|
250
|
-
return modals.close();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}, /* @__PURE__ */ React4.createElement(Popover2.VirtualTrigger, {
|
|
254
|
-
virtualRef: modals.trigger
|
|
255
|
-
}), /* @__PURE__ */ React4.createElement(Popover2.Portal, null, /* @__PURE__ */ React4.createElement(Popover2.Content, {
|
|
256
|
-
classNames: "md:is-64"
|
|
257
|
-
}, targetObj && schema && /* @__PURE__ */ React4.createElement(Form2, {
|
|
258
|
-
readonly: true,
|
|
259
|
-
values: targetObj,
|
|
260
|
-
schema
|
|
261
|
-
}), /* @__PURE__ */ React4.createElement(Popover2.Arrow, null))));
|
|
262
|
-
};
|
|
263
|
-
|
|
264
226
|
// packages/ui/react-ui-table/src/components/Table/RowActionsMenu.tsx
|
|
265
|
-
import
|
|
227
|
+
import React4 from "react";
|
|
266
228
|
import { DropdownMenu as DropdownMenu3, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
267
229
|
var RowActionsMenu = ({ model, modals }) => {
|
|
268
230
|
const { t } = useTranslation2(translationKey);
|
|
@@ -271,23 +233,23 @@ var RowActionsMenu = ({ model, modals }) => {
|
|
|
271
233
|
if (state?.type !== "row") {
|
|
272
234
|
return null;
|
|
273
235
|
}
|
|
274
|
-
return /* @__PURE__ */
|
|
236
|
+
return /* @__PURE__ */ React4.createElement(DropdownMenu3.Root, {
|
|
275
237
|
modal: false,
|
|
276
238
|
open: true,
|
|
277
239
|
onOpenChange: modals.close
|
|
278
|
-
}, /* @__PURE__ */
|
|
240
|
+
}, /* @__PURE__ */ React4.createElement(DropdownMenu3.VirtualTrigger, {
|
|
279
241
|
virtualRef: modals.trigger
|
|
280
|
-
}), /* @__PURE__ */
|
|
242
|
+
}), /* @__PURE__ */ React4.createElement(DropdownMenu3.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu3.Viewport, null, model.features.dataEditable !== false && /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
|
|
281
243
|
"data-testid": "row-menu-delete",
|
|
282
244
|
onClick: () => model.deleteRow(state.rowIndex)
|
|
283
|
-
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */
|
|
245
|
+
}, t(hasSelection ? "bulk delete row label" : "delete row label")), model.rowActions?.map((action) => /* @__PURE__ */ React4.createElement(DropdownMenu3.Item, {
|
|
284
246
|
key: action.id,
|
|
285
247
|
"data-testid": `row-action-${action.id}`,
|
|
286
248
|
onClick: () => {
|
|
287
249
|
modals.close();
|
|
288
250
|
model.handleRowAction(action.id, state.rowIndex);
|
|
289
251
|
}
|
|
290
|
-
}, t(action.translationKey)))), /* @__PURE__ */
|
|
252
|
+
}, t(action.translationKey)))), /* @__PURE__ */ React4.createElement(DropdownMenu3.Arrow, null)));
|
|
291
253
|
};
|
|
292
254
|
|
|
293
255
|
// packages/ui/react-ui-table/src/model/table-model.ts
|
|
@@ -518,26 +480,6 @@ var columnSettingsButton = {
|
|
|
518
480
|
fieldId: el.getAttribute("data-field-id")
|
|
519
481
|
})
|
|
520
482
|
};
|
|
521
|
-
var referencedCellButton = {
|
|
522
|
-
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
523
|
-
icon: "ph--link-simple-horizontal--regular",
|
|
524
|
-
render: ({ targetId, schemaId }) => {
|
|
525
|
-
return createButton({
|
|
526
|
-
attr: BUTTON_IDENTIFIERS.referencedCell,
|
|
527
|
-
icon: referencedCellButton.icon,
|
|
528
|
-
data: {
|
|
529
|
-
"data-target-id": targetId,
|
|
530
|
-
"data-schema-id": schemaId
|
|
531
|
-
},
|
|
532
|
-
testId: "table-ref-cell-button"
|
|
533
|
-
});
|
|
534
|
-
},
|
|
535
|
-
getData: (el) => ({
|
|
536
|
-
type: "referencedCell",
|
|
537
|
-
targetId: el.getAttribute("data-target-id"),
|
|
538
|
-
schemaId: el.getAttribute("data-schema-id")
|
|
539
|
-
})
|
|
540
|
-
};
|
|
541
483
|
var rowMenuButton = {
|
|
542
484
|
attr: BUTTON_IDENTIFIERS.rowMenu,
|
|
543
485
|
icon: "ph--dots-three--regular",
|
|
@@ -582,7 +524,6 @@ var sortButton = {
|
|
|
582
524
|
var tableButtons = {
|
|
583
525
|
addColumn: addColumnButton,
|
|
584
526
|
columnSettings: columnSettingsButton,
|
|
585
|
-
referencedCell: referencedCellButton,
|
|
586
527
|
rowMenu: rowMenuButton,
|
|
587
528
|
sort: sortButton
|
|
588
529
|
};
|
|
@@ -1333,7 +1274,7 @@ var ModalController = class {
|
|
|
1333
1274
|
|
|
1334
1275
|
// packages/ui/react-ui-table/src/model/table-presentation.ts
|
|
1335
1276
|
import { signal as signal5 } from "@preact/signals-core";
|
|
1336
|
-
import { FormatEnum as FormatEnum4, getValue as getValue3 } from "@dxos/echo-schema";
|
|
1277
|
+
import { FormatEnum as FormatEnum4, getDXN, getValue as getValue3 } from "@dxos/echo-schema";
|
|
1337
1278
|
import { cellClassesForFieldType, formatForDisplay as formatForDisplay2 } from "@dxos/react-ui-form";
|
|
1338
1279
|
import { toPlaneCellIndex } from "@dxos/react-ui-grid";
|
|
1339
1280
|
import { mx } from "@dxos/react-ui-theme";
|
|
@@ -1435,10 +1376,8 @@ var TablePresentation = class {
|
|
|
1435
1376
|
if (props.format === FormatEnum4.Ref && props.referenceSchema) {
|
|
1436
1377
|
const targetObj = getValue3(obj, field.path)?.target;
|
|
1437
1378
|
if (targetObj) {
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
schemaId: props.referenceSchema
|
|
1441
|
-
});
|
|
1379
|
+
const dxn = getDXN(targetObj)?.toString();
|
|
1380
|
+
cell.accessoryHtml = `<dx-ref-tag ref=${dxn} class="dx-button block is-6 pli-[3px] plb-[3px] pbe-[2px] min-bs-0 absolute inline-end-1"><dx-icon icon="ph--link-simple--regular"/></dx-ref-tag>`;
|
|
1442
1381
|
}
|
|
1443
1382
|
}
|
|
1444
1383
|
if (props.format === FormatEnum4.Boolean) {
|
|
@@ -1630,7 +1569,7 @@ var cellClassesForRowSelection = (selected, selectionMode) => {
|
|
|
1630
1569
|
};
|
|
1631
1570
|
|
|
1632
1571
|
// packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx
|
|
1633
|
-
import
|
|
1572
|
+
import React5, { useCallback as useCallback3, useMemo as useMemo3, useRef } from "react";
|
|
1634
1573
|
import { FormatEnum as FormatEnum5 } from "@dxos/echo-schema";
|
|
1635
1574
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1636
1575
|
import { useThemeContext } from "@dxos/react-ui";
|
|
@@ -1885,7 +1824,7 @@ var TableCellEditor = ({ model, modals, onEnter, onFocus, onQuery, __gridScope }
|
|
|
1885
1824
|
model,
|
|
1886
1825
|
editing
|
|
1887
1826
|
]);
|
|
1888
|
-
return /* @__PURE__ */
|
|
1827
|
+
return /* @__PURE__ */ React5.createElement(GridCellEditor, {
|
|
1889
1828
|
extension,
|
|
1890
1829
|
getCellContent,
|
|
1891
1830
|
onBlur: handleBlur
|
|
@@ -1919,7 +1858,7 @@ var determineNavigationDelta = ({ key, shift }) => {
|
|
|
1919
1858
|
// packages/ui/react-ui-table/src/components/Table/Table.tsx
|
|
1920
1859
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
|
|
1921
1860
|
var TableRoot = ({ children, role }) => {
|
|
1922
|
-
return /* @__PURE__ */
|
|
1861
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1923
1862
|
role: "none",
|
|
1924
1863
|
className: mx2("relative !border-separator", role === "section" ? "attention-surface overflow-hidden [&_.dx-grid]:max-is-[--dx-grid-content-inline-size]" : "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:bs-0 [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]")
|
|
1925
1864
|
}, children);
|
|
@@ -2006,10 +1945,6 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2006
1945
|
modals.showColumnCreator();
|
|
2007
1946
|
break;
|
|
2008
1947
|
}
|
|
2009
|
-
case "referencedCell": {
|
|
2010
|
-
modals.showReferencePanel(data.targetId, data.schemaId);
|
|
2011
|
-
break;
|
|
2012
|
-
}
|
|
2013
1948
|
case "sort": {
|
|
2014
1949
|
model?.sorting?.toggleSort(data.fieldId);
|
|
2015
1950
|
break;
|
|
@@ -2121,7 +2056,7 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2121
2056
|
const space = model.space;
|
|
2122
2057
|
invariant3(space, void 0, {
|
|
2123
2058
|
F: __dxlog_file4,
|
|
2124
|
-
L:
|
|
2059
|
+
L: 307,
|
|
2125
2060
|
S: void 0,
|
|
2126
2061
|
A: [
|
|
2127
2062
|
"space",
|
|
@@ -2158,20 +2093,20 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2158
2093
|
t
|
|
2159
2094
|
]);
|
|
2160
2095
|
if (!model || !modals) {
|
|
2161
|
-
return /* @__PURE__ */
|
|
2096
|
+
return /* @__PURE__ */ React6.createElement("span", {
|
|
2162
2097
|
role: "none",
|
|
2163
2098
|
className: "attention-surface"
|
|
2164
2099
|
});
|
|
2165
2100
|
}
|
|
2166
|
-
return /* @__PURE__ */
|
|
2101
|
+
return /* @__PURE__ */ React6.createElement(Grid.Root, {
|
|
2167
2102
|
id: model.id ?? "table-grid"
|
|
2168
|
-
}, /* @__PURE__ */
|
|
2103
|
+
}, /* @__PURE__ */ React6.createElement(TableCellEditor, {
|
|
2169
2104
|
model,
|
|
2170
2105
|
modals,
|
|
2171
2106
|
onEnter: handleEnter,
|
|
2172
2107
|
onFocus: handleFocus,
|
|
2173
2108
|
onQuery: handleQuery
|
|
2174
|
-
}), /* @__PURE__ */
|
|
2109
|
+
}), /* @__PURE__ */ React6.createElement(Grid.Content, {
|
|
2175
2110
|
className: mx2("[--dx-grid-base:var(--surface-bg)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
|
|
2176
2111
|
frozen,
|
|
2177
2112
|
// getCells={getCells}
|
|
@@ -2184,20 +2119,17 @@ var TableMain = /* @__PURE__ */ forwardRef(({ model, presentation, ignoreAttenti
|
|
|
2184
2119
|
onKeyDown: handleKeyDown,
|
|
2185
2120
|
onWheelCapture: handleWheel,
|
|
2186
2121
|
ref: setDxGrid
|
|
2187
|
-
}), /* @__PURE__ */
|
|
2122
|
+
}), /* @__PURE__ */ React6.createElement(RowActionsMenu, {
|
|
2188
2123
|
model,
|
|
2189
2124
|
modals
|
|
2190
|
-
}), /* @__PURE__ */
|
|
2125
|
+
}), /* @__PURE__ */ React6.createElement(ColumnActionsMenu, {
|
|
2191
2126
|
model,
|
|
2192
2127
|
modals
|
|
2193
|
-
}), /* @__PURE__ */
|
|
2128
|
+
}), /* @__PURE__ */ React6.createElement(ColumnSettings, {
|
|
2194
2129
|
model,
|
|
2195
2130
|
modals,
|
|
2196
2131
|
onNewColumn: handleNewColumn
|
|
2197
|
-
}), /* @__PURE__ */
|
|
2198
|
-
model,
|
|
2199
|
-
modals
|
|
2200
|
-
}), /* @__PURE__ */ React7.createElement(RefPanel, {
|
|
2132
|
+
}), /* @__PURE__ */ React6.createElement(CreateRefPanel, {
|
|
2201
2133
|
model,
|
|
2202
2134
|
modals
|
|
2203
2135
|
}));
|
|
@@ -2208,7 +2140,7 @@ var Table = {
|
|
|
2208
2140
|
};
|
|
2209
2141
|
|
|
2210
2142
|
// packages/ui/react-ui-table/src/components/Table/DynamicTable.tsx
|
|
2211
|
-
import
|
|
2143
|
+
import React7, { useRef as useRef2, useMemo as useMemo5, useCallback as useCallback5 } from "react";
|
|
2212
2144
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
2213
2145
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
2214
2146
|
|
|
@@ -2333,13 +2265,13 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2333
2265
|
}, [
|
|
2334
2266
|
model
|
|
2335
2267
|
]);
|
|
2336
|
-
return /* @__PURE__ */
|
|
2268
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
2337
2269
|
role: "none",
|
|
2338
2270
|
className: mx3("is-full bs-full grow grid", classNames)
|
|
2339
|
-
}, /* @__PURE__ */
|
|
2271
|
+
}, /* @__PURE__ */ React7.createElement("div", {
|
|
2340
2272
|
role: "none",
|
|
2341
2273
|
className: "grid min-bs-0 overflow-hidden"
|
|
2342
|
-
}, /* @__PURE__ */
|
|
2274
|
+
}, /* @__PURE__ */ React7.createElement(Table.Root, null, /* @__PURE__ */ React7.createElement(Table.Main, {
|
|
2343
2275
|
ref: tableRef,
|
|
2344
2276
|
model,
|
|
2345
2277
|
presentation,
|
|
@@ -2349,7 +2281,7 @@ var DynamicTable = ({ classNames, name = "example.com/dynamic-table", rows, prop
|
|
|
2349
2281
|
};
|
|
2350
2282
|
|
|
2351
2283
|
// packages/ui/react-ui-table/src/components/TableToolbar/TableToolbar.tsx
|
|
2352
|
-
import
|
|
2284
|
+
import React8, { useCallback as useCallback6, useMemo as useMemo6 } from "react";
|
|
2353
2285
|
import { live as live4 } from "@dxos/live-object";
|
|
2354
2286
|
import { createGapSeparator, createMenuAction, MenuProvider, ToolbarMenu, useMenuActions } from "@dxos/react-ui-menu";
|
|
2355
2287
|
var createTableToolbarActions = (state) => {
|
|
@@ -2411,11 +2343,11 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAction }) => {
|
|
|
2411
2343
|
state
|
|
2412
2344
|
]);
|
|
2413
2345
|
const menu = useMenuActions(actionsCreator);
|
|
2414
|
-
return /* @__PURE__ */
|
|
2346
|
+
return /* @__PURE__ */ React8.createElement(MenuProvider, {
|
|
2415
2347
|
...menu,
|
|
2416
2348
|
attendableId,
|
|
2417
2349
|
onAction
|
|
2418
|
-
}, /* @__PURE__ */
|
|
2350
|
+
}, /* @__PURE__ */ React8.createElement(ToolbarMenu, {
|
|
2419
2351
|
classNames
|
|
2420
2352
|
}));
|
|
2421
2353
|
};
|