@dxos/react-ui-table 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef

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 (137) hide show
  1. package/dist/lib/browser/{chunk-OZBLY7XM.mjs → chunk-FBURZBPH.mjs} +17 -23
  2. package/dist/lib/browser/chunk-FBURZBPH.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  4. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-I5IFW7UF.mjs → chunk-YGC7LZJN.mjs} +39 -90
  6. package/dist/lib/browser/chunk-YGC7LZJN.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +198 -235
  8. package/dist/lib/browser/index.mjs.map +4 -4
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/testing/index.mjs +7 -6
  11. package/dist/lib/browser/testing/index.mjs.map +3 -3
  12. package/dist/lib/browser/translations.mjs +36 -0
  13. package/dist/lib/browser/translations.mjs.map +7 -0
  14. package/dist/lib/browser/types/index.mjs +2 -1
  15. package/dist/lib/node-esm/{chunk-WNZSKIRF.mjs → chunk-DKKMSVKP.mjs} +17 -23
  16. package/dist/lib/node-esm/chunk-DKKMSVKP.mjs.map +7 -0
  17. package/dist/lib/node-esm/{chunk-DDJKYJFY.mjs → chunk-GKIWDEZ7.mjs} +39 -90
  18. package/dist/lib/node-esm/chunk-GKIWDEZ7.mjs.map +7 -0
  19. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  20. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  21. package/dist/lib/node-esm/index.mjs +198 -235
  22. package/dist/lib/node-esm/index.mjs.map +4 -4
  23. package/dist/lib/node-esm/meta.json +1 -1
  24. package/dist/lib/node-esm/testing/index.mjs +7 -6
  25. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  26. package/dist/lib/node-esm/translations.mjs +37 -0
  27. package/dist/lib/node-esm/translations.mjs.map +7 -0
  28. package/dist/lib/node-esm/types/index.mjs +2 -1
  29. package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
  30. package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
  31. package/dist/types/src/components/Table/DynamicTable.d.ts +5 -4
  32. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  33. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +20 -22
  34. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  35. package/dist/types/src/components/Table/Relations.stories.d.ts +82 -82
  36. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  37. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  38. package/dist/types/src/components/Table/Table.d.ts +20 -21
  39. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  40. package/dist/types/src/components/Table/Table.stories.d.ts +84 -84
  41. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  42. package/dist/types/src/components/Table/TableContent.d.ts +17 -0
  43. package/dist/types/src/components/Table/TableContent.d.ts.map +1 -0
  44. package/dist/types/src/components/Table/TableToolbar.d.ts +21 -0
  45. package/dist/types/src/components/Table/TableToolbar.d.ts.map +1 -0
  46. package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
  47. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +3 -3
  48. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  49. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +2 -2
  50. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  51. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +22 -24
  52. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  53. package/dist/types/src/components/index.d.ts +0 -1
  54. package/dist/types/src/components/index.d.ts.map +1 -1
  55. package/dist/types/src/components/testing.d.ts.map +1 -1
  56. package/dist/types/src/hooks/useAddRow.d.ts +1 -1
  57. package/dist/types/src/hooks/useAddRow.d.ts.map +1 -1
  58. package/dist/types/src/hooks/useProjectionModel.d.ts +1 -1
  59. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
  60. package/dist/types/src/hooks/useTableModel.d.ts +1 -1
  61. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  62. package/dist/types/src/index.d.ts +0 -2
  63. package/dist/types/src/index.d.ts.map +1 -1
  64. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  65. package/dist/types/src/model/selection-model.d.ts +1 -1
  66. package/dist/types/src/model/selection-model.d.ts.map +1 -1
  67. package/dist/types/src/model/table-model.d.ts +7 -6
  68. package/dist/types/src/model/table-model.d.ts.map +1 -1
  69. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  70. package/dist/types/src/playwright/TableManager.d.ts +2 -1
  71. package/dist/types/src/playwright/TableManager.d.ts.map +1 -1
  72. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
  73. package/dist/types/src/testing/useTestTableModel.d.ts +2 -2
  74. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  75. package/dist/types/src/translations.d.ts +19 -21
  76. package/dist/types/src/translations.d.ts.map +1 -1
  77. package/dist/types/src/types/Table.d.ts +1 -6
  78. package/dist/types/src/types/Table.d.ts.map +1 -1
  79. package/dist/types/src/util/dynamic-table.d.ts +6 -5
  80. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  81. package/dist/types/src/util/dynamic-table.test.d.ts +2 -0
  82. package/dist/types/src/util/dynamic-table.test.d.ts.map +1 -0
  83. package/dist/types/src/util/query-ast.d.ts.map +1 -1
  84. package/dist/types/src/util/schema.d.ts.map +1 -1
  85. package/dist/types/src/util/signals.d.ts.map +1 -1
  86. package/dist/types/src/util/sort.d.ts.map +1 -1
  87. package/dist/types/src/util/table-buttons.d.ts +20 -20
  88. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  89. package/dist/types/src/util/table-controls.d.ts +4 -4
  90. package/dist/types/src/util/table-controls.d.ts.map +1 -1
  91. package/dist/types/src/util/tag.d.ts.map +1 -1
  92. package/dist/types/tsconfig.tsbuildinfo +1 -1
  93. package/package.json +59 -62
  94. package/src/components/Table/ColumnActionsMenu.tsx +7 -6
  95. package/src/components/Table/ColumnSettings.tsx +3 -4
  96. package/src/components/Table/DynamicTable.stories.tsx +19 -18
  97. package/src/components/Table/DynamicTable.tsx +13 -20
  98. package/src/components/Table/Relations.stories.tsx +78 -34
  99. package/src/components/Table/RowActionsMenu.tsx +3 -2
  100. package/src/components/Table/Table.stories.tsx +72 -52
  101. package/src/components/Table/Table.tsx +41 -435
  102. package/src/components/Table/TableContent.tsx +421 -0
  103. package/src/components/{TableToolbar → Table}/TableToolbar.tsx +36 -43
  104. package/src/components/TableCellEditor/CellValidationMessage.tsx +4 -4
  105. package/src/components/TableCellEditor/FormCellEditor.tsx +14 -7
  106. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +13 -12
  107. package/src/components/TableCellEditor/TableCellEditor.tsx +12 -10
  108. package/src/components/index.ts +0 -1
  109. package/src/components/testing.ts +10 -10
  110. package/src/hooks/useAddRow.ts +1 -1
  111. package/src/hooks/useProjectionModel.ts +3 -3
  112. package/src/hooks/useTableModel.ts +1 -1
  113. package/src/index.ts +0 -4
  114. package/src/model/table-model.test.ts +5 -6
  115. package/src/model/table-model.ts +18 -17
  116. package/src/model/table-presentation.test.ts +13 -7
  117. package/src/model/table-presentation.ts +12 -12
  118. package/src/playwright/TableManager.ts +10 -3
  119. package/src/playwright/playwright.config.ts +1 -1
  120. package/src/playwright/smoke.spec.ts +48 -5
  121. package/src/testing/useTestTableModel.ts +6 -6
  122. package/src/translations.ts +19 -21
  123. package/src/types/Table.ts +12 -23
  124. package/src/util/dynamic-table.test.ts +77 -0
  125. package/src/util/dynamic-table.ts +17 -16
  126. package/src/util/query-ast.ts +3 -0
  127. package/src/util/table-buttons.ts +1 -1
  128. package/src/util/table-controls.ts +2 -2
  129. package/dist/lib/browser/chunk-I5IFW7UF.mjs.map +0 -7
  130. package/dist/lib/browser/chunk-OZBLY7XM.mjs.map +0 -7
  131. package/dist/lib/node-esm/chunk-DDJKYJFY.mjs.map +0 -7
  132. package/dist/lib/node-esm/chunk-WNZSKIRF.mjs.map +0 -7
  133. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +0 -21
  134. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +0 -1
  135. package/dist/types/src/components/TableToolbar/index.d.ts +0 -2
  136. package/dist/types/src/components/TableToolbar/index.d.ts.map +0 -1
  137. package/src/components/TableToolbar/index.ts +0 -5
