@thebuoyant-tsdev/mui-ts-library 3.34.0 → 3.36.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.
@@ -2,121 +2,154 @@ import { kanbanBoardClasses as e } from "./kanbanBoardClasses.js";
2
2
  import { DEFAULT_KANBAN_BOARD_TRANSLATION as t } from "./KanbanBoard.types.js";
3
3
  import { KanbanBoardCard as n } from "./KanbanBoardCard.js";
4
4
  import { KanbanBoardCardDialog as r } from "./KanbanBoardCardDialog.js";
5
- import { KanbanBoardColumn as i } from "./KanbanBoardColumn.js";
6
- import { DndContext as a, DragOverlay as o, KeyboardSensor as s, PointerSensor as c, closestCorners as l, useSensor as u, useSensors as d } from "@dnd-kit/core";
7
- import { arrayMove as f, sortableKeyboardCoordinates as p } from "@dnd-kit/sortable";
8
- import m from "@mui/icons-material/Search";
9
- import { Box as h, InputAdornment as g, TextField as ee } from "@mui/material";
5
+ import { KanbanBoardColumnDialog as i } from "./KanbanBoardColumnDialog.js";
6
+ import { KanbanBoardColumn as a } from "./KanbanBoardColumn.js";
7
+ import { DndContext as o, DragOverlay as s, KeyboardSensor as c, PointerSensor as l, closestCorners as u, useSensor as d, useSensors as ee } from "@dnd-kit/core";
8
+ import { arrayMove as te, sortableKeyboardCoordinates as ne } from "@dnd-kit/sortable";
9
+ import f from "@mui/icons-material/Add";
10
+ import re from "@mui/icons-material/Search";
11
+ import { Box as p, Button as m, InputAdornment as h, TextField as g } from "@mui/material";
10
12
  import { useEffect as _, useState as v } from "react";
11
13
  import { jsx as y, jsxs as b } from "react/jsx-runtime";
12
14
  //#region src/components/kanban-board/KanbanBoard.tsx
