@dxos/react-ui-table 0.8.4-main.5ea62a8 → 0.8.4-main.72ec0f3

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 (97) hide show
  1. package/dist/lib/browser/{chunk-63UUF4IG.mjs → chunk-2PFAPQL4.mjs} +7 -7
  2. package/dist/lib/browser/chunk-2PFAPQL4.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-RQYXNWWN.mjs → chunk-GS2UNGJK.mjs} +451 -498
  4. package/dist/lib/browser/chunk-GS2UNGJK.mjs.map +7 -0
  5. package/dist/lib/browser/index.mjs +170 -317
  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 +10 -7
  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-K734DJB7.mjs → chunk-6POOFFYF.mjs} +7 -7
  12. package/dist/lib/node-esm/chunk-6POOFFYF.mjs.map +7 -0
  13. package/dist/lib/node-esm/{chunk-QNDUGIS7.mjs → chunk-TRR3C5NX.mjs} +451 -498
  14. package/dist/lib/node-esm/chunk-TRR3C5NX.mjs.map +7 -0
  15. package/dist/lib/node-esm/index.mjs +170 -317
  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 +10 -7
  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/DynamicTable.d.ts +2 -2
  22. package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
  23. package/dist/types/src/components/Table/DynamicTable.stories.d.ts +3 -3
  24. package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
  25. package/dist/types/src/components/Table/Relations.stories.d.ts +70 -7
  26. package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
  28. package/dist/types/src/components/Table/Table.d.ts +5 -2
  29. package/dist/types/src/components/Table/Table.d.ts.map +1 -1
  30. package/dist/types/src/components/Table/Table.stories.d.ts +5 -6
  31. package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
  32. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +7 -5
  33. package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
  34. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +5 -3
  35. package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
  36. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +1 -2
  37. package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/TableCellEditor/index.d.ts +1 -0
  39. package/dist/types/src/components/TableCellEditor/index.d.ts.map +1 -1
  40. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts +2 -2
  41. package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
  42. package/dist/types/src/components/testing.d.ts +3 -3
  43. package/dist/types/src/components/testing.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/useTableModel.d.ts +3 -3
  47. package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
  48. package/dist/types/src/model/modal-controller.d.ts +0 -7
  49. package/dist/types/src/model/modal-controller.d.ts.map +1 -1
  50. package/dist/types/src/model/table-model.d.ts +4 -4
  51. package/dist/types/src/model/table-model.d.ts.map +1 -1
  52. package/dist/types/src/model/table-presentation.d.ts.map +1 -1
  53. package/dist/types/src/model/table-sorting.d.ts +2 -3
  54. package/dist/types/src/model/table-sorting.d.ts.map +1 -1
  55. package/dist/types/src/testing/useTestTableModel.d.ts +3 -17
  56. package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -1
  57. package/dist/types/src/types/schema.d.ts +6 -6
  58. package/dist/types/src/types/schema.d.ts.map +1 -1
  59. package/dist/types/src/util/dynamic-table.d.ts +5 -6
  60. package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
  61. package/dist/types/src/util/schema.d.ts +1 -1
  62. package/dist/types/src/util/schema.d.ts.map +1 -1
  63. package/dist/types/tsconfig.tsbuildinfo +1 -1
  64. package/package.json +53 -52
  65. package/src/components/Table/DynamicTable.stories.tsx +11 -10
  66. package/src/components/Table/DynamicTable.tsx +4 -7
  67. package/src/components/Table/Relations.stories.tsx +127 -18
  68. package/src/components/Table/RowActionsMenu.tsx +21 -13
  69. package/src/components/Table/Table.stories.tsx +47 -46
  70. package/src/components/Table/Table.tsx +13 -9
  71. package/src/components/TableCellEditor/FormCellEditor.tsx +51 -41
  72. package/src/components/TableCellEditor/TableCellEditor.stories.tsx +19 -46
  73. package/src/components/TableCellEditor/TableCellEditor.tsx +17 -112
  74. package/src/components/TableCellEditor/index.ts +1 -0
  75. package/src/components/TableToolbar/TableToolbar.tsx +32 -22
  76. package/src/components/testing.ts +2 -2
  77. package/src/hooks/useAddRow.ts +1 -1
  78. package/src/hooks/useTableModel.ts +5 -5
  79. package/src/model/modal-controller.ts +0 -28
  80. package/src/model/table-model.test.ts +17 -7
  81. package/src/model/table-model.ts +19 -9
  82. package/src/model/table-presentation.test.ts +20 -18
  83. package/src/model/table-presentation.ts +4 -5
  84. package/src/model/table-sorting.ts +16 -7
  85. package/src/playwright/TableManager.ts +1 -1
  86. package/src/playwright/smoke.spec.ts +7 -5
  87. package/src/testing/useTestTableModel.ts +8 -5
  88. package/src/types/schema.ts +8 -8
  89. package/src/util/dynamic-table.ts +12 -13
  90. package/src/util/schema.ts +4 -4
  91. package/dist/lib/browser/chunk-63UUF4IG.mjs.map +0 -7
  92. package/dist/lib/browser/chunk-RQYXNWWN.mjs.map +0 -7
  93. package/dist/lib/node-esm/chunk-K734DJB7.mjs.map +0 -7
  94. package/dist/lib/node-esm/chunk-QNDUGIS7.mjs.map +0 -7
  95. package/dist/types/src/components/Table/CreateRefPanel.d.ts +0 -9
  96. package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +0 -1
  97. package/src/components/Table/CreateRefPanel.tsx +0 -103
