@trackunit/react-components 0.1.250 → 0.1.251
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/index.cjs.js +155 -111
- package/index.esm.js +152 -112
- package/package.json +1 -1
- package/src/components/DayPicker/DayPickerPopover.d.ts +2 -2
- package/src/components/buttons/Button/Button.d.ts +8 -2
- package/src/components/buttons/IconButton/IconButton.d.ts +2 -2
- package/src/components/buttons/shared/Button.variants.d.ts +12 -2
- package/src/components/buttons/shared/ButtonProps.d.ts +3 -8
package/index.cjs.js
CHANGED
|
@@ -485,68 +485,74 @@ const cvaButton = cssClassVarianceUtilities.cvaMerge([
|
|
|
485
485
|
"focus:ring",
|
|
486
486
|
"focus:ring-inset",
|
|
487
487
|
"focus:outline-none",
|
|
488
|
+
"focus:ring-primary-600",
|
|
488
489
|
"disabled:cursor-not-allowed",
|
|
489
|
-
"text-sm",
|
|
490
490
|
"font-medium",
|
|
491
491
|
"align-middle",
|
|
492
|
+
"rounded-md",
|
|
492
493
|
], {
|
|
493
494
|
variants: {
|
|
494
|
-
|
|
495
|
+
variant: {
|
|
495
496
|
primary: [
|
|
497
|
+
"text-white",
|
|
496
498
|
"bg-primary-600",
|
|
499
|
+
"hover:bg-primary-700",
|
|
500
|
+
"active:bg-primary-800",
|
|
501
|
+
"disabled:bg-slate-400",
|
|
502
|
+
"disabled:text-slate-200",
|
|
503
|
+
],
|
|
504
|
+
"primary-danger": [
|
|
497
505
|
"text-white",
|
|
498
|
-
"
|
|
499
|
-
"
|
|
500
|
-
"
|
|
501
|
-
"disabled:hover:bg-slate-400",
|
|
506
|
+
"bg-danger-600",
|
|
507
|
+
"hover:bg-danger-700",
|
|
508
|
+
"active:bg-danger-800",
|
|
502
509
|
"disabled:bg-slate-400",
|
|
503
510
|
"disabled:text-slate-200",
|
|
504
511
|
],
|
|
505
512
|
secondary: [
|
|
506
|
-
"
|
|
507
|
-
"
|
|
508
|
-
"
|
|
509
|
-
"
|
|
510
|
-
"
|
|
511
|
-
"
|
|
512
|
-
"
|
|
513
|
-
"
|
|
514
|
-
"disabled:text-secondary-400",
|
|
515
|
-
],
|
|
516
|
-
danger: [
|
|
517
|
-
"bg-danger-600",
|
|
518
|
-
"text-white",
|
|
519
|
-
"hover:bg-danger-800",
|
|
520
|
-
"active:bg-danger-700",
|
|
521
|
-
"focus:ring-danger-300",
|
|
513
|
+
"bg-white",
|
|
514
|
+
"border",
|
|
515
|
+
"border-slate-300",
|
|
516
|
+
"text-slate-600",
|
|
517
|
+
"hover:bg-slate-100",
|
|
518
|
+
"hover:text-slate-700",
|
|
519
|
+
"active:bg-slate-200",
|
|
520
|
+
"active:text-slate-800",
|
|
522
521
|
"disabled:bg-slate-200",
|
|
523
|
-
"disabled:hover:bg-slate-200",
|
|
524
|
-
"disabled:text-slate-400",
|
|
525
|
-
],
|
|
526
|
-
warning: [
|
|
527
|
-
"bg-warning-50",
|
|
528
|
-
"text-warning-600",
|
|
529
|
-
"hover:bg-warning-200",
|
|
530
|
-
"hover:text-warning-800",
|
|
531
|
-
"active:text-warning-700",
|
|
532
|
-
"active:bg-warning-100",
|
|
533
|
-
"focus:ring-warning-300",
|
|
534
|
-
"disabled:bg-warning-50",
|
|
535
|
-
"disabled:hover:bg-warning-50",
|
|
536
522
|
"disabled:text-slate-400",
|
|
537
523
|
],
|
|
538
|
-
|
|
524
|
+
"secondary-danger": [
|
|
539
525
|
"bg-white",
|
|
540
526
|
"border",
|
|
541
|
-
"text-slate-600",
|
|
542
|
-
"active:bg-slate-100",
|
|
543
|
-
"active:text-slate-700",
|
|
544
|
-
"focus:ring-slate-300",
|
|
545
|
-
"hover:bg-slate-200",
|
|
546
|
-
"hover:text-slate-800",
|
|
547
527
|
"border-slate-300",
|
|
548
|
-
"
|
|
549
|
-
"
|
|
528
|
+
"text-danger-600",
|
|
529
|
+
"hover:bg-danger-100",
|
|
530
|
+
"hover:text-danger-700",
|
|
531
|
+
"hover:border-danger-700",
|
|
532
|
+
"active:bg-danger-200",
|
|
533
|
+
"active:text-danger-800",
|
|
534
|
+
"active:border-danger-800",
|
|
535
|
+
"disabled:bg-slate-300",
|
|
536
|
+
"disabled:text-slate-400",
|
|
537
|
+
],
|
|
538
|
+
ghost: [
|
|
539
|
+
"bg-transparent",
|
|
540
|
+
"text-primary-600",
|
|
541
|
+
"hover:bg-black/5",
|
|
542
|
+
"hover:text-primary-700",
|
|
543
|
+
"active:bg-black/10",
|
|
544
|
+
"active:text-primary-800",
|
|
545
|
+
"disabled:bg-transparent",
|
|
546
|
+
"disabled:text-slate-400",
|
|
547
|
+
],
|
|
548
|
+
"ghost-neutral": [
|
|
549
|
+
"bg-transparent",
|
|
550
|
+
"text-slate-600",
|
|
551
|
+
"hover:bg-black/5",
|
|
552
|
+
"hover:text-slate-700",
|
|
553
|
+
"active:bg-black/10",
|
|
554
|
+
"active:text-slate-800",
|
|
555
|
+
"disabled:bg-transparent",
|
|
550
556
|
"disabled:text-slate-400",
|
|
551
557
|
],
|
|
552
558
|
},
|
|
@@ -566,9 +572,17 @@ const cvaButton = cssClassVarianceUtilities.cvaMerge([
|
|
|
566
572
|
* So we need to add padding to the min-height calculation. Two times the vertical
|
|
567
573
|
* padding aka py-1 * 2 aka --spacing-1 * 2 aka spacing-2 (for small).
|
|
568
574
|
*/
|
|
569
|
-
small: ["py-1", "
|
|
570
|
-
medium: ["py-1.5", "
|
|
571
|
-
large: [
|
|
575
|
+
small: ["px-2", "py-1.5", "gap-1", "h-7", "text-xs", "min-h-[calc(var(--line-height-sm)+var(--spacing-2))]"],
|
|
576
|
+
medium: ["px-3", "py-1.5", "gap-2", "h-8", "text-sm", "min-h-[calc(var(--line-height-sm)+var(--spacing-3))]"],
|
|
577
|
+
large: [
|
|
578
|
+
"px-4",
|
|
579
|
+
"py-2",
|
|
580
|
+
"h-10",
|
|
581
|
+
"gap-2",
|
|
582
|
+
"text-base",
|
|
583
|
+
"rounded-lg",
|
|
584
|
+
"min-h-[calc(var(--line-height-sm)+var(--spacing-4))]",
|
|
585
|
+
],
|
|
572
586
|
},
|
|
573
587
|
rounded: {
|
|
574
588
|
true: ["rounded-full"],
|
|
@@ -586,9 +600,9 @@ const cvaButton = cssClassVarianceUtilities.cvaMerge([
|
|
|
586
600
|
true: ["cursor-not-allowed", "pointer-events-none", "bg-slate-200", "hover:bg-slate-200", "text-slate-400"],
|
|
587
601
|
false: [],
|
|
588
602
|
},
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
603
|
+
loading: {
|
|
604
|
+
true: ["bg-transparent"],
|
|
605
|
+
false: [],
|
|
592
606
|
},
|
|
593
607
|
},
|
|
594
608
|
compoundVariants: [
|
|
@@ -608,88 +622,105 @@ const cvaButton = cssClassVarianceUtilities.cvaMerge([
|
|
|
608
622
|
className: ["p-2"],
|
|
609
623
|
},
|
|
610
624
|
{
|
|
611
|
-
|
|
612
|
-
variant: "
|
|
613
|
-
className: [
|
|
614
|
-
"text-primary-600",
|
|
615
|
-
"hover:text-primary-700",
|
|
616
|
-
"active:bg-primary-700",
|
|
617
|
-
"focus:ring-primary-300",
|
|
618
|
-
"hover:bg-primary-500/10",
|
|
619
|
-
],
|
|
625
|
+
loading: true,
|
|
626
|
+
variant: "primary",
|
|
627
|
+
className: ['disabled:bg-primary-600'],
|
|
620
628
|
},
|
|
621
629
|
{
|
|
622
|
-
|
|
623
|
-
variant: "
|
|
624
|
-
className: [
|
|
625
|
-
"text-secondary-600",
|
|
626
|
-
"hover:text-secondary-800",
|
|
627
|
-
"active:text-secondary-700",
|
|
628
|
-
"active:bg-black/10",
|
|
629
|
-
"focus:ring-secondary-300",
|
|
630
|
-
"hover:bg-black/5",
|
|
631
|
-
],
|
|
632
|
-
},
|
|
633
|
-
{
|
|
634
|
-
color: "warning",
|
|
635
|
-
variant: "transparent",
|
|
636
|
-
className: [
|
|
637
|
-
"text-warning-600",
|
|
638
|
-
"active:bg-warning-500/20",
|
|
639
|
-
"focus:ring-warning-300",
|
|
640
|
-
"hover:bg-warning-500/10",
|
|
641
|
-
],
|
|
630
|
+
loading: true,
|
|
631
|
+
variant: "primary-danger",
|
|
632
|
+
className: ["disabled:bg-danger-600"],
|
|
642
633
|
},
|
|
643
634
|
{
|
|
644
|
-
|
|
645
|
-
variant: "
|
|
646
|
-
className: ["
|
|
635
|
+
loading: true,
|
|
636
|
+
variant: "secondary",
|
|
637
|
+
className: ["disabled:bg-white"],
|
|
647
638
|
},
|
|
648
639
|
{
|
|
649
|
-
|
|
650
|
-
variant: "
|
|
651
|
-
className: ["
|
|
652
|
-
},
|
|
653
|
-
{
|
|
654
|
-
disabled: true,
|
|
655
|
-
variant: "transparent",
|
|
656
|
-
className: ["cursor-not-allowed", "pointer-events-none", "hover:bg-transparent"],
|
|
640
|
+
loading: true,
|
|
641
|
+
variant: "secondary-danger",
|
|
642
|
+
className: ["disabled:bg-white"],
|
|
657
643
|
},
|
|
658
644
|
],
|
|
659
645
|
defaultVariants: {
|
|
660
|
-
|
|
646
|
+
variant: "primary",
|
|
661
647
|
size: "medium",
|
|
662
648
|
rounded: false,
|
|
663
649
|
fullWidth: false,
|
|
664
650
|
square: false,
|
|
665
651
|
disabled: false,
|
|
666
|
-
|
|
652
|
+
},
|
|
653
|
+
});
|
|
654
|
+
const cvaButtonSpinnerContainer = cssClassVarianceUtilities.cvaMerge(["p-0", "h-auto"]);
|
|
655
|
+
const cvaButtonSpinner = cssClassVarianceUtilities.cvaMerge([], {
|
|
656
|
+
variants: {
|
|
657
|
+
variant: {
|
|
658
|
+
primary: ["border-white/[0.32]", "border-b-white"],
|
|
659
|
+
"primary-danger": ["border-white/[0.32]", "border-b-white"],
|
|
660
|
+
secondary: ['h-3.5', 'w-3.5'],
|
|
661
|
+
"secondary-danger": ['h-3.5', 'w-3.5'],
|
|
662
|
+
ghost: [],
|
|
663
|
+
"ghost-neutral": [],
|
|
664
|
+
},
|
|
665
|
+
},
|
|
666
|
+
defaultVariants: {
|
|
667
|
+
variant: "primary",
|
|
668
|
+
},
|
|
669
|
+
});
|
|
670
|
+
const cvaButtonPrefixSuffix = cssClassVarianceUtilities.cvaMerge(["flex", "items-center"], {
|
|
671
|
+
variants: {
|
|
672
|
+
size: {
|
|
673
|
+
small: ["h-4"],
|
|
674
|
+
medium: ["h-4"],
|
|
675
|
+
large: ["h-5"],
|
|
676
|
+
},
|
|
677
|
+
},
|
|
678
|
+
defaultVariants: {
|
|
679
|
+
size: "medium",
|
|
680
|
+
},
|
|
681
|
+
});
|
|
682
|
+
const cvaIconButton = cssClassVarianceUtilities.cvaMerge([], {
|
|
683
|
+
variants: {
|
|
684
|
+
size: {
|
|
685
|
+
small: ["p-1.5", "w-7", "h-7"],
|
|
686
|
+
medium: ["p-2", "w-8", "h-8"],
|
|
687
|
+
large: ["p-2.5", "w-10", "h-10"],
|
|
688
|
+
},
|
|
689
|
+
},
|
|
690
|
+
defaultVariants: {
|
|
691
|
+
size: "medium",
|
|
667
692
|
},
|
|
668
693
|
});
|
|
669
694
|
|
|
670
695
|
/**
|
|
671
|
-
* Buttons allow users to
|
|
672
|
-
|
|
696
|
+
* Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. Button labels express what action will occur when the user interacts with it.
|
|
697
|
+
*
|
|
698
|
+
* ### When to use
|
|
699
|
+
* Use buttons to communicate actions users can take and to allow users to interact with the page. Each page should have one primary button, and any remaining calls to action should be represented as lower emphasis buttons.
|
|
700
|
+
*
|
|
701
|
+
* ### When not to use
|
|
702
|
+
* Do not use buttons as navigational elements. Instead, use [Links](https://www.notion.so/Links-49638788b6c042698b40b94a318361f1?pvs=21) when the desired action is to take the user to a new page.
|
|
703
|
+
*
|
|
673
704
|
* @param {ButtonProps} props - The props for the Button component
|
|
674
705
|
* @returns {JSX.Element} Button component
|
|
675
706
|
*/
|
|
676
707
|
const Button = React__namespace.forwardRef((_a, ref) => {
|
|
677
|
-
var { onClick, children, loading, disabled, className, fullWidth = false, prefix, suffix,
|
|
708
|
+
var { onClick, children, loading, disabled, className, fullWidth = false, prefix, suffix, variant = "primary", type = "button", size = "medium", square = false, dataTestId, title, role, tabIndex, renderAs = "button", circular } = _a, rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "variant", "type", "size", "square", "dataTestId", "title", "role", "tabIndex", "renderAs", "circular"]);
|
|
678
709
|
return React__namespace.createElement(renderAs, Object.assign({ ref,
|
|
679
710
|
title,
|
|
680
711
|
type,
|
|
681
712
|
role,
|
|
682
713
|
onClick,
|
|
683
|
-
tabIndex, disabled: disabled || loading, className: cvaButton({ rounded: circular, disabled, size, square,
|
|
714
|
+
tabIndex, disabled: disabled || loading, className: cvaButton({ rounded: circular, disabled, size, square, variant, loading, fullWidth, className }), "aria-label": title, "data-testid": dataTestId }, rest), jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [loading ? (jsxRuntime.jsx(Spinner, { size: "small", centering: "vertically", containerClassName: cvaButtonSpinnerContainer(), className: cvaButtonSpinner({ variant }) })) : null, prefix && !loading ? jsxRuntime.jsx("div", { className: cvaButtonPrefixSuffix({ size: size }), children: prefix }) : null, children, suffix && !loading ? jsxRuntime.jsx("div", { className: cvaButtonPrefixSuffix({ size: size }), children: suffix }) : null] }));
|
|
684
715
|
});
|
|
685
716
|
Button.displayName = "Button";
|
|
686
717
|
|
|
687
718
|
/**
|
|
688
|
-
*
|
|
719
|
+
* Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. The Icon Button is a version of the standard Button component without the text label.
|
|
689
720
|
*/
|
|
690
721
|
const IconButton = React__namespace.forwardRef((_a, ref) => {
|
|
691
|
-
var { icon, size = "
|
|
692
|
-
return (jsxRuntime.jsx(Button, Object.assign({ size: size, prefix: !loading ? icon : undefined, square: square, loading: loading, disabled: disabled || loading, ref: ref }, rest)));
|
|
722
|
+
var { icon, size = "medium", square = true, loading, disabled, className } = _a, rest = __rest(_a, ["icon", "size", "square", "loading", "disabled", "className"]);
|
|
723
|
+
return (jsxRuntime.jsx(Button, Object.assign({ size: size, prefix: !loading ? icon : undefined, square: square, loading: loading, disabled: disabled || loading, ref: ref, className: cvaIconButton({ size: size, className }) }, rest)));
|
|
693
724
|
});
|
|
694
725
|
IconButton.displayName = "IconButton";
|
|
695
726
|
|
|
@@ -722,6 +753,16 @@ const cvaAlertContentContainer = cssClassVarianceUtilities.cvaMerge(["flex", "fl
|
|
|
722
753
|
const cvaAlertCloseButtonContainer = cssClassVarianceUtilities.cvaMerge(["flex", "self-start", "w-min", "shrink-0"]);
|
|
723
754
|
const cvaAlertIconContainer = cssClassVarianceUtilities.cvaMerge(["self-start", "shrink-0", "grid", "w-min", "hidden", "@2xs:block"]);
|
|
724
755
|
|
|
756
|
+
const getSecondaryActionVariant = (color) => {
|
|
757
|
+
switch (color) {
|
|
758
|
+
case "danger":
|
|
759
|
+
return "secondary-danger";
|
|
760
|
+
case "warning":
|
|
761
|
+
return "ghost-neutral";
|
|
762
|
+
default:
|
|
763
|
+
return "ghost";
|
|
764
|
+
}
|
|
765
|
+
};
|
|
725
766
|
/**
|
|
726
767
|
* The Alert component should be used to inform the user of important information.
|
|
727
768
|
|
|
@@ -747,9 +788,9 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
747
788
|
const getButtonColor = () => {
|
|
748
789
|
switch (color) {
|
|
749
790
|
case "danger":
|
|
750
|
-
return "danger";
|
|
791
|
+
return "primary-danger";
|
|
751
792
|
case "warning":
|
|
752
|
-
return "
|
|
793
|
+
return "secondary-danger";
|
|
753
794
|
default:
|
|
754
795
|
return "primary";
|
|
755
796
|
}
|
|
@@ -761,7 +802,7 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
761
802
|
(_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
762
803
|
}
|
|
763
804
|
}, [ref, autoScroll]);
|
|
764
|
-
return (jsxRuntime.jsxs("div", { className: cvaAlert({ color, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxRuntime.jsxs("div", { className: cvaAlertContentContainer(), children: [jsxRuntime.jsx("div", { className: cvaAlertIconContainer(), children: getIconFromColor() }), jsxRuntime.jsxs("div", { className: cvaContent(), children: [title ? jsxRuntime.jsx(Text, { weight: "bold", children: title }) : null, children ? (jsxRuntime.jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight: !title ? "bold" : "normal", children: children })) : null] }), onClose ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer(), children: jsxRuntime.jsx(IconButton, { size: "small", variant: "
|
|
805
|
+
return (jsxRuntime.jsxs("div", { className: cvaAlert({ color, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxRuntime.jsxs("div", { className: cvaAlertContentContainer(), children: [jsxRuntime.jsx("div", { className: cvaAlertIconContainer(), children: getIconFromColor() }), jsxRuntime.jsxs("div", { className: cvaContent(), children: [title ? jsxRuntime.jsx(Text, { weight: "bold", children: title }) : null, children ? (jsxRuntime.jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight: !title ? "bold" : "normal", children: children })) : null] }), onClose ? (jsxRuntime.jsx("div", { className: cvaAlertCloseButtonContainer(), children: jsxRuntime.jsx(IconButton, { size: "small", variant: "ghost-neutral", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), title: "Close Alert", circular: true }) })) : null] }), primaryAction || secondaryAction ? (jsxRuntime.jsxs("div", { className: cvaAlertActionsContainer(), children: [secondaryAction ? (jsxRuntime.jsx(Button, { size: "small", variant: getSecondaryActionVariant(color), onClick: secondaryAction.onClick, loading: secondaryAction.loading, children: secondaryAction.label })) : null, primaryAction ? (jsxRuntime.jsx(Button, { size: "small", variant: getButtonColor(), onClick: primaryAction.onClick, loading: primaryAction.loading, children: primaryAction.label })) : null] })) : null] }));
|
|
765
806
|
};
|
|
766
807
|
|
|
767
808
|
const cvaBadge = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -1004,7 +1045,7 @@ const CardHeader = ({ heading, headingVariant = "primary", subHeading, onClose,
|
|
|
1004
1045
|
density,
|
|
1005
1046
|
border: hideSeparator ? "borderless" : "default",
|
|
1006
1047
|
className,
|
|
1007
|
-
}), children: jsxRuntime.jsxs("div", { className: cvaCardHeader(), children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsxRuntime.jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading ? (jsxRuntime.jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })) : null, children] }), jsxRuntime.jsxs("div", { className: "flex gap-x-2 gap-y-1", children: [actions, onClose ? (jsxRuntime.jsx(IconButton, { dataTestId: "card-header-close-button", variant: "
|
|
1048
|
+
}), children: jsxRuntime.jsxs("div", { className: cvaCardHeader(), children: [jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsxRuntime.jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading ? (jsxRuntime.jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })) : null, children] }), jsxRuntime.jsxs("div", { className: "flex gap-x-2 gap-y-1", children: [actions, onClose ? (jsxRuntime.jsx(IconButton, { dataTestId: "card-header-close-button", variant: "ghost-neutral", onClick: onClose, icon: jsxRuntime.jsx(Icon, { name: "XMark", size: "small" }), className: "!h-min" })) : null] })] }) }));
|
|
1008
1049
|
};
|
|
1009
1050
|
|
|
1010
1051
|
const cvaCollapse = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -1048,7 +1089,7 @@ const Collapse = ({ id, initialExpanded = false, onToggle, label, children, clas
|
|
|
1048
1089
|
}
|
|
1049
1090
|
setExpanded(!expanded);
|
|
1050
1091
|
}, [expanded, onToggle]);
|
|
1051
|
-
return (jsxRuntime.jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaCollapseHeader({ expanded }), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick, children: [jsxRuntime.jsxs("div", { className: cvaCollapseLabelContainer(), children: [jsxRuntime.jsx(Text, { type: "span", weight: "bold", children: label }), jsxRuntime.jsx(IconButton, { icon: jsxRuntime.jsx(Icon, { name: "ChevronUpDown", size: "small" }), size: "medium", variant: "
|
|
1092
|
+
return (jsxRuntime.jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaCollapseHeader({ expanded }), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick, children: [jsxRuntime.jsxs("div", { className: cvaCollapseLabelContainer(), children: [jsxRuntime.jsx(Text, { type: "span", weight: "bold", children: label }), jsxRuntime.jsx(IconButton, { icon: jsxRuntime.jsx(Icon, { name: "ChevronUpDown", size: "small" }), size: "medium", variant: "ghost-neutral" })] }), headerAddon ? headerAddon : null] }), jsxRuntime.jsx(Collapsible, { expanded: expanded, id: id, children: children })] }));
|
|
1052
1093
|
};
|
|
1053
1094
|
const Collapsible = ({ children, expanded, id }) => {
|
|
1054
1095
|
const [ref, { height }] = reactUse.useMeasure();
|
|
@@ -1277,7 +1318,7 @@ const PopoverTrigger = React.forwardRef(function PopoverTrigger(_a, propRef) {
|
|
|
1277
1318
|
* @returns {JSX.Element} DayPickerPopover component
|
|
1278
1319
|
*/
|
|
1279
1320
|
const DayPickerPopover = ({ disabledDays, className, dataTestId, selectedDay, onDaySelect, color = "secondary", placement, size = "small", buttonContent, language, }) => {
|
|
1280
|
-
return (jsxRuntime.jsxs(Popover, { placement: placement, children: [jsxRuntime.jsx(PopoverTrigger, { children: jsxRuntime.jsx(Button, {
|
|
1321
|
+
return (jsxRuntime.jsxs(Popover, { placement: placement, children: [jsxRuntime.jsx(PopoverTrigger, { children: jsxRuntime.jsx(Button, { variant: color, size: size, className: className, prefix: jsxRuntime.jsx(Icon, { name: "Calendar", size: "small" }), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "show-day-picker", children: buttonContent }) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsx(Card, { children: jsxRuntime.jsx(DayPicker, { disabledDays: disabledDays, onDaySelect: onDaySelect, selectedDays: selectedDay, language: language }) }) })] }));
|
|
1281
1322
|
};
|
|
1282
1323
|
|
|
1283
1324
|
/**
|
|
@@ -1791,7 +1832,7 @@ const MoreMenu = ({ className, dataTestId, popoverProps, iconProps = {
|
|
|
1791
1832
|
size: "small",
|
|
1792
1833
|
circular: true,
|
|
1793
1834
|
square: true,
|
|
1794
|
-
|
|
1835
|
+
variant: "secondary",
|
|
1795
1836
|
}, customButton, customPortalId, children, }) => {
|
|
1796
1837
|
const actionMenuRef = React.useRef(null);
|
|
1797
1838
|
return (jsxRuntime.jsx("div", { ref: actionMenuRef, className: cvaMoreMenu({ className }), "data-testid": dataTestId, children: jsxRuntime.jsxs(Popover, Object.assign({}, popoverProps, { children: [jsxRuntime.jsx(PopoverTrigger, { children: customButton !== null && customButton !== void 0 ? customButton : jsxRuntime.jsx(IconButton, Object.assign({}, iconButtonProps, { icon: jsxRuntime.jsx(Icon, Object.assign({ name: "EllipsisHorizontal" }, iconProps)) })) }), jsxRuntime.jsx(PopoverContent, { portalId: customPortalId, children: close => (typeof children === "function" ? children(close) : children) })] })) }));
|
|
@@ -1946,7 +1987,7 @@ const PageHeader = ({ className, dataTestId, action, showLoading, description, l
|
|
|
1946
1987
|
return (jsxRuntime.jsxs("div", { className: cvaPageHeaderContainer({
|
|
1947
1988
|
className,
|
|
1948
1989
|
withBorder: !tabsList,
|
|
1949
|
-
}), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeader(), children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId ? `${dataTestId}-heading-container` : undefined, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo ? (jsxRuntime.jsx(IconButton, { to: backTo, renderAs: reactRouterDom.Link,
|
|
1990
|
+
}), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeader(), children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId ? `${dataTestId}-heading-container` : undefined, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo ? (jsxRuntime.jsx(IconButton, { to: backTo, renderAs: reactRouterDom.Link, variant: "ghost-neutral", size: "small", icon: jsxRuntime.jsx(Icon, { name: "ArrowLeft" }) })) : undefined, jsxRuntime.jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId ? `${dataTestId}-heading` : undefined, children: title }), description && !showLoading ? (jsxRuntime.jsxs("div", { className: cvaPageHeaderDescriptionAndLinkContainer(), children: [jsxRuntime.jsx(Tooltip, { label: description, dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, iconProps: { name: "QuestionMarkCircle" }, placement: "bottom" }), link ? (jsxRuntime.jsxs(reactRouterDom.Link, { to: link, "data-testid": "tooltip-link", target: "_blank", className: cvaPageHeaderLink(), children: [linkText, jsxRuntime.jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" })] })) : undefined] })) : undefined] }), tag && !showLoading ? (jsxRuntime.jsx(Tag, { dataTestId: dataTestId ? `${dataTestId}-tag` : undefined, color: tagColor, children: tag })) : undefined, showLoading ? (jsxRuntime.jsx(Spinner, { dataTestId: dataTestId ? `${dataTestId}-spinner` : undefined, centering: "vertically" })) : null, action] }), children ? jsxRuntime.jsx("div", { className: cvaPageHeaderChildContainer(), children: children }) : null] }), tabsList] }));
|
|
1950
1991
|
};
|
|
1951
1992
|
|
|
1952
1993
|
const cvaPagination = cssClassVarianceUtilities.cvaMerge(["flex", "items-center", "gap-1"]);
|
|
@@ -1995,9 +2036,9 @@ const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, page
|
|
|
1995
2036
|
if (loading) {
|
|
1996
2037
|
return (jsxRuntime.jsx("div", { className: cvaPagination({ className }), children: jsxRuntime.jsx(SkeletonLines, { height: 16, width: 150 }) }));
|
|
1997
2038
|
}
|
|
1998
|
-
return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: cvaPagination({ className }), children: [jsxRuntime.jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsxRuntime.jsx(Icon, { name: "ChevronLeft", size: "small" }), size: "small",
|
|
2039
|
+
return (jsxRuntime.jsxs("div", { "data-testid": dataTestId, className: cvaPagination({ className }), children: [jsxRuntime.jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsxRuntime.jsx(Icon, { name: "ChevronLeft", size: "small" }), size: "small", variant: "ghost-neutral" }), !cursorBase && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: cvaPaginationText(), "data-testid": "current-page", children: currentPage }), jsxRuntime.jsx("div", { className: cvaPaginationText(), "data-testid": "page-count", children: pageCount !== null && pageCount !== undefined && getTranslatedCount ? getTranslatedCount(pageCount) : null })] })), jsxRuntime.jsx(IconButton, { onClick: () => handlePageChange("next"), disabled: cursorBase
|
|
1999
2040
|
? !canNextPage || false
|
|
2000
|
-
: page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsxRuntime.jsx(Icon, { name: "ChevronRight", size: "small" }), size: "small",
|
|
2041
|
+
: page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsxRuntime.jsx(Icon, { name: "ChevronRight", size: "small" }), size: "small", variant: "ghost-neutral" })] }));
|
|
2001
2042
|
};
|
|
2002
2043
|
|
|
2003
2044
|
function useConfirmExit(confirmExit, when = true) {
|
|
@@ -2192,8 +2233,7 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
2192
2233
|
});
|
|
2193
2234
|
}) }), overflowItemCount > 0 ? (jsxRuntime.jsx(MoreMenu, Object.assign({ iconButtonProps: {
|
|
2194
2235
|
circular: false,
|
|
2195
|
-
variant: "
|
|
2196
|
-
color: "secondary",
|
|
2236
|
+
variant: "ghost-neutral",
|
|
2197
2237
|
}, popoverProps: { placement: "bottom-end" } }, moreMenuProps, { className: `${(moreMenuProps === null || moreMenuProps === void 0 ? void 0 : moreMenuProps.className) || ""} !p-0`, dataTestId: dataTestId ? `${dataTestId}-more-menu` : undefined, children: close => (jsxRuntime.jsx(MenuList, Object.assign({}, menuListProps, { dataTestId: dataTestId ? `${dataTestId}-menu-list` : undefined, children: React__default["default"].Children.map(children, child => {
|
|
2198
2238
|
return itemOverflowMap[child.props.id]
|
|
2199
2239
|
? React__default["default"].cloneElement(child, {
|
|
@@ -3075,7 +3115,11 @@ exports.Tooltip = Tooltip;
|
|
|
3075
3115
|
exports.ValueBar = ValueBar;
|
|
3076
3116
|
exports.WidgetBody = WidgetBody;
|
|
3077
3117
|
exports.cvaButton = cvaButton;
|
|
3118
|
+
exports.cvaButtonPrefixSuffix = cvaButtonPrefixSuffix;
|
|
3119
|
+
exports.cvaButtonSpinner = cvaButtonSpinner;
|
|
3120
|
+
exports.cvaButtonSpinnerContainer = cvaButtonSpinnerContainer;
|
|
3078
3121
|
exports.cvaClickable = cvaClickable;
|
|
3122
|
+
exports.cvaIconButton = cvaIconButton;
|
|
3079
3123
|
exports.cvaIndicator = cvaIndicator;
|
|
3080
3124
|
exports.cvaIndicatorIcon = cvaIndicatorIcon;
|
|
3081
3125
|
exports.cvaIndicatorIconBackground = cvaIndicatorIconBackground;
|
package/index.esm.js
CHANGED
|
@@ -454,68 +454,74 @@ const cvaButton = cvaMerge([
|
|
|
454
454
|
"focus:ring",
|
|
455
455
|
"focus:ring-inset",
|
|
456
456
|
"focus:outline-none",
|
|
457
|
+
"focus:ring-primary-600",
|
|
457
458
|
"disabled:cursor-not-allowed",
|
|
458
|
-
"text-sm",
|
|
459
459
|
"font-medium",
|
|
460
460
|
"align-middle",
|
|
461
|
+
"rounded-md",
|
|
461
462
|
], {
|
|
462
463
|
variants: {
|
|
463
|
-
|
|
464
|
+
variant: {
|
|
464
465
|
primary: [
|
|
466
|
+
"text-white",
|
|
465
467
|
"bg-primary-600",
|
|
468
|
+
"hover:bg-primary-700",
|
|
469
|
+
"active:bg-primary-800",
|
|
470
|
+
"disabled:bg-slate-400",
|
|
471
|
+
"disabled:text-slate-200",
|
|
472
|
+
],
|
|
473
|
+
"primary-danger": [
|
|
466
474
|
"text-white",
|
|
467
|
-
"
|
|
468
|
-
"
|
|
469
|
-
"
|
|
470
|
-
"disabled:hover:bg-slate-400",
|
|
475
|
+
"bg-danger-600",
|
|
476
|
+
"hover:bg-danger-700",
|
|
477
|
+
"active:bg-danger-800",
|
|
471
478
|
"disabled:bg-slate-400",
|
|
472
479
|
"disabled:text-slate-200",
|
|
473
480
|
],
|
|
474
481
|
secondary: [
|
|
475
|
-
"
|
|
476
|
-
"
|
|
477
|
-
"
|
|
478
|
-
"
|
|
479
|
-
"
|
|
480
|
-
"
|
|
481
|
-
"
|
|
482
|
-
"
|
|
483
|
-
"disabled:text-secondary-400",
|
|
484
|
-
],
|
|
485
|
-
danger: [
|
|
486
|
-
"bg-danger-600",
|
|
487
|
-
"text-white",
|
|
488
|
-
"hover:bg-danger-800",
|
|
489
|
-
"active:bg-danger-700",
|
|
490
|
-
"focus:ring-danger-300",
|
|
482
|
+
"bg-white",
|
|
483
|
+
"border",
|
|
484
|
+
"border-slate-300",
|
|
485
|
+
"text-slate-600",
|
|
486
|
+
"hover:bg-slate-100",
|
|
487
|
+
"hover:text-slate-700",
|
|
488
|
+
"active:bg-slate-200",
|
|
489
|
+
"active:text-slate-800",
|
|
491
490
|
"disabled:bg-slate-200",
|
|
492
|
-
"disabled:hover:bg-slate-200",
|
|
493
|
-
"disabled:text-slate-400",
|
|
494
|
-
],
|
|
495
|
-
warning: [
|
|
496
|
-
"bg-warning-50",
|
|
497
|
-
"text-warning-600",
|
|
498
|
-
"hover:bg-warning-200",
|
|
499
|
-
"hover:text-warning-800",
|
|
500
|
-
"active:text-warning-700",
|
|
501
|
-
"active:bg-warning-100",
|
|
502
|
-
"focus:ring-warning-300",
|
|
503
|
-
"disabled:bg-warning-50",
|
|
504
|
-
"disabled:hover:bg-warning-50",
|
|
505
491
|
"disabled:text-slate-400",
|
|
506
492
|
],
|
|
507
|
-
|
|
493
|
+
"secondary-danger": [
|
|
508
494
|
"bg-white",
|
|
509
495
|
"border",
|
|
510
|
-
"text-slate-600",
|
|
511
|
-
"active:bg-slate-100",
|
|
512
|
-
"active:text-slate-700",
|
|
513
|
-
"focus:ring-slate-300",
|
|
514
|
-
"hover:bg-slate-200",
|
|
515
|
-
"hover:text-slate-800",
|
|
516
496
|
"border-slate-300",
|
|
517
|
-
"
|
|
518
|
-
"
|
|
497
|
+
"text-danger-600",
|
|
498
|
+
"hover:bg-danger-100",
|
|
499
|
+
"hover:text-danger-700",
|
|
500
|
+
"hover:border-danger-700",
|
|
501
|
+
"active:bg-danger-200",
|
|
502
|
+
"active:text-danger-800",
|
|
503
|
+
"active:border-danger-800",
|
|
504
|
+
"disabled:bg-slate-300",
|
|
505
|
+
"disabled:text-slate-400",
|
|
506
|
+
],
|
|
507
|
+
ghost: [
|
|
508
|
+
"bg-transparent",
|
|
509
|
+
"text-primary-600",
|
|
510
|
+
"hover:bg-black/5",
|
|
511
|
+
"hover:text-primary-700",
|
|
512
|
+
"active:bg-black/10",
|
|
513
|
+
"active:text-primary-800",
|
|
514
|
+
"disabled:bg-transparent",
|
|
515
|
+
"disabled:text-slate-400",
|
|
516
|
+
],
|
|
517
|
+
"ghost-neutral": [
|
|
518
|
+
"bg-transparent",
|
|
519
|
+
"text-slate-600",
|
|
520
|
+
"hover:bg-black/5",
|
|
521
|
+
"hover:text-slate-700",
|
|
522
|
+
"active:bg-black/10",
|
|
523
|
+
"active:text-slate-800",
|
|
524
|
+
"disabled:bg-transparent",
|
|
519
525
|
"disabled:text-slate-400",
|
|
520
526
|
],
|
|
521
527
|
},
|
|
@@ -535,9 +541,17 @@ const cvaButton = cvaMerge([
|
|
|
535
541
|
* So we need to add padding to the min-height calculation. Two times the vertical
|
|
536
542
|
* padding aka py-1 * 2 aka --spacing-1 * 2 aka spacing-2 (for small).
|
|
537
543
|
*/
|
|
538
|
-
small: ["py-1", "
|
|
539
|
-
medium: ["py-1.5", "
|
|
540
|
-
large: [
|
|
544
|
+
small: ["px-2", "py-1.5", "gap-1", "h-7", "text-xs", "min-h-[calc(var(--line-height-sm)+var(--spacing-2))]"],
|
|
545
|
+
medium: ["px-3", "py-1.5", "gap-2", "h-8", "text-sm", "min-h-[calc(var(--line-height-sm)+var(--spacing-3))]"],
|
|
546
|
+
large: [
|
|
547
|
+
"px-4",
|
|
548
|
+
"py-2",
|
|
549
|
+
"h-10",
|
|
550
|
+
"gap-2",
|
|
551
|
+
"text-base",
|
|
552
|
+
"rounded-lg",
|
|
553
|
+
"min-h-[calc(var(--line-height-sm)+var(--spacing-4))]",
|
|
554
|
+
],
|
|
541
555
|
},
|
|
542
556
|
rounded: {
|
|
543
557
|
true: ["rounded-full"],
|
|
@@ -555,9 +569,9 @@ const cvaButton = cvaMerge([
|
|
|
555
569
|
true: ["cursor-not-allowed", "pointer-events-none", "bg-slate-200", "hover:bg-slate-200", "text-slate-400"],
|
|
556
570
|
false: [],
|
|
557
571
|
},
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
572
|
+
loading: {
|
|
573
|
+
true: ["bg-transparent"],
|
|
574
|
+
false: [],
|
|
561
575
|
},
|
|
562
576
|
},
|
|
563
577
|
compoundVariants: [
|
|
@@ -577,88 +591,105 @@ const cvaButton = cvaMerge([
|
|
|
577
591
|
className: ["p-2"],
|
|
578
592
|
},
|
|
579
593
|
{
|
|
580
|
-
|
|
581
|
-
variant: "
|
|
582
|
-
className: [
|
|
583
|
-
"text-primary-600",
|
|
584
|
-
"hover:text-primary-700",
|
|
585
|
-
"active:bg-primary-700",
|
|
586
|
-
"focus:ring-primary-300",
|
|
587
|
-
"hover:bg-primary-500/10",
|
|
588
|
-
],
|
|
594
|
+
loading: true,
|
|
595
|
+
variant: "primary",
|
|
596
|
+
className: ['disabled:bg-primary-600'],
|
|
589
597
|
},
|
|
590
598
|
{
|
|
591
|
-
|
|
592
|
-
variant: "
|
|
593
|
-
className: [
|
|
594
|
-
"text-secondary-600",
|
|
595
|
-
"hover:text-secondary-800",
|
|
596
|
-
"active:text-secondary-700",
|
|
597
|
-
"active:bg-black/10",
|
|
598
|
-
"focus:ring-secondary-300",
|
|
599
|
-
"hover:bg-black/5",
|
|
600
|
-
],
|
|
601
|
-
},
|
|
602
|
-
{
|
|
603
|
-
color: "warning",
|
|
604
|
-
variant: "transparent",
|
|
605
|
-
className: [
|
|
606
|
-
"text-warning-600",
|
|
607
|
-
"active:bg-warning-500/20",
|
|
608
|
-
"focus:ring-warning-300",
|
|
609
|
-
"hover:bg-warning-500/10",
|
|
610
|
-
],
|
|
599
|
+
loading: true,
|
|
600
|
+
variant: "primary-danger",
|
|
601
|
+
className: ["disabled:bg-danger-600"],
|
|
611
602
|
},
|
|
612
603
|
{
|
|
613
|
-
|
|
614
|
-
variant: "
|
|
615
|
-
className: ["
|
|
604
|
+
loading: true,
|
|
605
|
+
variant: "secondary",
|
|
606
|
+
className: ["disabled:bg-white"],
|
|
616
607
|
},
|
|
617
608
|
{
|
|
618
|
-
|
|
619
|
-
variant: "
|
|
620
|
-
className: ["
|
|
621
|
-
},
|
|
622
|
-
{
|
|
623
|
-
disabled: true,
|
|
624
|
-
variant: "transparent",
|
|
625
|
-
className: ["cursor-not-allowed", "pointer-events-none", "hover:bg-transparent"],
|
|
609
|
+
loading: true,
|
|
610
|
+
variant: "secondary-danger",
|
|
611
|
+
className: ["disabled:bg-white"],
|
|
626
612
|
},
|
|
627
613
|
],
|
|
628
614
|
defaultVariants: {
|
|
629
|
-
|
|
615
|
+
variant: "primary",
|
|
630
616
|
size: "medium",
|
|
631
617
|
rounded: false,
|
|
632
618
|
fullWidth: false,
|
|
633
619
|
square: false,
|
|
634
620
|
disabled: false,
|
|
635
|
-
|
|
621
|
+
},
|
|
622
|
+
});
|
|
623
|
+
const cvaButtonSpinnerContainer = cvaMerge(["p-0", "h-auto"]);
|
|
624
|
+
const cvaButtonSpinner = cvaMerge([], {
|
|
625
|
+
variants: {
|
|
626
|
+
variant: {
|
|
627
|
+
primary: ["border-white/[0.32]", "border-b-white"],
|
|
628
|
+
"primary-danger": ["border-white/[0.32]", "border-b-white"],
|
|
629
|
+
secondary: ['h-3.5', 'w-3.5'],
|
|
630
|
+
"secondary-danger": ['h-3.5', 'w-3.5'],
|
|
631
|
+
ghost: [],
|
|
632
|
+
"ghost-neutral": [],
|
|
633
|
+
},
|
|
634
|
+
},
|
|
635
|
+
defaultVariants: {
|
|
636
|
+
variant: "primary",
|
|
637
|
+
},
|
|
638
|
+
});
|
|
639
|
+
const cvaButtonPrefixSuffix = cvaMerge(["flex", "items-center"], {
|
|
640
|
+
variants: {
|
|
641
|
+
size: {
|
|
642
|
+
small: ["h-4"],
|
|
643
|
+
medium: ["h-4"],
|
|
644
|
+
large: ["h-5"],
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
defaultVariants: {
|
|
648
|
+
size: "medium",
|
|
649
|
+
},
|
|
650
|
+
});
|
|
651
|
+
const cvaIconButton = cvaMerge([], {
|
|
652
|
+
variants: {
|
|
653
|
+
size: {
|
|
654
|
+
small: ["p-1.5", "w-7", "h-7"],
|
|
655
|
+
medium: ["p-2", "w-8", "h-8"],
|
|
656
|
+
large: ["p-2.5", "w-10", "h-10"],
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
defaultVariants: {
|
|
660
|
+
size: "medium",
|
|
636
661
|
},
|
|
637
662
|
});
|
|
638
663
|
|
|
639
664
|
/**
|
|
640
|
-
* Buttons allow users to
|
|
641
|
-
|
|
665
|
+
* Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. Button labels express what action will occur when the user interacts with it.
|
|
666
|
+
*
|
|
667
|
+
* ### When to use
|
|
668
|
+
* Use buttons to communicate actions users can take and to allow users to interact with the page. Each page should have one primary button, and any remaining calls to action should be represented as lower emphasis buttons.
|
|
669
|
+
*
|
|
670
|
+
* ### When not to use
|
|
671
|
+
* Do not use buttons as navigational elements. Instead, use [Links](https://www.notion.so/Links-49638788b6c042698b40b94a318361f1?pvs=21) when the desired action is to take the user to a new page.
|
|
672
|
+
*
|
|
642
673
|
* @param {ButtonProps} props - The props for the Button component
|
|
643
674
|
* @returns {JSX.Element} Button component
|
|
644
675
|
*/
|
|
645
676
|
const Button = React.forwardRef((_a, ref) => {
|
|
646
|
-
var { onClick, children, loading, disabled, className, fullWidth = false, prefix, suffix,
|
|
677
|
+
var { onClick, children, loading, disabled, className, fullWidth = false, prefix, suffix, variant = "primary", type = "button", size = "medium", square = false, dataTestId, title, role, tabIndex, renderAs = "button", circular } = _a, rest = __rest(_a, ["onClick", "children", "loading", "disabled", "className", "fullWidth", "prefix", "suffix", "variant", "type", "size", "square", "dataTestId", "title", "role", "tabIndex", "renderAs", "circular"]);
|
|
647
678
|
return React.createElement(renderAs, Object.assign({ ref,
|
|
648
679
|
title,
|
|
649
680
|
type,
|
|
650
681
|
role,
|
|
651
682
|
onClick,
|
|
652
|
-
tabIndex, disabled: disabled || loading, className: cvaButton({ rounded: circular, disabled, size, square,
|
|
683
|
+
tabIndex, disabled: disabled || loading, className: cvaButton({ rounded: circular, disabled, size, square, variant, loading, fullWidth, className }), "aria-label": title, "data-testid": dataTestId }, rest), jsxs(Fragment, { children: [loading ? (jsx(Spinner, { size: "small", centering: "vertically", containerClassName: cvaButtonSpinnerContainer(), className: cvaButtonSpinner({ variant }) })) : null, prefix && !loading ? jsx("div", { className: cvaButtonPrefixSuffix({ size: size }), children: prefix }) : null, children, suffix && !loading ? jsx("div", { className: cvaButtonPrefixSuffix({ size: size }), children: suffix }) : null] }));
|
|
653
684
|
});
|
|
654
685
|
Button.displayName = "Button";
|
|
655
686
|
|
|
656
687
|
/**
|
|
657
|
-
*
|
|
688
|
+
* Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. The Icon Button is a version of the standard Button component without the text label.
|
|
658
689
|
*/
|
|
659
690
|
const IconButton = React.forwardRef((_a, ref) => {
|
|
660
|
-
var { icon, size = "
|
|
661
|
-
return (jsx(Button, Object.assign({ size: size, prefix: !loading ? icon : undefined, square: square, loading: loading, disabled: disabled || loading, ref: ref }, rest)));
|
|
691
|
+
var { icon, size = "medium", square = true, loading, disabled, className } = _a, rest = __rest(_a, ["icon", "size", "square", "loading", "disabled", "className"]);
|
|
692
|
+
return (jsx(Button, Object.assign({ size: size, prefix: !loading ? icon : undefined, square: square, loading: loading, disabled: disabled || loading, ref: ref, className: cvaIconButton({ size: size, className }) }, rest)));
|
|
662
693
|
});
|
|
663
694
|
IconButton.displayName = "IconButton";
|
|
664
695
|
|
|
@@ -691,6 +722,16 @@ const cvaAlertContentContainer = cvaMerge(["flex", "flex-row", "h-full", "gap-2"
|
|
|
691
722
|
const cvaAlertCloseButtonContainer = cvaMerge(["flex", "self-start", "w-min", "shrink-0"]);
|
|
692
723
|
const cvaAlertIconContainer = cvaMerge(["self-start", "shrink-0", "grid", "w-min", "hidden", "@2xs:block"]);
|
|
693
724
|
|
|
725
|
+
const getSecondaryActionVariant = (color) => {
|
|
726
|
+
switch (color) {
|
|
727
|
+
case "danger":
|
|
728
|
+
return "secondary-danger";
|
|
729
|
+
case "warning":
|
|
730
|
+
return "ghost-neutral";
|
|
731
|
+
default:
|
|
732
|
+
return "ghost";
|
|
733
|
+
}
|
|
734
|
+
};
|
|
694
735
|
/**
|
|
695
736
|
* The Alert component should be used to inform the user of important information.
|
|
696
737
|
|
|
@@ -716,9 +757,9 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
716
757
|
const getButtonColor = () => {
|
|
717
758
|
switch (color) {
|
|
718
759
|
case "danger":
|
|
719
|
-
return "danger";
|
|
760
|
+
return "primary-danger";
|
|
720
761
|
case "warning":
|
|
721
|
-
return "
|
|
762
|
+
return "secondary-danger";
|
|
722
763
|
default:
|
|
723
764
|
return "primary";
|
|
724
765
|
}
|
|
@@ -730,7 +771,7 @@ const Alert = ({ color = "info", title, className, children, primaryAction, seco
|
|
|
730
771
|
(_b = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
731
772
|
}
|
|
732
773
|
}, [ref, autoScroll]);
|
|
733
|
-
return (jsxs("div", { className: cvaAlert({ color, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxs("div", { className: cvaAlertContentContainer(), children: [jsx("div", { className: cvaAlertIconContainer(), children: getIconFromColor() }), jsxs("div", { className: cvaContent(), children: [title ? jsx(Text, { weight: "bold", children: title }) : null, children ? (jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight: !title ? "bold" : "normal", children: children })) : null] }), onClose ? (jsx("div", { className: cvaAlertCloseButtonContainer(), children: jsx(IconButton, { size: "small", variant: "
|
|
774
|
+
return (jsxs("div", { className: cvaAlert({ color, className }), "data-testid": dataTestId, ref: ref, role: "alert", children: [jsxs("div", { className: cvaAlertContentContainer(), children: [jsx("div", { className: cvaAlertIconContainer(), children: getIconFromColor() }), jsxs("div", { className: cvaContent(), children: [title ? jsx(Text, { weight: "bold", children: title }) : null, children ? (jsx(Text, { type: typeof children === "string" || typeof children === "number" ? "p" : "span", weight: !title ? "bold" : "normal", children: children })) : null] }), onClose ? (jsx("div", { className: cvaAlertCloseButtonContainer(), children: jsx(IconButton, { size: "small", variant: "ghost-neutral", onClick: onClose, icon: jsx(Icon, { name: "XMark", size: "small" }), title: "Close Alert", circular: true }) })) : null] }), primaryAction || secondaryAction ? (jsxs("div", { className: cvaAlertActionsContainer(), children: [secondaryAction ? (jsx(Button, { size: "small", variant: getSecondaryActionVariant(color), onClick: secondaryAction.onClick, loading: secondaryAction.loading, children: secondaryAction.label })) : null, primaryAction ? (jsx(Button, { size: "small", variant: getButtonColor(), onClick: primaryAction.onClick, loading: primaryAction.loading, children: primaryAction.label })) : null] })) : null] }));
|
|
734
775
|
};
|
|
735
776
|
|
|
736
777
|
const cvaBadge = cvaMerge([
|
|
@@ -973,7 +1014,7 @@ const CardHeader = ({ heading, headingVariant = "primary", subHeading, onClose,
|
|
|
973
1014
|
density,
|
|
974
1015
|
border: hideSeparator ? "borderless" : "default",
|
|
975
1016
|
className,
|
|
976
|
-
}), children: jsxs("div", { className: cvaCardHeader(), children: [jsxs("div", { children: [jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading ? (jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })) : null, children] }), jsxs("div", { className: "flex gap-x-2 gap-y-1", children: [actions, onClose ? (jsx(IconButton, { dataTestId: "card-header-close-button", variant: "
|
|
1017
|
+
}), children: jsxs("div", { className: cvaCardHeader(), children: [jsxs("div", { children: [jsxs("div", { className: cvaCardHeaderHeadingContainer(), children: [jsx(Heading, { className: "self-center", variant: headingVariant, children: heading }), accessories] }), subHeading ? (jsx(Heading, { subtle: true, variant: "subtitle", children: subHeading })) : null, children] }), jsxs("div", { className: "flex gap-x-2 gap-y-1", children: [actions, onClose ? (jsx(IconButton, { dataTestId: "card-header-close-button", variant: "ghost-neutral", onClick: onClose, icon: jsx(Icon, { name: "XMark", size: "small" }), className: "!h-min" })) : null] })] }) }));
|
|
977
1018
|
};
|
|
978
1019
|
|
|
979
1020
|
const cvaCollapse = cvaMerge([
|
|
@@ -1017,7 +1058,7 @@ const Collapse = ({ id, initialExpanded = false, onToggle, label, children, clas
|
|
|
1017
1058
|
}
|
|
1018
1059
|
setExpanded(!expanded);
|
|
1019
1060
|
}, [expanded, onToggle]);
|
|
1020
|
-
return (jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsxs("div", { className: cvaCollapseHeader({ expanded }), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick, children: [jsxs("div", { className: cvaCollapseLabelContainer(), children: [jsx(Text, { type: "span", weight: "bold", children: label }), jsx(IconButton, { icon: jsx(Icon, { name: "ChevronUpDown", size: "small" }), size: "medium", variant: "
|
|
1061
|
+
return (jsxs("div", { className: cvaCollapse({ className }), "data-testid": dataTestId, children: [jsxs("div", { className: cvaCollapseHeader({ expanded }), role: "button", "aria-expanded": expanded, "aria-controls": id, onClick: handleClick, children: [jsxs("div", { className: cvaCollapseLabelContainer(), children: [jsx(Text, { type: "span", weight: "bold", children: label }), jsx(IconButton, { icon: jsx(Icon, { name: "ChevronUpDown", size: "small" }), size: "medium", variant: "ghost-neutral" })] }), headerAddon ? headerAddon : null] }), jsx(Collapsible, { expanded: expanded, id: id, children: children })] }));
|
|
1021
1062
|
};
|
|
1022
1063
|
const Collapsible = ({ children, expanded, id }) => {
|
|
1023
1064
|
const [ref, { height }] = useMeasure();
|
|
@@ -1246,7 +1287,7 @@ const PopoverTrigger = forwardRef(function PopoverTrigger(_a, propRef) {
|
|
|
1246
1287
|
* @returns {JSX.Element} DayPickerPopover component
|
|
1247
1288
|
*/
|
|
1248
1289
|
const DayPickerPopover = ({ disabledDays, className, dataTestId, selectedDay, onDaySelect, color = "secondary", placement, size = "small", buttonContent, language, }) => {
|
|
1249
|
-
return (jsxs(Popover, { placement: placement, children: [jsx(PopoverTrigger, { children: jsx(Button, {
|
|
1290
|
+
return (jsxs(Popover, { placement: placement, children: [jsx(PopoverTrigger, { children: jsx(Button, { variant: color, size: size, className: className, prefix: jsx(Icon, { name: "Calendar", size: "small" }), dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "show-day-picker", children: buttonContent }) }), jsx(PopoverContent, { children: jsx(Card, { children: jsx(DayPicker, { disabledDays: disabledDays, onDaySelect: onDaySelect, selectedDays: selectedDay, language: language }) }) })] }));
|
|
1250
1291
|
};
|
|
1251
1292
|
|
|
1252
1293
|
/**
|
|
@@ -1760,7 +1801,7 @@ const MoreMenu = ({ className, dataTestId, popoverProps, iconProps = {
|
|
|
1760
1801
|
size: "small",
|
|
1761
1802
|
circular: true,
|
|
1762
1803
|
square: true,
|
|
1763
|
-
|
|
1804
|
+
variant: "secondary",
|
|
1764
1805
|
}, customButton, customPortalId, children, }) => {
|
|
1765
1806
|
const actionMenuRef = useRef(null);
|
|
1766
1807
|
return (jsx("div", { ref: actionMenuRef, className: cvaMoreMenu({ className }), "data-testid": dataTestId, children: jsxs(Popover, Object.assign({}, popoverProps, { children: [jsx(PopoverTrigger, { children: customButton !== null && customButton !== void 0 ? customButton : jsx(IconButton, Object.assign({}, iconButtonProps, { icon: jsx(Icon, Object.assign({ name: "EllipsisHorizontal" }, iconProps)) })) }), jsx(PopoverContent, { portalId: customPortalId, children: close => (typeof children === "function" ? children(close) : children) })] })) }));
|
|
@@ -1915,7 +1956,7 @@ const PageHeader = ({ className, dataTestId, action, showLoading, description, l
|
|
|
1915
1956
|
return (jsxs("div", { className: cvaPageHeaderContainer({
|
|
1916
1957
|
className,
|
|
1917
1958
|
withBorder: !tabsList,
|
|
1918
|
-
}), "data-testid": dataTestId, children: [jsxs("div", { className: cvaPageHeader(), children: [jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId ? `${dataTestId}-heading-container` : undefined, children: [jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo ? (jsx(IconButton, { to: backTo, renderAs: Link,
|
|
1959
|
+
}), "data-testid": dataTestId, children: [jsxs("div", { className: cvaPageHeader(), children: [jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId ? `${dataTestId}-heading-container` : undefined, children: [jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo ? (jsx(IconButton, { to: backTo, renderAs: Link, variant: "ghost-neutral", size: "small", icon: jsx(Icon, { name: "ArrowLeft" }) })) : undefined, jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId ? `${dataTestId}-heading` : undefined, children: title }), description && !showLoading ? (jsxs("div", { className: cvaPageHeaderDescriptionAndLinkContainer(), children: [jsx(Tooltip, { label: description, dataTestId: dataTestId ? `${dataTestId}-tooltip` : undefined, iconProps: { name: "QuestionMarkCircle" }, placement: "bottom" }), link ? (jsxs(Link, { to: link, "data-testid": "tooltip-link", target: "_blank", className: cvaPageHeaderLink(), children: [linkText, jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" })] })) : undefined] })) : undefined] }), tag && !showLoading ? (jsx(Tag, { dataTestId: dataTestId ? `${dataTestId}-tag` : undefined, color: tagColor, children: tag })) : undefined, showLoading ? (jsx(Spinner, { dataTestId: dataTestId ? `${dataTestId}-spinner` : undefined, centering: "vertically" })) : null, action] }), children ? jsx("div", { className: cvaPageHeaderChildContainer(), children: children }) : null] }), tabsList] }));
|
|
1919
1960
|
};
|
|
1920
1961
|
|
|
1921
1962
|
const cvaPagination = cvaMerge(["flex", "items-center", "gap-1"]);
|
|
@@ -1964,9 +2005,9 @@ const Pagination = ({ previousPage, nextPage, canPreviousPage, canNextPage, page
|
|
|
1964
2005
|
if (loading) {
|
|
1965
2006
|
return (jsx("div", { className: cvaPagination({ className }), children: jsx(SkeletonLines, { height: 16, width: 150 }) }));
|
|
1966
2007
|
}
|
|
1967
|
-
return (jsxs("div", { "data-testid": dataTestId, className: cvaPagination({ className }), children: [jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsx(Icon, { name: "ChevronLeft", size: "small" }), size: "small",
|
|
2008
|
+
return (jsxs("div", { "data-testid": dataTestId, className: cvaPagination({ className }), children: [jsx(IconButton, { onClick: () => handlePageChange("prev"), disabled: cursorBase ? !canPreviousPage || false : page !== undefined && page <= 0, "data-testid": "prev-page", icon: jsx(Icon, { name: "ChevronLeft", size: "small" }), size: "small", variant: "ghost-neutral" }), !cursorBase && (jsxs(Fragment, { children: [jsx("div", { className: cvaPaginationText(), "data-testid": "current-page", children: currentPage }), jsx("div", { className: cvaPaginationText(), "data-testid": "page-count", children: pageCount !== null && pageCount !== undefined && getTranslatedCount ? getTranslatedCount(pageCount) : null })] })), jsx(IconButton, { onClick: () => handlePageChange("next"), disabled: cursorBase
|
|
1968
2009
|
? !canNextPage || false
|
|
1969
|
-
: page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsx(Icon, { name: "ChevronRight", size: "small" }), size: "small",
|
|
2010
|
+
: page !== undefined && pageCount !== undefined && pageCount !== null && page >= pageCount - 1, "data-testid": "next-page", icon: jsx(Icon, { name: "ChevronRight", size: "small" }), size: "small", variant: "ghost-neutral" })] }));
|
|
1970
2011
|
};
|
|
1971
2012
|
|
|
1972
2013
|
function useConfirmExit(confirmExit, when = true) {
|
|
@@ -2161,8 +2202,7 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
2161
2202
|
});
|
|
2162
2203
|
}) }), overflowItemCount > 0 ? (jsx(MoreMenu, Object.assign({ iconButtonProps: {
|
|
2163
2204
|
circular: false,
|
|
2164
|
-
variant: "
|
|
2165
|
-
color: "secondary",
|
|
2205
|
+
variant: "ghost-neutral",
|
|
2166
2206
|
}, popoverProps: { placement: "bottom-end" } }, moreMenuProps, { className: `${(moreMenuProps === null || moreMenuProps === void 0 ? void 0 : moreMenuProps.className) || ""} !p-0`, dataTestId: dataTestId ? `${dataTestId}-more-menu` : undefined, children: close => (jsx(MenuList, Object.assign({}, menuListProps, { dataTestId: dataTestId ? `${dataTestId}-menu-list` : undefined, children: React__default.Children.map(children, child => {
|
|
2167
2207
|
return itemOverflowMap[child.props.id]
|
|
2168
2208
|
? React__default.cloneElement(child, {
|
|
@@ -2993,4 +3033,4 @@ const useVisibilityChange = ({ onChange, targetState = "hidden" }) => {
|
|
|
2993
3033
|
}, [onChange, targetState]);
|
|
2994
3034
|
};
|
|
2995
3035
|
|
|
2996
|
-
export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, PackageNameStoryComponent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, Tooltip, ValueBar, WidgetBody, cvaButton, cvaClickable, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useVisibilityChange };
|
|
3036
|
+
export { Alert, Badge, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CopyableText, DayPicker, DayPickerPopover, DayRangePicker, Drawer, EmptyState, ExternalLink, Heading, Icon, IconButton, Indicator, MenuItem, MenuList, Modal, ModalBackdrop, MoreMenu, PackageNameStoryComponent, PageHeader, Pagination, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, Timeline, TimelineElement, Tooltip, ValueBar, WidgetBody, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaIconButton, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemSuffix, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, setLocalStorage, useClickOutside, useContainerProps, useContinuousTimeout, useDebounce, useDevicePixelRatio, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextCutOff, useLocalStorage, useLocalStorageReducer, useModal, useOptionallyElevatedState, useOverflowItems, usePopoverContext, usePrompt, useResize, useSelfUpdatingRef, useTimeout, useVisibilityChange };
|
package/package.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import { Matcher } from "react-day-picker";
|
|
3
3
|
import { CommonProps, Size } from "../../common/CommonProps";
|
|
4
4
|
import { PopoverPlacement } from "../Popover";
|
|
5
|
-
import {
|
|
5
|
+
import { ButtonVariant } from "../buttons";
|
|
6
6
|
export interface DayPickerPopoverProps extends CommonProps {
|
|
7
7
|
disabledDays?: Matcher | Matcher[] | undefined;
|
|
8
8
|
onDaySelect: (day: Date) => void;
|
|
9
9
|
selectedDay?: Date;
|
|
10
|
-
color?:
|
|
10
|
+
color?: ButtonVariant;
|
|
11
11
|
size?: Size;
|
|
12
12
|
placement?: PopoverPlacement;
|
|
13
13
|
buttonContent: JSX.Element;
|
|
@@ -36,8 +36,14 @@ export interface ButtonProps extends ButtonCommonProps {
|
|
|
36
36
|
name?: string;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* Buttons allow users to
|
|
40
|
-
|
|
39
|
+
* Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. Button labels express what action will occur when the user interacts with it.
|
|
40
|
+
*
|
|
41
|
+
* ### When to use
|
|
42
|
+
* Use buttons to communicate actions users can take and to allow users to interact with the page. Each page should have one primary button, and any remaining calls to action should be represented as lower emphasis buttons.
|
|
43
|
+
*
|
|
44
|
+
* ### When not to use
|
|
45
|
+
* Do not use buttons as navigational elements. Instead, use [Links](https://www.notion.so/Links-49638788b6c042698b40b94a318361f1?pvs=21) when the desired action is to take the user to a new page.
|
|
46
|
+
*
|
|
41
47
|
* @param {ButtonProps} props - The props for the Button component
|
|
42
48
|
* @returns {JSX.Element} Button component
|
|
43
49
|
*/
|
|
@@ -13,11 +13,11 @@ export interface IconButtonProps extends ButtonCommonProps {
|
|
|
13
13
|
*/
|
|
14
14
|
renderAs?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
|
|
15
15
|
/**
|
|
16
|
-
* The size of the button. Defaults to "
|
|
16
|
+
* The size of the button. Defaults to "medium".
|
|
17
17
|
*/
|
|
18
18
|
size?: Size;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Buttons are clickable elements that are used to trigger actions. They communicate calls to action to the user and allow users to interact with pages in a variety of ways. The Icon Button is a version of the standard Button component without the text label.
|
|
22
22
|
*/
|
|
23
23
|
export declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
export declare const cvaButton: (props?: ({
|
|
2
|
-
|
|
2
|
+
variant?: "primary" | "primary-danger" | "secondary" | "secondary-danger" | "ghost" | "ghost-neutral" | null | undefined;
|
|
3
3
|
size?: "small" | "medium" | "large" | null | undefined;
|
|
4
4
|
rounded?: boolean | null | undefined;
|
|
5
5
|
fullWidth?: boolean | null | undefined;
|
|
6
6
|
square?: boolean | null | undefined;
|
|
7
7
|
disabled?: boolean | null | undefined;
|
|
8
|
-
|
|
8
|
+
loading?: boolean | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
10
|
+
export declare const cvaButtonSpinnerContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
11
|
+
export declare const cvaButtonSpinner: (props?: ({
|
|
12
|
+
variant?: "primary" | "primary-danger" | "secondary" | "secondary-danger" | "ghost" | "ghost-neutral" | null | undefined;
|
|
13
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
14
|
+
export declare const cvaButtonPrefixSuffix: (props?: ({
|
|
15
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
16
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
17
|
+
export declare const cvaIconButton: (props?: ({
|
|
18
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
9
19
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { GeneralColors
|
|
2
|
+
import { GeneralColors } from "@trackunit/ui-design-tokens";
|
|
3
3
|
import { CommonProps, Size } from "../../../common/CommonProps";
|
|
4
|
-
export type ButtonVariant = "
|
|
5
|
-
export type ButtonColor = Extract<GeneralColors, "primary" | "secondary"> | Extract<IntentColors, "warning" | "danger"> | "tertiary";
|
|
4
|
+
export type ButtonVariant = Extract<GeneralColors, "primary" | "secondary"> | "primary-danger" | "secondary-danger" | "ghost" | "ghost-neutral";
|
|
6
5
|
export type ButtonType = "button" | "submit";
|
|
7
6
|
export interface ButtonCommonProps extends CommonProps {
|
|
8
7
|
/**
|
|
@@ -30,11 +29,7 @@ export interface ButtonCommonProps extends CommonProps {
|
|
|
30
29
|
*/
|
|
31
30
|
square?: boolean;
|
|
32
31
|
/**
|
|
33
|
-
* The button's variant. Values are
|
|
34
|
-
*/
|
|
35
|
-
color?: ButtonColor;
|
|
36
|
-
/**
|
|
37
|
-
* The variant of the button.
|
|
32
|
+
* The button's variant. Values are primary, secondary, primary-danger, secondary-danger, ghost and ghost-neutral.
|
|
38
33
|
*/
|
|
39
34
|
variant?: ButtonVariant;
|
|
40
35
|
/**
|