13
- function x({ tasks: x, columns: S, onTasksChange: C, onCardClick: w, enableBuiltinDialogs: T = !0, onTaskCreated: E, onTaskUpdated: D, onTaskDeleted: O, onTaskMoved: k, showPriority: A = !0, showAssignee: j = !0, showDueDate: M = !0, showDueDateWarning: N = !0, chipVariant: P = "outlined", showSearchField: F = !1, filterText: I = "", width: L = "100%", height: R = "100%", translation: z }) {
14
- let B = {
15
+ function x({ tasks: x, columns: S, onTasksChange: C, onCardClick: ie, enableBuiltinDialogs: w = !0, enableColumnManagement: T = !1, onTaskCreated: ae, onTaskUpdated: oe, onTaskDeleted: E, onTaskMoved: D, onColumnsChange: O, onColumnAdd: k, onColumnUpdate: A, onColumnDelete: se, showPriority: j = !0, showAssignee: M = !0, showDueDate: N = !0, showDueDateWarning: P = !0, showSubtasks: F = !0, chipVariant: I = "outlined", showSearchField: L = !1, filterText: R = "", width: z = "100%", height: B = "100%", translation: V }) {
16
+ let H = {
15
17
  ...t,
16
- ...z
17
- }, [V, H] = v(x);
18
+ ...V
19
+ }, [U, W] = v(x);
18
20
  _(() => {
19
- H(x);
21
+ W(x);
20
22
  }, [x]);
21
- let [U, W] = v(null), [G, K] = v(null), [q, J] = v(""), Y = d(u(c, { activationConstraint: { distance: 8 } }), u(s, { coordinateGetter: p }));
22
- function X({ active: e }) {
23
- W(V.find((t) => t.id === e.id) ?? null);
23
+ let [G, K] = v(S);
24
+ _(() => {
25
+ K(S);
26
+ }, [S]);
27
+ let [q, J] = v(null), [Y, X] = v(null), [ce, Z] = v(null), [Q, le] = v(""), ue = ee(d(l, { activationConstraint: { distance: 8 } }), d(c, { coordinateGetter: ne }));
28
+ function de({ active: e }) {
29
+ J(U.find((t) => t.id === e.id) ?? null);
24
30
  }
25
- function Z({ active: e, over: t }) {
31
+ function fe({ active: e, over: t }) {
26
32
  if (!t) return;
27
- let n = e.id, r = t.id, i = V.find((e) => e.id === n);
33
+ let n = e.id, r = t.id, i = U.find((e) => e.id === n);
28
34
  if (!i) return;
29
- let a = S.find((e) => e.id === r), o = V.find((e) => e.id === r), s = a?.id ?? o?.status;
30
- !s || i.status === s || H((e) => e.map((e) => e.id === n ? {
35
+ let a = S.find((e) => e.id === r), o = U.find((e) => e.id === r), s = a?.id ?? o?.status;
36
+ !s || i.status === s || W((e) => e.map((e) => e.id === n ? {
31
37
  ...e,
32
38
  status: s
33
39
  } : e));
34
40
  }
35
- function Q({ active: e, over: t }) {
36
- let n = U?.status;
37
- if (W(null), !t) {
38
- H(x);
41
+ function pe({ active: e, over: t }) {
42
+ let n = q?.status;
43
+ if (J(null), !t) {
44
+ W(x);
39
45
  return;
40
46
  }
41
- let r = e.id, i = t.id, a = V.findIndex((e) => e.id === r), o = V.findIndex((e) => e.id === i), s;
42
- if (s = a !== -1 && o !== -1 && a !== o ? f(V, a, o) : [...V], H(s), C?.(s), n) {
47
+ let r = e.id, i = t.id, a = U.findIndex((e) => e.id === r), o = U.findIndex((e) => e.id === i), s;
48
+ if (s = a !== -1 && o !== -1 && a !== o ? te(U, a, o) : [...U], W(s), C?.(s), n) {
43
49
  let e = s.find((e) => e.id === r);
44
- e && e.status !== n && k?.(e, n, e.status);
50
+ e && e.status !== n && D?.(e, n, e.status);
45
51
  }
46
52
  }
47
- function te(e) {
48
- T ? K({
53
+ function me(e) {
54
+ w ? X({
49
55
  mode: "edit",
50
56
  task: e
51
- }) : w?.(e);
57
+ }) : ie?.(e);
52
58
  }
53
- function ne(e) {
54
- K({
59
+ function he(e) {
60
+ X({
55
61
  mode: "add",
56
62
  columnId: e
57
63
  });
58
64
  }
59
- function re(e) {
60
- let t = !V.find((t) => t.id === e.id), n = t ? [...V, e] : V.map((t) => t.id === e.id ? e : t);
61
- H(n), C?.(n), t ? E?.(e) : D?.(e), K(null);
65
+ function ge(e) {
66
+ let t = !U.find((t) => t.id === e.id), n = t ? [...U, e] : U.map((t) => t.id === e.id ? e : t);
67
+ W(n), C?.(n), t ? ae?.(e) : oe?.(e), X(null);
62
68
  }
63
- function ie(e) {
64
- let t = V.filter((t) => t.id !== e);
65
- H(t), C?.(t), O?.(e), K(null);
69
+ function _e(e) {
70
+ let t = U.filter((t) => t.id !== e);
71
+ W(t), C?.(t), E?.(e), X(null);
66
72
  }
67
- function ae(e) {
68
- K({
73
+ function ve(e) {
74
+ X({
69
75
  mode: "delete",
70
76
  task: e
71
77
  });
72
78
  }
73
- let $ = (I || q).trim().toLowerCase();
74
- function oe(e) {
79
+ let $ = (R || Q).trim().toLowerCase();
80
+ function ye(e) {
75
81
  return $ ? e.title.toLowerCase().includes($) || (e.assignee?.toLowerCase().includes($) ?? !1) : !0;
76
82
  }
77
- return /* @__PURE__ */ b(h, {
83
+ function be(e) {
84
+ let t = [...G, e];
85
+ K(t), k?.(e), O?.(t), Z(null);
86
+ }
87
+ function xe(e, t) {
88
+ let n = G.map((n) => n.id === e ? {
89
+ ...n,
90
+ label: t
91
+ } : n);
92
+ K(n);
93
+ let r = n.find((t) => t.id === e);
94
+ r && A?.(r), O?.(n);
95
+ }
96
+ function Se(e) {
97
+ let t = G.find((t) => t.id === e);
98
+ if (!t) return;
99
+ let n = U.filter((t) => t.status === e).length;
100
+ Z({
101
+ mode: "delete",
102
+ column: t,
103
+ cardCount: n
104
+ });
105
+ }
106
+ function Ce(e) {
107
+ let t = G.filter((t) => t.id !== e), n = U.filter((t) => t.status !== e);
108
+ K(t), W(n), se?.(e), O?.(t), C?.(n), Z(null);
109
+ }
110
+ return /* @__PURE__ */ b(p, {
78
111
  className: e.root,
79
112
  sx: {
80
- width: L,
81
- height: R,
113
+ width: z,
114
+ height: B,
82
115
  display: "flex",
83
116
  flexDirection: "column",
84
117
  overflow: "hidden"
85
118
  },
86
119
  children: [
87
- F && /* @__PURE__ */ y(h, {
120
+ L && /* @__PURE__ */ y(p, {
88
121
  className: e.searchFieldWrapper,
89
122
  sx: {
90
123
  px: 2,
91
124
  pt: 1.5,
92
125
  pb: .5
93
126
  },
94
- children: /* @__PURE__ */ y(ee, {
127
+ children: /* @__PURE__ */ y(g, {
95
128
  className: e.searchField,
96
129
  size: "small",
97
- placeholder: B.searchFieldPlaceholder,
98
- value: q,
99
- onChange: (e) => J(e.target.value),
130
+ placeholder: H.searchFieldPlaceholder,
131
+ value: Q,
132
+ onChange: (e) => le(e.target.value),
100
133
  slotProps: {
101
- input: { startAdornment: /* @__PURE__ */ y(g, {
134
+ input: { startAdornment: /* @__PURE__ */ y(h, {
102
135
  position: "start",
103
- children: /* @__PURE__ */ y(m, {
136
+ children: /* @__PURE__ */ y(re, {
104
137
  fontSize: "small",
105
138
  sx: { color: "text.disabled" }
106
139
  })
107
140
  }) },
108
- htmlInput: { "aria-label": B.searchFieldPlaceholder }
141
+ htmlInput: { "aria-label": H.searchFieldPlaceholder }
109
142
  },
110
143
  sx: { width: 280 }
111
144
  })
112
145
  }),
113
- /* @__PURE__ */ b(a, {
114
- sensors: Y,
115
- collisionDetection: l,
116
- onDragStart: X,
117
- onDragOver: Z,
118
- onDragEnd: Q,
119
- children: [/* @__PURE__ */ y(h, {
146
+ /* @__PURE__ */ b(o, {
147
+ sensors: ue,
148
+ collisionDetection: u,
149
+ onDragStart: de,
150
+ onDragOver: fe,
151
+ onDragEnd: pe,
152
+ children: [/* @__PURE__ */ b(p, {
120
153
  className: e.columns,
121
154
  sx: {
122
155
  flex: 1,
@@ -127,44 +160,86 @@ function x({ tasks: x, columns: S, onTasksChange: C, onCardClick: w, enableBuilt
127
160
  overflowY: "hidden",
128
161
  alignItems: "stretch"
129
162
  },
130
- children: S.map((e) => {
131
- let t = V.filter((t) => t.status === e.id);
132
- return /* @__PURE__ */ y(i, {
163
+ children: [G.map((e) => {
164
+ let t = U.filter((t) => t.status === e.id);
165
+ return /* @__PURE__ */ y(a, {
133
166
  column: e,
134
- tasks: t.filter(oe),
167
+ tasks: t.filter(ye),
135
168
  totalCount: t.length,
136
- showPriority: A,
137
- showAssignee: j,
138
- showDueDate: M,
139
- showDueDateWarning: N,
140
- chipVariant: P,
141
- t: B,
142
- enableBuiltinDialogs: T,
143
- onCardClick: te,
144
- onAddClick: ne
169
+ showPriority: j,
170
+ showAssignee: M,
171
+ showDueDate: N,
172
+ showDueDateWarning: P,
173
+ showSubtasks: F,
174
+ chipVariant: I,
175
+ t: H,
176
+ enableBuiltinDialogs: w,
177
+ enableColumnManagement: T && w,
178
+ onCardClick: me,
179
+ onAddClick: he,
180
+ onColumnRename: xe,
181
+ onColumnDeleteRequest: Se
145
182
  }, e.id);
146
- })
147
- }), /* @__PURE__ */ y(o, { children: U && /* @__PURE__ */ y(n, {
148
- task: U,
149
- showPriority: A,
150
- showAssignee: j,
151
- showDueDate: M,
152
- showDueDateWarning: N,
153
- chipVariant: P,
154
- t: B,
183
+ }), T && w && /* @__PURE__ */ y(p, {
184
+ sx: {
185
+ display: "flex",
186
+ alignItems: "flex-start",
187
+ pt: .5
188
+ },
189
+ children: /* @__PURE__ */ y(m, {
190
+ className: e.columnAddButton,
191
+ startIcon: /* @__PURE__ */ y(f, {}),
192
+ size: "small",
193
+ onClick: () => Z({ mode: "add" }),
194
+ sx: {
195
+ minWidth: 140,
196
+ whiteSpace: "nowrap",
197
+ color: "text.secondary",
198
+ border: "1px dashed",
199
+ borderColor: "divider",
200
+ borderRadius: 2,
201
+ py: 1,
202
+ px: 2,
203
+ fontWeight: 600,
204
+ "&:hover": {
205
+ bgcolor: "action.hover",
206
+ borderColor: "text.secondary"
207
+ }
208
+ },
209
+ children: H.columnAddLabel
210
+ })
211
+ })]
212
+ }), /* @__PURE__ */ y(s, { children: q && /* @__PURE__ */ y(n, {
213
+ task: q,
214
+ showPriority: j,
215
+ showAssignee: M,
216
+ showDueDate: N,
217
+ showDueDateWarning: P,
218
+ showSubtasks: F,
219
+ enableBuiltinDialogs: !1,
220
+ chipVariant: I,
221
+ t: H,
155
222
  onCardClick: () => {},
156
223
  isOverlay: !0
157
224
  }) })]
158
225
  }),
159
- T && /* @__PURE__ */ y(r, {
160
- state: G,
161
- columns: S,
162
- t: B,
163
- onSave: re,
164
- onDelete: ie,
165
- onRequestDelete: ae,
166
- onClose: () => K(null)
167
- }, G ? `${G.mode}-${G.mode === "add" ? G.columnId : G.task.id}` : "closed")
226
+ w && /* @__PURE__ */ y(r, {
227
+ state: Y,
228
+ columns: G,
229
+ t: H,
230
+ showSubtasks: F,
231
+ onSave: ge,
232
+ onDelete: _e,
233
+ onRequestDelete: ve,
234
+ onClose: () => X(null)
235
+ }, Y ? `${Y.mode}-${Y.mode === "add" ? Y.columnId : Y.task.id}` : "closed"),
236
+ T && w && /* @__PURE__ */ y(i, {
237
+ state: ce,
238
+ t: H,
239
+ onAdd: be,
240
+ onDelete: Ce,
241
+ onClose: () => Z(null)
242
+ })
168
243
  ]
169
244
  });
170
245
  }
@@ -1,4 +1,9 @@
1
1
  export type KanbanTaskPriority = "low" | "medium" | "high" | "critical";
2
+ export type KanbanSubtask = {
3
+ id: string;
4
+ title: string;
5
+ done: boolean;
6
+ };
2
7
  export type KanbanTask = {
3
8
  id: string;
4
9
  title: string;
@@ -11,6 +16,8 @@ export type KanbanTask = {
11
16
  dueDate?: Date;
12
17
  /** Optional priority level — shown as a colored dot next to the card title when `showPriority` is true. */
13
18
  priority?: KanbanTaskPriority;
19
+ /** Optional checklist items — shown as a progress bar on the card and a checklist in the edit dialog. */
20
+ subtasks?: KanbanSubtask[];
14
21
  };
15
22
  export type KanbanColumn = {
16
23
  /** Used as the key — must match `KanbanTask.status` values. */
@@ -39,6 +46,24 @@ export type KanbanBoardTranslation = {
39
46
  noCardsLabel: string;
40
47
  /** Placeholder text for the built-in search field (`showSearchField={true}`). */
41
48
  searchFieldPlaceholder: string;
49
+ /** Section label for the subtask checklist in the edit/add dialog. */
50
+ dialogFieldSubtasks: string;
51
+ /** Placeholder for the "add subtask" input in the dialog. */
52
+ dialogSubtaskAdd: string;
53
+ /** Tooltip for the "+" button on the card's subtask progress bar. */
54
+ cardSubtaskAdd: string;
55
+ /** Button label for the "Add column" ghost button (`enableColumnManagement`). */
56
+ columnAddLabel: string;
57
+ /** Placeholder inside the add-column dialog text field. */
58
+ columnAddPlaceholder: string;
59
+ /** Confirmation dialog title when deleting a column. "{label}" → column name. */
60
+ columnDeleteConfirm: string;
61
+ /** Warning line shown when the column being deleted still has cards. "{count}" → number of cards. */
62
+ columnDeleteCardsWarning: string;
63
+ /** Tooltip on the rename icon in the column header. */
64
+ columnRenameTooltip: string;
65
+ /** Tooltip on the delete icon in the column header. */
66
+ columnDeleteTooltip: string;
42
67
  };
43
68
  export declare const DEFAULT_KANBAN_BOARD_TRANSLATION: Required<KanbanBoardTranslation>;
44
69
  export type KanbanBoardProps = {
@@ -94,6 +119,11 @@ export type KanbanBoardProps = {
94
119
  * `"filled"` — solid background, more prominent.
95
120
  */
96
121
  chipVariant?: "outlined" | "filled";
122
+ /**
123
+ * Show the subtask progress bar on cards and the subtask checklist in the edit/add dialog (default: true).
124
+ * Has no visual effect when a card has no `subtasks` field set.
125
+ */
126
+ showSubtasks?: boolean;
97
127
  /**
98
128
  * When `true`, renders a built-in `size="small"` search field above the board columns.
99
129
  * The board manages the search state internally — no extra wiring needed.
@@ -113,6 +143,25 @@ export type KanbanBoardProps = {
113
143
  * Alternative: set `showSearchField={true}` to let the board render a built-in field.
114
144
  */
115
145
  filterText?: string;
146
+ /**
147
+ * When `true`, shows inline rename / delete controls on column headers and an
148
+ * "Add column" button at the end of the board. Default: `false`.
149
+ *
150
+ * Requires `enableBuiltinDialogs` to be `true` (the controls are suppressed
151
+ * when built-in dialogs are disabled).
152
+ */
153
+ enableColumnManagement?: boolean;
154
+ /**
155
+ * Called after every column add, rename, or delete with the full updated column list.
156
+ * Mirror of `onTasksChange` for columns.
157
+ */
158
+ onColumnsChange?: (columns: KanbanColumn[]) => void;
159
+ /** Called after a new column is added via the built-in UI. */
160
+ onColumnAdd?: (column: KanbanColumn) => void;
161
+ /** Called after a column label is changed via the inline rename. */
162
+ onColumnUpdate?: (column: KanbanColumn) => void;
163
+ /** Called after a column (and all its cards) is deleted via the built-in UI. */
164
+ onColumnDelete?: (columnId: string) => void;
116
165
  /** Width of the board. Default: "100%". */
117
166
  width?: number | string;
118
167
  /** Height of the board. Default: "100%". */
@@ -14,7 +14,16 @@ var e = {
14
14
  dialogFieldDueDate: "Due date",
15
15
  dialogFieldStatus: "Status",
16
16
  noCardsLabel: "No cards",
17
- searchFieldPlaceholder: "Search by title or assignee…"
17
+ searchFieldPlaceholder: "Search by title or assignee…",
18
+ dialogFieldSubtasks: "Subtasks",
19
+ dialogSubtaskAdd: "Add subtask",
20
+ cardSubtaskAdd: "Add subtask",
21
+ columnAddLabel: "Add column",
22
+ columnAddPlaceholder: "Column name",
23
+ columnDeleteConfirm: "Delete column \"{label}\"?",
24
+ columnDeleteCardsWarning: "{count} card(s) in this column will also be deleted.",
25
+ columnRenameTooltip: "Rename",
26
+ columnDeleteTooltip: "Delete column"
18
27
  };
19
28
  //#endregion
20
29
  export { e as DEFAULT_KANBAN_BOARD_TRANSLATION };
@@ -5,11 +5,13 @@ type KanbanBoardCardProps = {
5
5
  showAssignee: boolean;
6
6
  showDueDate: boolean;
7
7
  showDueDateWarning: boolean;
8
+ showSubtasks: boolean;
9
+ enableBuiltinDialogs: boolean;
8
10
  chipVariant: "outlined" | "filled";
9
11
  t: Required<KanbanBoardTranslation>;
10
12
  onCardClick: (task: KanbanTask) => void;
11
13
  /** True when this card is the drag overlay ghost — rendered without transform/listeners. */
12
14
  isOverlay?: boolean;
13
15
  };
14
- export declare function KanbanBoardCard({ task, showPriority, showAssignee, showDueDate, showDueDateWarning, chipVariant, t, onCardClick, isOverlay, }: KanbanBoardCardProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function KanbanBoardCard({ task, showPriority, showAssignee, showDueDate, showDueDateWarning, showSubtasks, enableBuiltinDialogs, chipVariant, t, onCardClick, isOverlay, }: KanbanBoardCardProps): import("react/jsx-runtime").JSX.Element;
15
17
  export {};