@dxos/plugin-kanban 0.7.4 → 0.7.5-main.499c70c

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 (81) hide show
  1. package/dist/lib/browser/chunk-JZBAL6SW.mjs +56 -0
  2. package/dist/lib/browser/chunk-JZBAL6SW.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +218 -109
  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.mjs +12 -0
  7. package/dist/lib/node/chunk-BE2FRW7E.cjs +77 -0
  8. package/dist/lib/node/chunk-BE2FRW7E.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +210 -102
  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 → types.cjs} +8 -10
  13. package/dist/lib/node/types.cjs.map +7 -0
  14. package/dist/lib/node-esm/chunk-L7JM7LGJ.mjs +57 -0
  15. package/dist/lib/node-esm/chunk-L7JM7LGJ.mjs.map +7 -0
  16. package/dist/lib/node-esm/index.mjs +218 -109
  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.mjs +13 -0
  20. package/dist/types/src/KanbanPlugin.d.ts.map +1 -1
  21. package/dist/types/src/components/KanbanContainer.d.ts +7 -0
  22. package/dist/types/src/components/KanbanContainer.d.ts.map +1 -0
  23. package/dist/types/src/components/KanbanViewEditor.d.ts +8 -0
  24. package/dist/types/src/components/KanbanViewEditor.d.ts.map +1 -0
  25. package/dist/types/src/components/index.d.ts +1 -3
  26. package/dist/types/src/components/index.d.ts.map +1 -1
  27. package/dist/types/src/translations.d.ts +32 -0
  28. package/dist/types/src/translations.d.ts.map +1 -1
  29. package/dist/types/src/types.d.ts +61 -0
  30. package/dist/types/src/types.d.ts.map +1 -0
  31. package/dist/types/tsconfig.tsbuildinfo +1 -0
  32. package/package.json +21 -23
  33. package/src/KanbanPlugin.tsx +50 -78
  34. package/src/components/KanbanContainer.tsx +79 -0
  35. package/src/components/KanbanViewEditor.tsx +72 -0
  36. package/src/components/index.ts +2 -4
  37. package/src/translations.ts +8 -2
  38. package/src/{types/types.ts → types.ts} +42 -11
  39. package/dist/lib/browser/KanbanMain-I5TMXNIY.mjs +0 -444
  40. package/dist/lib/browser/KanbanMain-I5TMXNIY.mjs.map +0 -7
  41. package/dist/lib/browser/chunk-4Y4TZ47E.mjs +0 -47
  42. package/dist/lib/browser/chunk-4Y4TZ47E.mjs.map +0 -7
  43. package/dist/lib/browser/types/index.mjs +0 -14
  44. package/dist/lib/node/KanbanMain-4OWAWTS4.cjs +0 -453
  45. package/dist/lib/node/KanbanMain-4OWAWTS4.cjs.map +0 -7
  46. package/dist/lib/node/chunk-LTR4WYI2.cjs +0 -67
  47. package/dist/lib/node/chunk-LTR4WYI2.cjs.map +0 -7
  48. package/dist/lib/node/types/index.cjs.map +0 -7
  49. package/dist/lib/node-esm/KanbanMain-PJC2JMJH.mjs +0 -445
  50. package/dist/lib/node-esm/KanbanMain-PJC2JMJH.mjs.map +0 -7
  51. package/dist/lib/node-esm/chunk-2ZBX5F7L.mjs +0 -48
  52. package/dist/lib/node-esm/chunk-2ZBX5F7L.mjs.map +0 -7
  53. package/dist/lib/node-esm/types/index.mjs +0 -15
  54. package/dist/types/src/components/KanbanBoard.d.ts +0 -6
  55. package/dist/types/src/components/KanbanBoard.d.ts.map +0 -1
  56. package/dist/types/src/components/KanbanCard.d.ts +0 -9
  57. package/dist/types/src/components/KanbanCard.d.ts.map +0 -1
  58. package/dist/types/src/components/KanbanColumn.d.ts +0 -14
  59. package/dist/types/src/components/KanbanColumn.d.ts.map +0 -1
  60. package/dist/types/src/components/KanbanMain.d.ts +0 -7
  61. package/dist/types/src/components/KanbanMain.d.ts.map +0 -1
  62. package/dist/types/src/components/util.d.ts +0 -7
  63. package/dist/types/src/components/util.d.ts.map +0 -1
  64. package/dist/types/src/stories/testing.d.ts +0 -19
  65. package/dist/types/src/stories/testing.d.ts.map +0 -1
  66. package/dist/types/src/types/index.d.ts +0 -3
  67. package/dist/types/src/types/index.d.ts.map +0 -1
  68. package/dist/types/src/types/kanban.d.ts +0 -76
  69. package/dist/types/src/types/kanban.d.ts.map +0 -1
  70. package/dist/types/src/types/types.d.ts +0 -18
  71. package/dist/types/src/types/types.d.ts.map +0 -1
  72. package/src/components/KanbanBoard.tsx +0 -195
  73. package/src/components/KanbanCard.tsx +0 -82
  74. package/src/components/KanbanColumn.tsx +0 -143
  75. package/src/components/KanbanMain.tsx +0 -37
  76. package/src/components/util.ts +0 -38
  77. package/src/stories/testing.ts +0 -29
  78. package/src/types/index.ts +0 -6
  79. package/src/types/kanban.ts +0 -22
  80. /package/dist/lib/browser/{types/index.mjs.map → types.mjs.map} +0 -0
  81. /package/dist/lib/node-esm/{types/index.mjs.map → types.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,UAAU;;GAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC"}
@@ -1,5 +1,36 @@
1
1
  declare const _default: {
2
2
  'en-US': {
3
+ [x: string]: {
4
+ 'typename label': string;
5
+ 'plugin name'?: undefined;
6
+ 'kanban title label'?: undefined;
7
+ 'kanban title placeholder'?: undefined;
8
+ 'column title label'?: undefined;
9
+ 'column title placeholder'?: undefined;
10
+ 'item title label'?: undefined;
11
+ 'item title placeholder'?: undefined;
12
+ 'add column label'?: undefined;
13
+ 'add item label'?: undefined;
14
+ 'delete column label'?: undefined;
15
+ 'delete item label'?: undefined;
16
+ 'create kanban label'?: undefined;
17
+ 'card field deleted label'?: undefined;
18
+ } | {
19
+ 'plugin name': string;
20
+ 'kanban title label': string;
21
+ 'kanban title placeholder': string;
22
+ 'column title label': string;
23
+ 'column title placeholder': string;
24
+ 'item title label': string;
25
+ 'item title placeholder': string;
26
+ 'add column label': string;
27
+ 'add item label': string;
28
+ 'delete column label': string;
29
+ 'delete item label': string;
30
+ 'create kanban label': string;
31
+ 'card field deleted label': string;
32
+ 'typename label'?: undefined;
33
+ };
3
34
  "dxos.org/plugin/kanban": {
4
35
  'plugin name': string;
5
36
  'kanban title label': string;
@@ -13,6 +44,7 @@ declare const _default: {
13
44
  'delete column label': string;
14
45
  'delete item label': string;
15
46
  'create kanban label': string;
47
+ 'card field deleted label': string;
16
48
  };
17
49
  };
18
50
  }[];
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA,wBAmBE"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,wBAuBE"}
@@ -0,0 +1,61 @@
1
+ import type { IntentResolverProvides, MetadataRecordsProvides, SurfaceProvides, TranslationsProvides } from '@dxos/app-framework';
2
+ import { S } from '@dxos/echo-schema';
3
+ import { type SchemaProvides } from '@dxos/plugin-space';
4
+ import { type Space } from '@dxos/react-client/echo';
5
+ import { KanbanType } from '@dxos/react-ui-kanban';
6
+ /**
7
+ * Kanban data model.
8
+ * A Kanban board is a collection of columns, each of which contains a collection of items.
9
+ * The layout of columns and items is controlled by models.
10
+ * The underlying data model may be represented by direct object relationships
11
+ * (e.g., a column object containing an array of ordered items) or projections constructed
12
+ * by the model (e.g., a query of items based on metadata within a column object).
13
+ */
14
+ export declare namespace KanbanAction {
15
+ const Create_base: S.TaggedClass<Create, "dxos.org/plugin/kanban/action/create", {
16
+ readonly _tag: S.tag<"dxos.org/plugin/kanban/action/create">;
17
+ } & {
18
+ input: S.Struct<{
19
+ name: S.optional<typeof S.String>;
20
+ space: S.Schema<Space, Space, never>;
21
+ }>;
22
+ output: S.Struct<{
23
+ object: typeof KanbanType;
24
+ }>;
25
+ }>;
26
+ export class Create extends Create_base {
27
+ }
28
+ const DeleteCardField_base: S.TaggedClass<DeleteCardField, "dxos.org/plugin/kanban/action/delete-card-field", {
29
+ readonly _tag: S.tag<"dxos.org/plugin/kanban/action/delete-card-field">;
30
+ } & {
31
+ input: S.Struct<{
32
+ kanban: typeof KanbanType;
33
+ fieldId: typeof S.String;
34
+ deletionData: S.optional<S.Struct<{
35
+ field: S.mutable<S.Struct<{
36
+ id: typeof S.String;
37
+ path: S.Schema<import("@dxos/echo-schema").JsonPath, import("@dxos/echo-schema").JsonPath, never>;
38
+ visible: S.optional<typeof S.Boolean>;
39
+ size: S.optional<typeof S.Number>;
40
+ referencePath: S.optional<S.Schema<import("@dxos/echo-schema").JsonPath, import("@dxos/echo-schema").JsonPath, never>>;
41
+ }>>;
42
+ props: typeof S.Any;
43
+ index: typeof S.Number;
44
+ }>>;
45
+ }>;
46
+ output: typeof S.Void;
47
+ }>;
48
+ export class DeleteCardField extends DeleteCardField_base {
49
+ }
50
+ export {};
51
+ }
52
+ export type KanbanPluginProvides = SurfaceProvides & IntentResolverProvides & MetadataRecordsProvides & TranslationsProvides & SchemaProvides;
53
+ export interface KanbanModel {
54
+ root: KanbanType;
55
+ }
56
+ export type Location = {
57
+ idx?: number;
58
+ };
59
+ export declare const isKanban: (object: unknown) => object is KanbanType;
60
+ export declare const createKanban: (space: Space) => Promise<KanbanType>;
61
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,KAAK,KAAK,EAAe,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAMnD;;;;;;;GAOG;AAEH,yBAAiB,YAAY,CAAC;;;;;;;;;;;;IAG5B,MAAM,OAAO,MAAO,SAAQ,WAQ1B;KAAG;;;;;;;;;+BA5B+B,EAAG,MAAM;0BAC/C,EAAG,MAAM;6BAAyC,EAAG,QAAQ,QAC5D,EAAG,OAAO;0BAAY,EAAI,QAAO,QAAO,EAAG,MAAM;mCAC/B,EAAG,QAAQ,CAAC,EAAE,MAAM;;;;;;;;IA2BrC,MAAM,OAAO,eAAgB,SAAQ,oBAgBnC;KAAG;;CACN;AAED,MAAM,MAAM,oBAAoB,GAAG,eAAe,GAChD,sBAAsB,GACtB,uBAAuB,GACvB,oBAAoB,GACpB,cAAc,CAAC;AAUjB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,QAAQ,WAAY,OAAO,KAAG,MAAM,IAAI,UAA4D,CAAC;AAElH,eAAO,MAAM,YAAY,UAAiB,KAAK,wBAG9C,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":"5.7.2"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-kanban",
3
- "version": "0.7.4",
3
+ "version": "0.7.5-main.499c70c",
4
4
  "description": "Kanban DXOS Surface plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -40,41 +40,39 @@
40
40
  "src"
41
41
  ],
