laif-ds 0.2.52 → 0.2.53

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,98 +1,108 @@
1
1
  "use client";
2
- import { jsxs as c, jsx as r } from "react/jsx-runtime";
3
- import { Calendar as N } from "./calendar.js";
4
- import { Icon as k } from "./icon.js";
5
- import { Popover as I, PopoverTrigger as T, PopoverContent as v } from "./popover.js";
6
- import { designTokens as t } from "../../lib/design-tokens.js";
7
- import { cn as z } from "../../lib/utils.js";
8
- import * as b from "react";
9
- import { useEffect as E } from "react";
10
- import { it as R } from "../../node_modules/date-fns/locale/it.js";
2
+ import { jsxs as f, jsx as t } from "react/jsx-runtime";
3
+ import { Calendar as w } from "./calendar.js";
4
+ import { Icon as E } from "./icon.js";
5
+ import { Label as L } from "./label.js";
6
+ import { Popover as q, PopoverTrigger as A, PopoverContent as B } from "./popover.js";
7
+ import { designTokens as o } from "../../lib/design-tokens.js";
8
+ import { cn as P } from "../../lib/utils.js";
9
+ import * as c from "react";
10
+ import { useEffect as F } from "react";
11
+ import { it as G } from "../../node_modules/date-fns/locale/it.js";
11
12
  import { formatDate as d } from "../../node_modules/date-fns/format.js";
