@khanacademy/wonder-blocks-tooltip 4.2.17 → 5.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,73 @@
1
1
  # @khanacademy/wonder-blocks-tooltip
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - f52e4cd: Add an `exports` map (`.` and `./css`) and `"sideEffects": ["**/*.css"]` to the package.json. `./css` is the component stylesheet. It's conditional: `import` resolves to `dist/es/index.css` and `require` to `dist/index.css`, the same copy each JS entry already loads, so importing `./css` too doesn't duplicate the CSS.
8
+
9
+ **Breaking:** the new `exports` map blocks deep imports such as `@khanacademy/wonder-blocks-core/dist/...`. Import from the package root instead. No deep imports of these packages were found in Khan/frontend or Khan/perseus.
10
+
11
+ ### Minor Changes
12
+
13
+ - d93811b: Migrate `Tooltip` from Aphrodite to CSS Modules (WB-2333, CSS Modules Phase 5 /
14
+ Wave E). The public component API is unchanged: same props, same DOM
15
+ structure, and the same `contentStyle` / `backgroundColor` overrides.
16
+
17
+ - Styling now lives in `tooltip-bubble.module.css`,
18
+ `tooltip-content.module.css` and `tooltip-tail.module.css`.
19
+ - `TooltipBubble` and `TooltipContent` nest their rules under a `.root` marker
20
+ class, so their overrides of `View`'s `position`, `flex-direction`, `border`
21
+ and `padding` win on specificity rather than stylesheet load order.
22
+ - Popper's positioning, the legacy `backgroundColor` and `contentStyle` are
23
+ still plain style objects, so they keep their precedence (including
24
+ `backgroundColor` over the `strong` variant's background).
25
+ - The `Offset` and `ContentStyle` types now use `React.CSSProperties` in place
26
+ of Aphrodite's `CSSProperties`, which resolves to the same types for these
27
+ keys.
28
+ - The package now ships `dist/index.css` (auto side-effect import) and declares
29
+ `sideEffects`. `aphrodite` is dropped from `peerDependencies`.
30
+
31
+ ### Patch Changes
32
+
33
+ - 9652f57: Load each package's CSS after the CSS of the Wonder Blocks packages it depends
34
+ on. The published JS imported its own `index.css` before its dependencies, so
35
+ bundlers emitted, for example, Button's CSS before Typography's. Both sit in
36
+ `@layer shared` with single-class selectors, so the later `BodyText` rule won and
37
+ Button labels lost their own `font-weight`, `line-height` and `font-size`. The CSS
38
+ import now comes after the dependency imports, matching the source order that
39
+ Storybook already uses.
40
+ - c7b0d66: Hide `Floating` (while its reference element is out of view) and `Tooltip`'s bubble (until it's positioned) with a CSS class instead of an inline `visibility` style. Since plain style objects now render as the `style` attribute, the inline style made content inaccessible to Testing Library queries in consumer tests: jsdom has no layout, so floating-ui always reports the reference element as hidden there.
41
+ - Updated dependencies [0c6d97d]
42
+ - Updated dependencies [185dbbc]
43
+ - Updated dependencies [0b6c478]
44
+ - Updated dependencies [9652f57]
45
+ - Updated dependencies [aa5a8e1]
46
+ - Updated dependencies [f52e4cd]
47
+ - Updated dependencies [f52e4cd]
48
+ - Updated dependencies [647e025]
49
+ - Updated dependencies [b66b7b7]
50
+ - Updated dependencies [dbb8f0f]
51
+ - Updated dependencies [bcc10a1]
52
+ - Updated dependencies [64734d2]
53
+ - Updated dependencies [ea22448]
54
+ - Updated dependencies [ad52f4b]
55
+ - Updated dependencies [9c09ca7]
56
+ - Updated dependencies [a1002be]
57
+ - @khanacademy/wonder-blocks-tokens@18.3.0
58
+ - @khanacademy/wonder-blocks-modal@9.0.0
59
+ - @khanacademy/wonder-blocks-core@13.0.0
60
+ - @khanacademy/wonder-blocks-layout@5.0.0
61
+ - @khanacademy/wonder-blocks-typography@6.0.0
62
+
63
+ ## 4.2.18
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [5d07224]
68
+ - @khanacademy/wonder-blocks-layout@4.0.0
69
+ - @khanacademy/wonder-blocks-modal@8.10.7
70
+
3
71
  ## 4.2.17
4
72
 
5
73
  ### Patch Changes
@@ -0,0 +1,131 @@
1
+ @layer shared {/**
2
+ * TooltipBubble styles
3
+ *
4
+ * Every rule is nested inside `.root` — the marker class on the bubble's
5
+ * outer `View`, which carries no declarations of its own. Both the bubble
6
+ * and its content wrapper are `View`s, and this component overrides
7
+ * properties `View` sets in its own single-class rule in the same
8
+ * `@layer shared` (`position`, `flex-direction`, `border-*`). The bundle
9
+ * loads this package's CSS before core's, so at equal specificity `View`
10
+ * would win; the compound selector makes the result depend on specificity
11
+ * instead.
12
+ *
13
+ * Source order reproduces the order of the `style` arrays: `hide` → `bubble`
14
+ * → placement on the bubble, and `content` → `contentStrong` on the content
15
+ * wrapper. The popper position (`style`) and the legacy `backgroundColor`
16
+ * override are plain style objects, which `processStyleList` still routes
17
+ * through Aphrodite (unlayered and `!important`), so they win over this
18
+ * module as they did before — including over `contentStrong`.
19
+ *
20
+ * Nesting is native CSS: every `&` is explicit and resolves to the flat
21
+ * selector it replaces (`.root.hide`, `.root .content`, …). The build wraps
22
+ * every rule in `@layer shared { … }`.
23
+ */.wb-tooltip-bubble-root-250a0b0f {
24
+ /* The hide style ensures that the bounds of the bubble stay unchanged.
25
+ * This is because popper.js calculates the bubble position based off its
26
+ * bounds and if we stopped rendering it entirely, it wouldn't know where
27
+ * to place it when it reappeared. */
28
+ &.wb-tooltip-bubble-hide-250a0b0f {
29
+ pointer-events: none;
30
+ opacity: 0;
31
+ background-color: var(--wb-semanticColor-core-transparent);
32
+ color: var(--wb-semanticColor-core-transparent);
33
+ }
34
+
35
+ &.wb-tooltip-bubble-bubble-250a0b0f {
36
+ position: absolute;
37
+ }
38
+
39
+ /* Ensure the content and tail are properly arranged. */
40
+ &.wb-tooltip-bubble-contentTop-250a0b0f {
41
+ flex-direction: column;
42
+ }
43
+
44
+ &.wb-tooltip-bubble-contentRight-250a0b0f {
45
+ flex-direction: row-reverse;
46
+ }
47
+
48
+ &.wb-tooltip-bubble-contentBottom-250a0b0f {
49
+ flex-direction: column-reverse;
50
+ }
51
+
52
+ &.wb-tooltip-bubble-contentLeft-250a0b0f {
53
+ flex-direction: row;
54
+ }
55
+
56
+ & .wb-tooltip-bubble-content-250a0b0f {
57
+ max-inline-size: 472px;
58
+ border-radius: var(--wb-border-radius-radius_040);
59
+ border: solid var(--wb-border-width-thin) var(--wb-semanticColor-core-border-neutral-subtle);
60
+ background-color: var(--wb-semanticColor-core-background-base-default);
61
+ box-shadow: var(--wb-boxShadow-mid);
62
+ justify-content: center;
63
+ }
64
+
65
+ /* The strong variant uses a higher-emphasis inverse/knockout treatment.
66
+ * The text color is set here so it cascades to the `TooltipContent`
67
+ * typography, which inherits the CSS `color`. */
68
+ & .wb-tooltip-bubble-contentStrong-250a0b0f {
69
+ background-color: var(--wb-semanticColor-feedback-neutral-strong-background);
70
+ border-color: var(--wb-semanticColor-feedback-neutral-strong-border);
71
+ color: var(--wb-semanticColor-feedback-neutral-strong-text);
72
+ }
73
+ }
74
+ }
75
+
76
+ @layer shared {/**
77
+ * TooltipContent styles
78
+ *
79
+ * The rules are nested inside `.root` — the marker class on the content
80
+ * `View`, which carries no declarations of its own — because they override
81
+ * `View`'s `padding`, which core sets in a single-class rule in the same
82
+ * `@layer shared`. The bundle loads this package's CSS before core's, so at
83
+ * equal specificity `View` would win. `TooltipContent` is a public export
84
+ * and doesn't have to render inside a `TooltipBubble`, so it carries its
85
+ * own marker instead of relying on the bubble's.
86
+ *
87
+ * The consumer's `contentStyle` is a plain style object, which
88
+ * `processStyleList` still routes through Aphrodite (unlayered and
89
+ * `!important`), so it wins over this module as it did before. The build
90
+ * wraps every rule in `@layer shared { … }`.
91
+ */.wb-tooltip-content-root-06de2278 {
92
+ &.wb-tooltip-content-withoutTitle-06de2278 {
93
+ padding: var(--wb-sizing-size_100) var(--wb-sizing-size_160);
94
+ }
95
+
96
+ &.wb-tooltip-content-withTitle-06de2278 {
97
+ padding: var(--wb-sizing-size_160);
98
+
99
+ /* gap between the title and its children when both are present. */
100
+ gap: var(--wb-sizing-size_040);
101
+ }
102
+ }
103
+ }
104
+
105
+ @layer shared {/* Styles for `TooltipPopper`. The build wraps these rules in
106
+ * `@layer shared { … }` via the wrap-in-layer plugin in `postcss.config.cjs`. *//* Hides the bubble until popper has positioned it for the first time. This is
107
+ * a class rather than an inline style so that consumer test setups, which
108
+ * mock CSS, don't see the bubble as hidden before popper's first update. */.wb-tooltip-popper-hidden-71447701 {
109
+ visibility: hidden;
110
+ }
111
+ }
112
+
113
+ @layer shared {/**
114
+ * TooltipTail styles
115
+ *
116
+ * `.tailContainer` sits on a `View`, but neither of its declarations
117
+ * competes with core's `View` rule (`position: relative` matches the value
118
+ * `View` already sets), so a single class is enough. `.arrow` sits on a
119
+ * plain `svg`. The placement-specific container size/offset and the arrow
120
+ * margins stay plain style objects in the component. The build wraps every
121
+ * rule in `@layer shared { … }`.
122
+ */.wb-tooltip-tail-tailContainer-46f3a126 {
123
+ position: relative;
124
+ pointer-events: none;
125
+ }.wb-tooltip-tail-arrow-46f3a126 {
126
+ /* Ensure the dropshadow bleeds outside our bounds. */
127
+ overflow: visible;
128
+ }
129
+ }
130
+
131
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["<no source>","../../src/components/tooltip-bubble.module.css","../../src/components/tooltip-content.module.css","../../src/components/tooltip-popper.module.css","../../src/components/tooltip-tail.module.css"],"names":[],"mappings":"AAAA,eCAA;;;;;;;;;;;;;;;;;;;;;;EAsBE,CAEF;IACI;;;wCAGoC;IACpC;QACI,oBAAoB;QACpB,UAAU;QACV,0DAA0D;QAC1D,+CAA+C;IACnD;;IAEA;QACI,kBAAkB;IACtB;;IAEA,uDAAuD;IACvD;QACI,sBAAsB;IAC1B;;IAEA;QACI,2BAA2B;IAC/B;;IAEA;QACI,8BAA8B;IAClC;;IAEA;QACI,mBAAmB;IACvB;;IAEA;QACI,sBAAsB;QACtB,iDAAiD;QACjD,4FAA4F;QAC5F,sEAAsE;QACtE,mCAAmC;QACnC,uBAAuB;IAC3B;;IAEA;;oDAEgD;IAChD;QACI,4EAA4E;QAC5E,oEAAoE;QACpE,2DAA2D;IAC/D;AACJ;CD1EA;;AAAA,eEAA;;;;;;;;;;;;;;;EAeE,CAEF;IACI;QACI,4DAA4D;IAChE;;IAEA;QACI,kCAAkC;;QAElC,kEAAkE;QAClE,8BAA8B;IAClC;AACJ;CF5BA;;AAAA,eGAA;gFACgF,CAEhF;;2EAE2E,CAC3E;IACI,kBAAkB;AACtB;CHRA;;AAAA,eIAA;;;;;;;;;EASE,CAEF;IACI,kBAAkB;IAClB,oBAAoB;AACxB,CAEA;IACI,qDAAqD;IACrD,iBAAiB;AACrB;CJnBA","file":"index.css","sourcesContent":[null,"/**\n * TooltipBubble styles\n *\n * Every rule is nested inside `.root` — the marker class on the bubble's\n * outer `View`, which carries no declarations of its own. Both the bubble\n * and its content wrapper are `View`s, and this component overrides\n * properties `View` sets in its own single-class rule in the same\n * `@layer shared` (`position`, `flex-direction`, `border-*`). The bundle\n * loads this package's CSS before core's, so at equal specificity `View`\n * would win; the compound selector makes the result depend on specificity\n * instead.\n *\n * Source order reproduces the order of the `style` arrays: `hide` → `bubble`\n * → placement on the bubble, and `content` → `contentStrong` on the content\n * wrapper. The popper position (`style`) and the legacy `backgroundColor`\n * override are plain style objects, which `processStyleList` still routes\n * through Aphrodite (unlayered and `!important`), so they win over this\n * module as they did before — including over `contentStrong`.\n *\n * Nesting is native CSS: every `&` is explicit and resolves to the flat\n * selector it replaces (`.root.hide`, `.root .content`, …). The build wraps\n * every rule in `@layer shared { … }`.\n */\n\n.root {\n /* The hide style ensures that the bounds of the bubble stay unchanged.\n * This is because popper.js calculates the bubble position based off its\n * bounds and if we stopped rendering it entirely, it wouldn't know where\n * to place it when it reappeared. */\n &.hide {\n pointer-events: none;\n opacity: 0;\n background-color: var(--wb-semanticColor-core-transparent);\n color: var(--wb-semanticColor-core-transparent);\n }\n\n &.bubble {\n position: absolute;\n }\n\n /* Ensure the content and tail are properly arranged. */\n &.contentTop {\n flex-direction: column;\n }\n\n &.contentRight {\n flex-direction: row-reverse;\n }\n\n &.contentBottom {\n flex-direction: column-reverse;\n }\n\n &.contentLeft {\n flex-direction: row;\n }\n\n & .content {\n max-inline-size: 472px;\n border-radius: var(--wb-border-radius-radius_040);\n border: solid var(--wb-border-width-thin) var(--wb-semanticColor-core-border-neutral-subtle);\n background-color: var(--wb-semanticColor-core-background-base-default);\n box-shadow: var(--wb-boxShadow-mid);\n justify-content: center;\n }\n\n /* The strong variant uses a higher-emphasis inverse/knockout treatment.\n * The text color is set here so it cascades to the `TooltipContent`\n * typography, which inherits the CSS `color`. */\n & .contentStrong {\n background-color: var(--wb-semanticColor-feedback-neutral-strong-background);\n border-color: var(--wb-semanticColor-feedback-neutral-strong-border);\n color: var(--wb-semanticColor-feedback-neutral-strong-text);\n }\n}\n","/**\n * TooltipContent styles\n *\n * The rules are nested inside `.root` — the marker class on the content\n * `View`, which carries no declarations of its own — because they override\n * `View`'s `padding`, which core sets in a single-class rule in the same\n * `@layer shared`. The bundle loads this package's CSS before core's, so at\n * equal specificity `View` would win. `TooltipContent` is a public export\n * and doesn't have to render inside a `TooltipBubble`, so it carries its\n * own marker instead of relying on the bubble's.\n *\n * The consumer's `contentStyle` is a plain style object, which\n * `processStyleList` still routes through Aphrodite (unlayered and\n * `!important`), so it wins over this module as it did before. The build\n * wraps every rule in `@layer shared { … }`.\n */\n\n.root {\n &.withoutTitle {\n padding: var(--wb-sizing-size_100) var(--wb-sizing-size_160);\n }\n\n &.withTitle {\n padding: var(--wb-sizing-size_160);\n\n /* gap between the title and its children when both are present. */\n gap: var(--wb-sizing-size_040);\n }\n}\n","/* Styles for `TooltipPopper`. The build wraps these rules in\n * `@layer shared { … }` via the wrap-in-layer plugin in `postcss.config.cjs`. */\n\n/* Hides the bubble until popper has positioned it for the first time. This is\n * a class rather than an inline style so that consumer test setups, which\n * mock CSS, don't see the bubble as hidden before popper's first update. */\n.hidden {\n visibility: hidden;\n}\n","/**\n * TooltipTail styles\n *\n * `.tailContainer` sits on a `View`, but neither of its declarations\n * competes with core's `View` rule (`position: relative` matches the value\n * `View` already sets), so a single class is enough. `.arrow` sits on a\n * plain `svg`. The placement-specific container size/offset and the arrow\n * margins stay plain style objects in the component. The build wraps every\n * rule in `@layer shared { … }`.\n */\n\n.tailContainer {\n position: relative;\n pointer-events: none;\n}\n\n.arrow {\n /* Ensure the dropshadow bleeds outside our bounds. */\n overflow: visible;\n}\n"]}
package/dist/es/index.js CHANGED
@@ -3,8 +3,7 @@ import * as React from 'react';
3
3
  import * as ReactDOM from 'react-dom';
