laif-ds 0.2.46 → 0.2.48

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.
Files changed (34) hide show
  1. package/dist/_virtual/index6.js +2 -2
  2. package/dist/_virtual/index7.js +2 -2
  3. package/dist/agent-docs/components/AppForm.md +88 -10
  4. package/dist/agent-docs/components/AsyncSelect.md +94 -103
  5. package/dist/components/kanban.js +540 -0
  6. package/dist/components/ui/app-form.js +105 -72
  7. package/dist/components/ui/app-kanban.js +137 -0
  8. package/dist/components/ui/app-select.js +100 -87
  9. package/dist/components/ui/async-select.js +264 -278
  10. package/dist/index.d.ts +83 -29
  11. package/dist/index.js +77 -75
  12. package/dist/node_modules/@radix-ui/react-alert-dialog/dist/index.js +1 -1
  13. package/dist/node_modules/@radix-ui/react-alert-dialog/node_modules/@radix-ui/react-slot/dist/index.js +12 -0
  14. package/dist/node_modules/@radix-ui/react-collection/dist/index.js +1 -1
  15. package/dist/node_modules/@radix-ui/react-collection/node_modules/@radix-ui/react-slot/dist/index.js +50 -0
  16. package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +1 -1
  17. package/dist/node_modules/@radix-ui/react-dialog/node_modules/@radix-ui/react-slot/dist/index.js +50 -0
  18. package/dist/node_modules/@radix-ui/react-menu/dist/index.js +1 -1
  19. package/dist/node_modules/@radix-ui/react-menu/node_modules/@radix-ui/react-slot/dist/index.js +50 -0
  20. package/dist/node_modules/@radix-ui/react-popover/dist/index.js +1 -1
  21. package/dist/node_modules/@radix-ui/react-popover/node_modules/@radix-ui/react-slot/dist/index.js +50 -0
  22. package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +1 -1
  23. package/dist/node_modules/@radix-ui/react-primitive/node_modules/@radix-ui/react-slot/dist/index.js +50 -0
  24. package/dist/node_modules/@radix-ui/react-select/dist/index.js +1 -1
  25. package/dist/node_modules/@radix-ui/react-select/node_modules/@radix-ui/react-slot/dist/index.js +50 -0
  26. package/dist/node_modules/@radix-ui/react-slot/dist/index.js +47 -44
  27. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.js +1 -1
  28. package/dist/node_modules/@radix-ui/react-tooltip/node_modules/@radix-ui/react-slot/dist/index.js +12 -0
  29. package/dist/node_modules/eventemitter3/index2.js +1 -1
  30. package/dist/node_modules/style-to-object/cjs/index.js +1 -1
  31. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +536 -502
  32. package/dist/styles.css +1 -1
  33. package/dist/styles.v3.css +1 -1
  34. package/package.json +4 -4
@@ -1,22 +1,23 @@
1
1
  "use client";
2
- import { jsxs as n, jsx as a } from "react/jsx-runtime";
3
- import { cn as o } from "../../lib/utils.js";
4
- import { Controller as V } from "../../node_modules/react-hook-form/dist/index.esm.js";
5
- import { AppSelect as m } from "./app-select.js";
6
- import { Button as j } from "./button.js";
2
+ import { jsxs as l, jsx as a } from "react/jsx-runtime";
3
+ import { cn as s } from "../../lib/utils.js";
4
+ import { Controller as w } from "../../node_modules/react-hook-form/dist/index.esm.js";
5
+ import { AppSelect as v } from "./app-select.js";
6
+ import { AsyncSelect as O } from "./async-select.js";
7
+ import { Button as I } from "./button.js";
7
8
  import { Checkbox as A } from "./checkbox.js";
8
9
  import { DatePicker as F } from "./date-picker.js";
9
- import { Input as I } from "./input.js";
10
+ import { Input as R } from "./input.js";
10
11
  import { Label as t } from "./label.js";
11
- import { RadioGroup as R, RadioGroupItem as B } from "./radio-group.js";
12
- import { Slider as $ } from "./slider.js";
13
- import { Switch as D } from "./switch.js";
14
- import { Textarea as G } from "./textarea.js";
12
+ import { RadioGroup as j, RadioGroupItem as M } from "./radio-group.js";
13
+ import { Slider as B } from "./slider.js";
14
+ import { Switch as T } from "./switch.js";
15
+ import { Textarea as $ } from "./textarea.js";
15
16
  import { Typo as i } from "./typo.js";
