analytica-frontend-lib 1.0.18 → 1.0.20
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.
- package/dist/index.css +134 -8
- package/dist/index.d.mts +75 -32
- package/dist/index.d.ts +75 -32
- package/dist/index.js +248 -132
- package/dist/index.mjs +244 -129
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
Badge: () => Badge,
|
|
23
24
|
Button: () => Button,
|
|
24
25
|
CheckBox: () => CheckBox,
|
|
25
26
|
DropdownMenu: () => DropdownMenu,
|
|
@@ -256,124 +257,101 @@ var Text = ({
|
|
|
256
257
|
);
|
|
257
258
|
};
|
|
258
259
|
|
|
259
|
-
// src/components/
|
|
260
|
+
// src/components/Badge/Badge.tsx
|
|
260
261
|
var import_phosphor_react = require("phosphor-react");
|
|
261
262
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
262
263
|
var VARIANT_ACTION_CLASSES2 = {
|
|
263
264
|
solid: {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
265
|
+
error: "bg-error text-error-700 focus-visible:outline-none",
|
|
266
|
+
warning: "bg-warning text-warning-800 focus-visible:outline-none",
|
|
267
|
+
success: "bg-success text-success-800 focus-visible:outline-none",
|
|
268
|
+
info: "bg-info text-info-800 focus-visible:outline-none",
|
|
269
|
+
muted: "bg-background-muted text-background-800 focus-visible:outline-none"
|
|
267
270
|
},
|
|
268
271
|
outlined: {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
error: "bg-error text-error-700 border border-error-300 focus-visible:outline-none",
|
|
273
|
+
warning: "bg-warning text-warning-800 border border-warning-300 focus-visible:outline-none",
|
|
274
|
+
success: "bg-success text-success-800 border border-success-300 focus-visible:outline-none",
|
|
275
|
+
info: "bg-info text-info-800 border border-info-300 focus-visible:outline-none",
|
|
276
|
+
muted: "bg-background-muted text-background-800 border border-border-300 focus-visible:outline-none"
|
|
277
|
+
},
|
|
278
|
+
exams: {
|
|
279
|
+
exam1: "bg-exam-1 text-info-200 focus-visible:outline-none",
|
|
280
|
+
exam2: "bg-exam-2 text-typography-1 focus-visible:outline-none",
|
|
281
|
+
exam3: "bg-exam-3 text-typography-2 focus-visible:outline-none",
|
|
282
|
+
exam4: "bg-exam-4 text-success-700 focus-visible:outline-none"
|
|
283
|
+
},
|
|
284
|
+
resultStatus: {
|
|
285
|
+
negative: "bg-error text-error-800 focus-visible:outline-none",
|
|
286
|
+
positive: "bg-success text-success-800 focus-visible:outline-none"
|
|
287
|
+
},
|
|
288
|
+
notification: "text-primary"
|
|
273
289
|
};
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
290
|
+
var SIZE_CLASSES2 = {
|
|
291
|
+
small: "text-2xs px-2 py-1",
|
|
292
|
+
medium: "text-xs px-2 py-1",
|
|
293
|
+
large: "text-sm px-2 py-1"
|
|
278
294
|
};
|
|
279
|
-
var
|
|
280
|
-
|
|
281
|
-
|
|
295
|
+
var SIZE_CLASSES_ICON = {
|
|
296
|
+
small: "size-3",
|
|
297
|
+
medium: "size-3.5",
|
|
298
|
+
large: "size-4"
|
|
299
|
+
};
|
|
300
|
+
var Badge = ({
|
|
301
|
+
children,
|
|
302
|
+
iconLeft,
|
|
303
|
+
iconRight,
|
|
304
|
+
size = "medium",
|
|
305
|
+
variant = "solid",
|
|
306
|
+
action = "error",
|
|
282
307
|
className = "",
|
|
283
|
-
|
|
284
|
-
title,
|
|
285
|
-
description,
|
|
286
|
-
position = "default",
|
|
308
|
+
notificationActive = false,
|
|
287
309
|
...props
|
|
288
310
|
}) => {
|
|
289
|
-
const
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
311
|
+
const sizeClasses = SIZE_CLASSES2[size];
|
|
312
|
+
const sizeClassesIcon = SIZE_CLASSES_ICON[size];
|
|
313
|
+
const variantActionMap = VARIANT_ACTION_CLASSES2[variant] || {};
|
|
314
|
+
const variantClasses = typeof variantActionMap === "string" ? variantActionMap : variantActionMap[action] ?? variantActionMap.muted ?? "";
|
|
315
|
+
const baseClasses = "inline-flex items-center justify-center rounded-xs font-medium gap-1 relative";
|
|
316
|
+
const baseClassesIcon = "flex items-center";
|
|
317
|
+
if (variant === "notification") {
|
|
318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
319
|
+
"div",
|
|
320
|
+
{
|
|
321
|
+
className: `${baseClasses} ${variantClasses} ${sizeClasses} ${className}`,
|
|
322
|
+
...props,
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_phosphor_react.Bell, { size: 24, className: "text-primary-950" }),
|
|
325
|
+
notificationActive && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
326
|
+
"span",
|
|
327
|
+
{
|
|
328
|
+
"data-testid": "notification-dot",
|
|
329
|
+
className: "absolute top-[5px] right-[10px] block h-2 w-2 rounded-full bg-indicator-error ring-2 ring-white"
|
|
330
|
+
}
|
|
331
|
+
)
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
}
|
|
301
336
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
302
337
|
"div",
|
|
303
338
|
{
|
|
304
|
-
|
|
305
|
-
"aria-live": "assertive",
|
|
306
|
-
"aria-atomic": "true",
|
|
307
|
-
className: `${baseClasses} ${positionClasses[position]} ${variantClasses} ${className}`,
|
|
339
|
+
className: `${baseClasses} ${variantClasses} ${sizeClasses} ${className}`,
|
|
308
340
|
...props,
|
|
309
341
|
children: [
|
|
310
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "font-semibold text-md", children: title }),
|
|
314
|
-
description && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-md text-text-900", children: description })
|
|
315
|
-
] })
|
|
316
|
-
] }),
|
|
317
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
318
|
-
"button",
|
|
319
|
-
{
|
|
320
|
-
onClick: onClose,
|
|
321
|
-
"aria-label": "Dismiss notification",
|
|
322
|
-
className: "text-background-500 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
|
|
323
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_phosphor_react.X, {})
|
|
324
|
-
}
|
|
325
|
-
)
|
|
342
|
+
iconLeft && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `${baseClassesIcon} ${sizeClassesIcon}`, children: iconLeft }),
|
|
343
|
+
children,
|
|
344
|
+
iconRight && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `${baseClassesIcon} ${sizeClassesIcon}`, children: iconRight })
|
|
326
345
|
]
|
|
327
346
|
}
|
|
328
347
|
);
|
|
329
348
|
};
|
|
330
349
|
|
|
331
|
-
// src/components/Toast/utils/ToastStore.ts
|
|
332
|
-
var import_zustand = require("zustand");
|
|
333
|
-
var useToastStore = (0, import_zustand.create)((set) => ({
|
|
334
|
-
toasts: [],
|
|
335
|
-
addToast: (toast) => {
|
|
336
|
-
const id = crypto.randomUUID();
|
|
337
|
-
set((state) => ({
|
|
338
|
-
toasts: [...state.toasts, { id, ...toast }]
|
|
339
|
-
}));
|
|
340
|
-
},
|
|
341
|
-
removeToast: (id) => {
|
|
342
|
-
set((state) => ({
|
|
343
|
-
toasts: state.toasts.filter((t) => t.id !== id)
|
|
344
|
-
}));
|
|
345
|
-
}
|
|
346
|
-
}));
|
|
347
|
-
|
|
348
|
-
// src/components/Toast/utils/Toaster.tsx
|
|
349
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
350
|
-
var Toaster = () => {
|
|
351
|
-
const toasts = useToastStore((state) => state.toasts);
|
|
352
|
-
const removeToast = useToastStore((state) => state.removeToast);
|
|
353
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
354
|
-
Toast,
|
|
355
|
-
{
|
|
356
|
-
title: toast.title,
|
|
357
|
-
description: toast.description,
|
|
358
|
-
variant: toast.variant,
|
|
359
|
-
action: toast.action,
|
|
360
|
-
position: toast.position,
|
|
361
|
-
onClose: () => removeToast(toast.id)
|
|
362
|
-
},
|
|
363
|
-
toast.id
|
|
364
|
-
)) });
|
|
365
|
-
};
|
|
366
|
-
var useToast = () => {
|
|
367
|
-
const addToast = useToastStore((state) => state.addToast);
|
|
368
|
-
const removeToast = useToastStore((state) => state.removeToast);
|
|
369
|
-
return { addToast, removeToast };
|
|
370
|
-
};
|
|
371
|
-
|
|
372
350
|
// src/components/CheckBox/CheckBox.tsx
|
|
373
351
|
var import_react2 = require("react");
|
|
374
352
|
var import_phosphor_react2 = require("phosphor-react");
|
|
375
|
-
var
|
|
376
|
-
var
|
|
353
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
354
|
+
var SIZE_CLASSES3 = {
|
|
377
355
|
small: {
|
|
378
356
|
checkbox: "w-4 h-4",
|
|
379
357
|
// 16px x 16px
|
|
@@ -460,14 +438,14 @@ var CheckBox = (0, import_react2.forwardRef)(
|
|
|
460
438
|
onChange?.(event);
|
|
461
439
|
};
|
|
462
440
|
const currentState = disabled ? "disabled" : state;
|
|
463
|
-
const sizeClasses =
|
|
441
|
+
const sizeClasses = SIZE_CLASSES3[size];
|
|
464
442
|
const checkVariant = checked || indeterminate ? "checked" : "unchecked";
|
|
465
443
|
const stylingClasses = STATE_CLASSES[currentState][checkVariant];
|
|
466
444
|
const borderWidthClass = state === "focused" || state === "hovered" && size === "large" ? "border-[3px]" : sizeClasses.borderWidth;
|
|
467
445
|
const checkboxClasses = `${BASE_CHECKBOX_CLASSES} ${sizeClasses.checkbox} ${borderWidthClass} ${stylingClasses} ${className}`;
|
|
468
446
|
const renderIcon = () => {
|
|
469
447
|
if (indeterminate) {
|
|
470
|
-
return /* @__PURE__ */ (0,
|
|
448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
471
449
|
import_phosphor_react2.Minus,
|
|
472
450
|
{
|
|
473
451
|
size: sizeClasses.iconSize,
|
|
@@ -477,7 +455,7 @@ var CheckBox = (0, import_react2.forwardRef)(
|
|
|
477
455
|
);
|
|
478
456
|
}
|
|
479
457
|
if (checked) {
|
|
480
|
-
return /* @__PURE__ */ (0,
|
|
458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
481
459
|
import_phosphor_react2.Check,
|
|
482
460
|
{
|
|
483
461
|
size: sizeClasses.iconSize,
|
|
@@ -488,13 +466,13 @@ var CheckBox = (0, import_react2.forwardRef)(
|
|
|
488
466
|
}
|
|
489
467
|
return null;
|
|
490
468
|
};
|
|
491
|
-
return /* @__PURE__ */ (0,
|
|
492
|
-
/* @__PURE__ */ (0,
|
|
469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-col", children: [
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
493
471
|
"div",
|
|
494
472
|
{
|
|
495
473
|
className: `flex flex-row items-center ${sizeClasses.spacing} ${disabled ? "opacity-40" : ""}`,
|
|
496
474
|
children: [
|
|
497
|
-
/* @__PURE__ */ (0,
|
|
475
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
498
476
|
"input",
|
|
499
477
|
{
|
|
500
478
|
ref,
|
|
@@ -507,12 +485,12 @@ var CheckBox = (0, import_react2.forwardRef)(
|
|
|
507
485
|
...props
|
|
508
486
|
}
|
|
509
487
|
),
|
|
510
|
-
/* @__PURE__ */ (0,
|
|
511
|
-
label && /* @__PURE__ */ (0,
|
|
488
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: inputId, className: checkboxClasses, children: renderIcon() }),
|
|
489
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
512
490
|
"div",
|
|
513
491
|
{
|
|
514
492
|
className: `flex flex-row items-center ${sizeClasses.labelHeight}`,
|
|
515
|
-
children: /* @__PURE__ */ (0,
|
|
493
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
516
494
|
Text,
|
|
517
495
|
{
|
|
518
496
|
as: "label",
|
|
@@ -529,8 +507,8 @@ var CheckBox = (0, import_react2.forwardRef)(
|
|
|
529
507
|
]
|
|
530
508
|
}
|
|
531
509
|
),
|
|
532
|
-
errorMessage && /* @__PURE__ */ (0,
|
|
533
|
-
helperText && !errorMessage && /* @__PURE__ */ (0,
|
|
510
|
+
errorMessage && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-error-600", children: errorMessage }),
|
|
511
|
+
helperText && !errorMessage && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-text-500", children: helperText })
|
|
534
512
|
] });
|
|
535
513
|
}
|
|
536
514
|
);
|
|
@@ -538,23 +516,23 @@ CheckBox.displayName = "CheckBox";
|
|
|
538
516
|
|
|
539
517
|
// src/components/Table/Table.tsx
|
|
540
518
|
var import_react3 = require("react");
|
|
541
|
-
var
|
|
519
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
542
520
|
var Table = (0, import_react3.forwardRef)(
|
|
543
|
-
({ className, children, ...props }, ref) => /* @__PURE__ */ (0,
|
|
521
|
+
({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "border border-border-200 rounded-xl relative w-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
544
522
|
"table",
|
|
545
523
|
{
|
|
546
524
|
ref,
|
|
547
525
|
className: `w-full caption-bottom text-sm ${className ?? ""}`,
|
|
548
526
|
...props,
|
|
549
527
|
children: [
|
|
550
|
-
/* @__PURE__ */ (0,
|
|
528
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("caption", { className: "sr-only", children: "My Table" }),
|
|
551
529
|
children
|
|
552
530
|
]
|
|
553
531
|
}
|
|
554
532
|
) })
|
|
555
533
|
);
|
|
556
534
|
Table.displayName = "Table";
|
|
557
|
-
var TableHeader = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
535
|
+
var TableHeader = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
558
536
|
"thead",
|
|
559
537
|
{
|
|
560
538
|
ref,
|
|
@@ -563,7 +541,7 @@ var TableHeader = (0, import_react3.forwardRef)(({ className, ...props }, ref) =
|
|
|
563
541
|
}
|
|
564
542
|
));
|
|
565
543
|
TableHeader.displayName = "TableHeader";
|
|
566
|
-
var TableBody = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
544
|
+
var TableBody = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
567
545
|
"tbody",
|
|
568
546
|
{
|
|
569
547
|
ref,
|
|
@@ -572,7 +550,7 @@ var TableBody = (0, import_react3.forwardRef)(({ className, ...props }, ref) =>
|
|
|
572
550
|
}
|
|
573
551
|
));
|
|
574
552
|
TableBody.displayName = "TableBody";
|
|
575
|
-
var TableFooter = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
553
|
+
var TableFooter = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
576
554
|
"tfoot",
|
|
577
555
|
{
|
|
578
556
|
ref,
|
|
@@ -589,7 +567,7 @@ var VARIANT_STATES_ROW = {
|
|
|
589
567
|
};
|
|
590
568
|
var TableRow = (0, import_react3.forwardRef)(
|
|
591
569
|
({ state = "default", className, ...props }, ref) => {
|
|
592
|
-
return /* @__PURE__ */ (0,
|
|
570
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
593
571
|
"tr",
|
|
594
572
|
{
|
|
595
573
|
ref,
|
|
@@ -606,7 +584,7 @@ var TableRow = (0, import_react3.forwardRef)(
|
|
|
606
584
|
}
|
|
607
585
|
);
|
|
608
586
|
TableRow.displayName = "TableRow";
|
|
609
|
-
var TableHead = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
587
|
+
var TableHead = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
610
588
|
"th",
|
|
611
589
|
{
|
|
612
590
|
ref,
|
|
@@ -615,7 +593,7 @@ var TableHead = (0, import_react3.forwardRef)(({ className, ...props }, ref) =>
|
|
|
615
593
|
}
|
|
616
594
|
));
|
|
617
595
|
TableHead.displayName = "TableHead";
|
|
618
|
-
var TableCell = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
596
|
+
var TableCell = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
619
597
|
"td",
|
|
620
598
|
{
|
|
621
599
|
ref,
|
|
@@ -624,7 +602,7 @@ var TableCell = (0, import_react3.forwardRef)(({ className, ...props }, ref) =>
|
|
|
624
602
|
}
|
|
625
603
|
));
|
|
626
604
|
TableCell.displayName = "TableCell";
|
|
627
|
-
var TableCaption = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
605
|
+
var TableCaption = (0, import_react3.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
628
606
|
"caption",
|
|
629
607
|
{
|
|
630
608
|
ref,
|
|
@@ -636,7 +614,7 @@ TableCaption.displayName = "TableCaption";
|
|
|
636
614
|
|
|
637
615
|
// src/components/DropdownMenu/DropdownMenu.tsx
|
|
638
616
|
var import_react4 = require("react");
|
|
639
|
-
var
|
|
617
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
640
618
|
var DropdownMenuContext = (0, import_react4.createContext)(
|
|
641
619
|
void 0
|
|
642
620
|
);
|
|
@@ -652,9 +630,32 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
|
652
630
|
[isControlled, onOpenChange]
|
|
653
631
|
);
|
|
654
632
|
const menuRef = (0, import_react4.useRef)(null);
|
|
655
|
-
const
|
|
633
|
+
const handleArrowDownOrArrowUp = (event) => {
|
|
634
|
+
const menuContent = menuRef.current?.querySelector('[role="menu"]');
|
|
635
|
+
if (menuContent) {
|
|
636
|
+
event.preventDefault();
|
|
637
|
+
const items = Array.from(
|
|
638
|
+
menuContent.querySelectorAll(
|
|
639
|
+
'[role="menuitem"]:not([aria-disabled="true"])'
|
|
640
|
+
)
|
|
641
|
+
).filter((el) => el instanceof HTMLElement);
|
|
642
|
+
if (items.length === 0) return;
|
|
643
|
+
const focusedItem = document.activeElement;
|
|
644
|
+
const currentIndex = items.findIndex((item) => item === focusedItem);
|
|
645
|
+
let nextIndex;
|
|
646
|
+
if (event.key === "ArrowDown") {
|
|
647
|
+
nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % items.length;
|
|
648
|
+
} else {
|
|
649
|
+
nextIndex = currentIndex === -1 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length;
|
|
650
|
+
}
|
|
651
|
+
items[nextIndex]?.focus();
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
const handleDownkey = (event) => {
|
|
656
655
|
if (event.key === "Escape") {
|
|
657
656
|
setOpen(false);
|
|
657
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
658
|
+
handleArrowDownOrArrowUp(event);
|
|
658
659
|
}
|
|
659
660
|
};
|
|
660
661
|
const handleClickOutside = (event) => {
|
|
@@ -665,25 +666,25 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
|
665
666
|
(0, import_react4.useEffect)(() => {
|
|
666
667
|
if (currentOpen) {
|
|
667
668
|
document.addEventListener("mousedown", handleClickOutside);
|
|
668
|
-
document.addEventListener("keydown",
|
|
669
|
+
document.addEventListener("keydown", handleDownkey);
|
|
669
670
|
}
|
|
670
671
|
return () => {
|
|
671
672
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
672
|
-
document.removeEventListener("keydown",
|
|
673
|
+
document.removeEventListener("keydown", handleDownkey);
|
|
673
674
|
};
|
|
674
675
|
}, [currentOpen]);
|
|
675
676
|
const value = (0, import_react4.useMemo)(
|
|
676
677
|
() => ({ open: currentOpen, setOpen }),
|
|
677
678
|
[currentOpen, setOpen]
|
|
678
679
|
);
|
|
679
|
-
return /* @__PURE__ */ (0,
|
|
680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "relative", ref: menuRef, children }) });
|
|
680
681
|
};
|
|
681
682
|
var DropdownMenuTrigger = (0, import_react4.forwardRef)(({ className, children, onClick, ...props }, ref) => {
|
|
682
683
|
const context = (0, import_react4.useContext)(DropdownMenuContext);
|
|
683
684
|
if (!context)
|
|
684
685
|
throw new Error("DropdownMenuTrigger must be used within a DropdownMenu");
|
|
685
686
|
const { open, setOpen } = context;
|
|
686
|
-
return /* @__PURE__ */ (0,
|
|
687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
687
688
|
"button",
|
|
688
689
|
{
|
|
689
690
|
ref,
|
|
@@ -715,7 +716,7 @@ var ALIGN_CLASSES = {
|
|
|
715
716
|
center: "left-1/2 -translate-x-1/2",
|
|
716
717
|
end: "right-0"
|
|
717
718
|
};
|
|
718
|
-
var MenuLabel = (0, import_react4.forwardRef)(({ className, inset, ...props }, ref) => /* @__PURE__ */ (0,
|
|
719
|
+
var MenuLabel = (0, import_react4.forwardRef)(({ className, inset, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
719
720
|
"fieldset",
|
|
720
721
|
{
|
|
721
722
|
ref,
|
|
@@ -750,7 +751,7 @@ var MenuContent = (0, import_react4.forwardRef)(
|
|
|
750
751
|
const horizontal = ALIGN_CLASSES[align];
|
|
751
752
|
return `absolute ${vertical} ${horizontal}`;
|
|
752
753
|
};
|
|
753
|
-
return /* @__PURE__ */ (0,
|
|
754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
754
755
|
"div",
|
|
755
756
|
{
|
|
756
757
|
ref,
|
|
@@ -795,13 +796,14 @@ var MenuItem = (0, import_react4.forwardRef)(
|
|
|
795
796
|
}
|
|
796
797
|
onClick?.(e);
|
|
797
798
|
};
|
|
798
|
-
return /* @__PURE__ */ (0,
|
|
799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
799
800
|
"div",
|
|
800
801
|
{
|
|
801
802
|
ref,
|
|
802
803
|
role: "menuitem",
|
|
803
804
|
"aria-disabled": disabled,
|
|
804
805
|
className: `
|
|
806
|
+
focus-visible:bg-background-50
|
|
805
807
|
relative flex select-none items-center gap-2 rounded-sm p-3 text-sm outline-none transition-colors [&>svg]:size-4 [&>svg]:shrink-0
|
|
806
808
|
${inset && "pl-8"}
|
|
807
809
|
${sizeClasses}
|
|
@@ -824,7 +826,7 @@ var MenuItem = (0, import_react4.forwardRef)(
|
|
|
824
826
|
}
|
|
825
827
|
);
|
|
826
828
|
MenuItem.displayName = "MenuItem";
|
|
827
|
-
var MenuSeparator = (0, import_react4.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
829
|
+
var MenuSeparator = (0, import_react4.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
828
830
|
"div",
|
|
829
831
|
{
|
|
830
832
|
ref,
|
|
@@ -836,7 +838,7 @@ MenuSeparator.displayName = "MenuSeparator";
|
|
|
836
838
|
|
|
837
839
|
// src/components/NavButton/NavButton.tsx
|
|
838
840
|
var import_react5 = require("react");
|
|
839
|
-
var
|
|
841
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
840
842
|
var NavButton = (0, import_react5.forwardRef)(
|
|
841
843
|
({ icon, label, selected = false, className = "", disabled, ...props }, ref) => {
|
|
842
844
|
const baseClasses = [
|
|
@@ -864,7 +866,7 @@ var NavButton = (0, import_react5.forwardRef)(
|
|
|
864
866
|
];
|
|
865
867
|
const stateClasses = selected ? ["bg-primary-50", "text-primary-950"] : [];
|
|
866
868
|
const allClasses = [...baseClasses, ...stateClasses].join(" ");
|
|
867
|
-
return /* @__PURE__ */ (0,
|
|
869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
868
870
|
"button",
|
|
869
871
|
{
|
|
870
872
|
ref,
|
|
@@ -874,8 +876,8 @@ var NavButton = (0, import_react5.forwardRef)(
|
|
|
874
876
|
"aria-pressed": selected,
|
|
875
877
|
...props,
|
|
876
878
|
children: [
|
|
877
|
-
/* @__PURE__ */ (0,
|
|
878
|
-
/* @__PURE__ */ (0,
|
|
879
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "flex items-center justify-center w-5 h-5", children: icon }),
|
|
880
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "whitespace-nowrap", children: label })
|
|
879
881
|
]
|
|
880
882
|
}
|
|
881
883
|
);
|
|
@@ -885,7 +887,7 @@ NavButton.displayName = "NavButton";
|
|
|
885
887
|
|
|
886
888
|
// src/components/IconButton/IconButton.tsx
|
|
887
889
|
var import_react6 = require("react");
|
|
888
|
-
var
|
|
890
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
889
891
|
var IconButton = (0, import_react6.forwardRef)(
|
|
890
892
|
({ icon, size = "md", active = false, className = "", disabled, ...props }, ref) => {
|
|
891
893
|
const baseClasses = [
|
|
@@ -918,7 +920,7 @@ var IconButton = (0, import_react6.forwardRef)(
|
|
|
918
920
|
...activeClasses
|
|
919
921
|
].join(" ");
|
|
920
922
|
const ariaLabel = props["aria-label"] ?? "Bot\xE3o de a\xE7\xE3o";
|
|
921
|
-
return /* @__PURE__ */ (0,
|
|
923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
922
924
|
"button",
|
|
923
925
|
{
|
|
924
926
|
ref,
|
|
@@ -928,14 +930,128 @@ var IconButton = (0, import_react6.forwardRef)(
|
|
|
928
930
|
"aria-pressed": active,
|
|
929
931
|
"aria-label": ariaLabel,
|
|
930
932
|
...props,
|
|
931
|
-
children: /* @__PURE__ */ (0,
|
|
933
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "flex items-center justify-center", children: icon })
|
|
932
934
|
}
|
|
933
935
|
);
|
|
934
936
|
}
|
|
935
937
|
);
|
|
936
938
|
IconButton.displayName = "IconButton";
|
|
939
|
+
|
|
940
|
+
// src/components/Toast/Toast.tsx
|
|
941
|
+
var import_phosphor_react3 = require("phosphor-react");
|
|
942
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
943
|
+
var VARIANT_ACTION_CLASSES3 = {
|
|
944
|
+
solid: {
|
|
945
|
+
warning: "bg-warning text-warning-800 border-none focus-visible:outline-none",
|
|
946
|
+
success: "bg-success text-success-800 border-none focus-visible:outline-none",
|
|
947
|
+
info: "bg-info text-info-800 border-none focus-visible:outline-none"
|
|
948
|
+
},
|
|
949
|
+
outlined: {
|
|
950
|
+
warning: "bg-warning text-warning-800 border border-warning-200 focus-visible:outline-none",
|
|
951
|
+
success: "bg-success text-success-800 border border-success-200 focus-visible:outline-none",
|
|
952
|
+
info: "bg-info text-info-800 border border-info-200 focus-visible:outline-none"
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
var iconMap = {
|
|
956
|
+
success: import_phosphor_react3.CheckCircle,
|
|
957
|
+
info: import_phosphor_react3.Info,
|
|
958
|
+
warning: import_phosphor_react3.WarningCircle
|
|
959
|
+
};
|
|
960
|
+
var Toast = ({
|
|
961
|
+
variant = "outlined",
|
|
962
|
+
action = "success",
|
|
963
|
+
className = "",
|
|
964
|
+
onClose,
|
|
965
|
+
title,
|
|
966
|
+
description,
|
|
967
|
+
position = "default",
|
|
968
|
+
...props
|
|
969
|
+
}) => {
|
|
970
|
+
const variantClasses = VARIANT_ACTION_CLASSES3[variant][action];
|
|
971
|
+
const positionClasses = {
|
|
972
|
+
"top-left": "fixed top-4 left-4",
|
|
973
|
+
"top-center": "fixed top-4 left-1/2 transform -translate-x-1/2",
|
|
974
|
+
"top-right": "fixed top-4 right-4",
|
|
975
|
+
"bottom-left": "fixed bottom-4 left-4",
|
|
976
|
+
"bottom-center": "fixed bottom-4 left-1/2 transform -translate-x-1/2",
|
|
977
|
+
"bottom-right": "fixed bottom-4 right-4",
|
|
978
|
+
default: ""
|
|
979
|
+
};
|
|
980
|
+
const IconAction = iconMap[action] || iconMap["success"];
|
|
981
|
+
const baseClasses = "max-w-[390px] w-full flex flex-row items-start justify-between shadow-lg rounded-lg border p-4 gap-6 group";
|
|
982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
983
|
+
"div",
|
|
984
|
+
{
|
|
985
|
+
role: "alert",
|
|
986
|
+
"aria-live": "assertive",
|
|
987
|
+
"aria-atomic": "true",
|
|
988
|
+
className: `${baseClasses} ${positionClasses[position]} ${variantClasses} ${className}`,
|
|
989
|
+
...props,
|
|
990
|
+
children: [
|
|
991
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-row items-start gap-3", children: [
|
|
992
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "mt-1", "data-testid": `toast-icon-${action}`, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(IconAction, {}) }),
|
|
993
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col items-start justify-start", children: [
|
|
994
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "font-semibold text-md", children: title }),
|
|
995
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-md text-text-900", children: description })
|
|
996
|
+
] })
|
|
997
|
+
] }),
|
|
998
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
999
|
+
"button",
|
|
1000
|
+
{
|
|
1001
|
+
onClick: onClose,
|
|
1002
|
+
"aria-label": "Dismiss notification",
|
|
1003
|
+
className: "text-background-500 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
|
|
1004
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_phosphor_react3.X, {})
|
|
1005
|
+
}
|
|
1006
|
+
)
|
|
1007
|
+
]
|
|
1008
|
+
}
|
|
1009
|
+
);
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
// src/components/Toast/utils/ToastStore.ts
|
|
1013
|
+
var import_zustand = require("zustand");
|
|
1014
|
+
var useToastStore = (0, import_zustand.create)((set) => ({
|
|
1015
|
+
toasts: [],
|
|
1016
|
+
addToast: (toast) => {
|
|
1017
|
+
const id = crypto.randomUUID();
|
|
1018
|
+
set((state) => ({
|
|
1019
|
+
toasts: [...state.toasts, { id, ...toast }]
|
|
1020
|
+
}));
|
|
1021
|
+
},
|
|
1022
|
+
removeToast: (id) => {
|
|
1023
|
+
set((state) => ({
|
|
1024
|
+
toasts: state.toasts.filter((t) => t.id !== id)
|
|
1025
|
+
}));
|
|
1026
|
+
}
|
|
1027
|
+
}));
|
|
1028
|
+
|
|
1029
|
+
// src/components/Toast/utils/Toaster.tsx
|
|
1030
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1031
|
+
var Toaster = () => {
|
|
1032
|
+
const toasts = useToastStore((state) => state.toasts);
|
|
1033
|
+
const removeToast = useToastStore((state) => state.removeToast);
|
|
1034
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: toasts.map((toast) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1035
|
+
Toast,
|
|
1036
|
+
{
|
|
1037
|
+
title: toast.title,
|
|
1038
|
+
description: toast.description,
|
|
1039
|
+
variant: toast.variant,
|
|
1040
|
+
action: toast.action,
|
|
1041
|
+
position: toast.position,
|
|
1042
|
+
onClose: () => removeToast(toast.id)
|
|
1043
|
+
},
|
|
1044
|
+
toast.id
|
|
1045
|
+
)) });
|
|
1046
|
+
};
|
|
1047
|
+
var useToast = () => {
|
|
1048
|
+
const addToast = useToastStore((state) => state.addToast);
|
|
1049
|
+
const removeToast = useToastStore((state) => state.removeToast);
|
|
1050
|
+
return { addToast, removeToast };
|
|
1051
|
+
};
|
|
937
1052
|
// Annotate the CommonJS export names for ESM import in node:
|
|
938
1053
|
0 && (module.exports = {
|
|
1054
|
+
Badge,
|
|
939
1055
|
Button,
|
|
940
1056
|
CheckBox,
|
|
941
1057
|
DropdownMenu,
|