@dxos/plugin-kanban 0.8.4-main.1da679c → 0.8.4-main.21d9917

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 (120) hide show
  1. package/dist/lib/browser/blueprint-definition-T2544VMJ.mjs +17 -0
  2. package/dist/lib/browser/blueprint-definition-T2544VMJ.mjs.map +7 -0
  3. package/dist/lib/browser/blueprints/index.mjs +8 -0
  4. package/dist/lib/browser/blueprints/index.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  6. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-L6N4ZDZ7.mjs +35 -0
  8. package/dist/lib/browser/chunk-L6N4ZDZ7.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-XYQO4VL7.mjs +150 -0
  10. package/dist/lib/browser/chunk-XYQO4VL7.mjs.map +7 -0
  11. package/dist/lib/browser/index.mjs +58 -66
  12. package/dist/lib/browser/index.mjs.map +4 -4
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/operation-resolver-UEJHX42A.mjs +162 -0
  15. package/dist/lib/browser/operation-resolver-UEJHX42A.mjs.map +7 -0
  16. package/dist/lib/browser/react-surface-XZSKFDM5.mjs +236 -0
  17. package/dist/lib/browser/react-surface-XZSKFDM5.mjs.map +7 -0
  18. package/dist/lib/browser/types/index.mjs +8 -5
  19. package/dist/lib/node-esm/blueprint-definition-APJQFSHJ.mjs +18 -0
  20. package/dist/lib/node-esm/blueprint-definition-APJQFSHJ.mjs.map +7 -0
  21. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  22. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  23. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  24. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  25. package/dist/lib/node-esm/chunk-NN6JMKIT.mjs +152 -0
  26. package/dist/lib/node-esm/chunk-NN6JMKIT.mjs.map +7 -0
  27. package/dist/lib/node-esm/chunk-ZHRMUKTF.mjs +36 -0
  28. package/dist/lib/node-esm/chunk-ZHRMUKTF.mjs.map +7 -0
  29. package/dist/lib/node-esm/index.mjs +58 -66
  30. package/dist/lib/node-esm/index.mjs.map +4 -4
  31. package/dist/lib/node-esm/meta.json +1 -1
  32. package/dist/lib/node-esm/operation-resolver-5RPWHZCF.mjs +163 -0
  33. package/dist/lib/node-esm/operation-resolver-5RPWHZCF.mjs.map +7 -0
  34. package/dist/lib/node-esm/react-surface-JWRKX7GS.mjs +237 -0
  35. package/dist/lib/node-esm/react-surface-JWRKX7GS.mjs.map +7 -0
  36. package/dist/lib/node-esm/types/index.mjs +8 -5
  37. package/dist/types/src/KanbanPlugin.d.ts +2 -1
  38. package/dist/types/src/KanbanPlugin.d.ts.map +1 -1
  39. package/dist/types/src/blueprints/index.d.ts +2 -0
  40. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  41. package/dist/types/src/blueprints/kanban-blueprint.d.ts +22 -0
  42. package/dist/types/src/blueprints/kanban-blueprint.d.ts.map +1 -0
  43. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
  44. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
  45. package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
  46. package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
  47. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -0
  48. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  50. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  51. package/dist/types/src/capabilities/index.d.ts +3 -3
  52. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  53. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  54. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  55. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  56. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  57. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  58. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  59. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  60. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  61. package/dist/types/src/components/KanbanContainer.d.ts +4 -5
  62. package/dist/types/src/components/KanbanContainer.d.ts.map +1 -1
  63. package/dist/types/src/components/KanbanContainer.stories.d.ts +37 -12
  64. package/dist/types/src/components/KanbanContainer.stories.d.ts.map +1 -1
  65. package/dist/types/src/components/KanbanViewEditor.d.ts +3 -3
  66. package/dist/types/src/components/KanbanViewEditor.d.ts.map +1 -1
  67. package/dist/types/src/meta.d.ts +2 -3
  68. package/dist/types/src/meta.d.ts.map +1 -1
  69. package/dist/types/src/translations.d.ts +21 -9
  70. package/dist/types/src/translations.d.ts.map +1 -1
  71. package/dist/types/src/types/schema.d.ts +99 -44
  72. package/dist/types/src/types/schema.d.ts.map +1 -1
  73. package/dist/types/tsconfig.tsbuildinfo +1 -1
  74. package/package.json +64 -49
  75. package/src/KanbanPlugin.tsx +35 -54
  76. package/src/blueprints/index.ts +5 -0
  77. package/src/blueprints/kanban-blueprint.ts +24 -0
  78. package/src/capabilities/artifact-definition/artifact-definition.ts +150 -0
  79. package/src/capabilities/artifact-definition/index.ts +7 -0
  80. package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
  81. package/src/capabilities/blueprint-definition/index.ts +7 -0
  82. package/src/capabilities/index.ts +3 -5
  83. package/src/capabilities/operation-resolver/index.ts +7 -0
  84. package/src/capabilities/operation-resolver/operation-resolver.ts +133 -0
  85. package/src/capabilities/react-surface/index.ts +7 -0
  86. package/src/capabilities/react-surface/react-surface.tsx +86 -0
  87. package/src/components/KanbanContainer.stories.tsx +129 -94
  88. package/src/components/KanbanContainer.tsx +34 -45
  89. package/src/components/KanbanViewEditor.tsx +36 -39
  90. package/src/meta.ts +9 -7
  91. package/src/translations.ts +5 -5
  92. package/src/types/schema.ts +86 -40
  93. package/dist/lib/browser/blueprint-definition-UYVX622Q.mjs +0 -28
  94. package/dist/lib/browser/blueprint-definition-UYVX622Q.mjs.map +0 -7
  95. package/dist/lib/browser/chunk-NCNNL74W.mjs +0 -82
  96. package/dist/lib/browser/chunk-NCNNL74W.mjs.map +0 -7
  97. package/dist/lib/browser/intent-resolver-UWM5C5LZ.mjs +0 -111
  98. package/dist/lib/browser/intent-resolver-UWM5C5LZ.mjs.map +0 -7
  99. package/dist/lib/browser/react-surface-4JNCLFQB.mjs +0 -253
  100. package/dist/lib/browser/react-surface-4JNCLFQB.mjs.map +0 -7
  101. package/dist/lib/node-esm/blueprint-definition-42P47FUY.mjs +0 -30
  102. package/dist/lib/node-esm/blueprint-definition-42P47FUY.mjs.map +0 -7
  103. package/dist/lib/node-esm/chunk-5B3LKGA7.mjs +0 -84
  104. package/dist/lib/node-esm/chunk-5B3LKGA7.mjs.map +0 -7
  105. package/dist/lib/node-esm/intent-resolver-JDQ7I5HR.mjs +0 -112
  106. package/dist/lib/node-esm/intent-resolver-JDQ7I5HR.mjs.map +0 -7
  107. package/dist/lib/node-esm/react-surface-2C7LFFY5.mjs +0 -254
  108. package/dist/lib/node-esm/react-surface-2C7LFFY5.mjs.map +0 -7
  109. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  110. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  111. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  112. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  113. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  114. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  115. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  116. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  117. package/src/capabilities/artifact-definition.ts +0 -147
  118. package/src/capabilities/blueprint-definition.ts +0 -30
  119. package/src/capabilities/intent-resolver.ts +0 -71
  120. package/src/capabilities/react-surface.tsx +0 -84