16
- const X = ({
17
- items: h,
18
- cols: v = "2",
19
- form: b,
17
+ const Z = ({
18
+ items: u,
19
+ cols: b = "2",
20
+ form: m,
20
21
  submitText: g = "Invia",
21
22
  onSubmit: x,
22
23
  isSubmitting: p = !1,
@@ -25,98 +26,130 @@ const X = ({
25
26
  const {
26
27
  control: N,
27
28
  handleSubmit: y,
28
- formState: { errors: f, isValid: S, isDirty: k }
29
- } = b, w = (e) => {
29
+ formState: { errors: f, isValid: S, isDirty: V }
30
+ } = m, k = (e) => {
30
31
  const c = f[e.name]?.message, d = c ? String(c) : void 0;
31
32
  return /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a(
32
- V,
33
+ w,
33
34
  {
34
35
  name: e.name,
35
36
  control: N,
36
37
  render: ({ field: r }) => {
37
- const s = /* @__PURE__ */ n("div", { className: "mb-2 flex items-center justify-between", children: [
38
+ const o = /* @__PURE__ */ l("div", { className: "mb-2 flex items-center justify-between", children: [
38
39
  /* @__PURE__ */ a(t, { children: e.label }),
39
40
  d && /* @__PURE__ */ a("span", { className: "text-d-destructive text-xs", children: d })
40
41
  ] });
41
42
  switch (e.component) {
42
43
  case "input":
43
- return /* @__PURE__ */ n("div", { children: [
44
- s,
44
+ return /* @__PURE__ */ l("div", { children: [
45
+ o,
45
46
  /* @__PURE__ */ a(
46
- I,
47
+ R,
47
48
  {
48
49
  ...r,
50
+ type: e.inputType,
49
51
  placeholder: e.placeholder,
50
- className: o(d && "border-d-destructive"),
52
+ className: s(d && "border-d-destructive"),
51
53
  disabled: e.disabled
52
54
  }
53
55
  )
54
56
  ] });
57
+ case "async":
58
+ case "async-multiple": {
59
+ if (!e.fetcher || !e.renderOptionItem || !e.resolveOptionValue || !e.renderSelectedValue)
60
+ return /* @__PURE__ */ l("div", { children: [
61
+ o,
62
+ /* @__PURE__ */ a(i, { variant: "caption", className: "text-d-destructive", children: "Async select non configurato correttamente." })
63
+ ] });
64
+ const n = e.component === "async-multiple";
65
+ return /* @__PURE__ */ l("div", { children: [
66
+ o,
67
+ /* @__PURE__ */ a(
68
+ O,
69
+ {
70
+ multiple: n,
71
+ fetcher: e.fetcher,
72
+ initialOptions: e.initialOptions,
73
+ renderOptionItem: e.renderOptionItem,
74
+ resolveOptionValue: e.resolveOptionValue,
75
+ renderSelectedValue: e.renderSelectedValue,
76
+ value: r.value,
77
+ onChange: r.onChange,
78
+ placeholder: e.placeholder,
79
+ disabled: e.disabled,
80
+ notFound: e.notFound,
81
+ noResultsMessage: e.noResultsMessage,
82
+ debounce: e.debounce,
83
+ clearable: e.clearable
84
+ }
85
+ )
86
+ ] });
87
+ }
55
88
  case "textarea":
56
- return /* @__PURE__ */ n("div", { children: [
57
- s,
89
+ return /* @__PURE__ */ l("div", { children: [
90
+ o,
58
91
  /* @__PURE__ */ a(
59
- G,
92
+ $,
60
93
  {
61
94
  ...r,
62
95
  placeholder: e.placeholder,
63
- className: o(d && "border-d-destructive"),
96
+ className: s(d && "border-d-destructive"),
64
97
  disabled: e.disabled
65
98
  }
66
99
  )
67
100
  ] });
68
101
  case "radio":
69
- return /* @__PURE__ */ n("div", { children: [
70
- s,
102
+ return /* @__PURE__ */ l("div", { children: [
103
+ o,
71
104
  /* @__PURE__ */ a(
72
- R,
105
+ j,
73
106
  {
74
107
  value: r.value != null ? String(r.value) : "",
75
- onValueChange: (l) => r.onChange(l),
108
+ onValueChange: (n) => r.onChange(n),
76
109
  className: "space-y-2",
77
110
  disabled: e.disabled,
78
- children: (e.options ?? []).map((l) => {
79
- const u = `${e.name}-${l.value}`;
80
- return /* @__PURE__ */ n(
111
+ children: (e.options ?? []).map((n) => {
112
+ const h = `${e.name}-${n.value}`;
113
+ return /* @__PURE__ */ l(
81
114
  "div",
82
115
  {
83
116
  className: "flex items-center gap-2",
84
117
  children: [
85
118
  /* @__PURE__ */ a(
86
- B,
119
+ M,
87
120
  {
88
- id: u,
89
- value: String(l.value),
121
+ id: h,
122
+ value: String(n.value),
90
123
  disabled: e.disabled
91
124
  }
92
125
  ),
93
126
  /* @__PURE__ */ a(
94
127
  t,
95
128
  {
96
- htmlFor: u,
97
- className: o(
129
+ htmlFor: h,
130
+ className: s(
98
131
  "cursor-pointer",
99
132
  e.disabled && "cursor-not-allowed opacity-60"
100
133
  ),
101
- children: l.label
134
+ children: n.label
102
135
  }
103
136
  )
104
137
  ]
105
138
  },
106
- l.value
139
+ n.value
107
140
  );
108
141
  })
109
142
  }
110
143
  )
111
144
  ] });
112
145
  case "select":
113
- return /* @__PURE__ */ n("div", { children: [
114
- s,
146
+ return /* @__PURE__ */ l("div", { children: [
147
+ o,
115
148
  /* @__PURE__ */ a(
116
- m,
149
+ v,
117
150
  {
118
151
  ...r,
119
- onValueChange: (l) => r.onChange(l),
152
+ onValueChange: (n) => r.onChange(n),
120
153
  options: e.options ?? [],
121
154
  placeholder: e.placeholder,
122
155
  disabled: e.disabled
@@ -124,14 +157,14 @@ const X = ({
124
157
  )
125
158
  ] });
126
159
  case "multiselect":
127
- return /* @__PURE__ */ n("div", { children: [
128
- s,
160
+ return /* @__PURE__ */ l("div", { children: [
161
+ o,
129
162
  /* @__PURE__ */ a(
130
- m,
163
+ v,
131
164
  {
132
165
  ...r,
133
166
  multiple: !0,
134
- onValueChange: (l) => r.onChange(l),
167
+ onValueChange: (n) => r.onChange(n),
135
168
  options: e.options ?? [],
136
169
  placeholder: e.placeholder,
137
170
  disabled: e.disabled
@@ -139,13 +172,13 @@ const X = ({
139
172
  )
140
173
  ] });
141
174
  case "datepicker":
142
- return /* @__PURE__ */ n("div", { className: "relative", children: [
143
- s,
175
+ return /* @__PURE__ */ l("div", { className: "relative", children: [
176
+ o,
144
177
  /* @__PURE__ */ a(
145
178
  F,
146
179
  {
147
180
  value: r.value,
148
- onChange: e.disabled || e.calendarRange ? void 0 : (l) => r.onChange(l),
181
+ onChange: e.disabled || e.calendarRange ? void 0 : (n) => r.onChange(n),
149
182
  placeholder: e.placeholder,
150
183
  disabled: e.disabled,
151
184
  customCalendarProps: e.disabled ? {
@@ -154,20 +187,20 @@ const X = ({
154
187
  } : e.calendarRange ? {
155
188
  mode: "range",
156
189
  selected: r.value,
157
- onSelect: (l) => r.onChange(l)
190
+ onSelect: (n) => r.onChange(n)
158
191
  } : void 0
159
192
  }
160
193
  )
161
194
  ] });
162
195
  case "checkbox":
163
- return /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
164
- /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
196
+ return /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
197
+ /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
165
198
  /* @__PURE__ */ a(
166
199
  A,
167
200
  {
168
201
  ...r,
169
202
  id: e.name,
170
- onCheckedChange: (l) => r.onChange(l),
203
+ onCheckedChange: (n) => r.onChange(n),
171
204
  defaultChecked: !!e.defaultValue,
172
205
  disabled: e.disabled
173
206
  }
@@ -176,7 +209,7 @@ const X = ({
176
209
  t,
177
210
  {
178
211
  htmlFor: e.name,
179
- className: o(
212
+ className: s(
180
213
  "cursor-pointer",
181
214
  e.disabled && "cursor-not-allowed opacity-60"
182
215
  ),
@@ -195,9 +228,9 @@ const X = ({
195
228
  )
196
229
  ] });
197
230
  case "switch":
198
- return /* @__PURE__ */ n("div", { className: "space-y-1.5", children: [
199
- /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
200
- /* @__PURE__ */ n("div", { children: [
231
+ return /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
232
+ /* @__PURE__ */ l("div", { className: "flex items-center justify-between", children: [
233
+ /* @__PURE__ */ l("div", { children: [
201
234
  /* @__PURE__ */ a(t, { htmlFor: e.name, children: e.label }),
202
235
  e.caption && /* @__PURE__ */ a(
203
236
  i,
@@ -209,11 +242,11 @@ const X = ({
209
242
  )
210
243
  ] }),
211
244
  /* @__PURE__ */ a(
212
- D,
245
+ T,
213
246
  {
214
247
  id: e.name,
215
248
  checked: !!r.value,
216
- onCheckedChange: (l) => r.onChange(l),
249
+ onCheckedChange: (n) => r.onChange(n),
217
250
  disabled: e.disabled
218
251
  }
219
252
  )
@@ -221,13 +254,13 @@ const X = ({
221
254
  d && /* @__PURE__ */ a("span", { className: "text-d-destructive text-xs", children: d })
222
255
  ] });
223
256
  case "slider":
224
- return /* @__PURE__ */ n("div", { children: [
225
- s,
257
+ return /* @__PURE__ */ l("div", { children: [
258
+ o,
226
259
  /* @__PURE__ */ a(
227
- $,
260
+ B,
228
261
  {
229
262
  value: Array.isArray(r.value) ? r.value : [r.value || e.min || 0],
230
- onValueChange: (l) => r.onChange(l[0]),
263
+ onValueChange: (n) => r.onChange(n[0]),
231
264
  min: e.min ?? 0,
232
265
  max: e.max ?? 100,
233
266
  step: e.step ?? 1,
@@ -249,20 +282,20 @@ const X = ({
249
282
  }
250
283
  ) });
251
284
  };
252
- return /* @__PURE__ */ n("form", { onSubmit: y((e) => x?.(e)), children: [
253
- /* @__PURE__ */ a("div", { className: o("grid gap-4", `grid-cols-${v}`), children: h.map((e, c) => /* @__PURE__ */ a(
285
+ return /* @__PURE__ */ l("form", { onSubmit: y((e) => x?.(e)), children: [
286
+ /* @__PURE__ */ a("div", { className: s("grid gap-4", `grid-cols-${b}`), children: u.map((e, c) => /* @__PURE__ */ a(
254
287
  "div",
255
288
  {
256
- className: o(c === h.length - 1 && "col-span-full"),
257
- children: w(e)
289
+ className: s(c === u.length - 1 && "col-span-full"),
290
+ children: k(e)
258
291
  },
259
292
  e.name
260
293
  )) }),
261
294
  C && /* @__PURE__ */ a("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ a(
262
- j,
295
+ I,
263
296
  {
264
297
  type: "submit",
265
- disabled: !S || !k || p,
298
+ disabled: !S || !V || p,
266
299
  isLoading: p,
267
300
  children: g
268
301
  }
@@ -270,5 +303,5 @@ const X = ({
270
303
  ] });
271
304
  };
272
305
  export {
273
- X as AppForm
306
+ Z as AppForm
274
307
  };
@@ -0,0 +1,137 @@
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,
16
+ className: j,
17
+ allowTaskCreate: v = !0
18
+ }) {
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);
30
+ if (c !== -1) {
31
+ n = a, [t] = o[a].splice(c, 1);
32
+ break;
33
+ }
34
+ }
35
+ return !t || n === i ? r : (o[i] || (o[i] = []), o[i].push(t), n && l && l(e, n, i), o);
36
+ });
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)
41
+ );
42
+ if (!a) return t;
43
+ const c = n[a].findIndex(
44
+ (s) => s.id === e
45
+ );
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
51
+ );
52
+ if (m === -1)
53
+ n[r].push(p);
54
+ else {
55
+ const s = o === "top" ? m : m + 1;
56
+ n[r].splice(s, 0, p);
57
+ }
58
+ return a !== r && l && l(e, a, r), n;
59
+ });
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(
74
+ "span",
75
+ {
76
+ className: "inline-flex items-center gap-1.5 rounded-md px-2 py-0.5 text-xs font-medium",
77
+ style: {
78
+ backgroundColor: `${x(e.label)}20`,
79
+ color: x(e.label)
80
+ },
81
+ children: e.label
82
+ }
83
+ ),
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,
88
+ {
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
+ },
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
+ );
112
+ },
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
+ )) }) });
134
+ }
135
+ export {
136
+ Z as AppKanban
137
+ };