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

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 (41) hide show
  1. package/dist/lib/browser/chunk-YWNRUF4J.mjs +26 -0
  2. package/dist/lib/browser/chunk-YWNRUF4J.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +10 -11
  4. package/dist/lib/browser/index.mjs.map +3 -3
  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-2QLLIPZK.cjs → chunk-TGG6OZ54.cjs} +11 -13
  8. package/dist/lib/node/chunk-TGG6OZ54.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +60 -61
  10. package/dist/lib/node/index.cjs.map +3 -3
  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-N2RRVR7F.mjs → chunk-KKLP54L3.mjs} +9 -11
  15. package/dist/lib/node-esm/chunk-KKLP54L3.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +10 -11
  17. package/dist/lib/node-esm/index.mjs.map +3 -3
  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.stories.d.ts.map +1 -1
  22. package/dist/types/src/components/Table/relations.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/testing.d.ts +39 -39
  24. package/dist/types/src/components/testing.d.ts.map +1 -1
  25. package/dist/types/src/types/table.d.ts +42 -42
  26. package/dist/types/src/types/table.d.ts.map +1 -1
  27. package/dist/types/src/util/table.d.ts +2 -2
  28. package/dist/types/src/util/table.d.ts.map +1 -1
  29. package/package.json +33 -35
  30. package/src/components/Table/CreateRefPanel.tsx +3 -3
  31. package/src/components/Table/Table.stories.tsx +2 -1
  32. package/src/components/Table/relations.stories.tsx +9 -10
  33. package/src/components/testing.ts +6 -7
  34. package/src/model/table-model.test.ts +3 -4
  35. package/src/model/table-presentation.test.ts +3 -4
  36. package/src/types/table.ts +8 -16
  37. package/src/util/table.ts +7 -7
  38. package/dist/lib/browser/chunk-UGGYKLOH.mjs +0 -28
  39. package/dist/lib/browser/chunk-UGGYKLOH.mjs.map +0 -7
  40. package/dist/lib/node/chunk-2QLLIPZK.cjs.map +0 -7
  41. package/dist/lib/node-esm/chunk-N2RRVR7F.mjs.map +0 -7
@@ -5,15 +5,14 @@
5
5
  import '@dxos-theme';
6
6
 
7
7
  import { type StoryObj, type Meta } from '@storybook/react';
8
- import { SchemaAST } from 'effect';
9
8
  import React, { useEffect, useMemo } from 'react';
10
9
 
11
- import { type BaseObject, ImmutableSchema, type BaseSchema, type HasId } from '@dxos/echo-schema';
10
+ import { AST, type BaseObject, ImmutableSchema, type BaseSchema, type HasId } from '@dxos/echo-schema';
12
11
  import { getAnnotation } from '@dxos/effect';
13
12
  import { faker } from '@dxos/random';
14
13
  import { live, makeRef } from '@dxos/react-client/echo';
15
14
  import { useClientProvider, withClientProvider } from '@dxos/react-client/testing';
16
- import { DataType, createView, ViewProjection, ViewType } from '@dxos/schema';
15
+ import { Contact, createView, Organization, ViewProjection, ViewType } from '@dxos/schema';
17
16
  import { createAsyncGenerator, type ValueGenerator } from '@dxos/schema/testing';
18
17
  import { withLayout, withTheme } from '@dxos/storybook-utils';
19
18
 