42
42
  "dependencies": {
43
- "@dnd-kit/core": "^6.0.5",
44
- "@dnd-kit/modifiers": "^6.0.0",
45
- "@dnd-kit/sortable": "^7.0.1",
46
- "@dnd-kit/utilities": "^3.2.0",
47
43
  "@effect/schema": "^0.75.5",
48
44
  "@preact/signals-core": "^1.6.0",
49
- "@dxos/app-framework": "0.7.4",
50
- "@dxos/async": "0.7.4",
51
- "@dxos/echo-schema": "0.7.4",
52
- "@dxos/plugin-client": "0.7.4",
53
- "@dxos/plugin-graph": "0.7.4",
54
- "@dxos/live-object": "0.7.4",
55
- "@dxos/plugin-space": "0.7.4",
56
- "@dxos/react-client": "0.7.4",
57
- "@dxos/react-ui-editor": "0.7.4",
58
- "@dxos/util": "0.7.4"
45
+ "@dxos/app-framework": "0.7.5-main.499c70c",
46
+ "@dxos/async": "0.7.5-main.499c70c",
47
+ "@dxos/echo-schema": "0.7.5-main.499c70c",
48
+ "@dxos/invariant": "0.7.5-main.499c70c",
49
+ "@dxos/plugin-client": "0.7.5-main.499c70c",
50
+ "@dxos/plugin-search": "0.7.5-main.499c70c",
51
+ "@dxos/plugin-graph": "0.7.5-main.499c70c",
52
+ "@dxos/random": "0.7.5-main.499c70c",
53
+ "@dxos/plugin-space": "0.7.5-main.499c70c",
54
+ "@dxos/react-client": "0.7.5-main.499c70c",
55
+ "@dxos/react-ui-form": "0.7.5-main.499c70c",
56
+ "@dxos/react-ui-kanban": "0.7.5-main.499c70c",
57
+ "@dxos/util": "0.7.5-main.499c70c",
58
+ "@dxos/react-ui-stack": "0.7.5-main.499c70c",
59
+ "@dxos/schema": "0.7.5-main.499c70c"
59
60
  },
