@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
@@ -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-BF54SSNL.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 { composableProps, mx } 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
  }
@@ -256,7 +230,6 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
256
230
  const bgClass = variant === "error" ? "bg-error-surface" : "bg-warning-surface";
257
231
  const textClass = variant === "error" ? "text-error-surface-text" : "text-warning-surface-text";
258
232
  return /* @__PURE__ */ React.createElement("div", {
259
- role: "none",
260
233
  className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
261
234
  style: {
262
235
  ...{
@@ -279,9 +252,10 @@ import { Popover } from "@dxos/react-ui";
279
252
  import { Form } from "@dxos/react-ui-form";
280
253
  import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
281
254
  import { getDeep, isTruthy, setDeep } from "@dxos/util";
255
+ import { translationKey } from "#translations";
282
256
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
283
257
  var createOptionLabel = [
284
- "create new object label",
258
+ "create-new-object.label",
285
259
  {
286
260
  ns: translationKey
287
261
  }
@@ -317,27 +291,11 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
317
291
  const cell = parseCellIndex(contextEditing.index);
318
292
  if (model.isDraftCell(cell)) {
319
293
  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
- });
294
+ invariant(draftRow, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 52, S: void 0, A: ["draftRow", ""] });
329
295
  return draftRow.data;
330
296
  } else {
331
297
  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
- });
298
+ invariant(row, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0, A: ["row", ""] });
341
299
  return row;
342
300
  }
343
301
  }
@@ -457,11 +415,6 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
457
415
 
458
416
  // src/components/TableCellEditor/TableCellEditor.tsx
459
417
  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
418
  var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
466
419
  const { editing } = useGridContext3("TableValueEditor", __gridScope);
467
420
  const fieldProjection = useMemo2(() => {
@@ -471,15 +424,7 @@ var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, o
471
424
  const { col } = parseCellIndex2(editing.index);
472
425
  const field = model.projection.getFields()[col];
473
426
  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
- });
427
+ invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 21, S: void 0, A: ["fieldProjection", ""] });
483
428
  return fieldProjection2;
484
429
  }, [
485
430
  model,
@@ -516,15 +461,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
516
461
  const { col } = parseCellIndex2(editing.index);
517
462
  const field = model.projection.getFields()[col];
518
463
  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
- });
464
+ invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 59, S: void 0, A: ["fieldProjection", ""] });
528
465
  return fieldProjection2;
529
466
  }, [
530
467
  model,
@@ -658,9 +595,13 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
658
595
  __gridScope
659
596
  }), /* @__PURE__ */ React3.createElement(GridCellEditor, {
660
597
  extensions,
598
+ slots: {
599
+ content: {
600
+ className: "!py-(--dx-grid-cell-editor-padding-block)"
601
+ }
602
+ },
661
603
  getCellContent,
662
- onBlur: handleBlur,
663
- slots: editorSlots
604
+ onBlur: handleBlur
664
605
  }));
665
606
  };