4
4
  import { Text as Text$1, View, Id } from '@khanacademy/wonder-blocks-core';
5
5
  import { maybeGetPortalMountedModalHostElement } from '@khanacademy/wonder-blocks-modal';
6
- import { StyleSheet, css } from 'aphrodite';
7
- import { semanticColor, color, border, boxShadow, sizing, remToPx, tokenValue } from '@khanacademy/wonder-blocks-tokens';
6
+ import { semanticColor, color, remToPx, tokenValue, sizing } from '@khanacademy/wonder-blocks-tokens';
8
7
  import { Heading, BodyText } from '@khanacademy/wonder-blocks-typography';
9
8
  import { Popper } from 'react-popper';
10
9
 
@@ -14,18 +13,28 @@ const TooltipAppearanceDelay=100;const TooltipDisappearanceDelay=75;
14
13
 
15
14
  const TRACKER=new ActiveTracker;class TooltipAnchor extends React.Component{componentDidMount(){const anchorNode=ReactDOM.findDOMNode(this);if(anchorNode instanceof Text){throw new Error("TooltipAnchor must be applied to an Element. Text content is not supported.")}this._unsubscribeFromTracker=TRACKER.subscribe(this);this._anchorNode=anchorNode;this._updateFocusivity();if(anchorNode){anchorNode.addEventListener("focusin",this._handleFocusIn);anchorNode.addEventListener("focusout",this._handleFocusOut);anchorNode.addEventListener("mouseenter",this._handleMouseEnter);anchorNode.addEventListener("mouseleave",this._handleMouseLeave);this.props.anchorRef(this._anchorNode);}}componentDidUpdate(prevProps){if(prevProps.forceAnchorFocusivity!==this.props.forceAnchorFocusivity||prevProps.children!==this.props.children){this._updateFocusivity();}}componentWillUnmount(){if(this._unsubscribeFromTracker){this._unsubscribeFromTracker();}this._clearPendingAction();const anchorNode=this._anchorNode;if(anchorNode){anchorNode.removeEventListener("focusin",this._handleFocusIn);anchorNode.removeEventListener("focusout",this._handleFocusOut);anchorNode.removeEventListener("mouseenter",this._handleMouseEnter);anchorNode.removeEventListener("mouseleave",this._handleMouseLeave);}if(this.state.active){document.removeEventListener("keyup",this._handleKeyUp);}}_updateFocusivity(){const anchorNode=this._anchorNode;if(!anchorNode){return}const{forceAnchorFocusivity}=this.props;const currentTabIndex=anchorNode.getAttribute("tabindex");if(forceAnchorFocusivity&&!currentTabIndex){anchorNode.setAttribute("tabindex","0");this._weSetFocusivity=true;}else if(!forceAnchorFocusivity&&currentTabIndex){if(this._weSetFocusivity){anchorNode.removeAttribute("tabindex");this._weSetFocusivity=false;}}}_updateActiveState(hovered,focused){this._hovered=hovered;this._focused=focused;this._setActiveState(hovered||focused);}_clearPendingAction(){if(this._timeoutID){clearTimeout(this._timeoutID);this._timeoutID=null;}}_setActiveState(active,instant){if(this._stolenFromUs||active!==this.state.active||!this.state.active&&this._timeoutID){this._clearPendingAction();}else if(active===this.state.active){if(this._timeoutID){this._clearPendingAction();}return}instant=instant||active&&TRACKER.steal(this);if(instant){if(active){document.addEventListener("keyup",this._handleKeyUp);}else {document.removeEventListener("keyup",this._handleKeyUp);}this.setState({active});this.props.onActiveChanged(active);if(!this._stolenFromUs&&!active){TRACKER.giveup();}this._stolenFromUs=false;}else {const delay=active?TooltipAppearanceDelay:TooltipDisappearanceDelay;this._timeoutID=setTimeout(()=>{this._timeoutID=null;this._setActiveState(active,true);},delay);}}_renderAnchorableChildren(){const{children}=this.props;return typeof children==="string"?jsx(Text$1,{children:children}):children}render(){const{"aria-describedby":ariaDescribedBy}=this.props;const anchorableChildren=this._renderAnchorableChildren();return React.cloneElement(anchorableChildren,{"aria-describedby":ariaDescribedBy})}constructor(props){super(props),this.activeStateStolen=()=>{this._stolenFromUs=this.state.active||!!this._timeoutID;this._focused=false;this._setActiveState(false,true);},this._handleFocusIn=()=>{this._updateActiveState(this._hovered,true);},this._handleFocusOut=()=>{this._updateActiveState(this._hovered,false);},this._handleMouseEnter=()=>{this._updateActiveState(true,this._focused);},this._handleMouseLeave=()=>{this._updateActiveState(false,this._focused);},this._handleKeyUp=e=>{if(e.key==="Escape"&&this.state.active){e.preventDefault();e.stopPropagation();this._updateActiveState(false,false);}};this._focused=false;this._hovered=false;this.state={active:false};}}TooltipAnchor.defaultProps={forceAnchorFocusivity:true};
16
15
 
17
- let tempIdCounter=0;class TooltipTail extends React.Component{_calculateDimensionsFromPlacement(){const{placement}=this.props;const trimlineOffset=.5;switch(placement){case"top":return {trimlinePoints:[`0,-${trimlineOffset}`,`${ARROW_WIDTH},-${trimlineOffset}`],points:["0,0",`${ARROW_WIDTH/2},${ARROW_HEIGHT}`,`${ARROW_WIDTH},0`],height:ARROW_HEIGHT,width:ARROW_WIDTH};case"right":return {trimlinePoints:[`${ARROW_HEIGHT+trimlineOffset},0`,`${ARROW_HEIGHT+trimlineOffset},${ARROW_WIDTH}`],points:[`${ARROW_HEIGHT},0`,`0,${ARROW_WIDTH/2}`,`${ARROW_HEIGHT},${ARROW_WIDTH}`],width:ARROW_HEIGHT,height:ARROW_WIDTH};case"bottom":return {trimlinePoints:[`0, ${ARROW_HEIGHT+trimlineOffset}`,`${ARROW_WIDTH},${ARROW_HEIGHT+trimlineOffset}`],points:[`0, ${ARROW_HEIGHT}`,`${ARROW_WIDTH/2},0`,`${ARROW_WIDTH},${ARROW_HEIGHT}`],width:ARROW_WIDTH,height:ARROW_HEIGHT};case"left":return {trimlinePoints:[`-${trimlineOffset},0`,`-${trimlineOffset},${ARROW_WIDTH}`],points:[`0,0`,`${ARROW_HEIGHT},${ARROW_WIDTH/2}`,`0,${ARROW_WIDTH}`],width:ARROW_HEIGHT,height:ARROW_WIDTH};default:throw new Error(`Unknown placement: ${placement}`)}}_getFilterPositioning(){const{placement}=this.props;switch(placement){case"top":return {y:"-50%",x:"-50%",offsetShadowX:0};case"bottom":return null;case"left":return {y:"-50%",x:"0%",offsetShadowX:1};case"right":return {y:"-50%",x:"-100%",offsetShadowX:-1};default:throw new Error(`Unknown placement: ${placement}`)}}_maybeRenderDropshadow(points){const position=this._getFilterPositioning();if(!position){return null}const{placement}=this.props;const{y,x,offsetShadowX}=position;const dropShadowFilterId=`tooltip-dropshadow-${placement}-${tempIdCounter++}`;return [jsxs("filter",{id:dropShadowFilterId,width:"200%",height:"200%",x:x,y:y,children:[jsx("feGaussianBlur",{in:"SourceAlpha",stdDeviation:3}),jsx("feComponentTransfer",{children:jsx("feFuncA",{type:"linear",slope:"0.3"})})]},"filter"),jsx("g",{transform:`translate(${offsetShadowX},5.5)`,children:jsx("polyline",{fill:semanticColor.core.shadow.transparent.mid,points:points.join(" "),stroke:semanticColor.core.shadow.transparent.mid,filter:`url(#${dropShadowFilterId})`})},"dropshadow")]}_getFullTailWidth(){return ARROW_WIDTH+2*MIN_DISTANCE_FROM_CORNERS}_getFullTailHeight(){return ARROW_HEIGHT+DISTANCE_FROM_ANCHOR}_getContainerStyle(){const{placement}=this.props;const fullTailWidth=this._getFullTailWidth();const fullTailHeight=this._getFullTailHeight();switch(placement){case"top":return {top:-1,width:fullTailWidth,height:fullTailHeight};case"right":return {left:1,width:fullTailHeight,height:fullTailWidth};case"bottom":return {top:1,width:fullTailWidth,height:fullTailHeight};case"left":return {left:-1,width:fullTailHeight,height:fullTailWidth};default:throw new Error(`Unknown placement: ${placement}`)}}_getArrowStyle(){const{placement}=this.props;switch(placement){case"top":return {marginLeft:MIN_DISTANCE_FROM_CORNERS,marginRight:MIN_DISTANCE_FROM_CORNERS,paddingBottom:DISTANCE_FROM_ANCHOR};case"right":return {marginTop:MIN_DISTANCE_FROM_CORNERS,marginBottom:MIN_DISTANCE_FROM_CORNERS,paddingLeft:DISTANCE_FROM_ANCHOR};case"bottom":return {marginLeft:MIN_DISTANCE_FROM_CORNERS,marginRight:MIN_DISTANCE_FROM_CORNERS,paddingTop:DISTANCE_FROM_ANCHOR};case"left":return {marginTop:MIN_DISTANCE_FROM_CORNERS,marginBottom:MIN_DISTANCE_FROM_CORNERS,paddingRight:DISTANCE_FROM_ANCHOR};default:throw new Error(`Unknown placement: ${placement}`)}}_renderArrow(){const{trimlinePoints,points,height,width}=this._calculateDimensionsFromPlacement();const{color:arrowColor,show,variant}=this.props;const isStrong=variant==="strong";const tailFill=arrowColor!==undefined&&color[arrowColor]?color[arrowColor]:isStrong?semanticColor.feedback.neutral.strong.background:semanticColor.core.background.base.default;const tailBorder=isStrong?semanticColor.feedback.neutral.strong.border:semanticColor.core.border.neutral.subtle;if(!show){return jsx(View,{"aria-hidden":true,style:{inlineSize:height,flexBasis:height,flexShrink:0}})}return jsxs("svg",{className:css(styles$2.arrow),style:this._getArrowStyle(),width:width,height:height,"aria-hidden":true,children:[this._maybeRenderDropshadow(points),jsx("polyline",{fill:tailFill,stroke:tailFill,points:points.join(" ")}),jsx("polyline",{fill:tailFill,points:points.join(" "),stroke:tailBorder}),jsx("polyline",{stroke:tailFill,points:trimlinePoints.join(" ")})]})}render(){const{offset,placement,updateRef}=this.props;return jsx(View,{style:[styles$2.tailContainer,{...offset},this._getContainerStyle()],"data-placement":placement,ref:updateRef,children:this._renderArrow()})}}TooltipTail.defaultProps={show:true};const DISTANCE_FROM_ANCHOR=8;const MIN_DISTANCE_FROM_CORNERS=8;const ARROW_WIDTH=24;const ARROW_HEIGHT=12;const styles$2=StyleSheet.create({tailContainer:{position:"relative",pointerEvents:"none"},arrow:{overflow:"visible"}});
16
+ var modules_bf6a48cd={"tailContainer":"wb-tooltip-tail-tailContainer-46f3a126","arrow":"wb-tooltip-tail-arrow-46f3a126"};
18
17
 
