@dxos/plugin-kanban 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/neutral/KanbanContainer-QK6LNCYT.mjs +132 -0
- package/dist/lib/neutral/KanbanContainer-QK6LNCYT.mjs.map +7 -0
- package/dist/lib/neutral/KanbanPlugin.mjs +36 -0
- package/dist/lib/neutral/KanbanPlugin.mjs.map +7 -0
- package/dist/lib/neutral/KanbanPlugin.node.mjs +27 -0
- package/dist/lib/neutral/KanbanPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/KanbanSettings-G6M47NSK.mjs +83 -0
- package/dist/lib/neutral/KanbanSettings-G6M47NSK.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-FHVIEKTQ.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-FHVIEKTQ.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +8 -0
- package/dist/lib/neutral/capabilities/index.mjs +19 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-E65AME5F.mjs +255 -0
- package/dist/lib/neutral/chunk-E65AME5F.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-KDPM77BD.mjs +21 -0
- package/dist/lib/neutral/chunk-KDPM77BD.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Z7O5CETK.mjs +8 -0
- package/dist/lib/neutral/chunk-Z7O5CETK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZTQW5KQS.mjs +26 -0
- package/dist/lib/neutral/chunk-ZTQW5KQS.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +243 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +11 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-DKBSI46K.mjs +40 -0
- package/dist/lib/neutral/create-object-DKBSI46K.mjs.map +7 -0
- package/dist/lib/neutral/delete-card-QKT6OXGP.mjs +24 -0
- package/dist/lib/neutral/delete-card-QKT6OXGP.mjs.map +7 -0
- package/dist/lib/neutral/delete-card-field-XQKM7ZXE.mjs +42 -0
- package/dist/lib/neutral/delete-card-field-XQKM7ZXE.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +432 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +34 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/migrations-4NS6H7U2.mjs +31 -0
- package/dist/lib/neutral/migrations-4NS6H7U2.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-B7IW6MXU.mjs +13 -0
- package/dist/lib/neutral/operation-handler-B7IW6MXU.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-6RVSCHMJ.mjs +93 -0
- package/dist/lib/neutral/react-surface-6RVSCHMJ.mjs.map +7 -0
- package/dist/lib/neutral/restore-card-XW7AHMPO.mjs +21 -0
- package/dist/lib/neutral/restore-card-XW7AHMPO.mjs.map +7 -0
- package/dist/lib/neutral/restore-card-field-QOAUY3RJ.mjs +40 -0
- package/dist/lib/neutral/restore-card-field-QOAUY3RJ.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +60 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +44 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +22 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/neutral/undo-mappings-6CHW6BOF.mjs +42 -0
- package/dist/lib/neutral/undo-mappings-6CHW6BOF.mjs.map +7 -0
- package/dist/types/src/KanbanPlugin.d.ts +3 -1
- package/dist/types/src/KanbanPlugin.d.ts.map +1 -1
- package/dist/types/src/KanbanPlugin.node.d.ts +4 -0
- package/dist/types/src/KanbanPlugin.node.d.ts.map +1 -0
- package/dist/types/src/KanbanPlugin.test.d.ts +2 -0
- package/dist/types/src/KanbanPlugin.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/kanban-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/kanban-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition.d.ts +3 -2
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -4
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +13 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/migrations.d.ts +5 -0
- package/dist/types/src/capabilities/migrations.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/undo-mappings.d.ts +5 -0
- package/dist/types/src/capabilities/undo-mappings.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/KanbanBoard.d.ts +37 -0
- package/dist/types/src/components/KanbanBoard/KanbanBoard.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts +72 -0
- package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts +9 -0
- package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts +8 -0
- package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/context.d.ts +38 -0
- package/dist/types/src/components/KanbanBoard/context.d.ts.map +1 -0
- package/dist/types/src/components/KanbanBoard/index.d.ts +2 -0
- package/dist/types/src/components/KanbanBoard/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.d.ts +6 -0
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts +79 -0
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanContainer/index.d.ts +2 -0
- package/dist/types/src/containers/KanbanContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanSettings/KanbanSettings.d.ts +13 -0
- package/dist/types/src/containers/KanbanSettings/KanbanSettings.d.ts.map +1 -0
- package/dist/types/src/containers/KanbanSettings/index.d.ts +2 -0
- package/dist/types/src/containers/KanbanSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +7 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useEchoChangeCallback.d.ts +13 -0
- package/dist/types/src/hooks/useEchoChangeCallback.d.ts.map +1 -0
- package/dist/types/src/hooks/useItemsProjection.d.ts +10 -0
- package/dist/types/src/hooks/useItemsProjection.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanBoardModel.browser.test.d.ts +2 -0
- package/dist/types/src/hooks/useKanbanBoardModel.browser.test.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanBoardModel.d.ts +16 -0
- package/dist/types/src/hooks/useKanbanBoardModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts +22 -0
- package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts +19 -0
- package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts +15 -0
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/delete-card-field.d.ts +5 -0
- package/dist/types/src/operations/delete-card-field.d.ts.map +1 -0
- package/dist/types/src/operations/delete-card.d.ts +5 -0
- package/dist/types/src/operations/delete-card.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/restore-card-field.d.ts +5 -0
- package/dist/types/src/operations/restore-card-field.d.ts.map +1 -0
- package/dist/types/src/operations/restore-card.d.ts +5 -0
- package/dist/types/src/operations/restore-card.d.ts.map +1 -0
- package/dist/types/src/playwright/board-manager.d.ts +5 -0
- package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
- package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/KanbanCardTileSimple.d.ts +7 -0
- package/dist/types/src/testing/KanbanCardTileSimple.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +50 -22
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Kanban.d.ts +109 -0
- package/dist/types/src/types/Kanban.d.ts.map +1 -0
- package/dist/types/src/types/KanbanOperation.d.ts +52 -0
- package/dist/types/src/types/KanbanOperation.d.ts.map +1 -0
- package/dist/types/src/types/constants.d.ts +6 -0
- package/dist/types/src/types/constants.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/migrations.test.d.ts +2 -0
- package/dist/types/src/types/migrations.test.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +18 -52
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +28 -0
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util/arrangement.d.ts +72 -0
- package/dist/types/src/util/arrangement.d.ts.map +1 -0
- package/dist/types/src/util/arrangement.test.d.ts +2 -0
- package/dist/types/src/util/arrangement.test.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +120 -57
- package/src/KanbanPlugin.node.ts +21 -0
- package/src/KanbanPlugin.test.ts +31 -0
- package/src/KanbanPlugin.tsx +29 -57
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/kanban-blueprint.ts +27 -0
- package/src/capabilities/artifact-definition.ts +117 -113
- package/src/capabilities/blueprint-definition.ts +13 -24
- package/src/capabilities/create-object.ts +40 -0
- package/src/capabilities/index.ts +12 -4
- package/src/capabilities/migrations.ts +35 -0
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/capabilities/react-surface.tsx +79 -68
- package/src/capabilities/undo-mappings.ts +34 -0
- package/src/components/KanbanBoard/KanbanBoard.stories.tsx +146 -0
- package/src/components/KanbanBoard/KanbanBoard.tsx +164 -0
- package/src/components/KanbanBoard/KanbanCard.tsx +101 -0
- package/src/components/KanbanBoard/KanbanColumn.tsx +72 -0
- package/src/components/KanbanBoard/context.ts +54 -0
- package/src/components/KanbanBoard/index.ts +5 -0
- package/src/components/index.ts +1 -2
- package/src/containers/KanbanContainer/KanbanContainer.stories.tsx +277 -0
- package/src/containers/KanbanContainer/KanbanContainer.tsx +178 -0
- package/src/containers/KanbanContainer/index.ts +5 -0
- package/src/containers/KanbanSettings/KanbanSettings.tsx +94 -0
- package/src/containers/KanbanSettings/index.ts +5 -0
- package/src/containers/index.ts +8 -0
- package/src/hooks/index.ts +10 -0
- package/src/hooks/useEchoChangeCallback.ts +30 -0
- package/src/hooks/useItemsProjection.ts +44 -0
- package/src/hooks/useKanbanBoardModel.browser.test.ts +235 -0
- package/src/hooks/useKanbanBoardModel.ts +157 -0
- package/src/hooks/useKanbanColumnEventHandler.ts +106 -0
- package/src/hooks/useKanbanItemEventHandler.ts +133 -0
- package/src/hooks/useProjectionModel.ts +58 -0
- package/src/index.ts +3 -2
- package/src/meta.ts +9 -7
- package/src/operations/delete-card-field.ts +47 -0
- package/src/operations/delete-card.ts +23 -0
- package/src/operations/index.ts +10 -0
- package/src/operations/restore-card-field.ts +41 -0
- package/src/operations/restore-card.ts +21 -0
- package/src/playwright/board-manager.ts +13 -0
- package/src/playwright/playwright.config.ts +19 -0
- package/src/playwright/smoke.spec.ts +107 -0
- package/src/plugin.ts +11 -0
- package/src/testing/KanbanCardTileSimple.tsx +82 -0
- package/src/testing/index.ts +5 -0
- package/src/translations.ts +28 -20
- package/src/types/Kanban.ts +151 -0
- package/src/types/KanbanOperation.ts +67 -0
- package/src/types/constants.ts +9 -0
- package/src/types/index.ts +4 -0
- package/src/types/migrations.test.ts +83 -0
- package/src/types/schema.ts +33 -45
- package/src/types/types.ts +35 -0
- package/src/util/arrangement.test.ts +218 -0
- package/src/util/arrangement.ts +177 -0
- package/src/util/index.ts +5 -0
- package/dist/lib/browser/blueprint-definition-GFG7LX2C.mjs +0 -28
- package/dist/lib/browser/blueprint-definition-GFG7LX2C.mjs.map +0 -7
- package/dist/lib/browser/chunk-NCNNL74W.mjs +0 -82
- package/dist/lib/browser/chunk-NCNNL74W.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -106
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-KHOAFPNN.mjs +0 -111
- package/dist/lib/browser/intent-resolver-KHOAFPNN.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-UBRYXDKS.mjs +0 -253
- package/dist/lib/browser/react-surface-UBRYXDKS.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -11
- package/dist/lib/node-esm/blueprint-definition-MIMDXMUM.mjs +0 -30
- package/dist/lib/node-esm/blueprint-definition-MIMDXMUM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5B3LKGA7.mjs +0 -84
- package/dist/lib/node-esm/chunk-5B3LKGA7.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -107
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-MKO5HVES.mjs +0 -112
- package/dist/lib/node-esm/intent-resolver-MKO5HVES.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-B2FPS52G.mjs +0 -254
- package/dist/lib/node-esm/react-surface-B2FPS52G.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -12
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/KanbanContainer.d.ts +0 -7
- package/dist/types/src/components/KanbanContainer.d.ts.map +0 -1
- package/dist/types/src/components/KanbanContainer.stories.d.ts +0 -41
- package/dist/types/src/components/KanbanContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/KanbanViewEditor.d.ts +0 -8
- package/dist/types/src/components/KanbanViewEditor.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -71
- package/src/components/KanbanContainer.stories.tsx +0 -190
- package/src/components/KanbanContainer.tsx +0 -95
- package/src/components/KanbanViewEditor.tsx +0 -62
- /package/dist/lib/{browser/types → neutral/blueprints}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom, type Registry } from '@effect-atom/atom-react';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
|
+
import { AtomObj } from '@dxos/echo-atom';
|
|
10
|
+
import type { BoardModel } from '@dxos/react-ui-mosaic';
|
|
11
|
+
import type { ProjectionModel } from '@dxos/schema';
|
|
12
|
+
|
|
13
|
+
import { type BaseKanbanItem, type ColumnStructure, type Kanban } from '#types';
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
computeColumnStructure,
|
|
17
|
+
getOrderByColumnFromArrangement,
|
|
18
|
+
getOrderFromArrangement,
|
|
19
|
+
orderItemsInColumn,
|
|
20
|
+
} from '../util';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Builds a board model that maps kanban arrangement and projection onto columns and per-column items.
|
|
24
|
+
*
|
|
25
|
+
* @template T - Item type (must have id; defaults to BaseKanbanItem).
|
|
26
|
+
* @param kanban - Kanban object (arrangement, view).
|
|
27
|
+
* @param projection - ProjectionModel for pivot field and options.
|
|
28
|
+
* @param itemsAtom - Atom holding the full item list.
|
|
29
|
+
* @param registry - Registry for reading atom values.
|
|
30
|
+
* @returns BoardModel with columns atom, items family, and getColumns/getItems.
|
|
31
|
+
*/
|
|
32
|
+
export function useKanbanBoardModel<T extends BaseKanbanItem = BaseKanbanItem>(
|
|
33
|
+
kanban: Kanban.Kanban,
|
|
34
|
+
projection: ProjectionModel,
|
|
35
|
+
itemsAtom: Atom.Atom<T[]>,
|
|
36
|
+
registry: Registry.Registry,
|
|
37
|
+
): BoardModel<ColumnStructure, T> {
|
|
38
|
+
// Source atoms: reactive reads from the kanban object; items come from the passed-in atom (e.g. AtomQuery or in-memory).
|
|
39
|
+
const arrangementAtom = useMemo(() => AtomObj.makeProperty(kanban, 'arrangement'), [kanban]);
|
|
40
|
+
const viewSnapshotAtom = useMemo(
|
|
41
|
+
() =>
|
|
42
|
+
kanban?.spec?.kind === 'view' && kanban.spec.view
|
|
43
|
+
? AtomObj.make(kanban.spec.view)
|
|
44
|
+
: Atom.make<undefined>(() => undefined),
|
|
45
|
+
[kanban?.spec],
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Only changes when the discriminator-relevant pivot input changes.
|
|
50
|
+
* View-variant: derived from `view.projection.pivotFieldId`.
|
|
51
|
+
* Items-variant: the kanban's `spec.pivotField` (the property name itself acts as the field id).
|
|
52
|
+
*/
|
|
53
|
+
const pivotFieldIdAtom = useMemo(
|
|
54
|
+
() =>
|
|
55
|
+
Atom.make((get) => {
|
|
56
|
+
if (kanban?.spec.kind === 'items') {
|
|
57
|
+
return kanban.spec.pivotField;
|
|
58
|
+
}
|
|
59
|
+
return get(viewSnapshotAtom)?.projection?.pivotFieldId as string | undefined;
|
|
60
|
+
}),
|
|
61
|
+
[kanban?.spec, viewSnapshotAtom],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// Effective per-column ids: from kanban.arrangement.columns; empty when arrangement has no columns.
|
|
65
|
+
const effectiveByColumnAtom = useMemo(
|
|
66
|
+
() => Atom.make((get) => getOrderByColumnFromArrangement(get(arrangementAtom))),
|
|
67
|
+
[arrangementAtom],
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// Column structure: depends on pivotFieldId (not full view), arrangement, and projection so columns only fire when pivot or arrangement changes.
|
|
71
|
+
const columnsAtom = useMemo(
|
|
72
|
+
() =>
|
|
73
|
+
Atom.make((get) => {
|
|
74
|
+
const pivotFieldId = get(pivotFieldIdAtom);
|
|
75
|
+
if (pivotFieldId === undefined) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
get(projection.fields);
|
|
80
|
+
const fieldProj = projection.tryGetFieldProjection(pivotFieldId);
|
|
81
|
+
if (!fieldProj) {
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const selectOptions = fieldProj.props.options ?? [];
|
|
86
|
+
if (selectOptions.length === 0) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const arrangement = get(arrangementAtom);
|
|
91
|
+
const order = getOrderFromArrangement(arrangement);
|
|
92
|
+
const byColumn = getOrderByColumnFromArrangement(arrangement);
|
|
93
|
+
return computeColumnStructure(order, byColumn, selectOptions);
|
|
94
|
+
}),
|
|
95
|
+
[pivotFieldIdAtom, arrangementAtom, projection],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// Per-column slice of arrangement so each column’s items atom only depends on that column’s ids.
|
|
99
|
+
const columnArrangementAtomFamily = useMemo(
|
|
100
|
+
() =>
|
|
101
|
+
Atom.family<string, Atom.Atom<ColumnStructure>>((columnValue: string) =>
|
|
102
|
+
Atom.make((get) => {
|
|
103
|
+
const byColumn = get(effectiveByColumnAtom);
|
|
104
|
+
return {
|
|
105
|
+
columnValue,
|
|
106
|
+
ids: [...(byColumn[columnValue]?.ids ?? [])],
|
|
107
|
+
};
|
|
108
|
+
}),
|
|
109
|
+
),
|
|
110
|
+
[effectiveByColumnAtom],
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// Items for a single column: filter all items by pivot field, sort by this column’s ids, then append new items.
|
|
114
|
+
const itemsAtomFamily = useMemo(
|
|
115
|
+
() =>
|
|
116
|
+
Atom.family<string, Atom.Atom<T[]>>((columnValue: string) =>
|
|
117
|
+
Atom.make((get) => {
|
|
118
|
+
const columnArr = get(columnArrangementAtomFamily(columnValue));
|
|
119
|
+
const allItems = get(itemsAtom);
|
|
120
|
+
const pivotFieldId = get(pivotFieldIdAtom);
|
|
121
|
+
|
|
122
|
+
if (pivotFieldId === undefined) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// TODO(wittjosiah): Try to narrow this down further.
|
|
127
|
+
get(projection.fields);
|
|
128
|
+
const fieldProj = projection.tryGetFieldProjection(pivotFieldId);
|
|
129
|
+
if (!fieldProj) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const selectOptions = fieldProj.props.options ?? [];
|
|
134
|
+
const pivotPath = fieldProj.props.property;
|
|
135
|
+
const validColumnValues = new Set(selectOptions.map((opt) => opt.id));
|
|
136
|
+
return orderItemsInColumn(allItems, columnArr.ids, columnValue, pivotPath, validColumnValues);
|
|
137
|
+
}),
|
|
138
|
+
),
|
|
139
|
+
[columnArrangementAtomFamily, itemsAtom, pivotFieldIdAtom, projection],
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
return useMemo(
|
|
143
|
+
() => ({
|
|
144
|
+
getColumnId: (data) => data.columnValue,
|
|
145
|
+
getItemId: (data) => (data as T).id,
|
|
146
|
+
isColumn: (obj): obj is ColumnStructure =>
|
|
147
|
+
typeof obj === 'object' && obj !== null && 'columnValue' in obj && 'ids' in obj,
|
|
148
|
+
// TODO(wittjosiah): This should be restricted to objects of the type of the kanban view.
|
|
149
|
+
isItem: (obj): obj is T => Obj.isObject(obj),
|
|
150
|
+
columns: columnsAtom,
|
|
151
|
+
items: (column) => itemsAtomFamily(column.columnValue),
|
|
152
|
+
getColumns: () => registry.get(columnsAtom) ?? [],
|
|
153
|
+
getItems: (column) => registry.get(itemsAtomFamily(column.columnValue)) ?? [],
|
|
154
|
+
}),
|
|
155
|
+
[columnsAtom, itemsAtomFamily, registry],
|
|
156
|
+
);
|
|
157
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import type { BoardModel, MosaicEventHandler, MosaicTileData } from '@dxos/react-ui-mosaic';
|
|
8
|
+
import type { ProjectionModel } from '@dxos/schema';
|
|
9
|
+
import { arrayMove } from '@dxos/util';
|
|
10
|
+
|
|
11
|
+
import { type BaseKanbanItem, type ColumnStructure, type KanbanChangeCallback, UNCATEGORIZED_VALUE } from '#types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Builds the column drag-and-drop handler for the kanban board (reorder columns).
|
|
15
|
+
*
|
|
16
|
+
* @template T - Item type (extends BaseKanbanItem).
|
|
17
|
+
* @param id - Handler id.
|
|
18
|
+
* @param model - Board model for getColumns / getColumnId.
|
|
19
|
+
* @param projection - ProjectionModel for pivot field options (column order).
|
|
20
|
+
* @param pivotFieldId - Pivot field id; undefined disables drop.
|
|
21
|
+
* @param change - Callback to persist kanban.arrangement.order.
|
|
22
|
+
* @returns MosaicEventHandler for column tiles.
|
|
23
|
+
*/
|
|
24
|
+
export function useKanbanColumnEventHandler<T extends BaseKanbanItem>({
|
|
25
|
+
id,
|
|
26
|
+
model,
|
|
27
|
+
projection,
|
|
28
|
+
pivotFieldId,
|
|
29
|
+
change,
|
|
30
|
+
}: {
|
|
31
|
+
id: string;
|
|
32
|
+
model: BoardModel<ColumnStructure, T>;
|
|
33
|
+
projection: ProjectionModel | undefined;
|
|
34
|
+
pivotFieldId: string | undefined;
|
|
35
|
+
change: KanbanChangeCallback<T>;
|
|
36
|
+
}): MosaicEventHandler<ColumnStructure> {
|
|
37
|
+
return useMemo<MosaicEventHandler<ColumnStructure>>(
|
|
38
|
+
() => ({
|
|
39
|
+
id,
|
|
40
|
+
canDrop: ({ source }) => {
|
|
41
|
+
if (!projection) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const data = source.data as ColumnStructure;
|
|
45
|
+
const columnValue = model.getColumnId(data);
|
|
46
|
+
return (
|
|
47
|
+
model.isColumn(source.data) &&
|
|
48
|
+
columnValue !== UNCATEGORIZED_VALUE &&
|
|
49
|
+
(source as MosaicTileData<ColumnStructure>).id !== UNCATEGORIZED_VALUE
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
onDrop: ({ source, target }) => {
|
|
53
|
+
if (!projection || pivotFieldId === undefined) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const sourceColumnData = source.data as ColumnStructure;
|
|
57
|
+
const sourceColumnId = model.getColumnId(sourceColumnData);
|
|
58
|
+
if (sourceColumnId === UNCATEGORIZED_VALUE) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 1. Current column order from model; find source index.
|
|
63
|
+
const currentColumns = model.getColumns();
|
|
64
|
+
const sourceIndex = currentColumns.findIndex((c) => model.getColumnId(c) === sourceColumnId);
|
|
65
|
+
if (sourceIndex === -1) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 2. Resolve drop target to an index in the column list.
|
|
70
|
+
let targetIndex: number;
|
|
71
|
+
if (target?.type === 'tile' || target?.type === 'placeholder') {
|
|
72
|
+
targetIndex = typeof target.location === 'number' ? Math.floor(target.location) : -1;
|
|
73
|
+
} else if (target?.type === 'container') {
|
|
74
|
+
targetIndex = currentColumns.length;
|
|
75
|
+
} else {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (targetIndex < 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 3. New column order after move.
|
|
83
|
+
const currentColumnIds = currentColumns.map((c) => model.getColumnId(c));
|
|
84
|
+
const reorderedColumnIds = arrayMove([...currentColumnIds], sourceIndex, targetIndex);
|
|
85
|
+
|
|
86
|
+
// 4. Persist reordered options to projection (pivot field options = column order).
|
|
87
|
+
const fieldProjection = projection.getFieldProjection(pivotFieldId);
|
|
88
|
+
const currentOptions = [...(fieldProjection.props.options ?? [])];
|
|
89
|
+
const optionsInNewOrder = reorderedColumnIds
|
|
90
|
+
.map((columnId) => currentOptions.find((o) => o.id === columnId))
|
|
91
|
+
.filter((o): o is NonNullable<typeof o> => o != null);
|
|
92
|
+
|
|
93
|
+
projection.setFieldProjection({
|
|
94
|
+
...fieldProjection,
|
|
95
|
+
props: { ...fieldProjection.props, options: optionsInNewOrder },
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Persist column order to kanban.arrangement so the board UI reflects the new order.
|
|
99
|
+
change.kanban((kanban) => {
|
|
100
|
+
kanban.arrangement.order = reorderedColumnIds.filter((columnId) => columnId !== UNCATEGORIZED_VALUE);
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
}),
|
|
104
|
+
[id, model, projection, pivotFieldId, change],
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import type { BoardModel, MosaicEventHandler, MosaicTileData } from '@dxos/react-ui-mosaic';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
type ArrangedCards,
|
|
11
|
+
type BaseKanbanItem,
|
|
12
|
+
type ColumnStructure,
|
|
13
|
+
type KanbanChangeCallback,
|
|
14
|
+
UNCATEGORIZED_VALUE,
|
|
15
|
+
} from '#types';
|
|
16
|
+
|
|
17
|
+
function findColumn<T extends BaseKanbanItem>(
|
|
18
|
+
id: string,
|
|
19
|
+
arrangement: ArrangedCards<T>,
|
|
20
|
+
): { columnValue: string; cards: T[] } | undefined {
|
|
21
|
+
return arrangement.find(({ columnValue, cards }) => columnValue === id || cards.some((card) => card.id === id));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Builds the item drag-and-drop handler for a single column (reorder and move between columns).
|
|
26
|
+
*
|
|
27
|
+
* @template T - Item type (extends BaseKanbanItem).
|
|
28
|
+
* @param column - Column structure for this tile.
|
|
29
|
+
* @param columnFieldPath - Item property path for the pivot field (used when moving to another column).
|
|
30
|
+
* @param model - Board model for getColumns / getItems.
|
|
31
|
+
* @param change - Callback to persist arrangement and item field updates.
|
|
32
|
+
* @returns MosaicEventHandler for item tiles in this column.
|
|
33
|
+
*/
|
|
34
|
+
export function useKanbanItemEventHandler<T extends BaseKanbanItem>({
|
|
35
|
+
column,
|
|
36
|
+
columnFieldPath,
|
|
37
|
+
model,
|
|
38
|
+
change,
|
|
39
|
+
}: {
|
|
40
|
+
column: ColumnStructure;
|
|
41
|
+
columnFieldPath: string | undefined;
|
|
42
|
+
model: BoardModel<ColumnStructure, T>;
|
|
43
|
+
change: KanbanChangeCallback<T>;
|
|
44
|
+
}): MosaicEventHandler<T> {
|
|
45
|
+
return useMemo<MosaicEventHandler<T>>(
|
|
46
|
+
() => ({
|
|
47
|
+
id: column.columnValue,
|
|
48
|
+
canDrop: ({ source }) => model.isItem(source.data),
|
|
49
|
+
onTake: ({ source }, cb) => {
|
|
50
|
+
void cb(source.data as T);
|
|
51
|
+
},
|
|
52
|
+
onDrop: ({ source, target }) => {
|
|
53
|
+
// 1. Snapshot current arrangement from model (read-only).
|
|
54
|
+
const columns = model.getColumns();
|
|
55
|
+
const currentArrangement: ArrangedCards<T> = columns.map((col) => ({
|
|
56
|
+
columnValue: col.columnValue,
|
|
57
|
+
cards: model.getItems(col) ?? [],
|
|
58
|
+
}));
|
|
59
|
+
const sourceColumnInSnapshot = findColumn(source.id, currentArrangement);
|
|
60
|
+
if (!sourceColumnInSnapshot) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 2. Working copy to mutate, then persist.
|
|
65
|
+
const workingArrangement = currentArrangement.map((col) => ({
|
|
66
|
+
columnValue: col.columnValue,
|
|
67
|
+
cards: [...col.cards],
|
|
68
|
+
}));
|
|
69
|
+
const sourceColumnInWorking = workingArrangement.find(
|
|
70
|
+
(c) => c.columnValue === sourceColumnInSnapshot.columnValue || c.cards.some((card) => card.id === source.id),
|
|
71
|
+
);
|
|
72
|
+
const targetColumnInWorking = workingArrangement.find((c) => c.columnValue === column.columnValue);
|
|
73
|
+
if (!sourceColumnInWorking || !targetColumnInWorking) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 3. Remove card from source column in working copy.
|
|
78
|
+
const sourceIndex = sourceColumnInWorking.cards.findIndex((card) => card.id === source.id);
|
|
79
|
+
if (sourceIndex === -1) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const [movedCard] = sourceColumnInWorking.cards.splice(sourceIndex, 1);
|
|
83
|
+
|
|
84
|
+
// 4. Update card's pivot field to target column value.
|
|
85
|
+
if (columnFieldPath !== undefined) {
|
|
86
|
+
const newValue =
|
|
87
|
+
targetColumnInWorking.columnValue === UNCATEGORIZED_VALUE ? undefined : targetColumnInWorking.columnValue;
|
|
88
|
+
change.setItemField(movedCard, columnFieldPath, newValue);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 5. Compute insert index in target column, then insert.
|
|
92
|
+
const existingTargetIndex =
|
|
93
|
+
target?.type === 'tile'
|
|
94
|
+
? targetColumnInWorking.cards.findIndex(
|
|
95
|
+
(card) => model.getItemId(card) === (target as MosaicTileData<T>).id,
|
|
96
|
+
)
|
|
97
|
+
: -1;
|
|
98
|
+
const closestEdge: 'top' | 'bottom' =
|
|
99
|
+
target?.type === 'placeholder' && typeof target.location === 'number'
|
|
100
|
+
? target.location <= targetColumnInWorking.cards.length / 2
|
|
101
|
+
? 'top'
|
|
102
|
+
: 'bottom'
|
|
103
|
+
: 'bottom';
|
|
104
|
+
|
|
105
|
+
let insertIndex: number;
|
|
106
|
+
if (target?.type === 'placeholder' && typeof target.location === 'number') {
|
|
107
|
+
insertIndex = Math.max(0, Math.min(targetColumnInWorking.cards.length, Math.floor(target.location)));
|
|
108
|
+
} else if (target?.type === 'container' || existingTargetIndex === -1) {
|
|
109
|
+
insertIndex = targetColumnInWorking.cards.length;
|
|
110
|
+
} else if (sourceColumnInWorking.columnValue === targetColumnInWorking.columnValue) {
|
|
111
|
+
insertIndex = closestEdge === 'bottom' ? existingTargetIndex + 1 : existingTargetIndex;
|
|
112
|
+
if (sourceIndex < existingTargetIndex) {
|
|
113
|
+
insertIndex -= 1;
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
insertIndex = closestEdge === 'bottom' ? existingTargetIndex + 1 : existingTargetIndex;
|
|
117
|
+
}
|
|
118
|
+
targetColumnInWorking.cards.splice(insertIndex, 0, movedCard);
|
|
119
|
+
|
|
120
|
+
// 6. Persist arrangement to kanban.
|
|
121
|
+
change.kanban((kanban) => {
|
|
122
|
+
kanban.arrangement = {
|
|
123
|
+
order: workingArrangement.map(({ columnValue }) => columnValue),
|
|
124
|
+
columns: Object.fromEntries(
|
|
125
|
+
workingArrangement.map(({ columnValue, cards }) => [columnValue, { ids: cards.map((c) => c.id) }]),
|
|
126
|
+
),
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
}),
|
|
131
|
+
[column, columnFieldPath, model, change],
|
|
132
|
+
);
|
|
133
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Registry } from '@effect-atom/atom-react';
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { JsonSchema, Type } from '@dxos/echo';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
10
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
11
|
+
import { ProjectionModel, createEchoChangeCallback } from '@dxos/schema';
|
|
12
|
+
|
|
13
|
+
import { type Kanban } from '#types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Loads the kanban view and builds a ProjectionModel for field projections and pivot.
|
|
17
|
+
*
|
|
18
|
+
* @template S - Entity schema type.
|
|
19
|
+
* @param schema - Echo schema for the viewed type (or undefined).
|
|
20
|
+
* @param kanban - Kanban object whose view to load (or undefined).
|
|
21
|
+
* @param registry - Atom registry for reactive state.
|
|
22
|
+
* @returns ProjectionModel when loaded, or undefined while loading or when schema/kanban are missing.
|
|
23
|
+
*/
|
|
24
|
+
export const useProjectionModel = <S extends Type.AnyEntity>(
|
|
25
|
+
schema: S | undefined,
|
|
26
|
+
kanban: Kanban.Kanban | undefined,
|
|
27
|
+
registry: Registry.Registry,
|
|
28
|
+
) => {
|
|
29
|
+
const [projection, setProjection] = useState<ProjectionModel | undefined>();
|
|
30
|
+
|
|
31
|
+
useAsyncEffect(
|
|
32
|
+
async (controller) => {
|
|
33
|
+
if (!schema || !kanban || kanban.spec.kind !== 'view') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const view = await kanban.spec.view.load();
|
|
38
|
+
if (controller.signal.aborted) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const jsonSchema = Type.isMutable(schema) ? schema.jsonSchema : JsonSchema.toJsonSchema(schema);
|
|
43
|
+
const change = createEchoChangeCallback(view, Type.isMutable(schema) ? schema : undefined);
|
|
44
|
+
|
|
45
|
+
const projection = new ProjectionModel({ registry, view, baseSchema: jsonSchema, change });
|
|
46
|
+
projection.normalizeView();
|
|
47
|
+
if (!controller.signal.aborted) {
|
|
48
|
+
setProjection(projection);
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
log.catch(err, { schema, kanban });
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[schema, kanban, registry],
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return projection;
|
|
58
|
+
};
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: KANBAN_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'org.dxos.plugin.kanban',
|
|
11
10
|
name: 'Kanban',
|
|
12
|
-
description:
|
|
13
|
-
|
|
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
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
6
|
+
import { Operation } from '@dxos/compute';
|
|
7
|
+
import { JsonSchema, Obj } from '@dxos/echo';
|
|
8
|
+
import { type EchoSchema } from '@dxos/echo/internal';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { ProjectionModel, createEchoChangeCallback, getTypenameFromQuery } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { KanbanOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof KanbanOperation.DeleteCardField> = KanbanOperation.DeleteCardField.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fnUntraced(function* ({ view, fieldId }) {
|
|
17
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
18
|
+
const db = Obj.getDatabase(view);
|
|
19
|
+
invariant(db, 'Database not found');
|
|
20
|
+
const schema = yield* Effect.promise(() =>
|
|
21
|
+
db.schemaRegistry
|
|
22
|
+
.query({
|
|
23
|
+
typename: getTypenameFromQuery(view.query.ast)!,
|
|
24
|
+
location: ['database', 'runtime'],
|
|
25
|
+
})
|
|
26
|
+
.first(),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const projection = new ProjectionModel({
|
|
30
|
+
registry,
|
|
31
|
+
view,
|
|
32
|
+
baseSchema: JsonSchema.toJsonSchema(schema),
|
|
33
|
+
change: createEchoChangeCallback(view, schema as EchoSchema),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const result = projection.deleteFieldProjection(fieldId);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
field: result.deleted.field,
|
|
40
|
+
props: result.deleted.props,
|
|
41
|
+
index: result.index,
|
|
42
|
+
};
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export default handler;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Operation } from '@dxos/compute';
|
|
6
|
+
import { Obj } from '@dxos/echo';
|
|
7
|
+
import { invariant } from '@dxos/invariant';
|
|
8
|
+
|
|
9
|
+
import { KanbanOperation } from '../types';
|
|
10
|
+
|
|
11
|
+
const handler: Operation.WithHandler<typeof KanbanOperation.DeleteCard> = KanbanOperation.DeleteCard.pipe(
|
|
12
|
+
Operation.withHandler(({ card }) =>
|
|
13
|
+
Effect.sync(() => {
|
|
14
|
+
const db = Obj.getDatabase(card);
|
|
15
|
+
invariant(db);
|
|
16
|
+
db.remove(card);
|
|
17
|
+
|
|
18
|
+
return { card };
|
|
19
|
+
}),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export default handler;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import { OperationHandlerSet } from '@dxos/compute';
|
|
4
|
+
|
|
5
|
+
export const KanbanOperationHandlerSet = OperationHandlerSet.lazy(
|
|
6
|
+
() => import('./delete-card'),
|
|
7
|
+
() => import('./delete-card-field'),
|
|
8
|
+
() => import('./restore-card'),
|
|
9
|
+
() => import('./restore-card-field'),
|
|
10
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
6
|
+
import { Operation } from '@dxos/compute';
|
|
7
|
+
import { JsonSchema, Obj } from '@dxos/echo';
|
|
8
|
+
import { type EchoSchema } from '@dxos/echo/internal';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { ProjectionModel, createEchoChangeCallback, getTypenameFromQuery } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { KanbanOperation } from '../types';
|
|
13
|
+
|
|
14
|
+
const handler: Operation.WithHandler<typeof KanbanOperation.RestoreCardField> = KanbanOperation.RestoreCardField.pipe(
|
|
15
|
+
Operation.withHandler(
|
|
16
|
+
Effect.fnUntraced(function* ({ view, field, props, index }) {
|
|
17
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
18
|
+
const db = Obj.getDatabase(view);
|
|
19
|
+
invariant(db, 'Database not found');
|
|
20
|
+
const schema = yield* Effect.promise(() =>
|
|
21
|
+
db.schemaRegistry
|
|
22
|
+
.query({
|
|
23
|
+
typename: getTypenameFromQuery(view.query.ast)!,
|
|
24
|
+
location: ['database', 'runtime'],
|
|
25
|
+
})
|
|
26
|
+
.first(),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const projection = new ProjectionModel({
|
|
30
|
+
registry,
|
|
31
|
+
view,
|
|
32
|
+
baseSchema: JsonSchema.toJsonSchema(schema),
|
|
33
|
+
change: createEchoChangeCallback(view, schema as EchoSchema),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
projection.setFieldProjection({ field, props }, index);
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
export default handler;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Operation } from '@dxos/compute';
|
|
6
|
+
import { Obj } from '@dxos/echo';
|
|
7
|
+
import { invariant } from '@dxos/invariant';
|
|
8
|
+
|
|
9
|
+
import { KanbanOperation } from '../types';
|
|
10
|
+
|
|
11
|
+
const handler: Operation.WithHandler<typeof KanbanOperation.RestoreCard> = KanbanOperation.RestoreCard.pipe(
|
|
12
|
+
Operation.withHandler(({ card }) =>
|
|
13
|
+
Effect.sync(() => {
|
|
14
|
+
const db = Obj.getDatabase(card);
|
|
15
|
+
invariant(db);
|
|
16
|
+
db.add(card);
|
|
17
|
+
}),
|
|
18
|
+
),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export default handler;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { BoardManager as MosaicBoardManager } from '@dxos/react-ui-mosaic/playwright';
|
|
6
|
+
|
|
7
|
+
export class BoardManager extends MosaicBoardManager {
|
|
8
|
+
async waitUntilReady(): Promise<void> {
|
|
9
|
+
await this.columns().first().waitFor({ state: 'visible' });
|
|
10
|
+
await this.columns().nth(2).waitFor({ state: 'visible' });
|
|
11
|
+
await this.column(1).items().first().waitFor({ state: 'visible' });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineConfig } from '@playwright/test';
|
|
6
|
+
|
|
7
|
+
import { e2ePreset } from '@dxos/test-utils/playwright';
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
...e2ePreset(import.meta.dirname),
|
|
11
|
+
// TODO(wittjosiah): Stories are slow to start up.
|
|
12
|
+
timeout: 60_000,
|
|
13
|
+
// TODO(wittjosiah): Avoid hard-coding ports.
|
|
14
|
+
webServer: {
|
|
15
|
+
command: 'pnpm storybook dev --ci --quiet --port=9011 --config-dir=.storybook',
|
|
16
|
+
port: 9011,
|
|
17
|
+
reuseExistingServer: false,
|
|
18
|
+
},
|
|
19
|
+
});
|