666
607
  var determineNavigationAxis = ({ key }) => {
@@ -688,140 +629,52 @@ var determineNavigationDelta = ({ key, shift }) => {
688
629
  return shift ? -1 : 1;
689
630
  };
690
631
 
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
632
  // src/components/Table/ColumnActionsMenu.tsx
781
633
  import { useAtomValue } from "@effect-atom/atom-react";
782
- import React5 from "react";
634
+ import React4 from "react";
783
635
  import { DropdownMenu, useTranslation } from "@dxos/react-ui";
636
+ import { translationKey as translationKey2 } from "#translations";
784
637
  var ColumnActionsMenu = ({ model, modals }) => {
785
- const { t } = useTranslation(translationKey);
638
+ const { t } = useTranslation(translationKey2);
786
639
  const state = useAtomValue(modals.state);
787
640
  if (state?.type !== "column") {
788
641
  return null;
789
642
  }
790
643
  const currentSort = model.getSorting();
791
644
  const isCurrentColumnSorted = currentSort?.fieldId === state.fieldId;
792
- return /* @__PURE__ */ React5.createElement(DropdownMenu.Root, {
645
+ return /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
793
646
  modal: false,
794
647
  open: true,
795
648
  onOpenChange: modals.close
796
- }, /* @__PURE__ */ React5.createElement(DropdownMenu.VirtualTrigger, {
649
+ }, /* @__PURE__ */ React4.createElement(DropdownMenu.VirtualTrigger, {
797
650
  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, {
651
+ }), /* @__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
652
  "data-testid": "column-sort-descending",
800
653
  onClick: () => model.setSort(state.fieldId, "desc")
801
- }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
654
+ }, t("column-action-sort-descending.menu")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
802
655
  "data-testid": "column-sort-ascending",
803
656
  onClick: () => model.setSort(state.fieldId, "asc")
804
- }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
657
+ }, t("column-action-sort-ascending.menu")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
805
658
  "data-testid": "column-clear-sort",
806
659
  onClick: () => model.clearSort()
807
- }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
660
+ }, t("column-action-clear-sorting.menu")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
808
661
  "data-testid": "column-delete",
809
662
  onClick: () => model.deleteColumn(state.fieldId)
810
- }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
663
+ }, t("column-action-delete.menu")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
811
664
  "data-testid": "column-settings",
812
665
  onClick: () => modals.openColumnSettings()
813
- }, t("column action settings"))), /* @__PURE__ */ React5.createElement(DropdownMenu.Arrow, null))));
666
+ }, t("column-action-settings.menu"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
814
667
  };
815
668
 
816
669
  // src/components/Table/ColumnSettings.tsx
817
670
  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";
671
+ import React5, { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo3, useState as useState3 } from "react";
819
672
  import { Popover as Popover2 } from "@dxos/react-ui";
820
673
  import { FieldEditor } from "@dxos/react-ui-form";
821
674
  var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
822
675
  const [newField, setNewField] = useState3();
823
676
  const state = useAtomValue2(modals.state);
824
- useEffect3(() => {
677
+ useEffect2(() => {
825
678
  if (state?.type === "columnSettings" && state.mode.type === "create" && model?.projection) {
826
679
  setNewField(model.projection.createFieldProjection());
827
680
  requestAnimationFrame(() => {
@@ -834,7 +687,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
834
687
  model?.projection,
835
688
  state
836
689
  ]);
837
- const existingField = useMemo4(() => {
690
+ const existingField = useMemo3(() => {
838
691
  if (state?.type === "columnSettings") {
839
692
  const { mode } = state;
840
693
  if (mode.type === "edit") {
@@ -864,54 +717,55 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
864
717
  if (!model?.projection || !field) {
865
718
  return null;
866
719
  }
867
- return /* @__PURE__ */ React6.createElement(Popover2.Root, {
720
+ return /* @__PURE__ */ React5.createElement(Popover2.Root, {
868
721
  modal: false,
869
722
  open: state?.type === "columnSettings"
870
- }, /* @__PURE__ */ React6.createElement(Popover2.VirtualTrigger, {
723
+ }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
871
724
  virtualRef: modals.trigger
872
- }), /* @__PURE__ */ React6.createElement(Popover2.Portal, null, /* @__PURE__ */ React6.createElement(Popover2.Content, {
725
+ }), /* @__PURE__ */ React5.createElement(Popover2.Portal, null, /* @__PURE__ */ React5.createElement(Popover2.Content, {
873
726
  classNames: "md:w-64"
874
- }, /* @__PURE__ */ React6.createElement(Popover2.Viewport, null, /* @__PURE__ */ React6.createElement(FieldEditor, {
727
+ }, /* @__PURE__ */ React5.createElement(Popover2.Viewport, null, /* @__PURE__ */ React5.createElement(FieldEditor, {
875
728
  projection: model.projection,
876
729
  field,
877
730
  registry,
878
731
  onSave: handleSave,
879
732
  onCancel: handleCancel
880
- })), /* @__PURE__ */ React6.createElement(Popover2.Arrow, null))));
733
+ })), /* @__PURE__ */ React5.createElement(Popover2.Arrow, null))));
881
734
  };
882
735
 
883
736
  // src/components/Table/RowActionsMenu.tsx
884
737
  import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
885
- import React7 from "react";
738
+ import React6 from "react";
886
739
  import { DropdownMenu as DropdownMenu2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
740
+ import { translationKey as translationKey3 } from "#translations";
887
741
  var RowActionsMenu = ({ model, modals }) => {
888
- const { t } = useTranslation2(translationKey);
742
+ const { t } = useTranslation2(translationKey3);
889
743
  const hasSelection = model.selection.hasSelection;
890
744
  const state = useAtomValue3(modals.state);
891
745
  if (state?.type !== "row") {
892
746
  return null;
893
747
  }
894
- return /* @__PURE__ */ React7.createElement(DropdownMenu2.Root, {
748
+ return /* @__PURE__ */ React6.createElement(DropdownMenu2.Root, {
895
749
  modal: false,
896
750
  open: true,
897
751
  onOpenChange: modals.close
898
- }, /* @__PURE__ */ React7.createElement(DropdownMenu2.VirtualTrigger, {
752
+ }, /* @__PURE__ */ React6.createElement(DropdownMenu2.VirtualTrigger, {
899
753
  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, {
754
+ }), /* @__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
755
  key: action.id,
902
756
  "data-testid": `row-action-${action.id}`,
903
757
  onClick: () => {
904
758
  modals.close();
905
759
  model.handleRowAction(action.id, state.rowIndex);
906
760
  }
907
- }, toLocalizedString(action.label, t)))), /* @__PURE__ */ React7.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React7.createElement(DropdownMenu2.Item, {
761
+ }, toLocalizedString(action.label, t)))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
908
762
  "data-testid": "row-menu-delete",
909
763
  onClick: () => model.deleteRow(state.rowIndex)
910
- }, t(hasSelection ? "bulk delete row label" : "delete row label"))), /* @__PURE__ */ React7.createElement(DropdownMenu2.Arrow, null)));
764
+ }, t(hasSelection ? "bulk-delete-row.label" : "delete-row.label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
911
765
  };
912
766
 
913
- // src/components/Table/Table.tsx
914
- var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
767
+ // src/components/Table/TableContent.tsx
768
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/TableContent.tsx";
915
769
  var columnDefault = {
916
770
  grid: {
917
771
  minSize: 80,
@@ -924,19 +778,17 @@ var rowDefault = {
924
778
  focusUnfurl: false
925
779
  }
926
780
  };
927
- var emptyColumnMeta = Atom3.make({
781
+ var emptyColumnMeta = Atom2.make({
928
782
  grid: {}
929
783
  });
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);
784
+ var emptyRowsAtom = Atom2.make([]);
785
+ var emptyCellUpdateAtom = Atom2.make(0);
786
+ var TABLE_CONTENT_NAME = "Table.Content";
787
+ var TableContent = composable(({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
788
+ const registry = useContext(RegistryContext);
937
789
  const [dxGrid, setDxGrid] = useState4(null);
938
790
  const { hasAttention } = useAttention(model?.id ?? "table");
939
- const modals = useMemo5(() => new ModalController(registry), [
791
+ const modals = useMemo4(() => new ModalController(registry), [
940
792
  registry
941
793
  ]);
942
794
  const columnMeta = useAtomValue4(model?.columnMeta ?? emptyColumnMeta);
@@ -944,7 +796,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
944
796
  const cellUpdateCounter = useAtomValue4(model?.cellUpdate ?? emptyCellUpdateAtom);
945
797
  const columnCount = Object.keys(columnMeta.grid).length || model?.projection.getFields().length || 0;
946
798
  const draftRowCount = model?.getDraftRowCount() ?? 0;
947
- const frozen = useMemo5(() => {
799
+ const frozen = useMemo4(() => {
948
800
  const noActionColumn = model?.features.dataEditable === false && model?.features.schemaEditable === false && model.rowActions.length === 0;
949
801
  return {
950
802
  frozenRowsStart: 1,
@@ -959,7 +811,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
959
811
  const getCells = useCallback4((range, plane) => presentation?.getCells(range, plane) ?? {}, [
960
812
  presentation
961
813
  ]);
962
- useEffect4(() => {
814
+ useEffect3(() => {
963
815
  if (!dxGrid || !presentation) {
964
816
  return;
965
817
  }
@@ -969,7 +821,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
969
821
  presentation,
970
822
  getCells
971
823
  ]);
972
- useEffect4(() => {
824
+ useEffect3(() => {
973
825
  if (!dxGrid) {
974
826
  return;
975
827
  }
@@ -1140,12 +992,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1140
992
  void navigator.clipboard.writeText(textContent);
1141
993
  event.preventDefault();
1142
994
  } 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
- });
995
+ log.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 262, S: void 0 });
1149
996
  }
1150
997
  break;
1151
998
  }
@@ -1220,7 +1067,8 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1220
1067
  model,
1221
1068
  dxGrid
1222
1069
  ]);
1223
- useImperativeHandle(forwardedRef, () => {
1070
+ const { controllerRef } = useTableContext(TABLE_CONTENT_NAME);
1071
+ controllerRef.current = useMemo4(() => {
1224
1072
  if (!dxGrid || !presentation) {
1225
1073
  return {};
1226
1074
  }
@@ -1241,24 +1089,26 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1241
1089
  presentation
1242
1090
  ]);
1243
1091
  if (!model || !modals) {
1244
- return /* @__PURE__ */ React8.createElement("span", {
1092
+ return /* @__PURE__ */ React7.createElement("span", {
1245
1093
  role: "none",
1246
1094
  className: "dx-attention-surface"
1247
1095
  });
1248
1096
  }
1249
- return /* @__PURE__ */ React8.createElement("div", composableProps(props, {
1250
- role: "none",
1251
- className: "dx-container relative"
1252
- }), /* @__PURE__ */ React8.createElement(Grid.Root, {
1097
+ return /* @__PURE__ */ React7.createElement("div", {
1098
+ ...composableProps(props, {
1099
+ classNames: "dx-container relative"
1100
+ }),
1101
+ ref: forwardedRef
1102
+ }, /* @__PURE__ */ React7.createElement(Grid.Root, {
1253
1103
  id: model.id ?? "table-grid"
1254
- }, /* @__PURE__ */ React8.createElement(TableValueEditor, {
1104
+ }, /* @__PURE__ */ React7.createElement(TableValueEditor, {
1255
1105
  model,
1256
1106
  modals,
1257
1107
  schema,
1258
1108
  onFocus: handleFocus,
1259
1109
  onSave: handleSave,
1260
1110
  onCreate
1261
- }), /* @__PURE__ */ React8.createElement(Grid.Content, {
1111
+ }), /* @__PURE__ */ React7.createElement(Grid.Content, {
1262
1112
  className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
1263
1113
  frozen,
1264
1114
  columns: columnMeta,
@@ -1275,31 +1125,141 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1275
1125
  "data-testid": testId
1276
1126
  },
1277
1127
  ref: setDxGrid
1278
- }), /* @__PURE__ */ React8.createElement(RowActionsMenu, {
1128
+ }), /* @__PURE__ */ React7.createElement(RowActionsMenu, {
1279
1129
  model,
1280
1130
  modals
1281
- }), /* @__PURE__ */ React8.createElement(ColumnActionsMenu, {
1131
+ }), /* @__PURE__ */ React7.createElement(ColumnActionsMenu, {
1282
1132
  model,
1283
1133
  modals
1284
- }), /* @__PURE__ */ React8.createElement(ColumnSettings, {
1134
+ }), /* @__PURE__ */ React7.createElement(ColumnSettings, {
1285
1135
  model,
1286
1136
  modals,
1287
1137
  onNewColumn: handleNewColumn
1288
1138
  })));
1289
- };
1290
- var TableMain = /* @__PURE__ */ forwardRef(TableMainInner);
1139
+ });
1140
+ TableContent.displayName = TABLE_CONTENT_NAME;
1141
+
1142
+ // src/components/Table/TableToolbar.tsx
1143
+ import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
1144
+ import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
1145
+ import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
1146
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
1147
+ import { translationKey as translationKey4 } from "#translations";
1148
+ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
1149
+ const nodes = [];
1150
+ if (onAdd) {
1151
+ const add = createMenuAction("add-row", onAdd, {
1152
+ type: "add-row",
1153
+ icon: "ph--plus--regular",
1154
+ label: [
1155
+ "add-row.label",
1156
+ {
1157
+ ns: translationKey4
1158
+ }
1159
+ ],
1160
+ testId: "table.toolbar.add-row"
1161
+ });
1162
+ nodes.push(add);
1163
+ }
1164
+ if (onSave) {
1165
+ const state = get(stateAtom);
1166
+ const save = createMenuAction("save-view", onSave, {
1167
+ type: "save-view",
1168
+ icon: "ph--floppy-disk--regular",
1169
+ label: [
1170
+ "save-view.label",
1171
+ {
1172
+ ns: translationKey4
1173
+ }
1174
+ ],
1175
+ testId: "table.toolbar.save-view",
1176
+ iconOnly: false,
1177
+ hidden: !state.viewDirty
1178
+ });
1179
+ nodes.push(save);
1180
+ }
1181
+ const gap = createGapSeparator();
1182
+ nodes.push(...gap.nodes);
1183
+ const edges = nodes.map(({ id: target }) => ({
1184
+ source: "root",
1185
+ target,
1186
+ relation: "child"
1187
+ }));
1188
+ if (customActions) {
1189
+ const custom = get(customActions);
1190
+ nodes.push(...custom.nodes);
1191
+ edges.push(...custom.edges);
1192
+ }
1193
+ return {
1194
+ nodes,
1195
+ edges
1196
+ };
1197
+ });
1198
+ var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
1199
+ const registry = useContext2(RegistryContext2);
1200
+ const stateAtom = useMemo5(() => Atom3.make({
1201
+ viewDirty
1202
+ }), []);
1203
+ useEffect4(() => {
1204
+ registry.set(stateAtom, {
1205
+ viewDirty
1206
+ });
1207
+ }, [
1208
+ registry,
1209
+ stateAtom,
1210
+ viewDirty
1211
+ ]);
1212
+ const actionsCreator = useMemo5(() => createTableToolbarActions({
1213
+ stateAtom,
1214
+ onAdd,
1215
+ onSave,
1216
+ customActions
1217
+ }), [
1218
+ stateAtom,
1219
+ onAdd,
1220
+ onSave,
1221
+ customActions
1222
+ ]);
1223
+ const menuActions = useMenuActions(actionsCreator);
1224
+ return /* @__PURE__ */ React8.createElement(Menu.Root, {
1225
+ ...menuActions,
1226
+ attendableId
1227
+ }, /* @__PURE__ */ React8.createElement(Menu.Toolbar, {
1228
+ ...composableProps2(props),
1229
+ ref: forwardedRef
1230
+ }));
1231
+ });
1232
+ TableToolbar.displayName = "TableToolbar";
1233
+
1234
+ // src/components/Table/Table.tsx
1235
+ var emptyColumnMeta2 = Atom4.make({
1236
+ grid: {}
1237
+ });
1238
+ var [TableContextProvider, useTableContext] = createContext("Table");
1239
+ var TABLE_ROOT_NAME = "Table.Root";
1240
+ var TableRoot = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
1241
+ const controllerRef = useRef3({});
1242
+ useImperativeHandle(forwardedRef, () => ({
1243
+ update: (cell) => controllerRef.current?.update?.(cell),
1244
+ handleInsertRowResult: (result) => controllerRef.current?.handleInsertRowResult?.(result)
1245
+ }), []);
1246
+ return /* @__PURE__ */ React9.createElement(TableContextProvider, {
1247
+ controllerRef
1248
+ }, children);
1249
+ });
1250
+ TableRoot.displayName = TABLE_ROOT_NAME;
1291
1251
  var Table = {
1292
1252
  Root: TableRoot,
1293
- Main: TableMain,
1294
- Toolbar: TableToolbar
1253
+ Toolbar: TableToolbar,
1254
+ Content: TableContent
1295
1255
  };
1296
1256
 
1297
1257
  // src/components/Table/DynamicTable.tsx
1298
1258
  import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
1299
- import React9, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef3, useState as useState5 } from "react";
1259
+ import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
1300
1260
  import { useDefaultValue } from "@dxos/react-ui";
1301
1261
  import { mx as mx2 } from "@dxos/ui-theme";
1302
- var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
1262
+ var DynamicTable = ({ classNames, schema, name = "com.example.dynamicTable", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
1303
1263
  const registry = useContext3(RegistryContext3);
1304
1264
  const [dynamicTable, setDynamicTable] = useState5();
1305
1265
  const { jsonSchema } = useMemo6(() => getBaseSchema({
@@ -1324,7 +1284,7 @@ var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", ro
1324
1284
  jsonSchema,
1325
1285
  properties
1326
1286
  ]);
1327
- const tableRef = useRef3(null);
1287
+ const tableRef = useRef4(null);
1328
1288
  const handleCellUpdate = useCallback5((cell) => {
1329
1289
  tableRef.current?.update?.(cell);
1330
1290
  }, []);
@@ -1355,14 +1315,13 @@ var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", ro
1355
1315
  registry,
1356
1316
  model
1357
1317
  ]);
1358
- return /* @__PURE__ */ React9.createElement("div", {
1359
- role: "none",
1360
- className: mx2("w-full h-full grow grid", classNames)
1361
- }, /* @__PURE__ */ React9.createElement("div", {
1362
- role: "none",
1318
+ return /* @__PURE__ */ React10.createElement("div", {
1319
+ className: mx2("dx-expander grid", classNames)
1320
+ }, /* @__PURE__ */ React10.createElement("div", {
1363
1321
  className: "grid min-h-0 overflow-hidden"
1364
- }, /* @__PURE__ */ React9.createElement(Table.Root, null, /* @__PURE__ */ React9.createElement(Table.Main, {
1365
- ref: tableRef,
1322
+ }, /* @__PURE__ */ React10.createElement(Table.Root, {
1323
+ ref: tableRef
1324
+ }, /* @__PURE__ */ React10.createElement(Table.Content, {
1366
1325
  model,
1367
1326
  presentation,
1368
1327
  ignoreAttention: true,
@@ -1379,7 +1338,6 @@ export {
1379
1338
  Table,
1380
1339
  TableModel,
1381
1340
  TablePresentation,
1382
- TableToolbar,
1383
1341
  cellClassesForRowSelection,
1384
1342
  compareValues,
1385
1343
  createDirectChangeCallback,
@@ -1392,9 +1350,9 @@ export {
1392
1350
  tableButtons,
1393
1351
  tableControls,
1394
1352
  touch,
1395
- translations,
1396
1353
  useAddRow,
1397
1354
  useProjectionModel,
1355
+ useTableContext,
1398
1356
  useTableModel
1399
1357
  };
1400
1358
  //# sourceMappingURL=index.mjs.map