19
- class TooltipBubble extends React.Component{_setActiveState(active){this.setState({active});this.props.onActiveChanged(active);}render(){const{id,children,updateBubbleRef,placement,isReferenceHidden,style,updateTailRef,tailOffset,backgroundColor,variant}=this.props;const isStrong=variant==="strong";return jsxs(View,{id:id,role:"tooltip","data-placement":placement,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,ref:updateBubbleRef,style:[isReferenceHidden&&styles$1.hide,styles$1.bubble,styles$1[`content-${placement}`],style],children:[jsx(View,{style:[styles$1.content,backgroundColor&&{backgroundColor:color[backgroundColor]},isStrong&&styles$1.contentStrong],children:children}),jsx(TooltipTail,{updateRef:updateTailRef,placement:placement,offset:tailOffset,color:backgroundColor,variant:variant})]})}constructor(...args){super(...args),this.state={active:false},this.handleMouseEnter=()=>{this._setActiveState(true);},this.handleMouseLeave=()=>{this.props.onActiveChanged(false);};}}const styles$1=StyleSheet.create({bubble:{position:"absolute"},hide:{pointerEvents:"none",opacity:0,backgroundColor:semanticColor.core.transparent,color:semanticColor.core.transparent},"content-top":{flexDirection:"column"},"content-right":{flexDirection:"row-reverse"},"content-bottom":{flexDirection:"column-reverse"},"content-left":{flexDirection:"row"},content:{maxInlineSize:472,borderRadius:border.radius.radius_040,border:`solid 1px ${semanticColor.core.border.neutral.subtle}`,backgroundColor:semanticColor.core.background.base.default,boxShadow:boxShadow.mid,justifyContent:"center"},contentStrong:{backgroundColor:semanticColor.feedback.neutral.strong.background,borderColor:semanticColor.feedback.neutral.strong.border,color:semanticColor.feedback.neutral.strong.text}});
18
+ let tempIdCounter=0;class TooltipTail extends React.Component{_calculateDimensionsFromPlacement(){const{placement}=this.props;const trimlineOffset=.5;switch(placement){case"top":return {trimlinePoints:[`0,-${trimlineOffset}`,`${ARROW_WIDTH},-${trimlineOffset}`],points:["0,0",`${ARROW_WIDTH/2},${ARROW_HEIGHT}`,`${ARROW_WIDTH},0`],height:ARROW_HEIGHT,width:ARROW_WIDTH};case"right":return {trimlinePoints:[`${ARROW_HEIGHT+trimlineOffset},0`,`${ARROW_HEIGHT+trimlineOffset},${ARROW_WIDTH}`],points:[`${ARROW_HEIGHT},0`,`0,${ARROW_WIDTH/2}`,`${ARROW_HEIGHT},${ARROW_WIDTH}`],width:ARROW_HEIGHT,height:ARROW_WIDTH};case"bottom":return {trimlinePoints:[`0, ${ARROW_HEIGHT+trimlineOffset}`,`${ARROW_WIDTH},${ARROW_HEIGHT+trimlineOffset}`],points:[`0, ${ARROW_HEIGHT}`,`${ARROW_WIDTH/2},0`,`${ARROW_WIDTH},${ARROW_HEIGHT}`],width:ARROW_WIDTH,height:ARROW_HEIGHT};case"left":return {trimlinePoints:[`-${trimlineOffset},0`,`-${trimlineOffset},${ARROW_WIDTH}`],points:[`0,0`,`${ARROW_HEIGHT},${ARROW_WIDTH/2}`,`0,${ARROW_WIDTH}`],width:ARROW_HEIGHT,height:ARROW_WIDTH};default:throw new Error(`Unknown placement: ${placement}`)}}_getFilterPositioning(){const{placement}=this.props;switch(placement){case"top":return {y:"-50%",x:"-50%",offsetShadowX:0};case"bottom":return null;case"left":return {y:"-50%",x:"0%",offsetShadowX:1};case"right":return {y:"-50%",x:"-100%",offsetShadowX:-1};default:throw new Error(`Unknown placement: ${placement}`)}}_maybeRenderDropshadow(points){const position=this._getFilterPositioning();if(!position){return null}const{placement}=this.props;const{y,x,offsetShadowX}=position;const dropShadowFilterId=`tooltip-dropshadow-${placement}-${tempIdCounter++}`;return [jsxs("filter",{id:dropShadowFilterId,width:"200%",height:"200%",x:x,y:y,children:[jsx("feGaussianBlur",{in:"SourceAlpha",stdDeviation:3}),jsx("feComponentTransfer",{children:jsx("feFuncA",{type:"linear",slope:"0.3"})})]},"filter"),jsx("g",{transform:`translate(${offsetShadowX},5.5)`,children:jsx("polyline",{fill:semanticColor.core.shadow.transparent.mid,points:points.join(" "),stroke:semanticColor.core.shadow.transparent.mid,filter:`url(#${dropShadowFilterId})`})},"dropshadow")]}_getFullTailWidth(){return ARROW_WIDTH+2*MIN_DISTANCE_FROM_CORNERS}_getFullTailHeight(){return ARROW_HEIGHT+DISTANCE_FROM_ANCHOR}_getContainerStyle(){const{placement}=this.props;const fullTailWidth=this._getFullTailWidth();const fullTailHeight=this._getFullTailHeight();switch(placement){case"top":return {top:-1,width:fullTailWidth,height:fullTailHeight};case"right":return {left:1,width:fullTailHeight,height:fullTailWidth};case"bottom":return {top:1,width:fullTailWidth,height:fullTailHeight};case"left":return {left:-1,width:fullTailHeight,height:fullTailWidth};default:throw new Error(`Unknown placement: ${placement}`)}}_getArrowStyle(){const{placement}=this.props;switch(placement){case"top":return {marginLeft:MIN_DISTANCE_FROM_CORNERS,marginRight:MIN_DISTANCE_FROM_CORNERS,paddingBottom:DISTANCE_FROM_ANCHOR};case"right":return {marginTop:MIN_DISTANCE_FROM_CORNERS,marginBottom:MIN_DISTANCE_FROM_CORNERS,paddingLeft:DISTANCE_FROM_ANCHOR};case"bottom":return {marginLeft:MIN_DISTANCE_FROM_CORNERS,marginRight:MIN_DISTANCE_FROM_CORNERS,paddingTop:DISTANCE_FROM_ANCHOR};case"left":return {marginTop:MIN_DISTANCE_FROM_CORNERS,marginBottom:MIN_DISTANCE_FROM_CORNERS,paddingRight:DISTANCE_FROM_ANCHOR};default:throw new Error(`Unknown placement: ${placement}`)}}_renderArrow(){const{trimlinePoints,points,height,width}=this._calculateDimensionsFromPlacement();const{color:arrowColor,show,variant}=this.props;const isStrong=variant==="strong";const tailFill=arrowColor!==undefined&&color[arrowColor]?color[arrowColor]:isStrong?semanticColor.feedback.neutral.strong.background:semanticColor.core.background.base.default;const tailBorder=isStrong?semanticColor.feedback.neutral.strong.border:semanticColor.core.border.neutral.subtle;if(!show){return jsx(View,{"aria-hidden":true,style:{inlineSize:height,flexBasis:height,flexShrink:0}})}return jsxs("svg",{className:modules_bf6a48cd.arrow,style:this._getArrowStyle(),width:width,height:height,"aria-hidden":true,children:[this._maybeRenderDropshadow(points),jsx("polyline",{fill:tailFill,stroke:tailFill,points:points.join(" ")}),jsx("polyline",{fill:tailFill,points:points.join(" "),stroke:tailBorder}),jsx("polyline",{stroke:tailFill,points:trimlinePoints.join(" ")})]})}render(){const{offset,placement,updateRef}=this.props;return jsx(View,{style:[modules_bf6a48cd.tailContainer,{...offset},this._getContainerStyle()],"data-placement":placement,ref:updateRef,children:this._renderArrow()})}}TooltipTail.defaultProps={show:true};const DISTANCE_FROM_ANCHOR=8;const MIN_DISTANCE_FROM_CORNERS=8;const ARROW_WIDTH=24;const ARROW_HEIGHT=12;
20
19
 
21
- class TooltipContent extends React.Component{_renderTitle(){const{title}=this.props;if(title){if(typeof title==="string"){return jsx(Heading,{size:"medium",children:title})}else {return title}}return null}_renderChildren(){const{children}=this.props;if(typeof children==="string"){return jsx(BodyText,{tag:"span",children:children})}else {return children}}render(){const title=this._renderTitle();const children=this._renderChildren();const containerStyle=title?styles.withTitle:styles.withoutTitle;return jsxs(View,{style:[containerStyle,this.props.contentStyle],testId:this.props.testId,children:[title,title?jsx(View,{children:children}):children]})}}const styles=StyleSheet.create({withoutTitle:{padding:`${sizing.size_100} ${sizing.size_160}`},withTitle:{padding:sizing.size_160,gap:sizing.size_040}});
20
+ var modules_a9739994={"root":"wb-tooltip-bubble-root-250a0b0f","hide":"wb-tooltip-bubble-hide-250a0b0f","bubble":"wb-tooltip-bubble-bubble-250a0b0f","contentTop":"wb-tooltip-bubble-contentTop-250a0b0f","contentRight":"wb-tooltip-bubble-contentRight-250a0b0f","contentBottom":"wb-tooltip-bubble-contentBottom-250a0b0f","contentLeft":"wb-tooltip-bubble-contentLeft-250a0b0f","content":"wb-tooltip-bubble-content-250a0b0f","contentStrong":"wb-tooltip-bubble-contentStrong-250a0b0f"};
21
+
22
+ const placementStyles={top:modules_a9739994.contentTop,right:modules_a9739994.contentRight,bottom:modules_a9739994.contentBottom,left:modules_a9739994.contentLeft};class TooltipBubble extends React.Component{_setActiveState(active){this.setState({active});this.props.onActiveChanged(active);}render(){const{id,children,updateBubbleRef,placement,isReferenceHidden,style,updateTailRef,tailOffset,backgroundColor,variant}=this.props;const isStrong=variant==="strong";return jsxs(View,{id:id,role:"tooltip","data-placement":placement,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,ref:updateBubbleRef,style:[modules_a9739994.root,isReferenceHidden&&modules_a9739994.hide,modules_a9739994.bubble,placementStyles[placement],style],children:[jsx(View,{style:[modules_a9739994.content,backgroundColor&&{backgroundColor:color[backgroundColor]},isStrong&&modules_a9739994.contentStrong],children:children}),jsx(TooltipTail,{updateRef:updateTailRef,placement:placement,offset:tailOffset,color:backgroundColor,variant:variant})]})}constructor(...args){super(...args),this.state={active:false},this.handleMouseEnter=()=>{this._setActiveState(true);},this.handleMouseLeave=()=>{this.props.onActiveChanged(false);};}}
23
+
24
+ var modules_69555561={"root":"wb-tooltip-content-root-06de2278","withoutTitle":"wb-tooltip-content-withoutTitle-06de2278","withTitle":"wb-tooltip-content-withTitle-06de2278"};
25
+
26
+ class TooltipContent extends React.Component{_renderTitle(){const{title}=this.props;if(title){if(typeof title==="string"){return jsx(Heading,{size:"medium",children:title})}else {return title}}return null}_renderChildren(){const{children}=this.props;if(typeof children==="string"){return jsx(BodyText,{tag:"span",children:children})}else {return children}}render(){const title=this._renderTitle();const children=this._renderChildren();const containerStyle=title?modules_69555561.withTitle:modules_69555561.withoutTitle;return jsxs(View,{style:[modules_69555561.root,containerStyle,this.props.contentStyle],testId:this.props.testId,children:[title,title?jsx(View,{children:children}):children]})}}
22
27
 
