@dxos/plugin-kanban 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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 (225) hide show
  1. package/dist/lib/browser/KanbanContainer-BCXSJ6KS.mjs +304 -0
  2. package/dist/lib/browser/KanbanContainer-BCXSJ6KS.mjs.map +7 -0
  3. package/dist/lib/browser/KanbanViewEditor-IH5CJ6BW.mjs +66 -0
  4. package/dist/lib/browser/KanbanViewEditor-IH5CJ6BW.mjs.map +7 -0
  5. package/dist/lib/browser/blueprint-definition-HFEKGFJK.mjs +17 -0
  6. package/dist/lib/browser/blueprint-definition-HFEKGFJK.mjs.map +7 -0
  7. package/dist/lib/browser/blueprints/index.mjs +8 -0
  8. package/dist/lib/browser/blueprints/index.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  10. package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-QSWCFMEB.mjs +385 -0
  12. package/dist/lib/browser/chunk-QSWCFMEB.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-RNFIFE2P.mjs +213 -0
  14. package/dist/lib/browser/chunk-RNFIFE2P.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-TLYZSC7O.mjs +29 -0
  16. package/dist/lib/browser/chunk-TLYZSC7O.mjs.map +7 -0
  17. package/dist/lib/browser/index.mjs +65 -68
  18. package/dist/lib/browser/index.mjs.map +4 -4
  19. package/dist/lib/browser/meta.json +1 -1
  20. package/dist/lib/browser/operation-resolver-BRA2OHUE.mjs +162 -0
  21. package/dist/lib/browser/operation-resolver-BRA2OHUE.mjs.map +7 -0
  22. package/dist/lib/browser/react-surface-FOMOGFVW.mjs +99 -0
  23. package/dist/lib/browser/react-surface-FOMOGFVW.mjs.map +7 -0
  24. package/dist/lib/browser/types/index.mjs +14 -5
  25. package/dist/lib/node-esm/KanbanContainer-EHRTLE7M.mjs +305 -0
  26. package/dist/lib/node-esm/KanbanContainer-EHRTLE7M.mjs.map +7 -0
  27. package/dist/lib/node-esm/KanbanViewEditor-WDACFC35.mjs +67 -0
  28. package/dist/lib/node-esm/KanbanViewEditor-WDACFC35.mjs.map +7 -0
  29. package/dist/lib/node-esm/blueprint-definition-NARBX32U.mjs +18 -0
  30. package/dist/lib/node-esm/blueprint-definition-NARBX32U.mjs.map +7 -0
  31. package/dist/lib/node-esm/blueprints/index.mjs +9 -0
  32. package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
  33. package/dist/lib/node-esm/chunk-4AWDHQVY.mjs +214 -0
  34. package/dist/lib/node-esm/chunk-4AWDHQVY.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-CSL3HF2X.mjs +386 -0
  36. package/dist/lib/node-esm/chunk-CSL3HF2X.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  38. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-X3UJUQIV.mjs +31 -0
  40. package/dist/lib/node-esm/chunk-X3UJUQIV.mjs.map +7 -0
  41. package/dist/lib/node-esm/index.mjs +65 -68
  42. package/dist/lib/node-esm/index.mjs.map +4 -4
  43. package/dist/lib/node-esm/meta.json +1 -1
  44. package/dist/lib/node-esm/operation-resolver-UEQ64LCN.mjs +163 -0
  45. package/dist/lib/node-esm/operation-resolver-UEQ64LCN.mjs.map +7 -0
  46. package/dist/lib/node-esm/react-surface-AITKFRBE.mjs +100 -0
  47. package/dist/lib/node-esm/react-surface-AITKFRBE.mjs.map +7 -0
  48. package/dist/lib/node-esm/types/index.mjs +14 -5
  49. package/dist/types/src/KanbanPlugin.d.ts +2 -1
  50. package/dist/types/src/KanbanPlugin.d.ts.map +1 -1
  51. package/dist/types/src/blueprints/index.d.ts +2 -0
  52. package/dist/types/src/blueprints/index.d.ts.map +1 -0
  53. package/dist/types/src/blueprints/kanban-blueprint.d.ts +4 -0
  54. package/dist/types/src/blueprints/kanban-blueprint.d.ts.map +1 -0
  55. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
  56. package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
  57. package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
  58. package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
  59. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +6 -0
  60. package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
  61. package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
  62. package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
  63. package/dist/types/src/capabilities/index.d.ts +3 -3
  64. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  65. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  66. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  67. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  68. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  69. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  70. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  71. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  72. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  73. package/dist/types/src/components/KanbanBoard/KanbanBoard.d.ts +58 -0
  74. package/dist/types/src/components/KanbanBoard/KanbanBoard.d.ts.map +1 -0
  75. package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts +70 -0
  76. package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts.map +1 -0
  77. package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts +10 -0
  78. package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts.map +1 -0
  79. package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts +9 -0
  80. package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts.map +1 -0
  81. package/dist/types/src/components/KanbanBoard/index.d.ts +2 -0
  82. package/dist/types/src/components/KanbanBoard/index.d.ts.map +1 -0
  83. package/dist/types/src/components/index.d.ts +1 -2
  84. package/dist/types/src/components/index.d.ts.map +1 -1
  85. package/dist/types/src/containers/KanbanContainer/KanbanContainer.d.ts +6 -0
  86. package/dist/types/src/containers/KanbanContainer/KanbanContainer.d.ts.map +1 -0
  87. package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts +77 -0
  88. package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts.map +1 -0
  89. package/dist/types/src/containers/KanbanContainer/index.d.ts +3 -0
  90. package/dist/types/src/containers/KanbanContainer/index.d.ts.map +1 -0
  91. package/dist/types/src/containers/KanbanViewEditor/KanbanViewEditor.d.ts +6 -0
  92. package/dist/types/src/containers/KanbanViewEditor/KanbanViewEditor.d.ts.map +1 -0
  93. package/dist/types/src/containers/KanbanViewEditor/index.d.ts +3 -0
  94. package/dist/types/src/containers/KanbanViewEditor/index.d.ts.map +1 -0
  95. package/dist/types/src/containers/index.d.ts +4 -0
  96. package/dist/types/src/containers/index.d.ts.map +1 -0
  97. package/dist/types/src/hooks/index.d.ts +6 -0
  98. package/dist/types/src/hooks/index.d.ts.map +1 -0
  99. package/dist/types/src/hooks/useEchoChangeCallback.d.ts +13 -0
  100. package/dist/types/src/hooks/useEchoChangeCallback.d.ts.map +1 -0
  101. package/dist/types/src/hooks/useKanbanBoardModel.d.ts +16 -0
  102. package/dist/types/src/hooks/useKanbanBoardModel.d.ts.map +1 -0
  103. package/dist/types/src/hooks/useKanbanBoardModel.test.d.ts +2 -0
  104. package/dist/types/src/hooks/useKanbanBoardModel.test.d.ts.map +1 -0
  105. package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts +22 -0
  106. package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts.map +1 -0
  107. package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts +19 -0
  108. package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts.map +1 -0
  109. package/dist/types/src/hooks/useProjectionModel.d.ts +15 -0
  110. package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
  111. package/dist/types/src/meta.d.ts +2 -2
  112. package/dist/types/src/meta.d.ts.map +1 -1
  113. package/dist/types/src/playwright/board-manager.d.ts +5 -0
  114. package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
  115. package/dist/types/src/playwright/playwright.config.d.ts +3 -0
  116. package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
  117. package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
  118. package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
  119. package/dist/types/src/testing/KanbanCardTileSimple.d.ts +5 -0
  120. package/dist/types/src/testing/KanbanCardTileSimple.d.ts.map +1 -0
  121. package/dist/types/src/testing/index.d.ts +2 -0
  122. package/dist/types/src/testing/index.d.ts.map +1 -0
  123. package/dist/types/src/translations.d.ts +35 -9
  124. package/dist/types/src/translations.d.ts.map +1 -1
  125. package/dist/types/src/types/Kanban.d.ts +37 -0
  126. package/dist/types/src/types/Kanban.d.ts.map +1 -0
  127. package/dist/types/src/types/constants.d.ts +6 -0
  128. package/dist/types/src/types/constants.d.ts.map +1 -0
  129. package/dist/types/src/types/index.d.ts +2 -0
  130. package/dist/types/src/types/index.d.ts.map +1 -1
  131. package/dist/types/src/types/schema.d.ts +98 -43
  132. package/dist/types/src/types/schema.d.ts.map +1 -1
  133. package/dist/types/src/types/types.d.ts +28 -0
  134. package/dist/types/src/types/types.d.ts.map +1 -1
  135. package/dist/types/src/util/arrangement.d.ts +68 -0
  136. package/dist/types/src/util/arrangement.d.ts.map +1 -0
  137. package/dist/types/src/util/arrangement.test.d.ts +2 -0
  138. package/dist/types/src/util/arrangement.test.d.ts.map +1 -0
  139. package/dist/types/src/util/index.d.ts +2 -0
  140. package/dist/types/src/util/index.d.ts.map +1 -0
  141. package/dist/types/tsconfig.tsbuildinfo +1 -1
  142. package/package.json +67 -46
  143. package/src/KanbanPlugin.tsx +35 -54
  144. package/src/blueprints/index.ts +5 -0
  145. package/src/blueprints/kanban-blueprint.ts +31 -0
  146. package/src/capabilities/artifact-definition/artifact-definition.ts +151 -0
  147. package/src/capabilities/artifact-definition/index.ts +7 -0
  148. package/src/capabilities/blueprint-definition/blueprint-definition.ts +17 -0
  149. package/src/capabilities/blueprint-definition/index.ts +7 -0
  150. package/src/capabilities/index.ts +3 -5
  151. package/src/capabilities/operation-resolver/index.ts +7 -0
  152. package/src/capabilities/operation-resolver/operation-resolver.ts +133 -0
  153. package/src/capabilities/react-surface/index.ts +7 -0
  154. package/src/capabilities/react-surface/react-surface.tsx +86 -0
  155. package/src/components/KanbanBoard/KanbanBoard.stories.tsx +142 -0
  156. package/src/components/KanbanBoard/KanbanBoard.tsx +184 -0
  157. package/src/components/KanbanBoard/KanbanCard.tsx +87 -0
  158. package/src/components/KanbanBoard/KanbanColumn.tsx +69 -0
  159. package/src/components/KanbanBoard/index.ts +5 -0
  160. package/src/components/index.ts +1 -2
  161. package/src/containers/KanbanContainer/KanbanContainer.stories.tsx +263 -0
  162. package/src/containers/KanbanContainer/KanbanContainer.tsx +87 -0
  163. package/src/containers/KanbanContainer/index.ts +7 -0
  164. package/src/containers/KanbanViewEditor/KanbanViewEditor.tsx +63 -0
  165. package/src/containers/KanbanViewEditor/index.ts +7 -0
  166. package/src/containers/index.ts +8 -0
  167. package/src/hooks/index.ts +9 -0
  168. package/src/hooks/useEchoChangeCallback.ts +30 -0
  169. package/src/hooks/useKanbanBoardModel.test.ts +235 -0
  170. package/src/hooks/useKanbanBoardModel.ts +143 -0
  171. package/src/hooks/useKanbanColumnEventHandler.ts +106 -0
  172. package/src/hooks/useKanbanItemEventHandler.ts +133 -0
  173. package/src/hooks/useProjectionModel.ts +58 -0
  174. package/src/meta.ts +8 -4
  175. package/src/playwright/board-manager.ts +13 -0
  176. package/src/playwright/playwright.config.ts +19 -0
  177. package/src/playwright/smoke.spec.ts +107 -0
  178. package/src/testing/KanbanCardTileSimple.tsx +76 -0
  179. package/src/testing/index.ts +5 -0
  180. package/src/translations.ts +13 -6
  181. package/src/types/Kanban.ts +67 -0
  182. package/src/types/constants.ts +9 -0
  183. package/src/types/index.ts +2 -0
  184. package/src/types/schema.ts +84 -38
  185. package/src/types/types.ts +35 -0
  186. package/src/util/arrangement.test.ts +208 -0
  187. package/src/util/arrangement.ts +167 -0
  188. package/src/util/index.ts +5 -0
  189. package/dist/lib/browser/blueprint-definition-UYVX622Q.mjs +0 -28
  190. package/dist/lib/browser/blueprint-definition-UYVX622Q.mjs.map +0 -7
  191. package/dist/lib/browser/chunk-K7KYFJ3P.mjs +0 -80
  192. package/dist/lib/browser/chunk-K7KYFJ3P.mjs.map +0 -7
  193. package/dist/lib/browser/intent-resolver-LR3SDMKQ.mjs +0 -111
  194. package/dist/lib/browser/intent-resolver-LR3SDMKQ.mjs.map +0 -7
  195. package/dist/lib/browser/react-surface-R2ORFB43.mjs +0 -255
  196. package/dist/lib/browser/react-surface-R2ORFB43.mjs.map +0 -7
  197. package/dist/lib/node-esm/blueprint-definition-42P47FUY.mjs +0 -30
  198. package/dist/lib/node-esm/blueprint-definition-42P47FUY.mjs.map +0 -7
  199. package/dist/lib/node-esm/chunk-VDWYSHP4.mjs +0 -82
  200. package/dist/lib/node-esm/chunk-VDWYSHP4.mjs.map +0 -7
  201. package/dist/lib/node-esm/intent-resolver-CKDNVLND.mjs +0 -112
  202. package/dist/lib/node-esm/intent-resolver-CKDNVLND.mjs.map +0 -7
  203. package/dist/lib/node-esm/react-surface-RMRLHCOY.mjs +0 -256
  204. package/dist/lib/node-esm/react-surface-RMRLHCOY.mjs.map +0 -7
  205. package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
  206. package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
  207. package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
  208. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
  209. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  210. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  211. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  212. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  213. package/dist/types/src/components/KanbanContainer.d.ts +0 -7
  214. package/dist/types/src/components/KanbanContainer.d.ts.map +0 -1
  215. package/dist/types/src/components/KanbanContainer.stories.d.ts +0 -41
  216. package/dist/types/src/components/KanbanContainer.stories.d.ts.map +0 -1
  217. package/dist/types/src/components/KanbanViewEditor.d.ts +0 -8
  218. package/dist/types/src/components/KanbanViewEditor.d.ts.map +0 -1
  219. package/src/capabilities/artifact-definition.ts +0 -148
  220. package/src/capabilities/blueprint-definition.ts +0 -30
  221. package/src/capabilities/intent-resolver.ts +0 -71
  222. package/src/capabilities/react-surface.tsx +0 -84
  223. package/src/components/KanbanContainer.stories.tsx +0 -193
  224. package/src/components/KanbanContainer.tsx +0 -95
  225. package/src/components/KanbanViewEditor.tsx +0 -64