60
61
  "devDependencies": {
61
- "@phosphor-icons/react": "^2.1.5",
62
62
  "@types/react": "~18.2.0",
63
63
  "@types/react-dom": "~18.2.0",
64
64
  "react": "~18.2.0",
65
65
  "react-dom": "~18.2.0",
66
66
  "vite": "5.4.7",
67
- "@dxos/random": "0.7.4",
68
- "@dxos/react-ui": "0.7.4",
69
- "@dxos/react-ui-theme": "0.7.4",
70
- "@dxos/storybook-utils": "0.7.4"
67
+ "@dxos/react-ui": "0.7.5-main.499c70c",
68
+ "@dxos/react-ui-theme": "0.7.5-main.499c70c",
69
+ "@dxos/storybook-utils": "0.7.5-main.499c70c"
71
70
  },
72
71
  "peerDependencies": {
73
- "@phosphor-icons/react": "^2.1.5",
74
72
  "react": "~18.2.0",
75
73
  "react-dom": "~18.2.0",
76
- "@dxos/react-ui": "0.7.4",
77
- "@dxos/react-ui-theme": "0.7.4"
74
+ "@dxos/react-ui": "0.7.5-main.499c70c",
75
+ "@dxos/react-ui-theme": "0.7.5-main.499c70c"
78
76
  },