23
28
  var e=n=>null==n||"object"!=typeof n?n:Array.isArray(n)?n.map(e):Object.keys(n).reduce((t,r)=>(t[r]=e(n[r]),t),{}),t=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",InvalidUse:"InvalidUse",NotFound:"NotFound",NotAllowed:"NotAllowed",Unauthorized:"Unauthorized",NotImplemented:"NotImplemented"});function r(e,n,t){return (n=function(e){var n=function(e,n){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===n?String:Number)(e)}(e,"string");return "symbol"==typeof n?n:n+""}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}class o{constructor(e,n){r(this,"_name",void 0),r(this,"_message",void 0),this._name=e,this._message=n;}get message(){return this._message}get name(){return this._name}get messageWithName(){return "".concat(this.name,": ").concat(this.message)}static fromConsequenceAndCause(e,n){if("production"!==process.env.NODE_ENV){if(!(e instanceof o))throw new Error("consequence must be an instance of ErrorInfo");if(!(n instanceof o))throw new Error("cause must be an instance of ErrorInfo");if(n===e)throw new Error("cause and consequence must be different")}return new o(e.name,((e,n)=>{var t=e=>(null==e?void 0:e.trim())||"(empty message)",r=t(e);return null==n?r:"".concat(r,"\n\tcaused by\n\t\t").concat(t(n))})(e.message,n.messageWithName))}static normalize(e){var n;if("production"!==process.env.NODE_ENV&&!(e instanceof Error))throw new Error("Error must be an instance of Error");var t=null!==(n=e.message.toString().split("\n").find(e=>e.trim().length))&&void 0!==n?n:"(empty message)";return new o(e.name,t)}static from(e){if("production"!==process.env.NODE_ENV&&!(e instanceof Error))throw new Error("Error must be an instance of Error");return new o(e.name,e.message)}}class s extends Error{constructor(n){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.Unknown,{cause:i,prefix:a,name:u,metadata:c}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Object.freeze({});if("production"!==process.env.NODE_ENV){if(i&&!(i instanceof Error))throw new Error("cause must be an instance of Error");if(null!=u&&/\s/g.test(u))throw new Error("name must not contain whitespace");if(/\s/g.test(s))throw new Error("kind must not contain whitespace");if(null!=a&&/\s/g.test(a))throw new Error("prefix must not contain whitespace")}if(super(n),r(this,"kind",void 0),r(this,"originalMessage",void 0),r(this,"metadata",void 0),r(this,"cause",void 0),this.originalMessage=n,this.metadata=(n=>{if(null==n)return n;var t=e(n);return Object.freeze(t)})(c),this.name="".concat(null!=a?a:"").concat(s).concat(null!=u?u:"","Error"),this.kind=s,this.cause=i,null!=i){var l=o.normalize(this),f=o.from(i),d=o.fromConsequenceAndCause(l,f);this.message=d.message;}}}Object.freeze({ConsequenceFirst:"consequence-first",CauseFirst:"cause-first"});class g extends s{constructor(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.InvalidInput,r=arguments.length>2?arguments[2]:void 0;super("Unhandled case for '".concat(e,"'"),n,r);}}(function(e){return e.Production="production",e.Development="development",e.Test="test",e})({});
24
29
 
25
30
  class RefTracker{constructor(){this.updateRef=ref=>{if(ref){const domNode=ReactDOM.findDOMNode(ref);if(domNode instanceof HTMLElement&&domNode!==this._lastRef){this._lastRef=domNode;this._targetFn?.(domNode);}}};this.setCallback=targetFn=>{if(this._targetFn!==targetFn){if(targetFn&&typeof targetFn!=="function"){throw new Error("targetFn must be a function")}this._targetFn=targetFn||undefined;if(this._lastRef&&this._targetFn){this._targetFn(this._lastRef);}}};}}
26
31
 
27
- const filterPopperPlacement=placement=>{switch(placement){case"auto":case"auto-start":case"auto-end":case"top":case"top-start":case"top-end":return "top";case"bottom":case"bottom-start":case"bottom-end":return "bottom";case"right":case"right-start":case"right-end":return "right";case"left":case"left-start":case"left-end":return "left";default:throw new g(placement)}};function _modifyPosition({state}){const popperHeight=state.rects.popper.height+state.rects.reference.height;const minHeight=document.documentElement.clientHeight;if(minHeight<popperHeight&&state.modifiersData.hide){state.modifiersData.hide={...state.modifiersData.hide,isReferenceHidden:false};}}const smallViewportModifier={name:"smallViewport",enabled:true,phase:"main",fn:_modifyPosition};const VIEWPORT_PADDING=parseInt(remToPx(tokenValue(sizing.size_120)));class TooltipPopper extends React.Component{componentDidMount(){const{anchorElement,autoUpdate}=this.props;if(!anchorElement||!autoUpdate){return}this._observer=new MutationObserver(()=>{this._popperUpdate?.();});this._observer.observe(anchorElement,{attributes:true,childList:true,subtree:true});}componentWillUnmount(){this._observer?.disconnect();}_renderPositionedContent(popperProps){const{children}=this.props;const{isReady}=this.state;const placement=filterPopperPlacement(popperProps.placement)||this.props.placement;this._bubbleRefTracker.setCallback(popperProps.ref);this._tailRefTracker.setCallback(popperProps.arrowProps.ref);this._popperUpdate=popperProps.update;const bubbleProps={placement,style:{top:popperProps.style.top,left:popperProps.style.left,bottom:popperProps.style.bottom,right:popperProps.style.right,position:popperProps.style.position,transform:popperProps.style.transform,visibility:!isReady?"hidden":undefined},updateBubbleRef:this._bubbleRefTracker.updateRef,tailOffset:{bottom:popperProps.arrowProps.style.bottom,right:popperProps.arrowProps.style.right,top:popperProps.arrowProps.style.top,left:popperProps.arrowProps.style.left,transform:popperProps.arrowProps.style.transform},updateTailRef:this._tailRefTracker.updateRef,isReferenceHidden:popperProps.isReferenceHidden};return children(bubbleProps)}render(){const{anchorElement,placement,rootBoundary,viewportPadding}=this.props;const modifiers=[smallViewportModifier];if(rootBoundary==="viewport"){modifiers.push({name:"preventOverflow",options:{rootBoundary:"viewport",padding:viewportPadding}});}else {modifiers.push({name:"flip",options:{rootBoundary:"document"}});}return jsx(Popper,{referenceElement:anchorElement,strategy:"fixed",placement:placement,modifiers:modifiers,onFirstUpdate:this.handleFirstUpdate,children:props=>this._renderPositionedContent(props)})}constructor(props){super(props),this._bubbleRefTracker=new RefTracker,this._tailRefTracker=new RefTracker,this._observer=null,this._popperUpdate=null,this.handleFirstUpdate=()=>{this.setState({isReady:true});};this.state={isReady:false};}}TooltipPopper.defaultProps={rootBoundary:"viewport",viewportPadding:VIEWPORT_PADDING};
32
+ var modules_1c4532eb={"hidden":"wb-tooltip-popper-hidden-71447701"};
33
+
34
+ const filterPopperPlacement=placement=>{switch(placement){case"auto":case"auto-start":case"auto-end":case"top":case"top-start":case"top-end":return "top";case"bottom":case"bottom-start":case"bottom-end":return "bottom";case"right":case"right-start":case"right-end":return "right";case"left":case"left-start":case"left-end":return "left";default:throw new g(placement)}};function _modifyPosition({state}){const popperHeight=state.rects.popper.height+state.rects.reference.height;const minHeight=document.documentElement.clientHeight;if(minHeight<popperHeight&&state.modifiersData.hide){state.modifiersData.hide={...state.modifiersData.hide,isReferenceHidden:false};}}const smallViewportModifier={name:"smallViewport",enabled:true,phase:"main",fn:_modifyPosition};const VIEWPORT_PADDING=parseInt(remToPx(tokenValue(sizing.size_120)));class TooltipPopper extends React.Component{componentDidMount(){const{anchorElement,autoUpdate}=this.props;if(!anchorElement||!autoUpdate){return}this._observer=new MutationObserver(()=>{this._popperUpdate?.();});this._observer.observe(anchorElement,{attributes:true,childList:true,subtree:true});}componentWillUnmount(){this._observer?.disconnect();}_renderPositionedContent(popperProps){const{children}=this.props;const{isReady}=this.state;const placement=filterPopperPlacement(popperProps.placement)||this.props.placement;this._bubbleRefTracker.setCallback(popperProps.ref);this._tailRefTracker.setCallback(popperProps.arrowProps.ref);this._popperUpdate=popperProps.update;const bubbleProps={placement,style:[{top:popperProps.style.top,left:popperProps.style.left,bottom:popperProps.style.bottom,right:popperProps.style.right,position:popperProps.style.position,transform:popperProps.style.transform},!isReady&&modules_1c4532eb.hidden],updateBubbleRef:this._bubbleRefTracker.updateRef,tailOffset:{bottom:popperProps.arrowProps.style.bottom,right:popperProps.arrowProps.style.right,top:popperProps.arrowProps.style.top,left:popperProps.arrowProps.style.left,transform:popperProps.arrowProps.style.transform},updateTailRef:this._tailRefTracker.updateRef,isReferenceHidden:popperProps.isReferenceHidden};return children(bubbleProps)}render(){const{anchorElement,placement,rootBoundary,viewportPadding}=this.props;const modifiers=[smallViewportModifier];if(rootBoundary==="viewport"){modifiers.push({name:"preventOverflow",options:{rootBoundary:"viewport",padding:viewportPadding}});}else {modifiers.push({name:"flip",options:{rootBoundary:"document"}});}return jsx(Popper,{referenceElement:anchorElement,strategy:"fixed",placement:placement,modifiers:modifiers,onFirstUpdate:this.handleFirstUpdate,children:props=>this._renderPositionedContent(props)})}constructor(props){super(props),this._bubbleRefTracker=new RefTracker,this._tailRefTracker=new RefTracker,this._observer=null,this._popperUpdate=null,this.handleFirstUpdate=()=>{this.setState({isReady:true});};this.state={isReady:false};}}TooltipPopper.defaultProps={rootBoundary:"viewport",viewportPadding:VIEWPORT_PADDING};
28
35
 
29
36
  class Tooltip extends React.Component{static getDerivedStateFromProps(props,state){return {active:typeof props.opened==="boolean"?props.opened:state.active}}_updateAnchorElement(ref){if(ref&&ref!==this.state.anchorElement){this.setState({anchorElement:ref});}}_renderBubbleContent(){const{title,content,contentStyle,testId}=this.props;if(typeof content==="string"){return jsx(TooltipContent,{title:title,contentStyle:contentStyle,testId:testId?`${testId}-content`:undefined,children:content})}else if(title){return React.cloneElement(content,{title})}else {return content}}_renderPopper(ariaContentId){const{backgroundColor,placement,variant}=this.props;return jsx(TooltipPopper,{anchorElement:this.state.anchorElement,placement:placement,autoUpdate:this.props.autoUpdate,viewportPadding:this.props.viewportPadding,children:props=>jsx(TooltipBubble,{id:ariaContentId,style:props.style,backgroundColor:backgroundColor,variant:variant,tailOffset:props.tailOffset,isReferenceHidden:props.isReferenceHidden,placement:props.placement,updateTailRef:props.updateTailRef,updateBubbleRef:props.updateBubbleRef,onActiveChanged:active=>this.setState({activeBubble:active}),children:this._renderBubbleContent()})})}_getHost(){const{anchorElement}=this.state;return maybeGetPortalMountedModalHostElement(anchorElement)||document.body}_renderTooltipAnchor(uniqueId){const{autoUpdate,children,forceAnchorFocusivity}=this.props;const{active,activeBubble}=this.state;const popperHost=this._getHost();const shouldAnchorExist=autoUpdate?this.state.anchorElement:true;const shouldBeVisible=popperHost&&(active||activeBubble)&&shouldAnchorExist;const ariaContentId=`${uniqueId}-aria-content`;return jsxs(React.Fragment,{children:[jsx(TooltipAnchor,{forceAnchorFocusivity:forceAnchorFocusivity,anchorRef:r=>this._updateAnchorElement(r),onActiveChanged:active=>this.setState({active}),"aria-describedby":shouldBeVisible?ariaContentId:undefined,children:children}),shouldBeVisible&&ReactDOM.createPortal(this._renderPopper(ariaContentId),popperHost)]})}render(){const{id}=this.props;return jsx(Id,{id:id,children:uniqueId=>this._renderTooltipAnchor(uniqueId)})}constructor(...args){super(...args),this.state={active:false,activeBubble:false};}}Tooltip.defaultProps={forceAnchorFocusivity:true,placement:"top",variant:"subtle"};
30
37
 
31
38
  export { TooltipContent, TooltipPopper, TooltipTail, Tooltip as default };
