@ordinatio/ui 1.10.0 → 1.12.0
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/CHANGELOG.md +15 -0
- package/dist/board-dnd.d.mts +10 -2
- package/dist/board-dnd.mjs +12 -1
- package/dist/{board-types-D8JR0lN4.d.mts → board-types-CMDkTs9V.d.mts} +20 -0
- package/dist/index.d.mts +22 -7
- package/dist/index.mjs +62 -30
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Entries start at 1.9.0 (older history is in git).
|
|
4
4
|
|
|
5
|
+
## 1.12.0
|
|
6
|
+
|
|
7
|
+
- `BoardCard.tags[].chipClassName` (optional): classes the app computes for one tag's chip on the card (for example the tag's own color). They are added after the injected `tagChip` class; giving one also switches the default look off, as an injected class does. A card whose tags have none renders exactly as in 1.11.0.
|
|
8
|
+
|
|
9
|
+
## 1.11.0
|
|
10
|
+
|
|
11
|
+
Board refinements found in the first real browser passes. Every new prop is optional and an app that passes none behaves as in 1.10.0, except `stretchColumns` (columns now share the tallest column's height by default; pass `false` for the old look).
|
|
12
|
+
|
|
13
|
+
- `AddCardBox` / `BoardColumn` / `PipelineBoard`: `closeOnAdd` (the form closes after a successful add and focus returns to the "+ Add a card" button). `AddCardBox` now sends an EMPTY currency when the amount is empty, even if a currency is preselected (a title-only add no longer trips the "currency without amount" rule).
|
|
14
|
+
- `BoardColumnData.canAdd` (false: no add control, for example an archived stage that still holds deals). `BoardCard.draggable` (false: the drag layer never lifts the card). `BoardCard.ownerFormer` with `texts.ownerFormer` (an owner who left is named in the owner mark's accessible name). A "+n" mark when a card has more than two tags (`texts.moreTags(n)` for your own words).
|
|
15
|
+
- Lost step: it stays open after a refusal with the sentence and the typed reason (the card does not move until the move succeeds); optional `texts.lostTitleFor(stageName)`, `texts.lostHelp`, and `texts.lostIncoming(cardTitle)` (a marker drawn in the target Lost column while the step is open); `LostStep` takes `stageName`; `DealCard` takes `keepControls` and `waiting`; `BoardColumn` takes `incoming`.
|
|
16
|
+
- Moves to stages the board does not draw (more stages than columns): a stage listed by `legalTargets` can be moved to even when it has no column; `MoveTarget.kind` makes an undrawn Lost stage ask for a reason.
|
|
17
|
+
- Drag layer: `boardDnd({ refusal })` gives a reason-specific note for a refused drop (falls back to `texts.cannotDrop`); new pure `refusalNote` and type `DropRefusal`.
|
|
18
|
+
- `PipelineBoard.stretchColumns` (default true).
|
|
19
|
+
|
|
5
20
|
## 1.10.0
|
|
6
21
|
|
|
7
22
|
- New pipeline board components: `PipelineBoard`, `BoardColumn`, `DealCard`, `AddCardBox`, `MoveMenu`, `LostStep`, `ReopenStep`, the pure `nearestColumnIndex`, and the types (`BoardCard`, `BoardColumnData`, `BoardTexts`, `BoardClassNames`, `MoveRequest`, `DropRule`, `BoardDnd`, and more). A Trello-style row of columns with cards. Contract: the app injects ALL words (`texts`, no English defaults) and, optionally, `classNames` (replace the default look; the sideways-scroll structure is always kept inline). The board holds no rules: `legalTargets`, `reopenFor`, `lost` (`validateReason`, `humanize`, suggestions) and every callback come from the app. A move into a lost column asks for a reason first; a move shows "moving" in the new column and snaps back with the sentence on a refusal; a closed card can be reopened (stage picker or plain).
|
package/dist/board-dnd.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { c as BoardCard, b as BoardColumnData, D as DropRule, e as BoardDnd } from './board-types-CMDkTs9V.mjs';
|
|
3
3
|
|
|
4
4
|
/** How a drag starts. A mouse needs a small move; a finger needs a long press (so scrolling the row still works) with a small allowed wobble. The keyboard uses Space to pick up and drop and Escape to cancel. */
|
|
5
5
|
declare const BOARD_DND_SENSORS: {
|
|
@@ -39,6 +39,12 @@ declare function findCard(columns: ReadonlyArray<BoardColumnData>, cardId: strin
|
|
|
39
39
|
} | null;
|
|
40
40
|
/** What a drop of `activeId` on `overId` means. Never throws. */
|
|
41
41
|
declare function resolveDrop(activeId: string, overId: string | null, columns: ReadonlyArray<BoardColumnData>, canDrop: DropRule): DropOutcome;
|
|
42
|
+
/** The app's own sentence for a refused drop, or null to fall back to the general one. */
|
|
43
|
+
type DropRefusal = (card: BoardCard, fromStageId: string, toStageId: string, columns: ReadonlyArray<BoardColumnData>) => string | null;
|
|
44
|
+
/** The note for a drop the app's rule refused: the app's specific sentence when it gives a non-empty one, else the general `cannotDrop` text. A throwing `refusal` falls back too. */
|
|
45
|
+
declare function refusalNote(texts: {
|
|
46
|
+
cannotDrop: string;
|
|
47
|
+
}, refusal: DropRefusal | undefined, columns: ReadonlyArray<BoardColumnData>, activeId: string, overId: string | null): string;
|
|
42
48
|
interface ColumnRect {
|
|
43
49
|
id: string;
|
|
44
50
|
left: number;
|
|
@@ -101,6 +107,8 @@ declare function buildAnnouncements(texts: BoardDndTexts, lookup: AnnouncementLo
|
|
|
101
107
|
|
|
102
108
|
interface BoardDndConfig {
|
|
103
109
|
canDrop: DropRule;
|
|
110
|
+
/** Optional. The sentence for a refused drop, for example "A closed deal must be reopened first."; null or missing falls back to `texts.cannotDrop`. */
|
|
111
|
+
refusal?: DropRefusal;
|
|
104
112
|
texts: BoardDndTexts;
|
|
105
113
|
/** What follows the pointer while dragging. Default: the card's title in a plain box. */
|
|
106
114
|
renderPreview?: (card: BoardCard) => ReactNode;
|
|
@@ -108,4 +116,4 @@ interface BoardDndConfig {
|
|
|
108
116
|
/** The descriptor for `<PipelineBoard dnd={...} />`. Call it once per render with the app's drop rule and texts. */
|
|
109
117
|
declare function boardDnd(config: BoardDndConfig): BoardDnd;
|
|
110
118
|
|
|
111
|
-
export { type AnnouncementLookup, BOARD_DND_SENSORS, type BoardDndConfig, type BoardDndTexts, type ColumnRect, type DropOutcome, boardDnd, buildAnnouncements, columnShift, findCard, resolveDrop };
|
|
119
|
+
export { type AnnouncementLookup, BOARD_DND_SENSORS, type BoardDndConfig, type BoardDndTexts, type ColumnRect, type DropOutcome, type DropRefusal, boardDnd, buildAnnouncements, columnShift, findCard, refusalNote, resolveDrop };
|
package/dist/board-dnd.mjs
CHANGED
|
@@ -43,6 +43,16 @@ function resolveDrop(activeId, overId, columns, canDrop) {
|
|
|
43
43
|
if (!canDrop(found.card, found.column.id, target.id, columns)) return { kind: "illegal" };
|
|
44
44
|
return { kind: "move", cardId: activeId, toStageId: target.id };
|
|
45
45
|
}
|
|
46
|
+
function refusalNote(texts, refusal, columns, activeId, overId) {
|
|
47
|
+
const found = findCard(columns, activeId);
|
|
48
|
+
if (!refusal || !found || overId === null) return texts.cannotDrop;
|
|
49
|
+
try {
|
|
50
|
+
const sentence = refusal(found.card, found.column.id, overId, columns);
|
|
51
|
+
return typeof sentence === "string" && sentence.trim() !== "" ? sentence : texts.cannotDrop;
|
|
52
|
+
} catch {
|
|
53
|
+
return texts.cannotDrop;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
46
56
|
function columnShift(key, currentLeft, columns) {
|
|
47
57
|
if (key !== "ArrowRight" && key !== "ArrowLeft") return null;
|
|
48
58
|
const sorted = [...columns].sort((a, b) => a.left - b.left);
|
|
@@ -165,7 +175,7 @@ function BoardDndProvider({ columns, onDrop, allow, config, children }) {
|
|
|
165
175
|
const outcome = resolveDrop(String(event.active.id), event.over ? String(event.over.id) : null, columns, cfg.canDrop);
|
|
166
176
|
if (outcome.kind === "move") onDrop(outcome.cardId, outcome.toStageId);
|
|
167
177
|
else if (outcome.kind === "same-column") setNote(cfg.texts.sameColumnNote);
|
|
168
|
-
else if (outcome.kind === "illegal") setNote(cfg.texts.
|
|
178
|
+
else if (outcome.kind === "illegal") setNote(refusalNote(cfg.texts, cfg.refusal, columns, String(event.active.id), event.over ? String(event.over.id) : null));
|
|
169
179
|
};
|
|
170
180
|
return /* @__PURE__ */ jsx(ConfigContext.Provider, { value: cfg, children: /* @__PURE__ */ jsxs(
|
|
171
181
|
DndContext,
|
|
@@ -204,5 +214,6 @@ export {
|
|
|
204
214
|
buildAnnouncements,
|
|
205
215
|
columnShift,
|
|
206
216
|
findCard,
|
|
217
|
+
refusalNote,
|
|
207
218
|
resolveDrop
|
|
208
219
|
};
|
|
@@ -14,12 +14,18 @@ interface BoardCard {
|
|
|
14
14
|
overdue?: boolean;
|
|
15
15
|
ownerInitials?: string | null;
|
|
16
16
|
/** At most two are drawn. */
|
|
17
|
+
/** `chipClassName` (optional): classes the APP computes for this tag's chip (for example its own color). They are added after the injected `tagChip` class; giving one also switches the default look off, as an injected class does. */
|
|
17
18
|
tags?: ReadonlyArray<{
|
|
18
19
|
id: string;
|
|
19
20
|
label: string;
|
|
21
|
+
chipClassName?: string;
|
|
20
22
|
}>;
|
|
21
23
|
/** A closed card shows its badge. */
|
|
22
24
|
badge?: 'won' | 'lost' | null;
|
|
25
|
+
/** False: a closed or otherwise fixed card is not lifted by the drag layer (the menu is unaffected). Missing means draggable. */
|
|
26
|
+
draggable?: boolean;
|
|
27
|
+
/** The owner has left the team: the owner mark is named with `texts.ownerFormer` when that text is given. */
|
|
28
|
+
ownerFormer?: boolean;
|
|
23
29
|
}
|
|
24
30
|
/** open: new cards can be added here. won and lost: a stage that ends a deal. */
|
|
25
31
|
type BoardColumnKind = 'open' | 'won' | 'lost';
|
|
@@ -34,6 +40,8 @@ interface BoardColumnData {
|
|
|
34
40
|
cards: ReadonlyArray<BoardCard>;
|
|
35
41
|
/** More cards exist in this stage than are drawn. */
|
|
36
42
|
hasMore?: boolean;
|
|
43
|
+
/** False: no "+ Add a card" here even in an open column (for example an archived stage that still holds deals). Missing means true. */
|
|
44
|
+
canAdd?: boolean;
|
|
37
45
|
}
|
|
38
46
|
/** What a move sends. `reason` is present only for a move into a lost stage. */
|
|
39
47
|
interface MoveRequest {
|
|
@@ -61,6 +69,8 @@ type DropRule = (card: BoardCard, fromStageId: string, toStageId: string, column
|
|
|
61
69
|
interface MoveTarget {
|
|
62
70
|
stageId: string;
|
|
63
71
|
label: string;
|
|
72
|
+
/** Needed only for a stage the board does not draw (more stages than columns): a Lost stage still asks for a reason. */
|
|
73
|
+
kind?: BoardColumnKind;
|
|
64
74
|
}
|
|
65
75
|
/** Every text arrives from outside (no English default lives in this package), so an app in any language shows only its own words. */
|
|
66
76
|
interface BoardTexts {
|
|
@@ -108,6 +118,16 @@ interface BoardTexts {
|
|
|
108
118
|
reopenCancel: string;
|
|
109
119
|
/** Shown when an action throws instead of returning a refusal. */
|
|
110
120
|
unexpectedError: string;
|
|
121
|
+
/** Optional. The Lost step title with the target stage named, for example (name) gives "Move to Lost?". Replaces `lostTitle` when given. */
|
|
122
|
+
lostTitleFor?: (stageName: string) => string;
|
|
123
|
+
/** Optional. One plain line under the Lost step title, for example "The card moves when you press Mark lost." */
|
|
124
|
+
lostHelp?: string;
|
|
125
|
+
/** Optional. The marker drawn in the target Lost column while its step is open; receives the card title. */
|
|
126
|
+
lostIncoming?: (cardTitle: string) => string;
|
|
127
|
+
/** Optional. The mark for hidden tags; receives how many are hidden. Without it the mark is "+n". */
|
|
128
|
+
moreTags?: (hidden: number) => string;
|
|
129
|
+
/** Optional. Spoken after the owner mark of a card whose owner left, for example "former member". */
|
|
130
|
+
ownerFormer?: string;
|
|
111
131
|
}
|
|
112
132
|
/** The parts of the board that can take a class name. Any part left out keeps a plain default look. */
|
|
113
133
|
interface BoardClassNames {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { Component, ReactNode, ErrorInfo, ComponentType, CSSProperties, ElementType, RefObject, FormEvent, KeyboardEvent as KeyboardEvent$1 } from 'react';
|
|
4
|
-
import { B as BoardTexts, a as BoardClassNames, b as BoardColumnData, M as MoveHandler, c as BoardCard, d as MoveTarget, A as AddCardHandler, R as RenderCardTitle, e as BoardDnd, C as CardShellProps, f as AddCardInput, g as BoardResult } from './board-types-
|
|
5
|
-
export { h as BoardColumnKind, i as ColumnShellProps, D as DropRule, j as MoveRequest } from './board-types-
|
|
4
|
+
import { B as BoardTexts, a as BoardClassNames, b as BoardColumnData, M as MoveHandler, c as BoardCard, d as MoveTarget, A as AddCardHandler, R as RenderCardTitle, e as BoardDnd, C as CardShellProps, f as AddCardInput, g as BoardResult } from './board-types-CMDkTs9V.mjs';
|
|
5
|
+
export { h as BoardColumnKind, i as ColumnShellProps, D as DropRule, j as MoveRequest } from './board-types-CMDkTs9V.mjs';
|
|
6
6
|
|
|
7
7
|
interface ErrorBoundaryProps {
|
|
8
8
|
children: ReactNode;
|
|
@@ -1341,10 +1341,12 @@ interface LostStepProps {
|
|
|
1341
1341
|
error?: string;
|
|
1342
1342
|
/** The move is running: the buttons are disabled. */
|
|
1343
1343
|
busy?: boolean;
|
|
1344
|
+
/** The stage the card is moving to; with `texts.lostTitleFor` it names the target in the title. */
|
|
1345
|
+
stageName?: string;
|
|
1344
1346
|
onConfirm: (reasonCode: string) => void;
|
|
1345
1347
|
onCancel: () => void;
|
|
1346
1348
|
}
|
|
1347
|
-
declare function LostStep({ suggestions, used, validateReason, humanize, texts, classNames, error, busy, onConfirm, onCancel }: LostStepProps): react_jsx_runtime.JSX.Element;
|
|
1349
|
+
declare function LostStep({ suggestions, used, validateReason, humanize, texts, classNames, error, busy, stageName, onConfirm, onCancel }: LostStepProps): react_jsx_runtime.JSX.Element;
|
|
1348
1350
|
|
|
1349
1351
|
interface BoardLostConfig {
|
|
1350
1352
|
suggestions: ReadonlyArray<LostReasonChoice>;
|
|
@@ -1384,6 +1386,10 @@ interface PipelineBoardProps {
|
|
|
1384
1386
|
onAddCard?: AddCardHandler;
|
|
1385
1387
|
currencies?: ReadonlyArray<string>;
|
|
1386
1388
|
defaultCurrency?: string;
|
|
1389
|
+
/** True: the add form closes after a card is added (default: it stays open for the next card). */
|
|
1390
|
+
closeOnAdd?: boolean;
|
|
1391
|
+
/** False: columns keep their own height. Default true: every column stretches to the height of the tallest. */
|
|
1392
|
+
stretchColumns?: boolean;
|
|
1387
1393
|
onShowMore?: (stageId: string) => void;
|
|
1388
1394
|
renderCardTitle?: RenderCardTitle;
|
|
1389
1395
|
/** Drawn at the right end of the row (for example the "Add another stage" link). */
|
|
@@ -1402,10 +1408,13 @@ interface BoardColumnProps {
|
|
|
1402
1408
|
onAddCard?: AddCardHandler;
|
|
1403
1409
|
currencies?: ReadonlyArray<string>;
|
|
1404
1410
|
defaultCurrency?: string;
|
|
1411
|
+
closeOnAdd?: boolean;
|
|
1412
|
+
/** Drawn first in the card list (for example the marker of a card that is about to arrive). */
|
|
1413
|
+
incoming?: ReactNode;
|
|
1405
1414
|
onShowMore?: (stageId: string) => void;
|
|
1406
1415
|
dnd?: Pick<BoardDnd, 'Column'>;
|
|
1407
1416
|
}
|
|
1408
|
-
declare function BoardColumn({ column, texts, classNames, renderCard, onAddCard, currencies, defaultCurrency, onShowMore, dnd }: BoardColumnProps): react_jsx_runtime.JSX.Element;
|
|
1417
|
+
declare function BoardColumn({ column, texts, classNames, renderCard, onAddCard, currencies, defaultCurrency, closeOnAdd, incoming, onShowMore, dnd }: BoardColumnProps): react_jsx_runtime.JSX.Element;
|
|
1409
1418
|
|
|
1410
1419
|
interface DealCardProps {
|
|
1411
1420
|
card: BoardCard;
|
|
@@ -1419,12 +1428,16 @@ interface DealCardProps {
|
|
|
1419
1428
|
error?: string;
|
|
1420
1429
|
/** Wraps the title, for example in a link. */
|
|
1421
1430
|
renderTitle?: RenderCardTitle;
|
|
1422
|
-
/** The card's own controls (for example the move menu). Not drawn while pending
|
|
1431
|
+
/** The card's own controls (for example the move menu). Not drawn while pending, unless `keepControls`. */
|
|
1423
1432
|
controls?: ReactNode;
|
|
1433
|
+
/** Draw `controls` even while pending (an open step that must stay on screen while its move runs). */
|
|
1434
|
+
keepControls?: boolean;
|
|
1435
|
+
/** Dimmed look without hiding the controls: a step on this card is waiting for its answer. */
|
|
1436
|
+
waiting?: boolean;
|
|
1424
1437
|
/** Ref and attributes from the drag layer (the plain board passes none). */
|
|
1425
1438
|
shellProps?: CardShellProps;
|
|
1426
1439
|
}
|
|
1427
|
-
declare function DealCard({ card, texts, classNames, pending, dragging, error, renderTitle, controls, shellProps }: DealCardProps): react_jsx_runtime.JSX.Element;
|
|
1440
|
+
declare function DealCard({ card, texts, classNames, pending, dragging, error, renderTitle, controls, keepControls, waiting, shellProps }: DealCardProps): react_jsx_runtime.JSX.Element;
|
|
1428
1441
|
|
|
1429
1442
|
interface AddCardBoxProps {
|
|
1430
1443
|
/** Used to tell several boxes apart in the accessible names, for example the column name. */
|
|
@@ -1434,9 +1447,11 @@ interface AddCardBoxProps {
|
|
|
1434
1447
|
/** Currency codes offered; empty hides the currency field. */
|
|
1435
1448
|
currencies?: ReadonlyArray<string>;
|
|
1436
1449
|
defaultCurrency?: string;
|
|
1450
|
+
/** True: after a successful add the form closes and focus goes back to the "+ Add a card" button. Default false (stays open for the next card). */
|
|
1451
|
+
closeOnAdd?: boolean;
|
|
1437
1452
|
onAdd: (input: AddCardInput) => Promise<BoardResult>;
|
|
1438
1453
|
}
|
|
1439
|
-
declare function AddCardBox({ columnName, texts, classNames, currencies, defaultCurrency, onAdd }: AddCardBoxProps): react_jsx_runtime.JSX.Element;
|
|
1454
|
+
declare function AddCardBox({ columnName, texts, classNames, currencies, defaultCurrency, closeOnAdd, onAdd }: AddCardBoxProps): react_jsx_runtime.JSX.Element;
|
|
1440
1455
|
|
|
1441
1456
|
interface MoveMenuProps {
|
|
1442
1457
|
/** Used in the accessible name so several menus on a page are told apart, for example the card title. */
|
package/dist/index.mjs
CHANGED
|
@@ -3149,7 +3149,7 @@ function boardPart(classNames, key, options = {}) {
|
|
|
3149
3149
|
|
|
3150
3150
|
// src/components/add-card-box.tsx
|
|
3151
3151
|
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3152
|
-
function AddCardBox({ columnName, texts, classNames, currencies = [], defaultCurrency = "", onAdd }) {
|
|
3152
|
+
function AddCardBox({ columnName, texts, classNames, currencies = [], defaultCurrency = "", closeOnAdd = false, onAdd }) {
|
|
3153
3153
|
const initialCurrency = currencies.includes(defaultCurrency) ? defaultCurrency : "";
|
|
3154
3154
|
const [open, setOpen] = useState20(false);
|
|
3155
3155
|
const [title, setTitle] = useState20("");
|
|
@@ -3189,9 +3189,11 @@ function AddCardBox({ columnName, texts, classNames, currencies = [], defaultCur
|
|
|
3189
3189
|
setPending(true);
|
|
3190
3190
|
setError(void 0);
|
|
3191
3191
|
try {
|
|
3192
|
-
const result = await onAdd({ title: title.trim(), amount: amount.trim(), currency });
|
|
3192
|
+
const result = await onAdd({ title: title.trim(), amount: amount.trim(), currency: amount.trim() === "" ? "" : currency });
|
|
3193
3193
|
if (result && typeof result.error === "string" && result.error !== "") {
|
|
3194
3194
|
setError(result.error);
|
|
3195
|
+
} else if (closeOnAdd) {
|
|
3196
|
+
cancel();
|
|
3195
3197
|
} else {
|
|
3196
3198
|
setTitle("");
|
|
3197
3199
|
setAmount("");
|
|
@@ -3234,7 +3236,7 @@ function AddCardBox({ columnName, texts, classNames, currencies = [], defaultCur
|
|
|
3234
3236
|
|
|
3235
3237
|
// src/components/board-column.tsx
|
|
3236
3238
|
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
3237
|
-
function BoardColumn({ column, texts, classNames, renderCard, onAddCard, currencies, defaultCurrency, onShowMore, dnd }) {
|
|
3239
|
+
function BoardColumn({ column, texts, classNames, renderCard, onAddCard, currencies, defaultCurrency, closeOnAdd, incoming, onShowMore, dnd }) {
|
|
3238
3240
|
const headingId = useId5();
|
|
3239
3241
|
const body = (shell, over) => /* @__PURE__ */ jsxs16("section", { "aria-labelledby": headingId, "data-column-id": column.id, "data-kind": column.kind, ...shell, ...boardPart(classNames, "column", { states: over ? ["columnDropOver"] : [] }), children: [
|
|
3240
3242
|
/* @__PURE__ */ jsxs16("div", { ...boardPart(classNames, "columnHeader"), children: [
|
|
@@ -3242,9 +3244,12 @@ function BoardColumn({ column, texts, classNames, renderCard, onAddCard, currenc
|
|
|
3242
3244
|
/* @__PURE__ */ jsx17("span", { ...boardPart(classNames, "columnCount"), children: texts.columnCount(column.count) }),
|
|
3243
3245
|
column.totals.length > 0 ? /* @__PURE__ */ jsx17("p", { ...boardPart(classNames, "columnTotals"), children: column.totals.join(" \xB7 ") }) : null
|
|
3244
3246
|
] }),
|
|
3245
|
-
column.cards.length === 0 ? /* @__PURE__ */ jsx17("p", { ...boardPart(classNames, "empty"), children: texts.emptyColumn }) : /* @__PURE__ */
|
|
3247
|
+
column.cards.length === 0 && !incoming ? /* @__PURE__ */ jsx17("p", { ...boardPart(classNames, "empty"), children: texts.emptyColumn }) : /* @__PURE__ */ jsxs16("ul", { ...boardPart(classNames, "cardList"), children: [
|
|
3248
|
+
incoming,
|
|
3249
|
+
column.cards.map((card) => renderCard(card))
|
|
3250
|
+
] }),
|
|
3246
3251
|
column.hasMore && onShowMore ? /* @__PURE__ */ jsx17("button", { type: "button", onClick: () => onShowMore(column.id), ...boardPart(classNames, "showMore"), children: texts.showMore }) : null,
|
|
3247
|
-
column.kind === "open" && onAddCard ? /* @__PURE__ */ jsx17(AddCardBox, { columnName: column.name, texts, classNames, currencies, defaultCurrency, onAdd: (input) => onAddCard(column.id, input) }) : null
|
|
3252
|
+
column.kind === "open" && column.canAdd !== false && onAddCard ? /* @__PURE__ */ jsx17(AddCardBox, { columnName: column.name, texts, classNames, currencies, defaultCurrency, closeOnAdd, onAdd: (input) => onAddCard(column.id, input) }) : null
|
|
3248
3253
|
] });
|
|
3249
3254
|
if (!dnd) return body({}, false);
|
|
3250
3255
|
const Shell = dnd.Column;
|
|
@@ -3253,9 +3258,11 @@ function BoardColumn({ column, texts, classNames, renderCard, onAddCard, currenc
|
|
|
3253
3258
|
|
|
3254
3259
|
// src/components/deal-card.tsx
|
|
3255
3260
|
import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
3256
|
-
function DealCard({ card, texts, classNames, pending = false, dragging = false, error, renderTitle, controls, shellProps }) {
|
|
3257
|
-
const
|
|
3258
|
-
const
|
|
3261
|
+
function DealCard({ card, texts, classNames, pending = false, dragging = false, error, renderTitle, controls, keepControls = false, waiting = false, shellProps }) {
|
|
3262
|
+
const allTags = card.tags ?? [];
|
|
3263
|
+
const tags = allTags.slice(0, 2);
|
|
3264
|
+
const hiddenTags = allTags.length - tags.length;
|
|
3265
|
+
const states = [...pending || waiting ? ["cardPending"] : [], ...dragging ? ["cardDragging"] : []];
|
|
3259
3266
|
const title = /* @__PURE__ */ jsx18("span", { children: card.title });
|
|
3260
3267
|
const badge = card.badge === "won" ? texts.won : card.badge === "lost" ? texts.lost : null;
|
|
3261
3268
|
return /* @__PURE__ */ jsxs17("li", { tabIndex: -1, ...shellProps, ...boardPart(classNames, "card", { states }), "aria-busy": pending || void 0, "data-card-id": card.id, "data-pending": pending || void 0, children: [
|
|
@@ -3269,11 +3276,15 @@ function DealCard({ card, texts, classNames, pending = false, dragging = false,
|
|
|
3269
3276
|
] }) : null
|
|
3270
3277
|
] }) : null,
|
|
3271
3278
|
card.ownerInitials || tags.length > 0 || badge ? /* @__PURE__ */ jsxs17("p", { ...boardPart(classNames, "cardMeta"), style: { ...boardPart(classNames, "cardMeta").style, display: "flex", flexWrap: "wrap", alignItems: "center", gap: "6px" }, children: [
|
|
3272
|
-
card.ownerInitials ? /* @__PURE__ */ jsx18("span", { ...boardPart(classNames, "ownerMark"), "aria-label": `${texts.owner} ${card.ownerInitials}`, role: "img", children: card.ownerInitials }) : null,
|
|
3273
|
-
tags.map((tag) => /* @__PURE__ */ jsx18("span", { ...boardPart(classNames, "tagChip"), children: tag.label }, tag.id)),
|
|
3279
|
+
card.ownerInitials ? /* @__PURE__ */ jsx18("span", { ...boardPart(classNames, "ownerMark"), "aria-label": card.ownerFormer && texts.ownerFormer ? `${texts.owner} ${card.ownerInitials} (${texts.ownerFormer})` : `${texts.owner} ${card.ownerInitials}`, role: "img", children: card.ownerInitials }) : null,
|
|
3280
|
+
tags.map((tag) => /* @__PURE__ */ jsx18("span", { ...boardPart(tag.chipClassName ? { ...classNames, tagChip: [classNames?.tagChip, tag.chipClassName].filter(Boolean).join(" ") } : classNames, "tagChip"), children: tag.label }, tag.id)),
|
|
3281
|
+
hiddenTags > 0 ? /* @__PURE__ */ jsx18("span", { ...boardPart(classNames, "tagChip"), children: texts.moreTags ? texts.moreTags(hiddenTags) : `+${hiddenTags}` }) : null,
|
|
3274
3282
|
badge ? /* @__PURE__ */ jsx18("span", { ...boardPart(classNames, card.badge === "won" ? "badgeWon" : "badgeLost"), children: badge }) : null
|
|
3275
3283
|
] }) : null,
|
|
3276
|
-
pending ? /* @__PURE__ */
|
|
3284
|
+
pending ? /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
3285
|
+
keepControls ? controls : null,
|
|
3286
|
+
/* @__PURE__ */ jsx18("p", { ...boardPart(classNames, "note"), role: "status", children: texts.moving })
|
|
3287
|
+
] }) : controls,
|
|
3277
3288
|
error ? /* @__PURE__ */ jsx18("p", { ...boardPart(classNames, "cardError"), role: "alert", children: error }) : null
|
|
3278
3289
|
] });
|
|
3279
3290
|
}
|
|
@@ -3281,7 +3292,7 @@ function DealCard({ card, texts, classNames, pending = false, dragging = false,
|
|
|
3281
3292
|
// src/components/lost-step.tsx
|
|
3282
3293
|
import { useEffect as useEffect20, useId as useId6, useRef as useRef17, useState as useState21 } from "react";
|
|
3283
3294
|
import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
3284
|
-
function LostStep({ suggestions, used, validateReason, humanize, texts, classNames, error, busy = false, onConfirm, onCancel }) {
|
|
3295
|
+
function LostStep({ suggestions, used, validateReason, humanize, texts, classNames, error, busy = false, stageName, onConfirm, onCancel }) {
|
|
3285
3296
|
const [picked, setPicked] = useState21(null);
|
|
3286
3297
|
const [own, setOwn] = useState21("");
|
|
3287
3298
|
const [missing, setMissing] = useState21(false);
|
|
@@ -3312,6 +3323,7 @@ function LostStep({ suggestions, used, validateReason, humanize, texts, classNam
|
|
|
3312
3323
|
const onKeyDown = (event) => {
|
|
3313
3324
|
if (event.key !== "Escape") return;
|
|
3314
3325
|
event.stopPropagation();
|
|
3326
|
+
if (busy) return;
|
|
3315
3327
|
onCancel();
|
|
3316
3328
|
};
|
|
3317
3329
|
const choice = (item, index) => {
|
|
@@ -3337,7 +3349,8 @@ function LostStep({ suggestions, used, validateReason, humanize, texts, classNam
|
|
|
3337
3349
|
return (
|
|
3338
3350
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
3339
3351
|
/* @__PURE__ */ jsxs18("div", { role: "group", "aria-labelledby": titleId, onKeyDown, ...boardPart(classNames, "panel"), children: [
|
|
3340
|
-
/* @__PURE__ */ jsx19("p", { id: titleId, ...boardPart(classNames, "panelTitle"), children: texts.lostTitle }),
|
|
3352
|
+
/* @__PURE__ */ jsx19("p", { id: titleId, ...boardPart(classNames, "panelTitle"), children: stageName !== void 0 && texts.lostTitleFor ? texts.lostTitleFor(stageName) : texts.lostTitle }),
|
|
3353
|
+
texts.lostHelp ? /* @__PURE__ */ jsx19("p", { ...boardPart(classNames, "note"), children: texts.lostHelp }) : null,
|
|
3341
3354
|
suggestions.length > 0 ? /* @__PURE__ */ jsx19("div", { role: "group", "aria-label": texts.lostSuggested, style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: suggestions.map((s, i) => choice(s, i)) }) : null,
|
|
3342
3355
|
usedOnly.length > 0 ? /* @__PURE__ */ jsx19("div", { role: "group", "aria-label": texts.lostUsed, style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: usedOnly.map((u, i) => choice(u, suggestions.length + i)) }) : null,
|
|
3343
3356
|
/* @__PURE__ */ jsx19("label", { htmlFor: ownId, ...boardPart(classNames, "note"), children: texts.lostOwnLabel }),
|
|
@@ -3466,11 +3479,12 @@ var errorOf2 = (result) => {
|
|
|
3466
3479
|
return void 0;
|
|
3467
3480
|
};
|
|
3468
3481
|
function PipelineBoard(props) {
|
|
3469
|
-
const { columns, texts, classNames, pendingDealIds = [], cardErrors, onMove, legalTargets, reopenFor, onReopen, lost, onAddCard, currencies, defaultCurrency, onShowMore, renderCardTitle, endSlot, dnd } = props;
|
|
3482
|
+
const { columns, texts, classNames, pendingDealIds = [], cardErrors, onMove, legalTargets, reopenFor, onReopen, lost, onAddCard, currencies, defaultCurrency, closeOnAdd, stretchColumns = true, onShowMore, renderCardTitle, endSlot, dnd } = props;
|
|
3470
3483
|
const [placed, setPlaced] = useState24({});
|
|
3471
3484
|
const [errors, setErrors] = useState24({});
|
|
3472
3485
|
const [step, setStep] = useState24(null);
|
|
3473
3486
|
const [stepError, setStepError] = useState24();
|
|
3487
|
+
const [lostBusy, setLostBusy] = useState24(false);
|
|
3474
3488
|
const [position, setPosition] = useState24(0);
|
|
3475
3489
|
const rowRef = useRef19(null);
|
|
3476
3490
|
const running = useRef19(/* @__PURE__ */ new Set());
|
|
@@ -3499,7 +3513,10 @@ function PipelineBoard(props) {
|
|
|
3499
3513
|
const byId = /* @__PURE__ */ new Map();
|
|
3500
3514
|
for (const column of columns) for (const card of column.cards) byId.set(card.id, card);
|
|
3501
3515
|
return columns.map((column) => {
|
|
3502
|
-
const stay = column.cards.filter((card) =>
|
|
3516
|
+
const stay = column.cards.filter((card) => {
|
|
3517
|
+
const move = placed[card.id];
|
|
3518
|
+
return !Object.hasOwn(placed, card.id) || move?.toStageId === column.id || move?.running === true && !columns.some((c) => c.id === move.toStageId);
|
|
3519
|
+
});
|
|
3503
3520
|
const arriving = moved.filter(([, value]) => value.toStageId === column.id).map(([id]) => byId.get(id)).filter((card) => card !== void 0 && !column.cards.some((c) => c.id === card.id));
|
|
3504
3521
|
return arriving.length === 0 && stay.length === column.cards.length ? column : { ...column, cards: [...arriving, ...stay] };
|
|
3505
3522
|
});
|
|
@@ -3508,11 +3525,11 @@ function PipelineBoard(props) {
|
|
|
3508
3525
|
for (const column of columns) for (const card of column.cards) if (card.id === id) return card;
|
|
3509
3526
|
return void 0;
|
|
3510
3527
|
};
|
|
3511
|
-
const send = async (card, toStageId, reason) => {
|
|
3528
|
+
const send = async (card, toStageId, reason, hold = false) => {
|
|
3512
3529
|
if (!onMove || running.current.has(card.id)) return void 0;
|
|
3513
3530
|
running.current.add(card.id);
|
|
3514
3531
|
setErrors((prev) => withoutKey(prev, card.id));
|
|
3515
|
-
setPlaced((prev) => ({ ...prev, [card.id]: { toStageId, running: true } }));
|
|
3532
|
+
if (!hold) setPlaced((prev) => ({ ...prev, [card.id]: { toStageId, running: true } }));
|
|
3516
3533
|
const request = { dealId: card.id, toStageId, expectedVersion: card.version, ...reason !== void 0 ? { reason } : {} };
|
|
3517
3534
|
let message;
|
|
3518
3535
|
try {
|
|
@@ -3521,7 +3538,8 @@ function PipelineBoard(props) {
|
|
|
3521
3538
|
message = texts.unexpectedError;
|
|
3522
3539
|
}
|
|
3523
3540
|
running.current.delete(card.id);
|
|
3524
|
-
if (message) {
|
|
3541
|
+
if (message && hold) {
|
|
3542
|
+
} else if (message) {
|
|
3525
3543
|
setPlaced((prev) => withoutKey(prev, card.id));
|
|
3526
3544
|
setErrors((prev) => ({ ...prev, [card.id]: message }));
|
|
3527
3545
|
} else {
|
|
@@ -3530,11 +3548,13 @@ function PipelineBoard(props) {
|
|
|
3530
3548
|
}
|
|
3531
3549
|
return message;
|
|
3532
3550
|
};
|
|
3551
|
+
const kindOf = (card, toStageId) => columns.find((c) => c.id === toStageId)?.kind ?? legalTargets?.(card).find((t) => t.stageId === toStageId)?.kind ?? (legalTargets?.(card).some((t) => t.stageId === toStageId) ? "open" : void 0);
|
|
3533
3552
|
const requestMove = (card, toStageId) => {
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
if (
|
|
3537
|
-
if (
|
|
3553
|
+
if (lostBusy) return;
|
|
3554
|
+
const kind = kindOf(card, toStageId);
|
|
3555
|
+
if (kind === void 0 || card.stageId === toStageId) return;
|
|
3556
|
+
if (kind === "lost" && !lost) return;
|
|
3557
|
+
if (kind === "lost" && lost) {
|
|
3538
3558
|
setStepError(void 0);
|
|
3539
3559
|
setStep({ kind: "lost", card, toStageId });
|
|
3540
3560
|
return;
|
|
@@ -3556,11 +3576,20 @@ function PipelineBoard(props) {
|
|
|
3556
3576
|
texts,
|
|
3557
3577
|
classNames,
|
|
3558
3578
|
error: stepError,
|
|
3559
|
-
|
|
3560
|
-
|
|
3579
|
+
busy: lostBusy,
|
|
3580
|
+
stageName: legalTargets?.(card).find((t) => t.stageId === step.toStageId)?.label ?? columns.find((c) => c.id === step.toStageId)?.name,
|
|
3581
|
+
onCancel: () => {
|
|
3582
|
+
if (!lostBusy) setStep(null);
|
|
3583
|
+
},
|
|
3584
|
+
onConfirm: async (reason) => {
|
|
3585
|
+
if (!onMove || running.current.has(card.id)) return;
|
|
3561
3586
|
const target = step.toStageId;
|
|
3562
|
-
|
|
3563
|
-
|
|
3587
|
+
setStepError(void 0);
|
|
3588
|
+
setLostBusy(true);
|
|
3589
|
+
const message = await send(card, target, reason, true);
|
|
3590
|
+
setLostBusy(false);
|
|
3591
|
+
if (message) setStepError(message);
|
|
3592
|
+
else setStep(null);
|
|
3564
3593
|
}
|
|
3565
3594
|
}
|
|
3566
3595
|
);
|
|
@@ -3592,7 +3621,7 @@ function PipelineBoard(props) {
|
|
|
3592
3621
|
}
|
|
3593
3622
|
const reopen = card.badge && reopenFor && onReopen ? reopenFor(card) : null;
|
|
3594
3623
|
return /* @__PURE__ */ jsxs21(Fragment8, { children: [
|
|
3595
|
-
onMove && legalTargets ? /* @__PURE__ */ jsx22(MoveMenu, { cardTitle: card.title, targets: legalTargets(card).filter((t) => lost ||
|
|
3624
|
+
onMove && legalTargets ? /* @__PURE__ */ jsx22(MoveMenu, { cardTitle: card.title, targets: legalTargets(card).filter((t) => lost || kindOf(card, t.stageId) !== "lost"), texts, classNames, onChoose: (stageId) => requestMove(card, stageId) }) : null,
|
|
3596
3625
|
reopen ? /* @__PURE__ */ jsx22(
|
|
3597
3626
|
"button",
|
|
3598
3627
|
{
|
|
@@ -3609,8 +3638,9 @@ function PipelineBoard(props) {
|
|
|
3609
3638
|
};
|
|
3610
3639
|
const renderCard = (card) => {
|
|
3611
3640
|
const error = errors[card.id] ?? cardErrors?.[card.id];
|
|
3612
|
-
const
|
|
3613
|
-
|
|
3641
|
+
const lostOpen = step?.kind === "lost" && step.card.id === card.id;
|
|
3642
|
+
const build = (shellProps, dragging) => /* @__PURE__ */ jsx22(DealCard, { card, texts, classNames, pending: isPending(card.id), waiting: lostOpen, keepControls: lostOpen, dragging, error, renderTitle: renderCardTitle, controls: controlsFor(card), shellProps }, card.id);
|
|
3643
|
+
if (!dnd || isPending(card.id) || card.draggable === false || lostOpen) return build({}, false);
|
|
3614
3644
|
const Shell = dnd.Card;
|
|
3615
3645
|
return /* @__PURE__ */ jsx22(Shell, { card, children: (shellProps, dragging) => build(shellProps, dragging) }, card.id);
|
|
3616
3646
|
};
|
|
@@ -3625,7 +3655,7 @@ function PipelineBoard(props) {
|
|
|
3625
3655
|
}
|
|
3626
3656
|
const content = /* @__PURE__ */ jsxs21("div", { ...boardPart(classNames, "root"), children: [
|
|
3627
3657
|
columns.length > 1 ? /* @__PURE__ */ jsx22("p", { ...boardPart(classNames, "position"), role: "status", "aria-live": "polite", children: texts.stagePosition(Math.min(position, columns.length - 1) + 1, columns.length) }) : null,
|
|
3628
|
-
/* @__PURE__ */ jsxs21("div", { ref: rowRef, role: "region", "aria-label": texts.boardLabel, tabIndex: 0, onScroll, ...boardPart(classNames, "row"), children: [
|
|
3658
|
+
/* @__PURE__ */ jsxs21("div", { ref: rowRef, role: "region", "aria-label": texts.boardLabel, tabIndex: 0, onScroll, ...boardPart(classNames, "row"), style: { ...boardPart(classNames, "row").style, alignItems: stretchColumns ? "stretch" : "flex-start" }, children: [
|
|
3629
3659
|
view.map((column) => /* @__PURE__ */ jsx22(
|
|
3630
3660
|
BoardColumn,
|
|
3631
3661
|
{
|
|
@@ -3636,6 +3666,8 @@ function PipelineBoard(props) {
|
|
|
3636
3666
|
onAddCard,
|
|
3637
3667
|
currencies,
|
|
3638
3668
|
defaultCurrency,
|
|
3669
|
+
closeOnAdd,
|
|
3670
|
+
incoming: step?.kind === "lost" && step.toStageId === column.id && texts.lostIncoming ? /* @__PURE__ */ jsx22("li", { "data-incoming": step.card.id, ...boardPart(classNames, "note"), children: texts.lostIncoming(step.card.title) }) : void 0,
|
|
3639
3671
|
onShowMore,
|
|
3640
3672
|
dnd
|
|
3641
3673
|
},
|