@@ -0,0 +1,86 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+ import type * as Schema from 'effect/Schema';
7
+ import React, { useMemo } from 'react';
8
+
9
+ import { Capability, Common } from '@dxos/app-framework';
10
+ import { Database, Obj, Type } from '@dxos/echo';
11
+ import { findAnnotation } from '@dxos/effect';
12
+ import { type FormFieldComponentProps, SelectField, useFormValues } from '@dxos/react-ui-form';
13
+ import { Kanban } from '@dxos/react-ui-kanban/types';
14
+ import { type Collection } from '@dxos/schema';
15
+
16
+ import { KanbanContainer, KanbanViewEditor } from '../../components';
17
+ import { meta } from '../../meta';
18
+ import { PivotColumnAnnotationId } from '../../types';
19
+
20
+ export default Capability.makeModule(() =>
21
+ Effect.succeed(
22
+ Capability.contributes(Common.Capability.ReactSurface, [
23
+ Common.createSurface({
24
+ id: meta.id,
25
+ role: ['article', 'section'],
26
+ filter: (data): data is { subject: Kanban.Kanban } => Obj.instanceOf(Kanban.Kanban, data.subject),
27
+ component: ({ data, role }) => <KanbanContainer role={role} subject={data.subject} />,
28
+ }),
29
+ Common.createSurface({
30
+ id: `${meta.id}/object-settings`,
31
+ role: 'object-settings',
32
+ position: 'hoist',
33
+ filter: (data): data is { subject: Kanban.Kanban } => Obj.instanceOf(Kanban.Kanban, data.subject),
34
+ component: ({ data }) => <KanbanViewEditor object={data.subject} />,
35
+ }),
36
+ Common.createSurface({
37
+ id: `${meta.id}/create-initial-schema-form-[pivot-column]`,
38
+ role: 'form-input',
39
+ filter: (
40
+ data,
41
+ ): data is {
42
+ prop: string;
43
+ schema: Schema.Schema<any>;
44
+ target: Database.Database | Collection.Collection | undefined;
45
+ } => {
46
+ const annotation = findAnnotation<boolean>((data.schema as Schema.Schema.All).ast, PivotColumnAnnotationId);
47
+ return !!annotation;
48
+ },
49
+ component: ({ data: { target }, ...inputProps }) => {
50
+ const props = inputProps as any as FormFieldComponentProps;
51
+ const db = Database.isDatabase(target) ? target : target && Obj.getDatabase(target);
52
+ if (!db) {
53
+ return null;
54
+ }
55
+
56
+ const { typename } = useFormValues('KanbanForm');
57
+ const [selectedSchema] = useMemo(
58
+ () => db.schemaRegistry.query({ location: ['database', 'runtime'], typename }).runSync(),
59
+ [db, typename],
60
+ );
61
+ const singleSelectColumns = useMemo(() => {
62
+ const properties = Type.toJsonSchema(selectedSchema).properties;
63
+ if (!properties) {
64
+ return [];
65
+ }
66
+
67
+ const columns = Object.entries(properties).reduce<string[]>((acc, [key, value]) => {
68
+ if (typeof value === 'object' && value?.format === 'single-select') {
69
+ acc.push(key);
70
+ }
71
+ return acc;
72
+ }, []);
73
+
74
+ return columns;
75
+ }, [selectedSchema]);
76
+
77
+ if (!typename) {
78
+ return null;
79
+ }
80
+
81
+ return <SelectField {...props} options={singleSelectColumns.map((column) => ({ value: column }))} />;
82
+ },
83
+ }),
84
+ ]),
85
+ ),
86
+ );
@@ -2,80 +2,66 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
5
+ import { RegistryContext } from '@effect-atom/atom-react';
7
6
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
- import React, { useCallback, useEffect, useState } from 'react';
7
+ import * as Effect from 'effect/Effect';
8
+ import React, { useCallback, useContext } from 'react';
9
+ import { expect, waitFor, within } from 'storybook/test';
9
10
 