39
+
40
+ import "./index.css";
package/dist/index.css ADDED
@@ -0,0 +1,131 @@
1
+ @layer shared {/**
2
+ * TooltipBubble styles
3
+ *
4
+ * Every rule is nested inside `.root` — the marker class on the bubble's
5
+ * outer `View`, which carries no declarations of its own. Both the bubble
6
+ * and its content wrapper are `View`s, and this component overrides
7
+ * properties `View` sets in its own single-class rule in the same
8
+ * `@layer shared` (`position`, `flex-direction`, `border-*`). The bundle
9
+ * loads this package's CSS before core's, so at equal specificity `View`
10
+ * would win; the compound selector makes the result depend on specificity
11
+ * instead.
12
+ *
13
+ * Source order reproduces the order of the `style` arrays: `hide` → `bubble`
14
+ * → placement on the bubble, and `content` → `contentStrong` on the content
15
+ * wrapper. The popper position (`style`) and the legacy `backgroundColor`
16
+ * override are plain style objects, which `processStyleList` still routes
17
+ * through Aphrodite (unlayered and `!important`), so they win over this
18
+ * module as they did before — including over `contentStrong`.
19
+ *
20
+ * Nesting is native CSS: every `&` is explicit and resolves to the flat
21
+ * selector it replaces (`.root.hide`, `.root .content`, …). The build wraps
22
+ * every rule in `@layer shared { … }`.
23
+ */.wb-tooltip-bubble-root-250a0b0f {
24
+ /* The hide style ensures that the bounds of the bubble stay unchanged.
25
+ * This is because popper.js calculates the bubble position based off its
26
+ * bounds and if we stopped rendering it entirely, it wouldn't know where
27
+ * to place it when it reappeared. */
28
+ &.wb-tooltip-bubble-hide-250a0b0f {
29
+ pointer-events: none;
30
+ opacity: 0;
31
+ background-color: var(--wb-semanticColor-core-transparent);
32
+ color: var(--wb-semanticColor-core-transparent);
33
+ }
34
+
35
+ &.wb-tooltip-bubble-bubble-250a0b0f {
36
+ position: absolute;
37
+ }
38
+
39
+ /* Ensure the content and tail are properly arranged. */
40
+ &.wb-tooltip-bubble-contentTop-250a0b0f {
41
+ flex-direction: column;
42
+ }
43
+
44
+ &.wb-tooltip-bubble-contentRight-250a0b0f {
45
+ flex-direction: row-reverse;
46
+ }
47
+
48
+ &.wb-tooltip-bubble-contentBottom-250a0b0f {
49
+ flex-direction: column-reverse;
50
+ }
51
+
52
+ &.wb-tooltip-bubble-contentLeft-250a0b0f {
53
+ flex-direction: row;
54
+ }
55
+
56
+ & .wb-tooltip-bubble-content-250a0b0f {
57
+ max-inline-size: 472px;
58
+ border-radius: var(--wb-border-radius-radius_040);
59
+ border: solid var(--wb-border-width-thin) var(--wb-semanticColor-core-border-neutral-subtle);
60
+ background-color: var(--wb-semanticColor-core-background-base-default);
61
+ box-shadow: var(--wb-boxShadow-mid);
62
+ justify-content: center;
63
+ }
64
+
65
+ /* The strong variant uses a higher-emphasis inverse/knockout treatment.
66
+ * The text color is set here so it cascades to the `TooltipContent`
67
+ * typography, which inherits the CSS `color`. */
68
+ & .wb-tooltip-bubble-contentStrong-250a0b0f {
69
+ background-color: var(--wb-semanticColor-feedback-neutral-strong-background);
70
+ border-color: var(--wb-semanticColor-feedback-neutral-strong-border);
71
+ color: var(--wb-semanticColor-feedback-neutral-strong-text);
72
+ }
73
+ }
74
+ }
75
+
76
+ @layer shared {/**
77
+ * TooltipContent styles
78
+ *
79
+ * The rules are nested inside `.root` — the marker class on the content
80
+ * `View`, which carries no declarations of its own — because they override
81
+ * `View`'s `padding`, which core sets in a single-class rule in the same
82
+ * `@layer shared`. The bundle loads this package's CSS before core's, so at
83
+ * equal specificity `View` would win. `TooltipContent` is a public export
84
+ * and doesn't have to render inside a `TooltipBubble`, so it carries its
85
+ * own marker instead of relying on the bubble's.
86
+ *
87
+ * The consumer's `contentStyle` is a plain style object, which
88
+ * `processStyleList` still routes through Aphrodite (unlayered and
89
+ * `!important`), so it wins over this module as it did before. The build
90
+ * wraps every rule in `@layer shared { … }`.
91
+ */.wb-tooltip-content-root-06de2278 {
92
+ &.wb-tooltip-content-withoutTitle-06de2278 {
93
+ padding: var(--wb-sizing-size_100) var(--wb-sizing-size_160);
94
+ }
95
+
96
+ &.wb-tooltip-content-withTitle-06de2278 {
97
+ padding: var(--wb-sizing-size_160);
98
+
99
+ /* gap between the title and its children when both are present. */
100
+ gap: var(--wb-sizing-size_040);
101
+ }
102
+ }
103
+ }
104
+
105
+ @layer shared {/* Styles for `TooltipPopper`. The build wraps these rules in
106
+ * `@layer shared { … }` via the wrap-in-layer plugin in `postcss.config.cjs`. *//* Hides the bubble until popper has positioned it for the first time. This is
107
+ * a class rather than an inline style so that consumer test setups, which
108
+ * mock CSS, don't see the bubble as hidden before popper's first update. */.wb-tooltip-popper-hidden-71447701 {
109
+ visibility: hidden;
110
+ }
111
+ }
112
+
113
+ @layer shared {/**
114
+ * TooltipTail styles
115
+ *
116
+ * `.tailContainer` sits on a `View`, but neither of its declarations
117
+ * competes with core's `View` rule (`position: relative` matches the value
118
+ * `View` already sets), so a single class is enough. `.arrow` sits on a
119
+ * plain `svg`. The placement-specific container size/offset and the arrow
120
+ * margins stay plain style objects in the component. The build wraps every
121
+ * rule in `@layer shared { … }`.
122
+ */.wb-tooltip-tail-tailContainer-46f3a126 {
123
+ position: relative;
124
+ pointer-events: none;
125
+ }.wb-tooltip-tail-arrow-46f3a126 {
126
+ /* Ensure the dropshadow bleeds outside our bounds. */
127
+ overflow: visible;
128
+ }
129
+ }
130
+
131
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["<no source>","../src/components/tooltip-bubble.module.css","../src/components/tooltip-content.module.css","../src/components/tooltip-popper.module.css","../src/components/tooltip-tail.module.css"],"names":[],"mappings":"AAAA,eCAA;;;;;;;;;;;;;;;;;;;;;;EAsBE,CAEF;IACI;;;wCAGoC;IACpC;QACI,oBAAoB;QACpB,UAAU;QACV,0DAA0D;QAC1D,+CAA+C;IACnD;;IAEA;QACI,kBAAkB;IACtB;;IAEA,uDAAuD;IACvD;QACI,sBAAsB;IAC1B;;IAEA;QACI,2BAA2B;IAC/B;;IAEA;QACI,8BAA8B;IAClC;;IAEA;QACI,mBAAmB;IACvB;;IAEA;QACI,sBAAsB;QACtB,iDAAiD;QACjD,4FAA4F;QAC5F,sEAAsE;QACtE,mCAAmC;QACnC,uBAAuB;IAC3B;;IAEA;;oDAEgD;IAChD;QACI,4EAA4E;QAC5E,oEAAoE;QACpE,2DAA2D;IAC/D;AACJ;CD1EA;;AAAA,eEAA;;;;;;;;;;;;;;;EAeE,CAEF;IACI;QACI,4DAA4D;IAChE;;IAEA;QACI,kCAAkC;;QAElC,kEAAkE;QAClE,8BAA8B;IAClC;AACJ;CF5BA;;AAAA,eGAA;gFACgF,CAEhF;;2EAE2E,CAC3E;IACI,kBAAkB;AACtB;CHRA;;AAAA,eIAA;;;;;;;;;EASE,CAEF;IACI,kBAAkB;IAClB,oBAAoB;AACxB,CAEA;IACI,qDAAqD;IACrD,iBAAiB;AACrB;CJnBA","file":"index.css","sourcesContent":[null,"/**\n * TooltipBubble styles\n *\n * Every rule is nested inside `.root` — the marker class on the bubble's\n * outer `View`, which carries no declarations of its own. Both the bubble\n * and its content wrapper are `View`s, and this component overrides\n * properties `View` sets in its own single-class rule in the same\n * `@layer shared` (`position`, `flex-direction`, `border-*`). The bundle\n * loads this package's CSS before core's, so at equal specificity `View`\n * would win; the compound selector makes the result depend on specificity\n * instead.\n *\n * Source order reproduces the order of the `style` arrays: `hide` → `bubble`\n * → placement on the bubble, and `content` → `contentStrong` on the content\n * wrapper. The popper position (`style`) and the legacy `backgroundColor`\n * override are plain style objects, which `processStyleList` still routes\n * through Aphrodite (unlayered and `!important`), so they win over this\n * module as they did before — including over `contentStrong`.\n *\n * Nesting is native CSS: every `&` is explicit and resolves to the flat\n * selector it replaces (`.root.hide`, `.root .content`, …). The build wraps\n * every rule in `@layer shared { … }`.\n */\n\n.root {\n /* The hide style ensures that the bounds of the bubble stay unchanged.\n * This is because popper.js calculates the bubble position based off its\n * bounds and if we stopped rendering it entirely, it wouldn't know where\n * to place it when it reappeared. */\n &.hide {\n pointer-events: none;\n opacity: 0;\n background-color: var(--wb-semanticColor-core-transparent);\n color: var(--wb-semanticColor-core-transparent);\n }\n\n &.bubble {\n position: absolute;\n }\n\n /* Ensure the content and tail are properly arranged. */\n &.contentTop {\n flex-direction: column;\n }\n\n &.contentRight {\n flex-direction: row-reverse;\n }\n\n &.contentBottom {\n flex-direction: column-reverse;\n }\n\n &.contentLeft {\n flex-direction: row;\n }\n\n & .content {\n max-inline-size: 472px;\n border-radius: var(--wb-border-radius-radius_040);\n border: solid var(--wb-border-width-thin) var(--wb-semanticColor-core-border-neutral-subtle);\n background-color: var(--wb-semanticColor-core-background-base-default);\n box-shadow: var(--wb-boxShadow-mid);\n justify-content: center;\n }\n\n /* The strong variant uses a higher-emphasis inverse/knockout treatment.\n * The text color is set here so it cascades to the `TooltipContent`\n * typography, which inherits the CSS `color`. */\n & .contentStrong {\n background-color: var(--wb-semanticColor-feedback-neutral-strong-background);\n border-color: var(--wb-semanticColor-feedback-neutral-strong-border);\n color: var(--wb-semanticColor-feedback-neutral-strong-text);\n }\n}\n","/**\n * TooltipContent styles\n *\n * The rules are nested inside `.root` — the marker class on the content\n * `View`, which carries no declarations of its own — because they override\n * `View`'s `padding`, which core sets in a single-class rule in the same\n * `@layer shared`. The bundle loads this package's CSS before core's, so at\n * equal specificity `View` would win. `TooltipContent` is a public export\n * and doesn't have to render inside a `TooltipBubble`, so it carries its\n * own marker instead of relying on the bubble's.\n *\n * The consumer's `contentStyle` is a plain style object, which\n * `processStyleList` still routes through Aphrodite (unlayered and\n * `!important`), so it wins over this module as it did before. The build\n * wraps every rule in `@layer shared { … }`.\n */\n\n.root {\n &.withoutTitle {\n padding: var(--wb-sizing-size_100) var(--wb-sizing-size_160);\n }\n\n &.withTitle {\n padding: var(--wb-sizing-size_160);\n\n /* gap between the title and its children when both are present. */\n gap: var(--wb-sizing-size_040);\n }\n}\n","/* Styles for `TooltipPopper`. The build wraps these rules in\n * `@layer shared { … }` via the wrap-in-layer plugin in `postcss.config.cjs`. */\n\n/* Hides the bubble until popper has positioned it for the first time. This is\n * a class rather than an inline style so that consumer test setups, which\n * mock CSS, don't see the bubble as hidden before popper's first update. */\n.hidden {\n visibility: hidden;\n}\n","/**\n * TooltipTail styles\n *\n * `.tailContainer` sits on a `View`, but neither of its declarations\n * competes with core's `View` rule (`position: relative` matches the value\n * `View` already sets), so a single class is enough. `.arrow` sits on a\n * plain `svg`. The placement-specific container size/offset and the arrow\n * margins stay plain style objects in the component. The build wraps every\n * rule in `@layer shared { … }`.\n */\n\n.tailContainer {\n position: relative;\n pointer-events: none;\n}\n\n.arrow {\n /* Ensure the dropshadow bleeds outside our bounds. */\n overflow: visible;\n}\n"]}
package/dist/index.js CHANGED
@@ -7,7 +7,6 @@ var React = require('react');
7
7
  var ReactDOM = require('react-dom');
8
8
  var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
9
9
  var wonderBlocksModal = require('@khanacademy/wonder-blocks-modal');
10
- var aphrodite = require('aphrodite');
11
10
  var wonderBlocksTokens = require('@khanacademy/wonder-blocks-tokens');
12
11
  var wonderBlocksTypography = require('@khanacademy/wonder-blocks-typography');
13
12
  var reactPopper = require('react-popper');
@@ -39,17 +38,25 @@ const TooltipAppearanceDelay=100;const TooltipDisappearanceDelay=75;
39
38
 