12
- import { isSameDay as q } from "../../node_modules/date-fns/isSameDay.js";
13
- function V({
13
+ import { isSameDay as H } from "../../node_modules/date-fns/isSameDay.js";
14
+ function v({
14
15
  value: e,
15
16
  onChange: p,
16
- placeholder: y = "Seleziona data",
17
- dateFormat: m = "dd/MM/yyyy",
18
- className: j,
19
- disabled: i = !1,
20
- size: n = "default",
21
- firstDate: a,
22
- lastDate: l,
23
- availableDates: u,
24
- locale: C = R,
25
- initialCalendarMonth: h,
26
- customCalendarProps: P
17
+ placeholder: I = "Seleziona data",
18
+ dateFormat: a = "dd/MM/yyyy",
19
+ className: M,
20
+ disabled: n = !1,
21
+ size: m = "default",
22
+ firstDate: l,
23
+ lastDate: u,
24
+ availableDates: h,
25
+ locale: N = G,
26
+ initialCalendarMonth: g,
27
+ customCalendarProps: j,
28
+ label: x,
29
+ wrpClassName: k
27
30
  }) {
28
- const [o, g] = b.useState(e), [S, x] = b.useState(
29
- h
30
- ), w = (s) => {
31
- g(s), s && x(s), p && p(s);
31
+ const [r, y] = c.useState(e), [O, C] = c.useState(
32
+ g
33
+ ), [S, R] = c.useState(!1), z = (s) => {
34
+ y(s), s && C(s), p && p(s);
32
35
  };
33
- let f = [];
34
- return a && f.push({ before: a }), l && f.push({ after: l }), u?.length && f.push(
35
- (s) => !u.some(
36
- (M) => q(M, s)
36
+ let i = [];
37
+ l && i.push({ before: l }), u && i.push({ after: u }), h?.length && i.push(
38
+ (s) => !h.some(
39
+ (T) => H(T, s)
37
40
  )
38
- ), i && (f = [!0]), E(() => {
39
- g(o), x(o || h);
40
- }, [o]), /* @__PURE__ */ c(I, { open: i ? !1 : void 0, children: [
41
- /* @__PURE__ */ r(T, { asChild: !0, children: /* @__PURE__ */ r(
42
- "div",
43
- {
44
- className: z(
45
- t.input.base,
46
- t.radius.default,
47
- t.text.base,
48
- t.interaction.disabled,
49
- "flex items-center justify-between px-3 py-2 font-normal whitespace-nowrap [&>span]:line-clamp-1",
50
- "focus-visible:ring-d-ring/50 focus-visible:border-d-ring outline-none focus-visible:ring-[3px]",
51
- "hover:border-d-ring cursor-pointer transition-colors",
52
- !o && "text-d-muted-foreground",
53
- i && "cursor-not-allowed opacity-50",
54
- n === "default" && t.sizes.default,
55
- n === "sm" && t.sizes.sm,
56
- n === "lg" && t.sizes.lg,
57
- j
58
- ),
59
- "aria-disabled": i,
60
- role: "button",
61
- tabIndex: i ? -1 : 0,
62
- onClick: i ? void 0 : () => {
63
- },
64
- children: /* @__PURE__ */ c("div", { className: "flex w-full items-center justify-between gap-2", children: [
65
- /* @__PURE__ */ r(
66
- k,
67
- {
68
- name: "Calendar",
69
- size: n === "default" ? "md" : n === "sm" ? "xs" : "sm"
70
- }
41
+ ), n && (i = [!0]), F(() => {
42
+ y(r), C(r || g);
43
+ }, [r]);
44
+ const b = c.useId();
45
+ return /* @__PURE__ */ f("div", { className: P("flex flex-col gap-1.5", k), children: [
46
+ x && /* @__PURE__ */ t(L, { htmlFor: b, children: x }),
47
+ /* @__PURE__ */ f(q, { open: n ? !1 : S, onOpenChange: R, children: [
48
+ /* @__PURE__ */ t(A, { asChild: !0, children: /* @__PURE__ */ f(
49
+ "div",
50
+ {
51
+ id: b,
52
+ className: P(
53
+ o.input.base,
54
+ o.radius.default,
55
+ o.text.base,
56
+ o.interaction.disabled,
57
+ "flex items-center gap-2 font-normal whitespace-nowrap [&>span]:line-clamp-1",
58
+ o.focusRing,
59
+ S && o.activeRing,
60
+ "hover:border-d-ring cursor-pointer transition-colors",
61
+ !r && "text-d-muted-foreground",
62
+ n && "cursor-not-allowed opacity-50",
63
+ m === "default" && o.sizes.default,
64
+ m === "sm" && o.sizes.sm,
65
+ m === "lg" && o.sizes.lg,
66
+ M
71
67
  ),
72
- e && typeof e == "object" && "from" in e ? /* @__PURE__ */ c("span", { children: [
73
- e.from && d(e.from, m),
74
- e.from && e.to && " - ",
75
- e.to && d(e.to, m)
76
- ] }) : o ? /* @__PURE__ */ r("span", { children: d(o, m) }) : /* @__PURE__ */ r("span", { className: "text-d-muted-foreground", children: y })
77
- ] })
78
- }
79
- ) }),
80
- /* @__PURE__ */ r(v, { className: "w-auto p-0", children: /* @__PURE__ */ r(
81
- N,
82
- {
83
- ...P || {
84
- mode: "single",
85
- selected: o,
86
- onSelect: w
87
- },
88
- autoFocus: !0,
89
- disabled: f,
90
- locale: C,
91
- defaultMonth: S
92
- }
93
- ) })
68
+ "aria-disabled": n,
69
+ role: "button",
70
+ tabIndex: n ? -1 : 0,
71
+ onClick: n ? void 0 : () => {
72
+ },
73
+ children: [
74
+ /* @__PURE__ */ t(
75
+ E,
76
+ {
77
+ name: "Calendar",
78
+ size: m === "lg" ? "sm" : "xs"
79
+ }
80
+ ),
81
+ /* @__PURE__ */ t("div", { children: e && typeof e == "object" && "from" in e ? /* @__PURE__ */ f("span", { children: [
82
+ e.from && d(e.from, a),
83
+ e.from && e.to && " - ",
84
+ e.to && d(e.to, a)
85
+ ] }) : r ? /* @__PURE__ */ t("span", { children: d(r, a) }) : /* @__PURE__ */ t("span", { className: "text-d-muted-foreground", children: I }) })
86
+ ]
87
+ }
88
+ ) }),
89
+ /* @__PURE__ */ t(B, { className: "w-auto p-0", children: /* @__PURE__ */ t(
90
+ w,
91
+ {
92
+ ...j || {
93
+ mode: "single",
94
+ selected: r,
95
+ onSelect: z
96
+ },
97
+ autoFocus: !0,
98
+ disabled: i,
99
+ locale: N,
100
+ defaultMonth: O
101
+ }
102
+ ) })
103
+ ] })
94
104
  ] });
95
105
  }
96
106
  export {
97
- V as DatePicker
107
+ v as DatePicker
98
108
  };
@@ -1,19 +1,18 @@
1
1
  "use client";
2
- import { jsxs as f, jsx as n } from "react/jsx-runtime";
2
+ import { jsxs as f, jsx as l } from "react/jsx-runtime";
3
3
  import { Label as se } from "./label.js";
4
4
  import { designTokens as o } from "../../lib/design-tokens.js";
5
- import { cn as l } from "../../lib/utils.js";
6
- import { cva as R } from "../../node_modules/class-variance-authority/dist/index.js";
5
+ import { cn as n } from "../../lib/utils.js";
6
+ import { cva as j } from "../../node_modules/class-variance-authority/dist/index.js";
7
7
  import * as a from "react";
8
8
  import { Icon as N } from "./icon.js";
9
9
  import { Typo as te } from "./typo.js";
10
- const ae = R(
11
- l(
10
+ const ae = j(
11
+ n(
12
12
  o.input.base,
13
13
  o.radius.default,
14
14
  "items-center gap-2 px-3",
15
- // Focus states using the standard ring token but adapted for focus-within
16
- "focus-within:ring-d-ring/50 focus-within:ring-[3px] focus-within:border-d-ring outline-none",
15
+ o.focusRingWithin,
17
16
  o.input.invalid
18
17
  ),
19
18
  {
@@ -28,8 +27,8 @@ const ae = R(
28
27
  size: "default"
29
28
  }
30
29
  }
31
- ), re = R(
32
- l(
30
+ ), re = j(
31
+ n(
33
32
  o.text.base,
34
33
  "shadow-none flex-1 min-w-0 bg-transparent outline-none border-0 p-0 overflow-hidden text-ellipsis",
35
34
  "file:text-d-foreground file:inline-flex file:border-0 file:bg-transparent file:text-sm file:font-medium",
@@ -43,7 +42,7 @@ const ae = R(
43
42
  size: {
44
43
  default: "file:h-7",
45
44
  sm: "text-xs file:h-6",
46
- lg: "text-lg file:h-8"
45
+ lg: "text-base file:h-8"
47
46
  }
48
47
  },
49
48
  defaultVariants: {
@@ -55,7 +54,7 @@ const ae = R(
55
54
  hide: "Nascondi password"
56
55
  }, fe = a.forwardRef(
57
56
  ({
58
- className: W,
57
+ className: A,
59
58
  type: p,
60
59
  label: T,
61
60
  labelClassName: D,
@@ -77,7 +76,7 @@ const ae = R(
77
76
  validityI18n: e,
78
77
  ...$
79
78
  }, J) => {
80
- const [u, K] = a.useState(!1), [h, k] = a.useState(!0), [Q, L] = a.useState(!1), [U, V] = a.useState(""), X = a.useId(), w = G ?? X, j = `${w}-validity`, x = a.useRef(null), b = p === "password", Y = b ? u ? "text" : "password" : p, A = F ?? (!h && Q ? !0 : void 0), Z = [H, B && j].filter(Boolean).join(" ").trim() || void 0;
79
+ const [u, K] = a.useState(!1), [h, k] = a.useState(!0), [Q, L] = a.useState(!1), [U, V] = a.useState(""), X = a.useId(), w = G ?? X, R = `${w}-validity`, x = a.useRef(null), b = p === "password", Y = b ? u ? "text" : "password" : p, W = F ?? (!h && Q ? !0 : void 0), Z = [H, B && R].filter(Boolean).join(" ").trim() || void 0;
81
80
  a.useImperativeHandle(J, () => x.current);
82
81
  const q = a.useCallback(
83
82
  (t) => {
@@ -128,39 +127,39 @@ const ae = R(
128
127
  },
129
128
  [z, c]
130
129
  );
131
- return /* @__PURE__ */ f("div", { className: l("flex flex-col gap-1.5", W), children: [
132
- T && /* @__PURE__ */ f(se, { htmlFor: w, className: l("gap-0.5", D), children: [
130
+ return /* @__PURE__ */ f("div", { className: n("flex flex-col gap-1.5", A), children: [
131
+ T && /* @__PURE__ */ f(se, { htmlFor: w, className: n("gap-0.5", D), children: [
133
132
  T,
134
- C && h && /* @__PURE__ */ n("div", { children: "*" }),
135
- !h && /* @__PURE__ */ n("div", { className: "text-d-destructive", children: "*" })
133
+ C && h && /* @__PURE__ */ l("div", { children: "*" }),
134
+ !h && /* @__PURE__ */ l("div", { className: "text-d-destructive", children: "*" })
136
135
  ] }),
137
136
  /* @__PURE__ */ f(
138
137
  "div",
139
138
  {
140
- className: l(
139
+ className: n(
141
140
  ae({ size: g }),
142
141
  d ? "cursor-not-allowed opacity-50" : "cursor-text"
143
142
  ),
144
- "aria-invalid": A,
143
+ "aria-invalid": W,
145
144
  onClick: q,
146
145
  children: [
147
146
  (v || S) && /* @__PURE__ */ f("div", { className: "text-d-muted-foreground flex shrink-0 items-center gap-2", children: [
148
- v && /* @__PURE__ */ n(N, { name: v, size: g === "lg" ? "sm" : "xs" }),
147
+ v && /* @__PURE__ */ l(N, { name: v, size: g === "lg" ? "sm" : "xs" }),
149
148
  S
150
149
  ] }),
151
- /* @__PURE__ */ n(
150
+ /* @__PURE__ */ l(
152
151
  "input",
153
152
  {
154
153
  id: w,
155
154
  type: Y,
156
155
  "data-slot": "input",
157
- className: l(re({ size: g })),
156
+ className: n(re({ size: g })),
158
157
  ref: x,
159
158
  disabled: d,
160
159
  onChange: y,
161
160
  onBlur: I,
162
161
  onInvalid: ee,
163
- "aria-invalid": A,
162
+ "aria-invalid": W,
164
163
  "aria-describedby": Z,
165
164
  required: C,
166
165
  step: p === "number" ? "any" : void 0,
@@ -174,7 +173,7 @@ const ae = R(
174
173
  onClick: (t) => {
175
174
  t.stopPropagation(), t.preventDefault(), K((s) => !s);
176
175
  },
177
- className: l(
176
+ className: n(
178
177
  "text-d-muted-foreground flex shrink-0 cursor-pointer items-center",
179
178
  d && "cursor-not-allowed"
180
179
  ),
@@ -184,31 +183,31 @@ const ae = R(
184
183
  title: u ? m.hide : m.show,
185
184
  disabled: d,
186
185
  children: [
187
- /* @__PURE__ */ n(
186
+ /* @__PURE__ */ l(
188
187
  N,
189
188
  {
190
189
  name: u ? "EyeOff" : "Eye",
191
190
  size: g === "lg" ? "sm" : "xs"
192
191
  }
193
192
  ),
194
- /* @__PURE__ */ n("span", { className: "sr-only", children: u ? m.hide : m.show })
193
+ /* @__PURE__ */ l("span", { className: "sr-only", children: u ? m.hide : m.show })
195
194
  ]
196
195
  }
197
196
  ) : (M || E) && /* @__PURE__ */ f("div", { className: "text-d-muted-foreground flex shrink-0 items-center gap-2", children: [
198
197
  E,
199
- M && /* @__PURE__ */ n(N, { name: M, size: g === "lg" ? "sm" : "xs" })
198
+ M && /* @__PURE__ */ l(N, { name: M, size: g === "lg" ? "sm" : "xs" })
200
199
  ] })
201
200
  ]
202
201
  }
203
202
  ),
204
- B && U.length > 0 && /* @__PURE__ */ n(
203
+ B && U.length > 0 && /* @__PURE__ */ l(
205
204
  te,
206
205
  {
207
206
  variant: "caption",
208
- id: j,
207
+ id: R,
209
208
  role: h ? "status" : "alert",
210
209
  "aria-live": "polite",
211
- className: l(
210
+ className: n(
212
211
  "max-w-full min-w-0 text-wrap",
213
212
  h ? "text-d-success" : "text-d-destructive"
214
213
  ),
package/dist/index.d.ts CHANGED
@@ -1421,7 +1421,7 @@ export declare interface DataTableState {
1421
1421
  computedSorting?: DataTableSorting;
1422
1422
  }
1423
1423
 
1424
- export declare function DatePicker({ value, onChange, placeholder, dateFormat, className, disabled, size, firstDate, lastDate, availableDates, locale, initialCalendarMonth, customCalendarProps, }: DatePickerProps): JSX.Element;
1424
+ export declare function DatePicker({ value, onChange, placeholder, dateFormat, className, disabled, size, firstDate, lastDate, availableDates, locale, initialCalendarMonth, customCalendarProps, label, wrpClassName, }: DatePickerProps): JSX.Element;
1425
1425
 
1426
1426
  export declare interface DatePickerProps {
1427
1427
  value?: Date;
@@ -1438,6 +1438,8 @@ export declare interface DatePickerProps {
1438
1438
  locale?: Partial<Locale>;
1439
1439
  initialCalendarMonth?: Date;
1440
1440
  customCalendarProps?: React_2.ComponentProps<typeof Calendar>;
1441
+ label?: string | React_2.ReactNode;
1442
+ wrpClassName?: string;
1441
1443
  }
1442
1444
 
1443
1445
  /**
@@ -2,6 +2,8 @@
2
2
  const e = {
3
3
  // Interaction states
4
4
  focusRing: "focus-visible:ring-d-ring/50 focus-visible:ring-[3px] focus-visible:border-d-ring outline-none transition-all duration-200",
5
+ focusRingWithin: "focus-within:ring-d-ring/50 focus-within:ring-[3px] focus-within:border-d-ring outline-none transition-all duration-200",
6
+ activeRing: "ring-d-ring/50 ring-[3px] border-d-ring",
5
7
  // Base shapes
6
8
  radius: {
7
9
  default: "rounded-md",
@@ -11,7 +13,7 @@ const e = {
11
13
  },
12
14
  // Input & Button heights/paddings
13
15
  sizes: {
14
- default: "h-9 px-3 py-2",
16
+ default: "h-9 px-3 py-2 text-sm",
15
17
  sm: "h-8 px-2.5 py-1.5 text-xs",
16
18
  lg: "h-10 px-4 py-2 text-base",
17
19
  icon: {