10
- import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
11
11
  import { withPluginManager } from '@dxos/app-framework/testing';
12
- import { Obj, Query, Type } from '@dxos/echo';
12
+ import { Obj, type QueryAST, Type } from '@dxos/echo';
13
+ import { type Mutable } from '@dxos/echo/internal';
13
14
  import { invariant } from '@dxos/invariant';
14
15
  import { ClientPlugin } from '@dxos/plugin-client';
15
16
  import { PreviewPlugin } from '@dxos/plugin-preview';
16
17
  import { useGlobalFilteredObjects } from '@dxos/plugin-search';
17
18
  import { SpacePlugin } from '@dxos/plugin-space';
18
- import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
19
- import { ThemePlugin } from '@dxos/plugin-theme';
19
+ import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
20
20
  import { faker } from '@dxos/random';
21
- import { useClient } from '@dxos/react-client';
22
21
  import { Filter, useQuery, useSchema, useSpaces } from '@dxos/react-client/echo';
22
+ import { withTheme } from '@dxos/react-ui/testing';
23
23
  import { ViewEditor } from '@dxos/react-ui-form';
24
- import { Kanban as KanbanComponent, useKanbanModel } from '@dxos/react-ui-kanban';
24
+ import {
25
+ Kanban as KanbanComponent,
26
+ translations as kanbanTranslations,
27
+ useKanbanModel,
28
+ useProjectionModel,
29
+ } from '@dxos/react-ui-kanban';
25
30
  import { Kanban } from '@dxos/react-ui-kanban/types';
26
- import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
27
- import { defaultTx } from '@dxos/react-ui-theme';
28
- import { DataType, ProjectionModel, typenameFromQuery } from '@dxos/schema';
29
- import { withLayout } from '@dxos/storybook-utils';
31
+ import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
32
+ import { View, getTypenameFromQuery } from '@dxos/schema';
33
+ import { Organization, Person } from '@dxos/types';
30
34
 
31
35
  import { translations } from '../translations';
32
36
 
33
37
  faker.seed(0);
34
38
 
