@dxos/plugin-kanban 0.8.4-main.7ace549 → 0.8.4-main.937b3ca

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 (116) 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 +52 -57
  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 +4 -3
  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 +52 -57
  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 +4 -3
  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 +3 -4
  62. package/dist/types/src/components/KanbanContainer.d.ts.map +1 -1
  63. package/dist/types/src/components/KanbanContainer.stories.d.ts +14 -2
  64. package/dist/types/src/components/KanbanContainer.stories.d.ts.map +1 -1
  65. package/dist/types/src/components/KanbanViewEditor.d.ts.map +1 -1
  66. package/dist/types/src/meta.d.ts +2 -2
  67. package/dist/types/src/meta.d.ts.map +1 -1
  68. package/dist/types/src/types/schema.d.ts +94 -43
  69. package/dist/types/src/types/schema.d.ts.map +1 -1
  70. package/dist/types/tsconfig.tsbuildinfo +1 -1
  71. package/package.json +63 -48
  72. package/src/KanbanPlugin.tsx +33 -46
  73. package/src/blueprints/index.ts +5 -0
  74. package/src/blueprints/kanban-blueprint.ts +24 -0
  75. package/src/capabilities/artifact-definition/artifact-definition.ts +150 -0
  76. package/src/capabilities/artifact-definition/index.ts +7 -0
  77. package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
  78. package/src/capabilities/blueprint-definition/index.ts +7 -0
  79. package/src/capabilities/index.ts +3 -5
  80. package/src/capabilities/operation-resolver/index.ts +7 -0
  81. package/src/capabilities/operation-resolver/operation-resolver.ts +133 -0
  82. package/src/capabilities/react-surface/index.ts +7 -0
  83. package/src/capabilities/react-surface/react-surface.tsx +86 -0
  84. package/src/components/KanbanContainer.stories.tsx +110 -61
  85. package/src/components/KanbanContainer.tsx +29 -27
  86. package/src/components/KanbanViewEditor.tsx +18 -20
  87. package/src/meta.ts +2 -2
  88. package/src/types/schema.ts +69 -35
  89. package/dist/lib/browser/blueprint-definition-UYVX622Q.mjs +0 -28
  90. package/dist/lib/browser/blueprint-definition-UYVX622Q.mjs.map +0 -7
  91. package/dist/lib/browser/chunk-B7EZTXV2.mjs +0 -101
  92. package/dist/lib/browser/chunk-B7EZTXV2.mjs.map +0 -7
  93. package/dist/lib/browser/intent-resolver-ANBDVEJ2.mjs +0 -114
  94. package/dist/lib/browser/intent-resolver-ANBDVEJ2.mjs.map +0 -7
  95. package/dist/lib/browser/react-surface-7ONRKYBB.mjs +0 -242
  96. package/dist/lib/browser/react-surface-7ONRKYBB.mjs.map +0 -7
  97. package/dist/lib/node-esm/blueprint-definition-42P47FUY.mjs +0 -30
  98. package/dist/lib/node-esm/blueprint-definition-42P47FUY.mjs.map +0 -7
  99. package/dist/lib/node-esm/chunk-WBN5YQGD.mjs +0 -103
  100. package/dist/lib/node-esm/chunk-WBN5YQGD.mjs.map +0 -7
  101. package/dist/lib/node-esm/intent-resolver-X4UZDRI7.mjs +0 -115
  102. package/dist/lib/node-esm/intent-resolver-X4UZDRI7.mjs.map +0 -7
  103. package/dist/lib/node-esm/react-surface-D7XTGTZL.mjs +0 -243
  104. package/dist/lib/node-esm/react-surface-D7XTGTZL.mjs.map +0 -7
  105. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  106. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  107. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  108. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  109. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  110. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  111. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  112. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  113. package/src/capabilities/artifact-definition.ts +0 -148
  114. package/src/capabilities/blueprint-definition.ts +0 -30
  115. package/src/capabilities/intent-resolver.ts +0 -66
  116. package/src/capabilities/react-surface.tsx +0 -83
