@fabio.caffarello/react-design-system 4.1.0 → 4.3.0

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 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,137 @@
1
+ "use client";
2
+ var S = Object.defineProperty, B = Object.defineProperties;
3
+ var D = Object.getOwnPropertyDescriptors;
4
+ var i = Object.getOwnPropertySymbols;
5
+ var p = Object.prototype.hasOwnProperty, b = Object.prototype.propertyIsEnumerable;
6
+ var g = (r, a, e) => a in r ? S(r, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[a] = e, f = (r, a) => {
7
+ for (var e in a || (a = {}))
8
+ p.call(a, e) && g(r, e, a[e]);
9
+ if (i)
10
+ for (var e of i(a))
11
+ b.call(a, e) && g(r, e, a[e]);
12
+ return r;
13
+ }, u = (r, a) => B(r, D(a));
14
+ var h = (r, a) => {
15
+ var e = {};
16
+ for (var s in r)
17
+ p.call(r, s) && a.indexOf(s) < 0 && (e[s] = r[s]);
18
+ if (r != null && i)
19
+ for (var s of i(r))
20
+ a.indexOf(s) < 0 && b.call(r, s) && (e[s] = r[s]);
21
+ return e;
22
+ };
23
+ import { jsxs as x, jsx as o, Fragment as j } from "react/jsx-runtime";
24
+ import { memo as C, forwardRef as R } from "react";
25
+ import { getRadiusClass as T } from "../../tokens/radius.js";
26
+ import { getSpacingClass as t } from "../../tokens/spacing.js";
27
+ import { getTypographyWeight as y, getTypographySize as d } from "../../tokens/typography.js";
28
+ import { cn as n } from "../../utils/cn.js";
29
+ import { cva as V } from "../../utils/cva.js";
30
+ const _ = V(
31
+ n("inline-flex", "items-center", "border", T("md")),
32
+ {
33
+ variants: {
34
+ tone: {
35
+ neutral: n(
36
+ "bg-surface-muted",
37
+ "text-fg-primary",
38
+ "border-line-default"
39
+ ),
40
+ success: n("bg-success-bg", "text-success-dark", "border-success"),
41
+ warning: n("bg-warning-bg", "text-warning-dark", "border-warning"),
42
+ error: n("bg-error-bg", "text-error-dark", "border-error"),
43
+ info: n("bg-info-bg", "text-info-dark", "border-info"),
44
+ primary: n(
45
+ "bg-surface-brand-subtle",
46
+ "text-fg-brand-emphasis",
47
+ "border-line-brand"
48
+ ),
49
+ secondary: n(
50
+ "bg-surface-secondary-subtle",
51
+ "text-fg-brand-secondary-emphasis",
52
+ "border-line-secondary"
53
+ )
54
+ },
55
+ size: {
56
+ sm: n(
57
+ t("1.5", "px"),
58
+ t("0.5", "py"),
59
+ t("0.5", "gap"),
60
+ "[&_svg]:size-3"
61
+ ),
62
+ md: n(
63
+ t("sm", "px"),
64
+ t("0.5", "py"),
65
+ t("xs", "gap"),
66
+ "[&_svg]:size-3.5"
67
+ )
68
+ }
69
+ },
70
+ defaultVariants: { tone: "neutral", size: "md" }
71
+ }
72
+ ), F = C(
73
+ R(function(W, v) {
74
+ var m = W, {
75
+ label: a,
76
+ source: e,
77
+ tone: s = "neutral",
78
+ size: l = "md",
79
+ icon: c,
80
+ className: N = ""
81
+ } = m, k = h(m, [
82
+ "label",
83
+ "source",
84
+ "tone",
85
+ "size",
86
+ "icon",
87
+ "className"
88
+ ]);
89
+ const w = e != null && e !== "", z = l === "sm" ? "caption" : "bodySmall";
90
+ return /* @__PURE__ */ x(
91
+ "span",
92
+ u(f({
93
+ ref: v,
94
+ className: n(_({ tone: s, size: l }), N)
95
+ }, k), {
96
+ children: [
97
+ c ? /* @__PURE__ */ o(
98
+ "span",
99
+ {
100
+ className: "inline-flex shrink-0 items-center",
101
+ "aria-hidden": "true",
102
+ children: c
103
+ }
104
+ ) : null,
105
+ /* @__PURE__ */ o(
106
+ "span",
107
+ {
108
+ className: n(
109
+ d(z),
110
+ y("label")
111
+ ),
112
+ children: a
113
+ }
114
+ ),
115
+ w ? /* @__PURE__ */ x(j, { children: [
116
+ /* @__PURE__ */ o("span", { "aria-hidden": "true", className: d("caption"), children: "·" }),
117
+ /* @__PURE__ */ o(
118
+ "span",
119
+ {
120
+ className: n(
121
+ d("caption"),
122
+ y("caption")
123
+ ),
124
+ children: e
125
+ }
126
+ )
127
+ ] }) : null
128
+ ]
129
+ })
130
+ );
131
+ })
132
+ );
133
+ F.displayName = "DataBadge";
134
+ export {
135
+ F as default
136
+ };
137
+ //# sourceMappingURL=DataBadge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataBadge.js","sources":["../../../../../src/ui/primitives/DataBadge/DataBadge.tsx"],"sourcesContent":["import { memo, forwardRef } from \"react\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\nimport { getRadiusClass } from \"../../tokens/radius\";\nimport { getSpacingClass } from \"../../tokens/spacing\";\nimport {\n getTypographySize,\n getTypographyWeight,\n} from \"../../tokens/typography\";\nimport { cn, cva } from \"../../utils\";\n\n/**\n * Semantic tone for a {@link DataBadge}. Mirrors the `Badge` vocabulary\n * (role, not tone) so the soft-wash color treatment is shared and already\n * AA-verified. Map a consumer's tone names onto these roles:\n * `default → neutral`, `destructive → error`, `brand → primary`,\n * `accent → info` (or `secondary`).\n */\nexport type DataBadgeTone =\n | \"neutral\"\n | \"success\"\n | \"warning\"\n | \"error\"\n | \"info\"\n | \"primary\"\n | \"secondary\";\n\nexport type DataBadgeSize = \"sm\" | \"md\";\n\nexport interface DataBadgeProps extends HTMLAttributes<HTMLSpanElement> {\n /** Primary datum — the value the badge is about (e.g. \"L2\", \"Aprovada\"). */\n label: ReactNode;\n /**\n * Provenance of the datum, rendered as a lesser-emphasis sub-label after\n * the label (e.g. \"Câmara\", \"Portal Transparência\"). Omitted when absent.\n */\n source?: ReactNode;\n /** Semantic tone (role-based color). Defaults to `neutral`. */\n tone?: DataBadgeTone;\n /** Optional decorative leading icon (rendered `aria-hidden`). */\n icon?: ReactNode;\n /** Size scale. Defaults to `md`. */\n size?: DataBadgeSize;\n}\n\n// Tone → soft-wash classes, mirroring Badge's already-AA-verified scale.\nconst dataBadgeVariants = cva(\n cn(\"inline-flex\", \"items-center\", \"border\", getRadiusClass(\"md\")),\n {\n variants: {\n tone: {\n neutral: cn(\n \"bg-surface-muted\",\n \"text-fg-primary\",\n \"border-line-default\",\n ),\n success: cn(\"bg-success-bg\", \"text-success-dark\", \"border-success\"),\n warning: cn(\"bg-warning-bg\", \"text-warning-dark\", \"border-warning\"),\n error: cn(\"bg-error-bg\", \"text-error-dark\", \"border-error\"),\n info: cn(\"bg-info-bg\", \"text-info-dark\", \"border-info\"),\n primary: cn(\n \"bg-surface-brand-subtle\",\n \"text-fg-brand-emphasis\",\n \"border-line-brand\",\n ),\n secondary: cn(\n \"bg-surface-secondary-subtle\",\n \"text-fg-brand-secondary-emphasis\",\n \"border-line-secondary\",\n ),\n },\n size: {\n sm: cn(\n getSpacingClass(\"1.5\", \"px\"),\n getSpacingClass(\"0.5\", \"py\"),\n getSpacingClass(\"0.5\", \"gap\"),\n \"[&_svg]:size-3\",\n ),\n md: cn(\n getSpacingClass(\"sm\", \"px\"),\n getSpacingClass(\"0.5\", \"py\"),\n getSpacingClass(\"xs\", \"gap\"),\n \"[&_svg]:size-3.5\",\n ),\n },\n },\n defaultVariants: { tone: \"neutral\", size: \"md\" },\n },\n);\n\n/**\n * DataBadge\n *\n * An inline metadata chip: a primary `label`, an optional lesser-emphasis\n * `source` sub-label (the datum's provenance), a semantic `tone`, and an\n * optional decorative `icon`. Built for transparency/data UIs where a value\n * must travel with where it came from (\"L2 · Portal Transparência\").\n *\n * Why a separate primitive and not `Badge`: `Badge` is a single-string\n * status label; `DataBadge` carries a value + its source as a structured\n * pair. The `source` is the differentiator — it has no slot in `Badge` /\n * `Chip` / `Info`.\n *\n * Accessibility: the visible text (label, then source) IS the accessible\n * name — the separator and any `icon` are `aria-hidden`. Hierarchy between\n * label and source is conveyed by size + weight, never by dropping the\n * source below its tone's AA-safe text color. The root is a plain inline\n * `<span>` with no live-region role (metadata is static, not announced);\n * pass `role` / `aria-label` via props if a grouping role is wanted.\n *\n * Server-safe: no hooks, no client APIs, no DOM handlers of its own — ships\n * from the `./server` entry.\n *\n * @example\n * ```tsx\n * <DataBadge label=\"L2\" source=\"Portal Transparência\" tone=\"warning\" />\n * <DataBadge label=\"Aprovada\" tone=\"success\" />\n * ```\n */\nconst DataBadge = memo(\n forwardRef<HTMLSpanElement, DataBadgeProps>(function DataBadge(\n {\n label,\n source,\n tone = \"neutral\",\n size = \"md\",\n icon,\n className = \"\",\n ...rest\n },\n ref,\n ) {\n const hasSource = source !== undefined && source !== null && source !== \"\";\n // Label is the larger/heavier tier; source is one size smaller and a\n // lighter weight. Both keep the tone's AA-safe text color — hierarchy\n // comes from size + weight, not from reducing contrast.\n const labelSize = size === \"sm\" ? \"caption\" : \"bodySmall\";\n\n return (\n <span\n ref={ref}\n className={cn(dataBadgeVariants({ tone, size }), className)}\n {...rest}\n >\n {icon ? (\n <span\n className=\"inline-flex shrink-0 items-center\"\n aria-hidden=\"true\"\n >\n {icon}\n </span>\n ) : null}\n <span\n className={cn(\n getTypographySize(labelSize),\n getTypographyWeight(\"label\"),\n )}\n >\n {label}\n </span>\n {hasSource ? (\n <>\n <span aria-hidden=\"true\" className={getTypographySize(\"caption\")}>\n ·\n </span>\n <span\n className={cn(\n getTypographySize(\"caption\"),\n getTypographyWeight(\"caption\"),\n )}\n >\n {source}\n </span>\n </>\n ) : null}\n </span>\n );\n }),\n);\n\nDataBadge.displayName = \"DataBadge\";\n\nexport default DataBadge;\n"],"names":["dataBadgeVariants","cva","cn","getRadiusClass","getSpacingClass","DataBadge","memo","forwardRef","_a","ref","_b","label","source","tone","size","icon","className","rest","__objRest","hasSource","labelSize","jsxs","__spreadProps","__spreadValues","jsx","getTypographySize","getTypographyWeight","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAMA,IAAoBC;AAAA,EACxBC,EAAG,eAAe,gBAAgB,UAAUC,EAAe,IAAI,CAAC;AAAA,EAChE;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,SAASD;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,SAASA,EAAG,iBAAiB,qBAAqB,gBAAgB;AAAA,QAClE,SAASA,EAAG,iBAAiB,qBAAqB,gBAAgB;AAAA,QAClE,OAAOA,EAAG,eAAe,mBAAmB,cAAc;AAAA,QAC1D,MAAMA,EAAG,cAAc,kBAAkB,aAAa;AAAA,QACtD,SAASA;AAAA,UACP;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,WAAWA;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MACF;AAAA,MAEF,MAAM;AAAA,QACJ,IAAIA;AAAA,UACFE,EAAgB,OAAO,IAAI;AAAA,UAC3BA,EAAgB,OAAO,IAAI;AAAA,UAC3BA,EAAgB,OAAO,KAAK;AAAA,UAC5B;AAAA,QAAA;AAAA,QAEF,IAAIF;AAAA,UACFE,EAAgB,MAAM,IAAI;AAAA,UAC1BA,EAAgB,OAAO,IAAI;AAAA,UAC3BA,EAAgB,MAAM,KAAK;AAAA,UAC3B;AAAA,QAAA;AAAA,MACF;AAAA,IACF;AAAA,IAEF,iBAAiB,EAAE,MAAM,WAAW,MAAM,KAAA;AAAA,EAAK;AAEnD,GA+BMC,IAAYC;AAAA,EAChBC,EAA4C,SAC1CC,GASAC,GACA;AAVA,QAAAC,IAAAF,GACE;AAAA,aAAAG;AAAA,MACA,QAAAC;AAAA,MACA,MAAAC,IAAO;AAAA,MACP,MAAAC,IAAO;AAAA,MACP,MAAAC;AAAA,MACA,WAAAC,IAAY;AAAA,QANdN,GAOKO,IAAAC,EAPLR,GAOK;AAAA,MANH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAMS,IAAoCP,KAAW,QAAQA,MAAW,IAIlEQ,IAAYN,MAAS,OAAO,YAAY;AAE9C,WACE,gBAAAO;AAAA,MAAC;AAAA,MAAAC,EAAAC,EAAA;AAAA,QACC,KAAAd;AAAA,QACA,WAAWP,EAAGF,EAAkB,EAAE,MAAAa,GAAM,MAAAC,EAAA,CAAM,GAAGE,CAAS;AAAA,SACtDC,IAHL;AAAA,QAKE,UAAA;AAAA,UAAAF,IACC,gBAAAS;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAU;AAAA,cACV,eAAY;AAAA,cAEX,UAAAT;AAAA,YAAA;AAAA,UAAA,IAED;AAAA,UACJ,gBAAAS;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWtB;AAAA,gBACTuB,EAAkBL,CAAS;AAAA,gBAC3BM,EAAoB,OAAO;AAAA,cAAA;AAAA,cAG5B,UAAAf;AAAA,YAAA;AAAA,UAAA;AAAA,UAEFQ,IACC,gBAAAE,EAAAM,GAAA,EACE,UAAA;AAAA,YAAA,gBAAAH,EAAC,UAAK,eAAY,QAAO,WAAWC,EAAkB,SAAS,GAAG,UAAA,KAElE;AAAA,YACA,gBAAAD;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAWtB;AAAA,kBACTuB,EAAkB,SAAS;AAAA,kBAC3BC,EAAoB,SAAS;AAAA,gBAAA;AAAA,gBAG9B,UAAAd;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,EAAA,CACF,IACE;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGV,CAAC;AACH;AAEAP,EAAU,cAAc;"}
@@ -1,82 +1,50 @@
1
1
  "use client";
2
- var ie = Object.defineProperty;
3
- var P = Object.getOwnPropertySymbols;
4
- var K = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable;
5
- var J = (r, t, e) => t in r ? ie(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, U = (r, t) => {
6
- for (var e in t || (t = {}))
7
- K.call(t, e) && J(r, e, t[e]);
8
- if (P)
9
- for (var e of P(t))
10
- Q.call(t, e) && J(r, e, t[e]);
11
- return r;
12
- };
13
- var Y = (r, t) => {
14
- var e = {};
15
- for (var s in r)
16
- K.call(r, s) && t.indexOf(s) < 0 && (e[s] = r[s]);
17
- if (r != null && P)
18
- for (var s of P(r))
19
- t.indexOf(s) < 0 && Q.call(r, s) && (e[s] = r[s]);
2
+ var K = Object.defineProperty;
3
+ var c = Object.getOwnPropertySymbols;
4
+ var S = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
5
+ var b = (e, s, t) => s in e ? K(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t, E = (e, s) => {
6
+ for (var t in s || (s = {}))
7
+ S.call(s, t) && b(e, t, s[t]);
8
+ if (c)
9
+ for (var t of c(s))
10
+ N.call(s, t) && b(e, t, s[t]);
20
11
  return e;
21
12
  };
22
- import { jsxs as F, jsx as n } from "react/jsx-runtime";
23
- import { memo as _, forwardRef as de, useId as ue, useMemo as o, useState as fe, useCallback as T } from "react";
24
- import { getTypographySize as j, getTypographyClasses as z } from "../../tokens/typography.js";
25
- import { getRadiusClass as pe } from "../../tokens/radius.js";
26
- import { getSpacingClass as l } from "../../tokens/spacing.js";
27
- import { X as me, EyeOff as be, Eye as ge } from "lucide-react";
28
- import { Button as Z } from "../Button/Button.js";
29
- import { cva as ve } from "../../utils/cva.js";
30
- import { cn as c } from "../../utils/cn.js";
31
- const he = _(function({
32
- error: t,
33
- success: e,
34
- helperText: s,
35
- errorId: i,
36
- helperId: d
37
- }) {
38
- const a = o(
39
- () => c(
40
- l("xs", "mt"),
41
- z("caption"),
42
- t && "text-fg-error",
43
- e && "text-fg-success",
44
- !t && !e && "text-fg-secondary"
45
- ),
46
- [t, e]
47
- ), v = o(
48
- () => s || (t ? "Error" : e ? "Success" : ""),
49
- [s, t, e]
50
- );
51
- return /* @__PURE__ */ n(
52
- "div",
53
- {
54
- id: i || d,
55
- className: a,
56
- role: t || e ? "alert" : void 0,
57
- children: v
58
- }
59
- );
60
- }), ye = _(
61
- de(function(xe, ee) {
62
- var O = xe, {
63
- id: t,
64
- label: e,
65
- error: s = !1,
66
- success: i = !1,
67
- helperText: d,
68
- size: a = "md",
69
- variant: v = "outlined",
70
- leftIcon: h,
71
- rightIcon: y,
72
- showClearButton: k = !1,
73
- onClear: C,
74
- className: H = "",
75
- disabled: m = !1,
13
+ var T = (e, s) => {
14
+ var t = {};
15
+ for (var a in e)
16
+ S.call(e, a) && s.indexOf(a) < 0 && (t[a] = e[a]);
17
+ if (e != null && c)
18
+ for (var a of c(e))
19
+ s.indexOf(a) < 0 && N.call(e, a) && (t[a] = e[a]);
20
+ return t;
21
+ };
22
+ import { jsxs as L, Fragment as M, jsx as o } from "react/jsx-runtime";
23
+ import { memo as Q, forwardRef as U, useId as W, useState as Y } from "react";
24
+ import { getSpacingClass as I } from "../../tokens/spacing.js";
25
+ import { X as Z, EyeOff as _, Eye as ee } from "lucide-react";
26
+ import { Button as j } from "../Button/Button.js";
27
+ import te from "./InputBase.js";
28
+ const se = Q(
29
+ U(function(ae, D) {
30
+ var y = ae, {
31
+ id: s,
32
+ label: t,
33
+ error: a = !1,
34
+ success: $ = !1,
35
+ helperText: B,
36
+ size: p = "md",
37
+ variant: C = "outlined",
38
+ leftIcon: O,
39
+ rightIcon: u,
40
+ showClearButton: R = !1,
41
+ onClear: g,
42
+ className: k = "",
43
+ disabled: v = !1,
76
44
  type: x = "text",
77
- value: b,
78
- onChange: w
79
- } = O, q = Y(O, [
45
+ value: r,
46
+ onChange: d
47
+ } = y, A = T(y, [
80
48
  "id",
81
49
  "label",
82
50
  "error",
@@ -94,258 +62,94 @@ const he = _(function({
94
62
  "value",
95
63
  "onChange"
96
64
  ]);
97
- const te = ue(), u = t || `input-${te}`, V = o(
98
- () => s ? `${u}-error` : void 0,
99
- [s, u]
100
- ), D = o(
101
- () => d ? `${u}-helper` : void 0,
102
- [d, u]
103
- ), [N, se] = fe(!1), f = o(() => x === "password", [x]), oe = o(
104
- () => f && N ? "text" : x,
105
- [f, N, x]
106
- ), I = o(
107
- () => s ? "error" : i ? "success" : "default",
108
- [s, i]
109
- ), L = o(
110
- () => b != null && b !== "",
111
- [b]
112
- ), S = o(
113
- () => k && L && !m,
114
- [k, L, m]
115
- ), M = o(() => "focus:border-line-focus", []), W = o(() => "focus:border-error", []), X = o(() => "focus:border-success", []), A = o(
116
- () => M.replace("focus:border-", "focus:ring-"),
117
- [M]
118
- ), $ = T(
119
- (p) => p === "error" ? W.replace("focus:border-", "focus:ring-") : X.replace("focus:border-", "focus:ring-"),
120
- [W, X]
121
- ), B = o(
122
- () => ve(
123
- // Base classes
124
- c(
125
- "w-full",
126
- pe("md"),
127
- "transition-colors",
128
- "focus:outline-none",
129
- "focus:ring-2",
130
- "focus:ring-offset-2",
131
- "disabled:opacity-50",
132
- "disabled:cursor-not-allowed"
133
- ),
134
- {
135
- variants: {
136
- variant: {
137
- default: c(
138
- "border-0",
139
- "border-b-2",
140
- "border-line-default",
141
- "focus:border-line-focus"
142
- ),
143
- outlined: c(
144
- "border",
145
- "border-line-default",
146
- "focus:border-line-focus"
147
- ),
148
- filled: c(
149
- "bg-surface-muted",
150
- "border-0",
151
- "focus:bg-surface-base",
152
- "focus:ring-2",
153
- A
154
- )
65
+ const q = W(), z = s || `input-${q}`, [f, F] = Y(!1), n = x === "password", H = n && f ? "text" : x, V = r != null && r !== "", m = R && V && !v, i = p === "sm" ? "h-4 w-4" : p === "lg" ? "h-5 w-5" : "h-4 w-4", X = (l) => {
66
+ var P;
67
+ if (l.stopPropagation(), g)
68
+ g();
69
+ else if (d) {
70
+ const h = (P = l.currentTarget.closest(".relative")) == null ? void 0 : P.querySelector("input");
71
+ if (h) {
72
+ const w = {
73
+ target: h,
74
+ currentTarget: h,
75
+ bubbles: !0,
76
+ cancelable: !0,
77
+ defaultPrevented: !1,
78
+ eventPhase: 2,
79
+ isTrusted: !1,
80
+ nativeEvent: new Event("change"),
81
+ preventDefault: () => {
155
82
  },
156
- size: {
157
- sm: c(
158
- "h-8",
159
- j("bodySmall"),
160
- l("md", "px")
161
- ),
162
- md: c(
163
- "h-10",
164
- j("body"),
165
- l("base", "px")
166
- ),
167
- lg: c(
168
- "h-12",
169
- j("bodyLarge"),
170
- l("lg", "px")
171
- )
83
+ stopPropagation: () => {
172
84
  },
173
- state: {
174
- default: "",
175
- error: c(
176
- "border-error",
177
- "focus:border-error",
178
- $("error")
179
- ),
180
- success: c(
181
- "border-success",
182
- "focus:border-success",
183
- $("success")
184
- )
185
- }
186
- },
187
- defaultVariants: {
188
- variant: "outlined",
189
- size: "md",
190
- state: "default"
191
- }
85
+ persist: () => {
86
+ },
87
+ timeStamp: Date.now()
88
+ };
89
+ Object.defineProperty(w.target, "value", {
90
+ value: "",
91
+ writable: !0
92
+ }), Object.defineProperty(w.currentTarget, "value", {
93
+ value: "",
94
+ writable: !0
95
+ }), d(w);
96
+ }
97
+ }
98
+ }, G = () => F((l) => !l), J = m || n || !!u ? /* @__PURE__ */ L(M, { children: [
99
+ m && /* @__PURE__ */ o(
100
+ j,
101
+ {
102
+ variant: "ghost",
103
+ size: "sm",
104
+ onClick: X,
105
+ className: `h-auto ${I("xs", "p")}`,
106
+ "aria-label": "Clear input",
107
+ children: /* @__PURE__ */ o(Z, { className: i })
192
108
  }
193
109
  ),
194
- [A, $]
195
- ), re = o(
196
- () => c(
197
- B({ variant: v, size: a, state: I }),
198
- // Icon padding - specific values for icon positioning.
199
- // `pl-9` / `pr-9` aren't on the spacing scale (no semantic
200
- // key for 36px); they stay raw until a future PR either
201
- // extends the scale or refactors the icon-padding contract.
202
- h && (a === "sm" ? "pl-9" : a === "lg" ? l("3xl", "pl") : l("2xl", "pl")),
203
- (y || S || f) && (a === "sm" ? "pr-9" : a === "lg" ? l("3xl", "pr") : l("2xl", "pr")),
204
- H
205
- ),
206
- [
207
- B,
208
- v,
209
- a,
210
- I,
211
- h,
212
- y,
213
- S,
214
- f,
215
- H
216
- ]
217
- ), ae = o(
218
- () => c(
219
- "block",
220
- z("label"),
221
- l("xs", "mb"),
222
- m && "opacity-50"
223
- ),
224
- [m]
225
- ), g = o(
226
- () => a === "sm" ? "h-4 w-4" : a === "lg" ? "h-5 w-5" : "h-4 w-4",
227
- [a]
228
- ), ne = o(
229
- () => a === "sm" ? "top-2" : a === "lg" ? "top-3.5" : "top-2.5",
230
- [a]
231
- ), le = T(
232
- (p) => {
233
- var G;
234
- if (p.stopPropagation(), C)
235
- C();
236
- else if (w) {
237
- const E = (G = p.currentTarget.closest(".relative")) == null ? void 0 : G.querySelector("input");
238
- if (E) {
239
- const R = {
240
- target: E,
241
- currentTarget: E,
242
- bubbles: !0,
243
- cancelable: !0,
244
- defaultPrevented: !1,
245
- eventPhase: 2,
246
- isTrusted: !1,
247
- nativeEvent: new Event("change"),
248
- preventDefault: () => {
249
- },
250
- stopPropagation: () => {
251
- },
252
- persist: () => {
253
- },
254
- timeStamp: Date.now()
255
- };
256
- Object.defineProperty(R.target, "value", {
257
- value: "",
258
- writable: !0
259
- }), Object.defineProperty(R.currentTarget, "value", {
260
- value: "",
261
- writable: !0
262
- }), w(R);
263
- }
110
+ n && /* @__PURE__ */ o(
111
+ j,
112
+ {
113
+ variant: "ghost",
114
+ size: "sm",
115
+ onClick: G,
116
+ className: `h-auto ${I("xs", "p")}`,
117
+ "aria-label": f ? "Hide password" : "Show password",
118
+ children: f ? /* @__PURE__ */ o(_, { className: i }) : /* @__PURE__ */ o(ee, { className: i })
264
119
  }
265
- },
266
- [C, w]
267
- ), ce = T(() => {
268
- se((p) => !p);
269
- }, []);
270
- return /* @__PURE__ */ F("div", { className: "w-full", children: [
271
- e && /* @__PURE__ */ n("label", { htmlFor: u, className: ae, children: e }),
272
- /* @__PURE__ */ F("div", { className: "relative", children: [
273
- h && /* @__PURE__ */ n(
274
- "div",
275
- {
276
- className: `absolute left-3 ${ne} text-fg-secondary opacity-60 pointer-events-none`,
277
- children: /* @__PURE__ */ n("div", { className: g, children: h })
278
- }
279
- ),
280
- /* @__PURE__ */ n(
281
- "input",
282
- U({
283
- id: u,
284
- ref: ee,
285
- type: oe,
286
- className: re,
287
- disabled: m,
288
- value: b,
289
- onChange: w,
290
- "aria-invalid": s,
291
- "aria-required": q.required,
292
- "aria-describedby": V || D,
293
- suppressHydrationWarning: !0
294
- }, q)
295
- ),
296
- /* @__PURE__ */ F(
297
- "div",
298
- {
299
- className: `absolute right-3 top-0 bottom-0 flex items-center ${l("xs", "gap")}`,
300
- children: [
301
- S && /* @__PURE__ */ n(
302
- Z,
303
- {
304
- variant: "ghost",
305
- size: "sm",
306
- onClick: le,
307
- className: `h-auto ${l("xs", "p")}`,
308
- "aria-label": "Clear input",
309
- children: /* @__PURE__ */ n(me, { className: g })
310
- }
311
- ),
312
- f && /* @__PURE__ */ n(
313
- Z,
314
- {
315
- variant: "ghost",
316
- size: "sm",
317
- onClick: ce,
318
- className: `h-auto ${l("xs", "p")}`,
319
- "aria-label": N ? "Hide password" : "Show password",
320
- children: N ? /* @__PURE__ */ n(be, { className: g }) : /* @__PURE__ */ n(ge, { className: g })
321
- }
322
- ),
323
- y && !S && !f && /* @__PURE__ */ n(
324
- "div",
325
- {
326
- className: `text-fg-secondary opacity-60 pointer-events-none ${g}`,
327
- children: y
328
- }
329
- )
330
- ]
331
- }
332
- )
333
- ] }),
334
- (s || i || d) && /* @__PURE__ */ n(
335
- he,
120
+ ),
121
+ u && !m && !n && /* @__PURE__ */ o(
122
+ "div",
336
123
  {
337
- error: s,
338
- success: i,
339
- helperText: d,
340
- errorId: V,
341
- helperId: D
124
+ className: `text-fg-secondary opacity-60 pointer-events-none ${i}`,
125
+ children: u
342
126
  }
343
127
  )
344
- ] });
128
+ ] }) : void 0;
129
+ return /* @__PURE__ */ o(
130
+ te,
131
+ E({
132
+ ref: D,
133
+ id: z,
134
+ label: t,
135
+ error: a,
136
+ success: $,
137
+ helperText: B,
138
+ size: p,
139
+ variant: C,
140
+ leftIcon: O,
141
+ rightSlot: J,
142
+ className: k,
143
+ disabled: v,
144
+ type: H,
145
+ value: r,
146
+ onChange: d
147
+ }, A)
148
+ );
345
149
  })
346
150
  );
347
- ye.displayName = "Input";
151
+ se.displayName = "Input";
348
152
  export {
349
- ye as default
153
+ se as default
350
154
  };
351
155
  //# sourceMappingURL=Input.js.map