40
39
  const TRACKER=new ActiveTracker;class TooltipAnchor extends React__namespace.Component{componentDidMount(){const anchorNode=ReactDOM__namespace.findDOMNode(this);if(anchorNode instanceof Text){throw new Error("TooltipAnchor must be applied to an Element. Text content is not supported.")}this._unsubscribeFromTracker=TRACKER.subscribe(this);this._anchorNode=anchorNode;this._updateFocusivity();if(anchorNode){anchorNode.addEventListener("focusin",this._handleFocusIn);anchorNode.addEventListener("focusout",this._handleFocusOut);anchorNode.addEventListener("mouseenter",this._handleMouseEnter);anchorNode.addEventListener("mouseleave",this._handleMouseLeave);this.props.anchorRef(this._anchorNode);}}componentDidUpdate(prevProps){if(prevProps.forceAnchorFocusivity!==this.props.forceAnchorFocusivity||prevProps.children!==this.props.children){this._updateFocusivity();}}componentWillUnmount(){if(this._unsubscribeFromTracker){this._unsubscribeFromTracker();}this._clearPendingAction();const anchorNode=this._anchorNode;if(anchorNode){anchorNode.removeEventListener("focusin",this._handleFocusIn);anchorNode.removeEventListener("focusout",this._handleFocusOut);anchorNode.removeEventListener("mouseenter",this._handleMouseEnter);anchorNode.removeEventListener("mouseleave",this._handleMouseLeave);}if(this.state.active){document.removeEventListener("keyup",this._handleKeyUp);}}_updateFocusivity(){const anchorNode=this._anchorNode;if(!anchorNode){return}const{forceAnchorFocusivity}=this.props;const currentTabIndex=anchorNode.getAttribute("tabindex");if(forceAnchorFocusivity&&!currentTabIndex){anchorNode.setAttribute("tabindex","0");this._weSetFocusivity=true;}else if(!forceAnchorFocusivity&&currentTabIndex){if(this._weSetFocusivity){anchorNode.removeAttribute("tabindex");this._weSetFocusivity=false;}}}_updateActiveState(hovered,focused){this._hovered=hovered;this._focused=focused;this._setActiveState(hovered||focused);}_clearPendingAction(){if(this._timeoutID){clearTimeout(this._timeoutID);this._timeoutID=null;}}_setActiveState(active,instant){if(this._stolenFromUs||active!==this.state.active||!this.state.active&&this._timeoutID){this._clearPendingAction();}else if(active===this.state.active){if(this._timeoutID){this._clearPendingAction();}return}instant=instant||active&&TRACKER.steal(this);if(instant){if(active){document.addEventListener("keyup",this._handleKeyUp);}else {document.removeEventListener("keyup",this._handleKeyUp);}this.setState({active});this.props.onActiveChanged(active);if(!this._stolenFromUs&&!active){TRACKER.giveup();}this._stolenFromUs=false;}else {const delay=active?TooltipAppearanceDelay:TooltipDisappearanceDelay;this._timeoutID=setTimeout(()=>{this._timeoutID=null;this._setActiveState(active,true);},delay);}}_renderAnchorableChildren(){const{children}=this.props;return typeof children==="string"?jsxRuntime.jsx(wonderBlocksCore.Text,{children:children}):children}render(){const{"aria-describedby":ariaDescribedBy}=this.props;const anchorableChildren=this._renderAnchorableChildren();return React__namespace.cloneElement(anchorableChildren,{"aria-describedby":ariaDescribedBy})}constructor(props){super(props),this.activeStateStolen=()=>{this._stolenFromUs=this.state.active||!!this._timeoutID;this._focused=false;this._setActiveState(false,true);},this._handleFocusIn=()=>{this._updateActiveState(this._hovered,true);},this._handleFocusOut=()=>{this._updateActiveState(this._hovered,false);},this._handleMouseEnter=()=>{this._updateActiveState(true,this._focused);},this._handleMouseLeave=()=>{this._updateActiveState(false,this._focused);},this._handleKeyUp=e=>{if(e.key==="Escape"&&this.state.active){e.preventDefault();e.stopPropagation();this._updateActiveState(false,false);}};this._focused=false;this._hovered=false;this.state={active:false};}}TooltipAnchor.defaultProps={forceAnchorFocusivity:true};
41
40
 
42
- let tempIdCounter=0;class TooltipTail extends React__namespace.Component{_calculateDimensionsFromPlacement(){const{placement}=this.props;const trimlineOffset=.5;switch(placement){case"top":return {trimlinePoints:[`0,-${trimlineOffset}`,`${ARROW_WIDTH},-${trimlineOffset}`],points:["0,0",`${ARROW_WIDTH/2},${ARROW_HEIGHT}`,`${ARROW_WIDTH},0`],height:ARROW_HEIGHT,width:ARROW_WIDTH};case"right":return {trimlinePoints:[`${ARROW_HEIGHT+trimlineOffset},0`,`${ARROW_HEIGHT+trimlineOffset},${ARROW_WIDTH}`],points:[`${ARROW_HEIGHT},0`,`0,${ARROW_WIDTH/2}`,`${ARROW_HEIGHT},${ARROW_WIDTH}`],width:ARROW_HEIGHT,height:ARROW_WIDTH};case"bottom":return {trimlinePoints:[`0, ${ARROW_HEIGHT+trimlineOffset}`,`${ARROW_WIDTH},${ARROW_HEIGHT+trimlineOffset}`],points:[`0, ${ARROW_HEIGHT}`,`${ARROW_WIDTH/2},0`,`${ARROW_WIDTH},${ARROW_HEIGHT}`],width:ARROW_WIDTH,height:ARROW_HEIGHT};case"left":return {trimlinePoints:[`-${trimlineOffset},0`,`-${trimlineOffset},${ARROW_WIDTH}`],points:[`0,0`,`${ARROW_HEIGHT},${ARROW_WIDTH/2}`,`0,${ARROW_WIDTH}`],width:ARROW_HEIGHT,height:ARROW_WIDTH};default:throw new Error(`Unknown placement: ${placement}`)}}_getFilterPositioning(){const{placement}=this.props;switch(placement){case"top":return {y:"-50%",x:"-50%",offsetShadowX:0};case"bottom":return null;case"left":return {y:"-50%",x:"0%",offsetShadowX:1};case"right":return {y:"-50%",x:"-100%",offsetShadowX:-1};default:throw new Error(`Unknown placement: ${placement}`)}}_maybeRenderDropshadow(points){const position=this._getFilterPositioning();if(!position){return null}const{placement}=this.props;const{y,x,offsetShadowX}=position;const dropShadowFilterId=`tooltip-dropshadow-${placement}-${tempIdCounter++}`;return [jsxRuntime.jsxs("filter",{id:dropShadowFilterId,width:"200%",height:"200%",x:x,y:y,children:[jsxRuntime.jsx("feGaussianBlur",{in:"SourceAlpha",stdDeviation:3}),jsxRuntime.jsx("feComponentTransfer",{children:jsxRuntime.jsx("feFuncA",{type:"linear",slope:"0.3"})})]},"filter"),jsxRuntime.jsx("g",{transform:`translate(${offsetShadowX},5.5)`,children:jsxRuntime.jsx("polyline",{fill:wonderBlocksTokens.semanticColor.core.shadow.transparent.mid,points:points.join(" "),stroke:wonderBlocksTokens.semanticColor.core.shadow.transparent.mid,filter:`url(#${dropShadowFilterId})`})},"dropshadow")]}_getFullTailWidth(){return ARROW_WIDTH+2*MIN_DISTANCE_FROM_CORNERS}_getFullTailHeight(){return ARROW_HEIGHT+DISTANCE_FROM_ANCHOR}_getContainerStyle(){const{placement}=this.props;const fullTailWidth=this._getFullTailWidth();const fullTailHeight=this._getFullTailHeight();switch(placement){case"top":return {top:-1,width:fullTailWidth,height:fullTailHeight};case"right":return {left:1,width:fullTailHeight,height:fullTailWidth};case"bottom":return {top:1,width:fullTailWidth,height:fullTailHeight};case"left":return {left:-1,width:fullTailHeight,height:fullTailWidth};default:throw new Error(`Unknown placement: ${placement}`)}}_getArrowStyle(){const{placement}=this.props;switch(placement){case"top":return {marginLeft:MIN_DISTANCE_FROM_CORNERS,marginRight:MIN_DISTANCE_FROM_CORNERS,paddingBottom:DISTANCE_FROM_ANCHOR};case"right":return {marginTop:MIN_DISTANCE_FROM_CORNERS,marginBottom:MIN_DISTANCE_FROM_CORNERS,paddingLeft:DISTANCE_FROM_ANCHOR};case"bottom":return {marginLeft:MIN_DISTANCE_FROM_CORNERS,marginRight:MIN_DISTANCE_FROM_CORNERS,paddingTop:DISTANCE_FROM_ANCHOR};case"left":return {marginTop:MIN_DISTANCE_FROM_CORNERS,marginBottom:MIN_DISTANCE_FROM_CORNERS,paddingRight:DISTANCE_FROM_ANCHOR};default:throw new Error(`Unknown placement: ${placement}`)}}_renderArrow(){const{trimlinePoints,points,height,width}=this._calculateDimensionsFromPlacement();const{color:arrowColor,show,variant}=this.props;const isStrong=variant==="strong";const tailFill=arrowColor!==undefined&&wonderBlocksTokens.color[arrowColor]?wonderBlocksTokens.color[arrowColor]:isStrong?wonderBlocksTokens.semanticColor.feedback.neutral.strong.background:wonderBlocksTokens.semanticColor.core.background.base.default;const tailBorder=isStrong?wonderBlocksTokens.semanticColor.feedback.neutral.strong.border:wonderBlocksTokens.semanticColor.core.border.neutral.subtle;if(!show){return jsxRuntime.jsx(wonderBlocksCore.View,{"aria-hidden":true,style:{inlineSize:height,flexBasis:height,flexShrink:0}})}return jsxRuntime.jsxs("svg",{className:aphrodite.css(styles$2.arrow),style:this._getArrowStyle(),width:width,height:height,"aria-hidden":true,children:[this._maybeRenderDropshadow(points),jsxRuntime.jsx("polyline",{fill:tailFill,stroke:tailFill,points:points.join(" ")}),jsxRuntime.jsx("polyline",{fill:tailFill,points:points.join(" "),stroke:tailBorder}),jsxRuntime.jsx("polyline",{stroke:tailFill,points:trimlinePoints.join(" ")})]})}render(){const{offset,placement,updateRef}=this.props;return jsxRuntime.jsx(wonderBlocksCore.View,{style:[styles$2.tailContainer,{...offset},this._getContainerStyle()],"data-placement":placement,ref:updateRef,children:this._renderArrow()})}}TooltipTail.defaultProps={show:true};const DISTANCE_FROM_ANCHOR=8;const MIN_DISTANCE_FROM_CORNERS=8;const ARROW_WIDTH=24;const ARROW_HEIGHT=12;const styles$2=aphrodite.StyleSheet.create({tailContainer:{position:"relative",pointerEvents:"none"},arrow:{overflow:"visible"}});
41
+ var modules_bf6a48cd={"tailContainer":"wb-tooltip-tail-tailContainer-46f3a126","arrow":"wb-tooltip-tail-arrow-46f3a126"};
43
42
 