@@ -3,10 +3,10 @@
3
3
  //
4
4
 
5
5
  import { signal } from '@preact/signals-core';
6
- import { isNotNullable } from 'effect/Predicate';
6
+ import * as Predicate from 'effect/Predicate';
7
7
 
8
8
  import { Obj } from '@dxos/echo';
9
- import { FormatEnum, TypeEnum, getValue } from '@dxos/echo-schema';
9
+ import { FormatEnum, TypeEnum, getValue } from '@dxos/echo/internal';
10
10
  import { cellClassesForFieldType, formatForDisplay } from '@dxos/react-ui-form';
11
11
  import {
12
12
  type DxGridCellValue,
@@ -190,7 +190,7 @@ export class TablePresentation<T extends TableRow = TableRow> {
190
190
 
191
191
  const tags = targetArray
192
192
  .map(getLabel)
193
- .filter(isNotNullable)
193
+ .filter(Predicate.isNotNullable)
194
194
  .map((title) => {
195
195
  return `<span class="dx-tag" data-hue="neutral">${title}</span>`;
196
196
  })
@@ -205,7 +205,7 @@ export class TablePresentation<T extends TableRow = TableRow> {
205
205
  const targetObj = getValue(obj, field.path)?.target;
206
206
  if (targetObj) {
207
207
  const dxn = Obj.getDXN(targetObj)?.toString();
208
- cell.accessoryHtml = `<dx-ref-tag refId=${dxn} class="dx-button is-6 pli-[3px] pbe-[2px] min-bs-0 absolute inline-end-2 block-start-[.2rem]" data-dx-grid-action="accessory"><dx-icon icon="ph--link-simple--regular"/></dx-ref-tag>`;
208
+ cell.accessoryHtml = `<div role="none" class="absolute inline-end-0 inset-block-0 p-[--dx-grid-cell-content-padding-block]"><dx-anchor refId=${dxn} class="dx-button is-6 aspect-square min-bs-0" data-dx-grid-action="accessory"><dx-icon icon="ph--link-simple--regular"/></dx-anchor></div>`;
209
209
  }
210
210
  }
211
211
 
@@ -468,7 +468,6 @@ export const cellClassesForRowSelection = (selected: boolean, selectionMode: Sel
468
468
 
469
469
  switch (selectionMode) {
470
470
  case 'single':
471
- // TODO(ZaymonFC): @thure, do we need a grid version of 'currentRelated'?
472
471
  return ['!bg-currentRelated dx-grid__cell--no-focus-unfurl hover:bg-hoverSurface !cursor-pointer'];
473
472
  case 'multiple':
474
473
  return ['!bg-gridCellSelected'];
@@ -5,12 +5,21 @@
5
5
  import { type ReadonlySignal, type Signal, computed, signal } from '@preact/signals-core';
6
6
  import orderBy from 'lodash.orderby';
7
7
 
8
- import { type FieldSortType, FormatEnum, type SortDirectionType, TypeEnum, getValue } from '@dxos/echo-schema';
8
+ import { FormatEnum, TypeEnum, getValue } from '@dxos/echo/internal';
9
9
  import { formatForDisplay } from '@dxos/react-ui-form';
10
- import type { DataType, FieldType, ProjectionModel, PropertyType } from '@dxos/schema';
10
+ import {
11
+ type FieldSortType,
12
+ type FieldType,
13
+ type ProjectionModel,
14
+ type PropertyType,
15
+ type SortDirectionType,
16
+ type View,
17
+ } from '@dxos/schema';
11
18
 
12
19
  import { type TableRow } from './table-model';
13
20
 
21
+ // TODO(wittjosiah): Remove. Use ordering in queries instead.
22
+
14
23
  /**
15
24
  * Represents the local sort state.
16
25
  * - undefined: No local sort set, fallback to view sort.
@@ -49,13 +58,13 @@ export class TableSorting<T extends TableRow> {
49
58
 
50
59
  constructor(
51
60
  rows: Signal<T[]>,
52
- private readonly _view: DataType.View,
61
+ private readonly _view: View.View,
53
62
  private readonly _projection: ProjectionModel,
54
63
  ) {
55
64
  this._rows = rows;
56
65
  this._isDirty = computed(() => {
57
66
  const local = this._localSort.value;
58
- const viewSort = this._view.query.sort?.[0];
67
+ const viewSort = this._view.sort?.[0];
59
68
  if (local?.type === 'cleared') {
60
69
  return viewSort !== undefined;
61
70
  }
@@ -83,7 +92,7 @@ export class TableSorting<T extends TableRow> {
83
92
  return local.sort;
84
93
  }
85
94
 
86
- return this._view.query.sort?.[0];
95
+ return this._view.sort?.[0];
87
96
  }
88
97
 
89
98
  /**
@@ -129,9 +138,9 @@ export class TableSorting<T extends TableRow> {
129
138
  public save(): void {
130
139
  if (this._localSort.value !== undefined) {
131
140
  if (this._localSort.value.type === 'active') {
132
- this._view.query.sort = [this._localSort.value.sort];
141
+ this._view.sort = [this._localSort.value.sort];
133
142
  } else {
134
- this._view.query.sort = [];
143
+ this._view.sort = [];
135
144
  }
136
145
  this._localSort.value = undefined;
137
146
  }
@@ -59,6 +59,6 @@ export class TableManager {
59
59
  await this.page.getByLabel(`format ${format}`).click();
60
60
  await this.page.getByPlaceholder('Property label.').click();
61
61
  await this.page.getByPlaceholder('Property label.').fill(label);
62
- await this.page.getByRole('button', { name: 'button save' }).click();
62
+ await this.page.getByRole('button', { name: 'save button' }).click();
63
63
  }
64
64
  }
@@ -159,7 +159,8 @@ test.describe('Table', () => {
159
159
  await page.close();
160
160
  });
161
161
 
162
- test('extant relations work as expected', async ({ browser, browserName }) => {
162
+ // TODO(wittjosiah): Remove? Conflicts with story play function which is run as a unit test anyways.
163
+ test.skip('extant relations work as expected', async ({ browser, browserName }) => {
163
164
  test.skip(browserName === 'webkit');
164
165
  test.skip(browserName === 'firefox');
165
166
  const { page } = await setupPage(browser, { url: relationsStoryUrl });
@@ -187,7 +188,7 @@ test.describe('Table', () => {
187
188
  // Click on the combobox to open options
188
189
  await page.getByRole('combobox').click();
189
190
  await page.pause();
190
- await page.getByPlaceholder('Search...').focus();
191
+ await page.getByPlaceholder('Search…').focus();
191
192
 
192
193
  // Type the first few letters of an org name.
193
194
  const orgName =
@@ -213,7 +214,8 @@ test.describe('Table', () => {
213
214
  await page.close();
214
215
  });
215
216
 
216
- test('new relations work as expected', async ({ browser, browserName }) => {
217
+ // TODO(wittjosiah): Remove? Conflicts with story play function which is run as a unit test anyways.
218
+ test.skip('new relations work as expected', async ({ browser, browserName }) => {
217
219
  test.skip(browserName === 'webkit');
218
220
  test.skip(browserName === 'firefox');
219
221
  const { page } = await setupPage(browser, { url: relationsStoryUrl });
@@ -240,7 +242,7 @@ test.describe('Table', () => {
240
242
 
241
243
  // Click on the combobox to open options
242
244
  await page.getByRole('combobox').click();
243
- await page.getByPlaceholder('Search...').focus();
245
+ await page.getByPlaceholder('Search…').focus();
244
246
 
245
247
  // Type the first few letters of an org name.
246
248
  const orgName = 'Sally';
@@ -254,7 +256,7 @@ test.describe('Table', () => {
254
256
  await page.pause();
255
257
 
256
258
  // Click the save button in the popover
257
- await page.getByTestId('save-button').click();
259
+ await page.getByTestId('create-referenced-object-form').getByTestId('save-button').click();
258
260
 
259
261
  // Assert that the cell element has the org name
260
262
  await expect(targetCell).toHaveText(orgName);
@@ -4,13 +4,13 @@
4
4
 
5
5
  import { useCallback, useMemo, useRef } from 'react';
6
6
 
7
- import { isMutable, toJsonSchema } from '@dxos/echo-schema';
7
+ import { isMutable, toJsonSchema } from '@dxos/echo/internal';
8
8
  import { useGlobalFilteredObjects } from '@dxos/plugin-search';
9
9
  import { faker } from '@dxos/random';
10
10
  import { useClient } from '@dxos/react-client';
11
11
  import { Filter, useQuery, useSchema } from '@dxos/react-client/echo';
12
12
  import { useClientProvider } from '@dxos/react-client/testing';
13
- import { DataType, ProjectionModel } from '@dxos/schema';
13
+ import { ProjectionModel, View, getTypenameFromQuery } from '@dxos/schema';
14
14
 
15
15
  import { type TableController } from '../components';
16
16
  import { useAddRow, useTableModel } from '../hooks';
@@ -26,14 +26,17 @@ export const useTestTableModel = () => {
26
26
  const client = useClient();
27
27
  const { space } = useClientProvider();
28
28
 
29
- const views = useQuery(space, Filter.type(DataType.View));
29
+ const views = useQuery(space, Filter.type(View.View));
30
30
  const view = useMemo(() => views.at(0), [views]);
31
- const schema = useSchema(client, space, view?.query.typename);
31
+ const typename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;
32
+ const schema = useSchema(client, space, typename);
32
33
  const jsonSchema = useMemo(() => (schema ? toJsonSchema(schema) : undefined), [schema]);
33
34
 
34
35
  const projection = useMemo(() => {
35
36
  if (schema && view?.projection) {
36
- return new ProjectionModel(toJsonSchema(schema), view.projection);
37
+ const projection = new ProjectionModel(toJsonSchema(schema), view.projection);
38
+ projection.normalizeView();
39
+ return projection;
37
40
  }
38
41
  }, [schema, view?.projection]);
39
42
 
@@ -2,14 +2,14 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
- import { Match } from 'effect';
5
+ import * as Match from 'effect/Match';
6
+ import * as Schema from 'effect/Schema';
7
7
 
8
8
  import { Obj, Type } from '@dxos/echo';
9
- import { JsonPath, type JsonSchemaType, toEffectSchema } from '@dxos/echo-schema';
10
- import { ViewAnnotation } from '@dxos/echo-schema';
9
+ import { JsonPath, type JsonSchemaType, toEffectSchema } from '@dxos/echo/internal';
10
+ import { ViewAnnotation } from '@dxos/echo/internal';
11
11
  import { type SimpleType } from '@dxos/effect';
12
- import { type CreateViewFromSpaceProps, type DataType, createViewFromSpace, getSchemaProperties } from '@dxos/schema';
12
+ import { View, getSchemaProperties } from '@dxos/schema';
13
13
 
14
14
  export const Table = Schema.Struct({
15
15
  sizes: Schema.Record({
@@ -31,7 +31,7 @@ export type Table = Schema.Schema.Type<typeof Table>;
31
31
  */
32
32
  export const make = (props: Partial<Obj.MakeProps<typeof Table>> = {}) => Obj.make(Table, { sizes: {}, ...props });
33
33
 
34
- type MakeViewProps = Omit<CreateViewFromSpaceProps, 'presentation'> & {
34
+ type MakeViewProps = Omit<View.MakeFromSpaceProps, 'presentation'> & {
35
35
  sizes?: Record<string, number>;
36
36
  };
37
37
 
@@ -40,11 +40,11 @@ export const makeView = async ({
40
40
  ...props
41
41
  }: MakeViewProps): Promise<{
42
42
  jsonSchema: JsonSchemaType;
43
- view: DataType.View;
43
+ view: View.View;
44
44
  schema: ReturnType<typeof toEffectSchema>;
45
45
  }> => {
46
46
  const table = Obj.make(Table, { sizes: {} });
47
- const { jsonSchema, view } = await createViewFromSpace({ ...props, presentation: table });
47
+ const { jsonSchema, view } = await View.makeFromSpace({ ...props, presentation: table });
48
48
 
49
49
  // Preset sizes.
50
50
  const schema = toEffectSchema(jsonSchema);
@@ -2,16 +2,16 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type Schema } from 'effect';
5
+ import type * as Schema from 'effect/Schema';
6
6
 
7
- import { Obj } from '@dxos/echo';
8
- import { getTypename, toJsonSchema } from '@dxos/echo-schema';
9
- import type { JsonSchemaType, SortDirectionType } from '@dxos/echo-schema';
7
+ import { Filter, Obj, Query } from '@dxos/echo';
8
+ import { getTypename, toJsonSchema } from '@dxos/echo/internal';
9
+ import type { JsonSchemaType } from '@dxos/echo/internal';
10
10
  import {
11
- type DataType,
12
11
  ProjectionModel,
13
12
  type SchemaPropertyDefinition,
14
- createView,
13
+ type SortDirectionType,
14
+ View,
15
15
  getSchemaFromPropertyDefinitions,
16
16
  } from '@dxos/schema';
17
17
 
@@ -54,23 +54,22 @@ export const getBaseSchema = ({
54
54
  };
55
55
 
56
56
  export const makeDynamicTable = ({
57
- typename,
58
57
  jsonSchema,
59
58
  properties,
60
59
  }: {
61
- typename: string;
62
60
  jsonSchema: JsonSchemaType;
63
61
  properties?: TablePropertyDefinition[];
64
- }): { projection: ProjectionModel; view: DataType.View } => {
62
+ }): { projection: ProjectionModel; view: View.View } => {
65
63
  const table = Obj.make(Table.Table, { sizes: {} });
66
- const view = createView({
67
- typename,
64
+ const view = View.make({
65
+ query: Query.select(Filter.everything()),
68
66
  jsonSchema,
69
67
  presentation: table,
70
68
  ...(properties && { fields: properties.map((property) => property.name) }),
71
69
  });
72
70
 
73
71
  const projection = new ProjectionModel(jsonSchema, view.projection);
72
+ projection.normalizeView();
74
73
  if (properties && projection.fields) {
75
74
  setProperties(view, projection, table, properties);
76
75
  }
@@ -79,7 +78,7 @@ export const makeDynamicTable = ({
79
78
  };
80
79
 
81
80
  const setProperties = (
82
- view: DataType.View,
81
+ view: View.View,
83
82
  projection: ProjectionModel,
84
83
  table: Table.Table,
85
84
  properties: TablePropertyDefinition[],
@@ -101,7 +100,7 @@ const setProperties = (
101
100
 
102
101
  if (property.sort) {
103
102
  const fieldId = field.id;
104
- view.query.sort = [{ fieldId, direction: property.sort }];
103
+ view.sort = [{ fieldId, direction: property.sort }];
105
104
  }
106
105
  }
107
106
  }
@@ -2,8 +2,8 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
- import { TypeLiteral, isTypeLiteral } from 'effect/SchemaAST';
5
+ import * as Schema from 'effect/Schema';
6
+ import * as SchemaAST from 'effect/SchemaAST';
7
7
 
8
8
  /**
9
9
  * Creates a narrowed schema from an original schema that only includes
@@ -20,14 +20,14 @@ export const narrowSchema = <S extends Schema.Schema.AnyNoContext>(
20
20
  ): Schema.Schema<unknown, unknown> | undefined => {
21
21
  const ast = (schema as any)?.ast;
22
22
 
23
- if (isTypeLiteral(ast)) {
23
+ if (SchemaAST.isTypeLiteral(ast)) {
24
24
  // Filter property signatures that match any of the provided paths
25
25
  const propertySignatures = ast.propertySignatures.filter((signature) => paths.includes(signature.name.toString()));
26
26
 
27
27
  // If we found at least one matching property
28
28
  if (propertySignatures.length > 0) {
29
29
  // Create a new TypeLiteral with only the matching properties
30
- const narrowType = new TypeLiteral(propertySignatures, []);
30
+ const narrowType = new SchemaAST.TypeLiteral(propertySignatures, []);
31
31
  return Schema.make(narrowType);
32
32
  }
33
33
  }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types/schema.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\nimport { Match } from 'effect';\n\nimport { Obj, Type } from '@dxos/echo';\nimport { JsonPath, type JsonSchemaType, toEffectSchema } from '@dxos/echo-schema';\nimport { ViewAnnotation } from '@dxos/echo-schema';\nimport { type SimpleType } from '@dxos/effect';\nimport { type CreateViewFromSpaceProps, type DataType, createViewFromSpace, getSchemaProperties } from '@dxos/schema';\n\nexport const Table = Schema.Struct({\n sizes: Schema.Record({\n key: JsonPath,\n value: Schema.Number,\n }).pipe(Schema.mutable),\n}).pipe(\n Type.Obj({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n }),\n ViewAnnotation.set(true),\n);\n\nexport type Table = Schema.Schema.Type<typeof Table>;\n\n/**\n * Make a table view.\n */\nexport const make = (props: Partial<Obj.MakeProps<typeof Table>> = {}) => Obj.make(Table, { sizes: {}, ...props });\n\ntype MakeViewProps = Omit<CreateViewFromSpaceProps, 'presentation'> & {\n sizes?: Record<string, number>;\n};\n\nexport const makeView = async ({\n sizes,\n ...props\n}: MakeViewProps): Promise<{\n jsonSchema: JsonSchemaType;\n view: DataType.View;\n schema: ReturnType<typeof toEffectSchema>;\n}> => {\n const table = Obj.make(Table, { sizes: {} });\n const { jsonSchema, view } = await createViewFromSpace({ ...props, presentation: table });\n\n // Preset sizes.\n const schema = toEffectSchema(jsonSchema);\n const shouldIncludeId = props.fields?.find((field) => field === 'id') !== undefined;\n const properties = getSchemaProperties(schema.ast, {}, shouldIncludeId);\n for (const property of properties) {\n if (sizes?.[property.name]) {\n table.sizes[property.name as JsonPath] = sizes[property.name];\n continue;\n }\n\n Match.type<SimpleType>().pipe(\n Match.when('boolean', () => {\n table.sizes[property.name as JsonPath] = 100;\n }),\n Match.when('number', () => {\n table.sizes[property.name as JsonPath] = 100;\n }),\n Match.orElse(() => {\n // Noop.\n }),\n )(property.type);\n }\n\n return { jsonSchema, schema, view };\n};\n"],
5
- "mappings": ";;;;;;;AAAA;;;;;;AAIA,SAASA,cAAc;AACvB,SAASC,aAAa;AAEtB,SAASC,KAAKC,YAAY;AAC1B,SAASC,UAA+BC,sBAAsB;AAC9D,SAASC,sBAAsB;AAE/B,SAAuDC,qBAAqBC,2BAA2B;AAEhG,IAAMC,QAAQC,OAAOC,OAAO;EACjCC,OAAOF,OAAOG,OAAO;IACnBC,KAAKC;IACLC,OAAON,OAAOO;EAChB,CAAA,EAAGC,KAAKR,OAAOS,OAAO;AACxB,CAAA,EAAGD,KACDE,KAAKC,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,GACAC,eAAeC,IAAI,IAAA,CAAA;AAQd,IAAMC,OAAO,CAACC,QAA8C,CAAC,MAAMN,IAAIK,KAAKjB,OAAO;EAAEG,OAAO,CAAC;EAAG,GAAGe;AAAM,CAAA;AAMzG,IAAMC,WAAW,OAAO,EAC7BhB,OACA,GAAGe,MAAAA,MACW;AAKd,QAAME,QAAQR,IAAIK,KAAKjB,OAAO;IAAEG,OAAO,CAAC;EAAE,CAAA;AAC1C,QAAM,EAAEkB,YAAYC,KAAI,IAAK,MAAMC,oBAAoB;IAAE,GAAGL;IAAOM,cAAcJ;EAAM,CAAA;AAGvF,QAAMK,SAASC,eAAeL,UAAAA;AAC9B,QAAMM,kBAAkBT,MAAMU,QAAQC,KAAK,CAACC,UAAUA,UAAU,IAAA,MAAUC;AAC1E,QAAMC,aAAaC,oBAAoBR,OAAOS,KAAK,CAAC,GAAGP,eAAAA;AACvD,aAAWQ,YAAYH,YAAY;AACjC,QAAI7B,QAAQgC,SAASC,IAAI,GAAG;AAC1BhB,YAAMjB,MAAMgC,SAASC,IAAI,IAAgBjC,MAAMgC,SAASC,IAAI;AAC5D;IACF;AAEAC,UAAMC,KAAI,EAAe7B,KACvB4B,MAAME,KAAK,WAAW,MAAA;AACpBnB,YAAMjB,MAAMgC,SAASC,IAAI,IAAgB;IAC3C,CAAA,GACAC,MAAME,KAAK,UAAU,MAAA;AACnBnB,YAAMjB,MAAMgC,SAASC,IAAI,IAAgB;IAC3C,CAAA,GACAC,MAAMG,OAAO,MAAA;IAEb,CAAA,CAAA,EACAL,SAASG,IAAI;EACjB;AAEA,SAAO;IAAEjB;IAAYI;IAAQH;EAAK;AACpC;",
6
- "names": ["Schema", "Match", "Obj", "Type", "JsonPath", "toEffectSchema", "ViewAnnotation", "createViewFromSpace", "getSchemaProperties", "Table", "Schema", "Struct", "sizes", "Record", "key", "JsonPath", "value", "Number", "pipe", "mutable", "Type", "Obj", "typename", "version", "ViewAnnotation", "set", "make", "props", "makeView", "table", "jsonSchema", "view", "createViewFromSpace", "presentation", "schema", "toEffectSchema", "shouldIncludeId", "fields", "find", "field", "undefined", "properties", "getSchemaProperties", "ast", "property", "name", "Match", "type", "when", "orElse"]
7
- }