@dxos/plugin-kanban 0.8.4-main.c85a9c8dae → 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/{browser/KanbanViewEditor-IH5CJ6BW.mjs → neutral/KanbanSettings-G6M47NSK.mjs} +36 -19
- package/dist/lib/neutral/KanbanSettings-G6M47NSK.mjs.map +7 -0
- package/dist/lib/{browser/blueprint-definition-HFEKGFJK.mjs → neutral/blueprint-definition-FHVIEKTQ.mjs} +4 -6
- package/dist/lib/neutral/blueprint-definition-FHVIEKTQ.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/blueprints/index.mjs +1 -1
- 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-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/{browser/chunk-TLYZSC7O.mjs → neutral/chunk-ZTQW5KQS.mjs} +3 -6
- package/dist/lib/neutral/chunk-ZTQW5KQS.mjs.map +7 -0
- package/dist/lib/{browser/KanbanContainer-BCXSJ6KS.mjs → neutral/components/index.mjs} +78 -139
- 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/{node-esm/chunk-CSL3HF2X.mjs → neutral/hooks/index.mjs} +128 -82
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +34 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -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/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/{browser/react-surface-FOMOGFVW.mjs → neutral/react-surface-6RVSCHMJ.mjs} +21 -27
- 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/{browser → neutral}/types/index.mjs +7 -5
- 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 +1 -0
- 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/kanban-blueprint.d.ts +2 -2
- package/dist/types/src/blueprints/kanban-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- 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.map +1 -0
- 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 +17 -38
- package/dist/types/src/components/KanbanBoard/KanbanBoard.d.ts.map +1 -1
- package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts +48 -46
- package/dist/types/src/components/KanbanBoard/KanbanBoard.stories.d.ts.map +1 -1
- package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts +2 -3
- package/dist/types/src/components/KanbanBoard/KanbanCard.d.ts.map +1 -1
- package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts +2 -3
- package/dist/types/src/components/KanbanBoard/KanbanColumn.d.ts.map +1 -1
- 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/containers/KanbanContainer/KanbanContainer.d.ts +4 -4
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.d.ts.map +1 -1
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts +48 -46
- package/dist/types/src/containers/KanbanContainer/KanbanContainer.stories.d.ts.map +1 -1
- package/dist/types/src/containers/KanbanContainer/index.d.ts +1 -2
- package/dist/types/src/containers/KanbanContainer/index.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useEchoChangeCallback.d.ts +1 -1
- package/dist/types/src/hooks/useEchoChangeCallback.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/src/hooks/useKanbanBoardModel.d.ts.map +1 -1
- package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts +2 -2
- package/dist/types/src/hooks/useKanbanColumnEventHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts +2 -2
- package/dist/types/src/hooks/useKanbanItemEventHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts +1 -1
- package/dist/types/src/hooks/useProjectionModel.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.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.map +1 -1
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -1
- 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 +4 -2
- package/dist/types/src/testing/KanbanCardTileSimple.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +48 -46
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Kanban.d.ts +78 -6
- package/dist/types/src/types/Kanban.d.ts.map +1 -1
- 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 +3 -3
- package/dist/types/src/types/constants.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +2 -1
- 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 +15 -104
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -2
- package/dist/types/src/util/arrangement.d.ts +8 -4
- package/dist/types/src/util/arrangement.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +108 -65
- package/src/KanbanPlugin.node.ts +21 -0
- package/src/KanbanPlugin.test.ts +31 -0
- package/src/KanbanPlugin.tsx +21 -29
- package/src/blueprints/kanban-blueprint.ts +4 -8
- package/src/capabilities/{artifact-definition/artifact-definition.ts → artifact-definition.ts} +4 -4
- package/src/capabilities/{blueprint-definition/blueprint-definition.ts → blueprint-definition.ts} +3 -1
- package/src/capabilities/create-object.ts +40 -0
- package/src/capabilities/index.ts +13 -3
- package/src/capabilities/migrations.ts +35 -0
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +22 -13
- package/src/capabilities/undo-mappings.ts +34 -0
- package/src/components/KanbanBoard/KanbanBoard.stories.tsx +20 -16
- package/src/components/KanbanBoard/KanbanBoard.tsx +44 -64
- package/src/components/KanbanBoard/KanbanCard.tsx +77 -63
- package/src/components/KanbanBoard/KanbanColumn.tsx +19 -16
- package/src/components/KanbanBoard/context.ts +54 -0
- package/src/containers/KanbanContainer/KanbanContainer.stories.tsx +44 -30
- package/src/containers/KanbanContainer/KanbanContainer.tsx +118 -27
- package/src/containers/KanbanContainer/index.ts +1 -3
- package/src/containers/KanbanSettings/KanbanSettings.tsx +94 -0
- package/src/containers/KanbanSettings/index.ts +5 -0
- package/src/containers/index.ts +1 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useEchoChangeCallback.ts +3 -3
- package/src/hooks/useItemsProjection.ts +44 -0
- package/src/hooks/{useKanbanBoardModel.test.ts → useKanbanBoardModel.browser.test.ts} +5 -5
- package/src/hooks/useKanbanBoardModel.ts +20 -6
- package/src/hooks/useKanbanColumnEventHandler.ts +1 -1
- package/src/hooks/useKanbanItemEventHandler.ts +1 -1
- package/src/hooks/useProjectionModel.ts +3 -3
- package/src/index.ts +3 -2
- package/src/meta.ts +1 -1
- 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/smoke.spec.ts +3 -3
- package/src/plugin.ts +11 -0
- package/src/testing/KanbanCardTileSimple.tsx +25 -19
- package/src/translations.ts +26 -25
- package/src/types/Kanban.ts +98 -14
- package/src/types/KanbanOperation.ts +67 -0
- package/src/types/index.ts +3 -1
- package/src/types/migrations.test.ts +83 -0
- package/src/types/schema.ts +20 -78
- package/src/types/types.ts +2 -2
- package/src/util/arrangement.test.ts +11 -1
- package/src/util/arrangement.ts +25 -15
- package/dist/lib/browser/KanbanContainer-BCXSJ6KS.mjs.map +0 -7
- package/dist/lib/browser/KanbanViewEditor-IH5CJ6BW.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-HFEKGFJK.mjs.map +0 -7
- package/dist/lib/browser/chunk-QSWCFMEB.mjs +0 -385
- package/dist/lib/browser/chunk-QSWCFMEB.mjs.map +0 -7
- package/dist/lib/browser/chunk-RNFIFE2P.mjs +0 -213
- package/dist/lib/browser/chunk-RNFIFE2P.mjs.map +0 -7
- package/dist/lib/browser/chunk-TLYZSC7O.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -101
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operation-resolver-BRA2OHUE.mjs +0 -162
- package/dist/lib/browser/operation-resolver-BRA2OHUE.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FOMOGFVW.mjs.map +0 -7
- package/dist/lib/node-esm/KanbanContainer-EHRTLE7M.mjs +0 -305
- package/dist/lib/node-esm/KanbanContainer-EHRTLE7M.mjs.map +0 -7
- package/dist/lib/node-esm/KanbanViewEditor-WDACFC35.mjs +0 -67
- package/dist/lib/node-esm/KanbanViewEditor-WDACFC35.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-NARBX32U.mjs +0 -18
- package/dist/lib/node-esm/blueprint-definition-NARBX32U.mjs.map +0 -7
- package/dist/lib/node-esm/blueprints/index.mjs +0 -9
- package/dist/lib/node-esm/chunk-4AWDHQVY.mjs +0 -214
- package/dist/lib/node-esm/chunk-4AWDHQVY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CSL3HF2X.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-X3UJUQIV.mjs +0 -31
- package/dist/lib/node-esm/chunk-X3UJUQIV.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -102
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/operation-resolver-UEQ64LCN.mjs +0 -163
- package/dist/lib/node-esm/operation-resolver-UEQ64LCN.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-AITKFRBE.mjs +0 -100
- package/dist/lib/node-esm/react-surface-AITKFRBE.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -21
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -6
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/containers/KanbanViewEditor/KanbanViewEditor.d.ts +0 -6
- package/dist/types/src/containers/KanbanViewEditor/KanbanViewEditor.d.ts.map +0 -1
- package/dist/types/src/containers/KanbanViewEditor/index.d.ts +0 -3
- package/dist/types/src/containers/KanbanViewEditor/index.d.ts.map +0 -1
- package/dist/types/src/hooks/useKanbanBoardModel.test.d.ts +0 -2
- package/dist/types/src/hooks/useKanbanBoardModel.test.d.ts.map +0 -1
- package/src/capabilities/artifact-definition/index.ts +0 -7
- package/src/capabilities/blueprint-definition/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -133
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/containers/KanbanViewEditor/KanbanViewEditor.tsx +0 -63
- package/src/containers/KanbanViewEditor/index.ts +0 -7
- /package/dist/lib/{browser → neutral}/blueprints/index.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/blueprints/index.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral/operations}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/types/index.mjs.map} +0 -0
- /package/dist/types/src/capabilities/{artifact-definition/artifact-definition.d.ts → artifact-definition.d.ts} +0 -0
- /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
|
@@ -8,28 +8,28 @@ import React, { useCallback, useContext, useEffect, useMemo, useState } from 're
|
|
|
8
8
|
|
|
9
9
|
import { Filter, JsonSchema, Obj, Query } from '@dxos/echo';
|
|
10
10
|
import { type View } from '@dxos/echo';
|
|
11
|
-
import {
|
|
12
|
-
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
import { random } from '@dxos/random';
|
|
13
12
|
import { withMosaic } from '@dxos/react-ui-mosaic/testing';
|
|
13
|
+
import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
14
14
|
import { ProjectionModel, ViewModel, createEchoChangeCallback } from '@dxos/schema';
|
|
15
15
|
import { withRegistry } from '@dxos/storybook-utils';
|
|
16
16
|
import { Organization } from '@dxos/types';
|
|
17
17
|
|
|
18
|
-
import { createEchoChangeCallback as createKanbanChangeCallback } from '
|
|
19
|
-
import { KanbanCardTileSimple } from '
|
|
20
|
-
import { translations } from '
|
|
21
|
-
import { Kanban } from '
|
|
18
|
+
import { createEchoChangeCallback as createKanbanChangeCallback } from '#hooks';
|
|
19
|
+
import { KanbanCardTileSimple } from '#testing';
|
|
20
|
+
import { translations } from '#translations';
|
|
21
|
+
import { Kanban } from '#types';
|
|
22
22
|
|
|
23
23
|
import { KanbanBoard } from './KanbanBoard';
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
random.seed(1);
|
|
26
26
|
|
|
27
27
|
const createOrg = () => ({
|
|
28
|
-
name:
|
|
29
|
-
description:
|
|
30
|
-
image:
|
|
31
|
-
website:
|
|
32
|
-
status:
|
|
28
|
+
name: random.commerce.productName(),
|
|
29
|
+
description: random.lorem.sentence(),
|
|
30
|
+
image: random.image.url(),
|
|
31
|
+
website: random.internet.url(),
|
|
32
|
+
status: random.helpers.arrayElement(Organization.StatusOptions).id as Organization.Organization['status'],
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -66,7 +66,7 @@ const DefaultStory = () => {
|
|
|
66
66
|
const initialItems = Array.from({ length: 12 }, () =>
|
|
67
67
|
Obj.make(Organization.Organization, {
|
|
68
68
|
...createOrg(),
|
|
69
|
-
status:
|
|
69
|
+
status: random.helpers.arrayElement(statuses) as Organization.Organization['status'],
|
|
70
70
|
}),
|
|
71
71
|
);
|
|
72
72
|
|
|
@@ -79,7 +79,9 @@ const DefaultStory = () => {
|
|
|
79
79
|
|
|
80
80
|
const handleCardAdd = useCallback(
|
|
81
81
|
(columnValue: string | undefined) => {
|
|
82
|
-
if (!state || !columnFieldPath || !registry)
|
|
82
|
+
if (!state || !columnFieldPath || !registry) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
83
85
|
const card = Obj.make(Organization.Organization, {
|
|
84
86
|
...createOrg(),
|
|
85
87
|
...(columnFieldPath ? { [columnFieldPath]: columnValue } : {}),
|
|
@@ -93,7 +95,9 @@ const DefaultStory = () => {
|
|
|
93
95
|
|
|
94
96
|
const handleCardRemove = useCallback(
|
|
95
97
|
(card: Obj.Unknown) => {
|
|
96
|
-
if (!registry)
|
|
98
|
+
if (!registry) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
97
101
|
const current = registry.get(items) ?? [];
|
|
98
102
|
registry.set(
|
|
99
103
|
items,
|
|
@@ -104,7 +108,7 @@ const DefaultStory = () => {
|
|
|
104
108
|
);
|
|
105
109
|
|
|
106
110
|
if (!state) {
|
|
107
|
-
return
|
|
111
|
+
return <Loading />;
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
return (
|
|
@@ -3,63 +3,30 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Atom, RegistryContext } from '@effect-atom/atom-react';
|
|
6
|
-
import {
|
|
7
|
-
import React, {
|
|
8
|
-
type ComponentPropsWithoutRef,
|
|
9
|
-
type ComponentType,
|
|
10
|
-
type PropsWithChildren,
|
|
11
|
-
useCallback,
|
|
12
|
-
useContext,
|
|
13
|
-
useMemo,
|
|
14
|
-
} from 'react';
|
|
6
|
+
import React, { type ComponentPropsWithoutRef, type PropsWithChildren, useCallback, useContext, useMemo } from 'react';
|
|
15
7
|
|
|
16
8
|
import { Obj } from '@dxos/echo';
|
|
17
9
|
import { useTranslation } from '@dxos/react-ui';
|
|
18
10
|
import { Board, useBoard } from '@dxos/react-ui-mosaic';
|
|
19
11
|
import type { ProjectionModel } from '@dxos/schema';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import {
|
|
12
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
13
|
+
|
|
14
|
+
import { useKanbanBoardModel, useKanbanColumnEventHandler } from '#hooks';
|
|
15
|
+
import { meta } from '#meta';
|
|
16
|
+
import { type Kanban, UNCATEGORIZED_ATTRIBUTES, UNCATEGORIZED_VALUE } from '#types';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
KanbanBoardContext,
|
|
20
|
+
type KanbanBoardContextValue,
|
|
21
|
+
type KanbanCardProps,
|
|
22
|
+
type KanbanColumnProps,
|
|
23
|
+
useKanbanBoard,
|
|
24
|
+
} from './context';
|
|
25
|
+
import { KanbanCard } from './KanbanCard';
|
|
26
|
+
import { KanbanColumn } from './KanbanColumn';
|
|
27
27
|
|
|
28
28
|
// TODO(burdon): Rename Kanban.
|
|
29
29
|
|
|
30
|
-
//
|
|
31
|
-
// Context
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
const KANBAN_BOARD_NAME = 'KanbanBoard.Context';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Context value for the Kanban board.
|
|
38
|
-
* Items are Echo objects (Obj.Unknown).
|
|
39
|
-
*/
|
|
40
|
-
type KanbanBoardContextValue = {
|
|
41
|
-
kanbanId: string;
|
|
42
|
-
projection: ProjectionModel | undefined;
|
|
43
|
-
columnFieldPath: string | undefined;
|
|
44
|
-
change: KanbanChangeCallback<Obj.Unknown>;
|
|
45
|
-
pivotFieldId: string | undefined;
|
|
46
|
-
getPivotAttributes: (columnValue: string) => { title: string; color: string };
|
|
47
|
-
itemTile?: ComponentType<KanbanCardProps>; // TODO(burdon): Prop.
|
|
48
|
-
onCardAdd?: (columnValue: string | undefined) => string | undefined;
|
|
49
|
-
onCardRemove?: (card: Obj.Unknown) => void;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const [KanbanBoardContext, useKanbanBoard] = createContext<KanbanBoardContextValue>(KANBAN_BOARD_NAME, {
|
|
53
|
-
kanbanId: 'never',
|
|
54
|
-
projection: undefined,
|
|
55
|
-
columnFieldPath: undefined,
|
|
56
|
-
change: { kanban: () => {}, setItemField: () => {} },
|
|
57
|
-
pivotFieldId: undefined,
|
|
58
|
-
getPivotAttributes: (id: string) =>
|
|
59
|
-
id === UNCATEGORIZED_VALUE ? UNCATEGORIZED_ATTRIBUTES : { title: id, color: 'neutral' },
|
|
60
|
-
itemTile: (() => null) as ComponentType<KanbanCardProps>,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
30
|
//
|
|
64
31
|
// Root
|
|
65
32
|
//
|
|
@@ -67,7 +34,7 @@ const [KanbanBoardContext, useKanbanBoard] = createContext<KanbanBoardContextVal
|
|
|
67
34
|
const KANBAN_BOARD_ROOT = 'KanbanBoard.Root';
|
|
68
35
|
|
|
69
36
|
type KanbanBoardRootProps = PropsWithChildren<
|
|
70
|
-
|
|
37
|
+
{
|
|
71
38
|
kanban: Kanban.Kanban;
|
|
72
39
|
/** Required when providing context; Root derives columnFieldPath, pivotFieldId, getPivotAttributes from kanban + projection. */
|
|
73
40
|
projection: ProjectionModel;
|
|
@@ -75,33 +42,38 @@ type KanbanBoardRootProps = PropsWithChildren<
|
|
|
75
42
|
items: Atom.Atom<Obj.Unknown[]>;
|
|
76
43
|
onCardAdd?: (columnValue: string | undefined) => string | undefined;
|
|
77
44
|
onCardRemove?: (card: Obj.Unknown) => void;
|
|
78
|
-
} &
|
|
45
|
+
} & Pick<KanbanBoardContextValue, 'change' | 'itemTile'> &
|
|
46
|
+
ComponentPropsWithoutRef<'div'>
|
|
79
47
|
>;
|
|
80
48
|
|
|
81
49
|
export const KanbanBoardRoot = ({
|
|
82
50
|
children,
|
|
83
|
-
change,
|
|
84
|
-
itemTile = KanbanCard,
|
|
85
51
|
kanban,
|
|
86
52
|
projection,
|
|
87
53
|
items,
|
|
54
|
+
change,
|
|
55
|
+
itemTile = KanbanCard,
|
|
88
56
|
onCardAdd,
|
|
89
57
|
onCardRemove,
|
|
90
|
-
...props
|
|
91
58
|
}: KanbanBoardRootProps) => {
|
|
92
59
|
const registry = useContext(RegistryContext);
|
|
93
60
|
const { t } = useTranslation(meta.id);
|
|
94
61
|
const model = useKanbanBoardModel(kanban, projection, items, registry);
|
|
95
62
|
const columns = model?.getColumns?.() ?? [];
|
|
96
|
-
const view = kanban?.view
|
|
63
|
+
const view = kanban?.spec.kind === 'view' ? kanban.spec.view.target : undefined;
|
|
97
64
|
const pivotFieldId = view?.projection?.pivotFieldId;
|
|
98
65
|
const columnFieldPath = useMemo(() => {
|
|
66
|
+
// Items-variant kanbans use the property name itself as the pivot field
|
|
67
|
+
// (no view/projection translation layer).
|
|
68
|
+
if (kanban?.spec.kind === 'items') {
|
|
69
|
+
return kanban.spec.pivotField;
|
|
70
|
+
}
|
|
99
71
|
if (pivotFieldId === undefined || !projection) {
|
|
100
72
|
return undefined;
|
|
101
73
|
}
|
|
102
74
|
|
|
103
75
|
return projection.tryGetFieldProjection(pivotFieldId)?.props.property;
|
|
104
|
-
}, [projection, pivotFieldId]);
|
|
76
|
+
}, [kanban?.spec, projection, pivotFieldId]);
|
|
105
77
|
|
|
106
78
|
const getPivotAttributes = useCallback<KanbanBoardContextValue['getPivotAttributes']>(
|
|
107
79
|
(columnValue) => {
|
|
@@ -118,8 +90,8 @@ export const KanbanBoardRoot = ({
|
|
|
118
90
|
|
|
119
91
|
if (columns.length === 0) {
|
|
120
92
|
return (
|
|
121
|
-
<div
|
|
122
|
-
{t('select
|
|
93
|
+
<div className='flex flex-1 items-center justify-center p-8 text-center text-description'>
|
|
94
|
+
{t('select-pivot.placeholder')}
|
|
123
95
|
</div>
|
|
124
96
|
);
|
|
125
97
|
}
|
|
@@ -136,9 +108,7 @@ export const KanbanBoardRoot = ({
|
|
|
136
108
|
onCardAdd={onCardAdd}
|
|
137
109
|
onCardRemove={onCardRemove}
|
|
138
110
|
>
|
|
139
|
-
<Board.Root model={model}>
|
|
140
|
-
<div {...props}>{children}</div>
|
|
141
|
-
</Board.Root>
|
|
111
|
+
<Board.Root model={model}>{children}</Board.Root>
|
|
142
112
|
</KanbanBoardContext>
|
|
143
113
|
);
|
|
144
114
|
};
|
|
@@ -151,7 +121,9 @@ KanbanBoardRoot.displayName = KANBAN_BOARD_ROOT;
|
|
|
151
121
|
|
|
152
122
|
const KANBAN_BOARD_CONTENT = 'KanbanBoard.Content';
|
|
153
123
|
|
|
154
|
-
|
|
124
|
+
type KanbanBoardContentProps = {};
|
|
125
|
+
|
|
126
|
+
export const KanbanBoardContent = composable<HTMLDivElement, KanbanBoardContentProps>((props, forwardedRef) => {
|
|
155
127
|
const { model } = useBoard(KANBAN_BOARD_CONTENT);
|
|
156
128
|
const { kanbanId, projection, pivotFieldId, change } = useKanbanBoard(KANBAN_BOARD_CONTENT);
|
|
157
129
|
|
|
@@ -163,8 +135,16 @@ export const KanbanBoardContent = () => {
|
|
|
163
135
|
change,
|
|
164
136
|
});
|
|
165
137
|
|
|
166
|
-
return
|
|
167
|
-
|
|
138
|
+
return (
|
|
139
|
+
<Board.Content
|
|
140
|
+
{...composableProps(props)}
|
|
141
|
+
ref={forwardedRef}
|
|
142
|
+
id={kanbanId}
|
|
143
|
+
eventHandler={columnEventHandler}
|
|
144
|
+
Tile={KanbanColumn}
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
});
|
|
168
148
|
|
|
169
149
|
KanbanBoardContent.displayName = KANBAN_BOARD_CONTENT;
|
|
170
150
|
|
|
@@ -5,83 +5,97 @@
|
|
|
5
5
|
import React, { forwardRef, useCallback, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
-
import {
|
|
8
|
+
import { AppSurface, useObjectMenuItems } from '@dxos/app-toolkit/ui';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
10
|
import { Card, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import { Menu, createMenuAction } from '@dxos/react-ui-menu';
|
|
12
|
-
import { Focus, Mosaic,
|
|
12
|
+
import { Focus, Mosaic, useBoard } from '@dxos/react-ui-mosaic';
|
|
13
13
|
|
|
14
|
-
import { meta } from '
|
|
14
|
+
import { meta } from '#meta';
|
|
15
15
|
|
|
16
|
-
import { useKanbanBoard } from './
|
|
16
|
+
import { type KanbanCardProps, useKanbanBoard } from './context';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
export { type KanbanCardProps };
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const KANBAN_CARD_TILE_NAME = 'KanbanBoard.Card';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Mosaic Tile for Kanban card.
|
|
24
24
|
* Uses Surface for content; requires plugin manager context.
|
|
25
25
|
*/
|
|
26
|
-
export const KanbanCard = forwardRef<HTMLDivElement, KanbanCardProps>(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
export const KanbanCard = forwardRef<HTMLDivElement, KanbanCardProps>(
|
|
27
|
+
({ data, location, debug, draggable }, forwardedRef) => {
|
|
28
|
+
const { t } = useTranslation(meta.id);
|
|
29
|
+
const { model } = useBoard(KANBAN_CARD_TILE_NAME);
|
|
30
|
+
const { projection, columnFieldPath, onCardRemove } = useKanbanBoard(KANBAN_CARD_TILE_NAME);
|
|
31
|
+
const [dragHandle, setDragHandle] = useState<HTMLButtonElement | null>(null);
|
|
32
|
+
const dragHandleRef = useCallback((el: HTMLButtonElement | null) => setDragHandle(el), []);
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
const handleNavigate = useObjectNavigate(data);
|
|
34
|
+
const objectMenuItems = useObjectMenuItems(data);
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
const menuItems = useMemo(
|
|
37
|
+
() => [
|
|
38
|
+
...objectMenuItems,
|
|
39
|
+
...(onCardRemove
|
|
40
|
+
? [
|
|
41
|
+
createMenuAction('remove', () => onCardRemove(data), {
|
|
42
|
+
label: t('remove-card.label'),
|
|
43
|
+
icon: 'ph--trash--regular',
|
|
44
|
+
}),
|
|
45
|
+
]
|
|
46
|
+
: []),
|
|
47
|
+
],
|
|
48
|
+
[objectMenuItems, onCardRemove, data, t],
|
|
49
|
+
);
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
<Card.
|
|
64
|
-
<Card.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
51
|
+
return (
|
|
52
|
+
<Menu.Root>
|
|
53
|
+
<Mosaic.Tile
|
|
54
|
+
asChild
|
|
55
|
+
id={model.getItemId(data)}
|
|
56
|
+
data={data}
|
|
57
|
+
location={location}
|
|
58
|
+
debug={debug}
|
|
59
|
+
draggable={draggable}
|
|
60
|
+
dragHandle={dragHandle}
|
|
61
|
+
>
|
|
62
|
+
<Focus.Item asChild>
|
|
63
|
+
<Card.Root ref={forwardedRef} data-testid='board-item'>
|
|
64
|
+
<Card.Toolbar>
|
|
65
|
+
<Card.DragHandle ref={dragHandleRef} testId='mosaicBoard.cardDragHandle' />
|
|
66
|
+
<Card.Title data-testid='mosaicBoard.cardTitle'>{Obj.getLabel(data)}</Card.Title>
|
|
67
|
+
{/* TODO(wittjosiah): Reconcile with Card.Menu. */}
|
|
68
|
+
<Menu.Trigger asChild disabled={!menuItems?.length}>
|
|
69
|
+
<Toolbar.IconButton
|
|
70
|
+
iconOnly
|
|
71
|
+
variant='ghost'
|
|
72
|
+
icon='ph--dots-three-vertical--regular'
|
|
73
|
+
label={t('action-menu.label')}
|
|
74
|
+
/>
|
|
75
|
+
</Menu.Trigger>
|
|
76
|
+
<Menu.Content items={menuItems} />
|
|
77
|
+
</Card.Toolbar>
|
|
78
|
+
<Card.Content>
|
|
79
|
+
{projection && (
|
|
80
|
+
<Surface.Surface
|
|
81
|
+
type={AppSurface.Card}
|
|
82
|
+
limit={1}
|
|
83
|
+
data={{
|
|
84
|
+
subject: data,
|
|
85
|
+
projection,
|
|
86
|
+
// Hide the pivot field: its value is already conveyed by
|
|
87
|
+
// which column the card sits in.
|
|
88
|
+
ignorePaths: columnFieldPath ? [columnFieldPath] : undefined,
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
92
|
+
</Card.Content>
|
|
93
|
+
</Card.Root>
|
|
94
|
+
</Focus.Item>
|
|
95
|
+
</Mosaic.Tile>
|
|
96
|
+
</Menu.Root>
|
|
97
|
+
);
|
|
98
|
+
},
|
|
99
|
+
);
|
|
86
100
|
|
|
87
101
|
KanbanCard.displayName = KANBAN_CARD_TILE_NAME;
|
|
@@ -2,31 +2,31 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { forwardRef,
|
|
5
|
+
import React, { FC, forwardRef, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import type { Obj } from '@dxos/echo';
|
|
8
8
|
import { Board, type MosaicTileProps, useBoard } from '@dxos/react-ui-mosaic';
|
|
9
9
|
|
|
10
|
-
import { useKanbanItemEventHandler } from '
|
|
11
|
-
import { type ColumnStructure, UNCATEGORIZED_VALUE } from '
|
|
10
|
+
import { useKanbanItemEventHandler } from '#hooks';
|
|
11
|
+
import { type ColumnStructure, UNCATEGORIZED_VALUE } from '#types';
|
|
12
12
|
|
|
13
|
-
import { useKanbanBoard } from './
|
|
13
|
+
import { type KanbanColumnProps, useKanbanBoard } from './context';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export { type KanbanColumnProps };
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const KANBAN_COLUMN_NAME = 'KanbanBoard.Column';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Mosaic Tile for Kanban column.
|
|
21
21
|
*/
|
|
22
22
|
export const KanbanColumn = forwardRef<HTMLDivElement, KanbanColumnProps>(
|
|
23
|
-
({ data: column, location, debug }, forwardedRef) => {
|
|
23
|
+
({ data: column, location, debug, draggable }, forwardedRef) => {
|
|
24
24
|
const { model } = useBoard<ColumnStructure, Obj.Unknown>(KANBAN_COLUMN_NAME);
|
|
25
25
|
const { columnFieldPath, change, onCardAdd, getPivotAttributes, itemTile } = useKanbanBoard(KANBAN_COLUMN_NAME);
|
|
26
26
|
|
|
27
27
|
const { title } = getPivotAttributes(column.columnValue);
|
|
28
28
|
const uncategorized = column.columnValue === UNCATEGORIZED_VALUE;
|
|
29
|
-
const
|
|
29
|
+
const [dragHandle, setDragHandle] = useState<HTMLButtonElement | null>(null);
|
|
30
30
|
|
|
31
31
|
const eventHandler = useKanbanItemEventHandler({
|
|
32
32
|
column,
|
|
@@ -41,7 +41,8 @@ export const KanbanColumn = forwardRef<HTMLDivElement, KanbanColumnProps>(
|
|
|
41
41
|
location={location}
|
|
42
42
|
classNames='grid grid-rows-[var(--dx-rail-action)_1fr_var(--dx-rail-action)]'
|
|
43
43
|
debug={debug}
|
|
44
|
-
|
|
44
|
+
draggable={draggable}
|
|
45
|
+
dragHandle={dragHandle}
|
|
45
46
|
ref={forwardedRef}
|
|
46
47
|
>
|
|
47
48
|
{uncategorized ? (
|
|
@@ -49,18 +50,20 @@ export const KanbanColumn = forwardRef<HTMLDivElement, KanbanColumnProps>(
|
|
|
49
50
|
<span className='font-medium'>{title}</span>
|
|
50
51
|
</div>
|
|
51
52
|
) : (
|
|
52
|
-
<Board.Column.Header label={title} dragHandleRef={
|
|
53
|
+
<Board.Column.Header label={title} dragHandleRef={setDragHandle} />
|
|
53
54
|
)}
|
|
54
55
|
<Board.Column.Body
|
|
55
56
|
data={column}
|
|
56
57
|
eventHandler={eventHandler}
|
|
57
|
-
Tile={itemTile as
|
|
58
|
+
Tile={itemTile as FC<MosaicTileProps<Obj.Unknown>>}
|
|
59
|
+
/>
|
|
60
|
+
<Board.Column.Footer
|
|
61
|
+
onAdd={
|
|
62
|
+
onCardAdd
|
|
63
|
+
? () => onCardAdd(column.columnValue === UNCATEGORIZED_VALUE ? undefined : column.columnValue)
|
|
64
|
+
: undefined
|
|
65
|
+
}
|
|
58
66
|
/>
|
|
59
|
-
{onCardAdd && (
|
|
60
|
-
<Board.Column.Footer
|
|
61
|
-
onAdd={() => onCardAdd(column.columnValue === UNCATEGORIZED_VALUE ? undefined : column.columnValue)}
|
|
62
|
-
/>
|
|
63
|
-
)}
|
|
64
67
|
</Board.Column.Root>
|
|
65
68
|
);
|
|
66
69
|
},
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { createContext } from '@radix-ui/react-context';
|
|
6
|
+
import { type ComponentType } from 'react';
|
|
7
|
+
|
|
8
|
+
import { type Obj } from '@dxos/echo';
|
|
9
|
+
import { type MosaicTileProps } from '@dxos/react-ui-mosaic';
|
|
10
|
+
import { type ProjectionModel } from '@dxos/schema';
|
|
11
|
+
|
|
12
|
+
import { type ColumnStructure, type KanbanChangeCallback, UNCATEGORIZED_ATTRIBUTES, UNCATEGORIZED_VALUE } from '#types';
|
|
13
|
+
|
|
14
|
+
const KANBAN_BOARD_NAME = 'KanbanBoard.Context';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Card tile props. Defined here (rather than in `KanbanCard.tsx`) so the
|
|
18
|
+
* context type can reference it without forming a cycle through that
|
|
19
|
+
* module's runtime exports — webkit treats the resulting TDZ as a hard
|
|
20
|
+
* error while other engines are lenient.
|
|
21
|
+
*/
|
|
22
|
+
export type KanbanCardProps = Pick<MosaicTileProps<Obj.Unknown>, 'location' | 'data' | 'debug' | 'draggable'>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Column tile props. See note on {@link KanbanCardProps}.
|
|
26
|
+
*/
|
|
27
|
+
export type KanbanColumnProps = Pick<MosaicTileProps<ColumnStructure>, 'location' | 'data' | 'debug' | 'draggable'>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Context value for the Kanban board.
|
|
31
|
+
* Items are Echo objects (Obj.Unknown).
|
|
32
|
+
*/
|
|
33
|
+
export type KanbanBoardContextValue = {
|
|
34
|
+
kanbanId: string;
|
|
35
|
+
projection: ProjectionModel | undefined;
|
|
36
|
+
columnFieldPath: string | undefined;
|
|
37
|
+
change: KanbanChangeCallback<Obj.Unknown>;
|
|
38
|
+
pivotFieldId: string | undefined;
|
|
39
|
+
getPivotAttributes: (columnValue: string) => { title: string; color: string };
|
|
40
|
+
itemTile?: ComponentType<KanbanCardProps>; // TODO(burdon): Prop.
|
|
41
|
+
onCardAdd?: (columnValue: string | undefined) => string | undefined;
|
|
42
|
+
onCardRemove?: (card: Obj.Unknown) => void;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const [KanbanBoardContext, useKanbanBoard] = createContext<KanbanBoardContextValue>(KANBAN_BOARD_NAME, {
|
|
46
|
+
kanbanId: 'never',
|
|
47
|
+
projection: undefined,
|
|
48
|
+
columnFieldPath: undefined,
|
|
49
|
+
change: { kanban: () => {}, setItemField: () => {} },
|
|
50
|
+
pivotFieldId: undefined,
|
|
51
|
+
getPivotAttributes: (id: string) =>
|
|
52
|
+
id === UNCATEGORIZED_VALUE ? UNCATEGORIZED_ATTRIBUTES : { title: id, color: 'neutral' },
|
|
53
|
+
itemTile: (() => null) as ComponentType<KanbanCardProps>,
|
|
54
|
+
});
|