@dxos/react-ui-table 0.8.1 → 0.8.2-main.2f9c567

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 (66) hide show
  1. package/dist/lib/browser/chunk-UGGYKLOH.mjs +28 -0
  2. package/dist/lib/browser/chunk-UGGYKLOH.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +91 -126
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/types/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-TGG6OZ54.cjs → chunk-2QLLIPZK.cjs} +13 -11
  8. package/dist/lib/node/chunk-2QLLIPZK.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +145 -180
  10. package/dist/lib/node/index.cjs.map +4 -4
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/types/index.cjs +3 -3
  13. package/dist/lib/node/types/index.cjs.map +1 -1
  14. package/dist/lib/node-esm/{chunk-KKLP54L3.mjs → chunk-N2RRVR7F.mjs} +11 -9
  15. package/dist/lib/node-esm/chunk-N2RRVR7F.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +91 -126
  17. package/dist/lib/node-esm/index.mjs.map +4 -4
  18. package/dist/lib/node-esm/meta.json +1 -1
  19. package/dist/lib/node-esm/types/index.mjs +1 -1
  20. package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
  21. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  22. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
  24. package/dist/types/src/components/testing.d.ts +40 -40
  25. package/dist/types/src/components/testing.d.ts.map +1 -1
  26. package/dist/types/src/hooks/useTableModel.d.ts +2 -2
  27. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  28. package/dist/types/src/model/modal-controller.d.ts +3 -3
  29. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  30. package/dist/types/src/model/table-model.d.ts.map +1 -1
  31. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  32. package/dist/types/src/types/table.d.ts +43 -43
  33. package/dist/types/src/types/table.d.ts.map +1 -1
  34. package/dist/types/src/util/table-buttons.d.ts +0 -14
  35. package/dist/types/src/util/table-buttons.d.ts.map +1 -1
  36. package/dist/types/src/util/table.d.ts +2 -2
  37. package/dist/types/src/util/table.d.ts.map +1 -1
  38. package/dist/types/src/util/tag.d.ts +11 -0
  39. package/dist/types/src/util/tag.d.ts.map +1 -0
  40. package/package.json +35 -33
  41. package/src/components/Table/CreateRefPanel.tsx +5 -5
  42. package/src/components/Table/DynamicTable.stories.tsx +2 -2
  43. package/src/components/Table/Table.stories.tsx +10 -11
  44. package/src/components/Table/Table.tsx +18 -24
  45. package/src/components/Table/relations.stories.tsx +34 -24
  46. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +3 -3
  47. package/src/components/TableToolbar/TableToolbar.tsx +2 -2
  48. package/src/components/testing.ts +10 -9
  49. package/src/hooks/useTableModel.ts +2 -2
  50. package/src/model/modal-controller.ts +3 -3
  51. package/src/model/table-model.test.ts +7 -6
  52. package/src/model/table-model.ts +19 -2
  53. package/src/model/table-presentation.test.ts +7 -6
  54. package/src/model/table-presentation.ts +3 -5
  55. package/src/types/table.ts +16 -8
  56. package/src/util/dynamic-table.ts +2 -2
  57. package/src/util/table-buttons.ts +0 -23
  58. package/src/util/table.ts +10 -14
  59. package/src/util/tag.ts +33 -0
  60. package/dist/lib/browser/chunk-YWNRUF4J.mjs +0 -26
  61. package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +0 -7
  62. package/dist/lib/node/chunk-TGG6OZ54.cjs.map +0 -7
  63. package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +0 -7
  64. package/dist/types/src/components/Table/RefPanel.d.ts +0 -9
  65. package/dist/types/src/components/Table/RefPanel.d.ts.map +0 -1
  66. package/src/components/Table/RefPanel.tsx +0 -52
@@ -8,7 +8,7 @@ import { type Space } from '@dxos/client/echo';
8
8
  import { Resource } from '@dxos/context';
