laif-ds 0.2.71 → 0.2.72

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,5 +1,5 @@
1
1
  "use client";
2
- var e = { exports: {} };
2
+ var e = {};
3
3
  export {
4
- e as __module
4
+ e as __exports
5
5
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- var e = {};
2
+ var e = { exports: {} };
3
3
  export {
4
- e as __exports
4
+ e as __module
5
5
  };
@@ -1,185 +1,216 @@
1
1
  "use client";
2
- import { jsx as o, jsxs as l, Fragment as H } from "react/jsx-runtime";
3
- import { useState as I, useMemo as P } from "react";
4
- import { KanbanBoardProvider as A, KanbanBoard as F, KanbanBoardColumn as J, KanbanBoardColumnHeader as R, KanbanBoardColumnList as W, KanbanBoardColumnListItem as q, KanbanBoardCard as E, KanbanBoardCardTitle as G, KanbanBoardCardDescription as Q } from "./kanban.js";
5
- import { stringToHexColor as U, cn as B, hexToRgba as K } from "../../lib/utils.js";
6
- import { Button as V } from "./button.js";
7
- import { Icon as X } from "./icon.js";
8
- import Y from "../../node_modules/lucide-react/dist/esm/icons/lock.js";
9
- import Z from "../../node_modules/lucide-react/dist/esm/icons/plus.js";
10
- function ne({
11
- columns: p,
12
- initialTasks: w,
13
- onTaskMove: m,
14
- onTaskEdit: x,
15
- onTaskCreate: h,
16
- taskActions: D,
17
- renderTaskContent: g,
18
- className: j,
19
- allowTaskCreate: z = !0
2
+ import { jsx as i, jsxs as c, Fragment as L } from "react/jsx-runtime";
3
+ import { useState as S, useMemo as q, useCallback as h } from "react";
4
+ import { KanbanBoardProvider as G, KanbanBoard as M, KanbanBoardColumn as Q, KanbanBoardColumnHeader as T, KanbanBoardColumnList as V, KanbanBoardColumnListItem as X, KanbanBoardCard as Y, KanbanBoardCardTitle as Z, KanbanBoardCardDescription as _ } from "./kanban.js";
5
+ import { stringToHexColor as $, cn as I, hexToRgba as E } from "../../lib/utils.js";
6
+ import { Button as k } from "./button.js";
7
+ import { Icon as ee } from "./icon.js";
8
+ import re from "../../node_modules/lucide-react/dist/esm/icons/lock.js";
9
+ import ne from "../../node_modules/lucide-react/dist/esm/icons/arrow-down-to-line.js";
10
+ import ae from "../../node_modules/lucide-react/dist/esm/icons/arrow-up-from-line.js";
11
+ import te from "../../node_modules/lucide-react/dist/esm/icons/plus.js";
12
+ function pe({
13
+ columns: C,
14
+ initialTasks: P,
15
+ onTaskMove: x,
16
+ onTaskEdit: y,
17
+ onTaskCreate: N,
18
+ taskActions: A,
19
+ renderTaskContent: B,
20
+ className: H,
21
+ allowTaskCreate: F = !0
20
22
  }) {
21
- const [N, C] = I(w), b = P(
22
- () => new Set(p.filter((e) => e.disabled).map((e) => e.id)),
23
- [p]
24
- ), y = (e) => {
25
- const i = {};
26
- for (const r of Object.keys(e))
27
- i[r] = [...e[r]];
28
- return i;
29
- }, O = (e, i) => {
30
- C((r) => {
31
- const d = y(r);
32
- let a, n;
33
- for (const s of Object.keys(d)) {
34
- const c = d[s].findIndex((f) => f.id === e);
35
- if (c !== -1) {
36
- n = s, [a] = d[s].splice(c, 1);
23
+ const [v, w] = S(P), [g, K] = S(null), u = q(
24
+ () => new Map(C.map((e) => [e.id, e])),
25
+ [C]
26
+ ), O = h(
27
+ (e) => !!u.get(e)?.disabled,
28
+ [u]
29
+ ), D = h(
30
+ (e) => {
31
+ const r = u.get(e);
32
+ return r ? !r.disabled && !r.disableOnDragIn : !0;
33
+ },
34
+ [u]
35
+ ), b = h(
36
+ (e) => {
37
+ const r = u.get(e);
38
+ return r ? !r.disabled && !r.disableOnDragOut : !0;
39
+ },
40
+ [u]
41
+ ), U = h(
42
+ (e) => !g || g === e ? !1 : !b(g),
43
+ [g, b]
44
+ ), z = (e) => {
45
+ const r = {};
46
+ for (const t of Object.keys(e))
47
+ r[t] = [...e[t]];
48
+ return r;
49
+ }, J = (e, r) => {
50
+ w((t) => {
51
+ const d = z(t);
52
+ let s, n;
53
+ for (const o of Object.keys(d)) {
54
+ const a = d[o].findIndex((l) => l.id === e);
55
+ if (a !== -1) {
56
+ n = o, [s] = d[o].splice(a, 1);
37
57
  break;
38
58
  }
39
59
  }
40
- return !a || n === i || n && b.has(n) || b.has(i) ? r : (d[i] || (d[i] = []), d[i].push(a), n && m && m(e, n, i), d);
60
+ return !s || n === r || n && !b(n) || !D(r) ? t : (d[r] || (d[r] = []), d[r].push(s), n && x && x(e, n, r), d);
41
61
  });
42
- }, L = (e, i, r, d) => {
43
- C((a) => {
44
- const n = y(a), s = Object.keys(n).find(
45
- (t) => n[t].some((S) => S.id === e)
62
+ }, R = (e, r, t, d) => {
63
+ w((s) => {
64
+ const n = z(s), o = Object.keys(n).find(
65
+ (m) => n[m].some((W) => W.id === e)
46
66
  );
47
- if (!s) return a;
48
- const c = n[s].findIndex(
49
- (t) => t.id === e
67
+ if (!o) return s;
68
+ const a = n[o].findIndex(
69
+ (m) => m.id === e
50
70
  );
51
- if (c === -1 || b.has(s) || b.has(r))
52
- return a;
53
- const [f] = n[s].splice(c, 1);
54
- n[r] || (n[r] = []);
55
- const u = n[r].findIndex(
56
- (t) => t.id === i
71
+ if (a === -1) return s;
72
+ const l = o === t;
73
+ if (l && O(t) || !l && (!b(o) || !D(t)))
74
+ return s;
75
+ const [f] = n[o].splice(a, 1);
76
+ n[t] || (n[t] = []);
77
+ const p = n[t].findIndex(
78
+ (m) => m.id === r
57
79
  );
58
- if (u === -1)
59
- n[r].push(f);
80
+ if (p === -1)
81
+ n[t].push(f);
60
82
  else {
61
- const t = d === "top" ? u : u + 1;
62
- n[r].splice(t, 0, f);
83
+ const m = d === "top" ? p : p + 1;
84
+ n[t].splice(m, 0, f);
63
85
  }
64
- return s !== r && m && m(e, s, r), n;
86
+ return o !== t && x && x(e, o, t), n;
65
87
  });
66
- }, v = (e) => JSON.parse(e);
67
- return /* @__PURE__ */ o(A, { children: /* @__PURE__ */ o(F, { className: j, children: p.map((e) => {
68
- const i = U(e.label), r = !!e.disabled;
69
- return /* @__PURE__ */ l(
70
- J,
88
+ }, j = (e) => JSON.parse(e);
89
+ return /* @__PURE__ */ i(G, { children: /* @__PURE__ */ i(M, { className: H, children: C.map((e) => {
90
+ const r = $(e.label), t = O(e.id), d = !D(e.id), s = !b(e.id), n = d && s, o = d || U(e.id);
91
+ return /* @__PURE__ */ c(
92
+ Q,
71
93
  {
72
94
  columnId: e.id,
73
- disabled: r,
74
- onDropOverColumn: (d) => {
75
- if (r) return;
76
- const a = v(d);
77
- O(a.id, e.id);
95
+ disabled: o,
96
+ onDropOverColumn: (a) => {
97
+ if (o) return;
98
+ const l = j(a);
99
+ J(l.id, e.id);
78
100
  },
79
- className: B(
101
+ className: I(
80
102
  "group/column relative transition-all duration-200",
81
- !r && "hover:-translate-y-0.5 hover:shadow-lg"
103
+ !n && "hover:-translate-y-0.5 hover:shadow-lg"
82
104
  ),
83
105
  children: [
84
- /* @__PURE__ */ o(R, { className: "sticky top-0 z-10 mb-2 rounded-xl border border-d-border/60 bg-d-sidebar/90 px-2.5 py-2 backdrop-blur", children: /* @__PURE__ */ l("div", { className: "flex w-full items-center justify-between", children: [
85
- /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
86
- /* @__PURE__ */ l(
106
+ /* @__PURE__ */ i(T, { className: "border-d-border/60 bg-d-sidebar/90 sticky top-0 z-10 mb-2 rounded-xl border px-2.5 py-2 backdrop-blur", children: /* @__PURE__ */ c("div", { className: "flex w-full items-center justify-between", children: [
107
+ /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
108
+ /* @__PURE__ */ c(
87
109
  "div",
88
110
  {
89
111
  className: "flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-semibold shadow-sm",
90
112
  style: {
91
- backgroundColor: K(i, 0.15),
92
- color: i,
93
- borderColor: K(i, 0.35)
113
+ backgroundColor: E(r, 0.15),
114
+ color: r,
115
+ borderColor: E(r, 0.35)
94
116
  },
95
117
  children: [
96
- /* @__PURE__ */ o(
118
+ /* @__PURE__ */ i(
97
119
  "span",
98
120
  {
99
121
  className: "size-1.5 rounded-full",
100
- style: { backgroundColor: i }
122
+ style: { backgroundColor: r }
101
123
  }
102
124
  ),
103
- /* @__PURE__ */ o("span", { className: "max-w-[150px] truncate", children: e.label })
125
+ /* @__PURE__ */ i("span", { className: "max-w-[150px] truncate", children: e.label })
104
126
  ]
105
127
  }
106
128
  ),
107
- /* @__PURE__ */ o("span", { className: "text-d-muted-foreground inline-flex items-center rounded-full border border-d-border/60 bg-d-muted/40 px-2 py-0.5 text-[11px] font-medium", children: N[e.id]?.length ?? 0 })
129
+ /* @__PURE__ */ i("span", { className: "text-d-muted-foreground border-d-border/60 bg-d-muted/40 inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-medium", children: v[e.id]?.length ?? 0 })
108
130
  ] }),
109
- /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
110
- r && /* @__PURE__ */ o(
131
+ /* @__PURE__ */ c("div", { className: "flex items-center gap-1", children: [
132
+ (d || s) && /* @__PURE__ */ i(
111
133
  "span",
112
134
  {
113
- className: "text-d-muted-foreground inline-flex size-6 items-center justify-center",
114
- title: "Colonna bloccata",
115
- "aria-label": "Colonna bloccata",
116
- children: /* @__PURE__ */ o(Y, { className: "size-3.5" })
135
+ className: "text-d-muted-foreground border-d-border/60 bg-d-muted/30 inline-flex h-6 items-center justify-center gap-1 rounded-md border px-1.5",
136
+ title: n ? "Entrata e uscita bloccate" : d ? "Entrata bloccata" : "Uscita bloccata",
137
+ "aria-label": n ? "Entrata e uscita bloccate" : d ? "Entrata bloccata" : "Uscita bloccata",
138
+ children: n ? /* @__PURE__ */ i(re, { className: "size-3.5" }) : /* @__PURE__ */ c(L, { children: [
139
+ d && /* @__PURE__ */ i(ne, { className: "size-3.5" }),
140
+ s && /* @__PURE__ */ i(ae, { className: "size-3.5" })
141
+ ] })
117
142
  }
118
143
  ),
119
- z && h && /* @__PURE__ */ o(
120
- V,
144
+ F && N && /* @__PURE__ */ i(
145
+ k,
121
146
  {
122
147
  variant: "ghost",
123
148
  size: "icon",
124
149
  className: "text-d-muted-foreground hover:text-d-foreground h-6 w-6",
125
- onClick: () => h(e.id),
126
- children: /* @__PURE__ */ o(Z, { className: "size-3.5" })
150
+ onClick: () => N(e.id),
151
+ children: /* @__PURE__ */ i(te, { className: "size-3.5" })
127
152
  }
128
153
  )
129
154
  ] })
130
155
  ] }) }),
131
- /* @__PURE__ */ o(
132
- W,
156
+ /* @__PURE__ */ i(
157
+ V,
133
158
  {
134
159
  className: "px-1.5 pb-3",
135
- dropDisabled: r,
136
- children: N[e.id]?.map((d) => /* @__PURE__ */ o(
137
- q,
160
+ dropDisabled: o,
161
+ children: v[e.id]?.map((a) => /* @__PURE__ */ i(
162
+ X,
138
163
  {
139
- cardId: d.id,
140
- dropDisabled: r,
164
+ cardId: a.id,
165
+ dropDisabled: o,
141
166
  className: "mb-2 border-0 last:mb-0",
142
- onDropOverListItem: (a, n) => {
143
- if (r || n === "none") return;
144
- const s = v(a);
145
- L(
146
- s.id,
147
- d.id,
167
+ onDragStartCapture: () => {
168
+ K(e.id);
169
+ },
170
+ onDragEndCapture: () => {
171
+ K(null);
172
+ },
173
+ onDropOverListItem: (l, f) => {
174
+ if (o || f === "none") return;
175
+ const p = j(l);
176
+ R(
177
+ p.id,
178
+ a.id,
148
179
  e.id,
149
- n
180
+ f
150
181
  );
151
182
  },
152
- children: /* @__PURE__ */ o(
153
- E,
183
+ children: /* @__PURE__ */ i(
184
+ Y,
154
185
  {
155
- data: d,
156
- dragDisabled: r,
157
- className: B(
186
+ data: a,
187
+ dragDisabled: t,
188
+ className: I(
158
189
  "group/card relative rounded-xl border border-transparent shadow-sm transition-all duration-200",
159
- !r && "hover:-translate-y-0.5 hover:border-d-border/60 hover:shadow-lg"
190
+ !t && "hover:border-d-border/60 hover:-translate-y-0.5 hover:shadow-lg"
160
191
  ),
161
- backgroundColor: i,
162
- onEdit: x ? () => x(d, e.id) : void 0,
163
- actions: D?.(d, e.id),
164
- meta: d.meta,
165
- children: g ? g(d, e.id) : /* @__PURE__ */ l(H, { children: [
166
- /* @__PURE__ */ l("div", { className: "mb-1 flex items-start gap-2", children: [
167
- d.icon && /* @__PURE__ */ o(
168
- X,
192
+ backgroundColor: r,
193
+ onEdit: y ? () => y(a, e.id) : void 0,
194
+ actions: A?.(a, e.id),
195
+ meta: a.meta,
196
+ children: B ? B(a, e.id) : /* @__PURE__ */ c(L, { children: [
197
+ /* @__PURE__ */ c("div", { className: "mb-1 flex items-start gap-2", children: [
198
+ a.icon && /* @__PURE__ */ i(
199
+ ee,
169
200
  {
170
- name: d.icon,
201
+ name: a.icon,
171
202
  size: "sm",
172
203
  className: "text-d-muted-foreground mt-0.5 shrink-0"
173
204
  }
174
205
  ),
175
- /* @__PURE__ */ o(G, { className: "flex-1 text-sm leading-snug font-semibold", children: d.title })
206
+ /* @__PURE__ */ i(Z, { className: "flex-1 text-sm leading-snug font-semibold", children: a.title })
176
207
  ] }),
177
- d.description && /* @__PURE__ */ o(Q, { className: "text-d-muted-foreground mt-1.5 line-clamp-2 text-xs leading-relaxed", children: d.description })
208
+ a.description && /* @__PURE__ */ i(_, { className: "text-d-muted-foreground mt-1.5 line-clamp-2 text-xs leading-relaxed", children: a.description })
178
209
  ] })
179
210
  }
180
211
  )
181
212
  },
182
- d.id
213
+ a.id
183
214
  ))
184
215
  }
185
216
  )
@@ -190,5 +221,5 @@ function ne({
190
221
  }) }) });
191
222
  }
192
223
  export {
193
- ne as AppKanban
224
+ pe as AppKanban
194
225
  };
package/dist/index.d.ts CHANGED
@@ -265,6 +265,14 @@ export declare type AppKanbanColumn = {
265
265
  id: string;
266
266
  label: string;
267
267
  disabled?: boolean;
268
+ /**
269
+ * Prevent dropping cards into this column.
270
+ */
271
+ disableOnDragIn?: boolean;
272
+ /**
273
+ * Prevent dragging cards out of this column.
274
+ */
275
+ disableOnDragOut?: boolean;
268
276
  };
269
277
 
270
278
  export declare type AppKanbanConfig<T = any> = {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as x } from "../../_virtual/index6.js";
2
+ import { __module as x } from "../../_virtual/index7.js";
3
3
  var w;
4
4
  function O() {
5
5
  return w ? x.exports : (w = 1, (function(d) {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __exports as r } from "../../../_virtual/index7.js";
2
+ import { __exports as r } from "../../../_virtual/index6.js";
3
3
  import { __require as c } from "../../inline-style-parser/index.js";
4
4
  var f;
5
5
  function j() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laif-ds",
3
3
  "private": false,
4
- "version": "0.2.71",
4
+ "version": "0.2.72",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",