79
77
  "publishConfig": {
80
78
  "access": "public"
@@ -4,18 +4,17 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { resolvePlugin, type PluginDefinition, parseIntentPlugin, NavigationAction } from '@dxos/app-framework';
8
- import { create } from '@dxos/live-object';
9
- import { parseClientPlugin } from '@dxos/plugin-client';
10
- import { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';
11
- import { SpaceAction } from '@dxos/plugin-space';
12
- import { loadObjectReferences } from '@dxos/react-client/echo';
7
+ import { type PluginDefinition, createSurface, createIntent, createResolver } from '@dxos/app-framework';
8
+ import { invariant } from '@dxos/invariant';
9
+ import { getSpace, type Space } from '@dxos/react-client/echo';
10
+ import { KanbanType, translations as kanbanTranslations } from '@dxos/react-ui-kanban';
11
+ import { ViewProjection } from '@dxos/schema';
13
12
 
14
- import { KanbanMain } from './components';
13
+ import { KanbanContainer } from './components';
14
+ import KanbanViewEditor from './components/KanbanViewEditor';
15
15
  import meta, { KANBAN_PLUGIN } from './meta';
16
16
  import translations from './translations';
17
- import { KanbanColumnType, KanbanItemType, KanbanType } from './types';
18
- import { KanbanAction, type KanbanPluginProvides } from './types';
17
+ import { isKanban, KanbanAction, type KanbanPluginProvides, createKanban } from './types';
19
18
 
20
19
  export const KanbanPlugin = (): PluginDefinition<KanbanPluginProvides> => {
21
20
  return {
@@ -24,87 +23,60 @@ export const KanbanPlugin = (): PluginDefinition<KanbanPluginProvides> => {
24
23
  metadata: {
25
24
  records: {
26
25
  [KanbanType.typename]: {
27
- createObject: KanbanAction.CREATE,
26
+ createObject: (props: { name?: string; space: Space }) => createIntent(KanbanAction.Create, props),
28
27
  placeholder: ['kanban title placeholder', { ns: KANBAN_PLUGIN }],
29
28
  icon: 'ph--kanban--regular',
30
- // TODO(wittjosiah): Move out of metadata.
31
- loadReferences: (kanban: KanbanType) => loadObjectReferences(kanban, (kanban) => kanban.columns),
32
- },
33
- [KanbanColumnType.typename]: {
34
- // TODO(wittjosiah): Move out of metadata.
35
- loadReferences: (column: KanbanColumnType) => loadObjectReferences(column, (column) => column.items),
36
- },
37
- [KanbanItemType.typename]: {
38
- // TODO(wittjosiah): Move out of metadata.
39
- loadReferences: (item: KanbanItemType) => [], // loadObjectReferences(item, (item) => item.object),
40
29
  },
41
30
  },
42
31
  },
43
32
  echo: {
44
33
  schema: [KanbanType],
45
- system: [KanbanColumnType, KanbanItemType],
46
- },
47
- translations,
48
- graph: {
49
- builder: (plugins) => {
50
- const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
51
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
52
- if (!client || !dispatch) {
53
- return [];
54
- }
55
-
56
- return createExtension({
57
- id: KanbanAction.CREATE,
58
- filter: (node): node is ActionGroup => isActionGroup(node) && node.id.startsWith(SpaceAction.ADD_OBJECT),
59
- actions: ({ node }) => {
60
- const id = node.id.split('/').at(-1);
61
- const [spaceId, objectId] = id?.split(':') ?? [];
62
- const space = client.spaces.get().find((space) => space.id === spaceId);
63
- const object = objectId && space?.db.getObjectById(objectId);
64
- const target = objectId ? object : space;
65
- if (!target) {
66
- return;
67
- }
68
-
69
- return [
70
- {
71
- id: `${KANBAN_PLUGIN}/create/${node.id}`,
72
- data: async () => {
73
- await dispatch([
74
- { plugin: KANBAN_PLUGIN, action: KanbanAction.CREATE },
75
- { action: SpaceAction.ADD_OBJECT, data: { target } },
76
- { action: NavigationAction.OPEN },
77
- ]);
78
- },
79
- properties: {
80
- label: ['create kanban label', { ns: KANBAN_PLUGIN }],
81
- icon: 'ph--kanban--regular',
82
- testId: 'kanbanPlugin.createObject',
83
- },
84
- },
85
- ];
86
- },
87
- });
88
- },
89
34
  },
35
+ translations: [...translations, ...kanbanTranslations],
90
36
  surface: {
91
- component: ({ data, role }) => {
92
- switch (role) {
93
- case 'main':
94
- return data.active instanceof KanbanType ? <KanbanMain kanban={data.active} /> : null;
95
- default:
96
- return null;
97
- }
98
- },
37
+ definitions: () => [
38
+ createSurface({
39
+ id: `${KANBAN_PLUGIN}/kanban`,
40
+ role: ['article', 'section'],
41
+ filter: (data): data is { subject: KanbanType } => isKanban(data.subject),
42
+ component: ({ data, role }) => <KanbanContainer kanban={data.subject} role={role} />,
43
+ }),
44
+ createSurface({
45
+ id: `${KANBAN_PLUGIN}/settings`,
46
+ role: 'complementary--settings',
47
+ filter: (data): data is { subject: KanbanType } => isKanban(data.subject),
48
+ component: ({ data }) => <KanbanViewEditor kanban={data.subject} />,
49
+ }),
50
+ ],
99
51
  },
100
52
  intent: {
101
- resolver: (intent) => {
102
- switch (intent.action) {
103
- case KanbanAction.CREATE: {
104
- return { data: create(KanbanType, { columns: [] }) };
53
+ resolvers: () => [
54
+ createResolver(KanbanAction.Create, async ({ space }) => ({
55
+ data: { object: await createKanban(space) },
56
+ })),
57
+ createResolver(KanbanAction.DeleteCardField, ({ kanban, fieldId, deletionData }, undo) => {
58
+ invariant(kanban.cardView);
59
+
60
+ const schema =
61
+ kanban.cardView.target &&
62
+ getSpace(kanban)?.db.schemaRegistry.getSchema(kanban.cardView.target.query.type);
63
+ invariant(schema);
64
+ const projection = new ViewProjection(schema, kanban.cardView.target!);
65
+
66
+ if (!undo) {
67
+ const { deleted, index } = projection.deleteFieldProjection(fieldId);
68
+ return {
69
+ undoable: {
70
+ message: translations[0]['en-US'][KANBAN_PLUGIN]['card field deleted label'],
71
+ data: { deletionData: { ...deleted, index } },
72
+ },
73
+ };
74
+ } else if (undo && deletionData) {
75
+ const { field, props, index } = deletionData;
76
+ projection.setFieldProjection({ field, props }, index);
105
77
  }
106
- }
107
- },
78
+ }),
79
+ ],
108
80
  },
109
81
  },
110
82
  };
@@ -0,0 +1,79 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useEffect, useState } from 'react';
6
+
7
+ import { type EchoSchema } from '@dxos/echo-schema';
8
+ import { invariant } from '@dxos/invariant';
9
+ import { useGlobalFilteredObjects } from '@dxos/plugin-search';
10
+ import { Filter, useQuery, getSpace, create } from '@dxos/react-client/echo';
11
+ import { type KanbanType, useKanbanModel, Kanban } from '@dxos/react-ui-kanban';
12
+ import { StackItem } from '@dxos/react-ui-stack';
13
+
14
+ export const KanbanContainer = ({ kanban }: { kanban: KanbanType; role: string }) => {
15
+ const [cardSchema, setCardSchema] = useState<EchoSchema>();
16
+ const space = getSpace(kanban);
17
+ useEffect(() => {
18
+ if (kanban.cardView && space) {
19
+ setCardSchema(space.db.schemaRegistry.getSchema(kanban.cardView.target!.query.type));
20
+ }
21
+ }, [kanban.cardView, space]);
22
+
23
+ const objects = useQuery(space, cardSchema ? Filter.schema(cardSchema) : Filter.nothing());
24
+ const filteredObjects = useGlobalFilteredObjects(objects);
25
+
26
+ const model = useKanbanModel({
27
+ kanban,
28
+ cardSchema,
29
+ items: filteredObjects,
30
+ });
31
+
32
+ const handleAddColumn = useCallback((columnValue: string) => model?.addEmptyColumn(columnValue), [model]);
33
+
34
+ const handleAddCard = useCallback(
35
+ (columnValue: string) => {
36
+ if (space && cardSchema) {
37
+ space.db.add(
38
+ create(cardSchema, {
39
+ title: '',
40
+ description: '',
41
+ state: columnValue,
42
+ }),
43
+ );
44
+ }
45
+ },
46
+ [space, cardSchema],
47
+ );
48
+
49
+ const handleRemoveCard = useCallback(
50
+ (card: { id: string }) => {
51
+ invariant(space);
52
+ space.db.remove(card);
53
+ },
54
+ [space],
55
+ );
56
+
57
+ const handleRemoveEmptyColumn = useCallback(
58
+ (columnValue: string) => {
59
+ model?.removeColumnFromArrangement(columnValue);
60
+ },
61
+ [model],
62
+ );
63
+
64
+ return (
65
+ <StackItem.Content toolbar={false}>
66
+ {model ? (
67
+ <Kanban
68
+ model={model}
69
+ onAddCard={handleAddCard}
70
+ onAddColumn={handleAddColumn}
71
+ onRemoveCard={handleRemoveCard}
72
+ onRemoveEmptyColumn={handleRemoveEmptyColumn}
73
+ />
74
+ ) : (
75
+ <span>Loading</span>
76
+ )}
77
+ </StackItem.Content>
78
+ );
79
+ };
@@ -0,0 +1,72 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useEffect, useState } from 'react';
6
+
7
+ import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
8
+ import { getSpace } from '@dxos/react-client/echo';
9
+ import { ViewEditor, Form } from '@dxos/react-ui-form';
10
+ import { type KanbanType, KanbanPropsSchema } from '@dxos/react-ui-kanban';
11
+
12
+ import { KanbanAction } from '../types';
13
+
14
+ type KanbanViewEditorProps = { kanban: KanbanType };
15
+
16
+ const KanbanViewEditor = ({ kanban }: KanbanViewEditorProps) => {
17
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
18
+ const space = getSpace(kanban);
19
+
20
+ // TODO(ZaymonFC): The schema registry needs an API where we can query with initial value and
21
+ // endure typename changes. We shouldn't need to manage a subscription at this layer.
22
+ const [schema, setSchema] = useState(
23
+ space && kanban?.cardView?.target?.query?.type
24
+ ? space.db.schemaRegistry.getSchema(kanban.cardView.target.query.type)
25
+ : undefined,
26
+ );
27
+
28
+ useEffect(() => {
29
+ if (space && kanban?.cardView?.target?.query?.type) {
30
+ const unsubscribe = space.db.schemaRegistry
31
+ .query({ typename: kanban?.cardView?.target?.query?.type })
32
+ .subscribe((query) => {
33
+ const [schema] = query.results;
34
+ if (schema) {
35
+ setSchema(schema);
36
+ }
37
+ });
38
+
39
+ return unsubscribe;
40
+ }
41
+ }, [space, kanban?.cardView?.target?.query?.type]);
42
+
43
+ const handleDelete = useCallback(
44
+ (fieldId: string) => dispatch?.(createIntent(KanbanAction.DeleteCardField, { kanban, fieldId })),
45
+ [dispatch, kanban],
46
+ );
47
+
48
+ if (!space || !schema || !kanban.cardView?.target) {
49
+ return null;
50
+ }
51
+
52
+ return (
53
+ <>
54
+ <Form
55
+ schema={KanbanPropsSchema}
56
+ values={{ columnField: kanban.columnField }}
57
+ onSave={({ columnField }) => {
58
+ kanban.columnField = columnField;
59
+ kanban.arrangement = undefined;
60
+ }}
61
+ />
62
+ <ViewEditor
63
+ registry={space.db.schemaRegistry}
64
+ schema={schema}
65
+ view={kanban.cardView.target}
66
+ onDelete={handleDelete}
67
+ />
68
+ </>
69
+ );
70
+ };
71
+
72
+ export default KanbanViewEditor;
@@ -1,7 +1,5 @@
1
1
  //
2
- // Copyright 2023 DXOS.org
2
+ // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from 'react';
6
-
7
- export const KanbanMain = lazy(() => import('./KanbanMain'));
5
+ export * from './KanbanContainer';
@@ -2,11 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { KanbanType } from '@dxos/react-ui-kanban';
6
+
5
7
  import { KANBAN_PLUGIN } from './meta';
6
8
 
7
9
  export default [
8
10
  {
9
11
  'en-US': {
12
+ [KanbanType.typename]: {
13
+ 'typename label': 'Kanban',
14
+ },
10
15
  [KANBAN_PLUGIN]: {
11
16
  'plugin name': 'Kanban',
12
17
  'kanban title label': 'Title',
@@ -16,10 +21,11 @@ export default [
16
21
  'item title label': 'Item title',
17
22
  'item title placeholder': 'New item',
18
23
  'add column label': 'Add column',
19
- 'add item label': 'Add item',
24
+ 'add item label': 'Add card',
20
25
  'delete column label': 'Delete column',
21
- 'delete item label': 'Delete item',
26
+ 'delete item label': 'Delete card',
22
27
  'create kanban label': 'Create kanban',
28
+ 'card field deleted label': 'Card field deleted',
23
29
  },
24
30
  },
25
31
  },
@@ -3,16 +3,19 @@
3
3
  //
4
4
 
5
5
  import type {
6
- GraphBuilderProvides,
7
6
  IntentResolverProvides,
8
7
  MetadataRecordsProvides,
9
8
  SurfaceProvides,
10
9
  TranslationsProvides,
11
10
  } from '@dxos/app-framework';
11
+ import { S } from '@dxos/echo-schema';
12
12
  import { type SchemaProvides } from '@dxos/plugin-space';
13
+ import { type Space, SpaceSchema } from '@dxos/react-client/echo';
14
+ import { KanbanType } from '@dxos/react-ui-kanban';
15
+ import { initializeKanban } from '@dxos/react-ui-kanban/testing';
16
+ import { FieldSchema } from '@dxos/schema';
13
17
 
14
- import { type KanbanColumnType, type KanbanItemType, type KanbanType } from './kanban';
15
- import { KANBAN_PLUGIN } from '../meta';
18
+ import { KANBAN_PLUGIN } from './meta';
16
19
 
17
20
  /**
18
21
  * Kanban data model.
@@ -23,15 +26,40 @@ import { KANBAN_PLUGIN } from '../meta';
23
26
  * by the model (e.g., a query of items based on metadata within a column object).
24
27
  */
25
28
 
26
- const KANBAN_ACTION = `${KANBAN_PLUGIN}/action`;
29
+ export namespace KanbanAction {
30
+ const KANBAN_ACTION = `${KANBAN_PLUGIN}/action`;
27
31
 
28
- export enum KanbanAction {
29
- CREATE = `${KANBAN_ACTION}/create`,
32
+ export class Create extends S.TaggedClass<Create>()(`${KANBAN_ACTION}/create`, {
33
+ input: S.Struct({
34
+ name: S.optional(S.String),
35
+ space: SpaceSchema,
36
+ }),
37
+ output: S.Struct({
38
+ object: KanbanType,
39
+ }),
40
+ }) {}
41
+
42
+ export class DeleteCardField extends S.TaggedClass<DeleteCardField>()(`${KANBAN_ACTION}/delete-card-field`, {
43
+ input: S.Struct({
44
+ kanban: KanbanType,
45
+ fieldId: S.String,
46
+ // TODO(wittjosiah): Separate fields for undo data?
47
+ deletionData: S.optional(
48
+ S.Struct({
49
+ field: FieldSchema,
50
+ // TODO(wittjosiah): This creates a type error.
51
+ // props: PropertySchema,
52
+ props: S.Any,
53
+ index: S.Number,
54
+ }),
55
+ ),
56
+ }),
57
+ output: S.Void,
58
+ }) {}
30
59
  }
31
60
 
32
61
  export type KanbanPluginProvides = SurfaceProvides &
33
62
  IntentResolverProvides &
34
- GraphBuilderProvides &
35
63
  MetadataRecordsProvides &
36
64
  TranslationsProvides &
37
65
  SchemaProvides;
@@ -46,12 +74,15 @@ export type KanbanPluginProvides = SurfaceProvides &
46
74
  // TODO(burdon): Extend model for moving items (in and across columns).
47
75
  export interface KanbanModel {
48
76
  root: KanbanType;
49
- createColumn(): KanbanColumnType;
50
- createItem(column: KanbanColumnType): KanbanItemType;
51
77
  }
52
78
 
53
79
  export type Location = {
54
- column: KanbanColumnType;
55
- item?: KanbanItemType;
56
80
  idx?: number;
57
81
  };
82
+
83
+ export const isKanban = (object: unknown): object is KanbanType => object != null && object instanceof KanbanType;
84
+
85
+ export const createKanban = async (space: Space) => {
86
+ const { kanban } = await initializeKanban({ space });
87
+ return kanban;
88
+ };