@box/blueprint-web 9.12.1 → 9.13.0

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.
@@ -8,5 +8,6 @@ import { type CardTooltipProps } from './types';
8
8
  *
9
9
  * **IMPORTANT (2)**: Must wrap interactive component/element (such as: HTMLInputElement, HTMLAnchorElement, HTMLTextAreaElement, etc. [list of focusable elements](https://allyjs.io/data-tables/focusable.html))
10
10
  *
11
+ * @deprecated Use CardTooltipV2 instead.
11
12
  */
12
13
  export declare const CardTooltip: (props: CardTooltipProps) => import("react/jsx-runtime").JSX.Element;
@@ -15,6 +15,7 @@ import styles from './card-tooltip.module.js';
15
15
  *
16
16
  * **IMPORTANT (2)**: Must wrap interactive component/element (such as: HTMLInputElement, HTMLAnchorElement, HTMLTextAreaElement, etc. [list of focusable elements](https://allyjs.io/data-tables/focusable.html))
17
17
  *
18
+ * @deprecated Use CardTooltipV2 instead.
18
19
  */
19
20
  const CardTooltip = props => {
20
21
  const {
@@ -0,0 +1,10 @@
1
+ import { type CardTooltipV2Props } from './types';
2
+ /**
3
+ * CardTooltipV2 is a component that wraps a Card component inside a Tooltip component. The main difference between CardTooltipV2 and CardTooltip is that CardTooltipV2 uses Ariakit Tooltip component instead of Radix Tooltip component.
4
+ *
5
+ * You must only pass non-interactive content inside `content` prop.
6
+ *
7
+ * **IMPORTANT**: Must wrap interactive component/element (such as: HTMLInputElement, HTMLAnchorElement, HTMLTextAreaElement, etc. [list of focusable elements](https://allyjs.io/data-tables/focusable.html))
8
+ *
9
+ */
10
+ export declare const CardTooltipV2: import("react").ForwardRefExoticComponent<CardTooltipV2Props & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,95 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import * as Ariakit from '@ariakit/react';
3
+ import clsx from 'clsx';
4
+ import { forwardRef, useLayoutEffect, useCallback } from 'react';
5
+ import { Card } from '../card/card.js';
6
+ import { composeEventHandlers } from '../utils/composeEventHandlers.js';
7
+ import styles from './card-tooltip-v2.module.js';
8
+
9
+ /**
10
+ * CardTooltipV2 is a component that wraps a Card component inside a Tooltip component. The main difference between CardTooltipV2 and CardTooltip is that CardTooltipV2 uses Ariakit Tooltip component instead of Radix Tooltip component.
11
+ *
12
+ * You must only pass non-interactive content inside `content` prop.
13
+ *
14
+ * **IMPORTANT**: Must wrap interactive component/element (such as: HTMLInputElement, HTMLAnchorElement, HTMLTextAreaElement, etc. [list of focusable elements](https://allyjs.io/data-tables/focusable.html))
15
+ *
16
+ */
17
+ const CardTooltipV2 = /*#__PURE__*/forwardRef((props, ref) => {
18
+ const {
19
+ children,
20
+ content,
21
+ setOpen,
22
+ open,
23
+ defaultOpen,
24
+ className,
25
+ skipTimeout,
26
+ hideTooltipOnContentClick,
27
+ hideOnInteractOutside,
28
+ placement = 'bottom',
29
+ elevation = 'dropshadow-3',
30
+ ...contentProps
31
+ } = props;
32
+ const tooltipStore = Ariakit.useTooltipStore({
33
+ open,
34
+ setOpen,
35
+ defaultOpen,
36
+ placement,
37
+ showTimeout: 300,
38
+ hideTimeout: 0,
39
+ skipTimeout
40
+ });
41
+ const side = Ariakit.useStoreState(tooltipStore, 'currentPlacement').split('-')[0];
42
+ const contentId = Ariakit.useStoreState(tooltipStore, state => state.contentElement?.id);
43
+ const mounted = Ariakit.useStoreState(tooltipStore, 'mounted');
44
+ const isOpen = Ariakit.useStoreState(tooltipStore, 'open');
45
+ useLayoutEffect(() => {
46
+ if (mounted && !isOpen) {
47
+ // Make sure that tooltip disappears instantly after it is closed.
48
+ // Otherwise, once a tooltip is hovered, moving mouse to other tooltips
49
+ // could open them without honoring `showTimeout`.
50
+ tooltipStore.setState('animating', false);
51
+ }
52
+ }, [isOpen, mounted, tooltipStore]);
53
+ const handleHideOnInteractOutside = useCallback(e => {
54
+ if (typeof hideOnInteractOutside === 'function') {
55
+ hideOnInteractOutside(e);
56
+ }
57
+ if (e.type === 'focusin') {
58
+ const state = tooltipStore.getState();
59
+ const contentElement = state?.contentElement;
60
+ // If tooltip content is losing focus, do not hide it
61
+ // since it can be stolen sometimes by elements outside of it.
62
+ if (e?.relatedTarget === contentElement) {
63
+ return false;
64
+ }
65
+ }
66
+ return true;
67
+ }, [hideOnInteractOutside, tooltipStore]);
68
+ return jsxs(Ariakit.TooltipProvider, {
69
+ store: tooltipStore,
70
+ children: [jsx(Ariakit.TooltipAnchor, {
71
+ ...(mounted && {
72
+ 'aria-describedby': contentId
73
+ }),
74
+ onClick: tooltipStore.hide,
75
+ render: children
76
+ }), jsx(Ariakit.Tooltip, {
77
+ ...contentProps,
78
+ ...(hideTooltipOnContentClick && {
79
+ onClick: composeEventHandlers(tooltipStore.hide, contentProps.onClick)
80
+ }),
81
+ ref: ref,
82
+ className: clsx(styles.content, className),
83
+ "data-side": side,
84
+ fitViewport: true,
85
+ gutter: 4,
86
+ hideOnInteractOutside: handleHideOnInteractOutside,
87
+ children: jsx(Card, {
88
+ elevation: elevation,
89
+ children: content
90
+ })
91
+ })]
92
+ });
93
+ });
94
+
95
+ export { CardTooltipV2 };
@@ -0,0 +1,4 @@
1
+ import '../index.css';
2
+ var styles = {"content":"bp_card_tooltip_v2_module_content--86ebe","slideDownAndFade":"bp_card_tooltip_v2_module_slideDownAndFade--86ebe","slideLeftAndFade":"bp_card_tooltip_v2_module_slideLeftAndFade--86ebe","slideUpAndFade":"bp_card_tooltip_v2_module_slideUpAndFade--86ebe","slideRightAndFade":"bp_card_tooltip_v2_module_slideRightAndFade--86ebe"};
3
+
4
+ export { styles as default };
@@ -0,0 +1,2 @@
1
+ export { CardTooltipV2 } from './card-tooltip-v2';
2
+ export { type CardTooltipV2Props } from './types';
@@ -0,0 +1,25 @@
1
+ import { type TooltipProps, type TooltipStoreProps } from '@ariakit/react';
2
+ import { type ReactElement, type ReactNode } from 'react';
3
+ import { type CardProps } from '../card/types';
4
+ export interface CardTooltipV2Props extends Omit<TooltipProps, 'content' | 'ref'> {
5
+ /** The anchor for the tooltip. */
6
+ children: ReactElement;
7
+ /** The content of the tooltip. */
8
+ content: ReactNode;
9
+ defaultOpen?: TooltipStoreProps['defaultOpen'];
10
+ /**
11
+ * The elevation of the Card inside.
12
+ * @default dropshadow-3
13
+ */
14
+ elevation?: CardProps['elevation'];
15
+ /**
16
+ * If true, the tooltip will close itself when the content area is clicked.
17
+ * @default false
18
+ */
19
+ hideTooltipOnContentClick?: boolean;
20
+ open?: TooltipStoreProps['open'];
21
+ placement?: TooltipStoreProps['placement'];
22
+ portalElement?: TooltipProps['portalElement'];
23
+ setOpen?: TooltipStoreProps['setOpen'];
24
+ skipTimeout?: TooltipStoreProps['skipTimeout'];
25
+ }
package/lib-esm/index.css CHANGED
@@ -1031,6 +1031,82 @@
1031
1031
  }
1032
1032
  }
1033
1033
 
1034
+ .bp_card_tooltip_v2_module_content--86ebe{
1035
+ border-radius:var(--radius-1);
1036
+ font-family:Lato, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
1037
+ font-size:.875rem;
1038
+ font-weight:400;
1039
+ letter-spacing:.01875rem;
1040
+ line-height:1.25rem;
1041
+ max-height:var(--popover-available-height);
1042
+ max-width:336px;
1043
+ min-width:168px;
1044
+ padding:var(--space-2) var(--space-3);
1045
+ position:relative;
1046
+ text-decoration:none;
1047
+ text-transform:none;
1048
+ word-break:break-word;
1049
+ z-index:2147483647;
1050
+ }
1051
+ .bp_card_tooltip_v2_module_content--86ebe[data-open]{
1052
+ animation-duration:var(--animation-duration-4);
1053
+ animation-timing-function:var(--animation-easing-ease-base);
1054
+ will-change:transform, opacity;
1055
+ }
1056
+ .bp_card_tooltip_v2_module_content--86ebe[data-open][data-side=top]{
1057
+ animation-name:bp_card_tooltip_v2_module_slideDownAndFade--86ebe;
1058
+ }
1059
+ .bp_card_tooltip_v2_module_content--86ebe[data-open][data-side=right]{
1060
+ animation-name:bp_card_tooltip_v2_module_slideLeftAndFade--86ebe;
1061
+ }
1062
+ .bp_card_tooltip_v2_module_content--86ebe[data-open][data-side=bottom]{
1063
+ animation-name:bp_card_tooltip_v2_module_slideUpAndFade--86ebe;
1064
+ }
1065
+ .bp_card_tooltip_v2_module_content--86ebe[data-open][data-side=left]{
1066
+ animation-name:bp_card_tooltip_v2_module_slideRightAndFade--86ebe;
1067
+ }
1068
+
1069
+ @keyframes bp_card_tooltip_v2_module_slideUpAndFade--86ebe{
1070
+ from{
1071
+ opacity:0;
1072
+ transform:translateY(2px);
1073
+ }
1074
+ to{
1075
+ opacity:1;
1076
+ transform:translateY(0);
1077
+ }
1078
+ }
1079
+ @keyframes bp_card_tooltip_v2_module_slideRightAndFade--86ebe{
1080
+ from{
1081
+ opacity:0;
1082
+ transform:translateX(-2px);
1083
+ }
1084
+ to{
1085
+ opacity:1;
1086
+ transform:translateX(0);
1087
+ }
1088
+ }
1089
+ @keyframes bp_card_tooltip_v2_module_slideDownAndFade--86ebe{
1090
+ from{
1091
+ opacity:0;
1092
+ transform:translateY(-2px);
1093
+ }
1094
+ to{
1095
+ opacity:1;
1096
+ transform:translateY(0);
1097
+ }
1098
+ }
1099
+ @keyframes bp_card_tooltip_v2_module_slideLeftAndFade--86ebe{
1100
+ from{
1101
+ opacity:0;
1102
+ transform:translateX(2px);
1103
+ }
1104
+ to{
1105
+ opacity:1;
1106
+ transform:translateX(0);
1107
+ }
1108
+ }
1109
+
1034
1110
  .bp_interactive_icon_module_interactiveIcon--0dec5{
1035
1111
  all:unset;
1036
1112
  background:none;
@@ -7,6 +7,7 @@ export * from './button';
7
7
  export * from './button-wrapper';
8
8
  export * from './card';
9
9
  export * from './card-tooltip';
10
+ export * from './card-tooltip-v2';
10
11
  export * from './checkbox';
11
12
  export * from './collapsible';
12
13
  export * from './combobox';
package/lib-esm/index.js CHANGED
@@ -10,6 +10,7 @@ export { Button } from './button/button.js';
10
10
  export { ButtonWrapper } from './button-wrapper/button-wrapper.js';
11
11
  export { Card } from './card/card.js';
12
12
  export { CardTooltip } from './card-tooltip/card-tooltip.js';
13
+ export { CardTooltipV2 } from './card-tooltip-v2/card-tooltip-v2.js';
13
14
  export { Checkbox } from './checkbox/index.js';
14
15
  export { CollapsibleSection } from './collapsible/collapsible-section.js';
15
16
  export { Combobox, Root } from './combobox/combobox.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "9.12.1",
3
+ "version": "9.13.0",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -63,7 +63,7 @@
63
63
  "react-stately": "^3.31.1",
64
64
  "tsx": "^4.16.5"
65
65
  },
66
- "gitHead": "cde15b83e37a0f08119cd81fab817af5e8556166",
66
+ "gitHead": "a252c96d87a4b792684153ba74d5ccb0bf0e26e0",
67
67
  "module": "lib-esm/index.js",
68
68
  "main": "lib-esm/index.js",
69
69
  "exports": {