@@ -17,67 +17,41 @@ import {
17
17
  useAddRow,
18
18
  useProjectionModel,
19
19
  useTableModel
20
- } from "./chunk-DDJKYJFY.mjs";
20
+ } from "./chunk-GKIWDEZ7.mjs";
21
21
  import {
22
22
  Table_exports
23
- } from "./chunk-WNZSKIRF.mjs";
24
-
25
- // src/translations.ts
26
- var translationKey = "@dxos/react-ui-table";
27
- var translations = [
28
- {
29
- "en-US": {
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"
52
- }
53
- }
54
- }
55
- ];
23
+ } from "./chunk-DKKMSVKP.mjs";
24
+ import "./chunk-HSLMI22Q.mjs";
56
25
 
57
26
  // src/components/Table/Table.tsx
27
+ import { Atom as Atom4 } from "@effect-atom/atom-react";
28
+ import { createContext } from "@radix-ui/react-context";
29
+ import React9, { forwardRef, useImperativeHandle, useRef as useRef3 } from "react";
30
+
31
+ // src/components/Table/TableContent.tsx
58
32
  import { Atom as Atom2, RegistryContext, useAtomValue as useAtomValue4 } from "@effect-atom/atom-react";
59
33
  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";
34
+ import React7, { useCallback as useCallback4, useContext, useEffect as useEffect3, useMemo as useMemo4, useState as useState4 } from "react";
61
35
  import { log } from "@dxos/log";