44
- class TooltipBubble extends React__namespace.Component{_setActiveState(active){this.setState({active});this.props.onActiveChanged(active);}render(){const{id,children,updateBubbleRef,placement,isReferenceHidden,style,updateTailRef,tailOffset,backgroundColor,variant}=this.props;const isStrong=variant==="strong";return jsxRuntime.jsxs(wonderBlocksCore.View,{id:id,role:"tooltip","data-placement":placement,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,ref:updateBubbleRef,style:[isReferenceHidden&&styles$1.hide,styles$1.bubble,styles$1[`content-${placement}`],style],children:[jsxRuntime.jsx(wonderBlocksCore.View,{style:[styles$1.content,backgroundColor&&{backgroundColor:wonderBlocksTokens.color[backgroundColor]},isStrong&&styles$1.contentStrong],children:children}),jsxRuntime.jsx(TooltipTail,{updateRef:updateTailRef,placement:placement,offset:tailOffset,color:backgroundColor,variant:variant})]})}constructor(...args){super(...args),this.state={active:false},this.handleMouseEnter=()=>{this._setActiveState(true);},this.handleMouseLeave=()=>{this.props.onActiveChanged(false);};}}const styles$1=aphrodite.StyleSheet.create({bubble:{position:"absolute"},hide:{pointerEvents:"none",opacity:0,backgroundColor:wonderBlocksTokens.semanticColor.core.transparent,color:wonderBlocksTokens.semanticColor.core.transparent},"content-top":{flexDirection:"column"},"content-right":{flexDirection:"row-reverse"},"content-bottom":{flexDirection:"column-reverse"},"content-left":{flexDirection:"row"},content:{maxInlineSize:472,borderRadius:wonderBlocksTokens.border.radius.radius_040,border:`solid 1px ${wonderBlocksTokens.semanticColor.core.border.neutral.subtle}`,backgroundColor:wonderBlocksTokens.semanticColor.core.background.base.default,boxShadow:wonderBlocksTokens.boxShadow.mid,justifyContent:"center"},contentStrong:{backgroundColor:wonderBlocksTokens.semanticColor.feedback.neutral.strong.background,borderColor:wonderBlocksTokens.semanticColor.feedback.neutral.strong.border,color:wonderBlocksTokens.semanticColor.feedback.neutral.strong.text}});
43
+ let tempIdCounter=0;class TooltipTail extends React__namespace.Component{_calculateDimensionsFromPlacement(){const{placement}=this.props;const trimlineOffset=.5;switch(placement){case"top":return {trimlinePoints:[`0,-${trimlineOffset}`,`${ARROW_WIDTH},-${trimlineOffset}`],points:["0,0",`${ARROW_WIDTH/2},${ARROW_HEIGHT}`,`${ARROW_WIDTH},0`],height:ARROW_HEIGHT,width:ARROW_WIDTH};case"right":return {trimlinePoints:[`${ARROW_HEIGHT+trimlineOffset},0`,`${ARROW_HEIGHT+trimlineOffset},${ARROW_WIDTH}`],points:[`${ARROW_HEIGHT},0`,`0,${ARROW_WIDTH/2}`,`${ARROW_HEIGHT},${ARROW_WIDTH}`],width:ARROW_HEIGHT,height:ARROW_WIDTH};case"bottom":return {trimlinePoints:[`0, ${ARROW_HEIGHT+trimlineOffset}`,`${ARROW_WIDTH},${ARROW_HEIGHT+trimlineOffset}`],points:[`0, ${ARROW_HEIGHT}`,`${ARROW_WIDTH/2},0`,`${ARROW_WIDTH},${ARROW_HEIGHT}`],width:ARROW_WIDTH,height:ARROW_HEIGHT};case"left":return {trimlinePoints:[`-${trimlineOffset},0`,`-${trimlineOffset},${ARROW_WIDTH}`],points:[`0,0`,`${ARROW_HEIGHT},${ARROW_WIDTH/2}`,`0,${ARROW_WIDTH}`],width:ARROW_HEIGHT,height:ARROW_WIDTH};default:throw new Error(`Unknown placement: ${placement}`)}}_getFilterPositioning(){const{placement}=this.props;switch(placement){case"top":return {y:"-50%",x:"-50%",offsetShadowX:0};case"bottom":return null;case"left":return {y:"-50%",x:"0%",offsetShadowX:1};case"right":return {y:"-50%",x:"-100%",offsetShadowX:-1};default:throw new Error(`Unknown placement: ${placement}`)}}_maybeRenderDropshadow(points){const position=this._getFilterPositioning();if(!position){return null}const{placement}=this.props;const{y,x,offsetShadowX}=position;const dropShadowFilterId=`tooltip-dropshadow-${placement}-${tempIdCounter++}`;return [jsxRuntime.jsxs("filter",{id:dropShadowFilterId,width:"200%",height:"200%",x:x,y:y,children:[jsxRuntime.jsx("feGaussianBlur",{in:"SourceAlpha",stdDeviation:3}),jsxRuntime.jsx("feComponentTransfer",{children:jsxRuntime.jsx("feFuncA",{type:"linear",slope:"0.3"})})]},"filter"),jsxRuntime.jsx("g",{transform:`translate(${offsetShadowX},5.5)`,children:jsxRuntime.jsx("polyline",{fill:wonderBlocksTokens.semanticColor.core.shadow.transparent.mid,points:points.join(" "),stroke:wonderBlocksTokens.semanticColor.core.shadow.transparent.mid,filter:`url(#${dropShadowFilterId})`})},"dropshadow")]}_getFullTailWidth(){return ARROW_WIDTH+2*MIN_DISTANCE_FROM_CORNERS}_getFullTailHeight(){return ARROW_HEIGHT+DISTANCE_FROM_ANCHOR}_getContainerStyle(){const{placement}=this.props;const fullTailWidth=this._getFullTailWidth();const fullTailHeight=this._getFullTailHeight();switch(placement){case"top":return {top:-1,width:fullTailWidth,height:fullTailHeight};case"right":return {left:1,width:fullTailHeight,height:fullTailWidth};case"bottom":return {top:1,width:fullTailWidth,height:fullTailHeight};case"left":return {left:-1,width:fullTailHeight,height:fullTailWidth};default:throw new Error(`Unknown placement: ${placement}`)}}_getArrowStyle(){const{placement}=this.props;switch(placement){case"top":return {marginLeft:MIN_DISTANCE_FROM_CORNERS,marginRight:MIN_DISTANCE_FROM_CORNERS,paddingBottom:DISTANCE_FROM_ANCHOR};case"right":return {marginTop:MIN_DISTANCE_FROM_CORNERS,marginBottom:MIN_DISTANCE_FROM_CORNERS,paddingLeft:DISTANCE_FROM_ANCHOR};case"bottom":return {marginLeft:MIN_DISTANCE_FROM_CORNERS,marginRight:MIN_DISTANCE_FROM_CORNERS,paddingTop:DISTANCE_FROM_ANCHOR};case"left":return {marginTop:MIN_DISTANCE_FROM_CORNERS,marginBottom:MIN_DISTANCE_FROM_CORNERS,paddingRight:DISTANCE_FROM_ANCHOR};default:throw new Error(`Unknown placement: ${placement}`)}}_renderArrow(){const{trimlinePoints,points,height,width}=this._calculateDimensionsFromPlacement();const{color:arrowColor,show,variant}=this.props;const isStrong=variant==="strong";const tailFill=arrowColor!==undefined&&wonderBlocksTokens.color[arrowColor]?wonderBlocksTokens.color[arrowColor]:isStrong?wonderBlocksTokens.semanticColor.feedback.neutral.strong.background:wonderBlocksTokens.semanticColor.core.background.base.default;const tailBorder=isStrong?wonderBlocksTokens.semanticColor.feedback.neutral.strong.border:wonderBlocksTokens.semanticColor.core.border.neutral.subtle;if(!show){return jsxRuntime.jsx(wonderBlocksCore.View,{"aria-hidden":true,style:{inlineSize:height,flexBasis:height,flexShrink:0}})}return jsxRuntime.jsxs("svg",{className:modules_bf6a48cd.arrow,style:this._getArrowStyle(),width:width,height:height,"aria-hidden":true,children:[this._maybeRenderDropshadow(points),jsxRuntime.jsx("polyline",{fill:tailFill,stroke:tailFill,points:points.join(" ")}),jsxRuntime.jsx("polyline",{fill:tailFill,points:points.join(" "),stroke:tailBorder}),jsxRuntime.jsx("polyline",{stroke:tailFill,points:trimlinePoints.join(" ")})]})}render(){const{offset,placement,updateRef}=this.props;return jsxRuntime.jsx(wonderBlocksCore.View,{style:[modules_bf6a48cd.tailContainer,{...offset},this._getContainerStyle()],"data-placement":placement,ref:updateRef,children:this._renderArrow()})}}TooltipTail.defaultProps={show:true};const DISTANCE_FROM_ANCHOR=8;const MIN_DISTANCE_FROM_CORNERS=8;const ARROW_WIDTH=24;const ARROW_HEIGHT=12;
45
44
 
46
- class TooltipContent extends React__namespace.Component{_renderTitle(){const{title}=this.props;if(title){if(typeof title==="string"){return jsxRuntime.jsx(wonderBlocksTypography.Heading,{size:"medium",children:title})}else {return title}}return null}_renderChildren(){const{children}=this.props;if(typeof children==="string"){return jsxRuntime.jsx(wonderBlocksTypography.BodyText,{tag:"span",children:children})}else {return children}}render(){const title=this._renderTitle();const children=this._renderChildren();const containerStyle=title?styles.withTitle:styles.withoutTitle;return jsxRuntime.jsxs(wonderBlocksCore.View,{style:[containerStyle,this.props.contentStyle],testId:this.props.testId,children:[title,title?jsxRuntime.jsx(wonderBlocksCore.View,{children:children}):children]})}}const styles=aphrodite.StyleSheet.create({withoutTitle:{padding:`${wonderBlocksTokens.sizing.size_100} ${wonderBlocksTokens.sizing.size_160}`},withTitle:{padding:wonderBlocksTokens.sizing.size_160,gap:wonderBlocksTokens.sizing.size_040}});
45
+ var modules_a9739994={"root":"wb-tooltip-bubble-root-250a0b0f","hide":"wb-tooltip-bubble-hide-250a0b0f","bubble":"wb-tooltip-bubble-bubble-250a0b0f","contentTop":"wb-tooltip-bubble-contentTop-250a0b0f","contentRight":"wb-tooltip-bubble-contentRight-250a0b0f","contentBottom":"wb-tooltip-bubble-contentBottom-250a0b0f","contentLeft":"wb-tooltip-bubble-contentLeft-250a0b0f","content":"wb-tooltip-bubble-content-250a0b0f","contentStrong":"wb-tooltip-bubble-contentStrong-250a0b0f"};
46
+
47
+ const placementStyles={top:modules_a9739994.contentTop,right:modules_a9739994.contentRight,bottom:modules_a9739994.contentBottom,left:modules_a9739994.contentLeft};class TooltipBubble extends React__namespace.Component{_setActiveState(active){this.setState({active});this.props.onActiveChanged(active);}render(){const{id,children,updateBubbleRef,placement,isReferenceHidden,style,updateTailRef,tailOffset,backgroundColor,variant}=this.props;const isStrong=variant==="strong";return jsxRuntime.jsxs(wonderBlocksCore.View,{id:id,role:"tooltip","data-placement":placement,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,ref:updateBubbleRef,style:[modules_a9739994.root,isReferenceHidden&&modules_a9739994.hide,modules_a9739994.bubble,placementStyles[placement],style],children:[jsxRuntime.jsx(wonderBlocksCore.View,{style:[modules_a9739994.content,backgroundColor&&{backgroundColor:wonderBlocksTokens.color[backgroundColor]},isStrong&&modules_a9739994.contentStrong],children:children}),jsxRuntime.jsx(TooltipTail,{updateRef:updateTailRef,placement:placement,offset:tailOffset,color:backgroundColor,variant:variant})]})}constructor(...args){super(...args),this.state={active:false},this.handleMouseEnter=()=>{this._setActiveState(true);},this.handleMouseLeave=()=>{this.props.onActiveChanged(false);};}}
48
+
49
+ var modules_69555561={"root":"wb-tooltip-content-root-06de2278","withoutTitle":"wb-tooltip-content-withoutTitle-06de2278","withTitle":"wb-tooltip-content-withTitle-06de2278"};
50
+
51
+ class TooltipContent extends React__namespace.Component{_renderTitle(){const{title}=this.props;if(title){if(typeof title==="string"){return jsxRuntime.jsx(wonderBlocksTypography.Heading,{size:"medium",children:title})}else {return title}}return null}_renderChildren(){const{children}=this.props;if(typeof children==="string"){return jsxRuntime.jsx(wonderBlocksTypography.BodyText,{tag:"span",children:children})}else {return children}}render(){const title=this._renderTitle();const children=this._renderChildren();const containerStyle=title?modules_69555561.withTitle:modules_69555561.withoutTitle;return jsxRuntime.jsxs(wonderBlocksCore.View,{style:[modules_69555561.root,containerStyle,this.props.contentStyle],testId:this.props.testId,children:[title,title?jsxRuntime.jsx(wonderBlocksCore.View,{children:children}):children]})}}
47
52
 
48
53
  var e=n=>null==n||"object"!=typeof n?n:Array.isArray(n)?n.map(e):Object.keys(n).reduce((t,r)=>(t[r]=e(n[r]),t),{}),t=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",InvalidUse:"InvalidUse",NotFound:"NotFound",NotAllowed:"NotAllowed",Unauthorized:"Unauthorized",NotImplemented:"NotImplemented"});function r(e,n,t){return (n=function(e){var n=function(e,n){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===n?String:Number)(e)}(e,"string");return "symbol"==typeof n?n:n+""}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}class o{constructor(e,n){r(this,"_name",void 0),r(this,"_message",void 0),this._name=e,this._message=n;}get message(){return this._message}get name(){return this._name}get messageWithName(){return "".concat(this.name,": ").concat(this.message)}static fromConsequenceAndCause(e,n){if("production"!==process.env.NODE_ENV){if(!(e instanceof o))throw new Error("consequence must be an instance of ErrorInfo");if(!(n instanceof o))throw new Error("cause must be an instance of ErrorInfo");if(n===e)throw new Error("cause and consequence must be different")}return new o(e.name,((e,n)=>{var t=e=>(null==e?void 0:e.trim())||"(empty message)",r=t(e);return null==n?r:"".concat(r,"\n\tcaused by\n\t\t").concat(t(n))})(e.message,n.messageWithName))}static normalize(e){var n;if("production"!==process.env.NODE_ENV&&!(e instanceof Error))throw new Error("Error must be an instance of Error");var t=null!==(n=e.message.toString().split("\n").find(e=>e.trim().length))&&void 0!==n?n:"(empty message)";return new o(e.name,t)}static from(e){if("production"!==process.env.NODE_ENV&&!(e instanceof Error))throw new Error("Error must be an instance of Error");return new o(e.name,e.message)}}class s extends Error{constructor(n){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.Unknown,{cause:i,prefix:a,name:u,metadata:c}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Object.freeze({});if("production"!==process.env.NODE_ENV){if(i&&!(i instanceof Error))throw new Error("cause must be an instance of Error");if(null!=u&&/\s/g.test(u))throw new Error("name must not contain whitespace");if(/\s/g.test(s))throw new Error("kind must not contain whitespace");if(null!=a&&/\s/g.test(a))throw new Error("prefix must not contain whitespace")}if(super(n),r(this,"kind",void 0),r(this,"originalMessage",void 0),r(this,"metadata",void 0),r(this,"cause",void 0),this.originalMessage=n,this.metadata=(n=>{if(null==n)return n;var t=e(n);return Object.freeze(t)})(c),this.name="".concat(null!=a?a:"").concat(s).concat(null!=u?u:"","Error"),this.kind=s,this.cause=i,null!=i){var l=o.normalize(this),f=o.from(i),d=o.fromConsequenceAndCause(l,f);this.message=d.message;}}}Object.freeze({ConsequenceFirst:"consequence-first",CauseFirst:"cause-first"});class g extends s{constructor(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.InvalidInput,r=arguments.length>2?arguments[2]:void 0;super("Unhandled case for '".concat(e,"'"),n,r);}}(function(e){return e.Production="production",e.Development="development",e.Test="test",e})({});
