laif-ds 0.2.71 → 0.2.73

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,34 +1,38 @@
1
1
  "use client";
2
- import { jsxs as u, jsx as i } from "react/jsx-runtime";
2
+ import { jsxs as u, jsx as a } from "react/jsx-runtime";
3
3
  import { designTokens as f } from "../design-tokens.js";
4
- import { Icon as A } from "./icon.js";
5
- import { Label as ne } from "./label.js";
6
- import { Popover as oe, PopoverTrigger as re, PopoverContent as ie } from "./popover.js";
7
- import { cn as z } from "../../lib/utils.js";
8
- import { useState as I, useRef as _, useCallback as U, useMemo as S, useLayoutEffect as ae } from "react";
9
- import { Button as L } from "./button.js";
10
- const de = {
4
+ import { Icon as B } from "./icon.js";
5
+ import { Label as de } from "./label.js";
6
+ import { Popover as le, PopoverTrigger as ce, PopoverContent as ue } from "./popover.js";
7
+ import { cn as V } from "../../lib/utils.js";
8
+ import { useState as E, useRef as W, useCallback as k, useMemo as b, useLayoutEffect as me } from "react";
9
+ import { Button as X } from "./button.js";
10
+ const fe = {
11
11
  sm: f.sizes.sm,
12
12
  default: f.sizes.default,
13
13
  lg: f.sizes.lg
14
- }, le = {
14
+ }, ge = {
15
15
  default: "bg-d-input border-d-border/50",
16
16
  destructive: "bg-d-destructive/10 border-d-destructive/50 text-d-destructive",
17
17
  outline: "bg-transparent border-d-foreground",
18
18
  secondary: "bg-d-secondary border-d-border text-d-secondary-foreground",
19
19
  ghost: "bg-transparent border-transparent hover:bg-d-accent",
20
20
  link: "bg-transparent border-transparent text-d-primary underline-offset-4 hover:underline"
21
+ }, F = (r) => {
22
+ if (!Number.isFinite(r)) return 1;
23
+ const l = Math.trunc(r);
24
+ return Math.min(59, Math.max(1, l));
21
25
  };
22
- function k({
23
- options: a,
26
+ function D({
27
+ options: r,
24
28
  value: l,
25
29
  onChange: g,
26
- type: b,
30
+ type: p,
27
31
  className: T,
28
32
  disabledValues: w
29
33
  }) {
30
- const m = _(null);
31
- return ae(() => {
34
+ const m = W(null);
35
+ return me(() => {
32
36
  m.current && l !== void 0 && m.current.scrollIntoView({
33
37
  behavior: "instant",
34
38
  block: "center"
@@ -36,16 +40,16 @@ function k({
36
40
  }, [l]), /* @__PURE__ */ u(
37
41
  "div",
38
42
  {
39
- className: z(
43
+ className: V(
40
44
  "flex min-h-0 w-14 flex-col items-center overflow-hidden sm:w-16",
41
45
  T
42
46
  ),
43
47
  children: [
44
- /* @__PURE__ */ i("div", { className: "text-d-muted-foreground py-2 text-[10px] font-semibold tracking-wider uppercase", children: b === "hour" ? "HH" : b === "minute" ? "MM" : "SS" }),
45
- /* @__PURE__ */ i("div", { className: "flex min-h-0 w-full flex-1 flex-col overflow-auto overscroll-contain px-1.5", children: a.map((c) => {
48
+ /* @__PURE__ */ a("div", { className: "text-d-muted-foreground py-2 text-[10px] font-semibold tracking-wider uppercase", children: p === "hour" ? "HH" : p === "minute" ? "MM" : "SS" }),
49
+ /* @__PURE__ */ a("div", { className: "flex min-h-0 w-full flex-1 flex-col overflow-auto overscroll-contain px-1.5", children: r.map((c) => {
46
50
  const N = w?.has(c) ?? !1;
47
- return /* @__PURE__ */ i(
48
- L,
51
+ return /* @__PURE__ */ a(
52
+ X,
49
53
  {
50
54
  ref: l !== void 0 && c === l ? m : void 0,
51
55
  variant: l !== void 0 && c === l ? "default" : "ghost",
@@ -61,118 +65,132 @@ function k({
61
65
  }
62
66
  );
63
67
  }
64
- function ve(a) {
68
+ function Ne(r) {
65
69
  const {
66
70
  value: l,
67
71
  onChange: g,
68
- onClear: b,
72
+ onClear: p,
69
73
  label: T,
70
74
  placeholder: w = "Seleziona orario",
71
75
  disabled: m = !1,
72
76
  clearable: c = !1,
73
77
  className: N,
74
- labelClassName: B,
75
- wrpClassName: E,
76
- size: W = "default",
77
- variant: X = "default",
78
+ labelClassName: q,
79
+ wrpClassName: G,
80
+ size: J = "default",
81
+ variant: K = "default",
78
82
  useUtc: d = !1,
79
- withSeconds: H = !1,
80
- id: q,
81
- "data-testid": F
82
- } = a, [G, D] = I(
83
+ withSeconds: M = !1,
84
+ minuteStep: P = 1,
85
+ secondStep: O = 1,
86
+ id: Q,
87
+ "data-testid": Y
88
+ } = r, [Z, j] = E(
83
89
  void 0
84
- ), [V, J] = I(!1), K = _(null), p = a.hasOwnProperty("value"), s = p ? l : G, P = U(() => {
85
- p || D(void 0), g?.(void 0), b?.();
86
- }, [p, g, b]), O = U(() => {
90
+ ), [R, $] = E(!1), ee = W(null), v = r.hasOwnProperty("value"), s = v ? l : Z, A = k(() => {
91
+ v || j(void 0), g?.(void 0), p?.();
92
+ }, [v, g, p]), I = k(() => {
87
93
  if (!s) return "";
88
94
  let e, n, o;
89
95
  d ? (e = s.getUTCHours(), n = s.getUTCMinutes(), o = s.getUTCSeconds()) : (e = s.getHours(), n = s.getMinutes(), o = s.getSeconds());
90
- const v = [
96
+ const S = [
91
97
  e.toString().padStart(2, "0"),
92
98
  n.toString().padStart(2, "0")
93
99
  ];
94
- return H && v.push(o.toString().padStart(2, "0")), v.join(":");
95
- }, [s, d, H])(), M = U(
100
+ return M && S.push(o.toString().padStart(2, "0")), S.join(":");
101
+ }, [s, d, M])(), H = k(
96
102
  (e, n) => {
97
103
  const o = s ? new Date(s) : /* @__PURE__ */ new Date();
98
- d ? (s || o.setUTCHours(0, 0, 0, 0), e === "hour" ? o.setUTCHours(n) : e === "minute" ? o.setUTCMinutes(n) : e === "second" && o.setUTCSeconds(n)) : (s || o.setHours(0, 0, 0, 0), e === "hour" ? o.setHours(n) : e === "minute" ? o.setMinutes(n) : e === "second" && o.setSeconds(n)), p || D(o), g?.(o);
104
+ d ? (s || o.setUTCHours(0, 0, 0, 0), e === "hour" ? o.setUTCHours(n) : e === "minute" ? o.setUTCMinutes(n) : e === "second" && o.setUTCSeconds(n)) : (s || o.setHours(0, 0, 0, 0), e === "hour" ? o.setHours(n) : e === "minute" ? o.setMinutes(n) : e === "second" && o.setSeconds(n)), v || j(o), g?.(o);
99
105
  },
100
- [s, g, d, p]
101
- ), h = d ? s?.getUTCHours() : s?.getHours(), x = d ? s?.getUTCMinutes() : s?.getMinutes(), Q = d ? s?.getUTCSeconds() : s?.getSeconds(), Y = S(
106
+ [s, g, d, v]
107
+ ), h = d ? s?.getUTCHours() : s?.getHours(), x = d ? s?.getUTCMinutes() : s?.getMinutes(), te = d ? s?.getUTCSeconds() : s?.getSeconds(), y = b(
108
+ () => F(P),
109
+ [P]
110
+ ), U = b(
111
+ () => F(O),
112
+ [O]
113
+ ), se = b(
102
114
  () => Array.from({ length: 24 }, (e, n) => n),
103
115
  []
104
- ), Z = S(
105
- () => Array.from({ length: 60 }, (e, n) => n),
106
- []
107
- ), $ = S(
108
- () => Array.from({ length: 60 }, (e, n) => n),
109
- []
110
- ), { disabledHours: ee, disabledMinutes: te, disabledSeconds: se } = S(() => {
111
- const e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), v = d ? (r) => r.getUTCHours() : (r) => r.getHours(), j = d ? (r) => r.getUTCMinutes() : (r) => r.getMinutes(), R = d ? (r) => r.getUTCSeconds() : (r) => r.getSeconds();
112
- if (a.minTime) {
113
- const r = v(a.minTime), C = j(a.minTime), y = R(a.minTime);
114
- for (let t = 0; t < r; t++) e.add(t);
115
- if (h !== void 0 && h === r) {
116
+ ), ne = b(
117
+ () => Array.from(
118
+ { length: Math.floor(59 / y) + 1 },
119
+ (e, n) => n * y
120
+ ),
121
+ [y]
122
+ ), oe = b(
123
+ () => Array.from(
124
+ { length: Math.floor(59 / U) + 1 },
125
+ (e, n) => n * U
126
+ ),
127
+ [U]
128
+ ), { disabledHours: re, disabledMinutes: ie, disabledSeconds: ae } = b(() => {
129
+ const e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), S = d ? (i) => i.getUTCHours() : (i) => i.getHours(), _ = d ? (i) => i.getUTCMinutes() : (i) => i.getMinutes(), L = d ? (i) => i.getUTCSeconds() : (i) => i.getSeconds();
130
+ if (r.minTime) {
131
+ const i = S(r.minTime), C = _(r.minTime), z = L(r.minTime);
132
+ for (let t = 0; t < i; t++) e.add(t);
133
+ if (h !== void 0 && h === i) {
116
134
  for (let t = 0; t < C; t++) n.add(t);
117
135
  if (x !== void 0 && x === C)
118
- for (let t = 0; t < y; t++) o.add(t);
136
+ for (let t = 0; t < z; t++) o.add(t);
119
137
  }
120
138
  }
121
- if (a.maxTime) {
122
- const r = v(a.maxTime), C = j(a.maxTime), y = R(a.maxTime);
123
- for (let t = r + 1; t < 24; t++) e.add(t);
124
- if (h !== void 0 && h === r) {
139
+ if (r.maxTime) {
140
+ const i = S(r.maxTime), C = _(r.maxTime), z = L(r.maxTime);
141
+ for (let t = i + 1; t < 24; t++) e.add(t);
142
+ if (h !== void 0 && h === i) {
125
143
  for (let t = C + 1; t < 60; t++) n.add(t);
126
144
  if (x !== void 0 && x === C)
127
- for (let t = y + 1; t < 60; t++) o.add(t);
145
+ for (let t = z + 1; t < 60; t++) o.add(t);
128
146
  }
129
147
  }
130
148
  return { disabledHours: e, disabledMinutes: n, disabledSeconds: o };
131
- }, [a.minTime, a.maxTime, h, x, d]);
132
- return /* @__PURE__ */ u("div", { className: z("flex flex-col gap-1.5", E), children: [
133
- T && /* @__PURE__ */ i(ne, { className: B, children: T }),
149
+ }, [r.minTime, r.maxTime, h, x, d]);
150
+ return /* @__PURE__ */ u("div", { className: V("flex flex-col gap-1.5", G), children: [
151
+ T && /* @__PURE__ */ a(de, { className: q, children: T }),
134
152
  /* @__PURE__ */ u(
135
- oe,
153
+ le,
136
154
  {
137
- open: m ? !1 : V,
138
- onOpenChange: (e) => !m && J(e),
155
+ open: m ? !1 : R,
156
+ onOpenChange: (e) => !m && $(e),
139
157
  modal: !0,
140
158
  children: [
141
- /* @__PURE__ */ i(re, { asChild: !0, children: /* @__PURE__ */ u(
159
+ /* @__PURE__ */ a(ce, { asChild: !0, children: /* @__PURE__ */ u(
142
160
  "div",
143
161
  {
144
- ref: K,
145
- id: q,
146
- "data-testid": F,
147
- className: z(
162
+ ref: ee,
163
+ id: Q,
164
+ "data-testid": Y,
165
+ className: V(
148
166
  f.input.base,
149
167
  f.radius.default,
150
168
  f.focusRingWithin,
151
169
  "flex w-fit min-w-[120px] cursor-pointer items-center justify-between gap-3 transition-colors",
152
- V && f.activeRing,
153
- de[W],
154
- le[X],
170
+ R && f.activeRing,
171
+ fe[J],
172
+ ge[K],
155
173
  m && "cursor-not-allowed opacity-50",
156
174
  N
157
175
  ),
158
176
  children: [
159
177
  /* @__PURE__ */ u("div", { className: "flex items-center gap-2 overflow-hidden", children: [
160
- /* @__PURE__ */ i(A, { name: "Clock", size: "xs", className: "opacity-50" }),
161
- O ? /* @__PURE__ */ i("span", { className: "text-d-foreground truncate font-medium tabular-nums", children: O }) : /* @__PURE__ */ i("span", { className: "text-d-muted-foreground whitespace-nowrap", children: w })
178
+ /* @__PURE__ */ a(B, { name: "Clock", size: "xs", className: "opacity-50" }),
179
+ I ? /* @__PURE__ */ a("span", { className: "text-d-foreground truncate font-medium tabular-nums", children: I }) : /* @__PURE__ */ a("span", { className: "text-d-muted-foreground whitespace-nowrap", children: w })
162
180
  ] }),
163
181
  /* @__PURE__ */ u("div", { className: "text-d-muted-foreground/30 flex items-center gap-1.5", children: [
164
- c && s && /* @__PURE__ */ i(
182
+ c && s && /* @__PURE__ */ a(
165
183
  "div",
166
184
  {
167
185
  role: "button",
168
186
  className: "bg-d-accent hover:bg-d-accent/80 border-d-border flex cursor-pointer items-center justify-center rounded-full border p-1 transition-colors",
169
187
  onClick: (e) => {
170
- e.stopPropagation(), e.preventDefault(), P();
188
+ e.stopPropagation(), e.preventDefault(), A();
171
189
  },
172
190
  onMouseDown: (e) => e.preventDefault(),
173
191
  "aria-label": "Clear selection",
174
- children: /* @__PURE__ */ i(
175
- A,
192
+ children: /* @__PURE__ */ a(
193
+ B,
176
194
  {
177
195
  name: "X",
178
196
  size: "xs",
@@ -181,54 +199,54 @@ function ve(a) {
181
199
  )
182
200
  }
183
201
  ),
184
- d && /* @__PURE__ */ i("span", { className: "text-[10px] font-bold", children: "UTC" })
202
+ d && /* @__PURE__ */ a("span", { className: "text-[10px] font-bold", children: "UTC" })
185
203
  ] })
186
204
  ]
187
205
  }
188
206
  ) }),
189
- /* @__PURE__ */ u(ie, { className: "flex w-auto flex-col p-0", align: "start", children: [
207
+ /* @__PURE__ */ u(ue, { className: "flex w-auto flex-col p-0", align: "start", children: [
190
208
  /* @__PURE__ */ u("div", { className: "divide-d-border flex min-h-0 flex-1 items-start divide-x", children: [
191
- /* @__PURE__ */ i(
192
- k,
209
+ /* @__PURE__ */ a(
210
+ D,
193
211
  {
194
212
  type: "hour",
195
213
  value: h,
196
- options: Y,
197
- onChange: (e) => M("hour", e),
198
- disabledValues: ee,
214
+ options: se,
215
+ onChange: (e) => H("hour", e),
216
+ disabledValues: re,
199
217
  className: "flex max-h-64 flex-1"
200
218
  }
201
219
  ),
202
- /* @__PURE__ */ i(
203
- k,
220
+ /* @__PURE__ */ a(
221
+ D,
204
222
  {
205
223
  type: "minute",
206
224
  value: x,
207
- options: Z,
208
- onChange: (e) => M("minute", e),
209
- disabledValues: te,
225
+ options: ne,
226
+ onChange: (e) => H("minute", e),
227
+ disabledValues: ie,
210
228
  className: "flex max-h-64 flex-1"
211
229
  }
212
230
  ),
213
- H && /* @__PURE__ */ i(
214
- k,
231
+ M && /* @__PURE__ */ a(
232
+ D,
215
233
  {
216
234
  type: "second",
217
- value: Q,
218
- options: $,
219
- onChange: (e) => M("second", e),
220
- disabledValues: se,
235
+ value: te,
236
+ options: oe,
237
+ onChange: (e) => H("second", e),
238
+ disabledValues: ae,
221
239
  className: "flex max-h-64 flex-1"
222
240
  }
223
241
  )
224
242
  ] }),
225
- s && /* @__PURE__ */ i("div", { className: "border-d-border flex border-t p-1", children: /* @__PURE__ */ i(
226
- L,
243
+ s && /* @__PURE__ */ a("div", { className: "border-d-border flex border-t p-1", children: /* @__PURE__ */ a(
244
+ X,
227
245
  {
228
246
  size: "sm",
229
247
  variant: "ghost",
230
248
  className: "w-full",
231
- onClick: P,
249
+ onClick: A,
232
250
  children: "Clear"
233
251
  }
234
252
  ) })
@@ -239,6 +257,6 @@ function ve(a) {
239
257
  ] });
240
258
  }
241
259
  export {
242
- ve as AppTimePicker,
243
- k as TimePickerColumn
260
+ Ne as AppTimePicker,
261
+ D as TimePickerColumn
244
262
  };
@@ -1,11 +1,11 @@
1
1
  "use client";
2
- import { jsxs as d, jsx as e } from "react/jsx-runtime";
3
- import { cn as r } from "../../lib/utils.js";
4
- import { cva as k } from "../../node_modules/class-variance-authority/dist/index.js";
5
- import * as a from "react";
6
- import { Label as p } from "./label.js";
7
- import { Tooltip as z, TooltipTrigger as B, TooltipContent as C } from "./tooltip.js";
8
- const x = k(
2
+ import { jsxs as o, jsx as e } from "react/jsx-runtime";
3
+ import { cn as t } from "../../lib/utils.js";
4
+ import { cva as A } from "../../node_modules/class-variance-authority/dist/index.js";
5
+ import * as d from "react";
6
+ import { Label as g } from "./label.js";
7
+ import { Tooltip as B, TooltipTrigger as E, TooltipContent as L } from "./tooltip.js";
8
+ const v = A(
9
9
  "inline-flex items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-d-ring focus-visible:ring-offset-2",
10
10
  {
11
11
  variants: {
@@ -29,95 +29,76 @@ const x = k(
29
29
  }
30
30
  }
31
31
  );
32
- function E({
33
- content: o,
34
- children: n,
35
- label: t,
36
- labelClassName: i,
37
- header: f,
38
- variant: v = "secondary",
39
- triggerVariant: l = "default",
40
- size: u = "default",
41
- className: m,
42
- wrpClassName: g,
32
+ function D({
33
+ content: x,
34
+ children: s,
35
+ label: r,
36
+ labelClassName: a,
37
+ header: c,
38
+ variant: p = "secondary",
39
+ triggerVariant: f = "default",
40
+ size: l = "default",
41
+ className: u,
42
+ wrpClassName: m,
43
43
  contentClassName: h,
44
44
  side: b = "top",
45
45
  align: y = "center",
46
- sideOffset: T = 4,
47
- matchTriggerWidth: s = !1,
48
- delayDuration: N = 200,
46
+ sideOffset: N = 4,
47
+ matchTriggerWidth: i = !1,
48
+ delayDuration: T = 200,
49
49
  disabled: R = !1,
50
50
  asChild: j = !1
51
51
  }) {
52
- const [w, A] = a.useState(), c = a.useRef(null);
53
- return a.useEffect(() => {
54
- s && c.current && A(c.current.getBoundingClientRect().width);
55
- }, [s]), R ? /* @__PURE__ */ d("div", { className: r("flex flex-col gap-2", g), children: [
56
- t && /* @__PURE__ */ e(p, { className: i, children: t }),
52
+ const [w, z] = d.useState(), n = d.useRef(null);
53
+ return d.useEffect(() => {
54
+ i && n.current && z(n.current.getBoundingClientRect().width);
55
+ }, [i]), R ? /* @__PURE__ */ o("div", { className: t("flex flex-col gap-2", m), children: [
56
+ r && /* @__PURE__ */ e(g, { className: a, children: r }),
57
57
  /* @__PURE__ */ e(
58
58
  "div",
59
59
  {
60
- className: r(
61
- x({ variant: l, size: u }),
62
- m
60
+ className: t(
61
+ v({ variant: f, size: l }),
62
+ u
63
63
  ),
64
- children: n
64
+ children: s
65
65
  }
66
66
  )
67
- ] }) : /* @__PURE__ */ d("div", { className: r("flex flex-col gap-2", g), children: [
68
- t && /* @__PURE__ */ e(p, { className: i, children: t }),
69
- /* @__PURE__ */ d(z, { delayDuration: N, children: [
70
- /* @__PURE__ */ e(B, { asChild: j, children: /* @__PURE__ */ e(
67
+ ] }) : /* @__PURE__ */ o("div", { className: t("flex flex-col gap-2", m), children: [
68
+ r && /* @__PURE__ */ e(g, { className: a, children: r }),
69
+ /* @__PURE__ */ o(B, { delayDuration: T, children: [
70
+ /* @__PURE__ */ e(E, { asChild: j, children: /* @__PURE__ */ e(
71
71
  "div",
72
72
  {
73
- ref: c,
74
- className: r(
75
- x({ variant: l, size: u }),
76
- m
73
+ ref: n,
74
+ className: t(
75
+ v({ variant: f, size: l }),
76
+ u
77
77
  ),
78
- children: n
78
+ children: s
79
79
  }
80
80
  ) }),
81
- /* @__PURE__ */ d(
82
- C,
81
+ /* @__PURE__ */ o(
82
+ L,
83
83
  {
84
- variant: v,
84
+ variant: p,
85
85
  side: b,
86
86
  align: y,
87
- sideOffset: T,
88
- className: r(h),
87
+ sideOffset: N,
88
+ className: t(h),
89
89
  style: {
90
- width: s ? w : void 0
90
+ width: i ? w : void 0
91
91
  },
92
92
  children: [
93
- f && /* @__PURE__ */ e("div", { className: "border-d-border mb-2 border-b pb-2 font-semibold", children: f }),
94
- o
93
+ c && /* @__PURE__ */ e("div", { className: "border-d-border mb-2 border-b pb-2 font-semibold", children: c }),
94
+ x
95
95
  ]
96
96
  }
97
97
  )
98
98
  ] })
99
99
  ] });
100
100
  }
101
- function F({
102
- text: o,
103
- className: n,
104
- variant: t = "primary",
105
- truncate: i = !0
106
- }) {
107
- return /* @__PURE__ */ e(E, { content: o, variant: t, asChild: !0, children: /* @__PURE__ */ e(
108
- "span",
109
- {
110
- className: r(
111
- "text-d-secondary-foreground block w-full min-w-0",
112
- i && "truncate",
113
- n
114
- ),
115
- children: o
116
- }
117
- ) });
118
- }
119
101
  export {
120
- F as AppTextTooltip,
121
- E as AppTooltip,
122
- E as default
102
+ D as AppTooltip,
103
+ D as default
123
104
  };
@@ -5,7 +5,7 @@ import { cva as X } from "../../node_modules/class-variance-authority/dist/index
5
5
  import { motion as J } from "framer-motion";
6
6
  import { cn as l } from "../../lib/utils.js";
7
7
  import { Collapsible as _, CollapsibleTrigger as q, CollapsibleContent as G } from "./collapsible.js";
8
- import { FilePreview as H } from "./file-preview.js";
8
+ import { FilePreview as H } from "./file-preview/index.js";
9
9
  import { MarkdownRenderer as M } from "./markdown-renderer.js";
10
10
  import O from "../../node_modules/lucide-react/dist/esm/icons/x.js";
11
11
  import R from "../../node_modules/lucide-react/dist/esm/icons/check.js";