@dxos/react-ui-table 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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 (108) hide show
  1. package/dist/lib/browser/{chunk-OZBLY7XM.mjs → chunk-BF54SSNL.mjs} +12 -18
  2. package/dist/lib/browser/chunk-BF54SSNL.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-I5IFW7UF.mjs → chunk-EK6D2CVM.mjs} +37 -32
  4. package/dist/lib/browser/chunk-EK6D2CVM.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +200 -173
  6. package/dist/lib/browser/index.mjs.map +4 -4
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/testing/index.mjs +4 -4
  9. package/dist/lib/browser/testing/index.mjs.map +2 -2
  10. package/dist/lib/browser/types/index.mjs +1 -1
  11. package/dist/lib/node-esm/{chunk-DDJKYJFY.mjs → chunk-LYYDF6JP.mjs} +37 -32
  12. package/dist/lib/node-esm/chunk-LYYDF6JP.mjs.map +7 -0
  13. package/dist/lib/node-esm/{chunk-WNZSKIRF.mjs → chunk-SIRDIPHZ.mjs} +12 -18
  14. package/dist/lib/node-esm/chunk-SIRDIPHZ.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +200 -173
  16. package/dist/lib/node-esm/index.mjs.map +4 -4
  17. package/dist/lib/node-esm/meta.json +1 -1
  18. package/dist/lib/node-esm/testing/index.mjs +4 -4
  19. package/dist/lib/node-esm/testing/index.mjs.map +2 -2
  20. package/dist/lib/node-esm/types/index.mjs +1 -1
  21. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  22. package/dist/types/src/components/Table/DynamicTable.d.ts +5 -4
  23. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  24. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +20 -22
  25. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  26. package/dist/types/src/components/Table/Relations.stories.d.ts +80 -82
  27. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  28. package/dist/types/src/components/Table/Table.d.ts +28 -21
  29. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  30. package/dist/types/src/components/Table/Table.stories.d.ts +82 -84
  31. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  32. package/dist/types/src/components/Table/TableContent.d.ts +21 -0
  33. package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
  34. package/dist/types/src/components/Table/TableToolbar.d.ts +25 -0
  35. package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
  36. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +3 -3
  37. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  38. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +2 -2
  39. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  40. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +22 -24
  41. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  42. package/dist/types/src/components/index.d.ts +0 -1
  43. package/dist/types/src/components/index.d.ts.map +1 -1
  44. package/dist/types/src/hooks/useAddRow.d.ts +1 -1
  45. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  46. package/dist/types/src/hooks/useProjectionModel.d.ts +1 -1
  47. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
  48. package/dist/types/src/hooks/useTableModel.d.ts +1 -1
  49. package/dist/types/src/model/table-model.d.ts +5 -4
  50. package/dist/types/src/model/table-model.d.ts.map +1 -1
  51. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  52. package/dist/types/src/playwright/TableManager.d.ts +2 -1
  53. package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
  54. package/dist/types/src/testing/useTestTableModel.d.ts +2 -2
  55. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  56. package/dist/types/src/translations.d.ts +19 -21
  57. package/dist/types/src/translations.d.ts.map +1 -1
  58. package/dist/types/src/types/Table.d.ts +1 -6
  59. package/dist/types/src/types/Table.d.ts.map +1 -1
  60. package/dist/types/src/util/dynamic-table.d.ts +6 -5
  61. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  62. package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
  63. package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
  64. package/dist/types/src/util/query-ast.d.ts.map +1 -1
  65. package/dist/types/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +43 -43
  67. package/src/components/Table/ColumnActionsMenu.tsx +5 -5
  68. package/src/components/Table/ColumnSettings.tsx +3 -4
  69. package/src/components/Table/DynamicTable.stories.tsx +6 -5
  70. package/src/components/Table/DynamicTable.tsx +13 -19
  71. package/src/components/Table/Relations.stories.tsx +35 -25
  72. package/src/components/Table/Table.stories.tsx +61 -40
  73. package/src/components/Table/Table.tsx +41 -434
  74. package/src/components/Table/TableContent.tsx +422 -0
  75. package/src/components/{TableToolbar → Table}/TableToolbar.tsx +35 -42
  76. package/src/components/TableCellEditor/CellValidationMessage.tsx +4 -4
  77. package/src/components/TableCellEditor/FormCellEditor.tsx +12 -6
  78. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +6 -5
  79. package/src/components/TableCellEditor/TableCellEditor.tsx +10 -5
  80. package/src/components/index.ts +0 -1
  81. package/src/components/testing.ts +1 -1
  82. package/src/hooks/useAddRow.ts +1 -1
  83. package/src/hooks/useProjectionModel.ts +3 -3
  84. package/src/hooks/useTableModel.ts +1 -1
  85. package/src/model/table-model.test.ts +5 -5
  86. package/src/model/table-model.ts +13 -12
  87. package/src/model/table-presentation.test.ts +5 -5
  88. package/src/model/table-presentation.ts +12 -11
  89. package/src/playwright/TableManager.ts +10 -3
  90. package/src/playwright/playwright.config.ts +1 -1
  91. package/src/playwright/smoke.spec.ts +45 -2
  92. package/src/testing/useTestTableModel.ts +4 -4
  93. package/src/translations.ts +19 -21
  94. package/src/types/Table.ts +11 -22
  95. package/src/util/dynamic-table.test.ts +70 -0
  96. package/src/util/dynamic-table.ts +17 -16
  97. package/src/util/query-ast.ts +3 -0
  98. package/src/util/table-buttons.ts +1 -1
  99. package/src/util/table-controls.ts +2 -2
  100. package/dist/lib/browser/chunk-I5IFW7UF.mjs.map +0 -7
  101. package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +0 -7
  102. package/dist/lib/node-esm/chunk-DDJKYJFY.mjs.map +0 -7
  103. package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +0 -7
  104. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
  105. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
  106. package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
  107. package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
  108. package/src/components/TableToolbar/index.ts +0 -5
