@dxos/react-ui-table 0.8.3 → 0.8.4-main.1f223c7
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.
- package/dist/lib/browser/chunk-63UUF4IG.mjs +66 -0
- package/dist/lib/browser/chunk-63UUF4IG.mjs.map +7 -0
- package/dist/lib/browser/chunk-BBXDTWCX.mjs +1822 -0
- package/dist/lib/browser/chunk-BBXDTWCX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +814 -2152
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +124 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +3 -5
- package/dist/lib/node-esm/chunk-K734DJB7.mjs +67 -0
- package/dist/lib/node-esm/chunk-K734DJB7.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RNQDU7IQ.mjs +1823 -0
- package/dist/lib/node-esm/chunk-RNQDU7IQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +814 -2152
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +125 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +3 -5
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts +1 -1
- package/dist/types/src/components/Table/ColumnActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/ColumnSettings.d.ts +4 -2
- package/dist/types/src/components/Table/ColumnSettings.d.ts.map +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts +1 -1
- package/dist/types/src/components/Table/CreateRefPanel.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts +1 -1
- package/dist/types/src/components/Table/DynamicTable.d.ts.map +1 -1
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts +50 -2
- package/dist/types/src/components/Table/DynamicTable.stories.d.ts.map +1 -1
- package/dist/types/src/components/Table/Relations.stories.d.ts +44 -0
- package/dist/types/src/components/Table/Relations.stories.d.ts.map +1 -0
- package/dist/types/src/components/Table/RowActionsMenu.d.ts +1 -1
- package/dist/types/src/components/Table/RowActionsMenu.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.d.ts +3 -2
- package/dist/types/src/components/Table/Table.d.ts.map +1 -1
- package/dist/types/src/components/Table/Table.stories.d.ts +42 -3
- package/dist/types/src/components/Table/Table.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts +2 -1
- package/dist/types/src/components/TableCellEditor/CellValidationMessage.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts +8 -3
- package/dist/types/src/components/TableCellEditor/FormCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts +9 -15
- package/dist/types/src/components/TableCellEditor/TableCellEditor.d.ts.map +1 -1
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts +39 -3
- package/dist/types/src/components/TableCellEditor/TableCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TableToolbar/TableToolbar.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +3 -40
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAddRow.d.ts +14 -0
- package/dist/types/src/hooks/useAddRow.d.ts.map +1 -0
- package/dist/types/src/hooks/useTableModel.d.ts +8 -7
- package/dist/types/src/hooks/useTableModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model/modal-controller.d.ts.map +1 -1
- package/dist/types/src/model/selection-model.d.ts +2 -1
- package/dist/types/src/model/selection-model.d.ts.map +1 -1
- package/dist/types/src/model/table-model.d.ts +59 -21
- package/dist/types/src/model/table-model.d.ts.map +1 -1
- package/dist/types/src/model/table-presentation.d.ts +10 -1
- package/dist/types/src/model/table-presentation.d.ts.map +1 -1
- package/dist/types/src/model/table-sorting.d.ts +3 -4
- package/dist/types/src/model/table-sorting.d.ts.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/useTestTableModel.d.ts +22 -0
- package/dist/types/src/testing/useTestTableModel.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +5 -6
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +28 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util/dynamic-table.d.ts +4 -5
- package/dist/types/src/util/dynamic-table.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/table-buttons.d.ts +15 -1
- package/dist/types/src/util/table-buttons.d.ts.map +1 -1
- package/dist/types/src/util/table-controls.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +57 -44
- package/src/components/Table/ColumnActionsMenu.tsx +1 -1
- package/src/components/Table/ColumnSettings.tsx +15 -11
- package/src/components/Table/CreateRefPanel.tsx +30 -11
- package/src/components/Table/DynamicTable.stories.tsx +8 -5
- package/src/components/Table/DynamicTable.tsx +17 -10
- package/src/components/Table/{relations.stories.tsx → Relations.stories.tsx} +56 -47
- package/src/components/Table/RowActionsMenu.tsx +3 -3
- package/src/components/Table/Table.stories.tsx +126 -159
- package/src/components/Table/Table.tsx +167 -123
- package/src/components/TableCellEditor/CellValidationMessage.tsx +7 -2
- package/src/components/TableCellEditor/FormCellEditor.tsx +158 -48
- package/src/components/TableCellEditor/TableCellEditor.stories.tsx +31 -47
- package/src/components/TableCellEditor/TableCellEditor.tsx +106 -111
- package/src/components/TableToolbar/TableToolbar.tsx +2 -2
- package/src/components/testing.ts +7 -24
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useAddRow.ts +38 -0
- package/src/hooks/useTableModel.ts +21 -17
- package/src/index.ts +1 -2
- package/src/model/modal-controller.ts +1 -1
- package/src/model/selection-model.ts +6 -3
- package/src/model/table-model.test.ts +12 -9
- package/src/model/table-model.ts +288 -88
- package/src/model/table-presentation.test.ts +12 -8
- package/src/model/table-presentation.ts +263 -138
- package/src/model/table-sorting.ts +22 -13
- package/src/playwright/playwright.config.ts +17 -0
- package/src/playwright/smoke.spec.ts +137 -44
- package/src/testing/index.ts +5 -0
- package/src/testing/useTestTableModel.ts +124 -0
- package/src/translations.ts +7 -5
- package/src/types/index.ts +2 -2
- package/src/types/schema.ts +73 -0
- package/src/util/dynamic-table.ts +24 -21
- package/src/util/index.ts +0 -1
- package/src/util/schema.ts +1 -1
- package/src/util/table-buttons.ts +28 -4
- package/src/util/table-controls.ts +4 -1
- package/dist/lib/browser/chunk-TL7CKQQV.mjs +0 -27
- package/dist/lib/browser/chunk-TL7CKQQV.mjs.map +0 -7
- package/dist/lib/node/chunk-O2VPBNS5.cjs +0 -50
- package/dist/lib/node/chunk-O2VPBNS5.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -2739
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/types/index.cjs +0 -31
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-GBT6GD4G.mjs +0 -29
- package/dist/lib/node-esm/chunk-GBT6GD4G.mjs.map +0 -7
- package/dist/types/src/components/Table/relations.stories.d.ts +0 -9
- package/dist/types/src/components/Table/relations.stories.d.ts.map +0 -1
- package/dist/types/src/components/TableCellEditor/extension.d.ts +0 -13
- package/dist/types/src/components/TableCellEditor/extension.d.ts.map +0 -1
- package/dist/types/src/types/table.d.ts +0 -56
- package/dist/types/src/types/table.d.ts.map +0 -1
- package/dist/types/src/util/table.d.ts +0 -14
- package/dist/types/src/util/table.d.ts.map +0 -1
- package/src/components/TableCellEditor/extension.ts +0 -61
- package/src/playwright/playwright.config.cts +0 -18
- package/src/types/table.ts +0 -27
- package/src/util/table.ts +0 -127
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// packages/ui/react-ui-table/src/types/table.ts
|
|
4
|
-
import { Schema } from "effect";
|
|
5
|
-
import { Type } from "@dxos/echo";
|
|
6
|
-
import { ObjectId, Ref, Expando, LabelAnnotation } from "@dxos/echo-schema";
|
|
7
|
-
import { ViewType } from "@dxos/schema";
|
|
8
|
-
var TableSchema = Schema.Struct({
|
|
9
|
-
id: ObjectId,
|
|
10
|
-
name: Schema.optional(Schema.String),
|
|
11
|
-
view: Schema.optional(Ref(ViewType)),
|
|
12
|
-
// TODO(burdon): Document why threads is included here?
|
|
13
|
-
threads: Schema.optional(Schema.Array(Ref(
|
|
14
|
-
Expando
|
|
15
|
-
/* ThreadType */
|
|
16
|
-
)))
|
|
17
|
-
}).pipe(LabelAnnotation.set([
|
|
18
|
-
"name"
|
|
19
|
-
]));
|
|
20
|
-
var TableType = TableSchema.pipe(Type.Obj({
|
|
21
|
-
typename: "dxos.org/type/Table",
|
|
22
|
-
version: "0.1.0"
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
TableSchema,
|
|
27
|
-
TableType
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=chunk-GBT6GD4G.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\n// import { ThreadType } from '@dxos/plugin-space/types';\nimport { Type } from '@dxos/echo';\nimport { ObjectId, Ref, Expando, LabelAnnotation } from '@dxos/echo-schema';\nimport { ViewType } from '@dxos/schema';\n\nexport const TableSchema = Schema.Struct({\n id: ObjectId,\n name: Schema.optional(Schema.String),\n view: Schema.optional(Ref(ViewType)),\n // TODO(burdon): Document why threads is included here?\n threads: Schema.optional(Schema.Array(Ref(Expando /* ThreadType */))),\n}).pipe(LabelAnnotation.set(['name']));\n\n// TODO(burdon): Move out of react-ui-xxx.\nexport const TableType = TableSchema.pipe(\n Type.Obj({\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;AAGvB,SAASC,YAAY;AACrB,SAASC,UAAUC,KAAKC,SAASC,uBAAuB;AACxD,SAASC,gBAAgB;AAElB,IAAMC,cAAcC,OAAOC,OAAO;EACvCC,IAAIC;EACJC,MAAMJ,OAAOK,SAASL,OAAOM,MAAM;EACnCC,MAAMP,OAAOK,SAASG,IAAIC,QAAAA,CAAAA;;EAE1BC,SAASV,OAAOK,SAASL,OAAOW,MAAMH;IAAII;;EAAsB,CAAA,CAAA;AAClE,CAAA,EAAGC,KAAKC,gBAAgBC,IAAI;EAAC;CAAO,CAAA;AAG7B,IAAMC,YAAYjB,YAAYc,KACnCI,KAAKC,IAAI;EACPC,UAAU;EACVC,SAAS;AACX,CAAA,CAAA;",
|
|
6
|
-
"names": ["Schema", "Type", "ObjectId", "Ref", "Expando", "LabelAnnotation", "ViewType", "TableSchema", "Schema", "Struct", "id", "ObjectId", "name", "optional", "String", "view", "Ref", "ViewType", "threads", "Array", "Expando", "pipe", "LabelAnnotation", "set", "TableType", "Type", "Obj", "typename", "version"]
|
|
7
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import '@dxos-theme';
|
|
2
|
-
import { type StoryObj, type Meta } from '@storybook/react';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
declare const DefaultStory: () => React.JSX.Element;
|
|
5
|
-
declare const meta: Meta<typeof DefaultStory>;
|
|
6
|
-
export default meta;
|
|
7
|
-
type Story = StoryObj<typeof DefaultStory>;
|
|
8
|
-
export declare const Default: Story;
|
|
9
|
-
//# sourceMappingURL=relations.stories.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"relations.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Table/relations.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAA6B,MAAM,OAAO,CAAC;AA+ElD,QAAA,MAAM,YAAY,yBAejB,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,YAAY,CAanC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,YAAY,CAAC,CAAC;AAE3C,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type CompletionResult } from '@codemirror/autocomplete';
|
|
2
|
-
import { type Extension } from '@codemirror/state';
|
|
3
|
-
export type CompletionOptions = {
|
|
4
|
-
debug?: boolean;
|
|
5
|
-
onQuery: (text: string) => Promise<CompletionResult['options']>;
|
|
6
|
-
onMatch: (data: any) => void;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Autocomplete Codemirror extension.
|
|
10
|
-
* https://codemirror.net/docs/ref/#autocomplete.autocompletion
|
|
11
|
-
*/
|
|
12
|
-
export declare const completion: ({ debug, onQuery, onMatch }: CompletionOptions) => Extension;
|
|
13
|
-
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../../src/components/TableCellEditor/extension.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;IAChE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,6BAA6B,iBAAiB,KAAG,SAqC3E,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
import { Type } from '@dxos/echo';
|
|
3
|
-
import { Expando } from '@dxos/echo-schema';
|
|
4
|
-
export declare const TableSchema: Schema.Struct<{
|
|
5
|
-
id: import("@dxos/keys").ObjectIdClass;
|
|
6
|
-
name: Schema.optional<typeof Schema.String>;
|
|
7
|
-
view: Schema.optional<import("@dxos/echo-schema").Ref$<import("@dxos/echo-schema").TypedObjectFields<{
|
|
8
|
-
name: Schema.SchemaClass<string, string, never>;
|
|
9
|
-
query: Schema.Schema<import("@dxos/echo-schema").QueryType, import("@dxos/echo-schema").QueryType, never>;
|
|
10
|
-
schema: Schema.optional<Schema.Schema<Type.JsonSchema, Type.JsonSchema, never>>;
|
|
11
|
-
fields: Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
12
|
-
id: typeof Schema.String;
|
|
13
|
-
path: Schema.Schema<import("@dxos/effect").JsonPath, import("@dxos/effect").JsonPath, never>;
|
|
14
|
-
visible: Schema.optional<typeof Schema.Boolean>;
|
|
15
|
-
size: Schema.optional<typeof Schema.Number>;
|
|
16
|
-
referencePath: Schema.optional<Schema.Schema<import("@dxos/effect").JsonPath, import("@dxos/effect").JsonPath, never>>;
|
|
17
|
-
}>>>>;
|
|
18
|
-
hiddenFields: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
19
|
-
id: typeof Schema.String;
|
|
20
|
-
path: Schema.Schema<import("@dxos/effect").JsonPath, import("@dxos/effect").JsonPath, never>;
|
|
21
|
-
visible: Schema.optional<typeof Schema.Boolean>;
|
|
22
|
-
size: Schema.optional<typeof Schema.Number>;
|
|
23
|
-
referencePath: Schema.optional<Schema.Schema<import("@dxos/effect").JsonPath, import("@dxos/effect").JsonPath, never>>;
|
|
24
|
-
}>>>>>;
|
|
25
|
-
metadata: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
|
|
26
|
-
}, import("@dxos/echo-schema").TypedObjectOptions>>>;
|
|
27
|
-
threads: Schema.optional<Schema.Array$<import("@dxos/echo-schema").Ref$<Expando>>>;
|
|
28
|
-
}>;
|
|
29
|
-
export declare const TableType: Type.obj<Schema.Struct<{
|
|
30
|
-
id: import("@dxos/keys").ObjectIdClass;
|
|
31
|
-
name: Schema.optional<typeof Schema.String>;
|
|
32
|
-
view: Schema.optional<import("@dxos/echo-schema").Ref$<import("@dxos/echo-schema").TypedObjectFields<{
|
|
33
|
-
name: Schema.SchemaClass<string, string, never>;
|
|
34
|
-
query: Schema.Schema<import("@dxos/echo-schema").QueryType, import("@dxos/echo-schema").QueryType, never>;
|
|
35
|
-
schema: Schema.optional<Schema.Schema<Type.JsonSchema, Type.JsonSchema, never>>;
|
|
36
|
-
fields: Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
37
|
-
id: typeof Schema.String;
|
|
38
|
-
path: Schema.Schema<import("@dxos/effect").JsonPath, import("@dxos/effect").JsonPath, never>;
|
|
39
|
-
visible: Schema.optional<typeof Schema.Boolean>;
|
|
40
|
-
size: Schema.optional<typeof Schema.Number>;
|
|
41
|
-
referencePath: Schema.optional<Schema.Schema<import("@dxos/effect").JsonPath, import("@dxos/effect").JsonPath, never>>;
|
|
42
|
-
}>>>>;
|
|
43
|
-
hiddenFields: Schema.optional<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
44
|
-
id: typeof Schema.String;
|
|
45
|
-
path: Schema.Schema<import("@dxos/effect").JsonPath, import("@dxos/effect").JsonPath, never>;
|
|
46
|
-
visible: Schema.optional<typeof Schema.Boolean>;
|
|
47
|
-
size: Schema.optional<typeof Schema.Number>;
|
|
48
|
-
referencePath: Schema.optional<Schema.Schema<import("@dxos/effect").JsonPath, import("@dxos/effect").JsonPath, never>>;
|
|
49
|
-
}>>>>>;
|
|
50
|
-
metadata: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
|
|
51
|
-
}, import("@dxos/echo-schema").TypedObjectOptions>>>;
|
|
52
|
-
threads: Schema.optional<Schema.Array$<import("@dxos/echo-schema").Ref$<Expando>>>;
|
|
53
|
-
}>>;
|
|
54
|
-
export interface TableType extends Schema.Schema.Type<typeof TableType> {
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/types/table.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAiB,OAAO,EAAmB,MAAM,mBAAmB,CAAC;AAG5E,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;EAMc,CAAC;AAGvC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;GAKrB,CAAC;AACF,MAAM,WAAW,SAAU,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC;CAAG"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
import { type Client } from '@dxos/react-client';
|
|
3
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
4
|
-
import { type TableType } from '../types';
|
|
5
|
-
type InitialiseTableProps = {
|
|
6
|
-
client: Client;
|
|
7
|
-
space: Space;
|
|
8
|
-
table: TableType;
|
|
9
|
-
typename?: string;
|
|
10
|
-
initialRow?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export declare const initializeTable: ({ client, space, table, typename, initialRow, }: InitialiseTableProps) => Promise<Schema.Schema.AnyNoContext>;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../src/util/table.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAYhC,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAQ,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,KAAK,oBAAoB,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,iDAMnC,oBAAoB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CA0C3D,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
autocompletion,
|
|
7
|
-
pickedCompletion,
|
|
8
|
-
type CompletionContext,
|
|
9
|
-
type CompletionResult,
|
|
10
|
-
} from '@codemirror/autocomplete';
|
|
11
|
-
import { type Extension } from '@codemirror/state';
|
|
12
|
-
import { EditorView } from '@codemirror/view';
|
|
13
|
-
|
|
14
|
-
export type CompletionOptions = {
|
|
15
|
-
debug?: boolean;
|
|
16
|
-
onQuery: (text: string) => Promise<CompletionResult['options']>;
|
|
17
|
-
onMatch: (data: any) => void;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Autocomplete Codemirror extension.
|
|
22
|
-
* https://codemirror.net/docs/ref/#autocomplete.autocompletion
|
|
23
|
-
*/
|
|
24
|
-
export const completion = ({ debug, onQuery, onMatch }: CompletionOptions): Extension => {
|
|
25
|
-
return [
|
|
26
|
-
EditorView.theme({
|
|
27
|
-
'.cm-completionDialog': {
|
|
28
|
-
width: 'var(--dx-gridCellWidth)',
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
|
|
32
|
-
autocompletion({
|
|
33
|
-
icons: false,
|
|
34
|
-
activateOnTyping: true,
|
|
35
|
-
closeOnBlur: !debug,
|
|
36
|
-
override: [
|
|
37
|
-
async (context: CompletionContext): Promise<CompletionResult> => {
|
|
38
|
-
const text = context.state.doc.toString();
|
|
39
|
-
return {
|
|
40
|
-
from: 0,
|
|
41
|
-
options: await onQuery(text),
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
|
|
46
|
-
// TODO(burdon): Consts from grid (to line-up with grid).
|
|
47
|
-
tooltipClass: () => 'cm-completionDialog !mt-[8px] !-ml-[4px] [&>ul]:!max-h-[264px]',
|
|
48
|
-
optionClass: () => 'flex h-[33px] items-center',
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
// Check for accepted completion metadata in the transaction.
|
|
52
|
-
EditorView.updateListener.of((update) => {
|
|
53
|
-
update.transactions.forEach((tr) => {
|
|
54
|
-
const completion = tr.annotation(pickedCompletion);
|
|
55
|
-
if (completion) {
|
|
56
|
-
onMatch((completion as any).data);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}),
|
|
60
|
-
];
|
|
61
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { nxE2EPreset } from '@nx/playwright/preset';
|
|
6
|
-
import { defineConfig } from '@playwright/test';
|
|
7
|
-
|
|
8
|
-
import { e2ePreset } from '@dxos/test-utils/playwright';
|
|
9
|
-
|
|
10
|
-
export default defineConfig({
|
|
11
|
-
...nxE2EPreset(__filename, { testDir: __dirname }),
|
|
12
|
-
...e2ePreset(__dirname),
|
|
13
|
-
webServer: {
|
|
14
|
-
command: 'pnpm -w nx storybook-e2e stories',
|
|
15
|
-
port: 9009,
|
|
16
|
-
reuseExistingServer: !process.env.CI,
|
|
17
|
-
},
|
|
18
|
-
});
|
package/src/types/table.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
// import { ThreadType } from '@dxos/plugin-space/types';
|
|
8
|
-
import { Type } from '@dxos/echo';
|
|
9
|
-
import { ObjectId, Ref, Expando, LabelAnnotation } from '@dxos/echo-schema';
|
|
10
|
-
import { ViewType } from '@dxos/schema';
|
|
11
|
-
|
|
12
|
-
export const TableSchema = Schema.Struct({
|
|
13
|
-
id: ObjectId,
|
|
14
|
-
name: Schema.optional(Schema.String),
|
|
15
|
-
view: Schema.optional(Ref(ViewType)),
|
|
16
|
-
// TODO(burdon): Document why threads is included here?
|
|
17
|
-
threads: Schema.optional(Schema.Array(Ref(Expando /* ThreadType */))),
|
|
18
|
-
}).pipe(LabelAnnotation.set(['name']));
|
|
19
|
-
|
|
20
|
-
// TODO(burdon): Move out of react-ui-xxx.
|
|
21
|
-
export const TableType = TableSchema.pipe(
|
|
22
|
-
Type.Obj({
|
|
23
|
-
typename: 'dxos.org/type/Table',
|
|
24
|
-
version: '0.1.0',
|
|
25
|
-
}),
|
|
26
|
-
);
|
|
27
|
-
export interface TableType extends Schema.Schema.Type<typeof TableType> {}
|
package/src/util/table.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
type EchoSchema,
|
|
9
|
-
Format,
|
|
10
|
-
FormatEnum,
|
|
11
|
-
type JsonPath,
|
|
12
|
-
type JsonProp,
|
|
13
|
-
Ref,
|
|
14
|
-
TypedObject,
|
|
15
|
-
TypeEnum,
|
|
16
|
-
} from '@dxos/echo-schema';
|
|
17
|
-
import { type Client, PublicKey } from '@dxos/react-client';
|
|
18
|
-
import { live, type Space } from '@dxos/react-client/echo';
|
|
19
|
-
import { createFieldId, createView, getSchemaProperties, ViewProjection, type ViewType } from '@dxos/schema';
|
|
20
|
-
|
|
21
|
-
import { type TableType } from '../types';
|
|
22
|
-
|
|
23
|
-
// TODO(ZaymonFC): We don't need the client anymore.
|
|
24
|
-
type InitialiseTableProps = {
|
|
25
|
-
client: Client;
|
|
26
|
-
space: Space;
|
|
27
|
-
table: TableType;
|
|
28
|
-
typename?: string;
|
|
29
|
-
initialRow?: boolean;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const initializeTable = async ({
|
|
33
|
-
client,
|
|
34
|
-
space,
|
|
35
|
-
table,
|
|
36
|
-
typename,
|
|
37
|
-
initialRow = true,
|
|
38
|
-
}: InitialiseTableProps): Promise<Schema.Schema.AnyNoContext> => {
|
|
39
|
-
if (typename) {
|
|
40
|
-
const schema = await space.db.graph.getSchemaByTypename(typename, space.db);
|
|
41
|
-
if (!schema) {
|
|
42
|
-
throw new Error(`Schema not found: ${typename}`);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const fields = getSchemaProperties(schema.ast).map((prop) => prop.name);
|
|
46
|
-
|
|
47
|
-
table.view = Ref.make(
|
|
48
|
-
createView({
|
|
49
|
-
// TODO(ZaymonFC): Don't hardcode name?
|
|
50
|
-
name: 'View',
|
|
51
|
-
typename: schema.typename,
|
|
52
|
-
jsonSchema: schema.jsonSchema,
|
|
53
|
-
fields,
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
return schema;
|
|
58
|
-
} else {
|
|
59
|
-
const [schema] = await space.db.schemaRegistry.register([createContactSchema()]);
|
|
60
|
-
const fields = ContactFields;
|
|
61
|
-
|
|
62
|
-
table.view = Ref.make(
|
|
63
|
-
createView({
|
|
64
|
-
name: 'View',
|
|
65
|
-
typename: schema.typename,
|
|
66
|
-
jsonSchema: schema.jsonSchema,
|
|
67
|
-
fields,
|
|
68
|
-
}),
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
createProjection(schema, table.view.target!);
|
|
72
|
-
|
|
73
|
-
if (initialRow) {
|
|
74
|
-
// TODO(burdon): Last (first) row should not be in db and should be managed by the model.
|
|
75
|
-
space.db.add(live(schema, {}));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return schema;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const createContactSchema = () =>
|
|
83
|
-
TypedObject({
|
|
84
|
-
typename: `example.com/type/${PublicKey.random().truncate()}`,
|
|
85
|
-
version: '0.1.0',
|
|
86
|
-
})({
|
|
87
|
-
name: Schema.optional(Schema.String).annotations({ title: 'Name' }),
|
|
88
|
-
active: Schema.optional(Schema.Boolean).annotations({ title: 'Active' }),
|
|
89
|
-
email: Schema.optional(Format.Email),
|
|
90
|
-
salary: Schema.optional(Format.Currency()).annotations({ title: 'Salary' }),
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const ContactFields = ['name', 'email', 'salary', 'active'];
|
|
94
|
-
|
|
95
|
-
const createProjection = (schema: EchoSchema, view: ViewType): ViewProjection => {
|
|
96
|
-
const projection = new ViewProjection(schema.jsonSchema, view);
|
|
97
|
-
projection.setFieldProjection({
|
|
98
|
-
field: {
|
|
99
|
-
id: view.fields.find((f) => f.path === 'salary')!.id,
|
|
100
|
-
path: 'salary' as JsonPath,
|
|
101
|
-
size: 150,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
projection.setFieldProjection({
|
|
105
|
-
field: {
|
|
106
|
-
id: view.fields.find((f) => f.path === 'active')!.id,
|
|
107
|
-
path: 'active' as JsonPath,
|
|
108
|
-
size: 100,
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
projection.setFieldProjection({
|
|
112
|
-
field: {
|
|
113
|
-
id: createFieldId(),
|
|
114
|
-
path: 'manager' as JsonPath,
|
|
115
|
-
referencePath: 'name' as JsonPath,
|
|
116
|
-
},
|
|
117
|
-
props: {
|
|
118
|
-
property: 'manager' as JsonProp,
|
|
119
|
-
type: TypeEnum.Ref,
|
|
120
|
-
format: FormatEnum.Ref,
|
|
121
|
-
referenceSchema: schema.typename,
|
|
122
|
-
title: 'Manager',
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
return projection;
|
|
127
|
-
};
|