@dxos/react-ui-table 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe

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-MNZKOFMA.mjs → chunk-F7Y374KL.mjs} +41 -36
  4. package/dist/lib/browser/chunk-F7Y374KL.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +205 -179
  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 +6 -6
  9. package/dist/lib/browser/testing/index.mjs.map +3 -3
  10. package/dist/lib/browser/types/index.mjs +1 -1
  11. package/dist/lib/node-esm/{chunk-2ATAIIAO.mjs → chunk-CCJ4LOVM.mjs} +41 -36
  12. package/dist/lib/node-esm/chunk-CCJ4LOVM.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 +205 -179
  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 +6 -6
  19. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  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 +81 -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 +20 -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 +83 -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 +17 -0
  33. package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
  34. package/dist/types/src/components/Table/TableToolbar.d.ts +21 -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 +17 -17
  70. package/src/components/Table/DynamicTable.tsx +13 -20
  71. package/src/components/Table/Relations.stories.tsx +38 -30
  72. package/src/components/Table/Table.stories.tsx +69 -49
  73. package/src/components/Table/Table.tsx +41 -435
  74. package/src/components/Table/TableContent.tsx +421 -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 +11 -11
  79. package/src/components/TableCellEditor/TableCellEditor.tsx +12 -10
  80. package/src/components/index.ts +0 -1
  81. package/src/components/testing.ts +10 -10
  82. package/src/hooks/useAddRow.ts +1 -1
  83. package/src/hooks/useProjectionModel.ts +7 -8
  84. package/src/hooks/useTableModel.ts +1 -1
  85. package/src/model/table-model.test.ts +5 -6
  86. package/src/model/table-model.ts +15 -14
  87. package/src/model/table-presentation.test.ts +5 -6
  88. package/src/model/table-presentation.ts +12 -12
  89. package/src/playwright/TableManager.ts +10 -3
  90. package/src/playwright/playwright.config.ts +1 -1
  91. package/src/playwright/smoke.spec.ts +48 -5
  92. package/src/testing/useTestTableModel.ts +6 -6
  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-MNZKOFMA.mjs.map +0 -7
  101. package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +0 -7
  102. package/dist/lib/node-esm/chunk-2ATAIIAO.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-MNZKOFMA.mjs";