@@ -16,10 +16,10 @@ import {
16
16
  useAddRow,
17
17
  useProjectionModel,
18
18
  useTableModel
19
- } from "./chunk-I5IFW7UF.mjs";
19
+ } from "./chunk-EK6D2CVM.mjs";
20
20
  import {
21
21
  Table_exports
22
- } from "./chunk-OZBLY7XM.mjs";
22
+ } from "./chunk-BF54SSNL.mjs";
23
23
 
24
24
  // src/translations.ts
25
25
  var translationKey = "@dxos/react-ui-table";
@@ -27,56 +27,59 @@ var translations = [
27
27
  {
28
28
  "en-US": {
29
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"
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
+ "continue.label": "Continue",
36
+ "create-stack-section.label": "Create table",
37
+ "add-row.label": "Add row",
38
+ "column-action-sort-descending.menu": "Sort Descending",
39
+ "column-action-sort-ascending.menu": "Sort Ascending",
40
+ "column-action-clear-sorting.menu": "Clear Sorting",
41
+ "column-action-settings.menu": "Column Settings",
42
+ "column-action-delete.menu": "Delete Column",
43
+ "delete-row.label": "Delete row",
44
+ "bulk-delete-row.label": "Delete selected rows",
45
+ "column-deleted.label": "Column deleted",
46
+ "new-column-button.label": "Create column",
47
+ "create-new-object.label": "Create new object \u201C{{text}}\u201D",
48
+ "save-view.label": "Save changes to view"
51
49
  }
52
50
  }
53
51
  }
54
52
  ];
55
53
 
56
54
  // src/components/Table/Table.tsx
