@dxos/react-ui-table 0.8.4-main.4a85c3132b → 0.8.4-main.51f1e5ca51

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