@@ -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,28 +2,33 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { RegistryContext } from '@effect-atom/atom-react';
5
6
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React, { useCallback } from 'react';
7
+ import * as Effect from 'effect/Effect';
8
+ import React, { useCallback, useContext } from 'react';
9
+ import { expect, waitFor, within } from 'storybook/test';
7
10
 
8
- import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
9
11
  import { withPluginManager } from '@dxos/app-framework/testing';
10
12
  import { Obj, type QueryAST, Type } from '@dxos/echo';
13
+ import { type Mutable } from '@dxos/echo/internal';
11
14
  import { invariant } from '@dxos/invariant';
12
15
  import { ClientPlugin } from '@dxos/plugin-client';
13
16
  import { PreviewPlugin } from '@dxos/plugin-preview';
14
17
  import { useGlobalFilteredObjects } from '@dxos/plugin-search';
15
18
  import { SpacePlugin } from '@dxos/plugin-space';
16
- import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
17
- import { ThemePlugin } from '@dxos/plugin-theme';
19
+ import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
18
20
  import { faker } from '@dxos/random';
19
- import { useClient } from '@dxos/react-client';
20
21
  import { Filter, useQuery, useSchema, useSpaces } from '@dxos/react-client/echo';
21
22
  import { withTheme } from '@dxos/react-ui/testing';
22
23
  import { ViewEditor } from '@dxos/react-ui-form';
23
- import { Kanban as KanbanComponent, useKanbanModel, useProjectionModel } 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';
24
30
  import { Kanban } from '@dxos/react-ui-kanban/types';
25
- import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
26
- import { defaultTx } from '@dxos/react-ui-theme';
31
+ import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
27
32
  import { View, getTypenameFromQuery } from '@dxos/schema';
28
33
  import { Organization, Person } from '@dxos/types';
29
34
 
@@ -31,11 +36,7 @@ import { translations } from '../translations';
31
36
 
32
37
  faker.seed(0);
33
38
 