19
+ } from "./chunk-F7Y374KL.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, (table2) => {
126
+ table2.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, (view2) => {
143
+ view2.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,11 +460,6 @@ 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 = {
455
- scroll: {
456
- className: "!plb-[--dx-grid-cell-editor-padding-block]"
457
- }
458
- };
459
463
  var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
460
464
  const { editing } = useGridContext3("TableValueEditor", __gridScope);
461
465
  const fieldProjection = useMemo2(() => {
@@ -467,7 +471,7 @@ var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, o
467
471
  const fieldProjection2 = model.projection.getFieldProjection(field.id);
468
472
  invariant2(fieldProjection2, void 0, {
469
473
  F: __dxlog_file2,
470
- L: 73,
474
+ L: 66,
471
475
  S: void 0,
472
476
  A: [
473
477
  "fieldProjection",
@@ -512,7 +516,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
512
516
  const fieldProjection2 = model.projection.getFieldProjection(field.id);
513
517
  invariant2(fieldProjection2, void 0, {
514
518
  F: __dxlog_file2,
515
- L: 120,
519
+ L: 113,
516
520
  S: void 0,
517
521
  A: [
518
522
  "fieldProjection",
@@ -652,9 +656,13 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
652
656
  __gridScope
653
657
  }), /* @__PURE__ */ React3.createElement(GridCellEditor, {
654
658
  extensions,
659
+ slots: {
660
+ content: {
661
+ className: "!py-(--dx-grid-cell-editor-padding-block)"
662
+ }
663
+ },
655
664
  getCellContent,
656
- onBlur: handleBlur,
657
- slots: editorSlots
665
+ onBlur: handleBlur
658
666
  }));
659
667
  };
660
668
  var determineNavigationAxis = ({ key }) => {
@@ -703,19 +711,19 @@ var ColumnActionsMenu = ({ model, modals }) => {
703
711
  }), /* @__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
712
  "data-testid": "column-sort-descending",
705
713
  onClick: () => model.setSort(state.fieldId, "desc")
706
- }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
714
+ }, t("column-action-sort-descending.menu")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
707
715
  "data-testid": "column-sort-ascending",
708
716
  onClick: () => model.setSort(state.fieldId, "asc")
709
- }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
717
+ }, t("column-action-sort-ascending.menu")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
710
718
  "data-testid": "column-clear-sort",
711
719
  onClick: () => model.clearSort()
712
- }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
720
+ }, t("column-action-clear-sorting.menu")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
713
721
  "data-testid": "column-delete",
714
722
  onClick: () => model.deleteColumn(state.fieldId)
715
- }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
723
+ }, t("column-action-delete.menu")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
716
724
  "data-testid": "column-settings",
717
725
  onClick: () => modals.openColumnSettings()
718
- }, t("column action settings"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
726
+ }, t("column-action-settings.menu"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
719
727
  };
720
728
 
721
729
  // src/components/Table/ColumnSettings.tsx
@@ -775,7 +783,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
775
783
  }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
776
784
  virtualRef: modals.trigger
777
785
  }), /* @__PURE__ */ React5.createElement(Popover2.Portal, null, /* @__PURE__ */ React5.createElement(Popover2.Content, {
778
- classNames: "md:is-64"
786
+ classNames: "md:w-64"
779
787
  }, /* @__PURE__ */ React5.createElement(Popover2.Viewport, null, /* @__PURE__ */ React5.createElement(FieldEditor, {
780
788
  projection: model.projection,
781
789
  field,
@@ -815,8 +823,8 @@ var RowActionsMenu = ({ model, modals }) => {
815
823
  }, t(hasSelection ? "bulk delete row label" : "delete row label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
816
824
  };
817
825
 
818
- // src/components/Table/Table.tsx
819
- var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
826
+ // src/components/Table/TableContent.tsx
827
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/TableContent.tsx";
820
828
  var columnDefault = {
821
829
  grid: {
822
830
  minSize: 80,
@@ -832,22 +840,10 @@ var rowDefault = {
832
840
  var emptyColumnMeta = Atom2.make({
833
841
  grid: {}
834
842
  });
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
843
  var emptyRowsAtom = Atom2.make([]);
849
844
  var emptyCellUpdateAtom = Atom2.make(0);
850
- var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId }, forwardedRef) => {
845
+ var TABLE_CONTENT_NAME = "Table.Content";
846
+ var TableContent = composable(({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
851
847
  const registry = useContext(RegistryContext);
852
848
  const [dxGrid, setDxGrid] = useState4(null);
853
849
  const { hasAttention } = useAttention(model?.id ?? "table");
@@ -1057,7 +1053,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1057
1053
  } catch (error) {
1058
1054
  log.catch(error, void 0, {
1059
1055
  F: __dxlog_file3,
1060
- L: 322,
1056
+ L: 278,
1061
1057
  S: void 0,
1062
1058
  C: (f, a) => f(...a)
1063
1059
  });
@@ -1135,7 +1131,8 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1135
1131
  model,
1136
1132
  dxGrid
1137
1133
  ]);
1138
- useImperativeHandle(forwardedRef, () => {
1134
+ const { controllerRef } = useTableContext(TABLE_CONTENT_NAME);
1135
+ controllerRef.current = useMemo4(() => {
1139
1136
  if (!dxGrid || !presentation) {
1140
1137
  return {};
1141
1138
  }
@@ -1158,10 +1155,15 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1158
1155
  if (!model || !modals) {
1159
1156
  return /* @__PURE__ */ React7.createElement("span", {
1160
1157
  role: "none",
1161
- className: "attention-surface"
1158
+ className: "dx-attention-surface"
1162
1159
  });
1163
1160
  }
1164
- return /* @__PURE__ */ React7.createElement(Grid.Root, {
1161
+ return /* @__PURE__ */ React7.createElement("div", {
1162
+ ...composableProps(props, {
1163
+ classNames: "dx-container relative"
1164
+ }),
1165
+ ref: forwardedRef
1166
+ }, /* @__PURE__ */ React7.createElement(Grid.Root, {
1165
1167
  id: model.id ?? "table-grid"
1166
1168
  }, /* @__PURE__ */ React7.createElement(TableValueEditor, {
1167
1169
  model,
@@ -1171,7 +1173,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1171
1173
  onSave: handleSave,
1172
1174
  onCreate
1173
1175
  }), /* @__PURE__ */ React7.createElement(Grid.Content, {
1174
- className: mx("[--dx-grid-base:var(--baseSurface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
1176
+ className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
1175
1177
  frozen,
1176
1178
  columns: columnMeta,
1177
1179
  columnDefault,
@@ -1197,94 +1199,15 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1197
1199
  model,
1198
1200
  modals,
1199
1201
  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
- };
1202
+ })));
1203
+ });
1204
+ TableContent.displayName = TABLE_CONTENT_NAME;
1283
1205
 
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";
1206
+ // src/components/Table/TableToolbar.tsx
1207
+ import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
1208
+ import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
1209
+ import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
1210
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
1288
1211
  var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
1289
1212
  const nodes = [];
1290
1213
  if (onAdd) {
@@ -1292,7 +1215,7 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1292
1215
  type: "add-row",
1293
1216
  icon: "ph--plus--regular",
1294
1217
  label: [
1295
- "add row label",
1218
+ "add-row.label",
1296
1219
  {
1297
1220
  ns: translationKey
1298
1221
  }
@@ -1307,7 +1230,7 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1307
1230
  type: "save-view",
1308
1231
  icon: "ph--floppy-disk--regular",
1309
1232
  label: [
1310
- "save view label",
1233
+ "save-view.label",
1311
1234
  {
1312
1235
  ns: translationKey
1313
1236
  }
@@ -1322,7 +1245,8 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1322
1245
  nodes.push(...gap.nodes);
1323
1246
  const edges = nodes.map(({ id: target }) => ({
1324
1247
  source: "root",
1325
- target
1248
+ target,
1249
+ relation: "child"
1326
1250
  }));
1327
1251
  if (customActions) {
1328
1252
  const custom = get(customActions);
@@ -1334,12 +1258,12 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1334
1258
  edges
1335
1259
  };
1336
1260
  });
1337
- var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions }) => {
1338
- const registry = useContext3(RegistryContext3);
1339
- const stateAtom = useMemo6(() => Atom3.make({
1261
+ var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
1262
+ const registry = useContext2(RegistryContext2);
1263
+ const stateAtom = useMemo5(() => Atom3.make({
1340
1264
  viewDirty
1341
1265
  }), []);
1342
- useEffect5(() => {
1266
+ useEffect4(() => {
1343
1267
  registry.set(stateAtom, {
1344
1268
  viewDirty
1345
1269
  });
@@ -1348,7 +1272,7 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
1348
1272
  stateAtom,
1349
1273
  viewDirty
1350
1274
  ]);
1351
- const actionsCreator = useMemo6(() => createTableToolbarActions({
1275
+ const actionsCreator = useMemo5(() => createTableToolbarActions({
1352
1276
  stateAtom,
1353
1277
  onAdd,
1354
1278
  onSave,
@@ -1359,13 +1283,115 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
1359
1283
  onSave,
1360
1284
  customActions
1361
1285
  ]);
1362
- const menu = useMenuActions(actionsCreator);
1363
- return /* @__PURE__ */ React9.createElement(MenuProvider, {
1364
- ...menu,
1286
+ const menuActions = useMenuActions(actionsCreator);
1287
+ return /* @__PURE__ */ React8.createElement(Menu.Root, {
1288
+ ...menuActions,
1365
1289
  attendableId
1366
- }, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
1367
- classNames
1290
+ }, /* @__PURE__ */ React8.createElement(Menu.Toolbar, {
1291
+ ...composableProps2(props),
1292
+ ref: forwardedRef
1293
+ }));
1294
+ });
1295
+ TableToolbar.displayName = "TableToolbar";
1296
+
1297
+ // src/components/Table/Table.tsx
1298
+ var emptyColumnMeta2 = Atom4.make({
1299
+ grid: {}
1300
+ });
1301
+ var [TableContextProvider, useTableContext] = createContext("Table");
1302
+ var TABLE_ROOT_NAME = "Table.Root";
1303
+ var TableRoot = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
1304
+ const controllerRef = useRef3({});
1305
+ useImperativeHandle(forwardedRef, () => ({
1306
+ update: (cell) => controllerRef.current?.update?.(cell),
1307
+ handleInsertRowResult: (result) => controllerRef.current?.handleInsertRowResult?.(result)
1308
+ }), []);
1309
+ return /* @__PURE__ */ React9.createElement(TableContextProvider, {
1310
+ controllerRef
1311
+ }, children);
1312
+ });
1313
+ TableRoot.displayName = TABLE_ROOT_NAME;
1314
+ var Table = {
1315
+ Root: TableRoot,
1316
+ Toolbar: TableToolbar,
1317
+ Content: TableContent
1318
+ };
1319
+
1320
+ // src/components/Table/DynamicTable.tsx
1321
+ import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
1322
+ import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
1323
+ import { useDefaultValue } from "@dxos/react-ui";
1324
+ import { mx as mx2 } from "@dxos/ui-theme";
1325
+ var DynamicTable = ({ classNames, schema, name = "com.example.dynamic-table", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
1326
+ const registry = useContext3(RegistryContext3);
1327
+ const [dynamicTable, setDynamicTable] = useState5();
1328
+ const { jsonSchema } = useMemo6(() => getBaseSchema({
1329
+ typename: name,
1330
+ properties,
1331
+ jsonSchema: jsonSchemaProp,
1332
+ schema
1333
+ }), [
1334
+ name,
1335
+ properties,
1336
+ jsonSchemaProp,
1337
+ schema
1338
+ ]);
1339
+ useEffect5(() => {
1340
+ setDynamicTable(makeDynamicTable({
1341
+ registry,
1342
+ jsonSchema,
1343
+ properties
1344
+ }));
1345
+ }, [
1346
+ registry,
1347
+ jsonSchema,
1348
+ properties
1349
+ ]);
1350
+ const tableRef = useRef4(null);
1351
+ const handleCellUpdate = useCallback5((cell) => {
1352
+ tableRef.current?.update?.(cell);
1353
+ }, []);
1354
+ const handleRowOrderChange = useCallback5(() => {
1355
+ tableRef.current?.update?.();
1356
+ }, []);
1357
+ const features = useDefaultValue(props.features, () => ({
1358
+ selection: {
1359
+ enabled: false
1360
+ },
1361
+ dataEditable: false
1368
1362
  }));
1363
+ const model = useTableModel({
1364
+ rows,
1365
+ object: dynamicTable?.object,
1366
+ projection: dynamicTable?.projection,
1367
+ features,
1368
+ rowActions,
1369
+ onCellUpdate: handleCellUpdate,
1370
+ onRowOrderChange: handleRowOrderChange,
1371
+ onRowAction
1372
+ });
1373
+ const presentation = useMemo6(() => {
1374
+ if (model) {
1375
+ return new TablePresentation(registry, model);
1376
+ }
1377
+ }, [
1378
+ registry,
1379
+ model
1380
+ ]);
1381
+ return /* @__PURE__ */ React10.createElement("div", {
1382
+ role: "none",
1383
+ className: mx2("dx-expander grid", classNames)
1384
+ }, /* @__PURE__ */ React10.createElement("div", {
1385
+ role: "none",
1386
+ className: "grid min-h-0 overflow-hidden"
1387
+ }, /* @__PURE__ */ React10.createElement(Table.Root, {
1388
+ ref: tableRef
1389
+ }, /* @__PURE__ */ React10.createElement(Table.Content, {
1390
+ model,
1391
+ presentation,
1392
+ ignoreAttention: true,
1393
+ onRowClick
1394
+ }))));
1369
1395
  };
1370
1396
  export {
1371
1397
  BUTTON_IDENTIFIERS,
@@ -1377,7 +1403,6 @@ export {
1377
1403
  Table,
1378
1404
  TableModel,
1379
1405
  TablePresentation,
1380
- TableToolbar,
1381
1406
  cellClassesForRowSelection,
1382
1407
  compareValues,
1383
1408
  createDirectChangeCallback,
@@ -1393,6 +1418,7 @@ export {
1393
1418
  translations,
1394
1419
  useAddRow,
1395
1420
  useProjectionModel,
1421
+ useTableContext,
1396
1422
  useTableModel
1397
1423
  };
1398
1424
  //# sourceMappingURL=index.mjs.map