fiboui 2.4.4 → 2.6.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,1112 +0,0 @@
1
- "use client";
2
- var H = Object.defineProperty;
3
- var O = (c, l, e) => l in c ? H(c, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[l] = e;
4
- var r = (c, l, e) => O(c, typeof l != "symbol" ? l + "" : l, e);
5
- import t, { useState as M, useEffect as j, useRef as F } from "react";
6
- import { D as $, E as D, S as P } from "./builder-B5cebEWZ.js";
7
- import { t as L } from "./bundle-mjs-wppB-TKB.js";
8
- const q = t.memo((c) => {
9
- const {
10
- text: l,
11
- variant: e,
12
- size: o,
13
- onPress: a,
14
- onHover: s,
15
- disabled: d,
16
- icon: u,
17
- shape: p,
18
- shadow: k,
19
- tone: v,
20
- motion: x,
21
- expand: E,
22
- className: _,
23
- style: y,
24
- ...f
25
- } = c, g = {
26
- xs: "px-[21px] py-[8px] text-[10px] gap-[6px] h-auto tracking-[0.12em] font-normal",
27
- sm: "px-[14px] py-[6px] text-[13px] gap-[6px] h-[32px]",
28
- md: "px-[22px] py-[10px] text-[15px] gap-[8px] h-[44px]",
29
- lg: "px-[32px] py-[16px] text-[17px] gap-[10px] h-[56px]"
30
- };
31
- let S = "rounded-[14px]";
32
- p === "pill" ? S = "rounded-full" : p === "square" ? S = "rounded-[12px]" : p === "rect" ? S = "rounded-[2px]" : p === "rounded" ? S = "rounded-[8px]" : p === "sharp" && (S = "rounded-none");
33
- const m = v === "inverse";
34
- let b = "";
35
- e === "ghost" ? b = m ? "bg-transparent text-white shadow-none border border-transparent" : "bg-transparent text-[var(--fibo-on-surface)] shadow-none border border-transparent hover:bg-[color-mix(in_srgb,var(--fibo-on-surface)_8%,transparent)]" : e === "text" ? b = m ? "bg-transparent text-white shadow-none border-none px-2" : "bg-transparent text-[var(--fibo-on-surface)] shadow-none border-none px-2 hover:bg-[color-mix(in_srgb,var(--fibo-on-surface)_8%,transparent)]" : e === "soft" ? b = "bg-[color-mix(in_srgb,var(--fibo-primary)_12%,transparent)] text-[var(--fibo-primary)] shadow-none border-none hover:bg-[color-mix(in_srgb,var(--fibo-primary)_18%,transparent)]" : e === "outline" || e === "outlined" ? b = m ? "bg-black text-white shadow-none border border-[#3b3b3b]" : "bg-transparent border-[1.5px] border-[var(--fibo-outline,rgba(0,0,0,0.12))] text-[var(--fibo-on-surface)] shadow-none hover:bg-[color-mix(in_srgb,var(--fibo-on-surface)_6%,transparent)]" : e === "solid" ? b = m ? "bg-[#f2f2f2] text-black shadow-none border border-[#f2f2f2]" : "bg-[var(--fibo-primary)] text-[var(--fibo-on-primary)] shadow-none border-none hover:opacity-90" : e === "filled" || e === "primary" ? b = "bg-[var(--fibo-primary)] text-[var(--fibo-on-primary)] shadow-sm border-none hover:opacity-90 active:opacity-100" : e === "elevated" ? b = "bg-[var(--fibo-surface)] text-[var(--fibo-primary)] shadow-md border-none hover:shadow-lg" : e === "tonal" ? b = "bg-[var(--fibo-secondary-container)] text-[var(--fibo-on-secondary-container)] shadow-sm border-none" : e === "raw" && (b = "bg-transparent border-none shadow-none p-0 h-auto gap-0 text-inherit font-inherit hover:bg-transparent", S = ""), k === "soft" && e !== "raw" && (b += " shadow-[0_8px_20px_-6px_rgba(59,130,246,0.4)]");
36
- const w = y || {}, I = w.padding !== void 0 || w.paddingTop !== void 0 || w.paddingBottom !== void 0 || w.paddingLeft !== void 0 || w.paddingRight !== void 0 || w.fontSize !== void 0 || w.height !== void 0, C = w.borderRadius !== void 0, z = w.fontWeight !== void 0 || o === "xs" || m, n = e === "raw" || x === "none" || m || o === "xs", h = L(
37
- "fibo-button",
38
- "inline-flex items-center justify-center whitespace-nowrap",
39
- z ? "" : "font-semibold",
40
- // Resting scale(1) so active:scale eases instead of snapping from none.
41
- n ? "" : "scale-100 active:scale-[0.96] transform transition-transform duration-200 ease-out",
42
- d ? "cursor-not-allowed opacity-60" : "cursor-pointer",
43
- e === "raw" || I ? "" : g[o],
44
- e === "raw" || C ? "" : S,
45
- E ? "flex-1 w-full" : "",
46
- `fibo-button-${e}`,
47
- b,
48
- _
49
- ), A = [];
50
- return u && A.push(u), l && A.push(l), c.children && (Array.isArray(c.children) ? A.push(...c.children) : A.push(c.children)), t.createElement(
51
- "button",
52
- {
53
- className: h,
54
- onMouseEnter: s ? () => {
55
- d || s();
56
- } : f.onMouseEnter,
57
- onClick: (T) => {
58
- d || (!n && document.documentElement.classList.contains("fibo-theme-material") && e !== "raw" && import("./effects-CnevV566.js").then(({ createRipple: i }) => {
59
- i(T, T.currentTarget);
60
- }), a == null || a());
61
- },
62
- disabled: d,
63
- ...f,
64
- type: f.type ?? "button",
65
- style: w
66
- },
67
- ...A
68
- );
69
- });
70
- class V extends D {
71
- constructor(e = "") {
72
- super();
73
- r(this, "_text", "");
74
- r(this, "_variant", "elevated");
75
- r(this, "_size", "md");
76
- r(this, "_onPress");
77
- r(this, "_onHover");
78
- r(this, "_disabled", !1);
79
- r(this, "_icon");
80
- r(this, "_shape", "default");
81
- r(this, "_shadow", "none");
82
- r(this, "_tone", "default");
83
- r(this, "_motion", "default");
84
- r(this, "_expand", !1);
85
- this.text(e);
86
- }
87
- text(e) {
88
- return this._text = e, typeof e == "function" && this.observer(), this;
89
- }
90
- variant(e) {
91
- return this._variant = e, this;
92
- }
93
- clean() {
94
- return this._variant = "raw", this;
95
- }
96
- size(e) {
97
- return this._size = e, this;
98
- }
99
- onPress(e) {
100
- return this._onPress = e, this;
101
- }
102
- onHover(e) {
103
- return this._onHover = e, this;
104
- }
105
- disabled(e = !0) {
106
- return this._disabled = e, this;
107
- }
108
- icon(e) {
109
- return this._icon = e, this;
110
- }
111
- shape(e) {
112
- return this._shape = e, this;
113
- }
114
- shadow(e) {
115
- return this._shadow = e, this;
116
- }
117
- tone(e) {
118
- return this._tone = e, this;
119
- }
120
- motion(e) {
121
- return this._motion = e, this;
122
- }
123
- expand(e = !0) {
124
- return this._expand = e, this;
125
- }
126
- build() {
127
- const e = this.getClassName(), a = {
128
- text: typeof this._text == "function" ? this._text() : this._text,
129
- variant: this._variant,
130
- size: this._size,
131
- onPress: this._onPress,
132
- onHover: this._onHover,
133
- disabled: this._disabled,
134
- icon: this._icon,
135
- shape: this._shape,
136
- shadow: this._shadow,
137
- tone: this._tone,
138
- motion: this._motion,
139
- expand: this._expand,
140
- className: e,
141
- style: this.getStyle(),
142
- children: this.processChildren(),
143
- ...this._props
144
- };
145
- return t.createElement(q, a);
146
- }
147
- }
148
- const de = $(V), W = (c, l) => {
149
- let e = 0;
150
- const o = c.replace(/\D/g, "").split("");
151
- let a = "";
152
- for (let s = 0; s < l.length && !(e >= o.length); s++)
153
- l[s] === "9" ? a += o[e++] : a += l[s];
154
- return a;
155
- }, K = t.memo((c) => {
156
- const l = t.useId(), e = c.id || l, [o, a] = t.useState(!1), {
157
- containerClass: s,
158
- containerStyle: d,
159
- label: u,
160
- error: p,
161
- mask: k,
162
- type: v,
163
- value: x,
164
- onChange: E,
165
- leadingIcon: _,
166
- trailingIcon: y,
167
- ...f
168
- } = c, g = x instanceof P, [S, m] = M(g ? x.value : x);
169
- j(() => {
170
- if (g)
171
- return x.subscribe((h) => {
172
- m(h);
173
- });
174
- m(x);
175
- }, [x, g]);
176
- const b = v === "password", w = b && o ? "text" : v, I = (n) => {
177
- let h = n.target.value;
178
- if (k) {
179
- h = W(h, k);
180
- const A = {
181
- ...n,
182
- target: {
183
- ...n.target,
184
- value: h
185
- }
186
- };
187
- g && (x.value = h), E == null || E(A);
188
- } else
189
- g && (x.value = h), E == null || E(n);
190
- }, C = _ ? "2.75rem" : "1rem", z = y || b ? "2.75rem" : "1rem";
191
- return t.createElement(
192
- "div",
193
- { className: s, style: d },
194
- t.createElement("div", { className: "relative w-full h-full flex items-center" }, [
195
- _ && t.createElement(
196
- "div",
197
- {
198
- key: "leading-icon",
199
- className: "absolute left-3 top-1/2 transform -translate-y-1/2 flex items-center justify-center pointer-events-none z-10"
200
- },
201
- _
202
- ),
203
- t.createElement("input", {
204
- key: "input",
205
- id: e,
206
- className: "fibo-textfield-input w-full h-full bg-transparent outline-none py-2.5 text-sm",
207
- style: { paddingLeft: C, paddingRight: z },
208
- type: w,
209
- onChange: I,
210
- value: S,
211
- ...f
212
- }),
213
- u && t.createElement(
214
- "label",
215
- {
216
- key: "label",
217
- htmlFor: e,
218
- className: "fibo-textfield-label",
219
- style: { left: _ ? "2.75rem" : "1rem" }
220
- },
221
- u
222
- ),
223
- (y || b) && t.createElement(
224
- "div",
225
- {
226
- key: "trailing-icon",
227
- className: "absolute right-3 top-1/2 transform -translate-y-1/2 flex items-center justify-center z-10"
228
- },
229
- b ? t.createElement(
230
- "button",
231
- {
232
- type: "button",
233
- className: "text-gray-400 hover:text-gray-600 focus:outline-none",
234
- onClick: () => a(!o),
235
- tabIndex: -1
236
- },
237
- o ? t.createElement(
238
- "svg",
239
- { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" },
240
- t.createElement("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
241
- t.createElement("line", { x1: 1, y1: 1, x2: 23, y2: 23 })
242
- ) : t.createElement(
243
- "svg",
244
- { width: 16, height: 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" },
245
- t.createElement("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
246
- t.createElement("circle", { cx: 12, cy: 12, r: 3 })
247
- )
248
- ) : y
249
- )
250
- ]),
251
- p && t.createElement(
252
- "span",
253
- { className: "text-[var(--fibo-error)] text-xs mt-1 ml-1" },
254
- p
255
- )
256
- );
257
- });
258
- class G extends D {
259
- constructor(e = "") {
260
- super();
261
- r(this, "_value", "");
262
- r(this, "_label", "");
263
- r(this, "_placeholder", "");
264
- r(this, "_type", "text");
265
- r(this, "_disabled", !1);
266
- r(this, "_error");
267
- r(this, "_mask");
268
- r(this, "_onChange");
269
- r(this, "_leadingIcon");
270
- r(this, "_trailingIcon");
271
- r(this, "_variant", "filled");
272
- this._value = e;
273
- }
274
- value(e) {
275
- return this._value = e, this;
276
- }
277
- label(e) {
278
- return this._label = e, this;
279
- }
280
- placeholder(e) {
281
- return this._placeholder = e, this;
282
- }
283
- type(e) {
284
- return this._type = e, this;
285
- }
286
- mask(e) {
287
- return this._mask = e, this;
288
- }
289
- disabled(e = !0) {
290
- return this._disabled = e, this;
291
- }
292
- error(e) {
293
- return this._error = e, this;
294
- }
295
- onChange(e) {
296
- return this._onChange = e, this;
297
- }
298
- leadingIcon(e) {
299
- return this._leadingIcon = e, this;
300
- }
301
- trailingIcon(e) {
302
- return this._trailingIcon = e, this;
303
- }
304
- variant(e) {
305
- return this._variant = e, this;
306
- }
307
- build() {
308
- let e = "fibo-textfield-container w-full h-14 relative";
309
- this._variant === "outlined" ? e += " border border-[var(--fibo-outline)] rounded-[4px] bg-transparent" : e += " bg-[var(--fibo-surface-variant)] rounded-t-[4px] border-b border-[var(--fibo-outline)]";
310
- const a = {
311
- containerClass: L(e, ...this._classNames),
312
- containerStyle: this.getStyle(),
313
- label: this._label,
314
- error: this._error,
315
- leadingIcon: this._leadingIcon,
316
- trailingIcon: this._trailingIcon,
317
- value: this._value,
318
- placeholder: this._placeholder || " ",
319
- type: this._type,
320
- mask: this._mask,
321
- disabled: this._disabled,
322
- onChange: (s) => {
323
- var d;
324
- (d = this._onChange) == null || d.call(this, s.target.value);
325
- },
326
- ...this._props
327
- };
328
- return t.createElement(K, a);
329
- }
330
- }
331
- const ue = $(G), U = t.memo((c) => {
332
- const {
333
- checked: l,
334
- onChange: e,
335
- label: o,
336
- disabled: a,
337
- className: s,
338
- style: d,
339
- id: u
340
- } = c, p = L(
341
- "fibo-switch-track w-[44px] h-[24px] rounded-full relative transition-colors duration-200 ease-in-out",
342
- a ? "cursor-not-allowed opacity-50" : "cursor-pointer",
343
- l ? "bg-[var(--fibo-primary,#3B82F6)]" : "bg-gray-200"
344
- ), k = L(
345
- "absolute w-5 h-5 rounded-full bg-white top-[2px] left-[2px] transition-transform duration-200 ease-in-out shadow-sm",
346
- l ? "translate-x-[20px]" : "translate-x-0"
347
- );
348
- return t.createElement(
349
- "label",
350
- {
351
- className: L("fibo-switch flex items-center gap-3", s)
352
- },
353
- t.createElement(
354
- "div",
355
- {
356
- className: p,
357
- style: d,
358
- "aria-hidden": !0
359
- },
360
- t.createElement("div", { className: k })
361
- ),
362
- o && t.createElement(
363
- "span",
364
- { className: "text-sm font-medium text-gray-700 select-none" },
365
- o
366
- ),
367
- t.createElement("input", {
368
- id: u,
369
- type: "checkbox",
370
- role: "switch",
371
- checked: !!l,
372
- disabled: a,
373
- className: "sr-only",
374
- onChange: (v) => !a && (e == null ? void 0 : e(v.target.checked))
375
- })
376
- );
377
- });
378
- class J extends D {
379
- constructor() {
380
- super(...arguments);
381
- r(this, "_checked", !1);
382
- r(this, "_onChange");
383
- r(this, "_label");
384
- r(this, "_disabled", !1);
385
- }
386
- checked(e) {
387
- return this._checked = e, this;
388
- }
389
- onChange(e) {
390
- return this._onChange = e, this;
391
- }
392
- label(e) {
393
- return this._label = e, this;
394
- }
395
- disabled(e = !0) {
396
- return this._disabled = e, this;
397
- }
398
- build() {
399
- const e = {
400
- checked: this._checked,
401
- onChange: this._onChange,
402
- label: this._label,
403
- disabled: this._disabled,
404
- className: this.getClassName(),
405
- style: this.getStyle(),
406
- ...this._props
407
- };
408
- return t.createElement(U, e);
409
- }
410
- }
411
- const he = $(J), Q = t.memo((c) => {
412
- const {
413
- checked: l,
414
- onChange: e,
415
- label: o,
416
- disabled: a,
417
- indeterminate: s,
418
- className: d,
419
- style: u,
420
- id: p
421
- } = c, k = F(null), v = l || s;
422
- j(() => {
423
- k.current && (k.current.indeterminate = !!s);
424
- }, [s]);
425
- let x = null;
426
- return s ? x = t.createElement("div", { className: "w-[10px] h-[2px] bg-white rounded-[1px]" }) : l && (x = t.createElement(
427
- "svg",
428
- {
429
- width: "12",
430
- height: "12",
431
- viewBox: "0 0 12 12",
432
- fill: "none",
433
- xmlns: "http://www.w3.org/2000/svg",
434
- "aria-hidden": !0
435
- },
436
- t.createElement("path", {
437
- d: "M10 3L4.5 8.5L2 6",
438
- stroke: "white",
439
- strokeWidth: "2",
440
- strokeLinecap: "round",
441
- strokeLinejoin: "round"
442
- })
443
- )), t.createElement(
444
- "label",
445
- {
446
- className: L("fibo-checkbox flex items-center gap-2", d)
447
- },
448
- t.createElement(
449
- "div",
450
- {
451
- className: L(
452
- "fibo-checkbox-box w-5 h-5 rounded-[6px] border-2 flex items-center justify-center transition-all duration-200",
453
- a ? "cursor-not-allowed opacity-50" : "cursor-pointer",
454
- v ? "border-transparent bg-[var(--fibo-primary,#3B82F6)]" : "border-gray-300 bg-transparent"
455
- ),
456
- style: u,
457
- "aria-hidden": !0
458
- },
459
- x
460
- ),
461
- o && t.createElement(
462
- "span",
463
- { className: "text-sm text-gray-700 select-none" },
464
- o
465
- ),
466
- t.createElement("input", {
467
- ref: k,
468
- id: p,
469
- type: "checkbox",
470
- checked: !!l,
471
- disabled: a,
472
- className: "sr-only",
473
- onChange: (E) => !a && (e == null ? void 0 : e(E.target.checked))
474
- })
475
- );
476
- });
477
- class X extends D {
478
- constructor() {
479
- super(...arguments);
480
- r(this, "_checked", !1);
481
- r(this, "_onChange");
482
- r(this, "_label");
483
- r(this, "_disabled", !1);
484
- r(this, "_indeterminate", !1);
485
- }
486
- checked(e) {
487
- return this._checked = e, this;
488
- }
489
- indeterminate(e) {
490
- return this._indeterminate = e, this;
491
- }
492
- onChange(e) {
493
- return this._onChange = e, this;
494
- }
495
- label(e) {
496
- return this._label = e, this;
497
- }
498
- disabled(e = !0) {
499
- return this._disabled = e, this;
500
- }
501
- build() {
502
- const e = {
503
- checked: this._checked,
504
- onChange: this._onChange,
505
- label: this._label,
506
- disabled: this._disabled,
507
- indeterminate: this._indeterminate,
508
- className: this.getClassName(),
509
- style: this.getStyle(),
510
- ...this._props
511
- };
512
- return t.createElement(Q, e);
513
- }
514
- }
515
- const pe = $(X), Y = t.memo((c) => {
516
- const {
517
- value: l,
518
- options: e = [],
519
- onChange: o,
520
- name: a,
521
- direction: s,
522
- className: d,
523
- style: u
524
- } = c, p = t.useId(), k = a || p;
525
- return t.createElement(
526
- "div",
527
- {
528
- role: "radiogroup",
529
- className: L(`fibo-radio-group flex ${s === "vertical" ? "flex-col gap-2" : "flex-row gap-4"}`, d),
530
- style: u
531
- },
532
- e.map((v) => {
533
- const x = l === v.value, E = v.disabled, _ = L(
534
- "relative flex items-center justify-center w-[18px] h-[18px] rounded-full transition-all duration-200",
535
- x ? "border-[5px] border-[var(--fibo-primary,#3B82F6)]" : "border-2 border-gray-300"
536
- );
537
- return t.createElement(
538
- "label",
539
- {
540
- key: v.value,
541
- className: `flex items-center gap-2 cursor-pointer ${E ? "opacity-50 cursor-not-allowed" : ""}`
542
- },
543
- t.createElement(
544
- "div",
545
- {
546
- className: _,
547
- "aria-hidden": !0
548
- },
549
- t.createElement("input", {
550
- type: "radio",
551
- name: k,
552
- value: v.value,
553
- checked: x,
554
- disabled: E,
555
- className: "sr-only",
556
- onChange: () => !E && (o == null ? void 0 : o(v.value))
557
- })
558
- ),
559
- t.createElement(
560
- "span",
561
- { className: "text-sm text-gray-700" },
562
- v.label
563
- )
564
- );
565
- })
566
- );
567
- });
568
- class Z extends D {
569
- constructor() {
570
- super(...arguments);
571
- r(this, "_value", "");
572
- r(this, "_options", []);
573
- r(this, "_onChange");
574
- r(this, "_name");
575
- r(this, "_direction", "vertical");
576
- }
577
- value(e) {
578
- return this._value = e, this;
579
- }
580
- options(e) {
581
- return this._options = e, this;
582
- }
583
- onChange(e) {
584
- return this._onChange = e, this;
585
- }
586
- direction(e) {
587
- return this._direction = e, this;
588
- }
589
- name(e) {
590
- return this._name = e, this;
591
- }
592
- build() {
593
- const e = {
594
- value: this._value,
595
- options: this._options,
596
- onChange: this._onChange,
597
- name: this._name,
598
- direction: this._direction,
599
- className: this.getClassName(),
600
- style: this.getStyle()
601
- };
602
- return t.createElement(Y, e);
603
- }
604
- }
605
- const me = $(Z), ee = t.memo((c) => {
606
- const l = t.useId(), e = c.id || l, {
607
- containerClass: o,
608
- containerStyle: a,
609
- label: s,
610
- error: d,
611
- ...u
612
- } = c;
613
- return t.createElement(
614
- "div",
615
- { className: o, style: a },
616
- t.createElement("textarea", {
617
- id: e,
618
- className: "fibo-textarea-input w-full p-4 text-base bg-transparent outline-none relative z-10",
619
- ...u
620
- }),
621
- s && t.createElement(
622
- "label",
623
- {
624
- htmlFor: e,
625
- className: "fibo-textarea-label"
626
- },
627
- s
628
- ),
629
- d && t.createElement(
630
- "span",
631
- { className: "text-[var(--fibo-error)] text-xs mt-1 ml-1" },
632
- d
633
- )
634
- );
635
- });
636
- class te extends D {
637
- constructor() {
638
- super(...arguments);
639
- r(this, "_value", "");
640
- r(this, "_label", "");
641
- r(this, "_placeholder", "");
642
- r(this, "_disabled", !1);
643
- r(this, "_rows", 4);
644
- r(this, "_error");
645
- r(this, "_resize", "vertical");
646
- r(this, "_onChange");
647
- }
648
- value(e) {
649
- return this._value = e, this;
650
- }
651
- label(e) {
652
- return this._label = e, this;
653
- }
654
- placeholder(e) {
655
- return this._placeholder = e, this;
656
- }
657
- disabled(e = !0) {
658
- return this._disabled = e, this;
659
- }
660
- rows(e) {
661
- return this._rows = e, this;
662
- }
663
- resize(e) {
664
- return this._resize = e, this;
665
- }
666
- error(e) {
667
- return this._error = e, this;
668
- }
669
- onChange(e) {
670
- return this._onChange = e, this;
671
- }
672
- build() {
673
- const o = {
674
- containerClass: L("fibo-textarea-container w-full", ...this._classNames),
675
- containerStyle: this.getStyle(),
676
- label: this._label,
677
- error: this._error,
678
- rows: this._rows,
679
- value: this._value,
680
- placeholder: this._placeholder || " ",
681
- disabled: this._disabled,
682
- style: { resize: this._resize },
683
- onChange: (a) => {
684
- var s;
685
- (s = this._onChange) == null || s.call(this, a.target.value);
686
- },
687
- ...this._props
688
- };
689
- return t.createElement(ee, o);
690
- }
691
- }
692
- const be = $(te), re = t.memo((c) => {
693
- const l = t.useId(), e = c.id || l, o = `${e}-listbox`, [a, s] = M(!1), [d, u] = M(0), p = F(null), {
694
- containerClass: k,
695
- containerStyle: v,
696
- label: x,
697
- error: E,
698
- value: _,
699
- options: y = [],
700
- placeholder: f,
701
- onChange: g,
702
- disabled: S,
703
- multiple: m
704
- } = c;
705
- j(() => {
706
- const n = (h) => {
707
- p.current && !p.current.contains(h.target) && s(!1);
708
- };
709
- return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
710
- }, []);
711
- const b = (n) => m ? Array.isArray(_) && _.includes(n) : _ === n;
712
- let w = "";
713
- if (m)
714
- Array.isArray(_) && _.length > 0 && (w = y.filter((n) => _.includes(n.value)).map((n) => n.label).join(", "));
715
- else {
716
- const n = y.find((h) => h.value === _);
717
- w = n ? n.label : "";
718
- }
719
- const I = (n) => {
720
- if (!S)
721
- if (m) {
722
- const h = Array.isArray(_) ? [..._] : [], A = h.indexOf(n);
723
- A > -1 ? h.splice(A, 1) : h.push(n), g == null || g(h);
724
- } else
725
- g == null || g(n), s(!1);
726
- }, C = (n) => {
727
- y.length !== 0 && u((h) => (h + n + y.length) % y.length);
728
- }, z = (n) => {
729
- if (!S)
730
- switch (n.key) {
731
- case "ArrowDown":
732
- n.preventDefault(), a ? C(1) : s(!0);
733
- break;
734
- case "ArrowUp":
735
- n.preventDefault(), a ? C(-1) : s(!0);
736
- break;
737
- case "Home":
738
- n.preventDefault(), u(0);
739
- break;
740
- case "End":
741
- n.preventDefault(), u(Math.max(0, y.length - 1));
742
- break;
743
- case "Enter":
744
- case " ":
745
- n.preventDefault(), a ? y[d] && I(y[d].value) : s(!0);
746
- break;
747
- case "Escape":
748
- n.preventDefault(), s(!1);
749
- break;
750
- }
751
- };
752
- return t.createElement(
753
- "div",
754
- {
755
- ref: p,
756
- className: k,
757
- style: v
758
- },
759
- t.createElement("div", { className: "relative w-full h-full" }, [
760
- t.createElement("button", {
761
- key: "trigger",
762
- id: e,
763
- type: "button",
764
- role: "combobox",
765
- "aria-expanded": a,
766
- "aria-haspopup": "listbox",
767
- "aria-controls": o,
768
- "aria-activedescendant": a && y[d] ? `${o}-opt-${y[d].value}` : void 0,
769
- disabled: S,
770
- className: `fibo-textfield-input text-left w-full flex items-center justify-between ${w ? "" : "text-gray-400"}`,
771
- onClick: () => !S && s(!a),
772
- onKeyDown: z
773
- }, [
774
- t.createElement("span", { key: "text", className: "truncate" }, w || f || " "),
775
- t.createElement("svg", {
776
- key: "icon",
777
- className: `w-4 h-4 transition-transform ${a ? "rotate-180" : ""}`,
778
- fill: "none",
779
- stroke: "currentColor",
780
- viewBox: "0 0 24 24",
781
- "aria-hidden": !0
782
- }, t.createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }))
783
- ]),
784
- x && t.createElement(
785
- "label",
786
- {
787
- key: "label",
788
- htmlFor: e,
789
- className: "fibo-textfield-label"
790
- },
791
- x
792
- ),
793
- a && t.createElement("div", {
794
- key: "dropdown",
795
- id: o,
796
- role: "listbox",
797
- "aria-multiselectable": m || void 0,
798
- className: "absolute z-50 w-full mt-1 bg-[var(--fibo-surface)] border border-[var(--fibo-outline)] rounded-md shadow-lg max-h-60 overflow-auto focus:outline-none"
799
- }, y.map((n, h) => {
800
- const A = b(n.value), T = h === d;
801
- return t.createElement("div", {
802
- key: n.value,
803
- id: `${o}-opt-${n.value}`,
804
- role: "option",
805
- "aria-selected": A,
806
- className: `px-4 py-2 cursor-pointer text-sm hover:bg-[var(--fibo-primary-container)] hover:text-[var(--fibo-on-primary-container)] flex items-center justify-between ${A || T ? "bg-[var(--fibo-primary-container)] text-[var(--fibo-on-primary-container)] font-medium" : "text-[var(--fibo-on-surface)]"}`,
807
- onClick: () => I(n.value),
808
- onMouseEnter: () => u(h)
809
- }, [
810
- t.createElement("span", { key: "label" }, n.label),
811
- A && t.createElement("svg", {
812
- key: "check",
813
- className: "w-4 h-4 text-[var(--fibo-primary)]",
814
- viewBox: "0 0 20 20",
815
- fill: "currentColor",
816
- "aria-hidden": !0
817
- }, t.createElement("path", { fillRule: "evenodd", d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", clipRule: "evenodd" }))
818
- ]);
819
- }))
820
- ]),
821
- E && t.createElement(
822
- "span",
823
- { className: "text-[var(--fibo-error)] text-xs mt-1 ml-1", role: "alert" },
824
- E
825
- )
826
- );
827
- });
828
- class ae extends D {
829
- constructor() {
830
- super(...arguments);
831
- r(this, "_value", "");
832
- r(this, "_label", "");
833
- r(this, "_placeholder", "");
834
- r(this, "_disabled", !1);
835
- r(this, "_error");
836
- r(this, "_multiple", !1);
837
- r(this, "_options", []);
838
- r(this, "_onChange");
839
- }
840
- value(e) {
841
- return this._value = e, this;
842
- }
843
- label(e) {
844
- return this._label = e, this;
845
- }
846
- placeholder(e) {
847
- return this._placeholder = e, this;
848
- }
849
- options(e) {
850
- return this._options = e, this;
851
- }
852
- multiple(e = !0) {
853
- return this._multiple = e, this;
854
- }
855
- disabled(e = !0) {
856
- return this._disabled = e, this;
857
- }
858
- error(e) {
859
- return this._error = e, this;
860
- }
861
- onChange(e) {
862
- return this._onChange = e, this;
863
- }
864
- build() {
865
- const o = {
866
- containerClass: L("fibo-textfield-container relative", ...this._classNames),
867
- containerStyle: this.getStyle(),
868
- label: this._label,
869
- error: this._error,
870
- value: this._value,
871
- placeholder: this._placeholder,
872
- options: this._options,
873
- disabled: this._disabled,
874
- multiple: this._multiple,
875
- onChange: this._onChange,
876
- ...this._props
877
- };
878
- return t.createElement(re, o);
879
- }
880
- }
881
- const fe = $(ae), se = t.memo((c) => {
882
- const l = t.useId(), e = c.id || l, o = `${e}-listbox`, [a, s] = M(!1), [d, u] = M(""), [p, k] = M(0), v = F(null), {
883
- containerClass: x,
884
- containerStyle: E,
885
- label: _,
886
- error: y,
887
- value: f,
888
- options: g = [],
889
- placeholder: S,
890
- onChange: m,
891
- onAdd: b,
892
- disabled: w,
893
- multiple: I
894
- } = c;
895
- j(() => {
896
- if (!I) {
897
- const i = g.find((N) => N.value === f);
898
- i && !a && d !== i.label && u(i.label);
899
- }
900
- }, [f, g, a, I]);
901
- const C = g.filter(
902
- (i) => i.label.toLowerCase().includes(d.toLowerCase())
903
- );
904
- j(() => {
905
- k(0);
906
- }, [d, a]), j(() => {
907
- const i = (N) => {
908
- if (v.current && !v.current.contains(N.target))
909
- if (s(!1), I)
910
- u("");
911
- else {
912
- const B = g.find((R) => R.value === f);
913
- u(B ? B.label : "");
914
- }
915
- };
916
- return document.addEventListener("mousedown", i), () => document.removeEventListener("mousedown", i);
917
- }, [f, g, I]);
918
- const z = (i) => {
919
- if (I) {
920
- const N = Array.isArray(f) ? [...f] : [];
921
- N.includes(i.value) || (N.push(i.value), m == null || m(N)), u("");
922
- } else
923
- u(i.label), m == null || m(i.value), s(!1);
924
- }, n = (i) => {
925
- if (I && Array.isArray(f)) {
926
- const N = f.filter((B) => B !== i);
927
- m == null || m(N);
928
- }
929
- }, h = () => {
930
- b == null || b(d), I ? u("") : s(!1);
931
- }, A = (i) => I ? Array.isArray(f) && f.includes(i) : f === i, T = (i) => {
932
- if (!w)
933
- switch (i.key) {
934
- case "ArrowDown":
935
- i.preventDefault(), a ? C.length && k((N) => (N + 1) % C.length) : s(!0);
936
- break;
937
- case "ArrowUp":
938
- i.preventDefault(), a ? C.length && k((N) => (N - 1 + C.length) % C.length) : s(!0);
939
- break;
940
- case "Enter":
941
- i.preventDefault(), C[p] ? z(C[p]) : d && b && h();
942
- break;
943
- case "Escape":
944
- i.preventDefault(), s(!1);
945
- break;
946
- }
947
- };
948
- return t.createElement(
949
- "div",
950
- {
951
- ref: v,
952
- className: x,
953
- style: E
954
- },
955
- t.createElement("div", { className: "relative w-full h-full" }, [
956
- t.createElement("div", {
957
- key: "field",
958
- className: `fibo-textfield-input flex flex-wrap items-center gap-1 ${a ? "ring-2 ring-[var(--fibo-primary-container)] border-[var(--fibo-primary)]" : ""}`,
959
- style: { minHeight: "42px", padding: "4px 8px" }
960
- }, [
961
- I && Array.isArray(f) && f.map((i) => {
962
- const N = g.find((R) => R.value === i), B = N ? N.label : i;
963
- return t.createElement("span", {
964
- key: i,
965
- className: "bg-[var(--fibo-primary-container)] text-[var(--fibo-on-primary-container)] text-xs font-medium px-2 py-1 rounded-md flex items-center"
966
- }, [
967
- B,
968
- t.createElement("button", {
969
- type: "button",
970
- className: "ml-1 hover:text-[var(--fibo-primary)] focus:outline-none",
971
- "aria-label": `Remove ${B}`,
972
- onClick: (R) => {
973
- R.stopPropagation(), n(i);
974
- }
975
- }, "×")
976
- ]);
977
- }),
978
- t.createElement("input", {
979
- key: "input",
980
- id: e,
981
- role: "combobox",
982
- "aria-expanded": a,
983
- "aria-controls": o,
984
- "aria-autocomplete": "list",
985
- "aria-activedescendant": a && C[p] ? `${o}-opt-${C[p].value}` : void 0,
986
- className: "bg-transparent outline-none flex-1 min-w-[60px] text-sm h-8",
987
- value: d,
988
- placeholder: I && Array.isArray(f) && f.length > 0 ? "" : S || " ",
989
- disabled: w,
990
- onChange: (i) => {
991
- u(i.target.value), a || s(!0);
992
- },
993
- onFocus: () => s(!0),
994
- onKeyDown: T
995
- })
996
- ]),
997
- _ && t.createElement(
998
- "label",
999
- {
1000
- key: "label",
1001
- htmlFor: e,
1002
- className: "fibo-textfield-label"
1003
- },
1004
- _
1005
- ),
1006
- a && t.createElement("div", {
1007
- key: "dropdown",
1008
- id: o,
1009
- role: "listbox",
1010
- "aria-multiselectable": I || void 0,
1011
- className: "absolute z-50 w-full mt-1 bg-[var(--fibo-surface)] border border-[var(--fibo-outline)] rounded-md shadow-lg max-h-60 overflow-auto focus:outline-none left-0"
1012
- }, [
1013
- ...C.length > 0 ? C.map((i, N) => {
1014
- const B = A(i.value), R = N === p;
1015
- return t.createElement("div", {
1016
- key: i.value,
1017
- id: `${o}-opt-${i.value}`,
1018
- role: "option",
1019
- "aria-selected": B,
1020
- className: `px-4 py-2 cursor-pointer text-sm hover:bg-[var(--fibo-primary-container)] hover:text-[var(--fibo-on-primary-container)] ${B || R ? "bg-[var(--fibo-primary-container)] text-[var(--fibo-on-primary-container)] font-medium" : "text-[var(--fibo-on-surface)]"} ${B ? "opacity-50" : ""}`,
1021
- onClick: () => !B && z(i),
1022
- onMouseEnter: () => k(N)
1023
- }, i.label);
1024
- }) : [t.createElement("div", { key: "empty", className: "px-4 py-2 text-sm text-gray-500" }, "No results found.")],
1025
- d && !C.some((i) => i.label.toLowerCase() === d.toLowerCase()) && b ? t.createElement("div", {
1026
- key: "add-new",
1027
- role: "option",
1028
- "aria-selected": !1,
1029
- className: "border-t border-[var(--fibo-outline)] px-4 py-2 cursor-pointer text-sm text-[var(--fibo-primary)] hover:bg-[var(--fibo-primary-container)] font-medium flex items-center",
1030
- onClick: h
1031
- }, [
1032
- t.createElement("span", { key: "plus", className: "mr-1" }, "+"),
1033
- `Add "${d}"`
1034
- ]) : null
1035
- ])
1036
- ]),
1037
- y && t.createElement(
1038
- "span",
1039
- { className: "text-[var(--fibo-error)] text-xs mt-1 ml-1", role: "alert" },
1040
- y
1041
- )
1042
- );
1043
- });
1044
- class ne extends D {
1045
- constructor() {
1046
- super(...arguments);
1047
- r(this, "_value", "");
1048
- r(this, "_label", "");
1049
- r(this, "_placeholder", "");
1050
- r(this, "_disabled", !1);
1051
- r(this, "_error");
1052
- r(this, "_multiple", !1);
1053
- r(this, "_options", []);
1054
- r(this, "_onChange");
1055
- r(this, "_onAdd");
1056
- }
1057
- value(e) {
1058
- return this._value = e, this;
1059
- }
1060
- label(e) {
1061
- return this._label = e, this;
1062
- }
1063
- placeholder(e) {
1064
- return this._placeholder = e, this;
1065
- }
1066
- options(e) {
1067
- return this._options = e, this;
1068
- }
1069
- multiple(e = !0) {
1070
- return this._multiple = e, this;
1071
- }
1072
- disabled(e = !0) {
1073
- return this._disabled = e, this;
1074
- }
1075
- error(e) {
1076
- return this._error = e, this;
1077
- }
1078
- onChange(e) {
1079
- return this._onChange = e, this;
1080
- }
1081
- onAdd(e) {
1082
- return this._onAdd = e, this;
1083
- }
1084
- build() {
1085
- const o = {
1086
- containerClass: L("fibo-textfield-container relative", ...this._classNames),
1087
- containerStyle: this.getStyle(),
1088
- label: this._label,
1089
- error: this._error,
1090
- value: this._value,
1091
- placeholder: this._placeholder,
1092
- options: this._options,
1093
- disabled: this._disabled,
1094
- multiple: this._multiple,
1095
- onChange: this._onChange,
1096
- onAdd: this._onAdd,
1097
- ...this._props
1098
- };
1099
- return t.createElement(se, o);
1100
- }
1101
- }
1102
- const xe = $(ne);
1103
- export {
1104
- de as B,
1105
- pe as C,
1106
- me as R,
1107
- he as S,
1108
- ue as T,
1109
- be as a,
1110
- fe as b,
1111
- xe as c
1112
- };