laif-ds 1.0.3 → 1.0.5

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,41 +1,42 @@
1
1
  "use client";
2
- import { jsxs as f, jsx as l } from "react/jsx-runtime";
3
- import { cva as j } from "../../node_modules/class-variance-authority/dist/index.js";
2
+ import { jsxs as u, jsx as o } from "react/jsx-runtime";
3
+ import { cva as G } from "../../node_modules/class-variance-authority/dist/index.js";
4
4
  import * as a from "react";
5
- import { designTokens as o } from "../design-tokens.js";
6
- import { Label as se } from "./label.js";
7
- import { cn as n } from "../../lib/utils.js";
8
- import { Icon as N } from "./icon.js";
9
- import { Typo as te } from "./typo.js";
10
- const ae = j(
11
- n(
12
- o.input.base,
13
- o.radius.default,
5
+ import { designTokens as i } from "../design-tokens.js";
6
+ import { Label as oe } from "./label.js";
7
+ import { cn as c } from "../../lib/utils.js";
8
+ import { Icon as k } from "./icon.js";
9
+ import { Typo as ie } from "./typo.js";
10
+ const le = G(
11
+ c(
12
+ i.input.base,
13
+ i.radius.default,
14
14
  "items-center gap-2 px-3",
15
- o.focusRingWithin,
16
- o.input.invalid
15
+ i.focusRingWithin,
16
+ i.input.invalid
17
17
  ),
18
18
  {
19
19
  variants: {
20
20
  size: {
21
- default: o.sizes.default,
22
- sm: o.sizes.sm,
23
- lg: o.sizes.lg
21
+ default: i.sizes.default,
22
+ sm: i.sizes.sm,
23
+ lg: i.sizes.lg
24
24
  }
25
25
  },
26
26
  defaultVariants: {
27
27
  size: "default"
28
28
  }
29
29
  }
30
- ), re = j(
31
- n(
32
- o.text.base,
30
+ ), ce = G(
31
+ c(
32
+ i.text.base,
33
33
  "shadow-none flex-1 min-w-0 bg-transparent outline-none border-0 p-0 overflow-hidden text-ellipsis",
34
34
  "file:text-d-foreground file:inline-flex file:border-0 file:bg-transparent file:text-sm file:font-medium",
35
- o.text.placeholder,
35
+ i.text.placeholder,
36
36
  "selection:bg-d-primary selection:text-d-primary-foreground",
37
- o.interaction.disabled,
38
- "[-webkit-autofill]:shadow-[0_0_0_1000px_transparent_inset] [-webkit-autofill]:[-webkit-text-fill-color:inherit]"
37
+ i.interaction.disabled,
38
+ "[-webkit-autofill]:shadow-[0_0_0_1000px_transparent_inset] [-webkit-autofill]:[-webkit-text-fill-color:inherit]",
39
+ "[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none"
39
40
  ),
40
41
  {
41
42
  variants: {
@@ -49,167 +50,197 @@ const ae = j(
49
50
  size: "default"
50
51
  }
51
52
  }
52
- ), m = {
53
+ ), x = {
53
54
  show: "Mostra password",
54
55
  hide: "Nascondi password"
55
- }, fe = a.forwardRef(
56
+ }, T = "Cancella", xe = a.forwardRef(
56
57
  ({
57
- className: A,
58
- type: p,
59
- label: T,
60
- labelClassName: D,
61
- id: G,
62
- iconLeft: v,
63
- iconRight: M,
64
- startContent: S,
65
- endContent: E,
66
- size: g,
67
- disabled: c,
68
- required: C,
69
- onBlur: O,
70
- onChange: _,
71
- onInvalid: z,
72
- "aria-invalid": F,
73
- "aria-describedby": H,
74
- showValidMessage: P = !1,
75
- showValidityMessage: B = !1,
76
- validityI18n: e,
77
- ...$
78
- }, J) => {
79
- const [d, 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 ? d ? "text" : "password" : p, W = F ?? (!h && Q ? !0 : void 0), Z = [H, B && R].filter(Boolean).join(" ").trim() || void 0;
80
- a.useImperativeHandle(J, () => x.current);
81
- const q = a.useCallback(
82
- (t) => {
83
- if (c) return;
84
- const s = t.target;
58
+ className: F,
59
+ type: d,
60
+ label: E,
61
+ labelClassName: X,
62
+ id: $,
63
+ iconLeft: M,
64
+ iconRight: V,
65
+ startContent: C,
66
+ endContent: L,
67
+ size: f,
68
+ disabled: l,
69
+ required: O,
70
+ onBlur: _,
71
+ onChange: z,
72
+ onInvalid: B,
73
+ "aria-invalid": J,
74
+ "aria-describedby": K,
75
+ showValidMessage: D = !1,
76
+ showValidityMessage: A = !1,
77
+ validityI18n: t,
78
+ ...m
79
+ }, Q) => {
80
+ const [p, Y] = a.useState(!1), [w, N] = a.useState(!0), [Z, R] = a.useState(!1), [U, S] = a.useState(""), q = a.useId(), b = $ ?? q, j = `${b}-validity`, h = a.useRef(null), v = d === "password", W = d === "search", [H, P] = a.useState(
81
+ () => String(m.value ?? m.defaultValue ?? "").length > 0
82
+ ), I = v ? p ? "text" : "password" : d, y = J ?? (!w && Z ? !0 : void 0), ee = [K, A && j].filter(Boolean).join(" ").trim() || void 0;
83
+ a.useImperativeHandle(Q, () => h.current);
84
+ const te = a.useCallback(
85
+ (e) => {
86
+ if (l) return;
87
+ const s = e.target;
85
88
  if (s.tagName === "INPUT" || s.tagName === "BUTTON") return;
86
- const r = x.current;
87
- r && (r.focus(), !b && p !== "file" && r.select());
89
+ const r = h.current;
90
+ r && (r.focus(), !v && d !== "file" && r.select());
88
91
  },
89
- [c, b, p]
90
- ), u = a.useCallback(
91
- (t) => {
92
- const s = t.validity, r = t.validationMessage !== "" ? t.validationMessage : "✓";
92
+ [l, v, d]
93
+ ), g = a.useCallback(
94
+ (e) => {
95
+ const s = e.validity, r = e.validationMessage !== "" ? e.validationMessage : "✓";
93
96
  if (s.valid)
94
97
  return {
95
98
  isValid: !0,
96
- message: P ? e?.valid ?? r : ""
99
+ message: D ? t?.valid ?? r : ""
97
100
  };
98
- if (!e)
101
+ if (!t)
99
102
  return { isValid: !1, message: r };
100
- let i = r;
101
- return s.valueMissing && e.valueMissing ? i = e.valueMissing : s.typeMismatch && e.typeMismatch ? i = e.typeMismatch : s.patternMismatch && e.patternMismatch ? i = e.patternMismatch : s.tooLong && e.tooLong ? i = e.tooLong : s.tooShort && e.tooShort ? i = e.tooShort : s.rangeUnderflow && e.rangeUnderflow ? i = e.rangeUnderflow : s.rangeOverflow && e.rangeOverflow ? i = e.rangeOverflow : s.badInput && e.badInput ? i = e.badInput : s.stepMismatch && e.stepMismatch ? i = e.stepMismatch : s.customError && e.customError && (i = e.customError), { isValid: !1, message: i };
103
+ let n = r;
104
+ return s.valueMissing && t.valueMissing ? n = t.valueMissing : s.typeMismatch && t.typeMismatch ? n = t.typeMismatch : s.patternMismatch && t.patternMismatch ? n = t.patternMismatch : s.tooLong && t.tooLong ? n = t.tooLong : s.tooShort && t.tooShort ? n = t.tooShort : s.rangeUnderflow && t.rangeUnderflow ? n = t.rangeUnderflow : s.rangeOverflow && t.rangeOverflow ? n = t.rangeOverflow : s.badInput && t.badInput ? n = t.badInput : s.stepMismatch && t.stepMismatch ? n = t.stepMismatch : s.customError && t.customError && (n = t.customError), { isValid: !1, message: n };
102
105
  },
103
- [P, e]
106
+ [D, t]
104
107
  );
105
108
  a.useEffect(() => {
106
- if (x.current) {
107
- const { isValid: t, message: s } = u(x.current);
108
- k(t), V(s);
109
+ if (h.current) {
110
+ const { isValid: e, message: s } = g(h.current);
111
+ N(e), S(s);
109
112
  }
110
- }, [u]);
111
- const y = a.useCallback(
112
- (t) => {
113
- L(!0);
114
- const { isValid: s, message: r } = u(t.currentTarget);
115
- k(s), V(r), _?.(t);
113
+ }, [g]);
114
+ const se = a.useCallback(
115
+ (e) => {
116
+ R(!0);
117
+ const { isValid: s, message: r } = g(e.currentTarget);
118
+ N(s), S(r), P(e.currentTarget.value.length > 0), z?.(e);
116
119
  },
117
- [_, u]
118
- ), I = a.useCallback(
119
- (t) => {
120
- L(!0), O?.(t);
120
+ [z, g]
121
+ );
122
+ a.useEffect(() => {
123
+ m.value !== void 0 && P(String(m.value).length > 0);
124
+ }, [m.value]);
125
+ const ae = a.useCallback(() => {
126
+ const e = h.current;
127
+ if (!e) return;
128
+ Object.getOwnPropertyDescriptor(
129
+ window.HTMLInputElement.prototype,
130
+ "value"
131
+ )?.set?.call(e, ""), e.dispatchEvent(new Event("input", { bubbles: !0 })), e.focus();
132
+ }, []), re = a.useCallback(
133
+ (e) => {
134
+ R(!0), _?.(e);
121
135
  },
122
- [O]
123
- ), ee = a.useCallback(
124
- (t) => {
125
- const { isValid: s, message: r } = u(t.currentTarget);
126
- k(s), V(r), z?.(t);
136
+ [_]
137
+ ), ne = a.useCallback(
138
+ (e) => {
139
+ const { isValid: s, message: r } = g(e.currentTarget);
140
+ N(s), S(r), B?.(e);
127
141
  },
128
- [z, u]
142
+ [B, g]
129
143
  );
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: [
132
- T,
133
- C && h && /* @__PURE__ */ l("div", { children: "*" }),
134
- !h && /* @__PURE__ */ l("div", { className: "text-d-destructive", children: "*" })
144
+ return /* @__PURE__ */ u("div", { className: c("flex flex-col gap-1.5", F), children: [
145
+ E && /* @__PURE__ */ u(oe, { htmlFor: b, className: c("gap-0.5", X), children: [
146
+ E,
147
+ O && w && /* @__PURE__ */ o("div", { children: "*" }),
148
+ !w && /* @__PURE__ */ o("div", { className: "text-d-destructive", children: "*" })
135
149
  ] }),
136
- /* @__PURE__ */ f(
150
+ /* @__PURE__ */ u(
137
151
  "div",
138
152
  {
139
- className: n(
140
- ae({ size: g }),
141
- c ? "cursor-not-allowed opacity-50" : "cursor-text"
153
+ className: c(
154
+ le({ size: f }),
155
+ l ? "cursor-not-allowed opacity-50" : "cursor-text"
142
156
  ),
143
- "aria-invalid": W,
144
- onClick: q,
157
+ "aria-invalid": y,
158
+ onClick: te,
145
159
  children: [
146
- (v || S) && /* @__PURE__ */ f("div", { className: "text-d-muted-foreground flex shrink-0 items-center gap-2", children: [
147
- v && /* @__PURE__ */ l(N, { name: v, size: g === "lg" ? "sm" : "xs" }),
148
- S
160
+ (M || C) && /* @__PURE__ */ u("div", { className: "text-d-muted-foreground flex shrink-0 items-center gap-2", children: [
161
+ M && /* @__PURE__ */ o(k, { name: M, size: f === "lg" ? "sm" : "xs" }),
162
+ C
149
163
  ] }),
150
- /* @__PURE__ */ l(
164
+ /* @__PURE__ */ o(
151
165
  "input",
152
166
  {
153
- id: w,
154
- type: Y,
167
+ id: b,
168
+ type: I,
155
169
  "data-slot": "input",
156
- className: n(re({ size: g })),
157
- ref: x,
158
- disabled: c,
159
- onChange: y,
160
- onBlur: I,
161
- onInvalid: ee,
162
- "aria-invalid": W,
163
- "aria-describedby": Z,
164
- required: C,
165
- step: p === "number" ? "any" : void 0,
166
- ...$
170
+ className: c(ce({ size: f })),
171
+ ref: h,
172
+ disabled: l,
173
+ onChange: se,
174
+ onBlur: re,
175
+ onInvalid: ne,
176
+ "aria-invalid": y,
177
+ "aria-describedby": ee,
178
+ required: O,
179
+ step: d === "number" ? "any" : void 0,
180
+ ...m
167
181
  }
168
182
  ),
169
- b ? /* @__PURE__ */ f(
183
+ v ? /* @__PURE__ */ u(
170
184
  "button",
171
185
  {
172
186
  type: "button",
173
- onClick: (t) => {
174
- t.stopPropagation(), t.preventDefault(), K((s) => !s);
187
+ onClick: (e) => {
188
+ e.stopPropagation(), e.preventDefault(), Y((s) => !s);
175
189
  },
176
- className: n(
190
+ className: c(
177
191
  "text-d-muted-foreground flex shrink-0 cursor-pointer items-center",
178
- c && "cursor-not-allowed"
192
+ l && "cursor-not-allowed"
179
193
  ),
180
- "aria-label": d ? m.hide : m.show,
181
- "aria-pressed": d,
182
- "aria-controls": w,
183
- title: d ? m.hide : m.show,
184
- disabled: c,
194
+ "aria-label": p ? x.hide : x.show,
195
+ "aria-pressed": p,
196
+ "aria-controls": b,
197
+ title: p ? x.hide : x.show,
198
+ disabled: l,
185
199
  children: [
186
- /* @__PURE__ */ l(
187
- N,
200
+ /* @__PURE__ */ o(
201
+ k,
188
202
  {
189
- name: d ? "EyeOff" : "Eye",
190
- size: g === "lg" ? "sm" : "xs"
203
+ name: p ? "EyeOff" : "Eye",
204
+ size: f === "lg" ? "sm" : "xs"
191
205
  }
192
206
  ),
193
- /* @__PURE__ */ l("span", { className: "sr-only", children: d ? m.hide : m.show })
207
+ /* @__PURE__ */ o("span", { className: "sr-only", children: p ? x.hide : x.show })
194
208
  ]
195
209
  }
196
- ) : (M || E) && /* @__PURE__ */ f("div", { className: "text-d-muted-foreground flex shrink-0 items-center gap-2", children: [
197
- E,
198
- M && /* @__PURE__ */ l(N, { name: M, size: g === "lg" ? "sm" : "xs" })
210
+ ) : (W && H && !l ? !0 : V || L) && /* @__PURE__ */ u("div", { className: "text-d-muted-foreground flex shrink-0 items-center gap-2", children: [
211
+ L,
212
+ W && H && !l && /* @__PURE__ */ u(
213
+ "button",
214
+ {
215
+ type: "button",
216
+ onClick: (e) => {
217
+ e.stopPropagation(), e.preventDefault(), ae();
218
+ },
219
+ onMouseDown: (e) => e.preventDefault(),
220
+ className: "text-d-muted-foreground flex shrink-0 cursor-pointer items-center",
221
+ "aria-label": T,
222
+ title: T,
223
+ children: [
224
+ /* @__PURE__ */ o(k, { name: "X", size: f === "lg" ? "sm" : "xs" }),
225
+ /* @__PURE__ */ o("span", { className: "sr-only", children: T })
226
+ ]
227
+ }
228
+ ),
229
+ V && /* @__PURE__ */ o(k, { name: V, size: f === "lg" ? "sm" : "xs" })
199
230
  ] })
200
231
  ]
201
232
  }
202
233
  ),
203
- B && U.length > 0 && /* @__PURE__ */ l(
204
- te,
234
+ A && U.length > 0 && /* @__PURE__ */ o(
235
+ ie,
205
236
  {
206
237
  variant: "caption",
207
- id: R,
208
- role: h ? "status" : "alert",
238
+ id: j,
239
+ role: w ? "status" : "alert",
209
240
  "aria-live": "polite",
210
- className: n(
241
+ className: c(
211
242
  "max-w-full min-w-0 text-wrap",
212
- h ? "text-d-success" : "text-d-destructive"
243
+ w ? "text-d-success" : "text-d-destructive"
213
244
  ),
214
245
  children: U
215
246
  }
@@ -218,6 +249,6 @@ const ae = j(
218
249
  }
219
250
  );
220
251
  export {
221
- fe as Input,
222
- re as inputVariants
252
+ xe as Input,
253
+ ce as inputVariants
223
254
  };
@@ -1,5 +1,14 @@
1
1
  /* This files contains everything that should be imported in the template */
2
2
 
3
+ /* A control that can be used right now: neither natively disabled nor marked
4
+ `data-disabled` (how Button flags a disabled `asChild` link). Gates hover/press feedback without `pointer-events: none`,
5
+ which would drop the `not-allowed` cursor and any tooltip explaining why.
6
+ `:where()` keeps specificity at zero so a consumer's `hover:` class still
7
+ wins. Declared here, not in index.css, because consumer apps compile the
8
+ laif-ds classes with their own Tailwind and only import this file.
9
+ Mirrored in tailwind.config.v3.js. */
10
+ @custom-variant interactive (&:where(:not(:disabled, [data-disabled])));
11
+
3
12
  @theme inline {
4
13
  --radius-d-sm: calc(var(--d-radius) - 4px);
5
14
  --radius-d-md: calc(var(--d-radius) - 2px);
package/dist/index.d.ts CHANGED
@@ -952,7 +952,7 @@ export declare function BreadcrumbPage({ className, ...props }: React_2.Componen
952
952
 
953
953
  export declare function BreadcrumbSeparator({ children, className, ...props }: React_2.ComponentProps<"li">): JSX.Element;
954
954
 
955
- export declare function Button({ className, variant, size, asChild, iconLeft, iconRight, isLoading, ...props }: ButtonProps): JSX.Element;
955
+ export declare function Button({ className, variant, size, asChild, iconLeft, iconRight, isLoading, disabled, onClick, ...props }: ButtonProps): JSX.Element;
956
956
 
957
957
  export declare interface ButtonProps extends React_2.ComponentProps<"button"> {
958
958
  variant?: ButtonVariant;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../_virtual/index5.js";
2
+ import e from "../../_virtual/index2.js";
3
3
  export {
4
4
  e as EventEmitter,
5
5
  e as default
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as x } from "../../_virtual/index7.js";
2
+ import { __module as x } from "../../_virtual/index6.js";
3
3
  var w;
4
4
  function O() {
5
5
  return w ? x.exports : (w = 1, (function(d) {
@@ -3,7 +3,7 @@ import { stringify as w } from "../../comma-separated-tokens/index.js";
3
3
  import { ok as u } from "../../devlop/lib/default.js";
4
4
  import { svg as m, html as C } from "../../property-information/index.js";
5
5
  import { stringify as N } from "../../space-separated-tokens/index.js";
6
- import S from "../../../_virtual/index3.js";
6
+ import S from "../../../_virtual/index5.js";
7
7
  import { whitespace as j } from "../../hast-util-whitespace/lib/index.js";
8
8
  import { name as x } from "../../estree-util-is-identifier-name/lib/index.js";
9
9
  import { VFileMessage as h } from "../../vfile-message/lib/index.js";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import e from "../../../../_virtual/index5.js";
2
+ import e from "../../../../_virtual/index2.js";
3
3
  var r = new e(), n = "recharts.syncEvent.tooltip";
4
4
  export {
5
5
  n as TOOLTIP_SYNC_EVENT,
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __exports as r } from "../../../_virtual/index6.js";
2
+ import { __exports as r } from "../../../_virtual/index7.js";
3
3
  import { __require as c } from "../../inline-style-parser/index.js";
4
4
  var f;
5
5
  function j() {
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { __module as e } from "../../../_virtual/index2.js";
2
+ import { __module as e } from "../../../_virtual/index3.js";
3
3
  import { __require as i } from "../cjs/use-sync-external-store-shim.production.js";
4
4
  import { __require as o } from "../cjs/use-sync-external-store-shim.development.js";
5
5
  var r;