@dxos/react-ui-table 0.8.4-main.d05673bc65 → 0.8.4-main.dfabb4ec29

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.
Files changed (115) hide show
  1. package/dist/lib/browser/{chunk-BF54SSNL.mjs → chunk-FBURZBPH.mjs} +7 -7
  2. package/dist/lib/browser/chunk-FBURZBPH.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  4. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-PTHMYAAM.mjs → chunk-YGC7LZJN.mjs} +14 -70
  6. package/dist/lib/browser/chunk-YGC7LZJN.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +205 -247
  8. package/dist/lib/browser/index.mjs.map +4 -4
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/testing/index.mjs +6 -5
  11. package/dist/lib/browser/testing/index.mjs.map +3 -3
  12. package/dist/lib/browser/translations.mjs +36 -0
  13. package/dist/lib/browser/translations.mjs.map +7 -0
  14. package/dist/lib/browser/types/index.mjs +2 -1
  15. package/dist/lib/node-esm/{chunk-SIRDIPHZ.mjs → chunk-DKKMSVKP.mjs} +7 -7
  16. package/dist/lib/node-esm/chunk-DKKMSVKP.mjs.map +7 -0
  17. package/dist/lib/node-esm/{chunk-GI72MQSG.mjs → chunk-GKIWDEZ7.mjs} +14 -70
  18. package/dist/lib/node-esm/chunk-GKIWDEZ7.mjs.map +7 -0
  19. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  20. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  21. package/dist/lib/node-esm/index.mjs +205 -247
  22. package/dist/lib/node-esm/index.mjs.map +4 -4
  23. package/dist/lib/node-esm/meta.json +1 -1
  24. package/dist/lib/node-esm/testing/index.mjs +6 -5
  25. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  26. package/dist/lib/node-esm/translations.mjs +37 -0
  27. package/dist/lib/node-esm/translations.mjs.map +7 -0
  28. package/dist/lib/node-esm/types/index.mjs +2 -1
  29. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  30. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  31. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  32. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +19 -21
  33. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  34. package/dist/types/src/components/Table/Relations.stories.d.ts +82 -82
  35. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  36. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  37. package/dist/types/src/components/Table/Table.d.ts +20 -21
  38. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  39. package/dist/types/src/components/Table/Table.stories.d.ts +84 -84
  40. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  41. package/dist/types/src/components/Table/TableContent.d.ts +17 -0
  42. package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
  43. package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
  44. package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
  45. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
  46. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  47. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  48. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +22 -24
  49. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  50. package/dist/types/src/components/index.d.ts +0 -1
  51. package/dist/types/src/components/index.d.ts.map +1 -1
  52. package/dist/types/src/components/testing.d.ts.map +1 -1
  53. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  54. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
  55. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  56. package/dist/types/src/index.d.ts +0 -2
  57. package/dist/types/src/index.d.ts.map +1 -1
  58. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  59. package/dist/types/src/model/selection-model.d.ts +1 -1
  60. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  61. package/dist/types/src/model/table-model.d.ts +3 -3
  62. package/dist/types/src/model/table-model.d.ts.map +1 -1
  63. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  64. package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
  65. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
  66. package/dist/types/src/translations.d.ts +19 -21
  67. package/dist/types/src/translations.d.ts.map +1 -1
  68. package/dist/types/src/types/Table.d.ts.map +1 -1
  69. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  70. package/dist/types/src/util/query-ast.d.ts.map +1 -1
  71. package/dist/types/src/util/schema.d.ts.map +1 -1
  72. package/dist/types/src/util/signals.d.ts.map +1 -1
  73. package/dist/types/src/util/sort.d.ts.map +1 -1
  74. package/dist/types/src/util/table-buttons.d.ts +20 -20
  75. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  76. package/dist/types/src/util/table-controls.d.ts +4 -4
  77. package/dist/types/src/util/table-controls.d.ts.map +1 -1
  78. package/dist/types/src/util/tag.d.ts.map +1 -1
  79. package/dist/types/tsconfig.tsbuildinfo +1 -1
  80. package/package.json +50 -59
  81. package/src/components/Table/ColumnActionsMenu.tsx +7 -6
  82. package/src/components/Table/DynamicTable.stories.tsx +13 -13
  83. package/src/components/Table/DynamicTable.tsx +5 -13
  84. package/src/components/Table/Relations.stories.tsx +71 -30
  85. package/src/components/Table/RowActionsMenu.tsx +3 -2
  86. package/src/components/Table/Table.stories.tsx +25 -27
  87. package/src/components/Table/Table.tsx +37 -426
  88. package/src/components/Table/TableContent.tsx +421 -0
  89. package/src/components/{TableToolbar → Table}/TableToolbar.tsx +34 -41
  90. package/src/components/TableCellEditor/CellValidationMessage.tsx +0 -1
  91. package/src/components/TableCellEditor/FormCellEditor.tsx +3 -2
  92. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +9 -9
  93. package/src/components/TableCellEditor/TableCellEditor.tsx +10 -8
  94. package/src/components/index.ts +0 -1
  95. package/src/components/testing.ts +9 -9
  96. package/src/index.ts +0 -4
  97. package/src/model/table-model.test.ts +0 -1
  98. package/src/model/table-model.ts +9 -9
  99. package/src/model/table-presentation.test.ts +0 -1
  100. package/src/model/table-presentation.ts +0 -1
  101. package/src/playwright/smoke.spec.ts +3 -3
  102. package/src/testing/useTestTableModel.ts +3 -3
  103. package/src/translations.ts +19 -21
  104. package/src/types/Table.ts +1 -1
  105. package/src/util/dynamic-table.test.ts +3 -3
  106. package/src/util/dynamic-table.ts +4 -4
  107. package/dist/lib/browser/chunk-BF54SSNL.mjs.map +0 -7
  108. package/dist/lib/browser/chunk-PTHMYAAM.mjs.map +0 -7
  109. package/dist/lib/node-esm/chunk-GI72MQSG.mjs.map +0 -7
  110. package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +0 -7
  111. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
  112. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
  113. package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
  114. package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
  115. package/src/components/TableToolbar/index.ts +0 -5