62
36
  import { useAttention } from "@dxos/react-ui-attention";
63
37
  import { Grid, closestCell, gridSeparatorBlockEnd, gridSeparatorInlineEnd } from "@dxos/react-ui-grid";
64
38
  import { DxEditRequest } from "@dxos/react-ui-grid";
65
- import { mx } from "@dxos/ui-theme";
39
+ import { composable, composableProps, mx } from "@dxos/ui-theme";
66
40
 
67
41
  // 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";
42
+ import { Filter, JsonSchema, Obj, Order, Query, Ref, Type } from "@dxos/echo";
43
+ import { ProjectionModel, ViewModel, createEchoChangeCallback as createEchoChangeCallback2, getSchemaFromPropertyDefinitions } from "@dxos/schema";
70
44
  var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
71
45
  if (typename && properties) {
72
46
  const schema2 = getSchemaFromPropertyDefinitions(typename, properties);
73
47
  return {
74
48
  typename: schema2.typename,
75
- jsonSchema: schema2.jsonSchema
49
+ jsonSchema: JsonSchema.toJsonSchema(schema2)
76
50
  };
77
51
  } else if (schema) {
78
52
  return {
79
53
  typename: Type.getTypename(schema),
80
- jsonSchema: Type.toJsonSchema(schema)
54
+ jsonSchema: JsonSchema.toJsonSchema(schema)
81
55
  };
82
56
  } else if (typename && jsonSchema) {
83
57
  return {
@@ -89,7 +63,7 @@ var getBaseSchema = ({ schema, typename, properties, jsonSchema }) => {
89
63
  }
90
64
  };
91
65
  var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
92
- const view = View.make({
66
+ const view = ViewModel.make({
93
67
  query: Query.select(Filter.everything()),
94
68
  jsonSchema,
95
69
  ...properties && {
@@ -104,7 +78,7 @@ var makeDynamicTable = ({ registry, jsonSchema, properties }) => {
104
78
  registry,
105
79
  view,
106
80
  baseSchema: jsonSchema,
107
- change: createDirectChangeCallback2(view.projection, jsonSchema)
81
+ change: createEchoChangeCallback2(view, jsonSchema)
108
82
  });
109
83
  projection.normalizeView();
110
84
  if (properties && projection.getFields()) {
@@ -120,8 +94,8 @@ var setProperties = (view, projection, table, properties) => {
120
94
  const field = projection.getFields().find((field2) => field2.path === property.name);
121
95
  if (field) {
122
96
  if (property.size !== void 0) {
123
- Obj.change(table, (t) => {
124
- t.sizes[field.path] = property.size;
97
+ Obj.update(table, (table2) => {
98
+ table2.sizes[field.path] = property.size;
125
99
  });
126
100
  }
127
101
  if (property.title !== void 0) {
@@ -137,8 +111,8 @@ var setProperties = (view, projection, table, properties) => {
137
111
  if (property.sort) {
138
112
  const currentQuery = Query.fromAst(Obj.getSnapshot(view).query.ast);
139
113
  const newQuery = currentQuery.orderBy(Order.property(field.path, property.sort));
140
- Obj.change(view, (v) => {
141
- v.query.ast = newQuery.ast;
114
+ Obj.update(view, (view2) => {
115
+ view2.query.ast = newQuery.ast;
142
116
  });
143
117
  }
144
118
  }
@@ -254,14 +228,14 @@ var CellValidationMessage = ({ __gridScope, validationError, variant = "error" }
254
228
  if (!editing || !validationError) {
255
229
  return null;
256
230
  }
257
- const bgClass = variant === "error" ? "bg-errorSurface" : "bg-warningSurface";
258
- const textClass = variant === "error" ? "text-errorSurfaceText" : "text-warningSurfaceText";
231
+ const bgClass = variant === "error" ? "bg-error-surface" : "bg-warning-surface";
232
+ const textClass = variant === "error" ? "text-error-surface-text" : "text-warning-surface-text";
259
233
  return /* @__PURE__ */ React.createElement("div", {
260
234
  role: "none",
261
- className: `absolute ${bgClass} ${textClass} rounded-bs-sm text-xs p-1`,
235
+ className: `absolute ${bgClass} ${textClass} rounded-h-sm text-xs p-1`,
262
236
  style: {
263
237
  ...{
264
- "--dx-gridCellWidth": `${box?.inlineSize ?? 200}px`
238
+ "--dx-grid-cell-width": `${box?.inlineSize ?? 200}px`
265
239
  },
266
240
  zIndex: 10,
267
241
  insetBlockEnd: `calc(100% - ${box.insetBlockStart}px)`,
@@ -280,9 +254,10 @@ import { Popover } from "@dxos/react-ui";
280
254
  import { Form } from "@dxos/react-ui-form";
281
255
  import { parseCellIndex, useGridContext as useGridContext2 } from "@dxos/react-ui-grid";
282
256
  import { getDeep, isTruthy, setDeep } from "@dxos/util";
257
+ import { translationKey } from "#translations";
283
258
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/FormCellEditor.tsx";
284
259
  var createOptionLabel = [
285
- "create new object label",
260
+ "create-new-object.label",
286
261
  {
287
262
  ns: translationKey
288
263
  }
@@ -318,27 +293,11 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
318
293
  const cell = parseCellIndex(contextEditing.index);
319
294
  if (model.isDraftCell(cell)) {
320
295
  const draftRow = model.getDraftRows()[cell.row];
321
- invariant(draftRow, void 0, {
322
- F: __dxlog_file,
323
- L: 74,
324
- S: void 0,
325
- A: [
326
- "draftRow",
327
- ""
328
- ]
329
- });
296
+ invariant(draftRow, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 52, S: void 0, A: ["draftRow", ""] });
330
297
  return draftRow.data;
331
298
  } else {
332
299
  const row = model.getRowAt(cell.row);
333
- invariant(row, void 0, {
334
- F: __dxlog_file,
335
- L: 78,
336
- S: void 0,
337
- A: [
338
- "row",
339
- ""
340
- ]
341
- });
300
+ invariant(row, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 56, S: void 0, A: ["row", ""] });
342
301
  return row;
343
302
  }
344
303
  }
@@ -347,9 +306,13 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
347
306
  model,
348
307
  contextEditing
349
308
  ]);
350
- const formValues = useMemo(() => originalRow ? JSON.parse(JSON.stringify(originalRow)) : {}, [
309
+ const initialFormValues = useMemo(() => originalRow ? JSON.parse(JSON.stringify(originalRow)) : {}, [
351
310
  originalRow
352
311
  ]);
312
+ const [formValues, setFormValues] = useState(initialFormValues);
313
+ const handleValuesChanged = useCallback((values) => {
314
+ setFormValues(values);
315
+ }, []);
353
316
  const handleOpenChange = useCallback((nextOpen) => {
354
317
  if (nextOpen === false) {
355
318
  setEditing(null);
@@ -434,12 +397,14 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
434
397
  virtualRef: anchorRef
435
398
  }), /* @__PURE__ */ React2.createElement(Popover.Portal, null, /* @__PURE__ */ React2.createElement(Popover.Content, {
436
399
  tabIndex: -1,
437
- classNames: "popover-card-width density-fine"
400
+ classNames: "dx-card-popover-width dx-density-fine"
438
401
  }, /* @__PURE__ */ React2.createElement(Popover.Arrow, null), /* @__PURE__ */ React2.createElement(Popover.Viewport, null, /* @__PURE__ */ React2.createElement(Form.Root, {
439
402
  ...formProps,
440
403
  autoFocus: true,
441
404
  schema: narrowedSchema,
442
405
  values: formValues,
406
+ onValuesChanged: handleValuesChanged,
407
+ projection: model?.projection,
443
408
  createInitialValuePath: fieldProjection.field.referencePath,
444
409
  createOptionIcon: "ph--plus--regular",
445
410
  createOptionLabel,
@@ -452,11 +417,6 @@ var FormCellEditor = ({ __gridScope, schema, model, fieldProjection, onSave, onC
452
417
 
453
418
  // src/components/TableCellEditor/TableCellEditor.tsx
454
419
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/TableCellEditor/TableCellEditor.tsx";
455
- var editorSlots = {
456
- scroll: {
457
- className: "!plb-[--dx-grid-cell-editor-padding-block]"
458
- }
459
- };
460
420
  var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, onCreate }) => {
461
421
  const { editing } = useGridContext3("TableValueEditor", __gridScope);
462
422
  const fieldProjection = useMemo2(() => {
@@ -466,15 +426,7 @@ var TableValueEditor = ({ __gridScope, schema, model, modals, onFocus, onSave, o
466
426
  const { col } = parseCellIndex2(editing.index);
467
427
  const field = model.projection.getFields()[col];
468
428
  const fieldProjection2 = model.projection.getFieldProjection(field.id);
469
- invariant2(fieldProjection2, void 0, {
470
- F: __dxlog_file2,
471
- L: 73,
472
- S: void 0,
473
- A: [
474
- "fieldProjection",
475
- ""
476
- ]
477
- });
429
+ invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 21, S: void 0, A: ["fieldProjection", ""] });
478
430
  return fieldProjection2;
479
431
  }, [
480
432
  model,
@@ -511,15 +463,7 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
511
463
  const { col } = parseCellIndex2(editing.index);
512
464
  const field = model.projection.getFields()[col];
513
465
  const fieldProjection2 = model.projection.getFieldProjection(field.id);
514
- invariant2(fieldProjection2, void 0, {
515
- F: __dxlog_file2,
516
- L: 120,
517
- S: void 0,
518
- A: [
519
- "fieldProjection",
520
- ""
521
- ]
522
- });
466
+ invariant2(fieldProjection2, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 59, S: void 0, A: ["fieldProjection", ""] });
523
467
  return fieldProjection2;
524
468
  }, [
525
469
  model,
@@ -653,9 +597,13 @@ var TableCellEditor = ({ __gridScope, model, modals, onFocus, onSave }) => {
653
597
  __gridScope
654
598
  }), /* @__PURE__ */ React3.createElement(GridCellEditor, {
655
599
  extensions,
600
+ slots: {
601
+ content: {
602
+ className: "!py-(--dx-grid-cell-editor-padding-block)"
603
+ }
604
+ },
656
605
  getCellContent,
657
- onBlur: handleBlur,
658
- slots: editorSlots
606
+ onBlur: handleBlur
659
607
  }));
660
608
  };
661
609
  var determineNavigationAxis = ({ key }) => {
@@ -687,8 +635,9 @@ var determineNavigationDelta = ({ key, shift }) => {
687
635
  import { useAtomValue } from "@effect-atom/atom-react";
688
636
  import React4 from "react";
689
637
  import { DropdownMenu, useTranslation } from "@dxos/react-ui";
638
+ import { translationKey as translationKey2 } from "#translations";
690
639
  var ColumnActionsMenu = ({ model, modals }) => {
691
- const { t } = useTranslation(translationKey);
640
+ const { t } = useTranslation(translationKey2);
692
641
  const state = useAtomValue(modals.state);
693
642
  if (state?.type !== "column") {
694
643
  return null;
@@ -704,19 +653,19 @@ var ColumnActionsMenu = ({ model, modals }) => {
704
653
  }), /* @__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
654
  "data-testid": "column-sort-descending",
706
655
  onClick: () => model.setSort(state.fieldId, "desc")
707
- }, t("column action sort descending")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
656
+ }, t("column-action-sort-descending.menu")), (!isCurrentColumnSorted || currentSort?.direction === "desc") && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
708
657
  "data-testid": "column-sort-ascending",
709
658
  onClick: () => model.setSort(state.fieldId, "asc")
710
- }, t("column action sort ascending")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
659
+ }, t("column-action-sort-ascending.menu")), isCurrentColumnSorted && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
711
660
  "data-testid": "column-clear-sort",
712
661
  onClick: () => model.clearSort()
713
- }, t("column action clear sorting")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
662
+ }, t("column-action-clear-sorting.menu")), model.getColumnCount() > 1 && model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
714
663
  "data-testid": "column-delete",
715
664
  onClick: () => model.deleteColumn(state.fieldId)
716
- }, t("column action delete")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
665
+ }, t("column-action-delete.menu")), model.features.schemaEditable && /* @__PURE__ */ React4.createElement(DropdownMenu.Item, {
717
666
  "data-testid": "column-settings",
718
667
  onClick: () => modals.openColumnSettings()
719
- }, t("column action settings"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
668
+ }, t("column-action-settings.menu"))), /* @__PURE__ */ React4.createElement(DropdownMenu.Arrow, null))));
720
669
  };
721
670
 
722
671
  // src/components/Table/ColumnSettings.tsx
@@ -776,7 +725,7 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
776
725
  }, /* @__PURE__ */ React5.createElement(Popover2.VirtualTrigger, {
777
726
  virtualRef: modals.trigger
778
727
  }), /* @__PURE__ */ React5.createElement(Popover2.Portal, null, /* @__PURE__ */ React5.createElement(Popover2.Content, {
779
- classNames: "md:is-64"
728
+ classNames: "md:w-64"
780
729
  }, /* @__PURE__ */ React5.createElement(Popover2.Viewport, null, /* @__PURE__ */ React5.createElement(FieldEditor, {
781
730
  projection: model.projection,
782
731
  field,
@@ -790,8 +739,9 @@ var ColumnSettings = ({ registry, model, modals, onNewColumn }) => {
790
739
  import { useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
791
740
  import React6 from "react";
792
741
  import { DropdownMenu as DropdownMenu2, toLocalizedString, useTranslation as useTranslation2 } from "@dxos/react-ui";
742
+ import { translationKey as translationKey3 } from "#translations";
793
743
  var RowActionsMenu = ({ model, modals }) => {
794
- const { t } = useTranslation2(translationKey);
744
+ const { t } = useTranslation2(translationKey3);
795
745
  const hasSelection = model.selection.hasSelection;
796
746
  const state = useAtomValue3(modals.state);
797
747
  if (state?.type !== "row") {
@@ -813,11 +763,11 @@ var RowActionsMenu = ({ model, modals }) => {
813
763
  }, toLocalizedString(action.label, t)))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Separator, null)), model.features.dataEditable !== false && /* @__PURE__ */ React6.createElement(DropdownMenu2.Item, {
814
764
  "data-testid": "row-menu-delete",
815
765
  onClick: () => model.deleteRow(state.rowIndex)
816
- }, t(hasSelection ? "bulk delete row label" : "delete row label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
766
+ }, t(hasSelection ? "bulk-delete-row.label" : "delete-row.label"))), /* @__PURE__ */ React6.createElement(DropdownMenu2.Arrow, null)));
817
767
  };
818
768
 
819
- // src/components/Table/Table.tsx
820
- var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/Table.tsx";
769
+ // src/components/Table/TableContent.tsx
770
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-table/src/components/Table/TableContent.tsx";
821
771
  var columnDefault = {
822
772
  grid: {
823
773
  minSize: 80,
@@ -833,22 +783,10 @@ var rowDefault = {
833
783
  var emptyColumnMeta = Atom2.make({
834
784
  grid: {}
835
785
  });
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
786
  var emptyRowsAtom = Atom2.make([]);
850
787
  var emptyCellUpdateAtom = Atom2.make(0);
851
- var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId }, forwardedRef) => {
788
+ var TABLE_CONTENT_NAME = "Table.Content";
789
+ var TableContent = composable(({ schema, model, presentation, ignoreAttention, onCreate, onRowClick, testId, ...props }, forwardedRef) => {
852
790
  const registry = useContext(RegistryContext);
853
791
  const [dxGrid, setDxGrid] = useState4(null);
854
792
  const { hasAttention } = useAttention(model?.id ?? "table");
@@ -1056,12 +994,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1056
994
  void navigator.clipboard.writeText(textContent);
1057
995
  event.preventDefault();
1058
996
  } catch (error) {
1059
- log.catch(error, void 0, {
1060
- F: __dxlog_file3,
1061
- L: 322,
1062
- S: void 0,
1063
- C: (f, a) => f(...a)
1064
- });
997
+ log.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 262, S: void 0 });
1065
998
  }
1066
999
  break;
1067
1000
  }
@@ -1136,7 +1069,8 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1136
1069
  model,
1137
1070
  dxGrid
1138
1071
  ]);
1139
- useImperativeHandle(forwardedRef, () => {
1072
+ const { controllerRef } = useTableContext(TABLE_CONTENT_NAME);
1073
+ controllerRef.current = useMemo4(() => {
1140
1074
  if (!dxGrid || !presentation) {
1141
1075
  return {};
1142
1076
  }
@@ -1159,10 +1093,15 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1159
1093
  if (!model || !modals) {
1160
1094
  return /* @__PURE__ */ React7.createElement("span", {
1161
1095
  role: "none",
1162
- className: "attention-surface"
1096
+ className: "dx-attention-surface"
1163
1097
  });
1164
1098
  }
1165
- return /* @__PURE__ */ React7.createElement(Grid.Root, {
1099
+ return /* @__PURE__ */ React7.createElement("div", {
1100
+ ...composableProps(props, {
1101
+ classNames: "dx-container relative"
1102
+ }),
1103
+ ref: forwardedRef
1104
+ }, /* @__PURE__ */ React7.createElement(Grid.Root, {
1166
1105
  id: model.id ?? "table-grid"
1167
1106
  }, /* @__PURE__ */ React7.createElement(TableValueEditor, {
1168
1107
  model,
@@ -1172,7 +1111,7 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1172
1111
  onSave: handleSave,
1173
1112
  onCreate
1174
1113
  }), /* @__PURE__ */ React7.createElement(Grid.Content, {
1175
- className: mx("[--dx-grid-base:var(--baseSurface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
1114
+ className: mx("[--dx-grid-base:var(--base-surface)]", gridSeparatorInlineEnd, gridSeparatorBlockEnd),
1176
1115
  frozen,
1177
1116
  columns: columnMeta,
1178
1117
  columnDefault,
@@ -1198,94 +1137,16 @@ var TableMainInner = ({ schema, model, presentation, ignoreAttention, onCreate,
1198
1137
  model,
1199
1138
  modals,
1200
1139
  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
- };
1140
+ })));
1141
+ });
1142
+ TableContent.displayName = TABLE_CONTENT_NAME;
1284
1143
 
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";
1144
+ // src/components/Table/TableToolbar.tsx
1145
+ import { Atom as Atom3, RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
1146
+ import React8, { useContext as useContext2, useEffect as useEffect4, useMemo as useMemo5 } from "react";
1147
+ import { Menu, createGapSeparator, createMenuAction, useMenuActions } from "@dxos/react-ui-menu";
1148
+ import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
1149
+ import { translationKey as translationKey4 } from "#translations";
1289
1150
  var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) => Atom3.make((get) => {
1290
1151
  const nodes = [];
1291
1152
  if (onAdd) {
@@ -1293,9 +1154,9 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1293
1154
  type: "add-row",
1294
1155
  icon: "ph--plus--regular",
1295
1156
  label: [
1296
- "add row label",
1157
+ "add-row.label",
1297
1158
  {
1298
- ns: translationKey
1159
+ ns: translationKey4
1299
1160
  }
1300
1161
  ],
1301
1162
  testId: "table.toolbar.add-row"
@@ -1308,9 +1169,9 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1308
1169
  type: "save-view",
1309
1170
  icon: "ph--floppy-disk--regular",
1310
1171
  label: [
1311
- "save view label",
1172
+ "save-view.label",
1312
1173
  {
1313
- ns: translationKey
1174
+ ns: translationKey4
1314
1175
  }
1315
1176
  ],
1316
1177
  testId: "table.toolbar.save-view",
@@ -1323,7 +1184,8 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1323
1184
  nodes.push(...gap.nodes);
1324
1185
  const edges = nodes.map(({ id: target }) => ({
1325
1186
  source: "root",
1326
- target
1187
+ target,
1188
+ relation: "child"
1327
1189
  }));
1328
1190
  if (customActions) {
1329
1191
  const custom = get(customActions);
@@ -1335,12 +1197,12 @@ var createTableToolbarActions = ({ stateAtom, onAdd, onSave, customActions }) =>
1335
1197
  edges
1336
1198
  };
1337
1199
  });
1338
- var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, customActions }) => {
1339
- const registry = useContext3(RegistryContext3);
1340
- const stateAtom = useMemo6(() => Atom3.make({
1200
+ var TableToolbar = composable2(({ attendableId, viewDirty, onAdd, onSave, customActions, ...props }, forwardedRef) => {
1201
+ const registry = useContext2(RegistryContext2);
1202
+ const stateAtom = useMemo5(() => Atom3.make({
1341
1203
  viewDirty
1342
1204
  }), []);
1343
- useEffect5(() => {
1205
+ useEffect4(() => {
1344
1206
  registry.set(stateAtom, {
1345
1207
  viewDirty
1346
1208
  });
@@ -1349,7 +1211,7 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
1349
1211
  stateAtom,
1350
1212
  viewDirty
1351
1213
  ]);
1352
- const actionsCreator = useMemo6(() => createTableToolbarActions({
1214
+ const actionsCreator = useMemo5(() => createTableToolbarActions({
1353
1215
  stateAtom,
1354
1216
  onAdd,
1355
1217
  onSave,
@@ -1360,13 +1222,115 @@ var TableToolbar = ({ classNames, viewDirty, attendableId, onAdd, onSave, custom
1360
1222
  onSave,
1361
1223
  customActions
1362
1224
  ]);
1363
- const menu = useMenuActions(actionsCreator);
1364
- return /* @__PURE__ */ React9.createElement(MenuProvider, {
1365
- ...menu,
1225
+ const menuActions = useMenuActions(actionsCreator);
1226
+ return /* @__PURE__ */ React8.createElement(Menu.Root, {
1227
+ ...menuActions,
1366
1228
  attendableId
1367
- }, /* @__PURE__ */ React9.createElement(ToolbarMenu, {
1368
- classNames
1229
+ }, /* @__PURE__ */ React8.createElement(Menu.Toolbar, {
1230
+ ...composableProps2(props),
1231
+ ref: forwardedRef
1369
1232
  }));
1233
+ });
1234
+ TableToolbar.displayName = "TableToolbar";
1235
+
1236
+ // src/components/Table/Table.tsx
1237
+ var emptyColumnMeta2 = Atom4.make({
1238
+ grid: {}
1239
+ });
1240
+ var [TableContextProvider, useTableContext] = createContext("Table");
1241
+ var TABLE_ROOT_NAME = "Table.Root";
1242
+ var TableRoot = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
1243
+ const controllerRef = useRef3({});
1244
+ useImperativeHandle(forwardedRef, () => ({
1245
+ update: (cell) => controllerRef.current?.update?.(cell),
1246
+ handleInsertRowResult: (result) => controllerRef.current?.handleInsertRowResult?.(result)
1247
+ }), []);
1248
+ return /* @__PURE__ */ React9.createElement(TableContextProvider, {
1249
+ controllerRef
1250
+ }, children);
1251
+ });
1252
+ TableRoot.displayName = TABLE_ROOT_NAME;
1253
+ var Table = {
1254
+ Root: TableRoot,
1255
+ Toolbar: TableToolbar,
1256
+ Content: TableContent
1257
+ };
1258
+
1259
+ // src/components/Table/DynamicTable.tsx
1260
+ import { RegistryContext as RegistryContext3 } from "@effect-atom/atom-react";
1261
+ import React10, { useCallback as useCallback5, useContext as useContext3, useEffect as useEffect5, useMemo as useMemo6, useRef as useRef4, useState as useState5 } from "react";
1262
+ import { useDefaultValue } from "@dxos/react-ui";
1263
+ import { mx as mx2 } from "@dxos/ui-theme";
1264
+ var DynamicTable = ({ classNames, schema, name = "com.example.dynamicTable", rows, properties, jsonSchema: jsonSchemaProp, rowActions, onRowClick, onRowAction, ...props }) => {
1265
+ const registry = useContext3(RegistryContext3);
1266
+ const [dynamicTable, setDynamicTable] = useState5();
1267
+ const { jsonSchema } = useMemo6(() => getBaseSchema({
1268
+ typename: name,
1269
+ properties,
1270
+ jsonSchema: jsonSchemaProp,
1271
+ schema
1272
+ }), [
1273
+ name,
1274
+ properties,
1275
+ jsonSchemaProp,
1276
+ schema
1277
+ ]);
1278
+ useEffect5(() => {
1279
+ setDynamicTable(makeDynamicTable({
1280
+ registry,
1281
+ jsonSchema,
1282
+ properties
1283
+ }));
1284
+ }, [
1285
+ registry,
1286
+ jsonSchema,
1287
+ properties
1288
+ ]);
1289
+ const tableRef = useRef4(null);
1290
+ const handleCellUpdate = useCallback5((cell) => {
1291
+ tableRef.current?.update?.(cell);
1292
+ }, []);
1293
+ const handleRowOrderChange = useCallback5(() => {
1294
+ tableRef.current?.update?.();
1295
+ }, []);
1296
+ const features = useDefaultValue(props.features, () => ({
1297
+ selection: {
1298
+ enabled: false
1299
+ },
1300
+ dataEditable: false
1301
+ }));
1302
+ const model = useTableModel({
1303
+ rows,
1304
+ object: dynamicTable?.object,
1305
+ projection: dynamicTable?.projection,
1306
+ features,
1307
+ rowActions,
1308
+ onCellUpdate: handleCellUpdate,
1309
+ onRowOrderChange: handleRowOrderChange,
1310
+ onRowAction
1311
+ });
1312
+ const presentation = useMemo6(() => {
1313
+ if (model) {
1314
+ return new TablePresentation(registry, model);
1315
+ }
1316
+ }, [
1317
+ registry,
1318
+ model
1319
+ ]);
1320
+ return /* @__PURE__ */ React10.createElement("div", {
1321
+ role: "none",
1322
+ className: mx2("dx-expander grid", classNames)
1323
+ }, /* @__PURE__ */ React10.createElement("div", {
1324
+ role: "none",
1325
+ className: "grid min-h-0 overflow-hidden"
1326
+ }, /* @__PURE__ */ React10.createElement(Table.Root, {
1327
+ ref: tableRef
1328
+ }, /* @__PURE__ */ React10.createElement(Table.Content, {
1329
+ model,
1330
+ presentation,
1331
+ ignoreAttention: true,
1332
+ onRowClick
1333
+ }))));
1370
1334
  };
1371
1335
  export {
1372
1336
  BUTTON_IDENTIFIERS,
@@ -1378,7 +1342,6 @@ export {
1378
1342
  Table,
1379
1343
  TableModel,
1380
1344
  TablePresentation,
1381
- TableToolbar,
1382
1345
  cellClassesForRowSelection,
1383
1346
  compareValues,
1384
1347
  createDirectChangeCallback,
@@ -1391,9 +1354,9 @@ export {
1391
1354
  tableButtons,
1392
1355
  tableControls,
1393
1356
  touch,
1394
- translations,
1395
1357
  useAddRow,
1396
1358
  useProjectionModel,
1359
+ useTableContext,
1397
1360
  useTableModel
1398
1361
  };
1399
1362
  //# sourceMappingURL=index.mjs.map