laif-ds 0.2.48 → 0.2.49

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.
@@ -1,137 +1,157 @@
1
1
  "use client";
2
- import { jsx as d, jsxs as f, Fragment as P } from "react/jsx-runtime";
3
- import { useState as H } from "react";
4
- import { KanbanBoardProvider as S, KanbanBoard as A, KanbanBoardColumn as F, KanbanBoardColumnHeader as I, KanbanBoardColumnList as J, KanbanBoardColumnListItem as W, KanbanBoardCard as $, KanbanBoardCardTitle as q, KanbanBoardCardDescription as w } from "../kanban.js";
5
- import { Button as E } from "./button.js";
6
- import { stringToHexColor as x } from "../../lib/utils.js";
7
- import G from "../../node_modules/lucide-react/dist/esm/icons/plus.js";
8
- function Z({
9
- columns: g,
10
- initialTasks: N,
11
- onTaskMove: l,
12
- onTaskEdit: b,
13
- onTaskCreate: h,
14
- taskActions: O,
15
- renderTaskContent: u,
2
+ import { jsx as o, jsxs as l, Fragment as $ } from "react/jsx-runtime";
3
+ import { useState as z } from "react";
4
+ import { KanbanBoardProvider as H, KanbanBoard as I, KanbanBoardColumn as S, KanbanBoardColumnHeader as w, KanbanBoardColumnList as A, KanbanBoardColumnListItem as F, KanbanBoardCard as J, KanbanBoardCardTitle as W, KanbanBoardCardDescription as q } from "../kanban.js";
5
+ import { stringToHexColor as E } from "../../lib/utils.js";
6
+ import { Icon as G } from "./icon.js";
7
+ import Q from "../../node_modules/lucide-react/dist/esm/icons/plus.js";
8
+ function _({
9
+ columns: y,
10
+ initialTasks: K,
11
+ onTaskMove: p,
12
+ onTaskEdit: x,
13
+ onTaskCreate: u,
14
+ taskActions: B,
15
+ renderTaskContent: b,
16
16
  className: j,
17
- allowTaskCreate: v = !0
17
+ allowTaskCreate: v = !0,
18
+ createTaskLabel: O = "Nuovo task"
18
19
  }) {
19
- const [C, K] = H(N), y = (e) => {
20
- const i = {};
21
- for (const r of Object.keys(e))
22
- i[r] = [...e[r]];
23
- return i;
24
- }, D = (e, i) => {
25
- K((r) => {
26
- const o = y(r);
27
- let t, n;
28
- for (const a of Object.keys(o)) {
29
- const c = o[a].findIndex((p) => p.id === e);
20
+ const [h, C] = z(K), g = (r) => {
21
+ const n = {};
22
+ for (const e of Object.keys(r))
23
+ n[e] = [...r[e]];
24
+ return n;
25
+ }, D = (r, n) => {
26
+ C((e) => {
27
+ const t = g(e);
28
+ let d, i;
29
+ for (const s of Object.keys(t)) {
30
+ const c = t[s].findIndex((m) => m.id === r);
30
31
  if (c !== -1) {
31
- n = a, [t] = o[a].splice(c, 1);
32
+ i = s, [d] = t[s].splice(c, 1);
32
33
  break;
33
34
  }
34
35
  }
35
- return !t || n === i ? r : (o[i] || (o[i] = []), o[i].push(t), n && l && l(e, n, i), o);
36
+ return !d || i === n ? e : (t[n] || (t[n] = []), t[n].push(d), i && p && p(r, i, n), t);
36
37
  });
37
- }, z = (e, i, r, o) => {
38
- K((t) => {
39
- const n = y(t), a = Object.keys(n).find(
40
- (s) => n[s].some((L) => L.id === e)
38
+ }, L = (r, n, e, t) => {
39
+ C((d) => {
40
+ const i = g(d), s = Object.keys(i).find(
41
+ (a) => i[a].some((P) => P.id === r)
41
42
  );
42
- if (!a) return t;
43
- const c = n[a].findIndex(
44
- (s) => s.id === e
43
+ if (!s) return d;
44
+ const c = i[s].findIndex(
45
+ (a) => a.id === r
45
46
  );
46
- if (c === -1) return t;
47
- const [p] = n[a].splice(c, 1);
48
- n[r] || (n[r] = []);
49
- const m = n[r].findIndex(
50
- (s) => s.id === i
47
+ if (c === -1) return d;
48
+ const [m] = i[s].splice(c, 1);
49
+ i[e] || (i[e] = []);
50
+ const f = i[e].findIndex(
51
+ (a) => a.id === n
51
52
  );
52
- if (m === -1)
53
- n[r].push(p);
53
+ if (f === -1)
54
+ i[e].push(m);
54
55
  else {
55
- const s = o === "top" ? m : m + 1;
56
- n[r].splice(s, 0, p);
56
+ const a = t === "top" ? f : f + 1;
57
+ i[e].splice(a, 0, m);
57
58
  }
58
- return a !== r && l && l(e, a, r), n;
59
+ return s !== e && p && p(r, s, e), i;
59
60
  });
60
- }, B = (e) => JSON.parse(e);
61
- return /* @__PURE__ */ d(S, { children: /* @__PURE__ */ d(A, { className: j, children: g.map((e) => /* @__PURE__ */ f(
62
- F,
63
- {
64
- columnId: e.id,
65
- onDropOverColumn: (i) => {
66
- const r = B(i);
67
- D(r.id, e.id);
68
- },
69
- className: "group/column",
70
- children: [
71
- /* @__PURE__ */ f(I, { className: "relative", children: [
72
- /* @__PURE__ */ f("div", { className: "flex items-center gap-2", children: [
73
- /* @__PURE__ */ d(
61
+ }, N = (r) => JSON.parse(r);
62
+ return /* @__PURE__ */ o(H, { children: /* @__PURE__ */ o(I, { className: j, children: y.map((r) => {
63
+ const n = E(r.label);
64
+ return /* @__PURE__ */ l(
65
+ S,
66
+ {
67
+ columnId: r.id,
68
+ onDropOverColumn: (e) => {
69
+ const t = N(e);
70
+ D(t.id, r.id);
71
+ },
72
+ className: "group/column border-0",
73
+ style: {
74
+ backgroundColor: `${n}1d`
75
+ },
76
+ children: [
77
+ /* @__PURE__ */ o(w, { className: "relative mb-2", children: /* @__PURE__ */ l("div", { className: "flex items-center gap-1.5", children: [
78
+ /* @__PURE__ */ o(
74
79
  "span",
75
80
  {
76
- className: "inline-flex items-center gap-1.5 rounded-md px-2 py-0.5 text-xs font-medium",
81
+ className: "inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-sm font-semibold tracking-tight",
77
82
  style: {
78
- backgroundColor: `${x(e.label)}20`,
79
- color: x(e.label)
83
+ backgroundColor: `${n}18`,
84
+ color: n
80
85
  },
81
- children: e.label
86
+ children: r.label
82
87
  }
83
88
  ),
84
- /* @__PURE__ */ d("span", { className: "text-d-muted-foreground text-xs", children: C[e.id]?.length ?? 0 })
85
- ] }),
86
- v && h && /* @__PURE__ */ d(
87
- E,
89
+ /* @__PURE__ */ o("span", { className: "text-d-muted-foreground text-sm", children: h[r.id]?.length ?? 0 })
90
+ ] }) }),
91
+ /* @__PURE__ */ o(A, { children: h[r.id]?.map((e) => /* @__PURE__ */ o(
92
+ F,
88
93
  {
89
- variant: "ghost",
90
- size: "icon",
91
- className: "size-6 opacity-0 transition-opacity group-hover/column:opacity-100",
92
- onClick: (i) => {
93
- i.stopPropagation(), h(e.id);
94
+ cardId: e.id,
95
+ onDropOverListItem: (t, d) => {
96
+ if (d === "none") return;
97
+ const i = N(t);
98
+ L(
99
+ i.id,
100
+ e.id,
101
+ r.id,
102
+ d
103
+ );
94
104
  },
95
- children: /* @__PURE__ */ d(G, { className: "size-4" })
96
- }
97
- )
98
- ] }),
99
- /* @__PURE__ */ d(J, { children: C[e.id]?.map((i) => /* @__PURE__ */ d(
100
- W,
101
- {
102
- cardId: i.id,
103
- onDropOverListItem: (r, o) => {
104
- if (o === "none") return;
105
- const t = B(r);
106
- z(
107
- t.id,
108
- i.id,
109
- e.id,
110
- o
111
- );
105
+ children: /* @__PURE__ */ o(
106
+ J,
107
+ {
108
+ data: e,
109
+ onEdit: x ? () => x(e, r.id) : void 0,
110
+ actions: B?.(e, r.id),
111
+ meta: e.meta,
112
+ backgroundColor: n,
113
+ children: b ? b(e, r.id) : /* @__PURE__ */ l($, { children: [
114
+ /* @__PURE__ */ l("div", { className: "flex items-start gap-2", children: [
115
+ e.icon && /* @__PURE__ */ o(
116
+ G,
117
+ {
118
+ name: e.icon,
119
+ size: "sm",
120
+ className: "text-d-foreground/80 mt-0.5"
121
+ }
122
+ ),
123
+ /* @__PURE__ */ o(W, { className: "flex-1", children: e.title })
124
+ ] }),
125
+ e.description && /* @__PURE__ */ o(q, { children: e.description })
126
+ ] })
127
+ }
128
+ )
112
129
  },
113
- children: /* @__PURE__ */ d(
114
- $,
115
- {
116
- data: i,
117
- onEdit: b ? () => b(i, e.id) : void 0,
118
- actions: O?.(i, e.id),
119
- meta: i.meta,
120
- backgroundColor: x(e.label),
121
- children: u ? u(i, e.id) : /* @__PURE__ */ f(P, { children: [
122
- /* @__PURE__ */ d(q, { children: i.title }),
123
- i.description && /* @__PURE__ */ d(w, { children: i.description })
124
- ] })
125
- }
126
- )
127
- },
128
- i.id
129
- )) })
130
- ]
131
- },
132
- e.id
133
- )) }) });
130
+ e.id
131
+ )) }),
132
+ v && u && /* @__PURE__ */ o("div", { className: "px-2 pt-1", children: /* @__PURE__ */ l(
133
+ "button",
134
+ {
135
+ className: "flex w-full cursor-pointer items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-sm transition-colors",
136
+ style: {
137
+ backgroundColor: `${n}1a`,
138
+ color: n
139
+ },
140
+ onClick: (e) => {
141
+ e.stopPropagation(), u(r.id);
142
+ },
143
+ children: [
144
+ /* @__PURE__ */ o(Q, { className: "size-4" }),
145
+ /* @__PURE__ */ o("span", { children: O })
146
+ ]
147
+ }
148
+ ) })
149
+ ]
150
+ },
151
+ r.id
152
+ );
153
+ }) }) });
134
154
  }
135
155
  export {
136
- Z as AppKanban
156
+ _ as AppKanban
137
157
  };
package/dist/index.d.ts CHANGED
@@ -184,7 +184,7 @@ declare interface AppFormProps {
184
184
  showSubmitButton?: boolean;
185
185
  }
186
186
 
187
- export declare function AppKanban<T = any>({ columns, initialTasks, onTaskMove, onTaskEdit, onTaskCreate, taskActions, renderTaskContent, className, allowTaskCreate, }: AppKanbanConfig<T>): JSX.Element;
187
+ export declare function AppKanban<T = any>({ columns, initialTasks, onTaskMove, onTaskEdit, onTaskCreate, taskActions, renderTaskContent, className, allowTaskCreate, createTaskLabel, }: AppKanbanConfig<T>): JSX.Element;
188
188
 
189
189
  export declare type AppKanbanColumn = {
190
190
  id: string;
@@ -201,6 +201,7 @@ export declare type AppKanbanConfig<T = any> = {
201
201
  renderTaskContent?: (task: AppKanbanTask<T>, columnId: string) => ReactNode;
202
202
  className?: string;
203
203
  allowTaskCreate?: boolean;
204
+ createTaskLabel?: string;
204
205
  };
205
206
 
206
207
  export declare type AppKanbanTask<T = any> = {
@@ -209,6 +210,8 @@ export declare type AppKanbanTask<T = any> = {
209
210
  description?: string;
210
211
  data?: T;
211
212
  meta?: KanbanBoardCardMetaItem[];
213
+ icon?: IconName;
214
+ createTaskLabel?: string;
212
215
  };
213
216
 
214
217
  /**