@@ -34,9 +33,9 @@ const useTestModel = <T extends BaseObject & HasId>(schema: BaseSchema<T>, count
34
33
  const { space } = useClientProvider();
35
34
 
36
35
  const table = useMemo(() => {
37
- // const { typename } = pipe(schema.ast, SchemaAST.getAnnotation<TypeAnnotation>(TypeAnnotationId), Option.getOrThrow);
36
+ // const { typename } = pipe(schema.ast, AST.getAnnotation<TypeAnnotation>(TypeAnnotationId), Option.getOrThrow);
38
37
  const typename = schema.typename;
39
- const name = getAnnotation<string>(SchemaAST.TitleAnnotationId)(schema.ast) ?? typename;
38
+ const name = getAnnotation<string>(AST.TitleAnnotationId)(schema.ast) ?? typename;
40
39
  const view = createView({ name, typename, jsonSchema: schema.jsonSchema });
41
40
  return live(TableType, { view: makeRef(view) });
42
41
  }, [schema]);
@@ -82,12 +81,12 @@ const useTestModel = <T extends BaseObject & HasId>(schema: BaseSchema<T>, count
82
81
 
83
82
  const DefaultStory = () => {
84
83
  // TODO(burdon): Remove need for ImmutableSchema wrapper at API-level.
85
- const orgSchema = useMemo(() => new ImmutableSchema(DataType.Organization), []);
86
- const { model: orgModel, presentation: orgPresentation } = useTestModel<DataType.Organization>(orgSchema, 50);
84
+ const orgSchema = useMemo(() => new ImmutableSchema(Organization), []);
85
+ const { model: orgModel, presentation: orgPresentation } = useTestModel<Organization>(orgSchema, 50);
87
86
 
88
87
  // TODO(burdon): Generate links with references.
89
- const contactSchema = useMemo(() => new ImmutableSchema(DataType.Person), []);
90
- const { model: contactModel, presentation: contactPresentation } = useTestModel<DataType.Person>(contactSchema, 50);
88
+ const contactSchema = useMemo(() => new ImmutableSchema(Contact), []);
89
+ const { model: contactModel, presentation: contactPresentation } = useTestModel<Contact>(contactSchema, 50);
91
90
 
92
91
  return (
93
92
  <div className='is-full bs-full grid grid-cols-2 divide-x divide-separator'>
@@ -107,7 +106,7 @@ const meta: Meta<typeof DefaultStory> = {
107
106
  parameters: { translations },
108
107
  decorators: [
109
108
  withClientProvider({
110
- types: [TableType, ViewType, DataType.Organization, DataType.Person],
109
+ types: [TableType, ViewType, Organization, Contact],
111
110
  createIdentity: true,
112
111
  createSpace: true,
113
112
  }),
@@ -2,10 +2,9 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import { useEffect } from 'react';
7
6
 
8
- import { setValue, toJsonSchema, TypeEnum, TypedObject, FormatEnum, ObjectId } from '@dxos/echo-schema';
7
+ import { setValue, toJsonSchema, S, TypeEnum, TypedObject, FormatEnum } from '@dxos/echo-schema';
9
8
  import { faker } from '@dxos/random';
10
9
  import { live, makeRef } from '@dxos/react-client/echo';
11
10
  import { createView, type ViewProjection } from '@dxos/schema';
@@ -13,11 +12,11 @@ import { createView, type ViewProjection } from '@dxos/schema';
13
12
  import { TableType } from '../types';
14
13
 
15
14
  export const TestSchema = TypedObject({ typename: 'example.com/type/Test', version: '0.1.0' })({
16
- id: ObjectId,
17
- name: Schema.optional(Schema.String),
18
- age: Schema.optional(Schema.Number),
19
- active: Schema.optional(Schema.Boolean),
20
- netWorth: Schema.optional(Schema.Number),
15
+ id: S.String,
16
+ name: S.optional(S.String),
17
+ age: S.optional(S.Number),
18
+ active: S.optional(S.Boolean),
19
+ netWorth: S.optional(S.Number),
21
20
  });
22
21
 
23
22
  export const createTable = (schema = TestSchema) => {
@@ -3,10 +3,9 @@
3
3
  //
4
4
 
5
5
  import { computed } from '@preact/signals-core';
6
- import { Schema } from 'effect';
7
6
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
8
7
 
9
- import { TypedObject } from '@dxos/echo-schema';
8
+ import { S, TypedObject } from '@dxos/echo-schema';
10
9
  import { updateCounter } from '@dxos/echo-schema/testing';
11
10
  import { registerSignalsRuntime } from '@dxos/echo-signals';
12
11
  import { createEchoSchema } from '@dxos/live-object/testing';
@@ -100,8 +99,8 @@ describe('TableModel', () => {
100
99
  });
101
100
 
102
101
  class Test extends TypedObject({ typename: 'example.com/type/Test', version: '0.1.0' })({
103
- title: Schema.String,
104
- completed: Schema.Boolean,
102
+ title: S.String,
103
+ completed: S.Boolean,
105
104
  }) {}
106
105
 
107
106
  const createTableModel = (props: Partial<TableModelProps> = {}): TableModel => {
@@ -2,10 +2,9 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import { describe, expect, it, beforeEach } from 'vitest';
7
6
 
8
- import { TypedObject } from '@dxos/echo-schema';
7
+ import { S, TypedObject } from '@dxos/echo-schema';
9
8
  import { live, makeRef } from '@dxos/live-object';
10
9
  import { createEchoSchema } from '@dxos/live-object/testing';
11
10
  import { createView, ViewProjection } from '@dxos/schema';
@@ -90,8 +89,8 @@ describe('TablePresentation', () => {
90
89
  });
91
90
 
92
91
  class Test extends TypedObject({ typename: 'example.com/type/Test', version: '0.1.0' })({
93
- title: Schema.String,
94
- completed: Schema.Boolean,
92
+ title: S.String,
93
+ completed: S.Boolean,
95
94
  }) {}
96
95
 
97
96
  const createTableModel = (props: Partial<TableModelProps> = {}): TableModel => {
@@ -2,28 +2,20 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
-
7
- import { Type } from '@dxos/echo';
5
+ import { EchoObject, Expando, LabelAnnotationId, ObjectId, Ref, S } from '@dxos/echo-schema';
8
6
  // import { ThreadType } from '@dxos/plugin-space/types';
9
- import { LabelAnnotationId } from '@dxos/echo-schema';
10
7
  import { ViewType } from '@dxos/schema';
11
8
 
12
- export const TableSchema = Schema.Struct({
13
- id: Type.ObjectId,
14
- name: Schema.optional(Schema.String),
15
- view: Schema.optional(Type.Ref(ViewType)),
9
+ export const TableSchema = S.Struct({
10
+ id: ObjectId,
11
+ name: S.optional(S.String),
12
+ view: S.optional(Ref(ViewType)),
16
13
  // TODO(burdon): Document why threads is included here?
17
- threads: Schema.optional(Schema.Array(Type.Ref(Type.Expando /* ThreadType */))),
14
+ threads: S.optional(S.Array(Ref(Expando /* ThreadType */))),
18
15
  }).annotations({
19
16
  // TODO(burdon): Move annotation to property.
20
17
  [LabelAnnotationId]: 'name',
21
18
  });
22
19
 
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> {}
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> {}
package/src/util/table.ts CHANGED
@@ -2,14 +2,14 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema, SchemaAST } from 'effect';
6
-
7
5
  import {
6
+ AST,
8
7
  type EchoSchema,
9
8
  Format,
10
9
  FormatEnum,
11
10
  type JsonPath,
12
11
  type JsonProp,
12
+ S,
13
13
  TypedObject,
14
14
  TypeEnum,
15
15
  } from '@dxos/echo-schema';
@@ -34,7 +34,7 @@ export const initializeTable = async ({
34
34
  table,
35
35
  typename,
36
36
  initialRow = true,
37
- }: InitialiseTableProps): Promise<Schema.Schema.AnyNoContext> => {
37
+ }: InitialiseTableProps): Promise<S.Schema.AnyNoContext> => {
38
38
  if (typename) {
39
39
  const schema = await space.db.graph.getSchemaByTypename(typename, space.db);
40
40
  if (!schema) {
@@ -82,10 +82,10 @@ const ContactSchema = TypedObject({
82
82
  typename: `example.com/type/${PublicKey.random().truncate()}`,
83
83
  version: '0.1.0',
84
84
  })({
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' }),
85
+ name: S.optional(S.String).annotations({ [AST.TitleAnnotationId]: 'Name' }),
86
+ active: S.optional(S.Boolean),
87
+ email: S.optional(Format.Email),
88
+ salary: S.optional(Format.Currency()).annotations({ [AST.TitleAnnotationId]: 'Salary' }),
89
89
  });
90
90
 
91
91
  const ContactFields = ['name', 'email', 'salary', 'active'];
@@ -1,28 +0,0 @@
1
- // packages/ui/react-ui-table/src/types/table.ts
2
- import { Schema } from "effect";
3
- import { Type } from "@dxos/echo";
4
- import { LabelAnnotationId } from "@dxos/echo-schema";
5
- import { ViewType } from "@dxos/schema";
6
- var TableSchema = Schema.Struct({
7
- id: Type.ObjectId,
8
- name: Schema.optional(Schema.String),
9
- view: Schema.optional(Type.Ref(ViewType)),
10
- // TODO(burdon): Document why threads is included here?
11
- threads: Schema.optional(Schema.Array(Type.Ref(
12
- Type.Expando
13
- /* ThreadType */
14
- )))
15
- }).annotations({
16
- // TODO(burdon): Move annotation to property.
17
- [LabelAnnotationId]: "name"
18
- });
19
- var TableType = TableSchema.pipe(Type.def({
20
- typename: "dxos.org/type/Table",
21
- version: "0.1.0"
22
- }));
23
-
24
- export {
25
- TableSchema,
26
- TableType
27
- };
28
- //# sourceMappingURL=chunk-UGGYKLOH.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 { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { LabelAnnotationId } from '@dxos/echo-schema';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = Schema.Struct({\n id: Type.ObjectId,\n name: Schema.optional(Schema.String),\n view: Schema.optional(Type.Ref(ViewType)),\n // TODO(burdon): Document why threads is included here?\n threads: Schema.optional(Schema.Array(Type.Ref(Type.Expando /* ThreadType */))),\n}).annotations({\n // TODO(burdon): Move annotation to property.\n [LabelAnnotationId]: 'name',\n});\n\nexport const TableType = TableSchema.pipe(\n Type.def({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n }),\n);\nexport interface TableType extends Schema.Schema.Type<typeof TableType> {}\n"],
5
- "mappings": ";AAIA,SAASA,cAAc;AAEvB,SAASC,YAAY;AAErB,SAASC,yBAAyB;AAClC,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,OAAOC,OAAO;EACvCC,IAAIC,KAAKC;EACTC,MAAML,OAAOM,SAASN,OAAOO,MAAM;EACnCC,MAAMR,OAAOM,SAASH,KAAKM,IAAIC,QAAAA,CAAAA;;EAE/BC,SAASX,OAAOM,SAASN,OAAOY,MAAMT,KAAKM;IAAIN,KAAKU;;EAAsB,CAAA,CAAA;AAC5E,CAAA,EAAGC,YAAY;;EAEb,CAACC,iBAAAA,GAAoB;AACvB,CAAA;AAEO,IAAMC,YAAYjB,YAAYkB,KACnCd,KAAKe,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
6
- "names": ["Schema", "Type", "LabelAnnotationId", "ViewType", "TableSchema", "Schema", "Struct", "id", "Type", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "annotations", "LabelAnnotationId", "TableType", "pipe", "def", "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 { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { LabelAnnotationId } from '@dxos/echo-schema';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = Schema.Struct({\n id: Type.ObjectId,\n name: Schema.optional(Schema.String),\n view: Schema.optional(Type.Ref(ViewType)),\n // TODO(burdon): Document why threads is included here?\n threads: Schema.optional(Schema.Array(Type.Ref(Type.Expando /* ThreadType */))),\n}).annotations({\n // TODO(burdon): Move annotation to property.\n [LabelAnnotationId]: 'name',\n});\n\nexport const TableType = TableSchema.pipe(\n Type.def({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n }),\n);\nexport interface TableType extends Schema.Schema.Type<typeof TableType> {}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAAuB;AAEvB,kBAAqB;AAErB,yBAAkC;AAClC,oBAAyB;AAElB,IAAMA,cAAcC,qBAAOC,OAAO;EACvCC,IAAIC,iBAAKC;EACTC,MAAML,qBAAOM,SAASN,qBAAOO,MAAM;EACnCC,MAAMR,qBAAOM,SAASH,iBAAKM,IAAIC,sBAAAA,CAAAA;;EAE/BC,SAASX,qBAAOM,SAASN,qBAAOY,MAAMT,iBAAKM;IAAIN,iBAAKU;;EAAsB,CAAA,CAAA;AAC5E,CAAA,EAAGC,YAAY;;EAEb,CAACC,oCAAAA,GAAoB;AACvB,CAAA;AAEO,IAAMC,YAAYjB,YAAYkB,KACnCd,iBAAKe,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
6
- "names": ["TableSchema", "Schema", "Struct", "id", "Type", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "annotations", "LabelAnnotationId", "TableType", "pipe", "def", "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 { Schema } from 'effect';\n\nimport { Type } from '@dxos/echo';\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { LabelAnnotationId } from '@dxos/echo-schema';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = Schema.Struct({\n id: Type.ObjectId,\n name: Schema.optional(Schema.String),\n view: Schema.optional(Type.Ref(ViewType)),\n // TODO(burdon): Document why threads is included here?\n threads: Schema.optional(Schema.Array(Type.Ref(Type.Expando /* ThreadType */))),\n}).annotations({\n // TODO(burdon): Move annotation to property.\n [LabelAnnotationId]: 'name',\n});\n\nexport const TableType = TableSchema.pipe(\n Type.def({\n typename: 'dxos.org/type/Table',\n version: '0.1.0',\n }),\n);\nexport interface TableType extends Schema.Schema.Type<typeof TableType> {}\n"],
5
- "mappings": ";;;AAIA,SAASA,cAAc;AAEvB,SAASC,YAAY;AAErB,SAASC,yBAAyB;AAClC,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,OAAOC,OAAO;EACvCC,IAAIC,KAAKC;EACTC,MAAML,OAAOM,SAASN,OAAOO,MAAM;EACnCC,MAAMR,OAAOM,SAASH,KAAKM,IAAIC,QAAAA,CAAAA;;EAE/BC,SAASX,OAAOM,SAASN,OAAOY,MAAMT,KAAKM;IAAIN,KAAKU;;EAAsB,CAAA,CAAA;AAC5E,CAAA,EAAGC,YAAY;;EAEb,CAACC,iBAAAA,GAAoB;AACvB,CAAA;AAEO,IAAMC,YAAYjB,YAAYkB,KACnCd,KAAKe,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
6
- "names": ["Schema", "Type", "LabelAnnotationId", "ViewType", "TableSchema", "Schema", "Struct", "id", "Type", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "annotations", "LabelAnnotationId", "TableType", "pipe", "def", "typename", "version"]
7
- }