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