@@ -1,71 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { Capabilities, type PluginContext, contributes, createResolver } from '@dxos/app-framework';
6
- import { invariant } from '@dxos/invariant';
7
- import { ClientCapabilities } from '@dxos/plugin-client';
8
- import { getSpace } from '@dxos/react-client/echo';
9
- import { Kanban } from '@dxos/react-ui-kanban/types';
10
- import { ProjectionModel, getTypenameFromQuery } from '@dxos/schema';
11
-
12
- import { meta } from '../meta';
13
- import { KanbanAction } from '../types';
14
-
15
- export default (context: PluginContext) =>
16
- contributes(Capabilities.IntentResolver, [
17
- createResolver({
18
- intent: KanbanAction.Create,
19
- resolve: async ({ space, name, typename, initialPivotColumn }) => {
20
- const client = context.getCapability(ClientCapabilities.Client);
21
- const { view } = await Kanban.makeView({
22
- client,
23
- space,
24
- name,
25
- typename,
26
- pivotFieldName: initialPivotColumn,
27
- });
28
- return { data: { object: view } };
29
- },
30
- }),
31
- createResolver({
32
- intent: KanbanAction.DeleteCardField,
33
- resolve: async ({ view, fieldId, deletionData }, undo) => {
34
- const schema = getSpace(view)?.db.schemaRegistry.getSchema(getTypenameFromQuery(view.query.ast)!);
35
- invariant(schema);
36
- const projection = new ProjectionModel(schema.jsonSchema, view.projection);
37
-
38
- if (!undo) {
39
- const { deleted, index } = projection.deleteFieldProjection(fieldId);
40
- return {
41
- undoable: {
42
- message: ['card field deleted label', { ns: meta.id }],
43
- data: { deletionData: { ...deleted, index } },
44
- },
45
- };
46
- } else if (undo && deletionData) {
47
- const { field, props, index } = deletionData;
48
- projection.setFieldProjection({ field, props }, index);
49
- }
50
- },
51
- }),
52
- createResolver({
53
- intent: KanbanAction.DeleteCard,
54
- resolve: ({ card }, undo) => {
55
- const space = getSpace(card);
56
- invariant(space);
57
-
58
- if (!undo) {
59
- space.db.remove(card);
60
- return {
61
- undoable: {
62
- message: ['card deleted label', { ns: meta.id }],
63
- data: { card },
64
- },
65
- };
66
- } else {
67
- space.db.add(card);
68
- }
69
- },
70
- }),
71
- ]);
@@ -1,84 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import type * as Schema from 'effect/Schema';
6
- import React, { useMemo } from 'react';
7
-
8
- import { Capabilities, contributes, createSurface, useCapabilities } from '@dxos/app-framework';
9
- import { Obj, Type } from '@dxos/echo';
10
- import { findAnnotation } from '@dxos/effect';
11
- import { ClientCapabilities } from '@dxos/plugin-client';
12
- import { type Space, getSpace, isSpace } from '@dxos/react-client/echo';
13
- import { type InputProps, SelectInput, useFormValues } from '@dxos/react-ui-form';
14
- import { Kanban } from '@dxos/react-ui-kanban/types';
15
- import { DataType } from '@dxos/schema';
16
-
17
- import { KanbanContainer, KanbanViewEditor } from '../components';
18
- import { meta } from '../meta';
19
- import { PivotColumnAnnotationId } from '../types';
20
-
21
- export default () =>
22
- contributes(Capabilities.ReactSurface, [
23
- createSurface({
24
- id: meta.id,
25
- role: ['article', 'section'],
26
- filter: (data): data is { subject: DataType.View } =>
27
- Obj.instanceOf(DataType.View, data.subject) && Obj.instanceOf(Kanban.Kanban, data.subject.presentation.target),
28
- component: ({ data, role }) => <KanbanContainer view={data.subject} role={role} />,
29
- }),
30
- createSurface({
31
- id: `${meta.id}/object-settings`,
32
- role: 'object-settings',
33
- position: 'hoist',
34
- filter: (data): data is { subject: DataType.View } =>
35
- Obj.instanceOf(DataType.View, data.subject) && Obj.instanceOf(Kanban.Kanban, data.subject.presentation.target),
36
- component: ({ data }) => <KanbanViewEditor view={data.subject} />,
37
- }),
38
- createSurface({
39
- id: `${meta.id}/create-initial-schema-form-[pivot-column]`,
40
- role: 'form-input',
41
- filter: (
42
- data,
43
- ): data is { prop: string; schema: Schema.Schema<any>; target: Space | DataType.Collection | undefined } => {
44
- const annotation = findAnnotation<boolean>((data.schema as Schema.Schema.All).ast, PivotColumnAnnotationId);
45
- return !!annotation;
46
- },
47
- component: ({ data: { target }, ...inputProps }) => {
48
- const props = inputProps as any as InputProps;
49
- const space = isSpace(target) ? target : getSpace(target);
50
- if (!space) {
51
- return null;
52
- }
53
- const { typename } = useFormValues();
54
- // TODO(wittjosiah): Unify this schema lookup.
55
- const schemaWhitelists = useCapabilities(ClientCapabilities.SchemaWhiteList);
56
- const staticSchema = schemaWhitelists.flat().find((schema) => Type.getTypename(schema) === typename);
57
- const [selectedSchema] = space?.db.schemaRegistry.query({ typename }).runSync();
58
-
59
- const singleSelectColumns = useMemo(() => {
60
- const properties = staticSchema
61
- ? Type.toJsonSchema(staticSchema).properties
62
- : selectedSchema?.jsonSchema?.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?.jsonSchema, staticSchema]);
76
-
77
- if (!typename) {
78
- return null;
79
- }
80
-
81
- return <SelectInput {...props} options={singleSelectColumns.map((column) => ({ value: column }))} />;
82
- },
83
- }),
84
- ]);
@@ -1,193 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React, { useCallback, useEffect, useState } from 'react';
7
-
8
- import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
9
- import { withPluginManager } from '@dxos/app-framework/testing';
10
- import { Obj, Query, Type } from '@dxos/echo';
11
- import { invariant } from '@dxos/invariant';
12
- import { ClientPlugin } from '@dxos/plugin-client';
13
- import { PreviewPlugin } from '@dxos/plugin-preview';
14
- import { useGlobalFilteredObjects } from '@dxos/plugin-search';
15
- import { SpacePlugin } from '@dxos/plugin-space';
16
- import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
17
- import { ThemePlugin } from '@dxos/plugin-theme';
18
- import { faker } from '@dxos/random';
19
- import { useClient } from '@dxos/react-client';
20
- import { Filter, useQuery, useSchema, useSpaces } from '@dxos/react-client/echo';
21
- import { withTheme } from '@dxos/react-ui/testing';
22
- import { ViewEditor } from '@dxos/react-ui-form';
23
- import { Kanban as KanbanComponent, useKanbanModel } from '@dxos/react-ui-kanban';
24
- 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';
27
- import { DataType, ProjectionModel, getTypenameFromQuery } from '@dxos/schema';
28
-
29
- import { translations } from '../translations';
30
-
31
- faker.seed(0);
32
-
33
- //
34
- // Story components.
35
- //
36
-
37
- const rollOrg = () => ({
38
- name: faker.commerce.productName(),
39
- description: faker.lorem.paragraph(),
40
- image: faker.image.url(),
41
- website: faker.internet.url(),
42
- status: faker.helpers.arrayElement(DataType.OrganizationStatusOptions).id as DataType.Organization['status'],
43
- });
44
-
45
- const StorybookKanban = () => {
46
- const client = useClient();
47
- const spaces = useSpaces();
48
- const space = spaces[spaces.length - 1];
49
- const views = useQuery(space, Filter.type(DataType.View));
50
- const [view, setView] = useState<DataType.View>();
51
- const [projection, setProjection] = useState<ProjectionModel>();
52
- const typename = view?.query ? getTypenameFromQuery(view.query.ast) : undefined;
53
- const schema = useSchema(client, space, typename);
54
-
55
- useEffect(() => {
56
- if (views.length && !view) {
57
- const view = views[0];
58
- setView(view);
59
- }
60
- }, [views]);
61
-
62
- useEffect(() => {
63
- if (view?.projection && schema) {
64
- const jsonSchema = Type.toJsonSchema(schema);
65
- setProjection(new ProjectionModel(jsonSchema, view.projection));
66
- }
67
- // TODO(ZaymonFC): Is there a better way to get notified about deep changes in the json schema?
68
- // @dmaretskyi? Once resolved, update in multiple places (e.g., storybooks).
69
- }, [view?.projection, schema, JSON.stringify(schema ? Type.toJsonSchema(schema) : {})]);
70
-
71
- const objects = useQuery(space, schema ? Filter.type(schema) : Filter.nothing());
72
- const filteredObjects = useGlobalFilteredObjects(objects);
73
-
74
- const model = useKanbanModel({
75
- view,
76
- schema,
77
- projection,
78
- items: filteredObjects,
79
- });
80
-
81
- const handleAddCard = useCallback(
82
- (columnValue: string | undefined) => {
83
- const path = model?.columnFieldPath;
84
- if (space && schema && path) {
85
- const card = Obj.make(schema, {
86
- ...rollOrg(),
87
- [path]: columnValue,
88
- });
89
-
90
- space.db.add(card);
91
- return card.id;
92
- }
93
- },
94
- [space, schema, model],
95
- );
96
-
97
- const handleRemoveCard = useCallback((card: { id: string }) => space.db.remove(card), [space]);
98
-
99
- const handleUpdateQuery = useCallback(
100
- (typename: string) => {
101
- invariant(schema);
102
- invariant(Type.isMutable(schema));
103
- invariant(view);
104
-
105
- schema.updateTypename(typename);
106
- view.query.ast = Query.select(Filter.typename(typename)).ast;
107
- },
108
- [view, schema],
109
- );
110
-
111
- if (!schema || !view) {
112
- return null;
113
- }
114
-
115
- return (
116
- <div className='grow grid grid-cols-[1fr_350px]'>
117
- {model ? <KanbanComponent model={model} onAddCard={handleAddCard} onRemoveCard={handleRemoveCard} /> : <div />}
118
- <div className='flex flex-col bs-full border-is border-separator overflow-y-auto'>
119
- <ViewEditor
120
- registry={space?.db.schemaRegistry}
121
- schema={schema}
122
- view={view}
123
- onQueryChanged={handleUpdateQuery}
124
- onDelete={(fieldId: string) => {
125
- console.log('[ViewEditor]', 'onDelete', fieldId);
126
- }}
127
- />
128
- <SyntaxHighlighter language='json' className='text-xs'>
129
- {JSON.stringify({ view, schema }, null, 2)}
130
- </SyntaxHighlighter>
131
- </div>
132
- </div>
133
- );
134
- };
135
-
136
- type StoryProps = {
137
- rows?: number;
138
- };
139
-
140
- //
141
- // Story definitions.
142
- //
143
-
144
- const meta = {
145
- title: 'plugins/plugin-kanban/Kanban',
146
- component: StorybookKanban,
147
- render: () => <StorybookKanban />,
148
- decorators: [
149
- withTheme,
150
- withPluginManager({
151
- plugins: [
152
- ClientPlugin({
153
- types: [DataType.Organization, DataType.Person, DataType.View, Kanban.Kanban],
154
- onClientInitialized: async ({ client }) => {
155
- await client.halo.createIdentity();
156
- const space = await client.spaces.create();
157
- await space.waitUntilReady();
158
- const { view } = await Kanban.makeView({
159
- client,
160
- space,
161
- typename: DataType.Organization.typename,
162
- pivotFieldName: 'status',
163
- });
164
- space.db.add(view);
165
-
166
- // TODO(burdon): Replace with sdk/schema/testing.
167
- Array.from({ length: 80 }).map(() => {
168
- return space.db.add(Obj.make(DataType.Organization, rollOrg()));
169
- });
170
- },
171
- }),
172
- SpacePlugin({}),
173
- IntentPlugin(),
174
- SettingsPlugin(),
175
-
176
- // UI
177
- ThemePlugin({ tx: defaultTx }),
178
- PreviewPlugin(),
179
- StorybookLayoutPlugin({}),
180
- ],
181
- }),
182
- ],
183
- parameters: {
184
- layout: 'fullscreen',
185
- translations,
186
- },
187
- } satisfies Meta<typeof StorybookKanban>;
188
-
189
- export default meta;
190
-
191
- type Story = StoryObj<typeof meta>;
192
-
193
- export const Default: Story = {};
@@ -1,95 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
6
-
7
- import { createIntent, useIntentDispatcher } from '@dxos/app-framework';
8
- import { Filter, Obj, Type } from '@dxos/echo';
9
- import { EchoSchema, type TypedObject } from '@dxos/echo/internal';
10
- 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, getTypenameFromQuery } from '@dxos/schema';
16
-
17
- import { KanbanAction } from '../types';
18
-
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 ? getTypenameFromQuery(view.query.ast) : undefined;
26
-
27
- const jsonSchema = useMemo(() => {
28
- if (!cardSchema) {
29
- return undefined;
30
- }
31
- return cardSchema instanceof EchoSchema ? cardSchema.jsonSchema : Type.toJsonSchema(cardSchema);
32
- }, [cardSchema]);
33
-
34
- useEffect(() => {
35
- const staticSchema = client.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
36
- if (staticSchema) {
37
- setCardSchema(() => staticSchema as TypedObject<any, any>);
38
- }
39
- if (!staticSchema && typename && space) {
40
- const query = space.db.schemaRegistry.query({ typename });
41
- const unsubscribe = query.subscribe(
42
- () => {
43
- const [schema] = query.results;
44
- if (schema) {
45
- setCardSchema(schema);
46
- }
47
- },
48
- { fire: true },
49
- );
50
- return unsubscribe;
51
- }
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)]);
60
-
61
- const objects = useQuery(space, cardSchema ? Filter.type(cardSchema) : Filter.nothing());
62
- const filteredObjects = useGlobalFilteredObjects(objects);
63
-
64
- const model = useKanbanModel({
65
- view,
66
- schema: cardSchema,
67
- projection,
68
- items: filteredObjects,
69
- });
70
-
71
- const handleAddCard = useCallback(
72
- (columnValue: string | undefined) => {
73
- const path = model?.columnFieldPath;
74
- if (space && cardSchema && path) {
75
- const card = Obj.make(cardSchema, { [path]: columnValue });
76
- space.db.add(card);
77
- return card.id;
78
- }
79
- },
80
- [space, cardSchema, model],
81
- );
82
-
83
- const handleRemoveCard = useCallback(
84
- (card: { id: string }) => {
85
- void dispatch(createIntent(KanbanAction.DeleteCard, { card }));
86
- },
87
- [dispatch],
88
- );
89
-
90
- return (
91
- <StackItem.Content>
92
- {model && <Kanban model={model} onAddCard={handleAddCard} onRemoveCard={handleRemoveCard} />}
93
- </StackItem.Content>
94
- );
95
- };
@@ -1,64 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { useCallback, useMemo } from 'react';
6
-
7
- import { Type } from '@dxos/echo';
8
- import { EchoSchema, FormatEnum } from '@dxos/echo/internal';
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, getTypenameFromQuery } 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 ? getTypenameFromQuery(view.query.ast) : 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
- const projection = new ProjectionModel(jsonSchema, view.projection);
27
- projection.normalizeView();
28
- return projection;
29
- }
30
- }, [view.projection, JSON.stringify(schema)]);
31
-
32
- const fieldProjections = projection?.getFieldProjections() || [];
33
- const selectFields = fieldProjections
34
- .filter((field) => field.props.format === FormatEnum.SingleSelect)
35
- .map(({ field }) => ({ value: field.id, label: field.path }));
36
-
37
- const handleSave = useCallback(
38
- (values: Partial<{ columnFieldId: string }>) => {
39
- view.projection.pivotFieldId = values.columnFieldId;
40
- },
41
- [view],
42
- );
43
-
44
- const initialValues = useMemo(
45
- () => ({ columnFieldId: view.projection.pivotFieldId }),
46
- [view.projection.pivotFieldId],
47
- );
48
- const custom: CustomInputMap = useMemo(
49
- () => ({ columnFieldId: (props) => <SelectInput {...props} options={selectFields} /> }),
50
- [selectFields],
51
- );
52
-
53
- return (
54
- <Form
55
- Custom={custom}
56
- schema={Kanban.SettingsSchema}
57
- values={initialValues}
58
- onSave={handleSave}
59
- autoSave
60
- outerSpacing={false}
61
- classNames='pbs-inputSpacingBlock'
62
- />
63
- );
64
- };