infinity-ui-elements 1.15.1 → 1.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +5 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.stories.d.ts +1 -0
- package/dist/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/index.esm.js +89 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +89 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;CAC3D;AAED,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;IACzE;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,E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aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACrC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CAChE;AAED,eAAO,MAAM,MAAM,sFAyYlB,CAAC"}
|
|
@@ -12,7 +12,7 @@ export interface TooltipProps {
|
|
|
12
12
|
/**
|
|
13
13
|
* Description text for the tooltip
|
|
14
14
|
*/
|
|
15
|
-
description: string;
|
|
15
|
+
description: string | React.ReactNode;
|
|
16
16
|
/**
|
|
17
17
|
* Placement of the tooltip relative to the trigger
|
|
18
18
|
*/
|
|
@@ -33,6 +33,10 @@ export interface TooltipProps {
|
|
|
33
33
|
* Whether the tooltip is disabled
|
|
34
34
|
*/
|
|
35
35
|
disabled?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Trigger mode for opening tooltip
|
|
38
|
+
*/
|
|
39
|
+
trigger?: "hover" | "click";
|
|
36
40
|
}
|
|
37
41
|
declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
38
42
|
export { Tooltip, tooltipVariants };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,QAAA,MAAM,eAAe,yFAEpB,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,QAAA,MAAM,eAAe,yFAEpB,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IACtC;;OAEG;IACH,SAAS,CAAC,EACN,WAAW,GACX,KAAK,GACL,SAAS,GACT,cAAc,GACd,QAAQ,GACR,YAAY,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAC7B;AAED,QAAA,MAAM,OAAO,qFA+JZ,CAAC;AAIF,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -10,6 +10,7 @@ export declare const AllPlacements: Story;
|
|
|
10
10
|
export declare const WithoutArrow: Story;
|
|
11
11
|
export declare const LongContent: Story;
|
|
12
12
|
export declare const CustomDelay: Story;
|
|
13
|
+
export declare const ClickTrigger: Story;
|
|
13
14
|
export declare const InstantTooltip: Story;
|
|
14
15
|
export declare const Disabled: Story;
|
|
15
16
|
export declare const DifferentTriggers: Story;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,OAAO,
|
|
1
|
+
{"version":3,"file":"Tooltip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Tooltip/Tooltip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,OAAO,CA8B9B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,OAAO,CAAC,CAAC;AAEtC,eAAO,MAAM,OAAO,EAAE,KAcrB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAW5B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KActB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KA0D3B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAY1B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAazB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAazB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAa1B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAa5B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAatB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAwC/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KA4BzB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAmB3B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KA2DvB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -5315,7 +5315,10 @@ var Content2 = HoverCardContent;
|
|
|
5315
5315
|
var Arrow2 = HoverCardArrow;
|
|
5316
5316
|
|
|
5317
5317
|
const tooltipVariants = cva("z-[9998] bg-popup-fill-intense text-action-ink-on-primary-normal border border-popup-outline-subtle flex flex-col p-4 rounded-xlarge min-w-[200px] max-w-[300px] shadow-[0_4px_20px_rgba(0,0,0,0.15)]");
|
|
5318
|
-
const Tooltip = React.forwardRef(({ children, heading, description, placement = "top", showArrow = true, className, delay = 200, disabled = false, }, ref) => {
|
|
5318
|
+
const Tooltip = React.forwardRef(({ children, heading, description, placement = "top", showArrow = true, className, delay = 200, disabled = false, trigger = "hover", }, ref) => {
|
|
5319
|
+
const [open, setOpen] = React.useState(false);
|
|
5320
|
+
const triggerRef = React.useRef(null);
|
|
5321
|
+
const contentRef = React.useRef(null);
|
|
5319
5322
|
const { side, align } = React.useMemo(() => {
|
|
5320
5323
|
switch (placement) {
|
|
5321
5324
|
case "top-start":
|
|
@@ -5333,10 +5336,65 @@ const Tooltip = React.forwardRef(({ children, heading, description, placement =
|
|
|
5333
5336
|
return { side: "top", align: "center" };
|
|
5334
5337
|
}
|
|
5335
5338
|
}, [placement]);
|
|
5336
|
-
|
|
5337
|
-
return
|
|
5338
|
-
|
|
5339
|
-
|
|
5339
|
+
const mergeRefs = (...refs) => {
|
|
5340
|
+
return (node) => {
|
|
5341
|
+
refs.forEach((currentRef) => {
|
|
5342
|
+
if (typeof currentRef === "function") {
|
|
5343
|
+
currentRef(node);
|
|
5344
|
+
return;
|
|
5345
|
+
}
|
|
5346
|
+
if (currentRef && typeof currentRef === "object") {
|
|
5347
|
+
currentRef.current = node;
|
|
5348
|
+
}
|
|
5349
|
+
});
|
|
5350
|
+
};
|
|
5351
|
+
};
|
|
5352
|
+
const triggerChild = React.cloneElement(children, {
|
|
5353
|
+
ref: mergeRefs(triggerRef, children.ref),
|
|
5354
|
+
onClick: (event) => {
|
|
5355
|
+
if (trigger === "click" && !disabled) {
|
|
5356
|
+
setOpen((prev) => !prev);
|
|
5357
|
+
}
|
|
5358
|
+
children.props.onClick?.(event);
|
|
5359
|
+
},
|
|
5360
|
+
});
|
|
5361
|
+
React.useEffect(() => {
|
|
5362
|
+
if (disabled || trigger !== "click" || !open)
|
|
5363
|
+
return;
|
|
5364
|
+
const handlePointerDownOutside = (event) => {
|
|
5365
|
+
const target = event.target;
|
|
5366
|
+
if (!target)
|
|
5367
|
+
return;
|
|
5368
|
+
if (triggerRef.current?.contains(target) ||
|
|
5369
|
+
contentRef.current?.contains(target)) {
|
|
5370
|
+
return;
|
|
5371
|
+
}
|
|
5372
|
+
setOpen(false);
|
|
5373
|
+
};
|
|
5374
|
+
const handleEscape = (event) => {
|
|
5375
|
+
if (event.key === "Escape") {
|
|
5376
|
+
setOpen(false);
|
|
5377
|
+
}
|
|
5378
|
+
};
|
|
5379
|
+
document.addEventListener("mousedown", handlePointerDownOutside);
|
|
5380
|
+
document.addEventListener("touchstart", handlePointerDownOutside);
|
|
5381
|
+
document.addEventListener("keydown", handleEscape);
|
|
5382
|
+
return () => {
|
|
5383
|
+
document.removeEventListener("mousedown", handlePointerDownOutside);
|
|
5384
|
+
document.removeEventListener("touchstart", handlePointerDownOutside);
|
|
5385
|
+
document.removeEventListener("keydown", handleEscape);
|
|
5386
|
+
};
|
|
5387
|
+
}, [disabled, open, trigger]);
|
|
5388
|
+
React.useEffect(() => {
|
|
5389
|
+
if (disabled) {
|
|
5390
|
+
setOpen(false);
|
|
5391
|
+
}
|
|
5392
|
+
}, [disabled]);
|
|
5393
|
+
return (jsxs(Root2, { open: trigger === "click" || disabled ? (disabled ? false : open) : undefined, onOpenChange: (nextOpen) => {
|
|
5394
|
+
if (!disabled && trigger === "hover") {
|
|
5395
|
+
setOpen(nextOpen);
|
|
5396
|
+
}
|
|
5397
|
+
}, openDelay: delay, closeDelay: 250, children: [jsx(Trigger, { asChild: true, children: triggerChild }), jsx(Portal, { children: jsxs(Content2, { ref: mergeRefs(contentRef, ref), role: "tooltip", side: side, align: align, sideOffset: 14, collisionPadding: 8, className: cn(tooltipVariants(), className), children: [showArrow && (jsx(Arrow2, { width: 12, height: 6, className: "fill-popup-fill-intense" })), jsxs("div", { className: "relative flex flex-col gap-2", children: [heading && (jsx(Text, { variant: "body", size: "medium", weight: "semibold", color: "onPrimary", children: heading })), typeof description === "string" ? (jsx(Text, { variant: "body", size: "small", weight: "regular", color: "onPrimary", children: description })) : (description)] })] }) })] }));
|
|
5340
5398
|
});
|
|
5341
5399
|
Tooltip.displayName = "Tooltip";
|
|
5342
5400
|
|
|
@@ -6817,7 +6875,7 @@ const TextField = React.forwardRef(({ label, helperText, errorText, successText,
|
|
|
6817
6875
|
});
|
|
6818
6876
|
TextField.displayName = "TextField";
|
|
6819
6877
|
|
|
6820
|
-
const Select = React.forwardRef(({ className, options = [], value: controlledValue, defaultValue, onChange, placeholder = "Select an option", label, helperText, errorText, successText, validationState = "none", isDisabled = false, isRequired = false, isOptional = false, isLoading = false, size = "medium", prefix, suffix, showClearButton = false, onClear, showLeadingIcon = false, containerClassName, labelClassName, triggerClassName, menuClassName, menuWidth = "full", sectionHeading, emptyTitle = "No options available", emptyDescription = "There are no options to select from.", emptyIcon, infoHeading, infoDescription, LinkComponent, linkText, linkHref, onLinkClick, ...props }, ref) => {
|
|
6878
|
+
const Select = React.forwardRef(({ className, options = [], value: controlledValue, defaultValue, onChange, placeholder = "Select an option", label, helperText, errorText, successText, validationState = "none", isDisabled = false, isRequired = false, isOptional = false, isLoading = false, size = "medium", prefix, suffix, showClearButton = false, onClear, showLeadingIcon = false, containerClassName, labelClassName, triggerClassName, menuClassName, menuWidth = "full", sectionHeading, emptyTitle = "No options available", emptyDescription = "There are no options to select from.", emptyIcon, infoHeading, infoDescription, LinkComponent, linkText, linkHref, onLinkClick, onClick, ...props }, ref) => {
|
|
6821
6879
|
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);
|
|
6822
6880
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
6823
6881
|
const [dropdownPlacement, setDropdownPlacement] = React.useState("bottom");
|
|
@@ -6846,16 +6904,31 @@ const Select = React.forwardRef(({ className, options = [], value: controlledVal
|
|
|
6846
6904
|
setIsOpen(newOpen);
|
|
6847
6905
|
}
|
|
6848
6906
|
};
|
|
6849
|
-
const
|
|
6907
|
+
const shouldIgnoreOpenInteraction = (target) => {
|
|
6908
|
+
if (!(target instanceof HTMLElement))
|
|
6909
|
+
return true;
|
|
6910
|
+
if (dropdownContainerRef.current?.contains(target))
|
|
6911
|
+
return true;
|
|
6912
|
+
if (target.closest("button") || target.closest("a"))
|
|
6913
|
+
return true;
|
|
6914
|
+
return false;
|
|
6915
|
+
};
|
|
6916
|
+
/** Open dropdown from any pointer activation on the composite (label, helper, input row, icons). */
|
|
6917
|
+
const handleCompositePointerActivate = (target) => {
|
|
6850
6918
|
if (isDisabled || isLoading)
|
|
6851
6919
|
return;
|
|
6852
|
-
|
|
6853
|
-
// Let clear/other explicit buttons and links behave normally.
|
|
6854
|
-
if (target.closest("button") || target.closest("a"))
|
|
6920
|
+
if (shouldIgnoreOpenInteraction(target))
|
|
6855
6921
|
return;
|
|
6856
|
-
// Open the dropdown when clicking anywhere on the trigger area.
|
|
6857
6922
|
handleOpenChange(true);
|
|
6858
6923
|
};
|
|
6924
|
+
const handleTriggerContainerPointerDownCapture = (event) => {
|
|
6925
|
+
if (event.button !== undefined && event.button !== 0)
|
|
6926
|
+
return;
|
|
6927
|
+
handleCompositePointerActivate(event.target);
|
|
6928
|
+
};
|
|
6929
|
+
const handleTriggerContainerClickCapture = (event) => {
|
|
6930
|
+
handleCompositePointerActivate(event.target);
|
|
6931
|
+
};
|
|
6859
6932
|
const handleSelect = (option) => {
|
|
6860
6933
|
if (controlledValue === undefined) {
|
|
6861
6934
|
setUncontrolledValue(option.value);
|
|
@@ -7002,7 +7075,11 @@ const Select = React.forwardRef(({ className, options = [], value: controlledVal
|
|
|
7002
7075
|
const displaySuffix = suffix ? (jsxs(Fragment, { children: [suffix, chevronIcon] })) : (chevronIcon);
|
|
7003
7076
|
// Render dropdown menu content
|
|
7004
7077
|
const renderDropdownContent = () => (jsx(DropdownMenu, { items: menuItems, sectionHeading: sectionHeading, isEmpty: options.length === 0, emptyTitle: emptyTitle, emptyDescription: emptyDescription, emptyIcon: emptyIcon, disableFooter: true, onClose: () => handleOpenChange(false), className: menuClassName, width: isMobile ? "full" : widthStyle, unstyled: isMobile }));
|
|
7005
|
-
return (jsxs("div", { ref: containerRef, className: "relative w-full", onClickCapture:
|
|
7078
|
+
return (jsxs("div", { ref: containerRef, className: cn("relative w-full min-w-0", !isDisabled && !isLoading && "cursor-pointer"), onPointerDownCapture: handleTriggerContainerPointerDownCapture, onClickCapture: handleTriggerContainerClickCapture, children: [jsx(TextField, { ref: inputRef, label: label, helperText: helperText, errorText: errorText, successText: successText, validationState: validationState, isDisabled: isDisabled, isRequired: isRequired, isOptional: isOptional, isLoading: isLoading, size: size, prefix: displayPrefix, suffix: displaySuffix, showClearButton: showClearButton && hasValue && !isLoading, onClear: handleClear, placeholder: placeholder, value: displayValue, readOnly: true, containerClassName: cn("w-full", containerClassName), labelClassName: labelClassName, className: cn("cursor-pointer", triggerClassName, className), inputClassName: "cursor-pointer", infoHeading: infoHeading, infoDescription: infoDescription, LinkComponent: LinkComponent, linkText: linkText, linkHref: linkHref, onLinkClick: onLinkClick, onClick: (event) => {
|
|
7079
|
+
onClick?.(event);
|
|
7080
|
+
if (!isDisabled && !isLoading)
|
|
7081
|
+
handleOpenChange(true);
|
|
7082
|
+
}, onKeyDown: handleKeyDown, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": isOpen, ...props }), isOpen && !isDisabled && !isLoading && (isMobile ? (jsx(BottomSheet, { isOpen: isOpen, onClose: () => handleOpenChange(false), title: sectionHeading || label, variant: "default", showDragHandle: true, closeOnOverlayClick: true, closeOnEscape: true, closeOnSwipeDown: true, children: renderDropdownContent() })) : (jsx("div", { ref: dropdownContainerRef, className: cn("absolute z-50 left-0 right-0", dropdownPlacement === "bottom"
|
|
7006
7083
|
? "top-full mt-1"
|
|
7007
7084
|
: "bottom-full mb-1"), children: renderDropdownContent() })))] }));
|
|
7008
7085
|
});
|