@@ -17,52 +17,26 @@ import {
17
17
  useAddRow,
18
18
  useProjectionModel,
19
19
  useTableModel
20
- } from "./chunk-GI72MQSG.mjs";
20
+ } from "./chunk-GKIWDEZ7.mjs";
21
21
  import {
22
22
  Table_exports
23
- } from "./chunk-SIRDIPHZ.mjs";
24
-
25
- // src/translations.ts
26
- var translationKey = "@dxos/react-ui-table";
27
- var translations = [
28
- {
29
- "en-US": {
30
- [translationKey]: {
31
- "object placeholder": "New table",
32
- "create object label": "Create table",
33
- "table name placeholder": "Table name",
34
- "settings title": "Table settings",
35
- "table schema label": "Type",
36
- "new schema": "New type",
37
- "continue label": "Continue",
38
- "create stack section label": "Create table",
39
- "add row label": "Add row",
40
- "create comment": "Create thread",
41
- "column action sort descending": "Sort Descending",
42
- "column action sort ascending": "Sort Ascending",
43
- "column action clear sorting": "Clear Sorting",
44
- "column action settings": "Column Settings",
45
- "column action delete": "Delete Column",
46
- "delete row label": "Delete row",
47
- "bulk delete row label": "Delete selected rows",
48
- "column deleted label": "Column deleted",
49
- "new column button label": "Create column",
50
- "create new object label": "Create new object \u201C{{text}}\u201D",
51
- "save view label": "Save changes to view"
52
- }
53
- }
54
- }
55
- ];
23
+ } from "./chunk-DKKMSVKP.mjs";
24
+ import "./chunk-HSLMI22Q.mjs";
56
25
 
57
26
  // src/components/Table/Table.tsx