35
- //
36
- // Story components.
37
- //
38
-
39
- const rollOrg = () => ({
39
+ const createOrg = () => ({
40
40
  name: faker.commerce.productName(),
41
41
  description: faker.lorem.paragraph(),
42
42
  image: faker.image.url(),
43
43
  website: faker.internet.url(),
44
- status: faker.helpers.arrayElement(DataType.OrganizationStatusOptions).id as DataType.Organization['status'],
44
+ status: faker.helpers.arrayElement(Organization.StatusOptions).id as Organization.Organization['status'],
45
45
  });
46
46
 
47
- const StorybookKanban = () => {
48
- const client = useClient();
47
+ //
48
+ // Story components.
49
+ //
50
+
51
+ const DefaultComponent = () => {
52
+ const registry = useContext(RegistryContext);
49
53
  const spaces = useSpaces();
50
54
  const space = spaces[spaces.length - 1];
51
- const views = useQuery(space, Filter.type(DataType.View));
52
- const [view, setView] = useState<DataType.View>();
53
- const [projection, setProjection] = useState<ProjectionModel>();
54
- const typename = view?.query ? typenameFromQuery(view.query) : undefined;
55
- const schema = useSchema(client, space, typename);
56
-
57
- useEffect(() => {
58
- if (views.length && !view) {
59
- const view = views[0];
60
- setView(view);
61
- }
62
- }, [views]);
63
-
64
- useEffect(() => {
65
- if (view?.projection && schema) {
66
- const jsonSchema = Type.toJsonSchema(schema);
67
- setProjection(new ProjectionModel(jsonSchema, view.projection));
68
- }
69
- // TODO(ZaymonFC): Is there a better way to get notified about deep changes in the json schema?
70
- // @dmaretskyi? Once resolved, update in multiple places (e.g., storybooks).
71
- }, [view?.projection, schema, JSON.stringify(schema ? Type.toJsonSchema(schema) : {})]);
72
-
73
- const objects = useQuery(space, schema ? Filter.type(schema) : Filter.nothing());
55
+ const [object] = useQuery(space?.db, Filter.type(Kanban.Kanban));
56
+ const typename = object?.view.target?.query ? getTypenameFromQuery(object.view.target.query.ast) : undefined;
57
+ const schema = useSchema(space?.db, typename);
58
+
59
+ const objects = useQuery(space?.db, schema ? Filter.type(schema) : Filter.nothing());
74
60
  const filteredObjects = useGlobalFilteredObjects(objects);
75
61
 
62
+ const projection = useProjectionModel(schema, object, registry);
76
63
  const model = useKanbanModel({
77
- view,
78
- schema,
64
+ object,
79
65
  projection,
80
66
  items: filteredObjects,
81
67
  });
@@ -83,9 +69,9 @@ const StorybookKanban = () => {
83
69
  const handleAddCard = useCallback(
84
70
  (columnValue: string | undefined) => {
85
71
  const path = model?.columnFieldPath;
86
- if (space && schema && path) {
72
+ if (space && schema && Type.isObjectSchema(schema) && path) {
87
73
  const card = Obj.make(schema, {
88
- ...rollOrg(),
74
+ ...createOrg(),
89
75
  [path]: columnValue,
90
76
  });
91
77
 
@@ -96,95 +82,144 @@ const StorybookKanban = () => {
96
82
  [space, schema, model],
97
83
  );
98
84
 
99
- const handleRemoveCard = useCallback((card: { id: string }) => space.db.remove(card), [space]);
85
+ const handleRemoveCard = useCallback((card: { id: string }) => Obj.isObject(card) && space?.db.remove(card), [space]);
100
86
 
101
87
  const handleUpdateQuery = useCallback(
102
- (typename: string) => {
88
+ (newQuery: QueryAST.Query) => {
103
89
  invariant(schema);
104
90
  invariant(Type.isMutable(schema));
105
- invariant(view);
91
+ invariant(object.view.target);
106
92
 
107
- schema.updateTypename(typename);
108
- view.query = Query.select(Filter.typename(typename)).ast;
93
+ schema.updateTypename(getTypenameFromQuery(newQuery));
94
+ Obj.change(object.view.target, (v) => {
95
+ v.query.ast = newQuery as Mutable<typeof newQuery>;
96
+ });
109
97
  },
110
- [view, schema],
98
+ [object, schema],
111
99
  );
112
100
 
113
- if (!schema || !view) {
101
+ if (!schema || !object.view.target) {
114
102
  return null;
115
103
  }
116
104
 
117
105
  return (
118
- <div className='grow grid grid-cols-[1fr_350px]'>
106
+ <div className='grow grid grid-cols-[1fr_350px] overflow-hidden'>
119
107
  {model ? <KanbanComponent model={model} onAddCard={handleAddCard} onRemoveCard={handleRemoveCard} /> : <div />}
120
- <div className='flex flex-col bs-full border-is border-separator overflow-y-auto'>
108
+ <div className='flex flex-col bs-full overflow-hidden border-l border-separator'>
121
109
  <ViewEditor
110
+ classNames='p-2'
122
111
  registry={space?.db.schemaRegistry}
123
112
  schema={schema}
124
- view={view}
113
+ view={object.view.target}
125
114
  onQueryChanged={handleUpdateQuery}
126
115
  onDelete={(fieldId: string) => {
127
116
  console.log('[ViewEditor]', 'onDelete', fieldId);
128
117
  }}
129
118
  />
130
- <SyntaxHighlighter language='json' className='text-xs'>
131
- {JSON.stringify({ view, schema }, null, 2)}
132
- </SyntaxHighlighter>
119
+ <JsonFilter data={{ view: object.view.target, schema }} classNames='text-xs' />
133
120
  </div>
134
121
  </div>
135
122
  );
136
123
  };
137
124
 
138
- type StoryProps = {
139
- rows?: number;
140
- };
141
-
142
125
  //
143
126
  // Story definitions.
144
127
  //
145
128
 
146
129
  const meta = {
147
130
  title: 'plugins/plugin-kanban/Kanban',
148
- component: StorybookKanban,
149
- render: () => <StorybookKanban />,
150
- parameters: { translations },
131
+ component: DefaultComponent,
132
+ render: () => <DefaultComponent />,
151
133
  decorators: [
152
- withLayout({ fullscreen: true }),
134
+ withTheme,
153
135
  withPluginManager({
154
136
  plugins: [
155
- ThemePlugin({ tx: defaultTx }),
137
+ ...corePlugins(),
156
138
  ClientPlugin({
157
- types: [DataType.Organization, DataType.Person, DataType.View, Kanban.Kanban],
158
- onClientInitialized: async ({ client }) => {
159
- await client.halo.createIdentity();
160
- const space = await client.spaces.create();
161
- await space.waitUntilReady();
162
- const { view } = await Kanban.makeView({
163
- client,
164
- space,
165
- typename: DataType.Organization.typename,
166
- pivotFieldName: 'status',
167
- });
168
- space.db.add(view);
169
-
170
- // TODO(burdon): Replace with sdk/schema/testing.
171
- Array.from({ length: 80 }).map(() => {
172
- return space.db.add(Obj.make(DataType.Organization, rollOrg()));
173
- });
174
- },
139
+ types: [Organization.Organization, Person.Person, View.View, Kanban.Kanban],
140
+ onClientInitialized: ({ client }) =>
141
+ Effect.gen(function* () {
142
+ yield* Effect.promise(() => client.halo.createIdentity());
143
+ const space = yield* Effect.promise(() => client.spaces.create());
144
+ yield* Effect.promise(() => space.waitUntilReady());
145
+ const { view } = yield* Effect.promise(() =>
146
+ View.makeFromDatabase({
147
+ db: space.db,
148
+ typename: Organization.Organization.typename,
149
+ pivotFieldName: 'status',
150
+ }),
151
+ );
152
+ const kanban = Kanban.make({ view });
153
+ space.db.add(kanban);
154
+
155
+ // TODO(burdon): Replace with sdk/schema/testing.
156
+ Array.from({ length: 80 }).map(() => {
157
+ return space.db.add(Obj.make(Organization.Organization, createOrg()));
158
+ });
159
+ }),
175
160
  }),
176
- StorybookLayoutPlugin(),
177
161
  PreviewPlugin(),
178
- SpacePlugin(),
179
- IntentPlugin(),
180
- SettingsPlugin(),
162
+ SpacePlugin({}),
163
+ StorybookPlugin({}),
181
164
  ],
182
165
  }),
183
166
  ],
184
- } satisfies Meta<typeof StorybookKanban>;
167
+ parameters: {
168
+ layout: 'fullscreen',
169
+ translations: [...translations, ...kanbanTranslations],
170
+ },
171
+ } satisfies Meta<typeof DefaultComponent>;
185
172
 
186
173
  export default meta;
187
174
 
188
175
  type Story = StoryObj<typeof meta>;
189
176
 
190
- export const Default: Story = {};
177
+ export const Default: Story = {
178
+ play: async ({ canvasElement }) => {
179
+ const canvas = within(canvasElement);
180
+
181
+ // Wait for the kanban columns to render by finding the status tags.
182
+ // Organization.StatusOptions: prospect, qualified, active, commit, reject.
183
+ const activeTag = await canvas.findByText('Active', undefined, { timeout: 30_000 });
184
+ const prospectTag = await canvas.findByText('Prospect', undefined, { timeout: 10_000 });
185
+ const commitTag = await canvas.findByText('Commit', undefined, { timeout: 10_000 });
186
+
187
+ // Verify all expected columns are rendered.
188
+ await expect(activeTag).toBeTruthy();
189
+ await expect(prospectTag).toBeTruthy();
190
+ await expect(commitTag).toBeTruthy();
191
+
192
+ // Find the column containers.
193
+ const activeColumn = activeTag.closest('[data-dx-stack-item]') as HTMLElement;
194
+ const prospectColumn = prospectTag.closest('[data-dx-stack-item]') as HTMLElement;
195
+ await expect(activeColumn).toBeTruthy();
196
+ await expect(prospectColumn).toBeTruthy();
197
+
198
+ // Wait for cards to render in the columns.
199
+ // Cards have data-dx-item-id attribute from StackItem.Root.
200
+ const getColumnCards = (column: HTMLElement) =>
201
+ Array.from(column.querySelectorAll('[data-dx-item-id]')) as HTMLElement[];
202
+
203
+ await waitFor(() => expect(getColumnCards(activeColumn).length).toBeGreaterThan(0));
204
+
205
+ // Verify cards are distributed across columns.
206
+ const activeCards = getColumnCards(activeColumn);
207
+ const prospectCards = getColumnCards(prospectColumn);
208
+ await expect(activeCards.length).toBeGreaterThan(0);
209
+ await expect(prospectCards.length).toBeGreaterThan(0);
210
+
211
+ // Verify cards have drag handles (first button in toolbar).
212
+ const firstActiveCard = activeCards[0];
213
+ const buttons = firstActiveCard.querySelectorAll('button');
214
+ await expect(buttons.length).toBeGreaterThan(0);
215
+
216
+ // Verify the drop zone exists in each column.
217
+ const activeDropZone = activeColumn.querySelector('.kanban-drop');
218
+ const prospectDropZone = prospectColumn.querySelector('.kanban-drop');
219
+ await expect(activeDropZone).toBeTruthy();
220
+ await expect(prospectDropZone).toBeTruthy();
221
+
222
+ // TODO(wittjosiah): Get drag & drop tests working.
223
+ // See packages/apps/composer-app/src/playwright/stack.spec.ts for reference.
224
+ },
225
+ };
@@ -2,42 +2,38 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
5
+ import { RegistryContext } from '@effect-atom/atom-react';
6
+ import React, { useCallback, useContext, useEffect, useState } from 'react';
6
7
 
7
- import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
8
+ import { Common } from '@dxos/app-framework';
9
+ import { type SurfaceComponentProps, useCapabilities, useOperationInvoker } from '@dxos/app-framework/react';
8
10
  import { Filter, Obj, Type } from '@dxos/echo';
9
- import { EchoSchema, type TypedObject } from '@dxos/echo-schema';
10
11
  import { useGlobalFilteredObjects } from '@dxos/plugin-search';
11
- import { useClient } from '@dxos/react-client';
12
- import { getSpace, useQuery } from '@dxos/react-client/echo';
13
- import { Kanban, useKanbanModel } from '@dxos/react-ui-kanban';
14
- import { StackItem } from '@dxos/react-ui-stack';
15
- import { type DataType, ProjectionModel, typenameFromQuery } from '@dxos/schema';
12
+ import { useQuery } from '@dxos/react-client/echo';
13
+ import { Kanban as KanbanComponent, useKanbanModel, useProjectionModel } from '@dxos/react-ui-kanban';
14
+ import { type Kanban } from '@dxos/react-ui-kanban/types';
15
+ import { Layout } from '@dxos/react-ui-mosaic';
16
+ import { getTypenameFromQuery } from '@dxos/schema';
16
17
 
17
- import { KanbanAction } from '../types';
18
+ import { KanbanOperation } from '../types';
18
19
 
19
- export const KanbanContainer = ({ view }: { view: DataType.View; role: string }) => {
20
- const client = useClient();
21
- const [cardSchema, setCardSchema] = useState<TypedObject<any, any>>();
22
- const [projection, setProjection] = useState<ProjectionModel>();
23
- const space = getSpace(view);
24
- const { dispatchPromise: dispatch } = useIntentDispatcher();
25
- const typename = view.query ? typenameFromQuery(view.query) : undefined;
20
+ export type KanbanContainerProps = SurfaceComponentProps<Kanban.Kanban>;
26
21
 
27
- const jsonSchema = useMemo(() => {
28
- if (!cardSchema) {
29
- return undefined;
30
- }
31
- return cardSchema instanceof EchoSchema ? cardSchema.jsonSchema : Type.toJsonSchema(cardSchema);
32
- }, [cardSchema]);
22
+ export const KanbanContainer = ({ role, subject: object }: KanbanContainerProps) => {
23
+ const registry = useContext(RegistryContext);
24
+ const schemas = useCapabilities(Common.Capability.Schema);
25
+ const [cardSchema, setCardSchema] = useState<Type.Obj.Any>();
26
+ const db = Obj.getDatabase(object);
27
+ const { invokePromise } = useOperationInvoker();
28
+ const typename = object.view.target?.query ? getTypenameFromQuery(object.view.target.query.ast) : undefined;
33
29
 
34
30
  useEffect(() => {
35
- const staticSchema = client.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
31
+ const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
36
32
  if (staticSchema) {
37
- setCardSchema(() => staticSchema as TypedObject<any, any>);
33
+ setCardSchema(staticSchema);
38
34
  }
39
- if (!staticSchema && typename && space) {
40
- const query = space.db.schemaRegistry.query({ typename });
35
+ if (!staticSchema && typename && db) {
36
+ const query = db.schemaRegistry.query({ typename });
41
37
  const unsubscribe = query.subscribe(
42
38
  () => {
43
39
  const [schema] = query.results;
@@ -49,21 +45,14 @@ export const KanbanContainer = ({ view }: { view: DataType.View; role: string })
49
45
  );
50
46
  return unsubscribe;
51
47
  }
52
- }, [typename, space]);
53
-
54
- useEffect(() => {
55
- if (jsonSchema) {
56
- setProjection(new ProjectionModel(jsonSchema, view.projection));
57
- }
58
- // TODO(ZaymonFC): Is there a better way to get notified about deep changes in the json schema?
59
- }, [view.projection, JSON.stringify(jsonSchema)]);
48
+ }, [schemas, db, typename]);
60
49
 
61
- const objects = useQuery(space, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
50
+ const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
62
51
  const filteredObjects = useGlobalFilteredObjects(objects);
63
52
 
53
+ const projection = useProjectionModel(cardSchema, object, registry);
64
54
  const model = useKanbanModel({
65
- view,
66
- schema: cardSchema,
55
+ object,
67
56
  projection,
68
57
  items: filteredObjects,
69
58
  });
@@ -71,25 +60,25 @@ export const KanbanContainer = ({ view }: { view: DataType.View; role: string })
71
60
  const handleAddCard = useCallback(
72
61
  (columnValue: string | undefined) => {
73
62
  const path = model?.columnFieldPath;
74
- if (space && cardSchema && path) {
63
+ if (db && cardSchema && path) {
75
64
  const card = Obj.make(cardSchema, { [path]: columnValue });
76
- space.db.add(card);
65
+ db.add(card);
77
66
  return card.id;
78
67
  }
79
68
  },
80
- [space, cardSchema, model],
69
+ [db, cardSchema, model],
81
70
  );
82
71
 
83
72
  const handleRemoveCard = useCallback(
84
73
  (card: { id: string }) => {
85
- void dispatch(createIntent(KanbanAction.DeleteCard, { card }));
74
+ void invokePromise(KanbanOperation.DeleteCard, { card });
86
75
  },
87
- [dispatch],
76
+ [invokePromise],
88
77
  );
89
78
 
90
79
  return (
91
- <StackItem.Content>
92
- {model && <Kanban model={model} onAddCard={handleAddCard} onRemoveCard={handleRemoveCard} />}
93
- </StackItem.Content>
80
+ <Layout.Main role={role}>
81
+ {model && <KanbanComponent model={model} onAddCard={handleAddCard} onRemoveCard={handleRemoveCard} />}
82
+ </Layout.Main>
94
83
  );
95
84
  };
@@ -2,61 +2,58 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback, useMemo } from 'react';
6
-
7
- import { Type } from '@dxos/echo';
8
- import { EchoSchema, FormatEnum } from '@dxos/echo-schema';
9
- import { useClient } from '@dxos/react-client';
10
- import { getSpace, useSchema } from '@dxos/react-client/echo';
11
- import { type CustomInputMap, Form, SelectInput } from '@dxos/react-ui-form';
12
- import { Kanban } from '@dxos/react-ui-kanban/types';
13
- import { type DataType, ProjectionModel, typenameFromQuery } from '@dxos/schema';
14
-
15
- type KanbanViewEditorProps = { view: DataType.View };
16
-
17
- export const KanbanViewEditor = ({ view }: KanbanViewEditorProps) => {
18
- const client = useClient();
19
- const space = getSpace(view);
20
- const currentTypename = view.query ? typenameFromQuery(view.query) : undefined;
21
- const schema = useSchema(client, space, currentTypename);
22
-
23
- const projection = useMemo(() => {
24
- if (schema) {
25
- const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : Type.toJsonSchema(schema);
26
- return new ProjectionModel(jsonSchema, view.projection);
27
- }
28
- }, [view.projection, JSON.stringify(schema)]);
5
+ import { RegistryContext } from '@effect-atom/atom-react';
6
+ import React, { useCallback, useContext, useMemo } from 'react';
7
+
8
+ import { Obj } from '@dxos/echo';
9
+ import { Format } from '@dxos/echo/internal';
10
+ import { invariant } from '@dxos/invariant';
11
+ import { useSchema } from '@dxos/react-client/echo';
12
+ import { Form, type FormFieldMap, SelectField } from '@dxos/react-ui-form';
13
+ import { useProjectionModel } from '@dxos/react-ui-kanban';
14
+ import { type Kanban } from '@dxos/react-ui-kanban/types';
15
+ import { getTypenameFromQuery } from '@dxos/schema';
16
+
17
+ import { SettingsSchema } from '../types';
18
+
19
+ type KanbanViewEditorProps = { object: Kanban.Kanban };
20
+
21
+ export const KanbanViewEditor = ({ object }: KanbanViewEditorProps) => {
22
+ const registry = useContext(RegistryContext);
23
+ const db = Obj.getDatabase(object);
24
+ const view = object.view.target;
25
+ const currentTypename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;
26
+ const schema = useSchema(db, currentTypename);
27
+ const projection = useProjectionModel(schema, object, registry);
29
28
 
30
29
  const fieldProjections = projection?.getFieldProjections() || [];
31
30
  const selectFields = fieldProjections
32
- .filter((field) => field.props.format === FormatEnum.SingleSelect)
31
+ .filter((field) => field.props.format === Format.TypeFormat.SingleSelect)
33
32
  .map(({ field }) => ({ value: field.id, label: field.path }));
34
33
 
35
34
  const handleSave = useCallback(
36
35
  (values: Partial<{ columnFieldId: string }>) => {
37
- view.projection.pivotFieldId = values.columnFieldId;
36
+ invariant(view);
37
+ Obj.change(view, (v) => {
38
+ v.projection.pivotFieldId = values.columnFieldId;
39
+ });
38
40
  },
39
41
  [view],
40
42
  );
41
43
 
42
44
  const initialValues = useMemo(
43
- () => ({ columnFieldId: view.projection.pivotFieldId }),
44
- [view.projection.pivotFieldId],
45
+ () => ({ columnFieldId: view?.projection.pivotFieldId }),
46
+ [view?.projection.pivotFieldId],
45
47
  );
46
- const custom: CustomInputMap = useMemo(
47
- () => ({ columnFieldId: (props) => <SelectInput {...props} options={selectFields} /> }),
48
+
49
+ const fieldMap: FormFieldMap = useMemo(
50
+ () => ({ columnFieldId: (props) => <SelectField {...props} options={selectFields} /> }),
48
51
  [selectFields],
49
52
  );
50
53
 
51
54
  return (
52
- <Form
53
- Custom={custom}
54
- schema={Kanban.SettingsSchema}
55
- values={initialValues}
56
- onSave={handleSave}
57
- autoSave
58
- outerSpacing={false}
59
- classNames='pbs-inputSpacingBlock'
60
- />
55
+ <Form.Root schema={SettingsSchema} values={initialValues} fieldMap={fieldMap} autoSave onSave={handleSave}>
56
+ <Form.FieldSet />
57
+ </Form.Root>
61
58
  );
62
59
  };
package/src/meta.ts CHANGED
@@ -2,16 +2,18 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
6
7
 
7
- export const KANBAN_PLUGIN = 'dxos.org/plugin/kanban';
8
-
9
- export const meta: PluginMeta = {
10
- id: KANBAN_PLUGIN,
8
+ export const meta: Plugin.Meta = {
9
+ id: 'dxos.org/plugin/kanban',
11
10
  name: 'Kanban',
12
- description:
13
- 'Kanban allows you to explore Table data in sorted columns defined by your custom schema. You can use Kanbans to track progress or trigger custom automations when cards are moved from one state to another.',
11
+ description: trim`
12
+ Visual project management using customizable kanban boards to track workflow progress.
13
+ Organize table data into columns, drag and drop items between stages, and trigger automations based on status changes.
14
+ `,
14
15
  icon: 'ph--kanban--regular',
16
+ iconHue: 'green',
15
17
  source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-kanban',
16
18
  screenshots: ['https://dxos.network/plugin-details-kanban-dark.png'],
17
19
  };