9
9
  import { type FieldSortType, FormatEnum, getValue, setValue, type JsonProp } from '@dxos/echo-schema';
10
10
  import { invariant } from '@dxos/invariant';
11
- import { isReactiveObject, makeRef } from '@dxos/live-object';
11
+ import { isLiveObject, makeRef } from '@dxos/live-object';
12
12
  import { formatForEditing, parseValue } from '@dxos/react-ui-form';
13
13
  import {
14
14
  type DxGridAxisMeta,
@@ -21,6 +21,7 @@ import { type ViewType, type ViewProjection } from '@dxos/schema';
21
21
  import { type SelectionMode, SelectionModel } from './selection-model';
22
22
  import { TableSorting } from './table-sorting';
23
23
  import { touch } from '../util';
24
+ import { extractTagIds } from '../util/tag';
24
25
 
25
26
  // TODO(burdon): Use schema types.
26
27
  export type TableRow = Record<JsonProp, any> & { id: string };
@@ -342,12 +343,28 @@ export class TableModel<T extends TableRow = TableRow> extends Resource {
342
343
  case FormatEnum.Ref: {
343
344
  // TODO(ZaymonFC): This get's called an additional time by the cell editor onBlur, but with the cell editors
344
345
  // plain string value. Maybe onBlur should be called with the actual value?
345
- if (isReactiveObject(value)) {
346
+ if (isLiveObject(value)) {
346
347
  setValue(this._rows.value[rowIdx], field.path, makeRef(value));
347
348
  }
348
349
  break;
349
350
  }
350
351
 
352
+ case FormatEnum.SingleSelect: {
353
+ const ids = extractTagIds(value);
354
+ if (ids && ids.length > 0) {
355
+ setValue(this._rows.value[rowIdx], field.path, ids[0]);
356
+ }
357
+ break;
358
+ }
359
+
360
+ case FormatEnum.MultiSelect: {
361
+ const ids = extractTagIds(value);
362
+ if (ids) {
363
+ setValue(this._rows.value[rowIdx], field.path, ids);
364
+ }
365
+ break;
366
+ }
367
+
351
368
  default: {
352
369
  setValue(
353
370
  this._rows.value[rowIdx],
@@ -2,10 +2,11 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { Schema } from 'effect';
5
6
  import { describe, expect, it, beforeEach } from 'vitest';
6
7
 
7
- import { S, TypedObject } from '@dxos/echo-schema';
8
- import { create, makeRef } from '@dxos/live-object';
8
+ import { TypedObject } from '@dxos/echo-schema';
9
+ import { live, makeRef } from '@dxos/live-object';
9
10
  import { createEchoSchema } from '@dxos/live-object/testing';
10
11
  import { createView, ViewProjection } from '@dxos/schema';
11
12
 
@@ -22,7 +23,7 @@ describe('TablePresentation', () => {
22
23
 
23
24
  beforeEach(async () => {
24
25
  updateCount = 0;
25
- ({ data } = create({
26
+ ({ data } = live({
26
27
  data: [
27
28
  { col1: 'A', col2: 1, col3: true },
28
29
  { col1: 'B', col2: 2, col3: false },
@@ -89,14 +90,14 @@ describe('TablePresentation', () => {
89
90
  });
90
91
 
91
92
  class Test extends TypedObject({ typename: 'example.com/type/Test', version: '0.1.0' })({
92
- title: S.String,
93
- completed: S.Boolean,
93
+ title: Schema.String,
94
+ completed: Schema.Boolean,
94
95
  }) {}
95
96
 
96
97
  const createTableModel = (props: Partial<TableModelProps> = {}): TableModel => {
97
98
  const schema = createEchoSchema(Test);
98
99
  const view = createView({ name: 'Test', typename: schema.typename, jsonSchema: schema.jsonSchema });
99
100
  const projection = new ViewProjection(schema.jsonSchema, view);
100
- const table = create(TableType, { view: makeRef(view) });
101
+ const table = live(TableType, { view: makeRef(view) });
101
102
  return new TableModel({ id: table.id, view, projection, ...props });
102
103
  };
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { signal } from '@preact/signals-core';
6
6
 
7
- import { FormatEnum, getValue } from '@dxos/echo-schema';
7
+ import { FormatEnum, getDXN, getValue } from '@dxos/echo-schema';
8
8
  import { cellClassesForFieldType, formatForDisplay } from '@dxos/react-ui-form';
9
9
  import {
10
10
  type DxGridPlane,
@@ -124,10 +124,8 @@ export class TablePresentation<T extends TableRow = TableRow> {
124
124
  if (props.format === FormatEnum.Ref && props.referenceSchema) {
125
125
  const targetObj = getValue(obj, field.path)?.target;
126
126
  if (targetObj) {
127
- cell.accessoryHtml = tableButtons.referencedCell.render({
128
- targetId: targetObj.id as any as string,
129
- schemaId: props.referenceSchema,
130
- });
127
+ const dxn = getDXN(targetObj)?.toString();
128
+ cell.accessoryHtml = `<dx-ref-tag ref=${dxn} class="dx-button block is-6 pli-[3px] plb-[3px] pbe-[2px] min-bs-0 absolute inline-end-1"><dx-icon icon="ph--link-simple--regular"/></dx-ref-tag>`;
131
129
  }
132
130
  }
133
131
 
@@ -2,20 +2,28 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { EchoObject, Expando, LabelAnnotationId, ObjectId, Ref, S } from '@dxos/echo-schema';
5
+ import { Schema } from 'effect';
6
+
7
+ import { Type } from '@dxos/echo';
6
8
  // import { ThreadType } from '@dxos/plugin-space/types';
9
+ import { LabelAnnotationId } from '@dxos/echo-schema';
7
10
  import { ViewType } from '@dxos/schema';
8
11
 
9
- export const TableSchema = S.Struct({
10
- id: ObjectId,
11
- name: S.optional(S.String),
12
- view: S.optional(Ref(ViewType)),
12
+ export const TableSchema = Schema.Struct({
13
+ id: Type.ObjectId,
14
+ name: Schema.optional(Schema.String),
15
+ view: Schema.optional(Type.Ref(ViewType)),
13
16
  // TODO(burdon): Document why threads is included here?
14
- threads: S.optional(S.Array(Ref(Expando /* ThreadType */))),
17
+ threads: Schema.optional(Schema.Array(Type.Ref(Type.Expando /* ThreadType */))),
15
18
  }).annotations({
16
19
  // TODO(burdon): Move annotation to property.
17
20
  [LabelAnnotationId]: 'name',
18
21
  });
19
22
 
20
- export const TableType = TableSchema.pipe(EchoObject({ typename: 'dxos.org/type/Table', version: '0.1.0' }));
21
- export interface TableType extends S.Schema.Type<typeof TableType> {}
23
+ export const TableType = TableSchema.pipe(
24
+ Type.def({
25
+ typename: 'dxos.org/type/Table',
26
+ version: '0.1.0',
27
+ }),
28
+ );
29
+ export interface TableType extends Schema.Schema.Type<typeof TableType> {}
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  import type { BaseSchema, JsonSchemaType, SortDirectionType } from '@dxos/echo-schema';
6
- import { create, makeRef } from '@dxos/live-object';
6
+ import { live, makeRef } from '@dxos/live-object';
7
7
  import {
8
8
  createView,
9
9
  getSchemaFromPropertyDefinitions,
@@ -66,7 +66,7 @@ export const makeDynamicTable = ({
66
66
  ...(properties && { fields: properties.map((property) => property.name) }),
67
67
  });
68
68
 
69
- const table = create(TableType, { name: 'dynamic-table', view: makeRef(view) });
69
+ const table = live(TableType, { name: 'dynamic-table', view: makeRef(view) });
70
70
  const projection = new ViewProjection(jsonSchema, view);
71
71
  if (properties && view.fields) {
72
72
  setProperties(view, projection, properties);
@@ -15,7 +15,6 @@ export const BUTTON_IDENTIFIERS: { [K in TableButton]: string } = {
15
15
  type ButtonData =
16
16
  | { type: 'columnSettings'; fieldId: string }
17
17
  | { type: 'newColumn'; disabled?: boolean }
18
- | { type: 'referencedCell'; schemaId: string; targetId: string }
19
18
  | { type: 'rowMenu'; rowIndex: number }
20
19
  | { type: 'sort'; fieldId: string; direction?: 'asc' | 'desc' };
21
20
 
@@ -76,27 +75,6 @@ const columnSettingsButton = {
76
75
  }),
77
76
  } as const;
78
77
 
79
- const referencedCellButton = {
80
- attr: BUTTON_IDENTIFIERS.referencedCell,
81
- icon: 'ph--link-simple-horizontal--regular',
82
- render: ({ targetId, schemaId }: Omit<Extract<ButtonData, { type: 'referencedCell' }>, 'type'>) => {
83
- return createButton({
84
- attr: BUTTON_IDENTIFIERS.referencedCell,
85
- icon: referencedCellButton.icon,
86
- data: {
87
- 'data-target-id': targetId,
88
- 'data-schema-id': schemaId,
89
- },
90
- testId: 'table-ref-cell-button',
91
- });
92
- },
93
- getData: (el: HTMLElement): Extract<ButtonData, { type: 'referencedCell' }> => ({
94
- type: 'referencedCell',
95
- targetId: el.getAttribute('data-target-id')!,
96
- schemaId: el.getAttribute('data-schema-id')!,
97
- }),
98
- } as const;
99
-
100
78
  const rowMenuButton = {
101
79
  attr: BUTTON_IDENTIFIERS.rowMenu,
102
80
  icon: 'ph--dots-three--regular',
@@ -143,7 +121,6 @@ const sortButton = {
143
121
  export const tableButtons = {
144
122
  addColumn: addColumnButton,
145
123
  columnSettings: columnSettingsButton,
146
- referencedCell: referencedCellButton,
147
124
  rowMenu: rowMenuButton,
148
125
  sort: sortButton,
149
126
  } as const;
package/src/util/table.ts CHANGED
@@ -2,19 +2,19 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { Schema, SchemaAST } from 'effect';
6
+
5
7
  import {
6
- AST,
7
8
  type EchoSchema,
8
9
  Format,
9
10
  FormatEnum,
10
11
  type JsonPath,
11
12
  type JsonProp,
12
- S,
13
13
  TypedObject,
14
14
  TypeEnum,
15
15
  } from '@dxos/echo-schema';
16
16
  import { type Client, PublicKey } from '@dxos/react-client';
17
- import { create, makeRef, type Space } from '@dxos/react-client/echo';
17
+ import { live, makeRef, type Space } from '@dxos/react-client/echo';
18
18
  import { createFieldId, createView, getSchemaProperties, ViewProjection, type ViewType } from '@dxos/schema';
19
19
 
20
20
  import { type TableType } from '../types';
@@ -34,18 +34,14 @@ export const initializeTable = async ({
34
34
  table,
35
35
  typename,
36
36
  initialRow = true,
37
- }: InitialiseTableProps): Promise<S.Schema.AnyNoContext> => {
37
+ }: InitialiseTableProps): Promise<Schema.Schema.AnyNoContext> => {
38
38
  if (typename) {
39
39
  const schema = await space.db.graph.getSchemaByTypename(typename, space.db);
40
40
  if (!schema) {
41
41
  throw new Error(`Schema not found: ${typename}`);
42
42
  }
43
43
 
44
- // We need to get the schema properties here.
45
- // For now, only simple types and refs, not compound types are going to be supported.
46
- const fields = getSchemaProperties(schema.ast)
47
- .filter((prop) => prop.format !== FormatEnum.Ref)
48
- .map((prop) => prop.name);
44
+ const fields = getSchemaProperties(schema.ast).map((prop) => prop.name);
49
45
 
50
46
  table.view = makeRef(
51
47
  createView({
@@ -75,7 +71,7 @@ export const initializeTable = async ({
75
71
 
76
72
  if (initialRow) {
77
73
  // TODO(burdon): Last (first) row should not be in db and should be managed by the model.
78
- space.db.add(create(schema, {}));
74
+ space.db.add(live(schema, {}));
79
75
  }
80
76
 
81
77
  return schema;
@@ -86,10 +82,10 @@ const ContactSchema = TypedObject({
86
82
  typename: `example.com/type/${PublicKey.random().truncate()}`,
87
83
  version: '0.1.0',
88
84
  })({
89
- name: S.optional(S.String).annotations({ [AST.TitleAnnotationId]: 'Name' }),
90
- active: S.optional(S.Boolean),
91
- email: S.optional(Format.Email),
92
- salary: S.optional(Format.Currency()).annotations({ [AST.TitleAnnotationId]: 'Salary' }),
85
+ name: Schema.optional(Schema.String).annotations({ [SchemaAST.TitleAnnotationId]: 'Name' }),
86
+ active: Schema.optional(Schema.Boolean),
87
+ email: Schema.optional(Format.Email),
88
+ salary: Schema.optional(Format.Currency()).annotations({ [SchemaAST.TitleAnnotationId]: 'Salary' }),
93
89
  });
94
90
 
95
91
  const ContactFields = ['name', 'email', 'salary', 'active'];
@@ -0,0 +1,33 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // TODO(ZaymonFC): Push this into the tag picker module.
6
+
7
+ /**
8
+ * Regex pattern for matching tags in the format [Label](id)
9
+ */
10
+ export const TAG_PATTERN_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
11
+
12
+ /**
13
+ * Extracts tag IDs from a string in the format [Label](id)
14
+ * @param value The string to extract IDs from
15
+ * @returns Array of extracted IDs or undefined if no matches or value is not a string
16
+ */
17
+ export const extractTagIds = (value: unknown): string[] | undefined => {
18
+ if (typeof value !== 'string') {
19
+ return undefined;
20
+ }
21
+
22
+ const ids: string[] = [];
23
+ let match;
24
+
25
+ // Use the global regex to find all matches
26
+ while ((match = TAG_PATTERN_REGEX.exec(value)) !== null) {
27
+ if (match[2]) {
28
+ ids.push(match[2]);
29
+ }
30
+ }
31
+
32
+ return ids.length > 0 ? ids : undefined;
33
+ };
@@ -1,26 +0,0 @@
1
- // packages/ui/react-ui-table/src/types/table.ts
2
- import { EchoObject, Expando, LabelAnnotationId, ObjectId, Ref, S } from "@dxos/echo-schema";
3
- import { ViewType } from "@dxos/schema";
4
- var TableSchema = S.Struct({
5
- id: ObjectId,
6
- name: S.optional(S.String),
7
- view: S.optional(Ref(ViewType)),
8
- // TODO(burdon): Document why threads is included here?
9
- threads: S.optional(S.Array(Ref(
10
- Expando
11
- /* ThreadType */
12
- )))
13
- }).annotations({
14
- // TODO(burdon): Move annotation to property.
15
- [LabelAnnotationId]: "name"
16
- });
17
- var TableType = TableSchema.pipe(EchoObject({
18
- typename: "dxos.org/type/Table",
19
- version: "0.1.0"
20
- }));
21
-
22
- export {
23
- TableSchema,
24
- TableType
25
- };
26
- //# sourceMappingURL=chunk-YWNRUF4J.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types/table.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { EchoObject, Expando, LabelAnnotationId, ObjectId, Ref, S } from '@dxos/echo-schema';\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = S.Struct({\n id: ObjectId,\n name: S.optional(S.String),\n view: S.optional(Ref(ViewType)),\n // TODO(burdon): Document why threads is included here?\n threads: S.optional(S.Array(Ref(Expando /* ThreadType */))),\n}).annotations({\n // TODO(burdon): Move annotation to property.\n [LabelAnnotationId]: 'name',\n});\n\nexport const TableType = TableSchema.pipe(EchoObject({ typename: 'dxos.org/type/Table', version: '0.1.0' }));\nexport interface TableType extends S.Schema.Type<typeof TableType> {}\n"],
5
- "mappings": ";AAIA,SAASA,YAAYC,SAASC,mBAAmBC,UAAUC,KAAKC,SAAS;AAEzE,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,EAAEC,OAAO;EAClCC,IAAIC;EACJC,MAAMJ,EAAEK,SAASL,EAAEM,MAAM;EACzBC,MAAMP,EAAEK,SAASG,IAAIC,QAAAA,CAAAA;;EAErBC,SAASV,EAAEK,SAASL,EAAEW,MAAMH;IAAII;;EAAsB,CAAA,CAAA;AACxD,CAAA,EAAGC,YAAY;;EAEb,CAACC,iBAAAA,GAAoB;AACvB,CAAA;AAEO,IAAMC,YAAYhB,YAAYiB,KAAKC,WAAW;EAAEC,UAAU;EAAuBC,SAAS;AAAQ,CAAA,CAAA;",
6
- "names": ["EchoObject", "Expando", "LabelAnnotationId", "ObjectId", "Ref", "S", "ViewType", "TableSchema", "S", "Struct", "id", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "annotations", "LabelAnnotationId", "TableType", "pipe", "EchoObject", "typename", "version"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types/table.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { EchoObject, Expando, LabelAnnotationId, ObjectId, Ref, S } from '@dxos/echo-schema';\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = S.Struct({\n id: ObjectId,\n name: S.optional(S.String),\n view: S.optional(Ref(ViewType)),\n // TODO(burdon): Document why threads is included here?\n threads: S.optional(S.Array(Ref(Expando /* ThreadType */))),\n}).annotations({\n // TODO(burdon): Move annotation to property.\n [LabelAnnotationId]: 'name',\n});\n\nexport const TableType = TableSchema.pipe(EchoObject({ typename: 'dxos.org/type/Table', version: '0.1.0' }));\nexport interface TableType extends S.Schema.Type<typeof TableType> {}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAyE;AAEzE,oBAAyB;AAElB,IAAMA,cAAcC,qBAAEC,OAAO;EAClCC,IAAIC;EACJC,MAAMJ,qBAAEK,SAASL,qBAAEM,MAAM;EACzBC,MAAMP,qBAAEK,aAASG,wBAAIC,sBAAAA,CAAAA;;EAErBC,SAASV,qBAAEK,SAASL,qBAAEW,UAAMH;IAAII;;EAAsB,CAAA,CAAA;AACxD,CAAA,EAAGC,YAAY;;EAEb,CAACC,oCAAAA,GAAoB;AACvB,CAAA;AAEO,IAAMC,YAAYhB,YAAYiB,SAAKC,+BAAW;EAAEC,UAAU;EAAuBC,SAAS;AAAQ,CAAA,CAAA;",
6
- "names": ["TableSchema", "S", "Struct", "id", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "annotations", "LabelAnnotationId", "TableType", "pipe", "EchoObject", "typename", "version"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types/table.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { EchoObject, Expando, LabelAnnotationId, ObjectId, Ref, S } from '@dxos/echo-schema';\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = S.Struct({\n id: ObjectId,\n name: S.optional(S.String),\n view: S.optional(Ref(ViewType)),\n // TODO(burdon): Document why threads is included here?\n threads: S.optional(S.Array(Ref(Expando /* ThreadType */))),\n}).annotations({\n // TODO(burdon): Move annotation to property.\n [LabelAnnotationId]: 'name',\n});\n\nexport const TableType = TableSchema.pipe(EchoObject({ typename: 'dxos.org/type/Table', version: '0.1.0' }));\nexport interface TableType extends S.Schema.Type<typeof TableType> {}\n"],
5
- "mappings": ";;;AAIA,SAASA,YAAYC,SAASC,mBAAmBC,UAAUC,KAAKC,SAAS;AAEzE,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,EAAEC,OAAO;EAClCC,IAAIC;EACJC,MAAMJ,EAAEK,SAASL,EAAEM,MAAM;EACzBC,MAAMP,EAAEK,SAASG,IAAIC,QAAAA,CAAAA;;EAErBC,SAASV,EAAEK,SAASL,EAAEW,MAAMH;IAAII;;EAAsB,CAAA,CAAA;AACxD,CAAA,EAAGC,YAAY;;EAEb,CAACC,iBAAAA,GAAoB;AACvB,CAAA;AAEO,IAAMC,YAAYhB,YAAYiB,KAAKC,WAAW;EAAEC,UAAU;EAAuBC,SAAS;AAAQ,CAAA,CAAA;",
6
- "names": ["EchoObject", "Expando", "LabelAnnotationId", "ObjectId", "Ref", "S", "ViewType", "TableSchema", "S", "Struct", "id", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "annotations", "LabelAnnotationId", "TableType", "pipe", "EchoObject", "typename", "version"]
7
- }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { type TableModel, type ModalController } from '../../model';
3
- type RefPanelProps = {
4
- model: TableModel;
5
- modals: ModalController;
6
- };
7
- export declare const RefPanel: ({ model, modals }: RefPanelProps) => React.JSX.Element | null;
8
- export {};
9
- //# sourceMappingURL=RefPanel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RefPanel.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/RefPanel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEpE,KAAK,aAAa,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC;AAUpE,eAAO,MAAM,QAAQ,sBAAuB,aAAa,6BA6BxD,CAAC"}
@@ -1,52 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { type Space } from '@dxos/react-client/echo';
8
- import { Popover } from '@dxos/react-ui';
9
- import { Form } from '@dxos/react-ui-form';
10
-
11
- import { type TableModel, type ModalController } from '../../model';
12
-
13
- type RefPanelProps = { model: TableModel; modals: ModalController };
14
-
15
- const getRefTargetObj = (space?: Space, id?: string) => {
16
- if (space && id) {
17
- return space?.db.getObjectById(id);
18
- } else {
19
- return undefined;
20
- }
21
- };
22
-
23
- export const RefPanel = ({ model, modals }: RefPanelProps) => {
24
- const state = modals.state.value;
25
- const space = model?.space;
26
- const targetObj = getRefTargetObj(space, state?.type === 'refPanel' ? state.targetId : undefined);
27
- const schema = space && state?.type === 'refPanel' ? space.db.schemaRegistry.getSchema(state.typename) : undefined;
28
-
29
- if (!model.view || !model.projection) {
30
- return null;
31
- }
32
-
33
- return (
34
- <Popover.Root
35
- modal={false}
36
- open={state?.type === 'refPanel' && !!targetObj && !!schema}
37
- onOpenChange={(nextOpen) => {
38
- if (!nextOpen) {
39
- return modals.close();
40
- }
41
- }}
42
- >
43
- <Popover.VirtualTrigger virtualRef={modals.trigger} />
44
- <Popover.Portal>
45
- <Popover.Content classNames='md:is-64'>
46
- {targetObj && schema && <Form readonly values={targetObj} schema={schema} />}
47
- <Popover.Arrow />
48
- </Popover.Content>
49
- </Popover.Portal>
50
- </Popover.Root>
51
- );
52
- };