58
- import { Atom as Atom3, RegistryContext as RegistryContext2, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
27
+ import { Atom as Atom4 } from "@effect-atom/atom-react";
28
+ import { createContext } from "@radix-ui/react-context";
29
+ import React9, { forwardRef, useImperativeHandle, useRef as useRef3 } from "react";
30
+
31
+ // src/components/Table/TableContent.tsx
32
+ import { Atom as Atom2, RegistryContext, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
59
33
  import * as String2 from "effect/String";
60
- import React8, { forwardRef, useCallback as useCallback4, useContext as useContext2, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo5, useState as useState4 } from "react";
34
+ import React7, { useCallback as useCallback4, useContext, useEffect as useEffect3, useMemo as useMemo4, useState as useState4 } from "react";
61
35
  import { log } from "@dxos/log";
62
36
  import { useAttention } from "@dxos/react-ui-attention";
63
37
  import { Grid, closestCell, gridSeparatorBlockEnd, gridSeparatorInlineEnd } from "@dxos/react-ui-grid";
64
38
  import { DxEditRequest } from "@dxos/react-ui-grid";
65
- import { composableProps, mx } from "@dxos/ui-theme";
39
+ import { composable, composableProps, mx } from "@dxos/ui-theme";
66
40
 
67
41
  // src/util/dynamic-table.ts
68
42
  import { Filter, JsonSchema, Obj, Order, Query, Ref, Type } from "@dxos/echo";
@@ -120,8 +94,8 @@ var setProperties = (view, projection, table, properties) => {
120
94
  const field = projection.getFields().find((field2) => field2.path === property.name);
121
95
  if (field) {
122
96
  if (property.size !== void 0) {
123
- Obj.change(table, (t) => {
124
- t.sizes[field.path] = property.size;
97
+ Obj.update(table, (table2) => {
98
+ table2.sizes[field.path] = property.size;
125
99
  });
126
100
  }
127
101
  if (property.title !== void 0) {
@@ -137,8 +111,8 @@ var setProperties = (view, projection, table, properties) => {
137
111
  if (property.sort) {
138
112
  const currentQuery = Query.fromAst(Obj.getSnapshot(view).query.ast);
139
113
  const newQuery = currentQuery.orderBy(Order.property(field.path, property.sort));
140
- Obj.change(view, (v) => {
141
- v.query.ast = newQuery.ast;
114
+ Obj.update(view, (view2) => {
115
+ view2.query.ast = newQuery.ast;
142
116
  });
143
117
  }
144
118
  }
@@ -257,7 +231,6 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
257
231
  const bgClass = variant === "error" ? "bg-error-surface" : "bg-warning-surface";
258
232
  const textClass = variant === "error" ? "text-error-surface-text" : "text-warning-surface-text";
259
233
  return /* @__PURE__ */ React.createElement("div", {
260
- role: "none",
261
234
  className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
262
235
  style: {
263
236
  ...{
@@ -280,9 +253,10 @@ import { Popover } from "@dxos/react-ui";
280
253
  import { Form } from "@dxos/react-ui-form";
281
254
  import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
282
255
  import { getDeep, isTruthy, setDeep } from "@dxos/util";
256
+ import { translationKey } from "#translations";
283
257
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
284
258
  var createOptionLabel = [
285
- "create new object label",
259
+ "create-new-object.label",
286
260
  {
287
261
  ns: translationKey
288
262
  }
@@ -318,27 +292,11 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
318
292
  const cell = parseCellIndex(contextEditing.index);
319
293
  if (model.isDraftCell(cell)) {
320
294
  const draftRow = model.getDraftRows()[cell.row];
321
- invariant(draftRow, void 0, {
322
- F: __dxlog_file,
323
- L: 74,
324
- S: void 0,
325
- A: [
326
- "draftRow",
327
- ""
328
- ]
329
- });
295
+ invariant(draftRow, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 52, S: void 0, A: ["draftRow", ""] });
330
296
  return draftRow.data;
331
297
  } else {
332
298
  const row = model.getRowAt(cell.row);
333
- invariant(row, void 0, {
334
- F: __dxlog_file,
335
- L: 78,
336
- S: void 0,
337
- A: [
338
- "row",
339
- ""
340
- ]
341
- });
299
+ invariant(row, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0, A: ["row", ""] });
342
300
  return row;
343
301
  }
344
302
  }
@@ -458,11 +416,6 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
458
416
 
459
417
  // src/components/TableCellEditor/TableCellEditor.tsx
460
418
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
461
- var editorSlots = {
462
- scroll: {
463
- className: "!py-(--dx-grid-cell-editor-padding-block)"
464
- }
465
- };
466
419
  var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
467
420
  const { editing } = useGridContext3("TableValueEditor", __gridScope);
468
421
  const fieldProjection = useMemo2(() => {
@@ -472,15 +425,7 @@ var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, o
472
425
  const { col } = parseCellIndex2(editing.index);
473
426
  const field = model.projection.getFields()[col];
474
427
  const fieldProjection2 = model.projection.getFieldProjection(field.id);
475
- invariant2(fieldProjection2, void 0, {
476
- F: __dxlog_file2,
477
- L: 73,
478
- S: void 0,
479
- A: [
480
- "fieldProjection",
481
- ""
482
- ]
483
- });
428
+ invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 21, S: void 0, A: ["fieldProjection", ""] });
484
429
  return fieldProjection2;
485
430
  }, [
486
431
  model,
@@ -517,15 +462,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
517
462
  const { col } = parseCellIndex2(editing.index);
518
463
  const field = model.projection.getFields()[col];
519
464
  const fieldProjection2 = model.projection.getFieldProjection(field.id);
520
- invariant2(fieldProjection2, void 0, {
521
- F: __dxlog_file2,
522
- L: 120,
523
- S: void 0,
524
- A: [
525
- "fieldProjection",
526
- ""
527
- ]
528
- });
465
+ invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 59, S: void 0, A: ["fieldProjection", ""] });
529
466
  return fieldProjection2;
530
467
  }, [
531
468
  model,
@@ -659,9 +596,13 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
659
596
  __gridScope
660
597
  }), /* @__PURE__ */ React3.createElement(GridCellEditor, {
661
598
  extensions,
599
+ slots: {
600
+ content: {
601
+ className: "!py-(--dx-grid-cell-editor-padding-block)"
602
+ }
603
+ },
662
604
  getCellContent,
663
- onBlur: handleBlur,
664
- slots: editorSlots
605
+ onBlur: handleBlur
665
606
  }));
666
607
  };
667
608
  var determineNavigationAxis = ({ key }) => {
@@ -689,140 +630,52 @@ var determineNavigationDelta = ({ key, shift }) => {
689
630
  return shift ? -1 : 1;
690
631
  };
691
632
 
692
- // src/components/TableToolbar/TableToolbar.tsx
693
- import { Atom as Atom2, RegistryContext } from "@effect-atom/atom-react";
694
- import React4, { useContext, useEffect as useEffect2, useMemo as useMemo3 } from "react";
695
- import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
696
- var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom2.make((get) => {
697
- const nodes = [];
698
- if (onAdd) {
699
- const add = createMenuAction("add-row", onAdd, {
700
- type: "add-row",
701
- icon: "ph--plus--regular",
702
- label: [
703
- "add row label",
704
- {
705
- ns: translationKey
706
- }
707
- ],
708
- testId: "table.toolbar.add-row"
709
- });
710
- nodes.push(add);
711
- }
712
- if (onSave) {
713
- const state = get(stateAtom);
714
- const save = createMenuAction("save-view", onSave, {
715
- type: "save-view",
716
- icon: "ph--floppy-disk--regular",
717
- label: [
718
- "save view label",
719
- {
720
- ns: translationKey
721
- }
722
- ],
723
- testId: "table.toolbar.save-view",
724
- iconOnly: false,
725
- hidden: !state.viewDirty
726
- });
727
- nodes.push(save);
728
- }
729
- const gap = createGapSeparator();
730
- nodes.push(...gap.nodes);
731
- const edges = nodes.map(({ id: target }) => ({
732
- source: "root",
733
- target,
734
- relation: "child"
735
- }));
736
- if (customActions) {
737
- const custom = get(customActions);
738
- nodes.push(...custom.nodes);
739
- edges.push(...custom.edges);
740
- }
741
- return {
742
- nodes,
743
- edges
744
- };
745
- });
746
- var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions, ...props }) => {
747
- const registry = useContext(RegistryContext);
748
- const stateAtom = useMemo3(() => Atom2.make({
749
- viewDirty
750
- }), []);
751
- useEffect2(() => {
752
- registry.set(stateAtom, {
753
- viewDirty
754
- });
755
- }, [
756
- registry,
757
- stateAtom,
758
- viewDirty
759
- ]);
760
- const actionsCreator = useMemo3(() => createTableToolbarActions({
761
- stateAtom,
762
- onAdd,
763
- onSave,
764
- customActions
765
- }), [
766
- stateAtom,
767
- onAdd,
768
- onSave,
769
- customActions
770
- ]);
771
- const menu = useMenuActions(actionsCreator);
772
- return /* @__PURE__ */ React4.createElement(Menu.Root, {
773
- ...menu,
774
- attendableId
775
- }, /* @__PURE__ */ React4.createElement(Menu.Toolbar, {
776
- ...props,
777
- classNames
778
- }));
779
- };
780
-
781
633
  // src/components/Table/ColumnActionsMenu.tsx
782
634
  import { useAtomValue } from "@effect-atom/atom-react";
783
- import React5 from "react";
635
+ import React4 from "react";
784
636
  import { DropdownMenu, useTranslation } from "@dxos/react-ui";
637
+ import { translationKey as translationKey2 } from "#translations";
785
638
  var ColumnActionsMenu = ({ model, modals }) => {
786
- const { t } = useTranslation(translationKey);
639
+ const { t } = useTranslation(translationKey2);
787
640
  const state = useAtomValue(modals.state);
788
641
  if (state?.type !== "column") {
789
642
  return null;
790
643
  }
791
644
  const currentSort = model.getSorting();
792
645
  const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
793
- return /* @__PURE__ */ React5.createElement(DropdownMenu.Root, {
646
+ return /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
794
647
  modal: false,
795
648
  open: true,
796
649
  onOpenChange: modals.close
797
- }, /* @__PURE__ */ React5.createElement(DropdownMenu.VirtualTrigger, {
650
+ }, /* @__PURE__ */ React4.createElement(DropdownMenu.VirtualTrigger, {
798
651
  virtualRef: modals.trigger
799
- }), /* @__PURE__ */ React5.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React5.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React5.createElement(DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
652
+ }), /* @__PURE__ */ React4.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Content, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Viewport, null, (!isCurrentColumnSorted || currentSort?.direction === "asc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
800
653
  "data-testid": "column-sort-descending",
801
654
  onClick: () => model.setSort(state.fieldId, "desc")
802
- }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
655
+ }, t("column-action-sort-descending.menu")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
803
656
  "data-testid": "column-sort-ascending",
804
657
  onClick: () => model.setSort(state.fieldId, "asc")
805
- }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
658
+ }, t("column-action-sort-ascending.menu")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
806
659
  "data-testid": "column-clear-sort",
807
660
  onClick: () => model.clearSort()
808
- }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
661
+ }, t("column-action-clear-sorting.menu")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
809
662
  "data-testid": "column-delete",
810
663
  onClick: () => model.deleteColumn(state.fieldId)
811
- }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
664
+ }, t("column-action-delete.menu")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
812
665
  "data-testid": "column-settings",