34
- //
35
- // Story components.
36
- //
37
-
38
- const rollOrg = () => ({
39
+ const createOrg = () => ({
39
40
  name: faker.commerce.productName(),
40
41
  description: faker.lorem.paragraph(),
41
42
  image: faker.image.url(),
@@ -43,18 +44,22 @@ const rollOrg = () => ({
43
44
  status: faker.helpers.arrayElement(Organization.StatusOptions).id as Organization.Organization['status'],
44
45
  });
45
46
 
46
- const StorybookKanban = () => {
47
- const client = useClient();
47
+ //
48
+ // Story components.
49
+ //
50
+
51
+ const DefaultComponent = () => {
52
+ const registry = useContext(RegistryContext);
48
53
  const spaces = useSpaces();
49
54
  const space = spaces[spaces.length - 1];
50
- const [object] = useQuery(space, Filter.type(Kanban.Kanban));
55
+ const [object] = useQuery(space?.db, Filter.type(Kanban.Kanban));
51
56
  const typename = object?.view.target?.query ? getTypenameFromQuery(object.view.target.query.ast) : undefined;
52
- const schema = useSchema(client, space, typename);
57
+ const schema = useSchema(space?.db, typename);
53
58
 
54
- const objects = useQuery(space, schema ? Filter.type(schema) : Filter.nothing());
59
+ const objects = useQuery(space?.db, schema ? Filter.type(schema) : Filter.nothing());
55
60
  const filteredObjects = useGlobalFilteredObjects(objects);
56
61
 
57
- const projection = useProjectionModel(schema, object);
62
+ const projection = useProjectionModel(schema, object, registry);
58
63
  const model = useKanbanModel({
59
64
  object,
60
65
  projection,
@@ -64,9 +69,9 @@ const StorybookKanban = () => {
64
69
  const handleAddCard = useCallback(
65
70
  (columnValue: string | undefined) => {
66
71
  const path = model?.columnFieldPath;
67
- if (space && schema && path) {
72
+ if (space && schema && Type.isObjectSchema(schema) && path) {
68
73
  const card = Obj.make(schema, {
69
- ...rollOrg(),
74
+ ...createOrg(),
70
75
  [path]: columnValue,
71
76
  });
72
77
 
@@ -86,7 +91,9 @@ const StorybookKanban = () => {
86
91
  invariant(object.view.target);
87
92
 
88
93
  schema.updateTypename(getTypenameFromQuery(newQuery));
89
- object.view.target.query.ast = newQuery;
94
+ Obj.change(object.view.target, (v) => {
95
+ v.query.ast = newQuery as Mutable<typeof newQuery>;
96
+ });
90
97
  },
91
98
  [object, schema],
92
99
  );
@@ -96,10 +103,11 @@ const StorybookKanban = () => {
96
103
  }
97
104
 
98
105
  return (
99
- <div className='grow grid grid-cols-[1fr_350px]'>
106
+ <div className='grow grid grid-cols-[1fr_350px] overflow-hidden'>
100
107
  {model ? <KanbanComponent model={model} onAddCard={handleAddCard} onRemoveCard={handleRemoveCard} /> : <div />}
101
- <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'>
102
109
  <ViewEditor
110
+ classNames='p-2'
103
111
  registry={space?.db.schemaRegistry}
104
112
  schema={schema}
105
113
  view={object.view.target}
@@ -108,70 +116,111 @@ const StorybookKanban = () => {
108
116
  console.log('[ViewEditor]', 'onDelete', fieldId);
109
117
  }}
110
118
  />
111
- <SyntaxHighlighter language='json' className='text-xs'>
112
- {JSON.stringify({ view: object.view.target, schema }, null, 2)}
113
- </SyntaxHighlighter>
119
+ <JsonFilter data={{ view: object.view.target, schema }} classNames='text-xs' />
114
120
  </div>
115
121
  </div>
116
122
  );
117
123
  };
118
124
 
119
- type StoryProps = {
120
- rows?: number;
121
- };
122
-
123
125
  //
124
126
  // Story definitions.
125
127
  //
126
128
 
127
129
  const meta = {
128
130
  title: 'plugins/plugin-kanban/Kanban',
129
- component: StorybookKanban,
130
- render: () => <StorybookKanban />,
131
+ component: DefaultComponent,
132
+ render: () => <DefaultComponent />,
131
133
  decorators: [
132
134
  withTheme,
133
135
  withPluginManager({
134
136
  plugins: [
137
+ ...corePlugins(),
135
138
  ClientPlugin({
136
139
  types: [Organization.Organization, Person.Person, View.View, Kanban.Kanban],
137
- onClientInitialized: async ({ client }) => {
138
- await client.halo.createIdentity();
139
- const space = await client.spaces.create();
140
- await space.waitUntilReady();
141
- const { view } = await View.makeFromSpace({
142
- client,
143
- space,
144
- typename: Organization.Organization.typename,
145
- pivotFieldName: 'status',
146
- });
147
- const kanban = Kanban.make({ view });
148
- space.db.add(kanban);
149
-
150
- // TODO(burdon): Replace with sdk/schema/testing.
151
- Array.from({ length: 80 }).map(() => {
152
- return space.db.add(Obj.make(Organization.Organization, rollOrg()));
153
- });
154
- },
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
+
146
+ const { view } = yield* Effect.promise(() =>
147
+ View.makeFromDatabase({
148
+ db: space.db,
149
+ typename: Organization.Organization.typename,
150
+ pivotFieldName: 'status',
151
+ }),
152
+ );
153
+ const kanban = Kanban.make({ view });
154
+ space.db.add(kanban);
155
+
156
+ // TODO(burdon): Replace with sdk/schema/testing.
157
+ Array.from({ length: 80 }).map(() => {
158
+ return space.db.add(Obj.make(Organization.Organization, createOrg()));
159
+ });
160
+ }),
155
161
  }),
156
- SpacePlugin({}),
157
- IntentPlugin(),
158
- SettingsPlugin(),
159
-
160
- // UI
161
- ThemePlugin({ tx: defaultTx }),
162
162
  PreviewPlugin(),
163
- StorybookLayoutPlugin({}),
163
+ SpacePlugin({}),
164
+ StorybookPlugin({}),
164
165
  ],
165
166
  }),
166
167
  ],
167
168
  parameters: {
168
169
  layout: 'fullscreen',
169
- translations,
170
+ translations: [...translations, ...kanbanTranslations],
170
171
  },
171
- } satisfies Meta<typeof StorybookKanban>;
172
+ } satisfies Meta<typeof DefaultComponent>;
172
173
 
173
174
  export default meta;
174
175
 
175
176
  type Story = StoryObj<typeof meta>;
176
177
 
177
- export const Default: Story = {};
178
+ export const Default: Story = {
179
+ play: async ({ canvasElement }) => {
180
+ const canvas = within(canvasElement);
181
+
182
+ // Wait for the kanban columns to render by finding the status tags.
183
+ // Organization.StatusOptions: prospect, qualified, active, commit, reject.
184
+ const activeTag = await canvas.findByText('Active', undefined, { timeout: 30_000 });
185
+ const prospectTag = await canvas.findByText('Prospect', undefined, { timeout: 10_000 });
186
+ const commitTag = await canvas.findByText('Commit', undefined, { timeout: 10_000 });
187
+
188
+ // Verify all expected columns are rendered.
189
+ await expect(activeTag).toBeTruthy();
190
+ await expect(prospectTag).toBeTruthy();
191
+ await expect(commitTag).toBeTruthy();
192
+
193
+ // Find the column containers.
194
+ const activeColumn = activeTag.closest('[data-dx-stack-item]') as HTMLElement;
195
+ const prospectColumn = prospectTag.closest('[data-dx-stack-item]') as HTMLElement;
196
+ await expect(activeColumn).toBeTruthy();
197
+ await expect(prospectColumn).toBeTruthy();
198
+
199
+ // Wait for cards to render in the columns.
200
+ // Cards have data-dx-item-id attribute from StackItem.Root.
201
+ const getColumnCards = (column: HTMLElement) =>
202
+ Array.from(column.querySelectorAll('[data-dx-item-id]')) as HTMLElement[];
203
+
204
+ await waitFor(() => expect(getColumnCards(activeColumn).length).toBeGreaterThan(0));
205
+
206
+ // Verify cards are distributed across columns.
207
+ const activeCards = getColumnCards(activeColumn);
208
+ const prospectCards = getColumnCards(prospectColumn);
209
+ await expect(activeCards.length).toBeGreaterThan(0);
210
+ await expect(prospectCards.length).toBeGreaterThan(0);
211
+
212
+ // Verify cards have drag handles (first button in toolbar).
213
+ const firstActiveCard = activeCards[0];
214
+ const buttons = firstActiveCard.querySelectorAll('button');
215
+ await expect(buttons.length).toBeGreaterThan(0);
216
+
217
+ // Verify the drop zone exists in each column.
218
+ const activeDropZone = activeColumn.querySelector('.kanban-drop');
219
+ const prospectDropZone = prospectColumn.querySelector('.kanban-drop');
220
+ await expect(activeDropZone).toBeTruthy();
221
+ await expect(prospectDropZone).toBeTruthy();
222
+
223
+ // TODO(wittjosiah): Get drag & drop tests working.
224
+ // See packages/apps/composer-app/src/playwright/stack.spec.ts for reference.
225
+ },
226
+ };
@@ -2,36 +2,38 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback, useEffect, 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 } from '@dxos/app-framework';
8
- import { useIntentDispatcher } from '@dxos/app-framework/react';
8
+ import { Common } from '@dxos/app-framework';
9
+ import { type SurfaceComponentProps, useCapabilities, useOperationInvoker } from '@dxos/app-framework/react';
9
10
  import { Filter, Obj, Type } from '@dxos/echo';
10
- import { type TypedObject } from '@dxos/echo/internal';
11
11
  import { useGlobalFilteredObjects } from '@dxos/plugin-search';
12
- import { useClient } from '@dxos/react-client';
13
- import { getSpace, useQuery } from '@dxos/react-client/echo';
12
+ import { useQuery } from '@dxos/react-client/echo';
14
13
  import { Kanban as KanbanComponent, useKanbanModel, useProjectionModel } from '@dxos/react-ui-kanban';
15
14
  import { type Kanban } from '@dxos/react-ui-kanban/types';
16
- import { StackItem } from '@dxos/react-ui-stack';
15
+ import { Layout } from '@dxos/react-ui-mosaic';
17
16
  import { getTypenameFromQuery } from '@dxos/schema';
18
17
 
19
- import { KanbanAction } from '../types';
18
+ import { KanbanOperation } from '../types';
20
19
 
21
- export const KanbanContainer = ({ object }: { object: Kanban.Kanban; role: string }) => {
22
- const client = useClient();
23
- const [cardSchema, setCardSchema] = useState<TypedObject<any, any>>();
24
- const space = getSpace(object);
25
- const { dispatchPromise: dispatch } = useIntentDispatcher();
20
+ export type KanbanContainerProps = SurfaceComponentProps<Kanban.Kanban>;
21
+
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();
26
28
  const typename = object.view.target?.query ? getTypenameFromQuery(object.view.target.query.ast) : undefined;
27
29
 
28
30
  useEffect(() => {
29
- const staticSchema = client.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
31
+ const staticSchema = schemas.flat().find((schema) => Type.getTypename(schema) === typename);
30
32
  if (staticSchema) {
31
- setCardSchema(() => staticSchema as TypedObject<any, any>);
33
+ setCardSchema(staticSchema);
32
34
  }
33
- if (!staticSchema && typename && space) {
34
- const query = space.db.schemaRegistry.query({ typename });
35
+ if (!staticSchema && typename && db) {
36
+ const query = db.schemaRegistry.query({ typename });
35
37
  const unsubscribe = query.subscribe(
36
38
  () => {
37
39
  const [schema] = query.results;
@@ -43,12 +45,12 @@ export const KanbanContainer = ({ object }: { object: Kanban.Kanban; role: strin
43
45
  );
44
46
  return unsubscribe;
45
47
  }
46
- }, [typename, space]);
48
+ }, [schemas, db, typename]);
47
49
 
48
- const objects = useQuery(space, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
50
+ const objects = useQuery(db, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
49
51
  const filteredObjects = useGlobalFilteredObjects(objects);
50
52
 
51
- const projection = useProjectionModel(cardSchema, object);
53
+ const projection = useProjectionModel(cardSchema, object, registry);
52
54
  const model = useKanbanModel({
53
55
  object,
54
56
  projection,
@@ -58,25 +60,25 @@ export const KanbanContainer = ({ object }: { object: Kanban.Kanban; role: strin
58
60
  const handleAddCard = useCallback(
59
61
  (columnValue: string | undefined) => {
60
62
  const path = model?.columnFieldPath;
61
- if (space && cardSchema && path) {
63
+ if (db && cardSchema && path) {
62
64
  const card = Obj.make(cardSchema, { [path]: columnValue });
63
- space.db.add(card);
65
+ db.add(card);
64
66
  return card.id;
65
67
  }
66
68
  },
67
- [space, cardSchema, model],
69
+ [db, cardSchema, model],
68
70
  );
69
71
 
70
72
  const handleRemoveCard = useCallback(
71
73
  (card: { id: string }) => {
72
- void dispatch(createIntent(KanbanAction.DeleteCard, { card }));
74
+ void invokePromise(KanbanOperation.DeleteCard, { card });
73
75
  },
74
- [dispatch],
76
+ [invokePromise],
75
77
  );
76
78
 
77
79
  return (
78
- <StackItem.Content>
80
+ <Layout.Main role={role}>
79
81
  {model && <KanbanComponent model={model} onAddCard={handleAddCard} onRemoveCard={handleRemoveCard} />}
80
- </StackItem.Content>
82
+ </Layout.Main>
81
83
  );
82
84
  };
@@ -2,13 +2,14 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback, useMemo } from 'react';
5
+ import { RegistryContext } from '@effect-atom/atom-react';
6
+ import React, { useCallback, useContext, useMemo } from 'react';
6
7
 
8
+ import { Obj } from '@dxos/echo';
7
9
  import { Format } from '@dxos/echo/internal';
8
10
  import { invariant } from '@dxos/invariant';
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';
11
+ import { useSchema } from '@dxos/react-client/echo';
12
+ import { Form, type FormFieldMap, SelectField } from '@dxos/react-ui-form';
12
13
  import { useProjectionModel } from '@dxos/react-ui-kanban';
13
14
  import { type Kanban } from '@dxos/react-ui-kanban/types';
14
15
  import { getTypenameFromQuery } from '@dxos/schema';
@@ -18,12 +19,12 @@ import { SettingsSchema } from '../types';
18
19
  type KanbanViewEditorProps = { object: Kanban.Kanban };
19
20
 
20
21
  export const KanbanViewEditor = ({ object }: KanbanViewEditorProps) => {
21
- const client = useClient();
22
- const space = getSpace(object);
22
+ const registry = useContext(RegistryContext);
23
+ const db = Obj.getDatabase(object);
23
24
  const view = object.view.target;
24
25
  const currentTypename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;
25
- const schema = useSchema(client, space, currentTypename);
26
- const projection = useProjectionModel(schema, object);
26
+ const schema = useSchema(db, currentTypename);
27
+ const projection = useProjectionModel(schema, object, registry);
27
28
 
28
29
  const fieldProjections = projection?.getFieldProjections() || [];
29
30
  const selectFields = fieldProjections
@@ -33,7 +34,9 @@ export const KanbanViewEditor = ({ object }: KanbanViewEditorProps) => {
33
34
  const handleSave = useCallback(
34
35
  (values: Partial<{ columnFieldId: string }>) => {
35
36
  invariant(view);
36
- view.projection.pivotFieldId = values.columnFieldId;
37
+ Obj.change(view, (v) => {
38
+ v.projection.pivotFieldId = values.columnFieldId;
39
+ });
37
40
  },
38
41
  [view],
39
42
  );
@@ -42,20 +45,15 @@ export const KanbanViewEditor = ({ object }: KanbanViewEditorProps) => {
42
45
  () => ({ columnFieldId: view?.projection.pivotFieldId }),
43
46
  [view?.projection.pivotFieldId],
44
47
  );
45
- const custom: CustomInputMap = useMemo(
46
- () => ({ columnFieldId: (props) => <SelectInput {...props} options={selectFields} /> }),
48
+
49
+ const fieldMap: FormFieldMap = useMemo(
50
+ () => ({ columnFieldId: (props) => <SelectField {...props} options={selectFields} /> }),
47
51
  [selectFields],
48
52
  );
49
53
 
50
54
  return (
51
- <Form
52
- Custom={custom}
53
- schema={SettingsSchema}
54
- values={initialValues}
55
- onSave={handleSave}
56
- autoSave
57
- outerSpacing={false}
58
- classNames='pbs-inputSpacingBlock'
59
- />
55
+ <Form.Root schema={SettingsSchema} values={initialValues} fieldMap={fieldMap} autoSave onSave={handleSave}>
56
+ <Form.FieldSet />
57
+ </Form.Root>
60
58
  );
61
59
  };
package/src/meta.ts CHANGED
@@ -2,10 +2,10 @@
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
6
  import { trim } from '@dxos/util';
7
7
 
8
- export const meta: PluginMeta = {
8
+ export const meta: Plugin.Meta = {
9
9
  id: 'dxos.org/plugin/kanban',
10
10
  name: 'Kanban',
11
11
  description: trim`
@@ -4,9 +4,9 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
+ import { Capability } from '@dxos/app-framework';
8
+ import { Operation } from '@dxos/operation';
7
9
  import { TypeInputOptionsAnnotation } from '@dxos/plugin-space/types';
8
- import { SpaceSchema } from '@dxos/react-client/echo';
9
- import { Kanban } from '@dxos/react-ui-kanban/types';
10
10
  import { FieldSchema, View } from '@dxos/schema';
11
11
 
12
12
  import { meta } from '../meta';
@@ -25,7 +25,7 @@ export const PivotColumnAnnotationId = Symbol.for('@dxos/plugin-kanban/annotatio
25
25
 
26
26
  export const SettingsSchema = Schema.Struct({
27
27
  columnFieldId: Schema.String.annotations({
28
- title: 'Column field identifier',
28
+ title: 'Column field',
29
29
  }),
30
30
  });
31
31
 
@@ -49,38 +49,72 @@ export const CreateKanbanSchema = Schema.Struct({
49
49
  ),
50
50
  });
51
51
 
52
- export namespace KanbanAction {
53
- const KANBAN_ACTION = `${meta.id}/action`;
52
+ const KANBAN_OPERATION = `${meta.id}/operation`;
54
53
 
55
- export class Create extends Schema.TaggedClass<Create>()(`${KANBAN_ACTION}/create`, {
56
- input: Schema.extend(Schema.Struct({ space: SpaceSchema }), CreateKanbanSchema),
57
- output: Schema.Struct({
58
- object: Kanban.Kanban,
59
- }),
60
- }) {}
61
-
62
- export class DeleteCardField extends Schema.TaggedClass<DeleteCardField>()(`${KANBAN_ACTION}/delete-card-field`, {
63
- input: Schema.Struct({
64
- view: View.View,
65
- fieldId: Schema.String,
66
- // TODO(wittjosiah): Separate fields for undo data?
67
- deletionData: Schema.optional(
68
- Schema.Struct({
69
- field: FieldSchema,
70
- // TODO(wittjosiah): This creates a type error.
71
- // props: PropertySchema,
72
- props: Schema.Any,
73
- index: Schema.Number,
74
- }),
75
- ),
76
- }),
77
- output: Schema.Void,
78
- }) {}
54
+ export namespace KanbanOperation {
55
+ export const DeleteCardFieldOutput = Schema.Struct({
56
+ field: FieldSchema.annotations({ description: 'The deleted field schema.' }),
57
+ props: Schema.Any.annotations({ description: 'The deleted field properties.' }),
58
+ index: Schema.Number.annotations({ description: 'The index the field was at.' }),
59
+ });
79
60
 
80
- export class DeleteCard extends Schema.TaggedClass<DeleteCard>()(`${KANBAN_ACTION}/delete-card`, {
81
- input: Schema.Struct({
82
- card: Schema.Any, // The card object to delete
83
- }),
84
- output: Schema.Void,
85
- }) {}
61
+ export type DeleteCardFieldOutput = Schema.Schema.Type<typeof DeleteCardFieldOutput>;
62
+
63
+ export const DeleteCardField = Operation.make({
64
+ meta: { key: `${KANBAN_OPERATION}/delete-card-field`, name: 'Delete Card Field' },
65
+ services: [Capability.Service],
66
+ schema: {
67
+ input: Schema.Struct({
68
+ view: View.View,
69
+ fieldId: Schema.String,
70
+ }),
71
+ output: DeleteCardFieldOutput,
72
+ },
73
+ });
74
+
75
+ export const DeleteCardOutput = Schema.Struct({
76
+ card: Schema.Any.annotations({ description: 'The deleted card.' }),
77
+ });
78
+
79
+ export type DeleteCardOutput = Schema.Schema.Type<typeof DeleteCardOutput>;
80
+
81
+ export const DeleteCard = Operation.make({
82
+ meta: { key: `${KANBAN_OPERATION}/delete-card`, name: 'Delete Card' },
83
+ schema: {
84
+ input: Schema.Struct({
85
+ card: Schema.Any,
86
+ }),
87
+ output: DeleteCardOutput,
88
+ },
89
+ });
90
+
91
+ /**
92
+ * Restore a deleted card field (inverse of DeleteCardField).
93
+ */
94
+ export const RestoreCardField = Operation.make({
95
+ meta: { key: `${KANBAN_OPERATION}/restore-card-field`, name: 'Restore Card Field' },
96
+ services: [Capability.Service],
97
+ schema: {
98
+ input: Schema.Struct({
99
+ view: View.View.annotations({ description: 'The view to restore the field to.' }),
100
+ field: FieldSchema.annotations({ description: 'The field schema to restore.' }),
101
+ props: Schema.Any.annotations({ description: 'The field properties to restore.' }),
102
+ index: Schema.Number.annotations({ description: 'The index to restore the field at.' }),
103
+ }),
104
+ output: Schema.Void,
105
+ },
106
+ });
107
+
108
+ /**
109
+ * Restore a deleted card (inverse of DeleteCard).
110
+ */
111
+ export const RestoreCard = Operation.make({
112
+ meta: { key: `${KANBAN_OPERATION}/restore-card`, name: 'Restore Card' },
113
+ schema: {
114
+ input: Schema.Struct({
115
+ card: Schema.Any.annotations({ description: 'The card to restore.' }),
116
+ }),
117
+ output: Schema.Void,
118
+ },
119
+ });
86
120
  }