55
+ import { Atom as Atom4 } from "@effect-atom/atom-react";
56
+ import { createContext } from "@radix-ui/react-context";
57
+ import React9, { forwardRef, useImperativeHandle, useRef as useRef3 } from "react";
58
+
59
+ // src/components/Table/TableContent.tsx
57
60
  import { Atom as Atom2, RegistryContext, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
58
61
  import * as String2 from "effect/String";
59
- import React7, { forwardRef, useCallback as useCallback4, useContext, useEffect as useEffect3, useImperativeHandle, useMemo as useMemo4, useState as useState4 } from "react";
62
+ import React7, { useCallback as useCallback4, useContext, useEffect as useEffect3, useMemo as useMemo4, useState as useState4 } from "react";
60
63
  import { log } from "@dxos/log";
61
64
  import { useAttention } from "@dxos/react-ui-attention";
62
65
  import { Grid, closestCell, gridSeparatorBlockEnd, gridSeparatorInlineEnd } from "@dxos/react-ui-grid";
63
66
  import { DxEditRequest } from "@dxos/react-ui-grid";
64
- import { mx } from "@dxos/ui-theme";
67
+ import { composable, composableProps, mx } from "@dxos/ui-theme";
65
68
 
66
69
  // src/util/dynamic-table.ts
67
- import { Filter, Obj, Order, Query, Ref, Type } from "@dxos/echo";
68
- import { ProjectionModel, View, createDirectChangeCallback as createDirectChangeCallback2, getSchemaFromPropertyDefinitions } from "@dxos/schema";
70
+ import { Filter, JsonSchema, Obj, Order, Query, Ref, Type } from "@dxos/echo";
71
+ import { ProjectionModel, ViewModel, createEchoChangeCallback as createEchoChangeCallback2, getSchemaFromPropertyDefinitions } from "@dxos/schema";
69
72
  var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
70
73
  if (typename && properties) {
71
74
  const schema2 = getSchemaFromPropertyDefinitions(typename, properties);
72
75
  return {
73
76
  typename: schema2.typename,
74
- jsonSchema: schema2.jsonSchema
77
+ jsonSchema: JsonSchema.toJsonSchema(schema2)
75
78
  };
76
79
  } else if (schema) {
77
80
  return {
78
81
  typename: Type.getTypename(schema),
79
- jsonSchema: Type.toJsonSchema(schema)
82
+ jsonSchema: JsonSchema.toJsonSchema(schema)
80
83
  };
81
84
  } else if (typename && jsonSchema) {
82
85
  return {
@@ -88,7 +91,7 @@ var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
88
91
  }
89
92
  };
90
93
  var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
91
- const view = View.make({
94
+ const view = ViewModel.make({
92
95
  query: Query.select(Filter.everything()),
93
96
  jsonSchema,
94
97
  ...properties && {
@@ -103,7 +106,7 @@ var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
103
106
  registry,
104
107
  view,
105
108
  baseSchema: jsonSchema,
106
- change: createDirectChangeCallback2(view.projection, jsonSchema)
109
+ change: createEchoChangeCallback2(view, jsonSchema)
107
110
  });
108
111
  projection.normalizeView();
109
112
  if (properties && projection.getFields()) {
@@ -119,8 +122,8 @@ var setProperties = (view, projection, table, properties) => {
119
122
  const field = projection.getFields().find((field2) => field2.path === property.name);
120
123
  if (field) {
121
124
  if (property.size !== void 0) {
122
- Obj.change(table, (t) => {
123
- t.sizes[field.path] = property.size;
125
+ Obj.change(table, (obj) => {
126
+ obj.sizes[field.path] = property.size;
124
127
  });
125
128
  }
126
129
  if (property.title !== void 0) {
@@ -136,8 +139,8 @@ var setProperties = (view, projection, table, properties) => {
136
139
  if (property.sort) {
137
140
  const currentQuery = Query.fromAst(Obj.getSnapshot(view).query.ast);
138
141
  const newQuery = currentQuery.orderBy(Order.property(field.path, property.sort));
139
- Obj.change(view, (v) => {
140
- v.query.ast = newQuery.ast;
142
+ Obj.change(view, (obj) => {
143
+ obj.query.ast = newQuery.ast;
141
144
  });
142
145
  }
143
146
  }
@@ -253,14 +256,14 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
253
256
  if (!editing || !validationError) {
254
257
  return null;
255
258
  }
256
- const bgClass = variant === "error" ? "bg-errorSurface" : "bg-warningSurface";
257
- const textClass = variant === "error" ? "text-errorSurfaceText" : "text-warningSurfaceText";
259
+ const bgClass = variant === "error" ? "bg-error-surface" : "bg-warning-surface";
260
+ const textClass = variant === "error" ? "text-error-surface-text" : "text-warning-surface-text";
258
261
  return /* @__PURE__ */ React.createElement("div", {
259
262
  role: "none",
260
- className: `absolute ${bgClass} ${textClass} rounded-bs-sm text-xs p-1`,
263
+ className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
261
264
  style: {
262
265
  ...{
263
- "--dx-gridCellWidth": `${box?.inlineSize ?? 200}px`
266
+ "--dx-grid-cell-width": `${box?.inlineSize ?? 200}px`
264
267
  },
265
268
  zIndex: 10,
266
269
  insetBlockEnd: `calc(100% - ${box.insetBlockStart}px)`,
@@ -281,7 +284,7 @@ import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-u
281
284
  import { getDeep, isTruthy, setDeep } from "@dxos/util";
282
285
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
283
286
  var createOptionLabel = [
284
- "create new object label",
287
+ "create-new-object.label",
285
288
  {
286
289
  ns: translationKey
287
290
  }
@@ -346,9 +349,13 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
346
349
  model,
347
350
  contextEditing
348
351
  ]);
349
- const formValues = useMemo(() => originalRow ? JSON.parse(JSON.stringify(originalRow)) : {}, [
352
+ const initialFormValues = useMemo(() => originalRow ? JSON.parse(JSON.stringify(originalRow)) : {}, [
350
353
  originalRow
351
354
  ]);
355
+ const [formValues, setFormValues] = useState(initialFormValues);
356
+ const handleValuesChanged = useCallback((values) => {
357
+ setFormValues(values);
358
+ }, []);
352
359
  const handleOpenChange = useCallback((nextOpen) => {
353
360
  if (nextOpen === false) {
354
361
  setEditing(null);
@@ -433,12 +440,14 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
433
440
  virtualRef: anchorRef
434
441
  }), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
435
442
  tabIndex: -1,
436
- classNames: "popover-card-width density-fine"
443
+ classNames: "dx-card-popover-width dx-density-fine"
437
444
  }, /* @__PURE__ */ React2.createElement(Popover.Arrow, null), /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Form.Root, {
438
445
  ...formProps,
439
446
  autoFocus: true,
440
447
  schema: narrowedSchema,
441
448
  values: formValues,
449
+ onValuesChanged: handleValuesChanged,
450
+ projection: model?.projection,
442
451
  createInitialValuePath: fieldProjection.field.referencePath,
443
452
  createOptionIcon: "ph--plus--regular",
444
453
  createOptionLabel,
@@ -451,9 +460,9 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
451
460
 
452
461
  // src/components/TableCellEditor/TableCellEditor.tsx
453
462
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
454
- var editorSlots = {
463
+ var documentSlots = {
455
464
  scroll: {
456
- className: "!plb-[--dx-grid-cell-editor-padding-block]"
465
+ className: "!py-(--dx-grid-cell-editor-padding-block)"
457
466
  }
458
467
  };
459
468
  var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
@@ -654,7 +663,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
654
663
  extensions,
655
664
  getCellContent,
656
665
  onBlur: handleBlur,
657
- slots: editorSlots
666
+ slots: documentSlots
658
667
  }));
659
668
  };
660
669
  var determineNavigationAxis = ({ key }) => {
@@ -703,19 +712,19 @@ var ColumnActionsMenu = ({ model, modals }) => {
703
712
  }), /* @__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, {
704
713
  "data-testid": "column-sort-descending",
705
714
  onClick: () => model.setSort(state.fieldId, "desc")
706
- }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
715
+ }, t("column-action-sort-descending.menu")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
707
716
  "data-testid": "column-sort-ascending",
708
717
  onClick: () => model.setSort(state.fieldId, "asc")
709
- }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
718
+ }, t("column-action-sort-ascending.menu")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
710
719
  "data-testid": "column-clear-sort",
711
720
  onClick: () => model.clearSort()
712
- }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
721
+ }, t("column-action-clear-sorting.menu")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
713
722
  "data-testid": "column-delete",
714
723
  onClick: () => model.deleteColumn(state.fieldId)
715
- }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
724
+ }, t("column-action-delete.menu")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
716
725
  "data-testid": "column-settings",
717
726
  onClick: () => modals.openColumnSettings()
718
- }, t("column action settings"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
727
+ }, t("column-action-settings.menu"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
719
728
  };
720
729
 
721
730
  // src/components/Table/ColumnSettings.tsx
@@ -775,7 +784,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
775
784
  }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
776
785
  virtualRef: modals.trigger
777
786
  }), /* @__PURE__ */ React5.createElement(Popover2.Portal, null, /* @__PURE__ */ React5.createElement(Popover2.Content, {
778
- classNames: "md:is-64"
787
+ classNames: "md:w-64"
779
788
  }, /* @__PURE__ */ React5.createElement(Popover2.Viewport, null, /* @__PURE__ */ React5.createElement(FieldEditor, {
780
789
  projection: model.projection,
781
790
  field,
@@ -815,8 +824,8 @@ var RowActionsMenu = ({ model, modals }) => {
815
824
  }, t(hasSelection ? "bulk delete row label" : "delete row label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
816
825
  };
817
826
 
818
- // src/components/Table/Table.tsx
819
- var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
827
+ // src/components/Table/TableContent.tsx
828
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/TableContent.tsx";
820
829
  var columnDefault = {
821
830
  grid: {
822
831
  minSize: 80,
@@ -832,22 +841,10 @@ var rowDefault = {
832
841
  var emptyColumnMeta = Atom2.make({
833
842
  grid: {}
834
843
  });
835
- var TableRoot = ({ children, role = "article" }) => {
836
- return /* @__PURE__ */ React7.createElement("div", {
837
- role: "none",
838
- className: mx("relative !border-separator [&_.dx-grid]:max-is-[--dx-grid-content-inline-size] [&_.dx-grid]:max-bs-[--dx-grid-content-block-size]", role === "card--popover" && "popover-card-height", role === "section" && "attention-surface", role === "card--intrinsic" && "[&_.dx-grid]:bs-[--dx-grid-content-block-size]", [
839
- "card--popover",
840
- "section",
841
- "card--extrinsic"
842
- ].includes(role) && "overflow-hidden", [
843
- "article",
844
- "slide"
845
- ].includes(role) && "flex flex-col [&_.dx-grid]:grow [&_.dx-grid]:bs-0")
846
- }, children);
847
- };
848
844
  var emptyRowsAtom = Atom2.make([]);
849
845
  var emptyCellUpdateAtom = Atom2.make(0);
850
- var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId }, forwardedRef) => {
846
+ var TABLE_CONTENT_NAME = "Table.Content";
847
+ var TableContent = composable(({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
851
848
  const registry = useContext(RegistryContext);
852
849
  const [dxGrid, setDxGrid] = useState4(null);
853
850
  const { hasAttention } = useAttention(model?.id ?? "table");
@@ -1057,7 +1054,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1057
1054
  } catch (error) {
1058
1055
  log.catch(error, void 0, {
1059
1056
  F: __dxlog_file3,
1060
- L: 322,
1057
+ L: 279,
1061
1058
  S: void 0,
1062
1059
  C: (f, a) => f(...a)
1063
1060
  });
@@ -1135,7 +1132,8 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1135
1132
  model,
1136
1133
  dxGrid
1137
1134
  ]);
1138
- useImperativeHandle(forwardedRef, () => {
1135
+ const { controllerRef } = useTableContext(TABLE_CONTENT_NAME);
1136
+ controllerRef.current = useMemo4(() => {
1139
1137
  if (!dxGrid || !presentation) {
1140
1138
  return {};
1141
1139
  }
@@ -1158,10 +1156,15 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1158
1156
  if (!model || !modals) {
1159
1157
  return /* @__PURE__ */ React7.createElement("span", {
1160
1158
  role: "none",
1161
- className: "attention-surface"
1159
+ className: "dx-attention-surface"
1162
1160
  });
1163
1161
  }
1164
- return /* @__PURE__ */ React7.createElement(Grid.Root, {
1162
+ return /* @__PURE__ */ React7.createElement("div", {
1163
+ ...composableProps(props, {
1164
+ classNames: "dx-container relative"
1165
+ }),
1166
+ ref: forwardedRef
1167
+ }, /* @__PURE__ */ React7.createElement(Grid.Root, {
1165
1168
  id: model.id ?? "table-grid"
1166
1169
  }, /* @__PURE__ */ React7.createElement(TableValueEditor, {
1167
1170
  model,
@@ -1171,7 +1174,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1171
1174
  onSave: handleSave,
1172
1175
  onCreate
1173
1176
  }), /* @__PURE__ */ React7.createElement(Grid.Content, {
1174
- className: mx("[--dx-grid-base:var(--baseSurface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
1177
+ className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
1175
1178
  frozen,
1176
1179
  columns: columnMeta,
1177
1180
  columnDefault,
@@ -1197,94 +1200,15 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1197
1200
  model,
1198
1201
  modals,
1199
1202
  onNewColumn: handleNewColumn
1200
- }));
1201
- };
1202
- var TableMain = /* @__PURE__ */ forwardRef(TableMainInner);
1203
- var Table = {
1204
- Root: TableRoot,
1205
- Main: TableMain
1206
- };
1207
-
1208
- // src/components/Table/DynamicTable.tsx
1209
- import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
1210
- import React8, { useCallback as useCallback5, useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5, useRef as useRef3, useState as useState5 } from "react";
1211
- import { useDefaultValue } from "@dxos/react-ui";
1212
- import { mx as mx2 } from "@dxos/ui-theme";
1213
- var DynamicTable = ({ classNames, schema, name = "example.com/dynamic-table", rows, properties, jsonSchema: _jsonSchema, rowActions, onRowClick, onRowAction, ...props }) => {
1214
- const registry = useContext2(RegistryContext2);
1215
- const [dynamicTable, setDynamicTable] = useState5();
1216
- const { jsonSchema } = useMemo5(() => getBaseSchema({
1217
- typename: name,
1218
- properties,
1219
- jsonSchema: _jsonSchema,
1220
- schema
1221
- }), [
1222
- name,
1223
- properties,
1224
- _jsonSchema,
1225
- schema
1226
- ]);
1227
- useEffect4(() => {
1228
- setDynamicTable(makeDynamicTable({
1229
- registry,
1230
- jsonSchema,
1231
- properties
1232
- }));
1233
- }, [
1234
- registry,
1235
- jsonSchema,
1236
- properties
1237
- ]);
1238
- const tableRef = useRef3(null);
1239
- const handleCellUpdate = useCallback5((cell) => {
1240
- tableRef.current?.update?.(cell);
1241
- }, []);
1242
- const handleRowOrderChange = useCallback5(() => {
1243
- tableRef.current?.update?.();
1244
- }, []);
1245
- const features = useDefaultValue(props.features, () => ({
1246
- selection: {
1247
- enabled: false
1248
- },
1249
- dataEditable: false
1250
- }));
1251
- const model = useTableModel({
1252
- rows,
1253
- object: dynamicTable?.object,
1254
- projection: dynamicTable?.projection,
1255
- features,
1256
- rowActions,
1257
- onCellUpdate: handleCellUpdate,
1258
- onRowOrderChange: handleRowOrderChange,
1259
- onRowAction
1260
- });
1261
- const presentation = useMemo5(() => {
1262
- if (model) {
1263
- return new TablePresentation(registry, model);
1264
- }
1265
- }, [
1266
- registry,
1267
- model
1268
- ]);
1269
- return /* @__PURE__ */ React8.createElement("div", {
1270
- role: "none",
1271
- className: mx2("is-full bs-full grow grid", classNames)
1272
- }, /* @__PURE__ */ React8.createElement("div", {
1273
- role: "none",
1274
- className: "grid min-bs-0 overflow-hidden"
1275
- }, /* @__PURE__ */ React8.createElement(Table.Root, null, /* @__PURE__ */ React8.createElement(Table.Main, {
1276
- ref: tableRef,
1277
- model,
1278
- presentation,
1279
- ignoreAttention: true,
1280
- onRowClick
1281
- }))));
1282
- };
1203
+ })));
1204
+ });
1205
+ TableContent.displayName = TABLE_CONTENT_NAME;
1283
1206
 
1284
- // src/components/TableToolbar/TableToolbar.tsx
1285
- import { Atom as Atom3, RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
1286
- import React9, { useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6 } from "react";
1287
- import { MenuProvider, ToolbarMenu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
1207
+ // src/components/Table/TableToolbar.tsx
1208
+ import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
1209
+ import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
1210
+ import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
1211
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
1288
1212
  var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
1289
1213
  const nodes = [];
1290
1214
  if (onAdd) {
@@ -1292,7 +1216,7 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1292
1216
  type: "add-row",
1293
1217
  icon: "ph--plus--regular",
1294
1218
  label: [
1295
- "add row label",
1219
+ "add-row.label",
1296
1220
  {
1297
1221
  ns: translationKey
1298
1222
  }
@@ -1307,7 +1231,7 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1307
1231
  type: "save-view",
1308
1232
  icon: "ph--floppy-disk--regular",
1309
1233
  label: [
1310
- "save view label",
1234
+ "save-view.label",
1311
1235
  {
1312
1236
  ns: translationKey
1313
1237
  }
@@ -1322,7 +1246,8 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1322
1246
  nodes.push(...gap.nodes);
1323
1247
  const edges = nodes.map(({ id: target }) => ({
1324
1248
  source: "root",
1325
- target
1249
+ target,
1250
+ relation: "child"
1326
1251
  }));
1327
1252
  if (customActions) {
1328
1253
  const custom = get(customActions);
@@ -1334,12 +1259,12 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1334
1259
  edges
1335
1260
  };
1336
1261
  });
1337
- var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions }) => {
1338
- const registry = useContext3(RegistryContext3);
1339
- const stateAtom = useMemo6(() => Atom3.make({
1262
+ var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
1263
+ const registry = useContext2(RegistryContext2);
1264
+ const stateAtom = useMemo5(() => Atom3.make({
1340
1265
  viewDirty
1341
1266
  }), []);
1342
- useEffect5(() => {
1267
+ useEffect4(() => {
1343
1268
  registry.set(stateAtom, {
1344
1269
  viewDirty
1345
1270
  });
@@ -1348,7 +1273,7 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
1348
1273
  stateAtom,
1349
1274
  viewDirty
1350
1275
  ]);
1351
- const actionsCreator = useMemo6(() => createTableToolbarActions({
1276
+ const actionsCreator = useMemo5(() => createTableToolbarActions({
1352
1277
  stateAtom,
1353
1278
  onAdd,
1354
1279
  onSave,
@@ -1359,13 +1284,115 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
1359
1284
  onSave,
1360
1285
  customActions
1361
1286
  ]);
1362
- const menu = useMenuActions(actionsCreator);
1363
- return /* @__PURE__ */ React9.createElement(MenuProvider, {
1364
- ...menu,
1287
+ const menuActions = useMenuActions(actionsCreator);
1288
+ return /* @__PURE__ */ React8.createElement(Menu.Root, {
1289
+ ...menuActions,
1365
1290
  attendableId
1366
- }, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
1367
- classNames
1291
+ }, /* @__PURE__ */ React8.createElement(Menu.Toolbar, {
1292
+ ...composableProps2(props),
1293
+ ref: forwardedRef
1294
+ }));
1295
+ });
1296
+ TableToolbar.displayName = "TableToolbar";
1297
+
1298
+ // src/components/Table/Table.tsx
1299
+ var emptyColumnMeta2 = Atom4.make({
1300
+ grid: {}
1301
+ });
1302
+ var [TableContextProvider, useTableContext] = createContext("Table");
1303
+ var TABLE_ROOT_NAME = "Table.Root";
1304
+ var TableRoot = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
1305
+ const controllerRef = useRef3({});
1306
+ useImperativeHandle(forwardedRef, () => ({
1307
+ update: (cell) => controllerRef.current?.update?.(cell),
1308
+ handleInsertRowResult: (result) => controllerRef.current?.handleInsertRowResult?.(result)
1309
+ }), []);
1310
+ return /* @__PURE__ */ React9.createElement(TableContextProvider, {
1311
+ controllerRef
1312
+ }, children);
1313
+ });
1314
+ TableRoot.displayName = TABLE_ROOT_NAME;
1315
+ var Table = {
1316
+ Root: TableRoot,
1317
+ Toolbar: TableToolbar,
1318
+ Content: TableContent
1319
+ };
1320
+
1321
+ // src/components/Table/DynamicTable.tsx
1322
+ import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
1323
+ import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
1324
+ import { useDefaultValue } from "@dxos/react-ui";
1325
+ import { mx as mx2 } from "@dxos/ui-theme";
1326
+ var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
1327
+ const registry = useContext3(RegistryContext3);
1328
+ const [dynamicTable, setDynamicTable] = useState5();
1329
+ const { jsonSchema } = useMemo6(() => getBaseSchema({
1330
+ typename: name,
1331
+ properties,
1332
+ jsonSchema: jsonSchemaProp,
1333
+ schema
1334
+ }), [
1335
+ name,
1336
+ properties,
1337
+ jsonSchemaProp,
1338
+ schema
1339
+ ]);
1340
+ useEffect5(() => {
1341
+ setDynamicTable(makeDynamicTable({
1342
+ registry,
1343
+ jsonSchema,
1344
+ properties
1345
+ }));
1346
+ }, [
1347
+ registry,
1348
+ jsonSchema,
1349
+ properties
1350
+ ]);
1351
+ const tableRef = useRef4(null);
1352
+ const handleCellUpdate = useCallback5((cell) => {
1353
+ tableRef.current?.update?.(cell);
1354
+ }, []);
1355
+ const handleRowOrderChange = useCallback5(() => {
1356
+ tableRef.current?.update?.();
1357
+ }, []);
1358
+ const features = useDefaultValue(props.features, () => ({
1359
+ selection: {
1360
+ enabled: false
1361
+ },
1362
+ dataEditable: false
1368
1363
  }));
1364
+ const model = useTableModel({
1365
+ rows,
1366
+ object: dynamicTable?.object,
1367
+ projection: dynamicTable?.projection,
1368
+ features,
1369
+ rowActions,
1370
+ onCellUpdate: handleCellUpdate,
1371
+ onRowOrderChange: handleRowOrderChange,
1372
+ onRowAction
1373
+ });
1374
+ const presentation = useMemo6(() => {
1375
+ if (model) {
1376
+ return new TablePresentation(registry, model);
1377
+ }
1378
+ }, [
1379
+ registry,
1380
+ model
1381
+ ]);
1382
+ return /* @__PURE__ */ React10.createElement("div", {
1383
+ role: "none",
1384
+ className: mx2("dx-expander grid", classNames)
1385
+ }, /* @__PURE__ */ React10.createElement("div", {
1386
+ role: "none",
1387
+ className: "grid min-h-0 overflow-hidden"
1388
+ }, /* @__PURE__ */ React10.createElement(Table.Root, {
1389
+ ref: tableRef
1390
+ }, /* @__PURE__ */ React10.createElement(Table.Content, {
1391
+ model,
1392
+ presentation,
1393
+ ignoreAttention: true,
1394
+ onRowClick
1395
+ }))));
1369
1396
  };
1370
1397
  export {
1371
1398
  BUTTON_IDENTIFIERS,
@@ -1377,7 +1404,6 @@ export {
1377
1404
  Table,
1378
1405
  TableModel,
1379
1406
  TablePresentation,
1380
- TableToolbar,
1381
1407
  cellClassesForRowSelection,
1382
1408
  compareValues,
1383
1409
  createDirectChangeCallback,
@@ -1393,6 +1419,7 @@ export {
1393
1419
  translations,
1394
1420
  useAddRow,
1395
1421
  useProjectionModel,
1422
+ useTableContext,
1396
1423
  useTableModel
1397
1424
  };
1398
1425
  //# sourceMappingURL=index.mjs.map