813
666
  onClick: () => modals.openColumnSettings()
814
- }, t("column action settings"))), /* @__PURE__ */ React5.createElement(DropdownMenu.Arrow, null))));
667
+ }, t("column-action-settings.menu"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
815
668
  };
816
669
 
817
670
  // src/components/Table/ColumnSettings.tsx
818
671
  import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
819
- import React6, { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo4, useState as useState3 } from "react";
672
+ import React5, { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo3, useState as useState3 } from "react";
820
673
  import { Popover as Popover2 } from "@dxos/react-ui";
821
674
  import { FieldEditor } from "@dxos/react-ui-form";
822
675
  var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
823
676
  const [newField, setNewField] = useState3();
824
677
  const state = useAtomValue2(modals.state);
825
- useEffect3(() => {
678
+ useEffect2(() => {
826
679
  if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
827
680
  setNewField(model.projection.createFieldProjection());
828
681
  requestAnimationFrame(() => {
@@ -835,7 +688,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
835
688
  model?.projection,
836
689
  state
837
690
  ]);
838
- const existingField = useMemo4(() => {
691
+ const existingField = useMemo3(() => {
839
692
  if (state?.type === "columnSettings") {
840
693
  const { mode } = state;
841
694
  if (mode.type === "edit") {
@@ -865,54 +718,55 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
865
718
  if (!model?.projection || !field) {
866
719
  return null;
867
720
  }
868
- return /* @__PURE__ */ React6.createElement(Popover2.Root, {
721
+ return /* @__PURE__ */ React5.createElement(Popover2.Root, {
869
722
  modal: false,
870
723
  open: state?.type === "columnSettings"
871
- }, /* @__PURE__ */ React6.createElement(Popover2.VirtualTrigger, {
724
+ }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
872
725
  virtualRef: modals.trigger
873
- }), /* @__PURE__ */ React6.createElement(Popover2.Portal, null, /* @__PURE__ */ React6.createElement(Popover2.Content, {
726
+ }), /* @__PURE__ */ React5.createElement(Popover2.Portal, null, /* @__PURE__ */ React5.createElement(Popover2.Content, {
874
727
  classNames: "md:w-64"
875
- }, /* @__PURE__ */ React6.createElement(Popover2.Viewport, null, /* @__PURE__ */ React6.createElement(FieldEditor, {
728
+ }, /* @__PURE__ */ React5.createElement(Popover2.Viewport, null, /* @__PURE__ */ React5.createElement(FieldEditor, {
876
729
  projection: model.projection,
877
730
  field,
878
731
  registry,
879
732
  onSave: handleSave,
880
733
  onCancel: handleCancel
881
- })), /* @__PURE__ */ React6.createElement(Popover2.Arrow, null))));
734
+ })), /* @__PURE__ */ React5.createElement(Popover2.Arrow, null))));
882
735
  };
883
736
 
884
737
  // src/components/Table/RowActionsMenu.tsx
885
738
  import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
886
- import React7 from "react";
739
+ import React6 from "react";
887
740
  import { DropdownMenu as DropdownMenu2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
741
+ import { translationKey as translationKey3 } from "#translations";
888
742
  var RowActionsMenu = ({ model, modals }) => {
889
- const { t } = useTranslation2(translationKey);
743
+ const { t } = useTranslation2(translationKey3);
890
744
  const hasSelection = model.selection.hasSelection;
891
745
  const state = useAtomValue3(modals.state);
892
746
  if (state?.type !== "row") {
893
747
  return null;
894
748
  }
895
- return /* @__PURE__ */ React7.createElement(DropdownMenu2.Root, {
749
+ return /* @__PURE__ */ React6.createElement(DropdownMenu2.Root, {
896
750
  modal: false,
897
751
  open: true,
898
752
  onOpenChange: modals.close
899
- }, /* @__PURE__ */ React7.createElement(DropdownMenu2.VirtualTrigger, {
753
+ }, /* @__PURE__ */ React6.createElement(DropdownMenu2.VirtualTrigger, {
900
754
  virtualRef: modals.trigger
901
- }), /* @__PURE__ */ React7.createElement(DropdownMenu2.Content, null, /* @__PURE__ */ React7.createElement(DropdownMenu2.Viewport, null, model.rowActions?.length > 0 && /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(DropdownMenu2.Group, null, model.rowActions?.map((action) => /* @__PURE__ */ React7.createElement(DropdownMenu2.Item, {
755
+ }), /* @__PURE__ */ React6.createElement(DropdownMenu2.Content, null, /* @__PURE__ */ React6.createElement(DropdownMenu2.Viewport, null, model.rowActions?.length > 0 && /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(DropdownMenu2.Group, null, model.rowActions?.map((action) => /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
902
756
  key: action.id,
903
757
  "data-testid": `row-action-${action.id}`,
904
758
  onClick: () => {
905
759
  modals.close();
906
760
  model.handleRowAction(action.id, state.rowIndex);
907
761
  }
908
- }, toLocalizedString(action.label, t)))), /* @__PURE__ */ React7.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React7.createElement(DropdownMenu2.Item, {
762
+ }, toLocalizedString(action.label, t)))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
909
763
  "data-testid": "row-menu-delete",
910
764
  onClick: () => model.deleteRow(state.rowIndex)
911
- }, t(hasSelection ? "bulk delete row label" : "delete row label"))), /* @__PURE__ */ React7.createElement(DropdownMenu2.Arrow, null)));
765
+ }, t(hasSelection ? "bulk-delete-row.label" : "delete-row.label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
912
766
  };
913
767
 
914
- // src/components/Table/Table.tsx
915
- var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
768
+ // src/components/Table/TableContent.tsx
769
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/TableContent.tsx";
916
770
  var columnDefault = {
917
771
  grid: {
918
772
  minSize: 80,
@@ -925,19 +779,17 @@ var rowDefault = {
925
779
  focusUnfurl: false
926
780
  }
927
781
  };
928
- var emptyColumnMeta = Atom3.make({
782
+ var emptyColumnMeta = Atom2.make({
929
783
  grid: {}
930
784
  });
931
- var TableRoot = ({ children }) => {
932
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, children);
933
- };
934
- var emptyRowsAtom = Atom3.make([]);
935
- var emptyCellUpdateAtom = Atom3.make(0);
936
- var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
937
- const registry = useContext2(RegistryContext2);
785
+ var emptyRowsAtom = Atom2.make([]);
786
+ var emptyCellUpdateAtom = Atom2.make(0);
787
+ var TABLE_CONTENT_NAME = "Table.Content";
788
+ var TableContent = composable(({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
789
+ const registry = useContext(RegistryContext);
938
790
  const [dxGrid, setDxGrid] = useState4(null);
939
791
  const { hasAttention } = useAttention(model?.id ?? "table");
940
- const modals = useMemo5(() => new ModalController(registry), [
792
+ const modals = useMemo4(() => new ModalController(registry), [
941
793
  registry
942
794
  ]);
943
795
  const columnMeta = useAtomValue4(model?.columnMeta ?? emptyColumnMeta);
@@ -945,7 +797,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
945
797
  const cellUpdateCounter = useAtomValue4(model?.cellUpdate ?? emptyCellUpdateAtom);
946
798
  const columnCount = Object.keys(columnMeta.grid).length || model?.projection.getFields().length || 0;
947
799
  const draftRowCount = model?.getDraftRowCount() ?? 0;
948
- const frozen = useMemo5(() => {
800
+ const frozen = useMemo4(() => {
949
801
  const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
950
802
  return {
951
803
  frozenRowsStart: 1,
@@ -960,7 +812,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
960
812
  const getCells = useCallback4((range, plane) => presentation?.getCells(range, plane) ?? {}, [
961
813
  presentation
962
814
  ]);
963
- useEffect4(() => {
815
+ useEffect3(() => {
964
816
  if (!dxGrid || !presentation) {
965
817
  return;
966
818
  }
@@ -970,7 +822,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
970
822
  presentation,
971
823
  getCells
972
824
  ]);
973
- useEffect4(() => {
825
+ useEffect3(() => {
974
826
  if (!dxGrid) {
975
827
  return;
976
828
  }
@@ -1141,12 +993,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1141
993
  void navigator.clipboard.writeText(textContent);
1142
994
  event.preventDefault();
1143
995
  } catch (error) {
1144
- log.catch(error, void 0, {
1145
- F: __dxlog_file3,
1146
- L: 310,
1147
- S: void 0,
1148
- C: (f, a) => f(...a)
1149
- });
996
+ log.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 262, S: void 0 });
1150
997
  }
1151
998
  break;
1152
999
  }
@@ -1221,7 +1068,8 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1221
1068
  model,
1222
1069
  dxGrid
1223
1070
  ]);
1224
- useImperativeHandle(forwardedRef, () => {
1071
+ const { controllerRef } = useTableContext(TABLE_CONTENT_NAME);
1072
+ controllerRef.current = useMemo4(() => {
1225
1073
  if (!dxGrid || !presentation) {
1226
1074
  return {};
1227
1075
  }
@@ -1242,24 +1090,26 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1242
1090
  presentation
1243
1091
  ]);
1244
1092
  if (!model || !modals) {
1245
- return /* @__PURE__ */ React8.createElement("span", {
1093
+ return /* @__PURE__ */ React7.createElement("span", {
1246
1094
  role: "none",
1247
1095
  className: "dx-attention-surface"
1248
1096
  });
1249
1097
  }
1250
- return /* @__PURE__ */ React8.createElement("div", composableProps(props, {
1251
- role: "none",
1252
- className: "dx-container relative"
1253
- }), /* @__PURE__ */ React8.createElement(Grid.Root, {
1098
+ return /* @__PURE__ */ React7.createElement("div", {
1099
+ ...composableProps(props, {
1100
+ classNames: "dx-container relative"
1101
+ }),
1102
+ ref: forwardedRef
1103
+ }, /* @__PURE__ */ React7.createElement(Grid.Root, {
1254
1104
  id: model.id ?? "table-grid"
1255
- }, /* @__PURE__ */ React8.createElement(TableValueEditor, {
1105
+ }, /* @__PURE__ */ React7.createElement(TableValueEditor, {
1256
1106
  model,
1257
1107
  modals,
1258
1108
  schema,
1259
1109
  onFocus: handleFocus,
1260
1110
  onSave: handleSave,
1261
1111
  onCreate
1262
- }), /* @__PURE__ */ React8.createElement(Grid.Content, {
1112
+ }), /* @__PURE__ */ React7.createElement(Grid.Content, {
1263
1113
  className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
1264
1114
  frozen,
1265
1115
  columns: columnMeta,
@@ -1276,31 +1126,141 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1276
1126
  "data-testid": testId
1277
1127
  },
1278
1128
  ref: setDxGrid
1279
- }), /* @__PURE__ */ React8.createElement(RowActionsMenu, {
1129
+ }), /* @__PURE__ */ React7.createElement(RowActionsMenu, {
1280
1130
  model,
1281
1131
  modals
1282
- }), /* @__PURE__ */ React8.createElement(ColumnActionsMenu, {
1132
+ }), /* @__PURE__ */ React7.createElement(ColumnActionsMenu, {
1283
1133
  model,
1284
1134
  modals
1285
- }), /* @__PURE__ */ React8.createElement(ColumnSettings, {
1135
+ }), /* @__PURE__ */ React7.createElement(ColumnSettings, {
1286
1136
  model,
1287
1137
  modals,
1288
1138
  onNewColumn: handleNewColumn
1289
1139
  })));
1290
- };
1291
- var TableMain = /* @__PURE__ */ forwardRef(TableMainInner);
1140
+ });
1141
+ TableContent.displayName = TABLE_CONTENT_NAME;
1142
+
1143
+ // src/components/Table/TableToolbar.tsx
1144
+ import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
1145
+ import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
1146
+ import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
1147
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
1148
+ import { translationKey as translationKey4 } from "#translations";
1149
+ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
1150
+ const nodes = [];
1151
+ if (onAdd) {
1152
+ const add = createMenuAction("add-row", onAdd, {
1153
+ type: "add-row",
1154
+ icon: "ph--plus--regular",
1155
+ label: [
1156
+ "add-row.label",
1157
+ {
1158
+ ns: translationKey4
1159
+ }
1160
+ ],
1161
+ testId: "table.toolbar.add-row"
1162
+ });
1163
+ nodes.push(add);
1164
+ }
1165
+ if (onSave) {
1166
+ const state = get(stateAtom);
1167
+ const save = createMenuAction("save-view", onSave, {
1168
+ type: "save-view",
1169
+ icon: "ph--floppy-disk--regular",
1170
+ label: [
1171
+ "save-view.label",
1172
+ {
1173
+ ns: translationKey4
1174
+ }
1175
+ ],
1176
+ testId: "table.toolbar.save-view",
1177
+ iconOnly: false,
1178
+ hidden: !state.viewDirty
1179
+ });
1180
+ nodes.push(save);
1181
+ }
1182
+ const gap = createGapSeparator();
1183
+ nodes.push(...gap.nodes);
1184
+ const edges = nodes.map(({ id: target }) => ({
1185
+ source: "root",
1186
+ target,
1187
+ relation: "child"
1188
+ }));
1189
+ if (customActions) {
1190
+ const custom = get(customActions);
1191
+ nodes.push(...custom.nodes);
1192
+ edges.push(...custom.edges);
1193
+ }
1194
+ return {
1195
+ nodes,
1196
+ edges
1197
+ };
1198
+ });
1199
+ var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
1200
+ const registry = useContext2(RegistryContext2);
1201
+ const stateAtom = useMemo5(() => Atom3.make({
1202
+ viewDirty
1203
+ }), []);
1204
+ useEffect4(() => {
1205
+ registry.set(stateAtom, {
1206
+ viewDirty
1207
+ });
1208
+ }, [
1209
+ registry,
1210
+ stateAtom,
1211
+ viewDirty
1212
+ ]);
1213
+ const actionsCreator = useMemo5(() => createTableToolbarActions({
1214
+ stateAtom,
1215
+ onAdd,
1216
+ onSave,
1217
+ customActions
1218
+ }), [
1219
+ stateAtom,
1220
+ onAdd,
1221
+ onSave,
1222
+ customActions
1223
+ ]);
1224
+ const menuActions = useMenuActions(actionsCreator);
1225
+ return /* @__PURE__ */ React8.createElement(Menu.Root, {
1226
+ ...menuActions,
1227
+ attendableId
1228
+ }, /* @__PURE__ */ React8.createElement(Menu.Toolbar, {
1229
+ ...composableProps2(props),
1230
+ ref: forwardedRef
1231
+ }));
1232
+ });
1233
+ TableToolbar.displayName = "TableToolbar";
1234
+
1235
+ // src/components/Table/Table.tsx
1236
+ var emptyColumnMeta2 = Atom4.make({
1237
+ grid: {}
1238
+ });
1239
+ var [TableContextProvider, useTableContext] = createContext("Table");
1240
+ var TABLE_ROOT_NAME = "Table.Root";
1241
+ var TableRoot = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
1242
+ const controllerRef = useRef3({});
1243
+ useImperativeHandle(forwardedRef, () => ({
1244
+ update: (cell) => controllerRef.current?.update?.(cell),
1245
+ handleInsertRowResult: (result) => controllerRef.current?.handleInsertRowResult?.(result)
1246
+ }), []);
1247
+ return /* @__PURE__ */ React9.createElement(TableContextProvider, {
1248
+ controllerRef
1249
+ }, children);
1250
+ });
1251
+ TableRoot.displayName = TABLE_ROOT_NAME;
1292
1252
  var Table = {
1293
1253
  Root: TableRoot,
1294
- Main: TableMain,
1295
- Toolbar: TableToolbar
1254
+ Toolbar: TableToolbar,
1255
+ Content: TableContent
1296
1256
  };
1297
1257
 
1298
1258
  // src/components/Table/DynamicTable.tsx
1299
1259
  import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
1300
- import React9, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef3, useState as useState5 } from "react";
1260
+ import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
1301
1261
  import { useDefaultValue } from "@dxos/react-ui";
1302
1262
  import { mx as mx2 } from "@dxos/ui-theme";
1303
- var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
1263
+ var DynamicTable = ({ classNames, schema, name = "com.example.dynamicTable", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
1304
1264
  const registry = useContext3(RegistryContext3);
1305
1265
  const [dynamicTable, setDynamicTable] = useState5();
1306
1266
  const { jsonSchema } = useMemo6(() => getBaseSchema({
@@ -1325,7 +1285,7 @@ var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", ro
1325
1285
  jsonSchema,
1326
1286
  properties
1327
1287
  ]);
1328
- const tableRef = useRef3(null);
1288
+ const tableRef = useRef4(null);
1329
1289
  const handleCellUpdate = useCallback5((cell) => {
1330
1290
  tableRef.current?.update?.(cell);
1331
1291
  }, []);
@@ -1356,14 +1316,13 @@ var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", ro
1356
1316
  registry,
1357
1317
  model
1358
1318
  ]);
1359
- return /* @__PURE__ */ React9.createElement("div", {
1360
- role: "none",
1361
- className: mx2("w-full h-full grow grid", classNames)
1362
- }, /* @__PURE__ */ React9.createElement("div", {
1363
- role: "none",
1319
+ return /* @__PURE__ */ React10.createElement("div", {
1320
+ className: mx2("dx-expander grid", classNames)
1321
+ }, /* @__PURE__ */ React10.createElement("div", {
1364
1322
  className: "grid min-h-0 overflow-hidden"
1365
- }, /* @__PURE__ */ React9.createElement(Table.Root, null, /* @__PURE__ */ React9.createElement(Table.Main, {
1366
- ref: tableRef,
1323
+ }, /* @__PURE__ */ React10.createElement(Table.Root, {
1324
+ ref: tableRef
1325
+ }, /* @__PURE__ */ React10.createElement(Table.Content, {
1367
1326
  model,
1368
1327
  presentation,
1369
1328
  ignoreAttention: true,
@@ -1380,7 +1339,6 @@ export {
1380
1339
  Table,
1381
1340
  TableModel,
1382
1341
  TablePresentation,
1383
- TableToolbar,
1384
1342
  cellClassesForRowSelection,
1385
1343
  compareValues,
1386
1344
  createDirectChangeCallback,
@@ -1393,9 +1351,9 @@ export {
1393
1351
  tableButtons,
1394
1352
  tableControls,
1395
1353
  touch,
1396
- translations,
1397
1354
  useAddRow,
1398
1355
  useProjectionModel,
1356
+ useTableContext,
1399
1357
  useTableModel
1400
1358
  };
1401
1359
  //# sourceMappingURL=index.mjs.map