analytica-frontend-lib 1.0.17 → 1.0.19
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 +201 -0
- package/dist/index.d.mts +81 -2
- package/dist/index.d.ts +81 -2
- package/dist/index.js +254 -41
- package/dist/index.mjs +246 -38
- package/package.json +5 -2
package/dist/index.mjs
CHANGED
|
@@ -206,6 +206,96 @@ var Text = ({
|
|
|
206
206
|
);
|
|
207
207
|
};
|
|
208
208
|
|
|
209
|
+
// src/components/Badge/Badge.tsx
|
|
210
|
+
import { Bell } from "phosphor-react";
|
|
211
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
212
|
+
var VARIANT_ACTION_CLASSES2 = {
|
|
213
|
+
solid: {
|
|
214
|
+
error: "bg-error text-error-700 focus-visible:outline-none",
|
|
215
|
+
warning: "bg-warning text-warning-800 focus-visible:outline-none",
|
|
216
|
+
success: "bg-success text-success-800 focus-visible:outline-none",
|
|
217
|
+
info: "bg-info text-info-800 focus-visible:outline-none",
|
|
218
|
+
muted: "bg-background-muted text-background-800 focus-visible:outline-none"
|
|
219
|
+
},
|
|
220
|
+
outlined: {
|
|
221
|
+
error: "bg-error text-error-700 border border-error-300 focus-visible:outline-none",
|
|
222
|
+
warning: "bg-warning text-warning-800 border border-warning-300 focus-visible:outline-none",
|
|
223
|
+
success: "bg-success text-success-800 border border-success-300 focus-visible:outline-none",
|
|
224
|
+
info: "bg-info text-info-800 border border-info-300 focus-visible:outline-none",
|
|
225
|
+
muted: "bg-background-muted text-background-800 border border-border-300 focus-visible:outline-none"
|
|
226
|
+
},
|
|
227
|
+
exams: {
|
|
228
|
+
exam1: "bg-exame-1 text-info-200 focus-visible:outline-none",
|
|
229
|
+
exam2: "bg-exame-2 text-typography-1 focus-visible:outline-none",
|
|
230
|
+
exam3: "bg-exame-3 text-typography-2 focus-visible:outline-none",
|
|
231
|
+
exam4: "bg-exame-4 text-success-700 focus-visible:outline-none"
|
|
232
|
+
},
|
|
233
|
+
resultStatus: {
|
|
234
|
+
negative: "bg-error text-error-800 focus-visible:outline-none",
|
|
235
|
+
positive: "bg-success text-success-800 focus-visible:outline-none"
|
|
236
|
+
},
|
|
237
|
+
notification: "text-primary"
|
|
238
|
+
};
|
|
239
|
+
var SIZE_CLASSES2 = {
|
|
240
|
+
small: "text-2xs px-2 py-1",
|
|
241
|
+
medium: "text-xs px-2 py-1",
|
|
242
|
+
large: "text-sm px-2 py-1"
|
|
243
|
+
};
|
|
244
|
+
var SIZE_CLASSES_ICON = {
|
|
245
|
+
small: "size-3",
|
|
246
|
+
medium: "size-3.5",
|
|
247
|
+
large: "size-4"
|
|
248
|
+
};
|
|
249
|
+
var Badge = ({
|
|
250
|
+
children,
|
|
251
|
+
iconLeft,
|
|
252
|
+
iconRight,
|
|
253
|
+
size = "medium",
|
|
254
|
+
variant = "solid",
|
|
255
|
+
action = "error",
|
|
256
|
+
className = "",
|
|
257
|
+
notificationActive = false,
|
|
258
|
+
...props
|
|
259
|
+
}) => {
|
|
260
|
+
const sizeClasses = SIZE_CLASSES2[size];
|
|
261
|
+
const sizeClassesIcon = SIZE_CLASSES_ICON[size];
|
|
262
|
+
const variantActionMap = VARIANT_ACTION_CLASSES2[variant] || {};
|
|
263
|
+
const variantClasses = typeof variantActionMap === "string" ? variantActionMap : variantActionMap[action] ?? variantActionMap.muted ?? "";
|
|
264
|
+
const baseClasses = "inline-flex items-center justify-center rounded-xs font-medium gap-1 relative";
|
|
265
|
+
const baseClassesIcon = "flex items-center";
|
|
266
|
+
if (variant === "notification") {
|
|
267
|
+
return /* @__PURE__ */ jsxs3(
|
|
268
|
+
"div",
|
|
269
|
+
{
|
|
270
|
+
className: `${baseClasses} ${variantClasses} ${sizeClasses} ${className}`,
|
|
271
|
+
...props,
|
|
272
|
+
children: [
|
|
273
|
+
/* @__PURE__ */ jsx5(Bell, { size: 24, className: "text-primary-950" }),
|
|
274
|
+
notificationActive && /* @__PURE__ */ jsx5(
|
|
275
|
+
"span",
|
|
276
|
+
{
|
|
277
|
+
"data-testid": "notification-dot",
|
|
278
|
+
className: "absolute top-[5px] right-[10px] block h-2 w-2 rounded-full bg-indicator-error ring-2 ring-white"
|
|
279
|
+
}
|
|
280
|
+
)
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
return /* @__PURE__ */ jsxs3(
|
|
286
|
+
"div",
|
|
287
|
+
{
|
|
288
|
+
className: `${baseClasses} ${variantClasses} ${sizeClasses} ${className}`,
|
|
289
|
+
...props,
|
|
290
|
+
children: [
|
|
291
|
+
iconLeft && /* @__PURE__ */ jsx5("span", { className: `${baseClassesIcon} ${sizeClassesIcon}`, children: iconLeft }),
|
|
292
|
+
children,
|
|
293
|
+
iconRight && /* @__PURE__ */ jsx5("span", { className: `${baseClassesIcon} ${sizeClassesIcon}`, children: iconRight })
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
);
|
|
297
|
+
};
|
|
298
|
+
|
|
209
299
|
// src/components/CheckBox/CheckBox.tsx
|
|
210
300
|
import {
|
|
211
301
|
forwardRef as forwardRef2,
|
|
@@ -213,8 +303,8 @@ import {
|
|
|
213
303
|
useId
|
|
214
304
|
} from "react";
|
|
215
305
|
import { Check, Minus } from "phosphor-react";
|
|
216
|
-
import { jsx as
|
|
217
|
-
var
|
|
306
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
307
|
+
var SIZE_CLASSES3 = {
|
|
218
308
|
small: {
|
|
219
309
|
checkbox: "w-4 h-4",
|
|
220
310
|
// 16px x 16px
|
|
@@ -301,14 +391,14 @@ var CheckBox = forwardRef2(
|
|
|
301
391
|
onChange?.(event);
|
|
302
392
|
};
|
|
303
393
|
const currentState = disabled ? "disabled" : state;
|
|
304
|
-
const sizeClasses =
|
|
394
|
+
const sizeClasses = SIZE_CLASSES3[size];
|
|
305
395
|
const checkVariant = checked || indeterminate ? "checked" : "unchecked";
|
|
306
396
|
const stylingClasses = STATE_CLASSES[currentState][checkVariant];
|
|
307
397
|
const borderWidthClass = state === "focused" || state === "hovered" && size === "large" ? "border-[3px]" : sizeClasses.borderWidth;
|
|
308
398
|
const checkboxClasses = `${BASE_CHECKBOX_CLASSES} ${sizeClasses.checkbox} ${borderWidthClass} ${stylingClasses} ${className}`;
|
|
309
399
|
const renderIcon = () => {
|
|
310
400
|
if (indeterminate) {
|
|
311
|
-
return /* @__PURE__ */
|
|
401
|
+
return /* @__PURE__ */ jsx6(
|
|
312
402
|
Minus,
|
|
313
403
|
{
|
|
314
404
|
size: sizeClasses.iconSize,
|
|
@@ -318,7 +408,7 @@ var CheckBox = forwardRef2(
|
|
|
318
408
|
);
|
|
319
409
|
}
|
|
320
410
|
if (checked) {
|
|
321
|
-
return /* @__PURE__ */
|
|
411
|
+
return /* @__PURE__ */ jsx6(
|
|
322
412
|
Check,
|
|
323
413
|
{
|
|
324
414
|
size: sizeClasses.iconSize,
|
|
@@ -329,13 +419,13 @@ var CheckBox = forwardRef2(
|
|
|
329
419
|
}
|
|
330
420
|
return null;
|
|
331
421
|
};
|
|
332
|
-
return /* @__PURE__ */
|
|
333
|
-
/* @__PURE__ */
|
|
422
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col", children: [
|
|
423
|
+
/* @__PURE__ */ jsxs4(
|
|
334
424
|
"div",
|
|
335
425
|
{
|
|
336
426
|
className: `flex flex-row items-center ${sizeClasses.spacing} ${disabled ? "opacity-40" : ""}`,
|
|
337
427
|
children: [
|
|
338
|
-
/* @__PURE__ */
|
|
428
|
+
/* @__PURE__ */ jsx6(
|
|
339
429
|
"input",
|
|
340
430
|
{
|
|
341
431
|
ref,
|
|
@@ -348,12 +438,12 @@ var CheckBox = forwardRef2(
|
|
|
348
438
|
...props
|
|
349
439
|
}
|
|
350
440
|
),
|
|
351
|
-
/* @__PURE__ */
|
|
352
|
-
label && /* @__PURE__ */
|
|
441
|
+
/* @__PURE__ */ jsx6("label", { htmlFor: inputId, className: checkboxClasses, children: renderIcon() }),
|
|
442
|
+
label && /* @__PURE__ */ jsx6(
|
|
353
443
|
"div",
|
|
354
444
|
{
|
|
355
445
|
className: `flex flex-row items-center ${sizeClasses.labelHeight}`,
|
|
356
|
-
children: /* @__PURE__ */
|
|
446
|
+
children: /* @__PURE__ */ jsx6(
|
|
357
447
|
Text,
|
|
358
448
|
{
|
|
359
449
|
as: "label",
|
|
@@ -370,8 +460,8 @@ var CheckBox = forwardRef2(
|
|
|
370
460
|
]
|
|
371
461
|
}
|
|
372
462
|
),
|
|
373
|
-
errorMessage && /* @__PURE__ */
|
|
374
|
-
helperText && !errorMessage && /* @__PURE__ */
|
|
463
|
+
errorMessage && /* @__PURE__ */ jsx6(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-error-600", children: errorMessage }),
|
|
464
|
+
helperText && !errorMessage && /* @__PURE__ */ jsx6(Text, { size: "sm", weight: "normal", className: "mt-1.5 text-text-500", children: helperText })
|
|
375
465
|
] });
|
|
376
466
|
}
|
|
377
467
|
);
|
|
@@ -379,23 +469,23 @@ CheckBox.displayName = "CheckBox";
|
|
|
379
469
|
|
|
380
470
|
// src/components/Table/Table.tsx
|
|
381
471
|
import { forwardRef as forwardRef3 } from "react";
|
|
382
|
-
import { jsx as
|
|
472
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
383
473
|
var Table = forwardRef3(
|
|
384
|
-
({ className, children, ...props }, ref) => /* @__PURE__ */
|
|
474
|
+
({ className, children, ...props }, ref) => /* @__PURE__ */ jsx7("div", { className: "border border-border-200 rounded-xl relative w-full overflow-hidden", children: /* @__PURE__ */ jsxs5(
|
|
385
475
|
"table",
|
|
386
476
|
{
|
|
387
477
|
ref,
|
|
388
478
|
className: `w-full caption-bottom text-sm ${className ?? ""}`,
|
|
389
479
|
...props,
|
|
390
480
|
children: [
|
|
391
|
-
/* @__PURE__ */
|
|
481
|
+
/* @__PURE__ */ jsx7("caption", { className: "sr-only", children: "My Table" }),
|
|
392
482
|
children
|
|
393
483
|
]
|
|
394
484
|
}
|
|
395
485
|
) })
|
|
396
486
|
);
|
|
397
487
|
Table.displayName = "Table";
|
|
398
|
-
var TableHeader = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */
|
|
488
|
+
var TableHeader = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
399
489
|
"thead",
|
|
400
490
|
{
|
|
401
491
|
ref,
|
|
@@ -404,7 +494,7 @@ var TableHeader = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
404
494
|
}
|
|
405
495
|
));
|
|
406
496
|
TableHeader.displayName = "TableHeader";
|
|
407
|
-
var TableBody = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */
|
|
497
|
+
var TableBody = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
408
498
|
"tbody",
|
|
409
499
|
{
|
|
410
500
|
ref,
|
|
@@ -413,7 +503,7 @@ var TableBody = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ js
|
|
|
413
503
|
}
|
|
414
504
|
));
|
|
415
505
|
TableBody.displayName = "TableBody";
|
|
416
|
-
var TableFooter = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */
|
|
506
|
+
var TableFooter = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
417
507
|
"tfoot",
|
|
418
508
|
{
|
|
419
509
|
ref,
|
|
@@ -430,7 +520,7 @@ var VARIANT_STATES_ROW = {
|
|
|
430
520
|
};
|
|
431
521
|
var TableRow = forwardRef3(
|
|
432
522
|
({ state = "default", className, ...props }, ref) => {
|
|
433
|
-
return /* @__PURE__ */
|
|
523
|
+
return /* @__PURE__ */ jsx7(
|
|
434
524
|
"tr",
|
|
435
525
|
{
|
|
436
526
|
ref,
|
|
@@ -447,7 +537,7 @@ var TableRow = forwardRef3(
|
|
|
447
537
|
}
|
|
448
538
|
);
|
|
449
539
|
TableRow.displayName = "TableRow";
|
|
450
|
-
var TableHead = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */
|
|
540
|
+
var TableHead = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
451
541
|
"th",
|
|
452
542
|
{
|
|
453
543
|
ref,
|
|
@@ -456,7 +546,7 @@ var TableHead = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ js
|
|
|
456
546
|
}
|
|
457
547
|
));
|
|
458
548
|
TableHead.displayName = "TableHead";
|
|
459
|
-
var TableCell = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */
|
|
549
|
+
var TableCell = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
460
550
|
"td",
|
|
461
551
|
{
|
|
462
552
|
ref,
|
|
@@ -465,7 +555,7 @@ var TableCell = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ js
|
|
|
465
555
|
}
|
|
466
556
|
));
|
|
467
557
|
TableCell.displayName = "TableCell";
|
|
468
|
-
var TableCaption = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */
|
|
558
|
+
var TableCaption = forwardRef3(({ className, ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
469
559
|
"caption",
|
|
470
560
|
{
|
|
471
561
|
ref,
|
|
@@ -486,7 +576,7 @@ import {
|
|
|
486
576
|
useRef,
|
|
487
577
|
useMemo
|
|
488
578
|
} from "react";
|
|
489
|
-
import { jsx as
|
|
579
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
490
580
|
var DropdownMenuContext = createContext(
|
|
491
581
|
void 0
|
|
492
582
|
);
|
|
@@ -526,14 +616,14 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
|
526
616
|
() => ({ open: currentOpen, setOpen }),
|
|
527
617
|
[currentOpen, setOpen]
|
|
528
618
|
);
|
|
529
|
-
return /* @__PURE__ */
|
|
619
|
+
return /* @__PURE__ */ jsx8(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ jsx8("div", { className: "relative", ref: menuRef, children }) });
|
|
530
620
|
};
|
|
531
621
|
var DropdownMenuTrigger = forwardRef4(({ className, children, onClick, ...props }, ref) => {
|
|
532
622
|
const context = useContext(DropdownMenuContext);
|
|
533
623
|
if (!context)
|
|
534
624
|
throw new Error("DropdownMenuTrigger must be used within a DropdownMenu");
|
|
535
625
|
const { open, setOpen } = context;
|
|
536
|
-
return /* @__PURE__ */
|
|
626
|
+
return /* @__PURE__ */ jsx8(
|
|
537
627
|
"button",
|
|
538
628
|
{
|
|
539
629
|
ref,
|
|
@@ -565,7 +655,7 @@ var ALIGN_CLASSES = {
|
|
|
565
655
|
center: "left-1/2 -translate-x-1/2",
|
|
566
656
|
end: "right-0"
|
|
567
657
|
};
|
|
568
|
-
var MenuLabel = forwardRef4(({ className, inset, ...props }, ref) => /* @__PURE__ */
|
|
658
|
+
var MenuLabel = forwardRef4(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx8(
|
|
569
659
|
"fieldset",
|
|
570
660
|
{
|
|
571
661
|
ref,
|
|
@@ -600,7 +690,7 @@ var MenuContent = forwardRef4(
|
|
|
600
690
|
const horizontal = ALIGN_CLASSES[align];
|
|
601
691
|
return `absolute ${vertical} ${horizontal}`;
|
|
602
692
|
};
|
|
603
|
-
return /* @__PURE__ */
|
|
693
|
+
return /* @__PURE__ */ jsx8(
|
|
604
694
|
"div",
|
|
605
695
|
{
|
|
606
696
|
ref,
|
|
@@ -645,7 +735,7 @@ var MenuItem = forwardRef4(
|
|
|
645
735
|
}
|
|
646
736
|
onClick?.(e);
|
|
647
737
|
};
|
|
648
|
-
return /* @__PURE__ */
|
|
738
|
+
return /* @__PURE__ */ jsxs6(
|
|
649
739
|
"div",
|
|
650
740
|
{
|
|
651
741
|
ref,
|
|
@@ -674,7 +764,7 @@ var MenuItem = forwardRef4(
|
|
|
674
764
|
}
|
|
675
765
|
);
|
|
676
766
|
MenuItem.displayName = "MenuItem";
|
|
677
|
-
var MenuSeparator = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */
|
|
767
|
+
var MenuSeparator = forwardRef4(({ className, ...props }, ref) => /* @__PURE__ */ jsx8(
|
|
678
768
|
"div",
|
|
679
769
|
{
|
|
680
770
|
ref,
|
|
@@ -686,7 +776,7 @@ MenuSeparator.displayName = "MenuSeparator";
|
|
|
686
776
|
|
|
687
777
|
// src/components/NavButton/NavButton.tsx
|
|
688
778
|
import { forwardRef as forwardRef5 } from "react";
|
|
689
|
-
import { jsx as
|
|
779
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
690
780
|
var NavButton = forwardRef5(
|
|
691
781
|
({ icon, label, selected = false, className = "", disabled, ...props }, ref) => {
|
|
692
782
|
const baseClasses = [
|
|
@@ -714,7 +804,7 @@ var NavButton = forwardRef5(
|
|
|
714
804
|
];
|
|
715
805
|
const stateClasses = selected ? ["bg-primary-50", "text-primary-950"] : [];
|
|
716
806
|
const allClasses = [...baseClasses, ...stateClasses].join(" ");
|
|
717
|
-
return /* @__PURE__ */
|
|
807
|
+
return /* @__PURE__ */ jsxs7(
|
|
718
808
|
"button",
|
|
719
809
|
{
|
|
720
810
|
ref,
|
|
@@ -724,8 +814,8 @@ var NavButton = forwardRef5(
|
|
|
724
814
|
"aria-pressed": selected,
|
|
725
815
|
...props,
|
|
726
816
|
children: [
|
|
727
|
-
/* @__PURE__ */
|
|
728
|
-
/* @__PURE__ */
|
|
817
|
+
/* @__PURE__ */ jsx9("span", { className: "flex items-center justify-center w-5 h-5", children: icon }),
|
|
818
|
+
/* @__PURE__ */ jsx9("span", { className: "whitespace-nowrap", children: label })
|
|
729
819
|
]
|
|
730
820
|
}
|
|
731
821
|
);
|
|
@@ -735,7 +825,7 @@ NavButton.displayName = "NavButton";
|
|
|
735
825
|
|
|
736
826
|
// src/components/IconButton/IconButton.tsx
|
|
737
827
|
import { forwardRef as forwardRef6 } from "react";
|
|
738
|
-
import { jsx as
|
|
828
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
739
829
|
var IconButton = forwardRef6(
|
|
740
830
|
({ icon, size = "md", active = false, className = "", disabled, ...props }, ref) => {
|
|
741
831
|
const baseClasses = [
|
|
@@ -768,7 +858,7 @@ var IconButton = forwardRef6(
|
|
|
768
858
|
...activeClasses
|
|
769
859
|
].join(" ");
|
|
770
860
|
const ariaLabel = props["aria-label"] ?? "Bot\xE3o de a\xE7\xE3o";
|
|
771
|
-
return /* @__PURE__ */
|
|
861
|
+
return /* @__PURE__ */ jsx10(
|
|
772
862
|
"button",
|
|
773
863
|
{
|
|
774
864
|
ref,
|
|
@@ -778,13 +868,127 @@ var IconButton = forwardRef6(
|
|
|
778
868
|
"aria-pressed": active,
|
|
779
869
|
"aria-label": ariaLabel,
|
|
780
870
|
...props,
|
|
781
|
-
children: /* @__PURE__ */
|
|
871
|
+
children: /* @__PURE__ */ jsx10("span", { className: "flex items-center justify-center", children: icon })
|
|
782
872
|
}
|
|
783
873
|
);
|
|
784
874
|
}
|
|
785
875
|
);
|
|
786
876
|
IconButton.displayName = "IconButton";
|
|
877
|
+
|
|
878
|
+
// src/components/Toast/Toast.tsx
|
|
879
|
+
import { CheckCircle, WarningCircle, Info, X } from "phosphor-react";
|
|
880
|
+
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
881
|
+
var VARIANT_ACTION_CLASSES3 = {
|
|
882
|
+
solid: {
|
|
883
|
+
warning: "bg-warning text-warning-800 border-none focus-visible:outline-none",
|
|
884
|
+
success: "bg-success text-success-800 border-none focus-visible:outline-none",
|
|
885
|
+
info: "bg-info text-info-800 border-none focus-visible:outline-none"
|
|
886
|
+
},
|
|
887
|
+
outlined: {
|
|
888
|
+
warning: "bg-warning text-warning-800 border border-warning-200 focus-visible:outline-none",
|
|
889
|
+
success: "bg-success text-success-800 border border-success-200 focus-visible:outline-none",
|
|
890
|
+
info: "bg-info text-info-800 border border-info-200 focus-visible:outline-none"
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
var iconMap = {
|
|
894
|
+
success: CheckCircle,
|
|
895
|
+
info: Info,
|
|
896
|
+
warning: WarningCircle
|
|
897
|
+
};
|
|
898
|
+
var Toast = ({
|
|
899
|
+
variant = "outlined",
|
|
900
|
+
action = "success",
|
|
901
|
+
className = "",
|
|
902
|
+
onClose,
|
|
903
|
+
title,
|
|
904
|
+
description,
|
|
905
|
+
position = "default",
|
|
906
|
+
...props
|
|
907
|
+
}) => {
|
|
908
|
+
const variantClasses = VARIANT_ACTION_CLASSES3[variant][action];
|
|
909
|
+
const positionClasses = {
|
|
910
|
+
"top-left": "fixed top-4 left-4",
|
|
911
|
+
"top-center": "fixed top-4 left-1/2 transform -translate-x-1/2",
|
|
912
|
+
"top-right": "fixed top-4 right-4",
|
|
913
|
+
"bottom-left": "fixed bottom-4 left-4",
|
|
914
|
+
"bottom-center": "fixed bottom-4 left-1/2 transform -translate-x-1/2",
|
|
915
|
+
"bottom-right": "fixed bottom-4 right-4",
|
|
916
|
+
default: ""
|
|
917
|
+
};
|
|
918
|
+
const IconAction = iconMap[action] || iconMap["success"];
|
|
919
|
+
const baseClasses = "max-w-[390px] w-full flex flex-row items-start justify-between shadow-lg rounded-lg border p-4 gap-6 group";
|
|
920
|
+
return /* @__PURE__ */ jsxs8(
|
|
921
|
+
"div",
|
|
922
|
+
{
|
|
923
|
+
role: "alert",
|
|
924
|
+
"aria-live": "assertive",
|
|
925
|
+
"aria-atomic": "true",
|
|
926
|
+
className: `${baseClasses} ${positionClasses[position]} ${variantClasses} ${className}`,
|
|
927
|
+
...props,
|
|
928
|
+
children: [
|
|
929
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-row items-start gap-3", children: [
|
|
930
|
+
/* @__PURE__ */ jsx11("span", { className: "mt-1", "data-testid": `toast-icon-${action}`, children: /* @__PURE__ */ jsx11(IconAction, {}) }),
|
|
931
|
+
/* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-start justify-start", children: [
|
|
932
|
+
/* @__PURE__ */ jsx11("p", { className: "font-semibold text-md", children: title }),
|
|
933
|
+
description && /* @__PURE__ */ jsx11("p", { className: "text-md text-text-900", children: description })
|
|
934
|
+
] })
|
|
935
|
+
] }),
|
|
936
|
+
/* @__PURE__ */ jsx11(
|
|
937
|
+
"button",
|
|
938
|
+
{
|
|
939
|
+
onClick: onClose,
|
|
940
|
+
"aria-label": "Dismiss notification",
|
|
941
|
+
className: "text-background-500 cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity",
|
|
942
|
+
children: /* @__PURE__ */ jsx11(X, {})
|
|
943
|
+
}
|
|
944
|
+
)
|
|
945
|
+
]
|
|
946
|
+
}
|
|
947
|
+
);
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
// src/components/Toast/utils/ToastStore.ts
|
|
951
|
+
import { create } from "zustand";
|
|
952
|
+
var useToastStore = create((set) => ({
|
|
953
|
+
toasts: [],
|
|
954
|
+
addToast: (toast) => {
|
|
955
|
+
const id = crypto.randomUUID();
|
|
956
|
+
set((state) => ({
|
|
957
|
+
toasts: [...state.toasts, { id, ...toast }]
|
|
958
|
+
}));
|
|
959
|
+
},
|
|
960
|
+
removeToast: (id) => {
|
|
961
|
+
set((state) => ({
|
|
962
|
+
toasts: state.toasts.filter((t) => t.id !== id)
|
|
963
|
+
}));
|
|
964
|
+
}
|
|
965
|
+
}));
|
|
966
|
+
|
|
967
|
+
// src/components/Toast/utils/Toaster.tsx
|
|
968
|
+
import { Fragment, jsx as jsx12 } from "react/jsx-runtime";
|
|
969
|
+
var Toaster = () => {
|
|
970
|
+
const toasts = useToastStore((state) => state.toasts);
|
|
971
|
+
const removeToast = useToastStore((state) => state.removeToast);
|
|
972
|
+
return /* @__PURE__ */ jsx12(Fragment, { children: toasts.map((toast) => /* @__PURE__ */ jsx12(
|
|
973
|
+
Toast,
|
|
974
|
+
{
|
|
975
|
+
title: toast.title,
|
|
976
|
+
description: toast.description,
|
|
977
|
+
variant: toast.variant,
|
|
978
|
+
action: toast.action,
|
|
979
|
+
position: toast.position,
|
|
980
|
+
onClose: () => removeToast(toast.id)
|
|
981
|
+
},
|
|
982
|
+
toast.id
|
|
983
|
+
)) });
|
|
984
|
+
};
|
|
985
|
+
var useToast = () => {
|
|
986
|
+
const addToast = useToastStore((state) => state.addToast);
|
|
987
|
+
const removeToast = useToastStore((state) => state.removeToast);
|
|
988
|
+
return { addToast, removeToast };
|
|
989
|
+
};
|
|
787
990
|
export {
|
|
991
|
+
Badge,
|
|
788
992
|
Button,
|
|
789
993
|
CheckBox,
|
|
790
994
|
DropdownMenu,
|
|
@@ -805,5 +1009,9 @@ export {
|
|
|
805
1009
|
TableHead,
|
|
806
1010
|
TableHeader,
|
|
807
1011
|
TableRow,
|
|
808
|
-
Text
|
|
1012
|
+
Text,
|
|
1013
|
+
Toast,
|
|
1014
|
+
Toaster,
|
|
1015
|
+
useToast,
|
|
1016
|
+
useToastStore
|
|
809
1017
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "analytica-frontend-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "Repositório público dos componentes utilizados nas plataformas da Analytica Ensino",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -64,7 +64,10 @@
|
|
|
64
64
|
"react-dom": ">=19.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"phosphor-react": "^1.4.1"
|
|
67
|
+
"phosphor-react": "^1.4.1",
|
|
68
|
+
"react": "^19.1.0",
|
|
69
|
+
"react-dom": "^19.1.0",
|
|
70
|
+
"zustand": "^5.0.5"
|
|
68
71
|
},
|
|
69
72
|
"devDependencies": {
|
|
70
73
|
"@eslint/eslintrc": "^3.3.1",
|