@trackunit/react-components 0.1.236 → 0.1.238
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 +74 -39
- package/index.esm.js +76 -40
- package/package.json +1 -1
- package/src/components/PageHeader/PageHeader.d.ts +5 -1
- package/src/components/Tooltip/Tooltip.d.ts +17 -4
- package/src/components/Tooltip/Tooltip.variants.d.ts +10 -2
- package/src/components/index.d.ts +0 -1
- package/src/components/Tip/Tip.d.ts +0 -27
- package/src/components/Tip/Tip.variants.d.ts +0 -4
- package/src/components/Tip/index.d.ts +0 -1
package/index.cjs.js
CHANGED
|
@@ -1454,36 +1454,96 @@ const ExternalLink = ({ rel = "noreferrer", target = "_blank", href, className,
|
|
|
1454
1454
|
return (jsxRuntime.jsx("a", { onClick: onClick, "data-testid": dataTestId, className: cvaExternalLink({ className }), title: title, href: href, rel: rel, target: target, children: children }));
|
|
1455
1455
|
};
|
|
1456
1456
|
|
|
1457
|
-
const cvaTooltipFlexContainer = cssClassVarianceUtilities.cvaMerge("inline-flex");
|
|
1457
|
+
const cvaTooltipFlexContainer = cssClassVarianceUtilities.cvaMerge("inline-flex hover:cursor-pointer");
|
|
1458
|
+
const cvaTooltipIcon = cssClassVarianceUtilities.cvaMerge("flex h-max w-fit text-slate-300 transition hover:cursor-pointer hover:text-slate-400", {
|
|
1459
|
+
variants: {
|
|
1460
|
+
color: {
|
|
1461
|
+
light: "hover:text-white",
|
|
1462
|
+
dark: "hover:text-slate-400",
|
|
1463
|
+
},
|
|
1464
|
+
defaultVariants: {
|
|
1465
|
+
color: "dark",
|
|
1466
|
+
},
|
|
1467
|
+
},
|
|
1468
|
+
});
|
|
1458
1469
|
const cvaTooltipPopover = cssClassVarianceUtilities.cvaMerge("pointer-events-none origin-center");
|
|
1459
|
-
cssClassVarianceUtilities.cvaMerge("
|
|
1460
|
-
|
|
1470
|
+
const cvaTooltipPopoverTail = cssClassVarianceUtilities.cvaMerge("", {
|
|
1471
|
+
variants: {
|
|
1472
|
+
placement: {
|
|
1473
|
+
top: "top-full left-2/4 ml-[-5px]",
|
|
1474
|
+
"top-start": "top-full left-[5%]",
|
|
1475
|
+
"top-end": "top-full right-[5%]",
|
|
1476
|
+
bottom: "bottom-full right-2/4 mr-[-6px] ",
|
|
1477
|
+
"bottom-start": "bottom-full left-[5%]",
|
|
1478
|
+
"bottom-end": "bottom-full right-[5%]",
|
|
1479
|
+
left: "top-2/4 left-full mt-[-6px]",
|
|
1480
|
+
"left-start": "top-1/4 top-[8%]",
|
|
1481
|
+
"left-end": "bottom-1/4 bottom-[8%]",
|
|
1482
|
+
right: "top-2/4 right-full mt-[-6px] ",
|
|
1483
|
+
"right-start": "top-1/4 top-[8%]",
|
|
1484
|
+
"right-end": "bottom-1/4 bottom-[8%]",
|
|
1485
|
+
},
|
|
1486
|
+
mode: {
|
|
1487
|
+
light: "fill-white",
|
|
1488
|
+
dark: "fill-slate-600",
|
|
1489
|
+
},
|
|
1490
|
+
},
|
|
1491
|
+
defaultVariants: {
|
|
1492
|
+
placement: "bottom",
|
|
1493
|
+
mode: "dark",
|
|
1494
|
+
},
|
|
1495
|
+
});
|
|
1496
|
+
cssClassVarianceUtilities.cvaMerge(["component-popover-border", "z-popover", "animate-fade-in-fast"]);
|
|
1497
|
+
const cvaTooltipPopoverContent = cssClassVarianceUtilities.cvaMerge("max-w-sm rounded p-2", {
|
|
1461
1498
|
variants: {
|
|
1462
1499
|
color: {
|
|
1463
|
-
light: "bg-white shadow-
|
|
1464
|
-
dark: "bg-
|
|
1500
|
+
light: "bg-white shadow-lg",
|
|
1501
|
+
dark: "bg-slate-600 text-white",
|
|
1465
1502
|
},
|
|
1466
1503
|
},
|
|
1467
1504
|
defaultVariants: {
|
|
1468
|
-
color: "
|
|
1505
|
+
color: "dark",
|
|
1469
1506
|
},
|
|
1470
1507
|
});
|
|
1471
1508
|
|
|
1472
1509
|
/**
|
|
1473
|
-
*
|
|
1510
|
+
*
|
|
1511
|
+
* @description Adding Tooltip Arrow
|
|
1512
|
+
* @returns {JSX.Element} Tooltip floating Arrow
|
|
1513
|
+
*/
|
|
1514
|
+
const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
1515
|
+
const { context: floatingContext } = usePopoverContext();
|
|
1516
|
+
return (jsxRuntime.jsx(react.FloatingArrow, { ref: arrowRef, context: floatingContext, className: cvaTooltipPopoverTail({ mode, placement: floatingContext.placement }) }));
|
|
1517
|
+
};
|
|
1518
|
+
/**
|
|
1519
|
+
* Tooltips display additional information upon hover. The information included should be contextual, helpful, and nonessential while providing that extra ability to communicate and give clarity to a user.
|
|
1520
|
+
*
|
|
1521
|
+
* Tooltips should be used sparingly and contain succinct, supplementary information, and they should contain read-only text. **❗️Do not include interactive elements in tooltips ** (no links, buttons, etc). Interactive elements in tooltips are inaccessible since tooltips do not receive focus.
|
|
1522
|
+
*
|
|
1523
|
+
* **Do use** tooltips to expose names of icon buttons that lack visual labels, when more information is useful in helping a user understand the context, when an element needs additional explanation, or use when defining a term or inline item.
|
|
1524
|
+
*
|
|
1525
|
+
* **Do not use** tooltips to include information that is necessary for the user to complete their task. Use helper text that is always visible and accessible for vital information.
|
|
1474
1526
|
|
|
1475
1527
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
1476
1528
|
* @returns {JSX.Element} Tooltip component
|
|
1477
1529
|
*/
|
|
1478
|
-
const Tooltip = (
|
|
1479
|
-
|
|
1530
|
+
const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label, placement = "auto", mode = "dark", contentTextType = "p", iconProps, }) => {
|
|
1531
|
+
const [isOpen, setIsOpen] = React__namespace.useState(false);
|
|
1532
|
+
const arrowRef = React__namespace.useRef(null);
|
|
1533
|
+
const { refs, floatingStyles, context } = react.useFloating({
|
|
1534
|
+
placement: placement === "auto" ? "bottom" : placement,
|
|
1535
|
+
open: isOpen,
|
|
1536
|
+
onOpenChange: setIsOpen,
|
|
1537
|
+
middleware: [react.offset(8), react.arrow({ element: arrowRef })],
|
|
1538
|
+
whileElementsMounted: react.autoUpdate,
|
|
1539
|
+
});
|
|
1540
|
+
const { isMounted } = react.useTransitionStatus(context);
|
|
1480
1541
|
const wrappedChildren = (jsxRuntime.jsx("div", { className: cvaTooltipFlexContainer({ className }), "data-testid": dataTestId && `${dataTestId}-parent`, children: children }));
|
|
1481
1542
|
if (disabled) {
|
|
1482
1543
|
return wrappedChildren;
|
|
1483
1544
|
}
|
|
1484
|
-
return (jsxRuntime.jsx(
|
|
1545
|
+
return (jsxRuntime.jsxs(Popover, { className: cvaTooltipPopover(), placement: placement === "auto" ? "bottom" : placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsxRuntime.jsx(PopoverTrigger, { className: cvaTooltipIcon({ color: mode }), ref: refs.setReference, onMouseEnter: () => setIsOpen(true), onMouseLeave: () => setIsOpen(false), "data-testid": dataTestId && `${dataTestId}-trigger`, children: children === undefined ? (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Icon, Object.assign({ name: "QuestionMarkCircle", size: "small", dataTestId: dataTestId && `${dataTestId}-icon` }, iconProps)) })) : (wrappedChildren) }), isMounted && (jsxRuntime.jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": `${dataTestId}-content`, children: [jsxRuntime.jsx(Text, { inverted: mode === "dark", type: contentTextType, children: label }), placement !== "auto" && jsxRuntime.jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) }))] }));
|
|
1485
1546
|
};
|
|
1486
|
-
const TooltipContainer = ({ label, placement = "bottom", mode = "dark", contentTextType = "p", children, dataTestId, }) => (jsxRuntime.jsxs(Popover, { className: cvaTooltipPopover(), placement: placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsxRuntime.jsx(PopoverTrigger, { children: children }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsx("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipContent({ color: mode }), children: jsxRuntime.jsx(Text, { inverted: mode === "dark", type: contentTextType, children: label }) }) })] }));
|
|
1487
1547
|
|
|
1488
1548
|
const cvaIndicator = cssClassVarianceUtilities.cvaMerge(["flex", "items-center"]);
|
|
1489
1549
|
const cvaIndicatorIcon = cssClassVarianceUtilities.cvaMerge(["mr-2"]);
|
|
@@ -1585,7 +1645,7 @@ const cvaIndicatorIconBackground = cssClassVarianceUtilities.cvaMerge(["rounded-
|
|
|
1585
1645
|
*/
|
|
1586
1646
|
const Indicator = (_a) => {
|
|
1587
1647
|
var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, className } = _a, rest = __rest(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping", "className"]);
|
|
1588
|
-
return (jsxRuntime.jsx(Tooltip, { className: className, disabled: withLabel, label: label, children: jsxRuntime.jsxs("div", Object.assign({ className: cvaIndicator(), "data-testid": dataTestId, "aria-label": label }, rest, { children: [jsxRuntime.jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping && (jsxRuntime.jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] }), label !== undefined && withLabel && (jsxRuntime.jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label }))] })) }));
|
|
1648
|
+
return (jsxRuntime.jsx(Tooltip, { className: className, disabled: withLabel, label: label, placement: "bottom", children: jsxRuntime.jsxs("div", Object.assign({ className: cvaIndicator(), "data-testid": dataTestId, "aria-label": label }, rest, { children: [jsxRuntime.jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping && (jsxRuntime.jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] }), label !== undefined && withLabel && (jsxRuntime.jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label }))] })) }));
|
|
1589
1649
|
};
|
|
1590
1650
|
|
|
1591
1651
|
const cvaMenuItem = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -1818,30 +1878,6 @@ const useModal = ({ closeOnOutsideClick } = {}) => {
|
|
|
1818
1878
|
};
|
|
1819
1879
|
};
|
|
1820
1880
|
|
|
1821
|
-
const cvaTip = cssClassVarianceUtilities.cvaMerge("flex text-slate-300 transition hover:text-slate-500");
|
|
1822
|
-
const cvaTipContent = cssClassVarianceUtilities.cvaMerge("flex max-w-sm items-center gap-2 rounded p-2 text-sm", {
|
|
1823
|
-
variants: {
|
|
1824
|
-
color: {
|
|
1825
|
-
light: "bg-white shadow-md",
|
|
1826
|
-
dark: "bg-neutral-800 text-white",
|
|
1827
|
-
},
|
|
1828
|
-
},
|
|
1829
|
-
defaultVariants: {
|
|
1830
|
-
color: "light",
|
|
1831
|
-
},
|
|
1832
|
-
});
|
|
1833
|
-
|
|
1834
|
-
/**
|
|
1835
|
-
* The Tip component is used to show helpful tips or contextual information to the users.
|
|
1836
|
-
* The tip can optionally be rendered as an anchor tag, which redirects to users to an external link on click.
|
|
1837
|
-
|
|
1838
|
-
* @param {TipProps} props - The props for the Tip component
|
|
1839
|
-
* @returns {JSX.Element} Tip component
|
|
1840
|
-
*/
|
|
1841
|
-
const Tip = ({ children, iconProps, dataTestId, className, placement = "bottom", mode = "dark", link, }) => {
|
|
1842
|
-
return (jsxRuntime.jsx("span", { "data-testid": dataTestId, className: cvaTip({ className }), children: jsxRuntime.jsxs(Popover, { placement: placement, activation: { click: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsxRuntime.jsx(PopoverTrigger, { children: jsxRuntime.jsx("div", { "data-testid": dataTestId && `${dataTestId}-trigger`, children: jsxRuntime.jsx(Icon, Object.assign({ name: "QuestionMarkCircle", size: "medium", dataTestId: dataTestId && `${dataTestId}-icon` }, iconProps)) }) }), jsxRuntime.jsx(PopoverContent, { children: jsxRuntime.jsxs("div", { className: cvaTipContent({ color: mode }), children: [jsxRuntime.jsx("div", { children: typeof children === "string" ? jsxRuntime.jsx("p", { children: children }) : children }), link ? (jsxRuntime.jsx("a", { href: link, children: jsxRuntime.jsx(Icon, { name: "ArrowRightCircle" }) })) : null] }) })] }) }));
|
|
1843
|
-
};
|
|
1844
|
-
|
|
1845
1881
|
const cvaPageHeaderContainer = cssClassVarianceUtilities.cvaMerge(["bg-white"], {
|
|
1846
1882
|
variants: {
|
|
1847
1883
|
withBorder: {
|
|
@@ -1881,11 +1917,11 @@ const cvaPageHeaderChildContainer = cssClassVarianceUtilities.cvaMerge(["flex",
|
|
|
1881
1917
|
* @param {PageHeaderProps} props - The props for the PageHeader component
|
|
1882
1918
|
* @returns {JSX.Element} PageHeader component
|
|
1883
1919
|
*/
|
|
1884
|
-
const PageHeader = ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, tagColor, children, tabsList, }) => {
|
|
1920
|
+
const PageHeader = ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, tagColor, children, tabsList, linkText = "Help Center Article", }) => {
|
|
1885
1921
|
return (jsxRuntime.jsxs("div", { className: cvaPageHeaderContainer({
|
|
1886
1922
|
className: `${className} tu-page-header`,
|
|
1887
1923
|
withBorder: !Boolean(tabsList),
|
|
1888
|
-
}), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeader(), children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container`, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo && (jsxRuntime.jsx(IconButton, { to: backTo, renderAs: reactRouterDom.Link, color: "tertiary", variant: "transparent", size: "small", icon: jsxRuntime.jsx(Icon, { name: "ArrowLeft" }) })), jsxRuntime.jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId && `${dataTestId}-heading`, children: title }), description && !showLoading && (jsxRuntime.jsx(
|
|
1924
|
+
}), "data-testid": dataTestId, children: [jsxRuntime.jsxs("div", { className: cvaPageHeader(), children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container`, children: [jsxRuntime.jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo && (jsxRuntime.jsx(IconButton, { to: backTo, renderAs: reactRouterDom.Link, color: "tertiary", variant: "transparent", size: "small", icon: jsxRuntime.jsx(Icon, { name: "ArrowLeft" }) })), jsxRuntime.jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId && `${dataTestId}-heading`, children: title }), description && !showLoading && (jsxRuntime.jsxs("div", { className: "flex h-fit items-center gap-1", children: [jsxRuntime.jsx(Tooltip, { label: description, dataTestId: dataTestId && `${dataTestId}-tooltip`, iconProps: { name: "QuestionMarkCircle" }, placement: "bottom" }), link && (jsxRuntime.jsxs(reactRouterDom.Link, { to: link, "data-testid": "tooltip-link", target: "_blank", className: "text-primary-600 hover:text-primary-700 flex h-4 items-center gap-1 text-xs underline", children: [linkText, jsxRuntime.jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" })] }))] }))] }), tag && !showLoading && (jsxRuntime.jsx(Tag, { dataTestId: dataTestId, color: tagColor, children: tag })), showLoading && jsxRuntime.jsx(Spinner, { dataTestId: dataTestId && `${dataTestId}-spinner`, centering: "vertically" }), action] }), jsxRuntime.jsx("div", { className: cvaPageHeaderChildContainer(), children: children })] }), tabsList] }));
|
|
1889
1925
|
};
|
|
1890
1926
|
|
|
1891
1927
|
const cvaPagination = cssClassVarianceUtilities.cvaMerge(["flex", "items-center", "gap-1"]);
|
|
@@ -3023,7 +3059,6 @@ exports.Tag = Tag;
|
|
|
3023
3059
|
exports.Text = Text;
|
|
3024
3060
|
exports.Timeline = Timeline;
|
|
3025
3061
|
exports.TimelineElement = TimelineElement;
|
|
3026
|
-
exports.Tip = Tip;
|
|
3027
3062
|
exports.Tooltip = Tooltip;
|
|
3028
3063
|
exports.ValueBar = ValueBar;
|
|
3029
3064
|
exports.WidgetBody = WidgetBody;
|
package/index.esm.js
CHANGED
|
@@ -10,7 +10,7 @@ import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
|
10
10
|
import { useMeasure, useCopyToClipboard, usePrevious } from 'react-use';
|
|
11
11
|
import { DayPicker as DayPicker$1 } from 'react-day-picker';
|
|
12
12
|
import { enGB, enUS, da, de, cs, nl, fr, fi, hu, it, nb, pl, pt, ru, ro, es, sv, ja, th } from 'date-fns/locale';
|
|
13
|
-
import { useFloating, autoUpdate, offset, flip, shift, size, useClick, useDismiss, useHover as useHover$1, useRole, useInteractions, useMergeRefs, FloatingPortal, FloatingFocusManager } from '@floating-ui/react';
|
|
13
|
+
import { useFloating, autoUpdate, offset, flip, shift, size, useClick, useDismiss, useHover as useHover$1, useRole, useInteractions, useMergeRefs, FloatingPortal, FloatingFocusManager, arrow, useTransitionStatus, FloatingArrow } from '@floating-ui/react';
|
|
14
14
|
import usePortal from 'react-useportal';
|
|
15
15
|
import { Link, UNSAFE_NavigationContext } from 'react-router-dom';
|
|
16
16
|
import { HelmetProvider, Helmet } from 'react-helmet-async';
|
|
@@ -1424,36 +1424,96 @@ const ExternalLink = ({ rel = "noreferrer", target = "_blank", href, className,
|
|
|
1424
1424
|
return (jsx("a", { onClick: onClick, "data-testid": dataTestId, className: cvaExternalLink({ className }), title: title, href: href, rel: rel, target: target, children: children }));
|
|
1425
1425
|
};
|
|
1426
1426
|
|
|
1427
|
-
const cvaTooltipFlexContainer = cvaMerge("inline-flex");
|
|
1427
|
+
const cvaTooltipFlexContainer = cvaMerge("inline-flex hover:cursor-pointer");
|
|
1428
|
+
const cvaTooltipIcon = cvaMerge("flex h-max w-fit text-slate-300 transition hover:cursor-pointer hover:text-slate-400", {
|
|
1429
|
+
variants: {
|
|
1430
|
+
color: {
|
|
1431
|
+
light: "hover:text-white",
|
|
1432
|
+
dark: "hover:text-slate-400",
|
|
1433
|
+
},
|
|
1434
|
+
defaultVariants: {
|
|
1435
|
+
color: "dark",
|
|
1436
|
+
},
|
|
1437
|
+
},
|
|
1438
|
+
});
|
|
1428
1439
|
const cvaTooltipPopover = cvaMerge("pointer-events-none origin-center");
|
|
1429
|
-
cvaMerge("
|
|
1430
|
-
|
|
1440
|
+
const cvaTooltipPopoverTail = cvaMerge("", {
|
|
1441
|
+
variants: {
|
|
1442
|
+
placement: {
|
|
1443
|
+
top: "top-full left-2/4 ml-[-5px]",
|
|
1444
|
+
"top-start": "top-full left-[5%]",
|
|
1445
|
+
"top-end": "top-full right-[5%]",
|
|
1446
|
+
bottom: "bottom-full right-2/4 mr-[-6px] ",
|
|
1447
|
+
"bottom-start": "bottom-full left-[5%]",
|
|
1448
|
+
"bottom-end": "bottom-full right-[5%]",
|
|
1449
|
+
left: "top-2/4 left-full mt-[-6px]",
|
|
1450
|
+
"left-start": "top-1/4 top-[8%]",
|
|
1451
|
+
"left-end": "bottom-1/4 bottom-[8%]",
|
|
1452
|
+
right: "top-2/4 right-full mt-[-6px] ",
|
|
1453
|
+
"right-start": "top-1/4 top-[8%]",
|
|
1454
|
+
"right-end": "bottom-1/4 bottom-[8%]",
|
|
1455
|
+
},
|
|
1456
|
+
mode: {
|
|
1457
|
+
light: "fill-white",
|
|
1458
|
+
dark: "fill-slate-600",
|
|
1459
|
+
},
|
|
1460
|
+
},
|
|
1461
|
+
defaultVariants: {
|
|
1462
|
+
placement: "bottom",
|
|
1463
|
+
mode: "dark",
|
|
1464
|
+
},
|
|
1465
|
+
});
|
|
1466
|
+
cvaMerge(["component-popover-border", "z-popover", "animate-fade-in-fast"]);
|
|
1467
|
+
const cvaTooltipPopoverContent = cvaMerge("max-w-sm rounded p-2", {
|
|
1431
1468
|
variants: {
|
|
1432
1469
|
color: {
|
|
1433
|
-
light: "bg-white shadow-
|
|
1434
|
-
dark: "bg-
|
|
1470
|
+
light: "bg-white shadow-lg",
|
|
1471
|
+
dark: "bg-slate-600 text-white",
|
|
1435
1472
|
},
|
|
1436
1473
|
},
|
|
1437
1474
|
defaultVariants: {
|
|
1438
|
-
color: "
|
|
1475
|
+
color: "dark",
|
|
1439
1476
|
},
|
|
1440
1477
|
});
|
|
1441
1478
|
|
|
1442
1479
|
/**
|
|
1443
|
-
*
|
|
1480
|
+
*
|
|
1481
|
+
* @description Adding Tooltip Arrow
|
|
1482
|
+
* @returns {JSX.Element} Tooltip floating Arrow
|
|
1483
|
+
*/
|
|
1484
|
+
const FloatingArrowContainer = ({ arrowRef, mode = "dark", }) => {
|
|
1485
|
+
const { context: floatingContext } = usePopoverContext();
|
|
1486
|
+
return (jsx(FloatingArrow, { ref: arrowRef, context: floatingContext, className: cvaTooltipPopoverTail({ mode, placement: floatingContext.placement }) }));
|
|
1487
|
+
};
|
|
1488
|
+
/**
|
|
1489
|
+
* Tooltips display additional information upon hover. The information included should be contextual, helpful, and nonessential while providing that extra ability to communicate and give clarity to a user.
|
|
1490
|
+
*
|
|
1491
|
+
* Tooltips should be used sparingly and contain succinct, supplementary information, and they should contain read-only text. **❗️Do not include interactive elements in tooltips ** (no links, buttons, etc). Interactive elements in tooltips are inaccessible since tooltips do not receive focus.
|
|
1492
|
+
*
|
|
1493
|
+
* **Do use** tooltips to expose names of icon buttons that lack visual labels, when more information is useful in helping a user understand the context, when an element needs additional explanation, or use when defining a term or inline item.
|
|
1494
|
+
*
|
|
1495
|
+
* **Do not use** tooltips to include information that is necessary for the user to complete their task. Use helper text that is always visible and accessible for vital information.
|
|
1444
1496
|
|
|
1445
1497
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
1446
1498
|
* @returns {JSX.Element} Tooltip component
|
|
1447
1499
|
*/
|
|
1448
|
-
const Tooltip = (
|
|
1449
|
-
|
|
1500
|
+
const Tooltip = ({ children, dataTestId = "tool-tip", disabled, className, label, placement = "auto", mode = "dark", contentTextType = "p", iconProps, }) => {
|
|
1501
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
1502
|
+
const arrowRef = React.useRef(null);
|
|
1503
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
1504
|
+
placement: placement === "auto" ? "bottom" : placement,
|
|
1505
|
+
open: isOpen,
|
|
1506
|
+
onOpenChange: setIsOpen,
|
|
1507
|
+
middleware: [offset(8), arrow({ element: arrowRef })],
|
|
1508
|
+
whileElementsMounted: autoUpdate,
|
|
1509
|
+
});
|
|
1510
|
+
const { isMounted } = useTransitionStatus(context);
|
|
1450
1511
|
const wrappedChildren = (jsx("div", { className: cvaTooltipFlexContainer({ className }), "data-testid": dataTestId && `${dataTestId}-parent`, children: children }));
|
|
1451
1512
|
if (disabled) {
|
|
1452
1513
|
return wrappedChildren;
|
|
1453
1514
|
}
|
|
1454
|
-
return (jsx(
|
|
1515
|
+
return (jsxs(Popover, { className: cvaTooltipPopover(), placement: placement === "auto" ? "bottom" : placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsx(PopoverTrigger, { className: cvaTooltipIcon({ color: mode }), ref: refs.setReference, onMouseEnter: () => setIsOpen(true), onMouseLeave: () => setIsOpen(false), "data-testid": dataTestId && `${dataTestId}-trigger`, children: children === undefined ? (jsx("div", { children: jsx(Icon, Object.assign({ name: "QuestionMarkCircle", size: "small", dataTestId: dataTestId && `${dataTestId}-icon` }, iconProps)) })) : (wrappedChildren) }), isMounted && (jsx("div", { ref: refs.setFloating, style: floatingStyles, children: jsx(PopoverContent, { children: jsxs("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipPopoverContent({ color: mode }), "data-testid": `${dataTestId}-content`, children: [jsx(Text, { inverted: mode === "dark", type: contentTextType, children: label }), placement !== "auto" && jsx(FloatingArrowContainer, { arrowRef: arrowRef, mode: mode })] }) }) }))] }));
|
|
1455
1516
|
};
|
|
1456
|
-
const TooltipContainer = ({ label, placement = "bottom", mode = "dark", contentTextType = "p", children, dataTestId, }) => (jsxs(Popover, { className: cvaTooltipPopover(), placement: placement, activation: { hover: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsx(PopoverTrigger, { children: children }), jsx(PopoverContent, { children: jsx("div", { "aria-label": typeof label === "string" ? label : undefined, className: cvaTooltipContent({ color: mode }), children: jsx(Text, { inverted: mode === "dark", type: contentTextType, children: label }) }) })] }));
|
|
1457
1517
|
|
|
1458
1518
|
const cvaIndicator = cvaMerge(["flex", "items-center"]);
|
|
1459
1519
|
const cvaIndicatorIcon = cvaMerge(["mr-2"]);
|
|
@@ -1555,7 +1615,7 @@ const cvaIndicatorIconBackground = cvaMerge(["rounded-full", "items-center", "ju
|
|
|
1555
1615
|
*/
|
|
1556
1616
|
const Indicator = (_a) => {
|
|
1557
1617
|
var { dataTestId, icon, label, color = "unknown", withBackground = true, withLabel = true, ping = false, className } = _a, rest = __rest(_a, ["dataTestId", "icon", "label", "color", "withBackground", "withLabel", "ping", "className"]);
|
|
1558
|
-
return (jsx(Tooltip, { className: className, disabled: withLabel, label: label, children: jsxs("div", Object.assign({ className: cvaIndicator(), "data-testid": dataTestId, "aria-label": label }, rest, { children: [jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping && (jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] }), label !== undefined && withLabel && (jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label }))] })) }));
|
|
1618
|
+
return (jsx(Tooltip, { className: className, disabled: withLabel, label: label, placement: "bottom", children: jsxs("div", Object.assign({ className: cvaIndicator(), "data-testid": dataTestId, "aria-label": label }, rest, { children: [jsxs("div", { className: cvaIndicatorIconBackground({ color, background: withBackground ? "visible" : "hidden" }), "data-testid": dataTestId ? `${dataTestId}-background` : "indicator-background", children: [ping && (jsx("div", { className: cvaIndicatorPing({ color }), "data-testid": dataTestId ? `${dataTestId}-ping` : "indicator-ping" })), icon] }), label !== undefined && withLabel && (jsx("div", { className: cvaIndicatorLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : "indicator-label", children: label }))] })) }));
|
|
1559
1619
|
};
|
|
1560
1620
|
|
|
1561
1621
|
const cvaMenuItem = cvaMerge([
|
|
@@ -1788,30 +1848,6 @@ const useModal = ({ closeOnOutsideClick } = {}) => {
|
|
|
1788
1848
|
};
|
|
1789
1849
|
};
|
|
1790
1850
|
|
|
1791
|
-
const cvaTip = cvaMerge("flex text-slate-300 transition hover:text-slate-500");
|
|
1792
|
-
const cvaTipContent = cvaMerge("flex max-w-sm items-center gap-2 rounded p-2 text-sm", {
|
|
1793
|
-
variants: {
|
|
1794
|
-
color: {
|
|
1795
|
-
light: "bg-white shadow-md",
|
|
1796
|
-
dark: "bg-neutral-800 text-white",
|
|
1797
|
-
},
|
|
1798
|
-
},
|
|
1799
|
-
defaultVariants: {
|
|
1800
|
-
color: "light",
|
|
1801
|
-
},
|
|
1802
|
-
});
|
|
1803
|
-
|
|
1804
|
-
/**
|
|
1805
|
-
* The Tip component is used to show helpful tips or contextual information to the users.
|
|
1806
|
-
* The tip can optionally be rendered as an anchor tag, which redirects to users to an external link on click.
|
|
1807
|
-
|
|
1808
|
-
* @param {TipProps} props - The props for the Tip component
|
|
1809
|
-
* @returns {JSX.Element} Tip component
|
|
1810
|
-
*/
|
|
1811
|
-
const Tip = ({ children, iconProps, dataTestId, className, placement = "bottom", mode = "dark", link, }) => {
|
|
1812
|
-
return (jsx("span", { "data-testid": dataTestId, className: cvaTip({ className }), children: jsxs(Popover, { placement: placement, activation: { click: true }, dataTestId: dataTestId !== null && dataTestId !== void 0 ? dataTestId : "", children: [jsx(PopoverTrigger, { children: jsx("div", { "data-testid": dataTestId && `${dataTestId}-trigger`, children: jsx(Icon, Object.assign({ name: "QuestionMarkCircle", size: "medium", dataTestId: dataTestId && `${dataTestId}-icon` }, iconProps)) }) }), jsx(PopoverContent, { children: jsxs("div", { className: cvaTipContent({ color: mode }), children: [jsx("div", { children: typeof children === "string" ? jsx("p", { children: children }) : children }), link ? (jsx("a", { href: link, children: jsx(Icon, { name: "ArrowRightCircle" }) })) : null] }) })] }) }));
|
|
1813
|
-
};
|
|
1814
|
-
|
|
1815
1851
|
const cvaPageHeaderContainer = cvaMerge(["bg-white"], {
|
|
1816
1852
|
variants: {
|
|
1817
1853
|
withBorder: {
|
|
@@ -1851,11 +1887,11 @@ const cvaPageHeaderChildContainer = cvaMerge(["flex", "flex-wrap", "gap-x-6", "i
|
|
|
1851
1887
|
* @param {PageHeaderProps} props - The props for the PageHeader component
|
|
1852
1888
|
* @returns {JSX.Element} PageHeader component
|
|
1853
1889
|
*/
|
|
1854
|
-
const PageHeader = ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, tagColor, children, tabsList, }) => {
|
|
1890
|
+
const PageHeader = ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, tagColor, children, tabsList, linkText = "Help Center Article", }) => {
|
|
1855
1891
|
return (jsxs("div", { className: cvaPageHeaderContainer({
|
|
1856
1892
|
className: `${className} tu-page-header`,
|
|
1857
1893
|
withBorder: !Boolean(tabsList),
|
|
1858
|
-
}), "data-testid": dataTestId, children: [jsxs("div", { className: cvaPageHeader(), children: [jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container`, children: [jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo && (jsx(IconButton, { to: backTo, renderAs: Link, color: "tertiary", variant: "transparent", size: "small", icon: jsx(Icon, { name: "ArrowLeft" }) })), jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId && `${dataTestId}-heading`, children: title }), description && !showLoading && (jsx(
|
|
1894
|
+
}), "data-testid": dataTestId, children: [jsxs("div", { className: cvaPageHeader(), children: [jsxs("div", { className: cvaPageHeaderHeadingAccessoriesContainer(), "data-testid": dataTestId && `${dataTestId}-heading-container`, children: [jsxs("div", { className: cvaPageHeaderHeadingContainer(), children: [backTo && (jsx(IconButton, { to: backTo, renderAs: Link, color: "tertiary", variant: "transparent", size: "small", icon: jsx(Icon, { name: "ArrowLeft" }) })), jsx("h1", { className: cvaPageHeaderHeading(), "data-testid": dataTestId && `${dataTestId}-heading`, children: title }), description && !showLoading && (jsxs("div", { className: "flex h-fit items-center gap-1", children: [jsx(Tooltip, { label: description, dataTestId: dataTestId && `${dataTestId}-tooltip`, iconProps: { name: "QuestionMarkCircle" }, placement: "bottom" }), link && (jsxs(Link, { to: link, "data-testid": "tooltip-link", target: "_blank", className: "text-primary-600 hover:text-primary-700 flex h-4 items-center gap-1 text-xs underline", children: [linkText, jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" })] }))] }))] }), tag && !showLoading && (jsx(Tag, { dataTestId: dataTestId, color: tagColor, children: tag })), showLoading && jsx(Spinner, { dataTestId: dataTestId && `${dataTestId}-spinner`, centering: "vertically" }), action] }), jsx("div", { className: cvaPageHeaderChildContainer(), children: children })] }), tabsList] }));
|
|
1859
1895
|
};
|
|
1860
1896
|
|
|
1861
1897
|
const cvaPagination = cvaMerge(["flex", "items-center", "gap-1"]);
|
|
@@ -2946,4 +2982,4 @@ const useVisibilityChange = ({ onChange, targetState = "hidden" }) => {
|
|
|
2946
2982
|
}, [onChange, targetState]);
|
|
2947
2983
|
};
|
|
2948
2984
|
|
|
2949
|
-
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,
|
|
2985
|
+
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, cvaButtonSpinner, cvaClickable, cvaIconButtonContainer, 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
|
@@ -15,6 +15,10 @@ export interface PageHeaderProps extends CommonProps {
|
|
|
15
15
|
* The link to which user is redirected to if user clicks on the tip.
|
|
16
16
|
*/
|
|
17
17
|
link?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Display text of the specified link
|
|
20
|
+
*/
|
|
21
|
+
linkText?: string;
|
|
18
22
|
/**
|
|
19
23
|
* Additional actions to be rendered along with the header.
|
|
20
24
|
*/
|
|
@@ -51,4 +55,4 @@ export interface PageHeaderProps extends CommonProps {
|
|
|
51
55
|
* @param {PageHeaderProps} props - The props for the PageHeader component
|
|
52
56
|
* @returns {JSX.Element} PageHeader component
|
|
53
57
|
*/
|
|
54
|
-
export declare const PageHeader: ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, tagColor, children, tabsList, }: PageHeaderProps) => JSX.Element;
|
|
58
|
+
export declare const PageHeader: ({ className, dataTestId, action, showLoading, description, link, title, tag, backTo, tagColor, children, tabsList, linkText, }: PageHeaderProps) => JSX.Element;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { Placement } from "@floating-ui/react";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { CommonProps } from "../../common";
|
|
3
|
-
import {
|
|
4
|
+
import { IconProps } from "../Icon/Icon";
|
|
4
5
|
import { TextType } from "../Text";
|
|
6
|
+
export type ToolTipVariant = "icon" | "none";
|
|
7
|
+
export type TooltipPlacement = Placement | "auto";
|
|
5
8
|
export interface TooltipProps extends CommonProps {
|
|
6
9
|
/**
|
|
7
10
|
* The text to be displayed in the tooltip.
|
|
@@ -10,7 +13,7 @@ export interface TooltipProps extends CommonProps {
|
|
|
10
13
|
/**
|
|
11
14
|
* Where the tooltip should preferentially be placed.
|
|
12
15
|
*/
|
|
13
|
-
placement?:
|
|
16
|
+
placement?: TooltipPlacement;
|
|
14
17
|
/**
|
|
15
18
|
* Child nodes
|
|
16
19
|
*/
|
|
@@ -27,11 +30,21 @@ export interface TooltipProps extends CommonProps {
|
|
|
27
30
|
* Type of content.
|
|
28
31
|
*/
|
|
29
32
|
contentTextType?: TextType;
|
|
33
|
+
/**
|
|
34
|
+
* The props for setting the icon on this tip.
|
|
35
|
+
*/
|
|
36
|
+
iconProps?: Omit<IconProps, "type">;
|
|
30
37
|
}
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
39
|
+
* Tooltips display additional information upon hover. The information included should be contextual, helpful, and nonessential while providing that extra ability to communicate and give clarity to a user.
|
|
40
|
+
*
|
|
41
|
+
* Tooltips should be used sparingly and contain succinct, supplementary information, and they should contain read-only text. **❗️Do not include interactive elements in tooltips ** (no links, buttons, etc). Interactive elements in tooltips are inaccessible since tooltips do not receive focus.
|
|
42
|
+
*
|
|
43
|
+
* **Do use** tooltips to expose names of icon buttons that lack visual labels, when more information is useful in helping a user understand the context, when an element needs additional explanation, or use when defining a term or inline item.
|
|
44
|
+
*
|
|
45
|
+
* **Do not use** tooltips to include information that is necessary for the user to complete their task. Use helper text that is always visible and accessible for vital information.
|
|
33
46
|
|
|
34
47
|
* @param {TooltipProps} props - The props for the Tooltip component
|
|
35
48
|
* @returns {JSX.Element} Tooltip component
|
|
36
49
|
*/
|
|
37
|
-
export declare const Tooltip: ({ children, dataTestId, disabled, className,
|
|
50
|
+
export declare const Tooltip: ({ children, dataTestId, disabled, className, label, placement, mode, contentTextType, iconProps, }: TooltipProps) => JSX.Element;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export declare const cvaTooltipFlexContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
2
|
+
export declare const cvaTooltipIcon: (props?: ({
|
|
3
|
+
color?: "light" | "dark" | null | undefined;
|
|
4
|
+
defaultVariants?: "color" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
2
6
|
export declare const cvaTooltipPopover: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
7
|
+
export declare const cvaTooltipPopoverTail: (props?: ({
|
|
8
|
+
placement?: "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end" | null | undefined;
|
|
9
|
+
mode?: "light" | "dark" | null | undefined;
|
|
10
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
11
|
+
export declare const cvaTooltipPopoverContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
12
|
+
export declare const cvaTooltipPopoverContent: (props?: ({
|
|
5
13
|
color?: "light" | "dark" | null | undefined;
|
|
6
14
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MakePropertyOptional, MappedOmit } from "@trackunit/shared-utils";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { CommonProps } from "../../common";
|
|
4
|
-
import { IconProps } from "../Icon/Icon";
|
|
5
|
-
import { TooltipProps } from "../Tooltip";
|
|
6
|
-
export interface TipProps extends CommonProps, Pick<TooltipProps, "placement" | "mode"> {
|
|
7
|
-
/**
|
|
8
|
-
* Child nodes to render inside the tip.
|
|
9
|
-
*/
|
|
10
|
-
children: React.ReactNode | string;
|
|
11
|
-
/**
|
|
12
|
-
* The props for setting the icon on this tip.
|
|
13
|
-
*/
|
|
14
|
-
iconProps?: MakePropertyOptional<MappedOmit<IconProps, "size" | "type">, "name">;
|
|
15
|
-
/**
|
|
16
|
-
* Shows an icon with link as the href attribute inside the tip.
|
|
17
|
-
*/
|
|
18
|
-
link?: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The Tip component is used to show helpful tips or contextual information to the users.
|
|
22
|
-
* The tip can optionally be rendered as an anchor tag, which redirects to users to an external link on click.
|
|
23
|
-
|
|
24
|
-
* @param {TipProps} props - The props for the Tip component
|
|
25
|
-
* @returns {JSX.Element} Tip component
|
|
26
|
-
*/
|
|
27
|
-
export declare const Tip: ({ children, iconProps, dataTestId, className, placement, mode, link, }: TipProps) => JSX.Element;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const cvaTip: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
2
|
-
export declare const cvaTipContent: (props?: ({
|
|
3
|
-
color?: "light" | "dark" | null | undefined;
|
|
4
|
-
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./Tip";
|