@alfadocs/ui-kit 0.18.1 → 0.19.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.
@@ -0,0 +1,396 @@
1
+ import { jsxs as W, jsx as V } from "react/jsx-runtime";
2
+ import { forwardRef as ie, useRef as K, useId as ue, useState as X, useMemo as Q, useEffect as oe, useCallback as Z } from "react";
3
+ import { useTranslation as se } from "react-i18next";
4
+ import { g as fe } from "./_commonjsHelpers-C6fGbg64.js";
5
+ import { T as ce } from "./text-input-CakysYnD.js";
6
+ import { u as de } from "./form-field-context-B3APVHKx.js";
7
+ import { c as me } from "./compose-refs-C0k0tdqF.js";
8
+ import { u as pe } from "./registry-C9nwlNyL.js";
9
+ import { C as ve } from "./circle-alert-ChA9opNA.js";
10
+ var j = { exports: {} }, A = { exports: {} }, G;
11
+ function z() {
12
+ return G || (G = 1, (function(i, t) {
13
+ Object.defineProperty(t, "__esModule", {
14
+ value: !0
15
+ }), t.default = f;
16
+ function f(o) {
17
+ if (o == null) throw new TypeError("Expected a string but received a ".concat(o));
18
+ if (o.constructor.name !== "String") throw new TypeError("Expected a string but received a ".concat(o.constructor.name));
19
+ }
20
+ i.exports = t.default, i.exports.default = t.default;
21
+ })(A, A.exports)), A.exports;
22
+ }
23
+ var M = { exports: {} }, J;
24
+ function _e() {
25
+ return J || (J = 1, (function(i, t) {
26
+ Object.defineProperty(t, "__esModule", {
27
+ value: !0
28
+ }), t.default = o;
29
+ function f(l) {
30
+ return Object.prototype.toString.call(l) === "[object RegExp]";
31
+ }
32
+ function o(l, u) {
33
+ for (var a = 0; a < u.length; a++) {
34
+ var r = u[a];
35
+ if (l === r || f(r) && r.test(l))
36
+ return !0;
37
+ }
38
+ return !1;
39
+ }
40
+ i.exports = t.default, i.exports.default = t.default;
41
+ })(M, M.exports)), M.exports;
42
+ }
43
+ var k = { exports: {} }, Y;
44
+ function ge() {
45
+ return Y || (Y = 1, (function(i, t) {
46
+ Object.defineProperty(t, "__esModule", {
47
+ value: !0
48
+ }), t.default = u;
49
+ var f = o(/* @__PURE__ */ z());
50
+ function o(a) {
51
+ return a && a.__esModule ? a : { default: a };
52
+ }
53
+ function l(a) {
54
+ "@babel/helpers - typeof";
55
+ return l = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(r) {
56
+ return typeof r;
57
+ } : function(r) {
58
+ return r && typeof Symbol == "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
59
+ }, l(a);
60
+ }
61
+ function u(a, r) {
62
+ (0, f.default)(a);
63
+ var e, p;
64
+ l(r) === "object" ? (e = r.min || 0, p = r.max) : (e = arguments[1], p = arguments[2]);
65
+ var _ = encodeURI(a).split(/%..|./).length - 1;
66
+ return _ >= e && (typeof p > "u" || _ <= p);
67
+ }
68
+ i.exports = t.default, i.exports.default = t.default;
69
+ })(k, k.exports)), k.exports;
70
+ }
71
+ var N = { exports: {} }, T = { exports: {} }, $;
72
+ function ae() {
73
+ return $ || ($ = 1, (function(i, t) {
74
+ Object.defineProperty(t, "__esModule", {
75
+ value: !0
76
+ }), t.default = o;
77
+ function f(l) {
78
+ "@babel/helpers - typeof";
79
+ return f = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(u) {
80
+ return typeof u;
81
+ } : function(u) {
82
+ return u && typeof Symbol == "function" && u.constructor === Symbol && u !== Symbol.prototype ? "symbol" : typeof u;
83
+ }, f(l);
84
+ }
85
+ function o() {
86
+ var l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, u = arguments.length > 1 ? arguments[1] : void 0;
87
+ (f(l) !== "object" || l === null) && (l = {});
88
+ for (var a in u)
89
+ typeof l[a] > "u" && (l[a] = u[a]);
90
+ return l;
91
+ }
92
+ i.exports = t.default, i.exports.default = t.default;
93
+ })(T, T.exports)), T.exports;
94
+ }
95
+ var ee;
96
+ function xe() {
97
+ return ee || (ee = 1, (function(i, t) {
98
+ Object.defineProperty(t, "__esModule", {
99
+ value: !0
100
+ }), t.default = a;
101
+ var f = l(/* @__PURE__ */ z()), o = l(/* @__PURE__ */ ae());
102
+ function l(r) {
103
+ return r && r.__esModule ? r : { default: r };
104
+ }
105
+ var u = {
106
+ require_tld: !0,
107
+ allow_underscores: !1,
108
+ allow_trailing_dot: !1,
109
+ allow_numeric_tld: !1,
110
+ allow_wildcard: !1,
111
+ ignore_max_length: !1
112
+ };
113
+ function a(r, e) {
114
+ (0, f.default)(r), e = (0, o.default)(e, u), e.allow_trailing_dot && r[r.length - 1] === "." && (r = r.substring(0, r.length - 1)), e.allow_wildcard === !0 && r.indexOf("*.") === 0 && (r = r.substring(2));
115
+ var p = r.split("."), _ = p[p.length - 1];
116
+ return e.require_tld && (p.length < 2 || !e.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(_) || /\s/.test(_)) || !e.allow_numeric_tld && /^\d+$/.test(_) ? !1 : p.every(function(s) {
117
+ return !(s.length > 63 && !e.ignore_max_length || !/^[a-z_\u00a1-\uffff0-9-]+$/i.test(s) || /[\uff01-\uff5e]/.test(s) || /^-|-$/.test(s) || !e.allow_underscores && /_/.test(s));
118
+ });
119
+ }
120
+ i.exports = t.default, i.exports.default = t.default;
121
+ })(N, N.exports)), N.exports;
122
+ }
123
+ var O = { exports: {} }, te;
124
+ function he() {
125
+ return te || (te = 1, (function(i, t) {
126
+ Object.defineProperty(t, "__esModule", {
127
+ value: !0
128
+ }), t.default = _;
129
+ var f = o(/* @__PURE__ */ z());
130
+ function o(s) {
131
+ return s && s.__esModule ? s : { default: s };
132
+ }
133
+ function l(s) {
134
+ "@babel/helpers - typeof";
135
+ return l = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(v) {
136
+ return typeof v;
137
+ } : function(v) {
138
+ return v && typeof Symbol == "function" && v.constructor === Symbol && v !== Symbol.prototype ? "symbol" : typeof v;
139
+ }, l(s);
140
+ }
141
+ var u = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])", a = "(".concat(u, "[.]){3}").concat(u), r = new RegExp("^".concat(a, "$")), e = "(?:[0-9a-fA-F]{1,4})", p = new RegExp("^(" + "(?:".concat(e, ":){7}(?:").concat(e, "|:)|") + "(?:".concat(e, ":){6}(?:").concat(a, "|:").concat(e, "|:)|") + "(?:".concat(e, ":){5}(?::").concat(a, "|(:").concat(e, "){1,2}|:)|") + "(?:".concat(e, ":){4}(?:(:").concat(e, "){0,1}:").concat(a, "|(:").concat(e, "){1,3}|:)|") + "(?:".concat(e, ":){3}(?:(:").concat(e, "){0,2}:").concat(a, "|(:").concat(e, "){1,4}|:)|") + "(?:".concat(e, ":){2}(?:(:").concat(e, "){0,3}:").concat(a, "|(:").concat(e, "){1,5}|:)|") + "(?:".concat(e, ":){1}(?:(:").concat(e, "){0,4}:").concat(a, "|(:").concat(e, "){1,6}|:)|") + "(?::((?::".concat(e, "){0,5}:").concat(a, "|(?::").concat(e, "){1,7}|:))") + ")(%[0-9a-zA-Z.]{1,})?$");
142
+ function _(s) {
143
+ var v = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
144
+ (0, f.default)(s);
145
+ var x = (l(v) === "object" ? v.version : arguments[1]) || "";
146
+ return x ? x.toString() === "4" ? r.test(s) : x.toString() === "6" ? p.test(s) : !1 : _(s, {
147
+ version: 4
148
+ }) || _(s, {
149
+ version: 6
150
+ });
151
+ }
152
+ i.exports = t.default, i.exports.default = t.default;
153
+ })(O, O.exports)), O.exports;
154
+ }
155
+ var re;
156
+ function ye() {
157
+ return re || (re = 1, (function(i, t) {
158
+ Object.defineProperty(t, "__esModule", {
159
+ value: !0
160
+ }), t.default = C;
161
+ var f = e(/* @__PURE__ */ z()), o = e(/* @__PURE__ */ _e()), l = e(/* @__PURE__ */ ge()), u = e(/* @__PURE__ */ xe()), a = e(/* @__PURE__ */ he()), r = e(/* @__PURE__ */ ae());
162
+ function e(d) {
163
+ return d && d.__esModule ? d : { default: d };
164
+ }
165
+ var p = {
166
+ allow_display_name: !1,
167
+ allow_underscores: !1,
168
+ require_display_name: !1,
169
+ allow_utf8_local_part: !0,
170
+ require_tld: !0,
171
+ blacklisted_chars: "",
172
+ ignore_max_length: !1,
173
+ host_blacklist: [],
174
+ host_whitelist: []
175
+ }, _ = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i, s = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i, v = /^[a-z\d]+$/, x = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i, L = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i, U = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i, I = 254;
176
+ function b(d) {
177
+ var n = d.replace(/^"(.+)"$/, "$1");
178
+ if (!n.trim())
179
+ return !1;
180
+ var y = /[\.";<>]/.test(n);
181
+ if (y) {
182
+ if (n === d)
183
+ return !1;
184
+ var h = n.split('"').length === n.split('\\"').length;
185
+ if (!h)
186
+ return !1;
187
+ }
188
+ return !0;
189
+ }
190
+ function C(d, n) {
191
+ if ((0, f.default)(d), n = (0, r.default)(n, p), n.require_display_name || n.allow_display_name) {
192
+ var y = d.match(_);
193
+ if (y) {
194
+ var h = y[1];
195
+ if (d = d.replace(h, "").replace(/(^<|>$)/g, ""), h.endsWith(" ") && (h = h.slice(0, -1)), !b(h))
196
+ return !1;
197
+ } else if (n.require_display_name)
198
+ return !1;
199
+ }
200
+ if (!n.ignore_max_length && d.length > I)
201
+ return !1;
202
+ var E = d.split("@"), g = E.pop(), F = g.toLowerCase();
203
+ if (n.host_blacklist.length > 0 && (0, o.default)(F, n.host_blacklist) || n.host_whitelist.length > 0 && !(0, o.default)(F, n.host_whitelist))
204
+ return !1;
205
+ var m = E.join("@");
206
+ if (n.domain_specific_validation && (F === "gmail.com" || F === "googlemail.com")) {
207
+ m = m.toLowerCase();
208
+ var R = m.split("+")[0];
209
+ if (!(0, l.default)(R.replace(/\./g, ""), {
210
+ min: 6,
211
+ max: 30
212
+ }))
213
+ return !1;
214
+ for (var D = R.split("."), w = 0; w < D.length; w++)
215
+ if (!v.test(D[w]))
216
+ return !1;
217
+ }
218
+ if (n.ignore_max_length === !1 && (!(0, l.default)(m, {
219
+ max: 64
220
+ }) || !(0, l.default)(g, {
221
+ max: 254
222
+ })))
223
+ return !1;
224
+ if (!(0, u.default)(g, {
225
+ require_tld: n.require_tld,
226
+ ignore_max_length: n.ignore_max_length,
227
+ allow_underscores: n.allow_underscores
228
+ })) {
229
+ if (!n.allow_ip_domain)
230
+ return !1;
231
+ if (!(0, a.default)(g)) {
232
+ if (!g.startsWith("[") || !g.endsWith("]"))
233
+ return !1;
234
+ var S = g.slice(1, -1);
235
+ if (S.length === 0 || !(0, a.default)(S))
236
+ return !1;
237
+ }
238
+ }
239
+ if (n.blacklisted_chars && m.search(new RegExp("[".concat(n.blacklisted_chars, "]+"), "g")) !== -1)
240
+ return !1;
241
+ if (m[0] === '"' && m[m.length - 1] === '"')
242
+ return m = m.slice(1, m.length - 1), n.allow_utf8_local_part ? U.test(m) : x.test(m);
243
+ for (var H = n.allow_utf8_local_part ? L : s, P = m.split("."), q = 0; q < P.length; q++)
244
+ if (!H.test(P[q]))
245
+ return !1;
246
+ return !0;
247
+ }
248
+ i.exports = t.default, i.exports.default = t.default;
249
+ })(j, j.exports)), j.exports;
250
+ }
251
+ var be = /* @__PURE__ */ ye();
252
+ const ne = /* @__PURE__ */ fe(be), Fe = {
253
+ id: "email-input",
254
+ capabilities: [],
255
+ state: {
256
+ value: {
257
+ type: "string",
258
+ descriptionKey: "ui.agent.emailInput.state.value",
259
+ description: "The current email address typed into the field.",
260
+ read: (i) => i.getValue()
261
+ },
262
+ isValid: {
263
+ type: "boolean",
264
+ descriptionKey: "ui.agent.emailInput.state.isValid",
265
+ description: "True when the value is non-empty AND parses as a valid email per RFC 5322.",
266
+ read: (i) => i.isValid()
267
+ }
268
+ },
269
+ actions: {},
270
+ domHooks: {
271
+ root: {
272
+ attr: "data-component",
273
+ value: "email-input",
274
+ description: 'Marks the EmailInput wrapper. The inline error element carries `role="alert"` when validation fails.'
275
+ },
276
+ instanceId: {
277
+ attr: "data-component-id",
278
+ sourceProp: "id",
279
+ description: "Sourced from the id prop, when provided."
280
+ }
281
+ }
282
+ };
283
+ function we(i) {
284
+ return i.length === 0 ? !0 : ne(i);
285
+ }
286
+ const Ee = ie(
287
+ ({
288
+ errorMessage: i,
289
+ onValidityChange: t,
290
+ disableBuiltInValidation: f = !1,
291
+ value: o,
292
+ defaultValue: l,
293
+ onChange: u,
294
+ onBlur: a,
295
+ id: r,
296
+ "aria-describedby": e,
297
+ ...p
298
+ }, _) => {
299
+ const { t: s } = se(), v = de(), x = K(null), L = me(_, x), U = ue(), I = v.errorId || U, b = o !== void 0, [C, d] = X(() => typeof o == "string" ? o : typeof l == "string" ? l : ""), n = b ? String(o) : C, [y, h] = X(
300
+ () => n.length > 0
301
+ ), E = Q(
302
+ () => we(n),
303
+ [n]
304
+ ), g = !f && y && n.length > 0 && !E, F = K(null);
305
+ oe(() => {
306
+ if (!y) return;
307
+ const c = n.length > 0 && E;
308
+ F.current !== c && (F.current = c, t == null || t(c));
309
+ }, [y, n, E, t]);
310
+ const m = Z(
311
+ (c) => {
312
+ b || d(c.target.value), u == null || u(c);
313
+ },
314
+ [b, u]
315
+ ), R = Z(
316
+ (c) => {
317
+ h(!0), a == null || a(c);
318
+ },
319
+ [a]
320
+ ), D = Q(
321
+ () => ({
322
+ getValue: () => {
323
+ var c;
324
+ return ((c = x.current) == null ? void 0 : c.value) ?? "";
325
+ },
326
+ isValid: () => {
327
+ var B;
328
+ const c = ((B = x.current) == null ? void 0 : B.value) ?? "";
329
+ return c.length > 0 && ne(c);
330
+ }
331
+ }),
332
+ []
333
+ );
334
+ pe(Fe, D, r);
335
+ const w = g && i !== null, S = v.describedBy || void 0, H = Q(() => {
336
+ const c = [
337
+ e,
338
+ S,
339
+ w ? I : null
340
+ ].filter(Boolean);
341
+ return c.length > 0 ? c.join(" ") : void 0;
342
+ }, [
343
+ e,
344
+ S,
345
+ w,
346
+ I
347
+ ]), P = g ? "error" : "default", q = g || v.invalid || void 0, le = i !== void 0 ? i : s("inputs.email.invalid", "Invalid email");
348
+ return /* @__PURE__ */ W(
349
+ "div",
350
+ {
351
+ "data-component": "email-input",
352
+ "data-component-id": r,
353
+ className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
354
+ children: [
355
+ /* @__PURE__ */ V(
356
+ ce,
357
+ {
358
+ ...p,
359
+ ref: L,
360
+ id: r,
361
+ type: "email",
362
+ inputMode: "email",
363
+ autoComplete: "email",
364
+ tone: P,
365
+ value: b ? n : void 0,
366
+ defaultValue: b ? void 0 : l,
367
+ onChange: m,
368
+ onBlur: R,
369
+ "aria-invalid": q,
370
+ "aria-describedby": H
371
+ }
372
+ ),
373
+ w ? /* @__PURE__ */ W(
374
+ "p",
375
+ {
376
+ id: I,
377
+ role: "alert",
378
+ "data-slot": "email-input-error",
379
+ className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] type-body-sm ds:text-destructive",
380
+ children: [
381
+ /* @__PURE__ */ V(ve, { "aria-hidden": "true", className: "ds:size-4 ds:shrink-0" }),
382
+ /* @__PURE__ */ V("span", { children: le })
383
+ ]
384
+ }
385
+ ) : null
386
+ ]
387
+ }
388
+ );
389
+ }
390
+ );
391
+ Ee.displayName = "EmailInput";
392
+ export {
393
+ Ee as E,
394
+ Fe as e
395
+ };
396
+ //# sourceMappingURL=email-input-DKN5JERd.js.map
@@ -76,9 +76,11 @@ const g = Z("desktop"), ns = C(
76
76
  "ds:min-h-16 ds:md:min-h-[76px]",
77
77
  "ds:bg-[var(--card)] ds:text-[var(--foreground)]",
78
78
  "ds:rounded-[var(--radius-lg)]",
79
- // `--card-border` is the kit's subtle surface-border token (Card uses
80
- // the same). Mirrors alfadocs.com's slate-200 pill border far closer
81
- // than `--border` (the heavier component-input outline).
79
+ // Surface-border hairline shared with `Card`. Tuned to ~14% black
80
+ // (light) / 16% white (dark) at the token level so the edge stays
81
+ // visible against tinted page backgrounds — see `--card-border` in
82
+ // `src/tokens/index.css`. Matches alfadocs.com's slate-200 reference
83
+ // pill border without introducing a pill-specific token.
82
84
  "ds:border ds:border-[color:var(--card-border)]",
83
85
  "ds:transition-colors ds:duration-[var(--animation-duration)]",
84
86
  "ds:motion-reduce:transition-none"
@@ -554,4 +556,4 @@ export {
554
556
  Cs as P,
555
557
  js as p
556
558
  };
557
- //# sourceMappingURL=public-header.agent-BIBQzkeV.js.map
559
+ //# sourceMappingURL=public-header.agent-BQ3r6Hgq.js.map