49
54
 
50
55
  class RefTracker{constructor(){this.updateRef=ref=>{if(ref){const domNode=ReactDOM__namespace.findDOMNode(ref);if(domNode instanceof HTMLElement&&domNode!==this._lastRef){this._lastRef=domNode;this._targetFn?.(domNode);}}};this.setCallback=targetFn=>{if(this._targetFn!==targetFn){if(targetFn&&typeof targetFn!=="function"){throw new Error("targetFn must be a function")}this._targetFn=targetFn||undefined;if(this._lastRef&&this._targetFn){this._targetFn(this._lastRef);}}};}}
51
56
 
52
- const filterPopperPlacement=placement=>{switch(placement){case"auto":case"auto-start":case"auto-end":case"top":case"top-start":case"top-end":return "top";case"bottom":case"bottom-start":case"bottom-end":return "bottom";case"right":case"right-start":case"right-end":return "right";case"left":case"left-start":case"left-end":return "left";default:throw new g(placement)}};function _modifyPosition({state}){const popperHeight=state.rects.popper.height+state.rects.reference.height;const minHeight=document.documentElement.clientHeight;if(minHeight<popperHeight&&state.modifiersData.hide){state.modifiersData.hide={...state.modifiersData.hide,isReferenceHidden:false};}}const smallViewportModifier={name:"smallViewport",enabled:true,phase:"main",fn:_modifyPosition};const VIEWPORT_PADDING=parseInt(wonderBlocksTokens.remToPx(wonderBlocksTokens.tokenValue(wonderBlocksTokens.sizing.size_120)));class TooltipPopper extends React__namespace.Component{componentDidMount(){const{anchorElement,autoUpdate}=this.props;if(!anchorElement||!autoUpdate){return}this._observer=new MutationObserver(()=>{this._popperUpdate?.();});this._observer.observe(anchorElement,{attributes:true,childList:true,subtree:true});}componentWillUnmount(){this._observer?.disconnect();}_renderPositionedContent(popperProps){const{children}=this.props;const{isReady}=this.state;const placement=filterPopperPlacement(popperProps.placement)||this.props.placement;this._bubbleRefTracker.setCallback(popperProps.ref);this._tailRefTracker.setCallback(popperProps.arrowProps.ref);this._popperUpdate=popperProps.update;const bubbleProps={placement,style:{top:popperProps.style.top,left:popperProps.style.left,bottom:popperProps.style.bottom,right:popperProps.style.right,position:popperProps.style.position,transform:popperProps.style.transform,visibility:!isReady?"hidden":undefined},updateBubbleRef:this._bubbleRefTracker.updateRef,tailOffset:{bottom:popperProps.arrowProps.style.bottom,right:popperProps.arrowProps.style.right,top:popperProps.arrowProps.style.top,left:popperProps.arrowProps.style.left,transform:popperProps.arrowProps.style.transform},updateTailRef:this._tailRefTracker.updateRef,isReferenceHidden:popperProps.isReferenceHidden};return children(bubbleProps)}render(){const{anchorElement,placement,rootBoundary,viewportPadding}=this.props;const modifiers=[smallViewportModifier];if(rootBoundary==="viewport"){modifiers.push({name:"preventOverflow",options:{rootBoundary:"viewport",padding:viewportPadding}});}else {modifiers.push({name:"flip",options:{rootBoundary:"document"}});}return jsxRuntime.jsx(reactPopper.Popper,{referenceElement:anchorElement,strategy:"fixed",placement:placement,modifiers:modifiers,onFirstUpdate:this.handleFirstUpdate,children:props=>this._renderPositionedContent(props)})}constructor(props){super(props),this._bubbleRefTracker=new RefTracker,this._tailRefTracker=new RefTracker,this._observer=null,this._popperUpdate=null,this.handleFirstUpdate=()=>{this.setState({isReady:true});};this.state={isReady:false};}}TooltipPopper.defaultProps={rootBoundary:"viewport",viewportPadding:VIEWPORT_PADDING};
57
+ var modules_1c4532eb={"hidden":"wb-tooltip-popper-hidden-71447701"};
58
+
59
+ const filterPopperPlacement=placement=>{switch(placement){case"auto":case"auto-start":case"auto-end":case"top":case"top-start":case"top-end":return "top";case"bottom":case"bottom-start":case"bottom-end":return "bottom";case"right":case"right-start":case"right-end":return "right";case"left":case"left-start":case"left-end":return "left";default:throw new g(placement)}};function _modifyPosition({state}){const popperHeight=state.rects.popper.height+state.rects.reference.height;const minHeight=document.documentElement.clientHeight;if(minHeight<popperHeight&&state.modifiersData.hide){state.modifiersData.hide={...state.modifiersData.hide,isReferenceHidden:false};}}const smallViewportModifier={name:"smallViewport",enabled:true,phase:"main",fn:_modifyPosition};const VIEWPORT_PADDING=parseInt(wonderBlocksTokens.remToPx(wonderBlocksTokens.tokenValue(wonderBlocksTokens.sizing.size_120)));class TooltipPopper extends React__namespace.Component{componentDidMount(){const{anchorElement,autoUpdate}=this.props;if(!anchorElement||!autoUpdate){return}this._observer=new MutationObserver(()=>{this._popperUpdate?.();});this._observer.observe(anchorElement,{attributes:true,childList:true,subtree:true});}componentWillUnmount(){this._observer?.disconnect();}_renderPositionedContent(popperProps){const{children}=this.props;const{isReady}=this.state;const placement=filterPopperPlacement(popperProps.placement)||this.props.placement;this._bubbleRefTracker.setCallback(popperProps.ref);this._tailRefTracker.setCallback(popperProps.arrowProps.ref);this._popperUpdate=popperProps.update;const bubbleProps={placement,style:[{top:popperProps.style.top,left:popperProps.style.left,bottom:popperProps.style.bottom,right:popperProps.style.right,position:popperProps.style.position,transform:popperProps.style.transform},!isReady&&modules_1c4532eb.hidden],updateBubbleRef:this._bubbleRefTracker.updateRef,tailOffset:{bottom:popperProps.arrowProps.style.bottom,right:popperProps.arrowProps.style.right,top:popperProps.arrowProps.style.top,left:popperProps.arrowProps.style.left,transform:popperProps.arrowProps.style.transform},updateTailRef:this._tailRefTracker.updateRef,isReferenceHidden:popperProps.isReferenceHidden};return children(bubbleProps)}render(){const{anchorElement,placement,rootBoundary,viewportPadding}=this.props;const modifiers=[smallViewportModifier];if(rootBoundary==="viewport"){modifiers.push({name:"preventOverflow",options:{rootBoundary:"viewport",padding:viewportPadding}});}else {modifiers.push({name:"flip",options:{rootBoundary:"document"}});}return jsxRuntime.jsx(reactPopper.Popper,{referenceElement:anchorElement,strategy:"fixed",placement:placement,modifiers:modifiers,onFirstUpdate:this.handleFirstUpdate,children:props=>this._renderPositionedContent(props)})}constructor(props){super(props),this._bubbleRefTracker=new RefTracker,this._tailRefTracker=new RefTracker,this._observer=null,this._popperUpdate=null,this.handleFirstUpdate=()=>{this.setState({isReady:true});};this.state={isReady:false};}}TooltipPopper.defaultProps={rootBoundary:"viewport",viewportPadding:VIEWPORT_PADDING};
53
60
 
54
61
  class Tooltip extends React__namespace.Component{static getDerivedStateFromProps(props,state){return {active:typeof props.opened==="boolean"?props.opened:state.active}}_updateAnchorElement(ref){if(ref&&ref!==this.state.anchorElement){this.setState({anchorElement:ref});}}_renderBubbleContent(){const{title,content,contentStyle,testId}=this.props;if(typeof content==="string"){return jsxRuntime.jsx(TooltipContent,{title:title,contentStyle:contentStyle,testId:testId?`${testId}-content`:undefined,children:content})}else if(title){return React__namespace.cloneElement(content,{title})}else {return content}}_renderPopper(ariaContentId){const{backgroundColor,placement,variant}=this.props;return jsxRuntime.jsx(TooltipPopper,{anchorElement:this.state.anchorElement,placement:placement,autoUpdate:this.props.autoUpdate,viewportPadding:this.props.viewportPadding,children:props=>jsxRuntime.jsx(TooltipBubble,{id:ariaContentId,style:props.style,backgroundColor:backgroundColor,variant:variant,tailOffset:props.tailOffset,isReferenceHidden:props.isReferenceHidden,placement:props.placement,updateTailRef:props.updateTailRef,updateBubbleRef:props.updateBubbleRef,onActiveChanged:active=>this.setState({activeBubble:active}),children:this._renderBubbleContent()})})}_getHost(){const{anchorElement}=this.state;return wonderBlocksModal.maybeGetPortalMountedModalHostElement(anchorElement)||document.body}_renderTooltipAnchor(uniqueId){const{autoUpdate,children,forceAnchorFocusivity}=this.props;const{active,activeBubble}=this.state;const popperHost=this._getHost();const shouldAnchorExist=autoUpdate?this.state.anchorElement:true;const shouldBeVisible=popperHost&&(active||activeBubble)&&shouldAnchorExist;const ariaContentId=`${uniqueId}-aria-content`;return jsxRuntime.jsxs(React__namespace.Fragment,{children:[jsxRuntime.jsx(TooltipAnchor,{forceAnchorFocusivity:forceAnchorFocusivity,anchorRef:r=>this._updateAnchorElement(r),onActiveChanged:active=>this.setState({active}),"aria-describedby":shouldBeVisible?ariaContentId:undefined,children:children}),shouldBeVisible&&ReactDOM__namespace.createPortal(this._renderPopper(ariaContentId),popperHost)]})}render(){const{id}=this.props;return jsxRuntime.jsx(wonderBlocksCore.Id,{id:id,children:uniqueId=>this._renderTooltipAnchor(uniqueId)})}constructor(...args){super(...args),this.state={active:false,activeBubble:false};}}Tooltip.defaultProps={forceAnchorFocusivity:true,placement:"top",variant:"subtle"};
55
62
 
@@ -57,3 +64,5 @@ exports.TooltipContent = TooltipContent;
57
64
  exports.TooltipPopper = TooltipPopper;
58
65
  exports.TooltipTail = TooltipTail;
59
66
  exports["default"] = Tooltip;
67
+
68
+ require("./index.css");
@@ -1,14 +1,13 @@
1
1
  import * as React from "react";
2
2
  import type { StyleType } from "@khanacademy/wonder-blocks-core";
3
3
  import type { State as PopperState } from "@popperjs/core";
4
- import type { CSSProperties } from "aphrodite";
5
4
  export type getRefFn = (arg1?: React.Component<any> | Element | null | undefined) => void;
6
5
  export type Offset = {
7
- bottom: CSSProperties["bottom"];
8
- top: CSSProperties["top"];
9
- left: CSSProperties["left"];
10
- right: CSSProperties["right"];
11
- transform: CSSProperties["transform"];
6
+ bottom: React.CSSProperties["bottom"];
7
+ top: React.CSSProperties["top"];
8
+ left: React.CSSProperties["left"];
9
+ right: React.CSSProperties["right"];
10
+ transform: React.CSSProperties["transform"];
12
11
  };
13
12
  export type Placement = "top" | "bottom" | "right" | "left";
14
13
  /**
@@ -24,8 +23,8 @@ export type TooltipVariant = "subtle" | "strong";
24
23
  * Subset of CSS properties to allow overriding some of the default styles
25
24
  */
26
25
  export type ContentStyle = {
27
- color?: CSSProperties["color"];
28
- padding?: CSSProperties["padding"];
26
+ color?: React.CSSProperties["color"];
27
+ padding?: React.CSSProperties["padding"];
29
28
  };
30
29
  export type PopperUpdateFn = () => Promise<null | Partial<PopperState>>;
31
30
  export type PopperElementProps = {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "4.2.17",
6
+ "version": "5.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -19,16 +19,30 @@
19
19
  "main": "dist/index.js",
20
20
  "module": "dist/es/index.js",
21
21
  "types": "dist/index.d.ts",
22
+ "sideEffects": [
23
+ "**/*.css"
24
+ ],
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/es/index.js",
29
+ "require": "./dist/index.js"
30
+ },
31
+ "./css": {
32
+ "import": "./dist/es/index.css",
33
+ "require": "./dist/index.css",
34
+ "default": "./dist/index.css"
35
+ }
36
+ },
22
37
  "dependencies": {
23
- "@khanacademy/wonder-blocks-core": "12.5.0",
24
- "@khanacademy/wonder-blocks-layout": "3.2.3",
25
- "@khanacademy/wonder-blocks-typography": "5.0.8",
26
- "@khanacademy/wonder-blocks-modal": "8.10.6",
27
- "@khanacademy/wonder-blocks-tokens": "18.2.1"
38
+ "@khanacademy/wonder-blocks-modal": "9.0.0",
39
+ "@khanacademy/wonder-blocks-tokens": "18.3.0",
40
+ "@khanacademy/wonder-blocks-typography": "6.0.0",
41
+ "@khanacademy/wonder-blocks-layout": "5.0.0",
42
+ "@khanacademy/wonder-blocks-core": "13.0.0"
28
43
  },
29
44
  "peerDependencies": {
30
45
  "@popperjs/core": "^2.10.1",
31
- "aphrodite": "^1.2.5",
32
46
  "react": "18.2.0",
33
47
  "react-dom": "18.2.0",
34
48
  "react-popper": "^2.3.0"